This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Increases account hash's stack buffer to hold 200 bytes of data#35394
Closed
brooksprumo wants to merge 1 commit intosolana-labs:masterfrom
Closed
Increases account hash's stack buffer to hold 200 bytes of data#35394brooksprumo wants to merge 1 commit intosolana-labs:masterfrom
brooksprumo wants to merge 1 commit intosolana-labs:masterfrom
Conversation
db9183f to
41fd838
Compare
41fd838 to
6716fa6
Compare
Contributor
|
This repository is no longer in use. Please re-open this pull request in the agave repo: https://github.com/anza-xyz/agave |
Contributor
Author
|
Moved to anza-xyz#56 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When hashing an account, we create a buffer on the stack to reduce the number of unique hash calls to make. The buffer is currently 128 bytes. The metadata fields occupy 81 bytes, which leaves 47 bytes for the account's data.
On mnb today there is approximately 431 million accounts. Of that, approximately 388 million are token accounts. That's 90% of accounts. We should ensure the stack buffer can hold the account data for a token account.
Token accounts have a size of 165 bytes1. This size will be growing though. ATA and Token22 extensions will be larger too. Jon estimates 170-182 bytes is "safe"2.
Also, there are ~1 million stake accounts. They are 200 bytes.
We could size the stack buffer to hold 200 bytes, which will cover the vast majority of accounts. Currently, the vast majority of calls to hash an account have to perform a heap allocation.
TODO: metrics before and after
Summary of Changes
Increases account hash's stack buffer to hold 200 bytes of data
Footnotes
https://github.com/solana-labs/solana-program-library/blob/e651623033fca7997ccd21e55d0f2388473122f9/token/program/src/state.rs#L134 ↩
https://discord.com/channels/428295358100013066/977244255212937306/1212827836281524224 ↩