test(spec): assert full post-state root against fixture postStateRoot#512
test(spec): assert full post-state root against fixture postStateRoot#512MegaRedHand wants to merge 2 commits into
Conversation
The STF spec-test runner captured `postStateRoot` only to satisfy deny_unknown_fields; the per-field `post` checks left any state field they don't enumerate unpinned. Assert the full post-state hash_tree_root against the fixture's postStateRoot so the whole state is verified on every successful transition. Mirror the same data in the Hive test driver: expose the full post-state root in the state_transition/run response so the simulator can perform the equivalent whole-state check. It previously reported only latest_block_header.state_root (a state field), never the SSZ root of the entire post-state.
966cf2a to
8b113c9
Compare
🤖 Codex Code ReviewNo material findings in the diff. The STF test change in crates/blockchain/state_transition/tests/stf_spectests.rs:54 strengthens correctness by checking the full SSZ Residual risk: the response-schema addition at crates/net/rpc/src/test_driver.rs:167 is not locked by an e2e assertion in crates/net/rpc/tests/test_driver_e2e.rs:225. I would add a check for I could not run the Rust tests in this environment because Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Kimi Code ReviewThe PR adds post-state root verification to both the spectest runner and the Hive RPC test driver. This is a good hardening measure that ensures the full SSZ state root matches expectations, catching any state field discrepancies not covered by per-field assertions. Review:
Consensus/Security:
Verdict: LGTM. The changes improve test robustness without affecting production consensus logic. The only suggestion is improving the error message formatting for the root mismatch case. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
Greptile SummaryThis PR adds full post-state root checks and exposes the root to Hive. The main changes are:
Confidence Score: 4/5The fixture assertion path needs a fix before merging because missing roots still bypass the full-state check.
crates/blockchain/state_transition/tests/stf_spectests.rs
|
| Filename | Overview |
|---|---|
| crates/blockchain/state_transition/tests/stf_spectests.rs | Adds the full-state comparison, but missing fixture roots still disable it. |
| crates/blockchain/state_transition/tests/types.rs | Updates the field documentation while retaining optional deserialization. |
| crates/net/rpc/src/test_driver.rs | Adds the full state root to the camelCase Hive response. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
crates/blockchain/state_transition/tests/stf_spectests.rs:60
**Missing Root Skips Full Check**
When a successful fixture omits `postStateRoot`, this branch silently skips the full-state assertion and relies on the partial `post` fields. The current fixture corpus omits this field, so unlisted state changes can still pass; a successful fixture should instead fail when the expected root is missing.
Reviews (1): Last reviewed commit: "test(spec): assert full post-state root ..." | Re-trigger Greptile
🤖 Claude Code ReviewReview: PR 512 — assert full post-state root against fixture
|
The Hive lean simulator (simulators/lean/src/scenarios/spec_assets.rs, StateTransitionPost) has no postStateRoot field and does not use deny_unknown_fields, so exposing post_state_root in the state_transition/run response was inert: nothing consumes it. Remove it. The functional whole-state check lives in the offline STF runner.
What
Turns the STF fixtures'
postStateRootfield into an actual assertion instead of a parse-only placeholder.Why
The STF spec-test runner captured
postStateRootonly to satisfydeny_unknown_fields. The per-fieldpostchecks pin only the fields a fixture chooses to enumerate, leaving any other state field unverified. Comparing the full post-statehash_tree_rootagainst the fixture'spostStateRootpins the entire state on every successful transition.Changes
state_transition/tests/stf_spectests.rspost_state.hash_tree_root() == postStateRoot.state_transition/tests/types.rs#[allow(dead_code)]onpost_state_root; document its new role.Testing
cargo test -p ethlambda-state-transition --release --test stf_spectests-> 71 passed (59 fixtures exercise the new check).cargo fmt --all,cargo clippy -p ethlambda-rpc -p ethlambda-state-transition --all-targetsclean.Based on
test/leanspec-fixture-check-hardening; targets that branch.