-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: add realloc
constraint group
#1943
Conversation
open discussion on how to handle the data zeroing option in the currently set to |
realloc
constraint grouprealloc
constraint group
realloc
constraint grouprealloc
constraint group
Co-authored-by: Armani Ferrante <[email protected]>
We should add docs on this here https://github.com/project-serum/anchor/blob/master/lang/derive/accounts/src/lib.rs before merging. |
Does |
Its for zero initializing new memory, however, the docs have this caveat...
|
@callensm based on that comment it sounds like one would almost never need to pass in that parameter. Nevertheless, I'm thinking we should force the developer to be explicit in their intention and pass in this parameter regardless, so that they at least are forced to read the docs and understand what is happening. It's ugly, but a bit safer in the event there's a reason one actually needs to re-zero-initialize (e.g., they call try_accounts manually in the instruction handler). |
@armaniferrante sounds good. next commit will contain resolutions for your suggestions above (renaming |
__field_info.data_len().checked_sub(#new_space).unwrap() | ||
}; | ||
|
||
if __delta_space > 0 { |
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.
from the solana source code:
/// Note: Account data can be increased within a single call by up to
/// `solana_program::entrypoint::MAX_PERMITTED_DATA_INCREASE` bytes.
perhaps we can give an informative error if delta_space exceeds this? Not sure what that error looks like on the Solana end.
This reverts commit 7fe39c6.
This reverts commit 7fe39c6.
Creates a new constraint group to include the usage of
realloc = <new_space>
,realloc::payer = <account>
, andrealloc::zero = <bool>
constraints.Handles the transfer of lamports between the reallocated and allocator accounts based on the delta-bytes (additive vs subtractive reallocation).
closes #1917