Skip to content

core/blockstm, core: exclude base-code senders from V2 nonce pre-compute; harden witness parity harness - #2383

Merged
cffls merged 2 commits into
developfrom
jerry/v2-sender-nonce-precompute
Sep 4, 2026
Merged

core/blockstm, core: exclude base-code senders from V2 nonce pre-compute; harden witness parity harness#2383
cffls merged 2 commits into
developfrom
jerry/v2-sender-nonce-precompute

Conversation

@cffls

@cffls cffls commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

V2 BlockSTM nonce pre-compute. computeSenderNonces pre-assigns nonces for senders with two or more txs in a block, on the assumption that only the sender's own txs (or an in-block EIP-7702 auth-list entry, already excluded) can move its nonce. A sender that carries a delegation designator at base state breaks that assumption: any CALL into it runs the delegate code in the sender's own frame, and a CREATE there bumps the sender's nonce mid-block. Because a SenderNonces hit short-circuits PDB.GetNonce without recording a read, validation could never correct the stale value, so V2 and the serial processor could disagree on such a block. Senders with base-state code are now excluded from the pre-compute and take the MVStore-aware nonce path (read recorded and validated), matching serial. Adds V2Env.BaseCodeSize, a computeSenderNonces unit case, and an integration test that runs a block with a base-state-delegated sender through V2.

Witness parity harness and testdata. While verifying with the 241-block mainnet witness suite, TestV2BlockSTMAllBlocks reported 3 stateRoot mismatches on develop (not on master). Root cause was a testdata gap exposed by #2180's base-read-error detection, not an executor bug: three blocks contain a SetCodeTx whose authority was already delegated, and the authority's pre-block designator blob was missing from codes.tar.gz. Serial reads the same blob, gets nil, and silently proceeds (the harness never checked StateDB.Error); V2 now surfaces ReadErr and drops the tx at settlement, which the harness misreported as a root mismatch. master passed only because its V2 had no read-error detection at all. Fixes: the V2 runner fails on ReadErr, executeStatelessSerial surfaces StateDB.Error, both runners count serial errors as failures, the dataset builder now fetches 7702 authorities, keys its cache by block, and verifies fetched code against the account hash, and the three missing designators are supplied (two reconstructed and keccak-verified from the dataset's own auth lists, one via a historical eth_getCode).

Performance. Measured on the 241 mainnet blocks (48,920 txs):

per block
existing scheduling cost (BaseNonce, every sender) 3,247 µs
added cost (BaseCodeSize, multi-tx senders only) 5.1 µs avg, 24 µs worst
typical V2 block time (4 workers) ~90 ms

The exclusion fired 0 times across 5,371 multi-tx senders, and V2 exec/vfail counts are unchanged within noise (58,306/9,386 on develop vs 57,797/8,877 here).

diffguard (-base origin/develop, mutation on): complexity max 9, sizes/churn/dead-code pass, mutation 100% (12/12). It also reports a core -> core dependency cycle, which is a tool artifact (the diff adds no import lines to any non-test file and Go rejects self-imports).

Executed tests

  • BOR_BLOCKSTM_TEST=1 go test ./core/ -run TestV2BlockSTMAllBlocks — 241/241 consistent, 0 failures (238/241 on develop before the testdata fix; 241/241 on master).
  • BOR_BLOCKSTM_TEST=1 go test ./core/ -run TestAllBlocksConsistency — 241/241 consistent, 0 failures.
  • go test ./core/blockstm/ — full package.
  • go test ./core/ -run 'TestV2_DelegatedSenderNonceParity|TestV2_DelegateCodeReadConsistency|TestV2_ExistMissesPriorTxNonce|TestV2SerialParity_MetamorphicCreate2|TestV2ExecutorVsSerial_SeedCorpus'.
  • Before the fix, the new integration test's block is accepted by V2 and rejected by serial (nonce too low); after, both reject it identically.

Rollout notes

Consensus-relevant: changes which senders V2 pre-computes nonces for, bringing V2 into line with the serial processor for delegated senders. No protocol, config, or storage change; backwards-compatible; no coordinated upgrade required. Nodes running parallelevm.enable=true (the default) should pick this up in the next release. Everything else in the PR is test-only.

🤖 Generated with Claude Code

cffls and others added 2 commits September 2, 2026 14:04
…te code

V2's same-sender nonce pre-compute assumed only a sender's own txs, or an
in-block auth-list entry, can move its nonce. A sender carrying a delegation
designator at base state can also have its nonce bumped by any CALL into it
whose delegate code executes CREATE, which the auth-list exclusion does not
cover since the delegation predates the block. Route such senders through the
MVStore-aware nonce path so the read is recorded and validated, matching the
serial processor's result.

Adds V2Env.BaseCodeSize, a computeSenderNonces unit case, and an integration
test executing a block with a base-state-delegated sender through V2.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…stdata codes

The 241-block harness compared state roots even when V2 surfaced a ReadErr,
which drops the affected tx at settlement and shows up as a misleading root
mismatch; the serial helper never checked StateDB.Error at all. Both now fail
the block explicitly.

The dataset builder fetched code only for tx.To() addresses and cached it by
address without a block dimension, so EIP-7702 authorities re-delegated
between dataset blocks had stale or missing pre-block designators. Fetch
authorities too, key the cache by block, verify fetched code against the
account's code hash, and add the three designators missing for blocks
83014074, 83014100 and 83020871.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.23%. Comparing base (a9c3c3b) to head (5e5c19b).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2383      +/-   ##
===========================================
+ Coverage    55.21%   55.23%   +0.01%     
===========================================
  Files          912      912              
  Lines       165870   165880      +10     
===========================================
+ Hits         91591    91625      +34     
+ Misses       68818    68789      -29     
- Partials      5461     5466       +5     
Files with missing lines Coverage Δ
core/blockstm/v2_executor.go 81.02% <100.00%> (-0.39%) ⬇️
core/parallel_state_processor.go 62.57% <100.00%> (+0.09%) ⬆️

... and 17 files with indirect coverage changes

Files with missing lines Coverage Δ
core/blockstm/v2_executor.go 81.02% <100.00%> (-0.39%) ⬇️
core/parallel_state_processor.go 62.57% <100.00%> (+0.09%) ⬆️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@cffls

cffls commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@cffls
cffls merged commit ff04aef into develop Sep 4, 2026
23 of 25 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.

3 participants