Skip to content
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

[resharding] Use state sync snapshots to get flat storage iterator at a precise block #9598

Merged
merged 4 commits into from
Oct 2, 2023

Conversation

shreyan-gupta
Copy link
Contributor

With the current implementation for flat storage iterator, we have the issue that we can not control the block over which we create the iterator. A solution to that is to use the snapshot mechanism from state sync.

We can assume that the snapshot would be created on all nodes as of the last block of an epoch.

The way we get the correct state for resharding is that we take the snapshot as of the prev_prev_hash and append the delta from the prev_hash so that the state of the child tries/shards matches that of the last block of prev epoch.

@shreyan-gupta shreyan-gupta marked this pull request as ready for review September 29, 2023 19:50
@shreyan-gupta shreyan-gupta requested a review from a team as a code owner September 29, 2023 19:50
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

LGTM, nice

Base automatically changed from shreyan/resharding/remove_unit_test to master October 2, 2023 17:36
@shreyan-gupta shreyan-gupta added this pull request to the merge queue Oct 2, 2023
Merged via the queue into master with commit 50e5ef4 Oct 2, 2023
14 checks passed
@shreyan-gupta shreyan-gupta deleted the shreyan/resharding/snapshot_iter branch October 2, 2023 18:23
nikurt pushed a commit that referenced this pull request Oct 3, 2023
… a precise block (#9598)

With the current implementation for flat storage iterator, we have the
issue that we can not control the block over which we create the
iterator. A solution to that is to use the snapshot mechanism from state
sync.

We can assume that the snapshot would be created on all nodes as of the
last block of an epoch.

The way we get the correct state for resharding is that we take the
snapshot as of the `prev_prev_hash` and append the delta from the
`prev_hash` so that the state of the child tries/shards matches that of
the last block of prev epoch.
})?;
let flat_storage_iter =
flat_storage_chunk_view.iter_flat_state_entries(None, None).map(|entry| {
let (key, value) = entry.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed it yesterday but we should properly propagate that error.

let new_shards = next_epoch_shard_layout
.get_split_shard_uids(shard_id)
.ok_or(Error::InvalidShardId(shard_id))?;
let mut state_roots: HashMap<_, _> =
new_shards.iter().map(|shard_uid| (*shard_uid, Trie::EMPTY_ROOT)).collect();

// Build the required iterator from flat storage and delta changes. Note that we are
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can you refactor this to a separate method?

hehe gotcha ;)

nikurt pushed a commit that referenced this pull request Oct 11, 2023
… a precise block (#9598)

With the current implementation for flat storage iterator, we have the
issue that we can not control the block over which we create the
iterator. A solution to that is to use the snapshot mechanism from state
sync.

We can assume that the snapshot would be created on all nodes as of the
last block of an epoch.

The way we get the correct state for resharding is that we take the
snapshot as of the `prev_prev_hash` and append the delta from the
`prev_hash` so that the state of the child tries/shards matches that of
the last block of prev epoch.
nikurt pushed a commit that referenced this pull request Oct 11, 2023
… a precise block (#9598)

With the current implementation for flat storage iterator, we have the
issue that we can not control the block over which we create the
iterator. A solution to that is to use the snapshot mechanism from state
sync.

We can assume that the snapshot would be created on all nodes as of the
last block of an epoch.

The way we get the correct state for resharding is that we take the
snapshot as of the `prev_prev_hash` and append the delta from the
`prev_hash` so that the state of the child tries/shards matches that of
the last block of prev epoch.
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.

[resharding] Use state sync snapshots to get flat storage iterator at a precise block
2 participants