Skip to content

fix(l1): validate incoming payloads even when the node is syncing. #2426

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mpaulucci
Copy link
Collaborator

@mpaulucci mpaulucci commented Apr 8, 2025

Motivation
We should be able to do payload validations even when the node is in a sync process (except if it's snap sync).

Description

  • Refactored some code to make it flatter
  • Removed early return when the node is syncing
  • minor renames for clarity sake.

Copy link

github-actions bot commented Apr 8, 2025

Lines of code report

Total lines added: 2
Total lines removed: 2
Total lines changed: 4

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/sync_manager.rs       | 130   | +1   |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/fork_choice.rs | 388   | -2   |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/payload.rs     | 684   | +1   |
+----------------------------------------------------+-------+------+

@mpaulucci mpaulucci marked this pull request as ready for review April 9, 2025 14:00
@mpaulucci mpaulucci requested a review from a team as a code owner April 9, 2025 14:00
Comment on lines +245 to +252
match apply_fork_choice(
&context.storage,
fork_choice_state.head_block_hash,
fork_choice_state.safe_block_hash,
fork_choice_state.finalized_block_hash,
)
.await
{
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't apply the fork choice if we are currently syncing, this can lead to false positives if snap sync is enabled

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, we need to be able to do it, since it's part of the spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

During an active snap sync we cannot rely on the current state (any block we have in the store may not have its state available), we cannot fetch a block from the store and set it as head if we have no state for it. Essentially, during a snap sync we "have no state"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, added a check specifically for snap sync.


match fork_choice_res {
if context.syncer.sync_mode() == SyncMode::Snap {
warn!("Snap sync in progress, setting new head optimistically");
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds misleading, setting new head optimistically sound like we are setting it as canonical head of the chain. Also warn is a bit too harsh for something that is regular behaviour. It is also too spammy as fcu happen quite often

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed with warn, but aren't we setting the new head as the canonical head of the chain in this case?

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.

2 participants