feat: Dump and apply state changes for a range of blocks. - #8628
Merged
Conversation
This simulates shard shadowing.
In order to fully correctly replay state changes and get matching state roots, all kinds of state changes need to be applied, including the ones which currently are filtered out. To achieve this I add a compilation feature.
Furthermore, DelayedReceipt{,Indices} state changes have no information about the shard they are coming from, which leads to two issues:
1) If two shards have a `DelayedReceipt` change, they will override one another, and the StateChanges column will contain only one of them.
2) We don't know to which shard to apply these state changes.
The solution is to encode ShardUId in the row key of the StateChanges column for these two kids of state changes.
The other kinds of state changes are matched to shards by their account_ids or receiver_ids.
Combination of these two solutions lets us have a backwards-compatible solution.
mm-near
reviewed
Feb 23, 2023
mm-near
suggested changes
Feb 23, 2023
Contributor
Author
|
@mm-near PTAL |
mm-near
approved these changes
Mar 9, 2023
| trie_key.clone(), | ||
| )); | ||
| } | ||
| let version_chunk = &suffix[..std::mem::size_of::<ShardVersion>()]; |
Contributor
There was a problem hiding this comment.
this code (505-523) should be put in a method of ShardUId ('deserialize_from_key'?)
And similarly - line 483 + 484 should be moved to ShardUid method too.
Contributor
Author
There was a problem hiding this comment.
Removed, as that code is already available as to_bytes() and try_from
| /// State root of the shard at the height of the first block with state changes. | ||
| state_root: StateRoot, | ||
| }, | ||
| /// Dumps state changes for a range of blocks from --height-from to --height-to inclusive. |
Contributor
There was a problem hiding this comment.
so this dumps it for all the shards, right?
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This simulates shard shadowing.
In order to fully correctly replay state changes and get matching state roots, all kinds of state changes need to be applied, including the ones which currently are filtered out. To achieve this I add a compilation feature.
Furthermore,
DelayedReceipt{,Indices}state changes have no information about the shard they are coming from, which leads to two issues:DelayedReceiptchange, they will override one another, and the StateChanges column will contain only one of them.The solution is to encode
ShardUIdin the row key of theStateChangescolumn for these two kids of state changes.The other kinds of state changes are matched to shards by their
account_ids orreceiver_ids. Combination of these two solutions lets us have a backwards-compatible solution.