test: Recover the blockchain test transaction senders #1634
Why this is here now?
Recovery is enabled only in the expected-invalid branch. The expected-valid path at lines 274-275 still calls apply_block() with the default recover_senders = false, so it continues trusting the JSON sender and can accept a purportedly valid block whose transaction signature does not recover. Opt the valid blockchain path into recovery as well (while leaving the t8n call explicitly opted out).
recover_sender() always uses RecoveryMode::strict, which rejects high-s signatures, but EIP-2 introduced that restriction only at Homestead. Enabling this path for every blockchain revision means an otherwise valid Frontier high-s transaction in an invalid block is now rejected as INVALID_SIGNATURE before the runner can check the block's intended invalidity. Make recovery/validation revision-aware: allow the malleable s range before EVMC_HOMESTEAD and enforce low-s from Homestead onward.
This passes a JSON-loaded transaction to an API whose documented precondition is that the transaction was decoded from tx_bytes. For protected legacy transactions, chain_id is not encoded independently—decoding derives it from v—so a JSON chainId inconsistent with v makes recovery hash the wrong preimage and later validates a chain ID that is not on the wire. Normalize the legacy chain ID from v before both recovery and execution.
Pull request overview
Adds transaction sender recovery to blockchain-test execution so invalid signatures are rejected directly.
Changes:
v values.Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
| ---- | ----------- |
| test/utils/block_transition.hpp | Adds sender-recovery option. |
| test/utils/block_transition.cpp | Recovers senders before execution. |
| test/state/transaction.cpp | Validates signature v. |
| test/blockchaintest/blockchaintest_runner.cpp | Enables recovery for invalid blocks. |
---
💡 <a href="/ipsilon/evmone/new/master?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Because the JSON path never decodes, and this is the only function that interprets v.
decode_transaction() bounds v while parsing (transaction.cpp:109-112 for legacy, :128 for typed), so a transaction that came from RLP can never reach here out of domain. A blockchain-test transaction is built field by field from rlp_decoded JSON, which applies no such bound, and this PR is the first caller to recover a sender from one. Without the check the v=34 cases of frontier/validation/bad_v_r_s derive y_parity = 1 from an even v, recover a stranger's address, and get rejected for its empty balance — got INSUFFICIENT_ACCOUNT_FUNDS, expected INVALID_SIGNATURE_VRS, 13 fixtures.
It sits immediately above the y_parity derivation because that is what it guards: the line below assumes v is one of the forms the comment describes.
It does duplicate the decoder's bound for now. The intended end state is the reverse — drop it from decode_transaction() so an out-of-range v is reported as INVALID_SIGNATURE rather than INVALID_ENCODING, which is what would let the over-broad {INVALID_ENCODING, "TransactionException.INVALID_SIGNATURE_VRS"} alternative come out of error_matching.cpp. That changes state-test behaviour, so I kept it out of this PR. Happy to fold it in if you would rather have it in one go.
Codecov Report
:x: Patch coverage is
91.66667% with 2 lines in your changes missing coverage. Please review.:white_check_mark: Project coverage is 97.70%. Comparing base (
56808b6) to head (1f4978b).:warning: Report is 2 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| test/blockchaintest/blockchaintest\_runner.cpp | 88.88% | 0 Missing and 1 partial :warning: |
| test/state/transaction.cpp | 50.00% | 0 Missing and 1 partial :warning: |
<details><summary>Additional details and impacted files</summary>
@@ Coverage Diff @@
## master #1634 +/- ##
==========================================
- Coverage 97.71% 97.70% -0.01%
==========================================
Files 171 171
Lines 15593 15602 +9
Branches 3607 3610 +3
==========================================
+ Hits 15236 15244 +8
Misses 269 269
- Partials 88 89 +1
| Flag | Coverage Δ | |
|---|---|---|
| eest-develop | 88.56% <87.50%> (-0.06%) | :arrow_down: |
| eest-develop-gmp | 26.65% <0.00%> (-0.02%) | :arrow_down: |
| eest-legacy | 18.83% <54.16%> (+1.66%) | :arrow_up: |
| eest-libsecp256k1 | 28.84% <0.00%> (-0.02%) | :arrow_down: |
| eest-stable | 88.56% <87.50%> (-0.06%) | :arrow_down: |
| evmone-unittests | 93.37% <50.00%> (-0.05%) | :arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| core | 96.06% <50.00%> (-0.02%) | :arrow_down: |
| tooling | 91.95% <95.45%> (+0.03%) | :arrow_up: |
| tests | 99.80% <ø> (ø) | |
| Files with missing lines | Coverage Δ | |
|---|---|---|
| test/utils/block\_transition.cpp | 100.00% <100.00%> (ø) | |
| test/blockchaintest/blockchaintest\_runner.cpp | 83.27% <88.88%> (-0.25%) | :arrow_down: |
| test/state/transaction.cpp | 98.87% <50.00%> (-1.13%) | :arrow_down: |
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
chfast
The runner trusted the sender the fixture supplies, so a transaction whose signature the test broke executed as that sender and the block was rejected by whatever rule it happened to break. Recover from the transaction's own encoding instead, and reject it when the signature does not recover. This removes the exemption added in #1632 and the TODO from #1623; the two fixtures added there now exercise the recovery.
recover_sender()also had to reject avoutside its domain, a rule onlydecode_transaction()enforced and the JSON path never runs. Without it thev=34cases offrontier/validation/bad_v_r_srecover a stranger's address and fail on its empty balance instead of on the signature — 13 blockchain fixtures.Recovery is opt-in via
BlockTransitionOptions, so t8n keeps using the sender it is given.