Cross-platform HW VDF client builds (Linux/macOS arm64/Windows) + callback/prover hardening#299
Conversation
|
hoffmang@MacBook-Air-2025-07 src % ./hw_vdf_client --list hoffmang@MacBook-Air-2025-07 src % ./hw_test |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Validate checkpoint stride and forms capacity arithmetic before allocation so malformed parameters fail fast instead of risking undersized storage. Co-authored-by: Cursor <cursoragent@cursor.com>
Fix a real race where readers could observe a new switch_iters value with a stale switch_index during the 2-wesolowski constant transition, which could compute an incorrect checkpoint slot. Use release store on switch_iters to pair with existing acquire load and preserve correct metadata visibility with negligible performance impact. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Prevent AVX2/AVX512 IFMA enablement unless OSXSAVE is present and XCR0 has required AVX/AVX-512 state bits, avoiding illegal-instruction crashes when OS context management is unavailable. Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid enabling AVX2/AVX512 execution paths when the OS hasn't enabled xstate, even when force env toggles are set, preventing illegal-instruction crashes. Co-authored-by: Cursor <cursoragent@cursor.com>
Store switch index and switch iteration in one atomic state so readers cannot observe mixed transition values during the 10-to-100 checkpoint switch. Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure hw_vdf_client_main calls WSACleanup on parse, list, and init_hw failure paths after successful WSAStartup so repeated in-process invocations do not leak Winsock references. 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.
Guard IncreaseConstants and GetPosition with forms_mutex so transition state publication and form index reads share one synchronization domain at the 10->100 switch. Co-authored-by: Cursor <cursoragent@cursor.com>
Collect positional port/VDF arguments while scanning all options so CLI parsing remains valid regardless of argument ordering. 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.
Disallow single-dash tokens from being treated as positional arguments and parse PORT/N_VDFS with strict numeric bounds so negative values cannot wrap through htons to unintended endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
Use a local guard in hw_vdf_client_main() so any successful WSAStartup() is always paired with WSACleanup(), including all early-return paths. Co-authored-by: Cursor <cursoragent@cursor.com>
Address Opus review follow-ups by making checkpoint position/stride decisions derive from a single transition_state snapshot and widening two-weso position indices to size_t to avoid narrowing risk. Also document the single-thread invariant for cached_form in TwoWesolowskiProver::GetForm. Co-authored-by: Cursor <cursoragent@cursor.com>
…ilds (#300) * Windows asm/ABI and runtime fixes * CMake: Windows + perf experiment options * CI: perf experiments and Windows benchmarking * ci: streamline test workflow * build: remove perf-only CMake toggles * core: gate AVX logging behind env flag * asm: document Windows ABI restore * docs: remove Windows perf notes * Nit note in README and clean up some language in test.yaml * Fix step name * various workflow clean ups and fix AVX512 flag * fix windows runners in test.yaml * more cmake instruction issues * harden finding boost on Mac intel * now cmake isn't always there... * more install cmake * fix ASAN, remove TSAN for windows runners * initiate windows dev env on ASAN runner * more ASAN windows issues - harden brew handling in cibuildwheel * giving up on ASAN * Add required linker flag for Windows asm - fix unchecked vector access * potentially fix bug in the 2weso test * consolidate 2weso fail-hunting phases 40-43 Collapse the contiguous phase-40 through phase-43 debug commits into one checkpoint while preserving the net tree state before phase 44. Co-authored-by: Cursor <cursoragent@cursor.com> * 2weso fail hunting 44 * 2weso fail hunting 45 * 2weso fail hunting 46 * cleanup: strip 2weso debug scaffolding after Windows root-cause isolation * ci - add an asm path to the c++ test path, fix HW headers * ci - bring windows back around to main ubuntu/macos testing * address cursor review issues * everything on windows should take the asm path * something about the windows asm path is broken * and we are off again searching for the asm issue * cache all the things and chase the asm issue * look closer at the ubuntu vs windows asm changes * Consolidate Windows asm investigation commits 1-17. Squash iterative CI and asm-path probing changes into one reviewable checkpoint before the final CI fix commit. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix Windows asm CI and align optimized test coverage (#304) * Instrument Windows asm failures and collect runtime evidence. Add targeted Windows probes and disassembly checks to localize crash offsets and failing asm paths. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix Windows asm addressing to be ASLR-safe. Convert global and table references to RIP-relative forms for Windows asm generation paths. Co-authored-by: Cursor <cursoragent@cursor.com> * Stabilize Windows gcd_unsigned dispatch control flow. Correct dispatch indexing and use explicit compare/branch selection to avoid executing table data. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix Windows CI probe exit-code handling. Ensure PowerShell helpers compare integer process exit codes so successful probes do not fail the workflow. Co-authored-by: Cursor <cursoragent@cursor.com> * Remove temporary Windows debug instrumentation. Drop crash-debug hooks and probes after validation, including the final vdf_fast cleanup. Co-authored-by: Cursor <cursoragent@cursor.com> * Align Windows optimized test coverage with other runners. Run the full optimized test set in the Windows PowerShell test step by removing ad-hoc iteration args and adding prover_test with fast mode. Co-authored-by: Cursor <cursoragent@cursor.com> * Clean up leftover no-op debug checks in fast path and tighten macOS-only branch selection in gcd_unsigned. This removes empty instrumentation cleanup blocks and keeps the dispatch path logic aligned with platform-specific behavior. Co-authored-by: Cursor <cursoragent@cursor.com> * Restore Windows jump-table dispatch path in gcd_unsigned. This reverts an accidental macOS-only condition change from the prior cleanup commit that caused 1weso_test to crash on Windows CI. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> * cleanup: finalize Windows asm follow-ups and include hygiene Tighten Windows asm/runtime plumbing and related docs/tests while removing stale duplicate include clutter from vdf headers. Co-authored-by: Cursor <cursoragent@cursor.com> * fix windows avx512 add table rip-relative access Include CHIA_WINDOWS in the avx512_add_table addressing branch so Windows emits LEA+ADD RIP-relative access instead of absolute table addressing. Co-authored-by: Cursor <cursoragent@cursor.com> * Remove unused max_test_iteration in 2weso_test. Drop dead local state that was computed and immediately discarded to avoid implying a missing iteration guard. Co-authored-by: Cursor <cursoragent@cursor.com> * fix gcd_unsigned compare against end_index Use end_index instead of size in the jump-table compare to match the mapped index logic and avoid incorrect branch selection. Co-authored-by: Cursor <cursoragent@cursor.com> * Harden callback state synchronization and update build/runtime tuning docs. This captures the current branch updates, including the TwoWesolowski position-locking fix and related CMake/parameter/readme adjustments for current CI work. Co-authored-by: Cursor <cursoragent@cursor.com> * Guard POSIX-only emulator hardware targets on Windows. Prevent `emu_hw_test` and `emu_hw_vdf_client` from being defined on Windows so CMake does not try to compile sources that depend on POSIX headers. Co-authored-by: Cursor <cursoragent@cursor.com> * Initialize FastAlgorithmCallback forms_capacity. Set forms_capacity when allocating FastAlgorithmCallback forms so all WesolowskiCallback subclasses consistently initialize capacity metadata for safe bounds checks. Co-authored-by: Cursor <cursoragent@cursor.com> * Harden macOS/Windows gcd_unsigned dispatch bounds check. Add the same a_end_index range guard used on Linux before the CMP/JE chain so out-of-range values jump to the error path instead of falling through to a kernel label. Co-authored-by: Cursor <cursoragent@cursor.com> * Define CHIAOSX for macOS CMake asm generation. Match the Makefile behavior so compile_asm emits Mach-O-compatible assembly on Intel macOS instead of falling back to Linux/ELF code paths. Co-authored-by: Cursor <cursoragent@cursor.com> * Refine Windows asm argument handling and remove unused SEH include. Allow asm_function Windows stack-arg loading to be toggled for internal call sites, and drop dead <excpt.h> from threading since no SEH constructs are used. Co-authored-by: Cursor <cursoragent@cursor.com> * Preserve non-Windows asm behavior and gate fallback logging. Keep Linux absolute addressing and restore macOS/Linux jump-dispatch parity with main, while making detached-thread fallback logging debug-only. Co-authored-by: Cursor <cursoragent@cursor.com> * Reply to Opus review with dispatch, bounds, and const-correctness fixes. This replies to Opus review feedback by fixing macOS gcd_unsigned end-index dispatch, aligning bounds checks across platforms and callbacks, enabling Windows AVX512 CI coverage, and removing unused asm/cast paths. Co-authored-by: Cursor <cursoragent@cursor.com> * Avoid synchronous fallback in TwoWesolowski prover start. Make prover form retrieval value-based and throw on thread-start failure so TwoWesolowski recursion preserves parallel proof generation instead of silently serializing work. Co-authored-by: Cursor <cursoragent@cursor.com> * Gate AVX512 IFMA dispatch on OS XSAVE/XCR0 state. Require OSXSAVE and XCR0 ZMM/opmask state in init_avx_flags() before enabling AVX-512 IFMA to prevent illegal-instruction crashes on unsupported OS configurations. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
Match the non-HW prover interfaces with main by returning forms by value, eliminating mixed pointer/value virtual signatures that surfaced after the ODR cherry-pick and destabilized cross-platform builds. Co-authored-by: Cursor <cursoragent@cursor.com>
Add a Linux-only switch to compare RIP-relative and absolute track_asm addressing from the same code path, and extend Ubuntu CI to build both variants, emit benchmark deltas, and upload asm/benchmark artifacts for reviewer verification. Co-authored-by: Cursor <cursoragent@cursor.com>
Use the vdf-client makefile for clean in the addressing benchmark step, and temporarily run short 2weso_test on Ubuntu optimized jobs to reduce CI runtime while preserving coverage elsewhere. Co-authored-by: Cursor <cursoragent@cursor.com>
…lute mode Remove the temporary Ubuntu A/B benchmark workflow changes and reinstate full optimized 2weso coverage, while restoring Linux track_asm accesses to absolute addressing by default. Co-authored-by: Cursor <cursoragent@cursor.com>
wjblanke
left a comment
There was a problem hiding this comment.
aok glad to see absolute back
Resolve the PR #307 merge conflict in vdf_base.hpp by adopting the shared prover header layout, and add explicit HW runtime wiring so emu/hw tool targets continue linking on macOS arm64. Co-authored-by: Cursor <cursoragent@cursor.com>
Include prover_runtime.o in HW_OBJS for Makefile.vdf-client so emu_hw_test and emu_hw_vdf_client resolve Prover/ParallelProver symbols after the prover header consolidation. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
.github/workflows/hw-build.yml, including smoke tests and platform artifacts.scripts/get-libft4222.sh(Linux/macOS)scripts/get-libft4222.ps1(Windows)@executable_pathrpath).Review Follow-ups Addressed (Opus)
TwoWesolowskiCallback::OnIteration()now uses a singletransition_statesnapshot for effective stride + position decisions under lock.klis retained only as a fast-path hint.size_tto remove narrowing/truncation risk and align withforms_capacity/array indexing.TwoWesolowskiProver::GetForm()returning&cached_form.Test Plan
HW Build (Ubuntu)HW Build (macOS arm64)HW Build (Windows)./scripts/get-libft4222.sh install && cd src && make -f Makefile.vdf-client emu_hw_test hw_test emu_hw_vdf_client hw_vdf_client./src/emu_hw_test 1 2000./src/emu_hw_vdf_client --listNote
Medium Risk
Touches build/CI plus low-level platform-specific code paths (Windows sockets, driver linking, asm/CPU-feature gating) that can easily break compilation or runtime on specific OS/toolchains. Logic changes are mostly defensive but affect hot-path callback checkpointing and feature detection.
Overview
Adds cross-platform CI coverage for the hardware VDF client: Ubuntu build now uses a shared FT4222 provisioning script and includes a basic smoke test; new jobs build+smoke-test+upload artifacts for macOS arm64 and Windows (Windows uses CMake/Ninja + MPIR checkout).
Introduces FT4222 driver download/install helpers (
get-libft4222.shfor Linux/macOS,get-libft4222.ps1for Windows) and updates build wiring (CMake +Makefile.vdf-client) to link the correct vendor libraries per-OS, add macOS@executable_pathrpath handling, and add Windows-specific defines/libs (MPIR,ws2_32) while avoiding generated-asm link collisions on Windows.Improves portability/stability of HW tools and emulator: replaces
usleep/sleepusage with portablestd::this_threadhelpers, adds Winsock lifecycle + socket wrappers + manual arg parsing inhw_vdf_client, and adjusts vendor header import macros for the emulator on Windows.Hardens core runtime behavior: adds overflow/ bounds checks in
OneWesolowskiCallback, makesTwoWesolowskiCallbacktransition state publication and indexing thread-safer via atomics/snapshots, updates AVX feature gating to respect OS xstate (XCR0), and adds small ABI/compile fixes for Windows/macOS (weak symbols, asm arg handling, header includes).Written by Cursor Bugbot for commit e42cabd. This will update automatically on new commits. Configure here.