Skip to content

simulators/lean: add spec-assets suites#1480

Merged
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:add-forkchoice-tests
May 10, 2026
Merged

simulators/lean: add spec-assets suites#1480
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:add-forkchoice-tests

Conversation

@KolbyML

@KolbyML KolbyML commented May 10, 2026

Copy link
Copy Markdown
Member

No description provided.

@KolbyML KolbyML merged commit 9a2bd0b into ethereum:master May 10, 2026
6 of 7 checks passed
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**
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.

1 participant