You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* lang: Update duplicate mutable account validation logic to include only types that serialize on exit (#3946)
* lang: Update documentation for `dup` constraint
* chore: Fix PR link
* lang: Update duplicate mutable account constraint to include `Migration` type
* lang: Allow duplicates in remaining accounts
* fix: use strict AnchorError assertion in nested duplicate test
* lang: Introduce `DuplicateMutableAccountKeys` trait for composite account validation
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ The minor version will be incremented upon a breaking change and the patch versi
28
28
- idl: Fix `address` constraint not resolving constants that have numbers in their identifiers ([#4144](https://github.com/solana-foundation/anchor/pull/4144)).
29
29
- lang: Fix constant nested string generation in `declare_program!` ([#4158](https://github.com/solana-foundation/anchor/pull/4158)).
30
30
- idl: Fix `local_file` method not found for `proc_macro2::Span` error ([#4187](https://github.com/solana-foundation/anchor/pull/4187)).
31
+
- lang: Relax duplicate mutable account constraint to only check types that serialize on exit (`Account`, `LazyAccount`, `InterfaceAccount`, `Migration`) ([#4202](https://github.com/solana-foundation/anchor/pull/4202)).
Description: By default, Anchor will prevents duplicate mutable accounts to avoid potential security issues and unintended behavior.
44
-
The `dup` constraint explicitly allows this for cases where it's intentional and safe.
43
+
Description: By default, Anchor prevents duplicate mutable accounts to avoid
44
+
potential security issues and unintended behavior. The `dup` constraint
45
+
explicitly allows this for cases where it's intentional and safe.
45
46
46
-
**Note**: This constraint only applies to mutable accounts (`mut`). Readonly accounts naturally allow duplicates without requiring the `dup` constraint.
47
+
**Note**: This constraint only applies to mutable account (`mut`) types that
48
+
serialize on exit. Other types like `UncheckedAccount`, `Signer`,
49
+
`SystemAccount`, `AccountLoader`, `Program`, and `Interface` naturally allow
50
+
duplicates as they don't serialize data on exit.
47
51
48
52
```rust title="attribute"
49
53
#[account(mut, dup)]
@@ -330,7 +334,8 @@ Description: Create or validate close authority extension on the mint account.
Copy file name to clipboardExpand all lines: lang/derive/accounts/src/lib.rs
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,9 @@ use syn::parse_macro_input;
96
96
/// Allows the same mutable account to be passed multiple times within the same instruction context.<br>
97
97
/// By default, Anchor will prevents duplicate mutable accounts to avoid potential security issues and unintended behavior.<br>
98
98
/// The <code>dup</code> constraint explicitly allows this for cases where it's intentional and safe.<br>
99
-
/// This constraint only applies to mutable accounts (<code>mut</code>). Readonly accounts naturally allow duplicates without requiring the <code>dup</code> constraint.<br>
99
+
/// This constraint only applies to mutable account (`mut`) types that serialize on exit. Other types like <br>
0 commit comments