Commit da95706
authored
feat(rpc): Hive lean spec-assets test-driver endpoints (lambdaclass#357)
## 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**1 parent ee922d7 commit da95706
17 files changed
Lines changed: 1497 additions & 494 deletions
File tree
- bin/ethlambda/src
- crates
- blockchain
- src
- tests
- common/test-fixtures
- src
- net/rpc
- src
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
| |||
120 | 118 | | |
121 | 119 | | |
122 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
123 | 137 | | |
124 | 138 | | |
125 | 139 | | |
| |||
275 | 289 | | |
276 | 290 | | |
277 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
278 | 326 | | |
279 | 327 | | |
280 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
480 | | - | |
| 480 | + | |
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| |||
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | | - | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
1161 | 1169 | | |
1162 | 1170 | | |
1163 | 1171 | | |
| |||
1372 | 1380 | | |
1373 | 1381 | | |
1374 | 1382 | | |
1375 | | - | |
| 1383 | + | |
1376 | 1384 | | |
1377 | 1385 | | |
1378 | 1386 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
| 16 | + | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
| |||
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | | - | |
| 65 | + | |
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
| |||
161 | 157 | | |
162 | 158 | | |
163 | 159 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | 160 | | |
188 | 161 | | |
189 | 162 | | |
| |||
374 | 347 | | |
375 | 348 | | |
376 | 349 | | |
377 | | - | |
| 350 | + | |
378 | 351 | | |
379 | 352 | | |
380 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
0 commit comments