Add streaming one-wesolowski compaction APIs#325
Add streaming one-wesolowski compaction APIs#325hoffmang9 wants to merge 9 commits intoChia-Network:mainfrom
Conversation
Introduce a fast C wrapper with streaming proof generation, incremental GetBlock optimization, and memory-budgeted (k,l) tuning, plus the minimal runtime/build infrastructure needed to embed chiavdf in multi-worker clients. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@Ealrann I'm hoping to cleanly upstream your changes so you can rely on chiavdf directly and not a fork. See the plan here: |
Guard the fast pairindex slot selection behind the existing x86/asm feature checks and return slot 0 on non-x86 targets, where threading counters are not compiled. Co-authored-by: Cursor <cursoragent@cursor.com>
Install cmake via Homebrew and export its bin path in the C libraries and wheel workflows so self-hosted macOS jobs don't fail when cmake is missing from PATH. Co-authored-by: Cursor <cursoragent@cursor.com>
…ocation. Track and roll back per-batch checkpoints when replaying a failed fast batch, and switch pairindex slot allocation to unsigned atomics to avoid negative modulo indexing after counter wraparound. Co-authored-by: Cursor <cursoragent@cursor.com>
Document that batch bounds use completed-iteration base values while OnIteration is normalized to 1-based indices to avoid ambiguity in replay tracking. Co-authored-by: Cursor <cursoragent@cursor.com>
Expose missing batch C bindings and debug visibility so downstream Rust tests can validate tuner behavior end-to-end. Co-authored-by: Cursor <cursoragent@cursor.com>
Default CHIA_VDF_FAST_COUNTER_SLOTS to 100 in threading.h so upstream builds keep lower BSS usage while allowing embedded deployments to override via compiler defines. Co-authored-by: Cursor <cursoragent@cursor.com>
Use one program-wide atomic slot allocator for `vdf_fast_pairindex()` so concurrent VDF computations started from different translation units cannot collide on shared fast counter slots. Co-authored-by: Cursor <cursoragent@cursor.com>
Reject k>=64 before any 64-bit left-shift and reuse validated bucket spans for allocation, indexing, and finalization loops so invalid parameter tuning cannot trigger undefined behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| #else | ||
| return 0; | ||
| #endif | ||
| } |
There was a problem hiding this comment.
Pairindex modulo can divide by zero
High Severity
vdf_fast_pairindex() computes slot % kSlots where kSlots comes from sizeof(master_counter). With the new CHIA_VDF_FAST_COUNTER_SLOTS macro, setting it to 0 makes master_counter length 0, and the modulo becomes undefined behavior (likely crash) in fast VDF mode.
Additional Locations (1)
|
Oh, yes the plan is perfect. I'll definitely update the wesoforge client to use the main chiavdf. Note: the plan mentions "Trick 2 (unreleased, on side branch)", but in fact trick 2 was properly merged on |


Summary
c_bindings/fast_wrapperAPI surface for streaming one-wesolowski proof generation wheny_refis known up frontGetBlockand memory-budgeted(k, l)tuning to improve compaction-worker throughput/memory behaviorvdf_fast_pairindex,quiet_mode,fastlibtarget, PIC/PIE options) and document the path indocs/bluebox_compaction.mdTest plan
git log -1 --show-signature)origin/mainonly includes intended PR1 filesMade with Cursor
Note
High Risk
Touches core VDF execution (
repeated_squarecallbacks, counter slotting, stdout behavior) and adds substantial new proving logic and build targets, so regressions could affect correctness/performance or embedded concurrency.Overview
Adds a new
src/c_bindings/fast_wrapperC API for fast one-wesolowski proving, including a streaming mode that requiresy_refup front (plus an optional incrementalGetBlockimplementation), a memory-budgeted(k,l)tuner, progress callbacks, and optional per-thread debug stats/parameter introspection; also adds a batch API for multiple streaming jobs.Updates the core VDF loop to support embedding/multi-worker use: introduces
quiet_modeto suppress stdout, assigns per-threadvdf_fast_pairindex()slots for fast counters, and addsOnBatchStart/OnBatchReplaycallback hooks to allow streaming bucket updates to be rolled back when the fast path replays a batch.Improves build/CI support by adding a
fastlibstatic library target (libchiavdf_fastc.a), optional PIC/PIE flags and asm compilation rules inMakefile.vdf-client, ensurescmakeis present on macOS GitHub runners, and documents the compaction path indocs/bluebox_compaction.md.Written by Cursor Bugbot for commit 707b2f4. This will update automatically on new commits. Configure here.