-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
|
lang/src/lib.rs
Outdated
@@ -82,6 +82,7 @@ pub trait Accounts<'info>: ToAccountMetas + ToAccountInfos<'info> + Sized { | |||
accounts: &mut &[AccountInfo<'info>], | |||
ix_data: &[u8], | |||
bumps: &mut BTreeMap<String, u8>, | |||
reallocs: &mut BTreeSet<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
realloc
constraint group from lang: addrealloc
constraint group #1943__delta_bytes
to ensure it is <= MAX_PERMITTED_DATA_INCREASEAccountReallocExceedsLimit
error code to rust and typescript for the data increase limit check