Skip to content
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 rent exemption skip to init and make init_if_needed check that acc is rent exempt if init is not needed #1234

Conversation

paul-schaaf
Copy link
Contributor

@paul-schaaf paul-schaaf commented Jan 4, 2022

fixes #1225, fixes #1224

@paul-schaaf paul-schaaf marked this pull request as ready for review January 5, 2022 00:31
};

let lamports = match rent_exempt {
ConstraintRentExempt::Skip => quote! {0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessarily what we want because it means the account will immediately be garbage collected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*at the end of the transaction so following ix can still use it.

I doubt this will be used much but to me it seems like the code a user would expect to be generated by that combination of constraints. I think the API is not great (not obvious that this causes init with 0) but at least it would provide the functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but yea maybe its better to just roll out the new rent/lamports feature asap and forbid rent_exempt = skip on init in the parser

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. rent_exempt = skip was originally added with the expectation that the account was created in a prior instruction (with what is now #[account(zero)]).

Copy link
Contributor Author

@paul-schaaf paul-schaaf Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm. The thing that sounds good to you is this #1234 (comment) comment, not the one before?

lang/syn/src/parser/accounts/constraints.rs Outdated Show resolved Hide resolved
lang/syn/src/parser/accounts/constraints.rs Outdated Show resolved Hide resolved
};

let lamports = match rent_exempt {
ConstraintRentExempt::Skip => quote! {0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. rent_exempt = skip was originally added with the expectation that the account was created in a prior instruction (with what is now #[account(zero)]).

@paul-schaaf paul-schaaf closed this Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants