Skip to content

feat(tests): cover invalid fee caps, block numbers and BAL edge cases - #3875

Open
fselmo wants to merge 16 commits into
ethereum:forks/bogotafrom
fselmo:tests/fee-caps-recreation-bal-redelivery
Open

fselmo wants to merge 16 commits into
ethereum:forks/bogotafrom
fselmo:tests/fee-caps-recreation-bal-redelivery

Conversation

@fselmo

@fselmo fselmo commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

I'm adding tests for six gaps, plus a sync-payload framework fix and the exception-mapper entries the block-number test needs, one commit each:

  • Fee caps on both sides of 264 and 2128 for every fee-market transaction type, funded exactly or one wei short, plus the largest cap a full balance covers and one above it. No fixture had a fee cap of 2**64 or more.
  • A contract created and self-destructed in one transaction and recreated later in the same block: the next block reads the recreated storage, and the destroyed incarnation's slot stays empty.
  • A creation over a storage-only account whose new contract self-destructs in a frame that stops or reverts. Skipped with its storage-only neighbors until EIP-8253.
  • A framework fix: a block rejected for a defect outside its header and later accepted kept the rejected copy's sync payload, built on its parent's state. The accepted copy now replaces it and moves to the end. Only the new re-delivery test's engine_x fixture changes.
  • A block rejected for carrying the wrong block access list, whether the list decodes or not, is accepted when it arrives again with the right one.
  • test_bal_create2_selfdestruct_then_recreate_same_block gains a case where both incarnations write the same slot: only the recreation's write is recorded, as a change. Its four existing ids gain a recreation_untouched component.
  • A block's number must be its parent's plus one: the same number and one too many are both rejected, from Frontier on. No test changed a header's number before.
  • Exception-mapper entries for the messages geth, ethrex and erigon give for a wrong block number; reth already had one. geth and erigon look the parent up by number, so they report a missing parent.

Related Issues or PRs

#3778 will need to gate test_recreated_contract_storage_in_next_block with the other recreate tests once SELFDESTRUCT stops destroying.

Checklist

  • Ran fast static checks to avoid CI fails: just static (typecheck as plain mypy, since the optimized group does not build on my machine)
  • PR title has the form <type>(<area>): <description>

Cute Animal Picture

   /\_/\
  ( o.o )   checked every
   > ^ <    fee cap twice
  /     \
 (_)-(_)

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.48%. Comparing base (2d92885) to head (cda8b3e).

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/bogota    #3875      +/-   ##
================================================
+ Coverage         95.37%   95.48%   +0.10%     
================================================
  Files               677      677              
  Lines             41907    41907              
  Branches           3939     3939              
================================================
+ Hits              39969    40013      +44     
+ Misses             1359     1337      -22     
+ Partials            579      557      -22     
Flag Coverage Δ
unittests 95.47% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fselmo fselmo changed the title feat(tests): cover wide fee caps, recreated storage and BAL re-delivery feat(tests): cover invalid fee caps, block numbers and BAL edge cases Oct 21, 2026

@LouisTsai-Csie LouisTsai-Csie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, I left some comment for refactor idea, please take a look: fselmo#62

fselmo and others added 15 commits December 3, 2026 15:57
EIP-1559 only bounds fee caps below 2**256, so wider caps are valid whenever the balance covers them. Covers both sides of 2**64 and 2**128 for every fee-market type, plus the largest cap a full balance covers and one above it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A contract created and self-destructed in one transaction and recreated in a later one of the same block keeps only the recreation's storage, and the next block reads it from committed state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whether the frame that self-destructs the new contract stops or reverts, the old storage stays wiped. Skipped like its storage-only neighbors until EIP-8253.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block rejected for a defect outside its header and later accepted kept the rejected copy's sync payload, built on its parent's state. The accepted copy now replaces it and moves to the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block rejected for carrying the wrong block access list, whether the list decodes or not, must be accepted when it arrives again with the right one: its hash is the same both times.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When both incarnations of a contract destroyed and recreated in one block write the same slot, the access list records only the recreation's write, as a change rather than a read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add test_block_number: a second block numbered its parent's number, plus one, and plus two. Marked verify_sync, so the valid chain also gets a sync fixture.
geth, ethrex, reth and erigon reject a block whose number is off from its parent's with messages no mapper read. geth and erigon look the parent up by number, so they report a missing parent.
Renames the test after the rule it checks and says why the first block is valid. Drops the reth alternative, a storage error that only reth's blocktest runner reports; reth's engine path already gives the mapped message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cap test (#62)

* feat(test-fill): cover a redelivered block accepted below a later leaf

A block first rejected for its delivered list and then accepted below a
later leaf is never a sync-payload leaf, so the rejected copy's target,
built on the block's parent state, stays in syncPayloads. The test
expects only the final block's target and fails until that is fixed.

* refactor(tests): separate the cases in test_fee_cap_at_balance_limit

Each branch now states only its fee cap, expected error and post state;
building the transaction, the premise check and the funding run once
after it. The filled fixtures are unchanged.
A block rejected for its delivered list and later accepted below another leaf kept the rejected copy's sync payload, built on its parent's state. Any accepted copy now drops it, and the candidates are keyed by block hash.
The recreation factory dispatches on named calldata cases and writes named slots, opcode arguments are passed by keyword, and the re-delivered block now carries a block access list expectation.
A block rejected twice keeps its first place among the rejected leaves, and two rejected blocks at one height keep a target each. The engine_x format page now says which entry a consumer uses when a block hash was delivered more than once.
…s on

The sync payload above a block rejected and then accepted must have the state root of an authored empty block above it. The format page's rule for a hash delivered more than once now covers every lookup on the path.
Bogota now yields a type 6 frame transaction for with_all_typed_transactions, which has no to field and refuses copy(), so the module failed to fill there after the rebase.
@fselmo
fselmo force-pushed the tests/fee-caps-recreation-bal-redelivery branch from 75ccf9f to f1d0b8e Compare December 3, 2026 22:57
@fselmo

fselmo commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the follow-up PR @LouisTsai-Csie! I merged it here.

I fixed the stale sync target your test caught and keyed the candidates by block hash like you suggested, with a few more tests around that. The factory uses Switch and CalldataCase with named slots, and the opcode args are keywords now.

I also rebased. Let me know if I missed anything 👀

@fselmo
fselmo requested a review from LouisTsai-Csie December 3, 2026 23:02
consume wirex refused any fixture in which two payloads share a block hash, which a block rejected for its delivered access list and then accepted does. The accepted payload now stands for the hash, the first rejected one when none was accepted, and two accepted payloads with one hash still raise.
@fselmo

fselmo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@danceratopz could you look at the last commit here? This PR adds a test where a block is rejected for a wrong BAL and then accepted when it's delivered again, so both payloads share a block hash and resolve_sync_paths raised on those fixtures. This commit changes it so that when two payloads have the same hash, the resolver uses the one that was accepted. That's the real block and the one a peer would send during sync.

One thing I left alone is the collection ordering in wirex/conftest.py. It still classifies from the raw payload list, so these fixtures sort as invalid even though their only path is a valid sync now. Happy to change it if you see it differently 👀


edit: I also ran the re-delivery fixtures through consume wirex and enginex against all seven clients and everything passed with this commit!

@fselmo
fselmo requested a review from danceratopz December 3, 2026 23:15

This branch has not been deployed

No deployments
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.

4 participants