simulators/lean: add spec-assets suites#1480
Merged
Merged
Conversation
8 tasks
pablodeymo
pushed a commit
to lambdaclass/ethlambda
that referenced
this pull request
May 11, 2026
## Summary - Adds an opt-in `/lean/v0/test_driver/...` HTTP router gated by `HIVE_LEAN_TEST_DRIVER`, enabling the new lean spec-asset suites from [ethereum/hive#1480](ethereum/hive#1480) (`lean-spec-tests-{fork-choice,state-transition,verify-signatures}`) to drive ethlambda over HTTP. - In driver mode the binary skips the BlockChain actor and P2P swarm entirely and serves only the four new endpoints plus `/lean/v0/health`. State lives behind `Arc<RwLock<Store>>` so each `fork_choice/init` request replaces the store and a single container can replay many fixtures. - Reuses the production code paths (`store::on_tick` / `on_block_without_verification` / `on_gossip_*`, `state_transition::state_transition`, `verify_block_signatures`) so the driver exercises the same logic as the consensus stack. - Lifts the fork-choice and verify-signatures fixture deserialization types out of `crates/blockchain/tests/` into the shared `ethlambda-test-fixtures` crate so the RPC handler and offline spec-test runner consume the same JSON schemas. ### Endpoints (camelCase per the hive contract) ``` POST /lean/v0/test_driver/fork_choice/init -> 204 / 400 POST /lean/v0/test_driver/fork_choice/step -> { accepted, error?, snapshot } POST /lean/v0/test_driver/state_transition/run -> { succeeded, error?, post? } POST /lean/v0/test_driver/verify_signatures/run -> { succeeded, error? } ``` ### Hive run result End-to-end run against a local hive instance with ethlambda built from this branch — all three spec-asset suites green: | Suite | Result | |---|---| | `lean-spec-tests-fork-choice` | **85/85** ✅ | | `lean-spec-tests-state-transition`| **51/51** ✅ | | `lean-spec-tests-verify-signatures`| **12/12** ✅ | | **Total** | **148/148** ✅ | First fork-choice run was 84/85: a single fixture (`test_store_from_anchor_rejects_mismatched_state_root`) caught a missing anchor invariant in the init handler. Fix in `1aa9f8f` enforces `block.state_root == state.tree_hash_root()` (with the header's `state_root` zeroed), mirroring Ream's check, and a new e2e regression test (`init_with_garbage_block_state_root_returns_400`) covers the exact shape. The rerun went 85/85. ### Commits - `41b86fd` feat(rpc): add Hive lean spec-assets test-driver endpoints - `b1f2ba5` fix(bin): check `HIVE_LEAN_TEST_DRIVER` before reading `--node-key` - `1aa9f8f` fix(rpc): reject anchors whose `block.state_root` disagrees with the state ## Test plan - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace --tests --all-targets -- -D warnings` - [x] `cargo test -p ethlambda-rpc` — 18 lib + 8 e2e tests (the 8 e2e tests use `tower::ServiceExt::oneshot` to exercise every endpoint with real JSON bodies; one of them is a regression test for the anchor invariant from `1aa9f8f`) - [x] `cargo test --workspace --lib --bins` — all suites green - [x] Smoke test the binary in driver mode with a non-existent `--node-key`; confirm short-circuit + `/lean/v0/health` + `/state_transition/run` respond correctly - [x] Hive `lean-spec-tests-fork-choice` — **85/85 pass** - [x] Hive `lean-spec-tests-state-transition` — **51/51 pass** - [x] Hive `lean-spec-tests-verify-signatures` — **12/12 pass**
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.