Skip to content

Conversation

@fedacking
Copy link
Contributor

Motivation

When the db had data, we should fullsync, not override the user's data

Description

  • Changes the fullsync option instead of snap to be any number instead of MIN_FULL_BLOCKS

@fedacking fedacking requested a review from a team as a code owner November 5, 2025 14:29
@github-actions github-actions bot added the L1 Ethereum client label Nov 5, 2025
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Lines of code report

Total lines added: 0
Total lines removed: 17
Total lines changed: 17

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/sync.rs               | 1379  | -3   |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/fork_choice.rs | 356   | -14  |
+----------------------------------------------------+-------+------+

debug!(
"Sync head is less than {MIN_FULL_BLOCKS} blocks away, switching to FullSync"
);
debug!("Sync head is found switching to FullSync");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be an info. Also, comma missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e4dc36d

}

// Update current fetch head
current_head = last_block_hash;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to revert #4985 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing in 636a594

current_head_number = last_block_number;

// If the sync head is less than 64 blocks away from our current head switch to full-sync
// If the sync head is not 0 we search to fullsync
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, if the sync head is 0 pero is less than X blocks away, we should also not do snap sync. Snap sync is for 1M blocks distance, not 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e4dc36d

// If the sync head is not 0 we search to fullsync
let head_found = sync_head_found && store.get_latest_block_number().await? > 0;
// Or the head is very close to 0
let head_close_to_0 = last_block_number < MIN_FULL_BLOCKS;
Copy link
Collaborator

@MegaRedHand MegaRedHand Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This skips snap-syncing when we have a few blocks in the DB, while the old logic compared the distance between head and sync-head.

Edit: this skips snap-syncing when the sync-head's block number is less than 10000

@github-project-automation github-project-automation bot moved this to In Review in ethrex_l1 Nov 5, 2025
@MegaRedHand MegaRedHand added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit d413c55 Nov 5, 2025
39 checks passed
@MegaRedHand MegaRedHand deleted the fullsync-if-db-not-empty branch November 5, 2025 16:41
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 5, 2025
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

When the db had data, we should fullsync, not override the user's data

**Description**

- Changes the fullsync option instead of snap to be any number instead
of `MIN_FULL_BLOCKS`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants