Skip to content

ef_tests: add EF gossip_validation handler (#9232)#9256

Draft
latifkasuli wants to merge 1 commit intosigp:unstablefrom
latifkasuli:ef-tests/gossip-validation-9232
Draft

ef_tests: add EF gossip_validation handler (#9232)#9256
latifkasuli wants to merge 1 commit intosigp:unstablefrom
latifkasuli:ef-tests/gossip-validation-9232

Conversation

@latifkasuli
Copy link
Copy Markdown

@latifkasuli latifkasuli commented May 3, 2026

Issue Addressed

Adds support for the EF networking/gossip_validation test format. Addresses #9232.

Proposed Changes

Introduces a new gossip_validation handler in ef_tests, wired through cases.rs / handler.rs / tests/tests.rs, that drives gossip validation through BeaconChainHarness using the same verify_*_for_gossip paths the network layer uses in production.

The handler:

  • Loads meta.yaml, preloaded blocks, and per-message fixtures.
  • Imports preloaded blocks (respecting failed and payload_status) before driving messages.
  • Drives each message through the topic-appropriate verify_*_for_gossip API on BeaconChain.
  • Maps results to Expected::{Valid, Ignore, Reject} and asserts the EF-prescribed outcome.

meta.finalized_checkpoint override

The EF format initialises the store's finalized checkpoint before importing preloaded blocks. This handler imports first and then overrides, which would otherwise let block imports either advance or fork finality away from the requested checkpoint. To keep semantics sound while staying on the harness's existing build_genesis_state / preload path, the override is reconciled against the current fork-choice finality with this decision table:

current vs requested action
equal no-op
current.epoch > requested.epoch, current descends from requested no-op (same end state)
current.epoch > requested.epoch, sibling fork FailedToParseTest conflict
same epoch, different root FailedToParseTest conflict
current.epoch < requested.epoch, requested descends from current apply override
current.epoch < requested.epoch, sibling fork FailedToParseTest conflict

The override itself is a single test-only helper on ForkChoice, override_finalized_checkpoint_for_testing, that updates all four checkpoint fields (finalized, justified, unrealized justified, unrealized finalized) atomically and validates that the override root is present in proto_array. It is only reachable from the EF handler.

The override accepts only:

  • the genesis block root, or
  • an on-boundary preloaded block (block.slot() == checkpoint.epoch.start_slot(slots_per_epoch)), to avoid silently using a pre-boundary block's state_root for a checkpoint whose state should be advanced to the boundary slot.

Additional Info

Out of scope and explicitly rejected with descriptive errors (left for follow-up PRs):

  • Non-genesis anchor states.
  • Skipped epoch-boundary checkpoint roots (would require materialising the advanced boundary state).
  • Cross-branch finality overrides.

The remaining external blocker is real EF vectors under consensus-spec-tests/tests/.../networking/gossip_validation. Until those land, only the discovery shim test runs. Once present, the gate is:

cargo fmt --check --package ef_tests --package fork_choice
cargo test -p ef_tests --features ef_tests --test tests gossip_validation --no-run
cargo test -p ef_tests --features 'ef_tests fake_crypto' --test tests gossip_validation --no-run
cargo test -p ef_tests --features ef_tests --test tests gossip_validation
cargo test -p fork_choice --lib

Add support for the EF networking/gossip_validation test format in
ef_tests. The new handler loads metadata, preloaded blocks, and message
fixtures, then drives each message through the BeaconChain gossip
verification paths and checks Valid/Ignore/Reject outcomes.

Includes test-only fork-choice support for reconciling finalized
checkpoint overrides needed by the EF format.
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented May 3, 2026

CLA assistant check
All committers have signed the CLA.

@dapplion
Copy link
Copy Markdown
Collaborator

dapplion commented May 3, 2026

thanks for the contribution @latifkasuli can you disclose the AI usage if any in this PR?

@latifkasuli
Copy link
Copy Markdown
Author

thanks for the contribution @latifkasuli can you disclose the AI usage if any in this PR?

Hey @dapplion, thanks for asking. Yes, I should have disclosed this upfront.

A significant portion of this PR was AI-assisted. I used Cursor(Claude) during investigation, implementation drafting, and review of edge cases. I reviewed the full diff, made the final scoping/design decisions, adjusted the implementation, and ran the local verification gate listed in the PR body.

In particular, I understand and take responsibility for the constrained finalized_checkpoint support: genesis/on-boundary preloaded checkpoints only, skipped-boundary roots rejected, cross-branch overrides rejected, and non-genesis anchors left out of scope for this PR.

I also reviewed and edited the PR description/comments so they reflect my own understanding. Happy to split or scope this down further if you’d prefer.

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