Skip to content

Test/stf block max attestations#605

Merged
tcoratger merged 6 commits intoleanEthereum:mainfrom
morelucks:test/stf-block-max-attestations
Apr 14, 2026
Merged

Test/stf block max attestations#605
tcoratger merged 6 commits intoleanEthereum:mainfrom
morelucks:test/stf-block-max-attestations

Conversation

@morelucks
Copy link
Copy Markdown
Contributor

@morelucks morelucks commented Apr 14, 2026

closes #573

This PR implements a new state transition test case test_block_with_maximum_attestations to verify that the consensus implementation correctly handles blocks containing the maximum allowed number of distinct AttestationData entries (MAX_ATTESTATIONS_DATA = 16).

Context

Verifying the state transition function's behavior at maximum capacity is critical for ensuring robustness against buffer overflows, incorrect iteration, and state tracking limits. This test specifically exercises the multi-stage justification tracking mechanism in the State.

Changes

  • Added test_block_with_maximum_attestations to tests/consensus/devnet/state_transition/test_block_processing.py.
  • Strategy: Builds a linear chain of 16 blocks at justifiable slots (following the 3SF-mini specification rules). A final block at slot 60 includes 16 distinct AggregatedAttestationSpec entries, each targeting one of the blocks in the chain.
  • Validator Reuse: Safely recycled the 12 available test validators to produce 16 distinct attestations without triggering double-voting errors (since each targets a different root).
  • Justification Tracking: Verified that the state correctly initializes and maintains 16 concurrent justification trackers for the distinct roots.

Verification

The test was verified using the fill tool:

uv run fill --fork=devnet --clean -n auto -k test_block_with_maximum_attestations

@tcoratger
Copy link
Copy Markdown
Collaborator

@morelucks Looks like we have a bunch of failures, can you check?

@morelucks
Copy link
Copy Markdown
Contributor Author

@tcoratger on it

@tcoratger tcoratger force-pushed the test/stf-block-max-attestations branch 7 times, most recently from dbc1232 to b83663a Compare April 14, 2026 21:09
Add fork choice fillers testing the MAX_ATTESTATIONS_DATA boundary.

- test_block_with_maximum_attestations: block at the exact limit is accepted
- test_block_exceeding_maximum_attestations_is_rejected: block with one
  extra entry is rejected by Store.on_block

The limit is enforced in the fork choice layer (Store.on_block), so both
tests live as fork choice fillers rather than state transition tests.

To support the rejection test, extend build_signed_block_with_store to
handle forced_attestations — entries that bypass the block builder's MAX
cap but carry valid signatures and state root.

Closes leanEthereum#573

Co-Authored-By: morelucks <morelucks@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger force-pushed the test/stf-block-max-attestations branch from b83663a to 19d5ef5 Compare April 14, 2026 22:09
@tcoratger tcoratger merged commit 040a905 into leanEthereum:main Apr 14, 2026
12 of 13 checks passed
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.

test(st): block with maximum attestations (16 AttestationData entries)

2 participants