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] Include state_changes in ApplySplitStateResult for split_state #9420

Closed
Tracked by #9418
shreyan-gupta opened this issue Aug 11, 2023 · 2 comments · Fixed by #9419
Closed
Tracked by #9418

[resharding] Include state_changes in ApplySplitStateResult for split_state #9420

shreyan-gupta opened this issue Aug 11, 2023 · 2 comments · Fixed by #9419
Assignees

Comments

@shreyan-gupta
Copy link
Contributor

shreyan-gupta commented Aug 11, 2023

For more context please view #9418

During resharding we need to split the trie/state changes across the child shards. This is mainly handled by the tries.apply_state_changes_to_split_states function which takes the set of trie state updates and distributes it as trie updates across the child shards as per account id.

During pre-processing runtime.apply_update_to_split_states function calls tries.apply_state_changes_to_split_states and saves the state changes as ApplySplitStateResult which would later be applied to the child shards during postprocessing after catchup.

Note that the WrappedTrieChanges (for each child shard) also contains the field called state_changes which wasn't being populated. This would eventually be used in the process_split_state function where we apply and commit the changes to the child shards to DB. We would use the state changes to update flat storage.

@wacban
Copy link
Contributor

wacban commented Aug 14, 2023

Thanks for the nice description! Makes sense.

I couldn't find the reference to state_changes in the process_split_state, can you point me to where is it? Or is that only going to be added later when you also ApplySplitStateResult to the flat storage?

@shreyan-gupta
Copy link
Contributor Author

shreyan-gupta commented Aug 14, 2023

@wacban, right, so, this task is to populate state_changes in ApplySplitStateResult and the actual use of the state_changes is a part of this PR #9421

Specifically, we use it here as result.trie_changes.state_changes()

                    if let Some(manager) = self.runtime_adapter.get_flat_storage_manager() {
                        let store_update = manager.save_flat_state_changes(
                            *block_hash,
                            *prev_hash,
                            block.header().height(),
                            result.shard_uid,
                            result.trie_changes.state_changes(),
                        )?;
                        manager.update_flat_storage_for_shard(*shard_uid, block)?;
                        self.chain_store_update.merge(store_update);
                    }

near-bulldozer bot pushed a commit that referenced this issue Aug 14, 2023
…_state (#9419)

For more context on the change, please look at #9420 and #9418
nikurt pushed a commit that referenced this issue Aug 15, 2023
…_state (#9419)

For more context on the change, please look at #9420 and #9418
nikurt pushed a commit to nikurt/nearcore that referenced this issue Aug 24, 2023
…_state (near#9419)

For more context on the change, please look at near#9420 and near#9418
nikurt pushed a commit that referenced this issue Aug 28, 2023
…_state (#9419)

For more context on the change, please look at #9420 and #9418
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 a pull request may close this issue.

2 participants