Skip to content

fix: always store uncompressed CRS on disk in C++ native path#21972

Open
AztecBot wants to merge 6 commits into
nextfrom
claudebox/fix-bn254-crs-not-found
Open

fix: always store uncompressed CRS on disk in C++ native path#21972
AztecBot wants to merge 6 commits into
nextfrom
claudebox/fix-bn254-crs-not-found

Conversation

@AztecBot

@AztecBot AztecBot commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

PR #21112 renamed the CRS file from bn254_g1.dat to bn254_g1_compressed.dat and stored compressed data on disk. This broke machines with cached bn254_g1.dat — tests using init_file_crs_factory (no download) would fail.

This PR fixes the C++ native path to always store uncompressed bn254_g1.dat on disk:

  • Downloads compressed g1_compressed.dat from CDN (50% bandwidth savings)
  • Decompresses once in parallel and stores as uncompressed bn254_g1.dat (64 bytes/point)
  • No decompression on subsequent loads — reads uncompressed data directly

The JS/WASM path is unchanged from PR #21112 (compressed throughout — srs_init_srs decompresses in C++).

Changes

  • get_bn254_crs.cpp: Download compressed, decompress, store uncompressed bn254_g1.dat
  • crs_factory.test.cpp: Simplified to read uncompressed format; removed chunk hash tests (those test compressed-on-disk which we no longer do)
  • chonk.bench.cpp: Updated decompression benchmark to compress from uncompressed file
  • crs/bootstrap.sh, scripts/download_bb_crs.sh: Download uncompressed g1.dat
  • release-image/bootstrap.sh: Use bn254_g1.dat"

@AztecBot AztecBot added ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR. labels Mar 24, 2026
…ed format

Instead of renaming to bn254_g1_compressed.dat (which breaks cached CRS),
keep the original bn254_g1.dat filename and auto-detect the format on read
by checking the first element against known uncompressed/compressed constants.

Bootstrap scripts now replace old uncompressed files when re-downloading.
@AztecBot AztecBot changed the title fix: add backward compatibility for legacy bn254_g1.dat CRS format fix: keep bn254_g1.dat filename, auto-detect compressed vs uncompressed CRS format Mar 24, 2026
…+ native path only

C++ native path: downloads compressed g1_compressed.dat (50% bandwidth savings),
decompresses, and stores as uncompressed bn254_g1.dat (64 bytes/point).

JS/WASM path: reverted to download uncompressed g1.dat directly.
srs_init_srs accepts uncompressed 64-byte points (reverted).

Bootstrap scripts download uncompressed g1.dat as before.
On-disk format is always uncompressed - no decompression on every load.
@AztecBot AztecBot changed the title fix: keep bn254_g1.dat filename, auto-detect compressed vs uncompressed CRS format fix: always store uncompressed CRS on disk Mar 24, 2026
…avior)

Only the C++ native path and bootstrap scripts change:
- C++ downloads compressed, decompresses, stores uncompressed bn254_g1.dat
- Bootstrap scripts download uncompressed g1.dat directly
- JS/WASM path unchanged from PR #21112 (compressed throughout)
@AztecBot AztecBot changed the title fix: always store uncompressed CRS on disk fix: always store uncompressed CRS on disk in C++ native path Mar 24, 2026
@ludamad ludamad marked this pull request as ready for review March 25, 2026 00:20
@ludamad ludamad requested a review from charlielye as a code owner March 25, 2026 00:20
CI machines may have bn254_g1_compressed.dat (from PR #21112) but not
bn254_g1.dat. Check both filenames: uncompressed first, then compressed.
New downloads still store as uncompressed bn254_g1.dat.
Base automatically changed from merge-train/barretenberg to next March 26, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants