Skip to content

Feat/hint arena - #942

Draft
diegokingston wants to merge 5 commits into
chore/bump-ethrex-revfrom
feat/hint-arena
Draft

Feat/hint arena#942
diegokingston wants to merge 5 commits into
chore/bump-ethrex-revfrom
feat/hint-arena

Conversation

@diegokingston

Copy link
Copy Markdown
Collaborator

No description provided.

The non-constraining hint ecall (and its prover HINT table) is replaced
by untrusted 32-byte hint slots appended to the private-input region:

  [u32 len][data][pad8][u32 hint_count][u32 pad][32-byte slots]

Guests consume slots positionally (syscalls: hint_count/hint_slot/
next_hint/request_hint) and must still verify each hint in-circuit,
falling back to software on failure or arena exhaustion. A lying host
can only force fallbacks, never change the result. When hints are not
known beforehand, request_hint appends (hint_id, input) to a request
log above the private-input window; the host reads it back
(Memory::hint_requests / ExecutionResult::hint_requests), answers with
compute_hint, and re-runs with a complete arena
(executor::collect_hints — the two-pass flow).

- executor: encode_private_input_region (single source of truth for
  the wire format), hints threaded through Executor::new, ecall
  dispatch and HINT_* error variants removed
- prover: HINT table and its trace-builder/CPU plumbing removed;
  hints threaded through prove_*/count_*/Traces::from_*
- ethrex-crypto: field_inv/scalar_inv/decompress_r read from the
  arena (verify + software fallback kept)
- cli: --hints on execute/prove/count-elements, execute
  --record-hints for the recording pass
- guests: hint_arena (slot API) and ecrecover_hints (N recoveries);
  two-pass measurement drivers on the executor and prover
  (continuation) sides

Measured on 30 ecrecovers: 6.41M guest cycles with software fallback
vs 866k with arena hints (7.40x); continuation proof of the hinted
run verifies end-to-end (14 epochs @ 2^16).
@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Benchmark — real block (ethrex_mainnet_25368371.bin) (median of 3)

continuations · epoch 2^22 · 9 epochs

Metric main PR Δ
Peak heap 47973 MB 47942 MB -31 MB (-0.1%) ⚪
Prove time 136.340s 123.573s -12.767s (-9.4%) 🟢

-9.4% — beyond what 3 runs resolve. Use /bench-abba for a paired test of the same block (default 12 pairs, ~72 min, resolves ~1%).

Prove-time spread 2.0% (121.714s / 123.573s / 124.190s)

Commit: cd1d611 · Baseline: cached · Runner: self-hosted bench

@diegokingston
diegokingston changed the base branch from main to chore/bump-ethrex-rev August 19, 2026 20:29
@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Benchmark Results for modified programs 🚀

Command Mean [ms] Min [ms] Max [ms] Relative
head ecsm 2.6 ± 0.1 2.5 2.9 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head hashmap 111.4 ± 2.4 108.6 115.9 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head keccak 125.9 ± 2.5 123.3 131.5 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head syscall_commit 84.9 ± 0.6 84.1 85.8 1.00

The restack brought in the ethrex bump, which moved lambda-vm-ethrex-crypto
to ethrex 4f658c2b while the guest kept its direct dep at 156cb8d6 — two
distinct Crypto traits, so the guest no longer compiled. Unify on the bumped
rev (lockfile collapses to a single ethrex-crypto entry).
@github-actions

Copy link
Copy Markdown

Benchmark Results for unmodified programs 🚀

Command Mean [ms] Min [ms] Max [ms] Relative
base binary_search 59.5 ± 1.0 58.2 60.9 1.01 ± 0.02
head binary_search 59.0 ± 0.6 57.9 59.9 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base bitwise_ops 59.4 ± 1.5 58.1 61.3 1.00
head bitwise_ops 59.6 ± 1.6 57.9 61.2 1.00 ± 0.04
Command Mean [ms] Min [ms] Max [ms] Relative
base fibonacci_26 63.5 ± 0.8 62.7 64.9 1.00 ± 0.02
head fibonacci_26 63.3 ± 0.7 62.7 64.6 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base matrix_multiply 65.1 ± 0.7 64.1 66.3 1.00
head matrix_multiply 105.6 ± 108.6 64.9 413.8 1.62 ± 1.67
Command Mean [ms] Min [ms] Max [ms] Relative
base modular_exp 58.9 ± 0.6 58.2 60.0 1.00 ± 0.02
head modular_exp 58.8 ± 0.9 57.8 61.0 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base quicksort 63.4 ± 0.6 62.5 64.4 1.00 ± 0.01
head quicksort 63.1 ± 0.7 62.1 64.4 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base sieve 64.9 ± 0.3 64.5 65.5 1.00
head sieve 66.0 ± 2.5 64.6 72.9 1.02 ± 0.04
Command Mean [ms] Min [ms] Max [ms] Relative
base sum_array 77.1 ± 4.0 74.0 85.7 1.04 ± 0.05
head sum_array 74.5 ± 0.7 73.7 75.6 1.00

The removed hint ecall accelerated hint-consuming guests on EVERY prove,
no caller opt-in; the arena made acceleration opt-in, so hint-less flows
(plain cli prove, bench_abba.sh) silently proved the software-fallback
trace — measured on ethrex_10_transfers: 3.35M cycles without hints vs
1.31M hinted (the ecall baseline was 1.70M).

resolve_hints restores the always-on ergonomics: when the caller passes
an empty arena, prove_with_options_and_inputs / prove_continuation /
count_elements first run the recording pass (collect_hints) and prove
the hinted trace. Both runs commit the same output — the arena only
changes cost — so the statement being proved is unchanged. Guests that
request nothing get an empty arena and an identical trace; the only
cost is one extra execution, negligible against proving.

Regression coverage: test_prove_ecrecover_hints_auto_records_arena
asserts hint-less and explicit-arena calls produce identical element
counts and equal verified public outputs.
@diegokingston

Copy link
Copy Markdown
Collaborator Author

/bench

- cargo fmt over the hint-arena diff
- group private_input/hints paths into ProveInputPaths so cmd_prove and
  cmd_prove_continuation stay under clippy's too_many_arguments (8/7),
  matching the FlamegraphCliOptions precedent

Verified: cargo fmt --check --all plus all four CI clippy passes
(default, debug-checks, disk-spill, cuda) green; the ethrex fixture
checksum gate passes.
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