Commit 4c9f42e
authored
feat(shadow): dummy XMSS proofs + sim-cost sleeps behind shadow-integration (lambdaclass#484)
## Summary
Ports zeam's Shadow-simulator **fake-XMSS** mode + rate-based **sim-cost
sleeps** into ethlambda, so the
[lean-shadow-fuzzer](https://github.com/kamilsa/lean-shadow-fuzzer) can
drive the client under Shadow without paying the multi-second leanVM
aggregation prover/verifier (which is also the thing that
stack-overflows the debug binary). Everything is behind the existing
`shadow-integration` Cargo feature; a stock build compiles **none** of
it and behaves identically, and `Cargo.lock` gains only one new dep edge
(`ethlambda` → `ethlambda-crypto`).
Two independent mechanisms, exactly as in zeam:
- **Fake XMSS** — a single process-global toggle that replaces the
aggregation prover/verifier with a deterministic stub: provers return a
fixed-size dummy proof, verifiers return `Ok(())`. Uniform across all
entry points (a fake aggregate feeding a real verify would mix
incompatible byte formats).
- **Sim-cost sleeps** — rate-based (`sleep = n / rate` seconds) sleeps
that model CPU cost on Shadow's virtual clock, applied whether or not
fake is on.
## New CLI flags (only under `--features shadow-integration`)
| Flag | Effect |
|------|--------|
| `--shadow-xmss-fake` | Replace the aggregation prover/verifier with a
deterministic stub (off by default). |
| `--shadow-xmss-aggregate-signatures-rate <f64>` | Sigs aggregated/sec;
injects `n/rate`s into aggregation. Unset or ≤0 disables. |
| `--shadow-xmss-verify-aggregated-signatures-rate <f64>` | Sigs
verified/aggregate/sec; injects `n/rate`s into Type-1 verify. |
| `--shadow-xmss-merge-rate <f64>` | Type-1 components merged into a
Type-2/sec; injects `n/rate`s into the block-proof merge. |
The four flags live in one feature-gated `ShadowOptions` struct
flattened into `CliOptions`; `main` calls `shadow_cost::init(...)` once
after arg parse.
## What changed
- **`ethlambda-crypto`**
- New `shadow-integration` feature + `shadow_cost` module: atomics
config (`init`, `fake_xmss`), rate-based delay helpers,
`FAKE_PROOF_SIZE`, and a dependency-free deterministic dummy-proof fill
(FNV-1a seed fold → SplitMix64). The dummy proof is seeded **only** from
what the real FFI binds (message, slot, child-proof bytes, participant
counts) so every node produces identical bytes for identical inputs —
reproducible Shadow runs, no consensus divergence.
- Feature-gated fake/sleep interception in all 7 aggregation/verify
functions. The fake branch sits after cheap arg validation but before
`ensure_prover_ready()`, so fake mode never even pays leanVM setup.
`AggregationBits` (who voted) stay real; only the SNARK bytes are
stubbed.
- **`ethlambda` (bin)** — the `ShadowOptions` flags, the transitive
feature enable, and the `init` wiring.
## Intentional deviations from zeam
1. Feature-gated rather than always-present (matches ethlambda's opt-in
Shadow model).
2. `--shadow-xmss-fake` is a real CLI flag (zeam uses env-only because
zigcli couldn't take another field; clap has no such limit).
3. CLI-only, no env fallback.
4. `aggregate_proofs` sleeps on `n = #children` (it has no raw sigs;
zeam models aggregate cost on raw count only, which would leave this
children-only path cost-free).
## Design note (zeam parity)
Only `verify_aggregated_signature` (Type-1) has a verify sleep.
`verify_type_2_signature` and `split_type_2_by_message` have **no**
modeled cost, matching zeam. So fake-mode block import (which verifies a
merged Type-2) incurs zero modeled verify cost — if Shadow ever
undercounts import-side verify time, that's the missing knob.
## Testing / verification
- `cargo test -p ethlambda-crypto --features shadow-integration` — new
`shadow_cost` unit tests (delays off/zero/proportional; deterministic
fill) + fake round-trip tests for the interception (dummy size,
determinism, message-sensitivity, fake verify accepts). All pass. (No
real XMSS keygen in the fake tests.)
- Stock build unchanged: `cargo build -p ethlambda[-crypto]`; stock
`--help` lists no `shadow` flags.
- Full binary under the feature: `cargo check -p ethlambda
--no-default-features --features shadow-integration` (the
`--no-default-features` drops jemalloc per the existing `compile_error!`
guard).
- `clippy -D warnings` and `fmt --check` clean in both stock and shadow
configs.
## How to build
```bash
# via the existing shadow build wrapper
make shadow-build
# then, e.g.
ethlambda ... --shadow-xmss-fake \
--shadow-xmss-aggregate-signatures-rate 22.7 \
--shadow-xmss-merge-rate 22.7
```1 parent 61981b3 commit 4c9f42e
7 files changed
Lines changed: 327 additions & 5 deletions
File tree
- bin/ethlambda
- src
- crates/common/crypto
- src
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 | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
110 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
304 | 331 | | |
305 | 332 | | |
306 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
166 | 182 | | |
167 | 183 | | |
168 | 184 | | |
| |||
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
177 | | - | |
| 193 | + | |
| 194 | + | |
178 | 195 | | |
179 | 196 | | |
180 | 197 | | |
| |||
201 | 218 | | |
202 | 219 | | |
203 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
204 | 237 | | |
205 | 238 | | |
206 | 239 | | |
| |||
224 | 257 | | |
225 | 258 | | |
226 | 259 | | |
227 | | - | |
| 260 | + | |
| 261 | + | |
228 | 262 | | |
229 | 263 | | |
230 | 264 | | |
| |||
240 | 274 | | |
241 | 275 | | |
242 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
243 | 291 | | |
244 | 292 | | |
245 | 293 | | |
| |||
257 | 305 | | |
258 | 306 | | |
259 | 307 | | |
260 | | - | |
| 308 | + | |
| 309 | + | |
261 | 310 | | |
262 | 311 | | |
263 | 312 | | |
| |||
272 | 321 | | |
273 | 322 | | |
274 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
275 | 332 | | |
276 | 333 | | |
277 | 334 | | |
| |||
310 | 367 | | |
311 | 368 | | |
312 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
313 | 385 | | |
314 | 386 | | |
315 | 387 | | |
| |||
321 | 393 | | |
322 | 394 | | |
323 | 395 | | |
324 | | - | |
| 396 | + | |
| 397 | + | |
325 | 398 | | |
326 | 399 | | |
327 | 400 | | |
| |||
341 | 414 | | |
342 | 415 | | |
343 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
344 | 422 | | |
345 | 423 | | |
346 | 424 | | |
| |||
391 | 469 | | |
392 | 470 | | |
393 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
394 | 480 | | |
395 | 481 | | |
396 | 482 | | |
| |||
0 commit comments