Skip to content

Conversation

@fakedev9999
Copy link
Member

Summary

Backport of #776 to release/v3.x.

This adds SP1Stdin caching to skip the 2-hour witness generation bottleneck in multi.rs and cost_estimator scripts.

Key Changes:

  • New witness_cache module with unified SP1Stdin caching (bincode serialization)
  • Both scripts use --cache flag to enable caching
  • Cache files at data/{chain_id}/witness-cache/{start_block}-{end_block}-stdin.bin
  • Documentation update with caching instructions

Original PR

#776

(cherry picked from commit 7bfa643)

* feat(witness-cache): add caching for witness generation

Add witness caching to reduce 2-hour bottleneck in multi.rs and cost_estimator scripts.
Cache WitnessData (not SP1Stdin) to disk with keys (chain_id, start_block, end_block).

New features:
- Witness cache module with save/load functions using rkyv serialization
- cfg_if conditional compilation for EigenDA support
- Three cache flags: --cache (default), --use-cache (load only), --save-cache (force regenerate)
- Multi-script integration with cache status messages
- Cost estimator parallel cache loads per batch range
- Comprehensive documentation on cache usage and management

Cache location: data/{chain_id}/witness-cache/{start_block}-{end_block}.bin
DA compatibility: Ethereum/Celestia compatible, EigenDA separate cache

Files changed:
- utils/host/src/witness_cache.rs (NEW)
- utils/host/src/lib.rs, Cargo.toml
- scripts/utils/src/lib.rs
- scripts/prove/bin/multi.rs
- scripts/utils/bin/cost_estimator.rs
- book/advanced/cost-estimation-tools.md (renamed from cost-estimator.md)
- book/SUMMARY.md

* fix(witness-cache): use SP1Stdin caching for cost_estimator to fix CI

- Add SP1Stdin cache functions using bincode (DA-agnostic)
- cost_estimator.rs now caches SP1Stdin instead of WitnessData
- Remove WitnessDataType type constraint that caused CI failures
- Fix race condition in multi.rs by using match pattern with graceful fallback

SP1Stdin is the same type regardless of which DA witness generator
produced it, so it works with generic host types. This fixes the CI
type mismatch error when running with --features celestia/eigenda.

* refactor(witness-cache): unify on SP1Stdin caching for DA-agnosticism

Switch both multi.rs and cost_estimator.rs to use SP1Stdin caching
instead of WitnessData caching. This fixes CI failures when running
with different DA feature flags (celestia, eigenda).

SP1Stdin is DA-agnostic - it's the same type regardless of which
witness generator produced it. This means cache files now work across
all DA types (Ethereum, Celestia, EigenDA).

Changes:
- Update multi.rs to cache SP1Stdin using bincode
- Simplify witness_cache.rs to only contain SP1Stdin functions
- Remove eigenda feature flag from utils/host (no longer needed)
- Update documentation to reflect SP1Stdin caching

* refactor(witness-cache): address PR review comments

- Use tracing macros instead of println/eprintln in multi.rs
- Fix DA compatibility docs: clarify that cache files are compatible
  between Ethereum ↔ Celestia, but NOT with EigenDA
- Simplify cache flags: remove --use-cache and --save-cache,
  keep only --cache for simpler UX

(cherry picked from commit 7bfa643)
@fakedev9999 fakedev9999 changed the title [v3.x backport] feat(scripts): add witness caching for multi and cost_estimator backport: feat(scripts): add witness caching for multi and cost_estimator Jan 30, 2026
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.

2 participants