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

feat(l1): save header download checkpoint + skip downloading pre-pivot bodies + track pending sync [WIP] #1712

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Jan 14, 2025

Motivation
This PR tackles the following problems:

  • Having to download all headers for each sync cycle
  • Fork choice update & new payloads being applied on top of non-synced state
    And also temporarily simplifies snap syncing by not downloading bodies and receipts for blocks before the pivot. (WARNING: this goes against the spec but shouldn't be a problem for the time being)

Description

  • Stores the last downloaded block's hash in the DB during snap sync to serve as a checkpoint if the sync is aborted halfway (common case when syncing from genesis). This checkpoint is cleared upon succesful snap sync.
  • No longer fetches receipts or block bodies past the pivot block during snap sync
  • Add method sync_status which returns an enum with the current sync status (either Inactive, Active or Pending) and uses it in the ForkChoiceUpdate & NewPayload engine rpc endpoints so that we don't apply their logic during an active or pending sync.

Closes None

Copy link

github-actions bot commented Jan 14, 2025

| File                                                                        | Lines | Diff |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex/ethrex.rs                        | 339   | -1   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/net.rs                | 884   | -8   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/sync.rs               | 604   | +3   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/rpc/engine/fork_choice.rs | 269   | +4   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/rpc/engine/payload.rs     | 335   | +10  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/rpc/rpc.rs                | 450   | +16  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/engines/api.rs         | 162   | +3   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/engines/in_memory.rs   | 389   | +16  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/engines/libmdbx.rs     | 756   | +34  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/engines/utils.rs       | 46    | +14  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/storage.rs             | 1161  | +9   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/errors.rs                | 235   | -4   |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/gas_cost.rs              | 881   | -50  |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/precompiles.rs           | 955   | -245 |
+-----------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/vm.rs                             | 766   | -51  |
+-----------------------------------------------------------------------------+-------+------+

Total lines added: +109
Total lines removed: 359
Total lines changed: 468

@fmoletta fmoletta force-pushed the track-snap-state-simplified branch from d18d2b3 to 27e01f5 Compare January 14, 2025 20:43
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