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] Handling forks in memtrie during resharding #12714

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shreyan-gupta
Copy link
Contributor

@shreyan-gupta shreyan-gupta commented Jan 10, 2025

This PR is the implementation for handling forks in memtrie which may occur close to or at the resharding boundary.

For context on what the exact problem is and the solution, please see this Zulip post.


High level, we want to achieve the following: In case of forks close to the resharding boundary

  1. If a resharding parent split of shard has already happened
  2. If there's a block being processed for the parent as a fork

Then we want the process the fork block on top of both the children shards as well.


Main changes in this PR

  • ShardTries has a new member temp_split_shard_map that keeps track of parent memtrie splits. Note that we append "temp" in the name as we only keep track of splits where the child shares the frozen trie with parent. This entry should be removed as soon as the child memtrie becomes independent of parent.
  • As part of freeze_parent_memtrie function, we update temp_split_shard_map
  • Trie object now has children_memtries member that stores reference to the children memtries. This is generated using temp_split_shard_map from ShardTries.
  • TrieChanges now has a new field children_memtrie_changes that saves the changes from parent that are to be written to children.
  • Trie update function is modified to write the changes to children memtries along with parent memtrie. This is better viewed with "hide whitespaces" option.

The resharding tests for forks still continue to fail as now we are hitting an issue with flat storage resharding. That is out the scope for this PR.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 74.63768% with 35 lines in your changes missing coverage. Please review.

Project coverage is 70.66%. Comparing base (f9e403b) to head (380cfc0).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
core/store/src/trie/mod.rs 72.85% 7 Missing and 12 partials ⚠️
core/store/src/trie/shard_tries.rs 73.21% 4 Missing and 11 partials ⚠️
chain/chain/src/resharding/manager.rs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12714      +/-   ##
==========================================
+ Coverage   70.64%   70.66%   +0.02%     
==========================================
  Files         848      848              
  Lines      173732   173864     +132     
  Branches   173732   173864     +132     
==========================================
+ Hits       122725   122863     +138     
+ Misses      45875    45865      -10     
- Partials     5132     5136       +4     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.35% <0.00%> (-0.01%) ⬇️
linux 69.22% <65.94%> (+<0.01%) ⬆️
linux-nightly 70.26% <74.63%> (+0.03%) ⬆️
pytests 1.65% <0.00%> (-0.01%) ⬇️
sanity-checks 1.46% <0.00%> (-0.01%) ⬇️
unittests 70.49% <74.63%> (+0.02%) ⬆️
upgradability 0.20% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shreyan-gupta shreyan-gupta marked this pull request as ready for review January 11, 2025 06:01
@shreyan-gupta shreyan-gupta requested a review from a team as a code owner January 11, 2025 06:01
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.

1 participant