Skip to content

Comments

Implement weak subjectivity safety checks#7347

Merged
mergify[bot] merged 28 commits intosigp:unstablefrom
eserilev:weak-subjectivity-startup-check
Feb 10, 2026
Merged

Implement weak subjectivity safety checks#7347
mergify[bot] merged 28 commits intosigp:unstablefrom
eserilev:weak-subjectivity-startup-check

Conversation

@eserilev
Copy link
Member

Issue Addressed

Closes #7273

Proposed Changes

ethereum/consensus-specs#4179

@eserilev
Copy link
Member Author

hey @dapplion when you have a chance, could you take a look at what I have so far?

The general flow is

  • user sets the weak subjectivity period checkpoint via the existing wss-checkpoint flag
  • on startup, we make the weak subjectivity calculation, using the user provided ws checkpoint, the head snapshot and the most recent finalized checkpoint

If the user doesn't set a weak subjectivity checkpoint, what are we supposed to do here?

@eserilev eserilev added electra Required for the Electra/Prague fork enhancement New feature or request work-in-progress PR is a work-in-progress labels Apr 22, 2025
let Ok(finalized_block) = fork_choice.get_finalized_block() else {
panic!("TODO(ws)")
};
if !store.is_within_weak_subjectivity_period(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just use the head_snapshot.beacon_state to compute the weak subjectivity period. You don't need to fetch the head state's finalize state. For WS sync, the head state = the weak subjectivity checkpoint state. You don't need to fetch any more data:

  • compute ws_period from head state
  • get current epoch from clock
  • check current_epoch <= head_state.epoch + ws_period

No need to involve the store here

.safe_div(balance_churn_limit.safe_mul(200)?)?;
let weak_subjectivity_period = spec
.min_validator_withdrawability_delay
.safe_mul(epochs_for_validator_set_churn)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

@eserilev eserilev Apr 23, 2025

Choose a reason for hiding this comment

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

I'm using the updated forumla for electra

https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/weak-subjectivity.md#modified-compute_weak_subjectivity_period

I think the calc is simpler now that top ups are part of activation churn

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah right, please link it

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah but we probably need to support the pre-electra calculation as well

@dapplion
Copy link
Collaborator

If the user doesn't set a weak subjectivity checkpoint, what are we supposed to do here?

We should assert that the initial state is within the weak subjectivity period on any type of start.

We should also offer a flag such that

  • If flag set and starting from outside weak subjectivity period: big warn log, continue start
  • If flag not set and starting from outside weak subjectivity period: error, abort start

}
return Err(
"The current head state is outside the weak subjectivity period. It is highly recommended to purge your db and \
checkpoint sync. Alternatively you can accept the risks and ignore this error with the --ignore-ws-check flag.".to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should either summarize "the risks" or link to some resource of our own. Otherwise it's quite opaque to the users.

Copy link
Member Author

Choose a reason for hiding this comment

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

i've summarized the risks and linked to a blog post by vitalik

@eserilev eserilev added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Apr 24, 2025
@eserilev
Copy link
Member Author

Thanks for all the help Lion. I've made changes based on your feedback and added additional test coverage

Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Looks great now!

@eserilev eserilev added the v8.1.0 Post-Fulu release label Oct 14, 2025
@mergify
Copy link

mergify bot commented Oct 14, 2025

This pull request has merge conflicts. Could you please resolve them @eserilev? 🙏

@mergify mergify bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Oct 14, 2025
@eserilev eserilev added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Oct 14, 2025
@eserilev
Copy link
Member Author

@mergify requeue

@mergify mergify bot removed the dequeued label Feb 10, 2026
@mergify
Copy link

mergify bot commented Feb 10, 2026

Merge Queue Status

Rule: default


This pull request spent 29 minutes 56 seconds in the queue, including 28 minutes 1 second running CI.

Required conditions to merge
  • check-success=local-testnet-success
  • check-success=test-suite-success

Reason

Pull request #7347 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (details: 1 review requesting changes and 1 approving review by reviewers with write access.)

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify mergify bot added the queued label Feb 10, 2026
mergify bot added a commit that referenced this pull request Feb 10, 2026
@mergify mergify bot added dequeued and removed queued labels Feb 10, 2026
@eserilev
Copy link
Member Author

@mergify requeue

@mergify
Copy link

mergify bot commented Feb 10, 2026

Merge Queue Status

Rule: default


This pull request spent 31 minutes 13 seconds in the queue, including 29 minutes 46 seconds running CI.

Required conditions to merge
  • check-success=local-testnet-success
  • check-success=test-suite-success

Reason

Pull request #7347 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (details: 1 review requesting changes and 1 approving review by reviewers with write access.)

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify mergify bot added queued and removed dequeued labels Feb 10, 2026
mergify bot added a commit that referenced this pull request Feb 10, 2026
@mergify mergify bot added dequeued and removed queued labels Feb 10, 2026
@dapplion
Copy link
Collaborator

@mergify requeue

@mergify
Copy link

mergify bot commented Feb 10, 2026

Merge Queue Status

Rule: default


This pull request spent 31 minutes 3 seconds in the queue, including 28 minutes 53 seconds running CI.

Required conditions to merge
  • check-success=local-testnet-success
  • check-success=test-suite-success

@mergify mergify bot added queued and removed dequeued labels Feb 10, 2026
mergify bot added a commit that referenced this pull request Feb 10, 2026
@mergify mergify bot merged commit 56eb81a into sigp:unstable Feb 10, 2026
37 checks passed
@mergify mergify bot removed the queued label Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

electra Required for the Electra/Prague fork enhancement New feature or request hardening ready-for-merge This PR is ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants