Commit 7bfa643
authored
feat(scripts): add witness caching for multi and cost_estimator (#776)
* 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 UX1 parent 2b40213 commit 7bfa643
File tree
10 files changed
+289
-74
lines changed- book
- advanced
- scripts
- prove/bin
- utils
- bin
- src
- utils/host
- src
10 files changed
+289
-74
lines changedSome 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 | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | | - | |
12 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
| |||
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
38 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
39 | 53 | | |
40 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
41 | 57 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | | - | |
47 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
48 | 87 | | |
49 | 88 | | |
50 | 89 | | |
| |||
55 | 94 | | |
56 | 95 | | |
57 | 96 | | |
58 | | - | |
| 97 | + | |
59 | 98 | | |
60 | 99 | | |
61 | 100 | | |
| |||
64 | 103 | | |
65 | 104 | | |
66 | 105 | | |
67 | | - | |
68 | | - | |
69 | 106 | | |
70 | 107 | | |
71 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
70 | | - | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
74 | 96 | | |
75 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
76 | 107 | | |
77 | 108 | | |
78 | 109 | | |
| |||
238 | 269 | | |
239 | 270 | | |
240 | 271 | | |
| 272 | + | |
241 | 273 | | |
242 | 274 | | |
243 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
0 commit comments