Skip to content

feat: Dump and apply state changes for a range of blocks. - #8628

Merged
near-bulldozer[bot] merged 9 commits into
masterfrom
nikurt-shadowing-tool
Mar 9, 2023
Merged

feat: Dump and apply state changes for a range of blocks.#8628
near-bulldozer[bot] merged 9 commits into
masterfrom
nikurt-shadowing-tool

Conversation

@nikurt

@nikurt nikurt commented Feb 22, 2023

Copy link
Copy Markdown
Contributor

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.

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.
@nikurt
nikurt requested a review from a team as a code owner February 22, 2023 17:33
@nikurt
nikurt requested a review from mm-near February 22, 2023 17:33
Comment thread tools/state-viewer/src/state_changes.rs Outdated
Comment thread chain/client/src/state_changes.rs Outdated
Comment thread chain/client/src/state_changes.rs Outdated
Comment thread chain/client/src/state_changes.rs Outdated
Comment thread core/store/src/trie/shard_tries.rs
Comment thread core/store/src/trie/shard_tries.rs Outdated
Comment thread core/store/src/trie/shard_tries.rs
Comment thread core/store/src/trie/shard_tries.rs Outdated
@nikurt
nikurt requested a review from mm-near February 24, 2023 15:58
@nikurt

nikurt commented Mar 6, 2023

Copy link
Copy Markdown
Contributor Author

@mm-near PTAL

Comment thread core/store/src/trie/shard_tries.rs Outdated
Comment thread core/store/src/trie/shard_tries.rs Outdated
trie_key.clone(),
));
}
let version_chunk = &suffix[..std::mem::size_of::<ShardVersion>()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, as that code is already available as to_bytes() and try_from

Comment thread core/store/src/trie/shard_tries.rs Outdated
Comment thread core/store/src/trie/shard_tries.rs Outdated
Comment thread core/store/src/trie/shard_tries.rs Outdated
/// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so this dumps it for all the shards, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, clarified

@near-bulldozer
near-bulldozer Bot merged commit cd12121 into master Mar 9, 2023
@near-bulldozer
near-bulldozer Bot deleted the nikurt-shadowing-tool branch March 9, 2023 16:30
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