Add version to AccountMeta #379
Replies: 6 comments 9 replies
-
|
+1 I think we can not expose this field in the runtime, for the sake of simplicity, and circle back if exposing it is necessary. |
Beta Was this translation helpful? Give feedback.
-
|
RPC calls may need a new API as well |
Beta Was this translation helpful? Give feedback.
-
|
Talked to @brooksprumo. His feedback is to focus on the account version in this SIMD, and leave the storage version alone. If storage format changes are wanted to save bytes, it should be done using TieredStorage which has even more gains. So the SIMD will just be Add Version to Accounts. Effects will be two fold:
|
Beta Was this translation helpful? Give feedback.
-
|
Other background on versioning the per-account hash: #319 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
Note we should only do this once there is a need. |
Beta Was this translation helpful? Give feedback.
-
|
Let's call this "account hash version" instead. This is needed for the accounts lattice hash, so that if we want to change the account structure, or how we hash a single account, that we can still compute the accounts lattice hash correctly. Some examples without changing the account structure:
Today we use blake3 for hashing. In the future there may be a new hash function, e.g. blake4, that we want to use. We want a way to update the hash function independent of the account structure.
Here's the order for hashing today: solana-improvement-documents/proposals/0215-accounts-lattice-hash.md Lines 101 to 107 in 6a41b4d Note that account data is in the middle. There have been discussions/recommendations that all variable length fields are moved to the end. Account data is the only variable length field today, so we would want to support moving account data to the end.
The account hash currently does not have hash domain, so it may collide with other non-account hashes. Yes, it is invalid to compare an account hash with a non-account hash. There has been a long-standing goal of putting all protocol hashes into their own hash domains to prevent these issues entirely. For the account hash, we'd want to support adding a hash domain. This would change the account hash algorithm itself, but not the account structure. E.g. we'd include the string "account" or "account v3" as the first field sent to the hash function. These were all examples of the how the account hash could change that is independent of the account structure itself changing. We'd also need to change the version if we change the account structure, yes. This is more to motivate why this concept is larger than versioning the account (or even more narrowly, the account metadata) itself. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is to solve two issues:
The format of an account in the snapshot cannot be changed, since there is only a single interpretation of accounts. Adding a version to the AccountMeta would allow changing the snapshot format to remove or add fields in the future. Currently there are 48 bytes of deprecated fields stored in every account.
The account hash cannot be changed as it requires mixing out the old hash. For example: Whether the rent epoch was included in the hash or not when the account was hashed in is required for adding the last written slot required for dynamic state rent (
To resolve both these issues: Version should be added to the AccountMeta, and should be included as part of the accounts hash.
To make this backwards compatible the initial version would be defined as 0, and bytes that are guaranteed to be zero in both the AccountMeta and the lattice hash calculation would be reused to store the version value: The upper 4 bits of the executable byte. This should provide support for up to 15 version rolls, while leaving 3 bits available in the byte for other data/changes in the future.
Any version updates will require a feature activation, and upon features activation, account versions would only be updated when an account is rewritten to a new bank.
Beta Was this translation helpful? Give feedback.
All reactions