near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.32k stars 623 forks source link

Flat storage resharding: basics #12035

Closed Trisfald closed 1 month ago

Trisfald commented 2 months ago

I would like to get some very early feedback on the direction I'm taking for flat storage resharding.

I added few lines of code to illustrate the general idea:

wacban commented 1 month ago

Can you confirm if this is roughly how it'll work?

Trisfald commented 1 month ago

Can you confirm if this is roughly how it'll work?

  • trigger

    • mark parent flat storage as ParentSplitting
    • create flat storage for both children and mark both as CreatingChild
    • send resharding request to some actor e.g. SyncJobsActor
  • handle resharding request

    • iterate parent and insert to either / both children
    • mark both children as Ready
    • remove parent
  • in the meantime chain is trying to add blocks to flat storage of children but since it's in CreatingChild state it stores deltas
  • eventually the children flat storages are ready and the flat storage head will be moved to its usual place (somewhere close to the final block)

Yes, correct! I'm not sure about few implementation details, like making or extending an actor or using threads / rayon. Is the actor the usual way to go?

Trisfald commented 1 month ago

Thanks for the feedback, I'll close this draft and reopen once I have more code committed