lang: adjust realloc implementation to safeguard max increase and idempotency#1986
Conversation
realloc implementation to safeguard max increase and idempotencyrealloc implementation to safeguard max increase and idempotency
realloc implementation to safeguard max increase and idempotencyrealloc implementation to safeguard max increase and idempotency
|
added |
There was a problem hiding this comment.
It seems that coverage of #[state] is lacking for zerocopy. Also, the second typo in the ix.has_receiver case for state interface impls is dead (and thus also untested), since #[interface] does not allow receivers in any of the trait's methods.
Also, I didn't see anything in rustdoc indicating that #[state] is deprecated...
|
|
| accounts: &mut &[AccountInfo<'info>], | ||
| ix_data: &[u8], | ||
| bumps: &mut BTreeMap<String, u8>, | ||
| reallocs: &mut BTreeSet<String>, |
There was a problem hiding this comment.
Since AFAICT nothing in docs signals that the Accounts trait is internal, this is a breaking change (with no real way around it if we want to implement the duplicate checking). It'd probably be a better idea to pass a new &mut TryAccountsContext struct or similar so that we can add more bits of state or data without needing to further modify this signature. Consider:
#[derive(Default)]
pub struct TryAccountsContext {
// private field to prevent the struct from containing only public fields; prevents users from
// constructing using a literal or pattern-matching/destructuring against this type
_marker: (),
pub bumps: BTreeMap<String, u8>,
pub reallocs: BTreeSet<String>,
}|
@armaniferrante is attempting to deploy a commit to the 200ms Team on Vercel. A member of the Team first needs to authorize it. |
Will this mean we won't be able to reallocate an account 2 times in the same instruction? We might want to reallocate an account with 0 space and then with try_accounts reallocate to original space to have the account "reinitialized". |
Co-authored-by: Ethan Wu <ethanwu10@gmail.com>
reallocconstraint group from lang: addreallocconstraint group #1943__delta_bytesto ensure it is <= MAX_PERMITTED_DATA_INCREASEAccountReallocExceedsLimiterror code to rust and typescript for the data increase limit check