Skip to content

p2w: Monitor and realloc() + rent adjuist on cfg account size change #305

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

Merged
merged 2 commits into from
Sep 27, 2022

Conversation

drozdziak1
Copy link
Contributor

This fixes a problem I observed together with Ali in devnet. Options in borsh result in byte count changes which means the underlying account size for contract state must grow/shrink together with the serialized byte length. This change implements such a scheme.

Copy link
Contributor

@jayantk jayantk left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

// Realloc if mismatched
if old_size != new_size {
accs.config.info().realloc(new_size, false)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe realloc the account and then set accs.config.1 = data, just to be safe? It looks like realloc doesn't change any bytes of the account, but you don't need to depend on that property if you reorder these two lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, will do

@drozdziak1 drozdziak1 merged commit b59bd70 into main Sep 27, 2022
@drozdziak1 drozdziak1 deleted the drozdziak1/p2w-set-config-dynamic-rent-adjustment branch September 27, 2022 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants