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

Avoid reprocessing deposits at startup #5432

Closed
ajsutton opened this issue May 5, 2022 · 8 comments
Closed

Avoid reprocessing deposits at startup #5432

ajsutton opened this issue May 5, 2022 · 8 comments
Assignees

Comments

@ajsutton
Copy link
Contributor

ajsutton commented May 5, 2022

Description

Currently at startup Teku loads all deposits from disk and replays them to recreate the merkle tree. We should investigate ways to store the merkle tree to disk instead to avoid the need to replay these deposits.

I believe you can just store the right hand edge of the tree since deposits always append but we'd likely have to update our merkle tree implementation to handle that.

Also need to ensure we can still create blocks that may need to get the merkle tree root omitting some of the more recent deposits (ie we may have received up to deposit 1000, but the Eth1Data in the current state is only at deposit 900, so we need to act as if we had a merkle tree only containing the 900 deposits).

@rolfyone
Copy link
Contributor

rolfyone commented May 5, 2022

potentially related: https://eips.ethereum.org/EIPS/eip-4881

@ajsutton
Copy link
Contributor Author

ajsutton commented Jun 1, 2022

New deposit merkle tree supporting snapshots has now been integrated but we're not actually using the snapshot functionality to avoid replaying deposits.

@zilm13
Copy link
Contributor

zilm13 commented Jul 8, 2022

I think I got a clear view on this finally and think it could be split into several PRs:

  1. Teku API to get finalized snapshot
  2. Teku flag to start from snapshot file (not sure on format) and perform all block events stuff without relying on its DB, instead query EL for everything
  3. Teku flag to make snapshot part of OnDiskStoreData, saving and loading to be able to restart without file option
  4. Optimization PR to not validate deposits which are already in finalized tree
  5. Remove block deposit events from DB

After 2nd we could be confident on performance of the approach and adjust a plan

@ajsutton
Copy link
Contributor Author

ajsutton commented Jul 8, 2022

Yep I think that looks good. The snapshot format should just be the DepositTreeSnapshot from the spec (SSZ encoded).

@zilm13
Copy link
Contributor

zilm13 commented Nov 8, 2022

@ajsutton I think we could close this one as completed.
Do I need to add something to docs or Changelog?
EIP https://eips.ethereum.org/EIPS/eip-4881 is still in draft.
There is API PR, but still not merged ethereum/beacon-APIs#245
Looks like we should keep everything in "--X"

@ajsutton
Copy link
Contributor Author

ajsutton commented Nov 8, 2022

I think we keep it open as long as the options are still --X since we're not supporting the feature yet. And we also want to include a deposit snapshot in our releases to avoid having to load all the deposits initially (which lets ELs prune data more aggressively). Possibly that should be a separate ticket as we need to work out a decent way to keep them reasonably up to date.

@zilm13
Copy link
Contributor

zilm13 commented Nov 9, 2022

Got you

And we also want to include a deposit snapshot in our releases to avoid having to load all the deposits initially

I forgot about this part, will try do something for it

@zilm13
Copy link
Contributor

zilm13 commented Apr 18, 2023

Completed with #7039

@zilm13 zilm13 closed this as completed Apr 18, 2023
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.

3 participants