Skip to content

fix(rom-setup): key asm/ROM caches on their build inputs#1079

Open
RogerTaule wants to merge 4 commits into
pre-develop-1.0.0-betafrom
fix/cache-undeterminism
Open

fix(rom-setup): key asm/ROM caches on their build inputs#1079
RogerTaule wants to merge 4 commits into
pre-develop-1.0.0-betafrom
fix/cache-undeterminism

Conversation

@RogerTaule

Copy link
Copy Markdown
Contributor

The asm binaries and ROM/verkey were cached by guest-ELF hash alone, so a change to the transpiler, the embedded float ELF, or the linked C libs reused stale artifacts — including returning the wrong program vk.

Fold a fingerprint of those inputs into the cache filenames: build.rs bakes build-time hashes of the transpiler + float (ROM) and + emulator-asm sources (asm); asm_setup.rs adds the runtime lib contents; utils.rs keys the ROM/verkey on them. lib-c uses so the hash is stable.

Adds unit tests, a before/after script, and a CI workflow.

Copilot AI review requested due to automatic review settings June 4, 2026 12:33
@cla-bot cla-bot Bot added the cla-signed label Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes stale asm/ROM cache reuse by incorporating additional build inputs (transpiler, embedded float ELF, emulator-asm sources, and linked libs) into the cache key/filenames, and adds automation to prevent regressions.

Changes:

  • Add rom-setup/build.rs to bake build-time fingerprints (ZISK_ROM_INPUTS_HASH, ZISK_ASM_INPUTS_HASH) and incorporate them into ROM/verkey and asm cache filenames.
  • Extend asm cache keying to include runtime hashing of linked static libs, and update downstream consumers to use the new canonical basename helper.
  • Add a probe example + shell script + CI workflow to validate cache invalidation behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/test_asm_cache_invalidation.sh Script to mutate inputs and assert cache filename changes (regression guard).
rom-setup/src/utils.rs ROM/verkey cache filenames now include a build-time ROM-inputs hash.
rom-setup/src/asm_setup.rs Adds deps hashing + canonical asm basename computation; updates generation to key on deps.
rom-setup/examples/cache_probe.rs Small probe example to print the computed asm cache basename.
rom-setup/Cargo.toml Enables build.rs and adds build-dependency on blake3.
rom-setup/build.rs Computes build-time fingerprints over ROM/asm inputs and exposes them via rustc-env.
prover-backend/src/utils.rs Switches to rom_setup::compute_asm_basename for asm cache filenames.
lib-c/c/Makefile Uses deterministic ar mode to stabilize archive bytes for hashing.
.github/workflows/asm_cache_invalidation.yml New CI workflow to run the cache invalidation regression test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rom-setup/src/asm_setup.rs
Comment thread tools/test_asm_cache_invalidation.sh Outdated
Comment thread tools/test_asm_cache_invalidation.sh Outdated
Comment thread tools/test_asm_cache_invalidation.sh Outdated
Comment thread .github/workflows/asm_cache_invalidation.yml Outdated
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

🔄 ZisK Cycle Tracking

Emulator cost report (ziskemu -X) comparing this PR against the base branch.

Summary

Guest Steps Δ Steps Total Cost Δ Total Cost
bigint 21,694,842 ➖ 0.00% 2,611,875,805 ➖ 0.00%
bls12_381 12,245,950 ➖ 0.00% 1,799,538,281 ➖ 0.00%
bn254 12,720,259 ➖ 0.00% 1,864,537,084 ➖ 0.00%
diagnostic 59,126 🟢 -1.99% 298,841,840 🟢 -0.04%
hashes 3,122,307 ➖ 0.00% 776,172,874 ➖ 0.00%
secp256k1 347,053 ➖ 0.00% 341,550,674 ➖ 0.00%
secp256r1 4,840,267 ➖ 0.00% 1,241,629,301 ➖ 0.00%
uint256 27,188 🟢 -0.02% 296,207,460 ➖ 0.00%

Per-Guest Breakdown

bigint
Metric Base Branch Current PR Diff Diff (%)
Total Steps 21,694,856 21,694,842 -14 -0.00%
Main Cost 1,475,250,208 1,475,249,256 -952 -0.00%
Opcodes Cost 135,941,105 135,941,105 0 0.00%
Precompiles Cost 337,634,025 337,634,025 0 0.00%
Memory Cost 369,450,391 369,450,139 -252 -0.00%
Variable Cost 2,318,275,729 2,318,274,525 -1,204 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 2,611,877,009 2,611,875,805 -1,204 -0.00%
Frops Cost 142,469,573 142,469,573 0 0.00%
bls12_381
Metric Base Branch Current PR Diff Diff (%)
Total Steps 12,245,961 12,245,950 -11 -0.00%
Main Cost 832,725,348 832,724,600 -748 -0.00%
Opcodes Cost 24,658,198 24,658,198 0 0.00%
Precompiles Cost 355,023,251 355,023,251 0 0.00%
Memory Cost 293,531,150 293,530,952 -198 -0.00%
Variable Cost 1,505,937,947 1,505,937,001 -946 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 1,799,539,227 1,799,538,281 -946 -0.00%
Frops Cost 2,690,137 2,690,137 0 0.00%
bn254
Metric Base Branch Current PR Diff Diff (%)
Total Steps 12,720,266 12,720,259 -7 -0.00%
Main Cost 864,978,088 864,977,612 -476 -0.00%
Opcodes Cost 14,583,268 14,583,268 0 0.00%
Precompiles Cost 378,756,879 378,756,879 0 0.00%
Memory Cost 312,618,171 312,618,045 -126 -0.00%
Variable Cost 1,570,936,406 1,570,935,804 -602 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 1,864,537,686 1,864,537,084 -602 -0.00%
Frops Cost 2,434,563 2,434,563 0 0.00%
diagnostic
Metric Base Branch Current PR Diff Diff (%)
Total Steps 60,325 59,126 -1,199 -1.99%
Main Cost 4,102,100 4,020,568 -81,532 -1.99%
Opcodes Cost 491,723 475,394 -16,329 -3.32%
Precompiles Cost 335,775 335,637 -138 -0.04%
Memory Cost 422,935 408,961 -13,974 -3.30%
Variable Cost 5,352,533 5,240,560 -111,973 -2.09%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 298,953,813 298,841,840 -111,973 -0.04%
Frops Cost 1,045,196 1,039,643 -5,553 -0.53%
hashes
Metric Base Branch Current PR Diff Diff (%)
Total Steps 3,122,310 3,122,307 -3 -0.00%
Main Cost 212,317,080 212,316,876 -204 -0.00%
Opcodes Cost 107,702,885 107,702,885 0 0.00%
Precompiles Cost 145,214,131 145,214,131 0 0.00%
Memory Cost 17,337,756 17,337,702 -54 -0.00%
Variable Cost 482,571,852 482,571,594 -258 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 776,173,132 776,172,874 -258 -0.00%
Frops Cost 9,851,420 9,851,420 0 0.00%
secp256k1
Metric Base Branch Current PR Diff Diff (%)
Total Steps 347,062 347,053 -9 -0.00%
Main Cost 23,600,216 23,599,604 -612 -0.00%
Opcodes Cost 4,144,800 4,144,775 -25 -0.00%
Precompiles Cost 14,215,653 14,215,653 0 0.00%
Memory Cost 5,989,524 5,989,362 -162 -0.00%
Variable Cost 47,950,193 47,949,394 -799 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 341,551,473 341,550,674 -799 -0.00%
Frops Cost 4,001,230 4,001,230 0 0.00%
secp256r1
Metric Base Branch Current PR Diff Diff (%)
Total Steps 4,840,271 4,840,267 -4 -0.00%
Main Cost 329,138,428 329,138,156 -272 -0.00%
Opcodes Cost 78,809,852 78,809,852 0 0.00%
Precompiles Cost 422,227,437 422,227,437 0 0.00%
Memory Cost 117,852,648 117,852,576 -72 -0.00%
Variable Cost 948,028,365 948,028,021 -344 -0.00%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 1,241,629,645 1,241,629,301 -344 -0.00%
Frops Cost 72,558,463 72,558,463 0 0.00%
uint256
Metric Base Branch Current PR Diff Diff (%)
Total Steps 27,194 27,188 -6 -0.02%
Main Cost 1,849,192 1,848,784 -408 -0.02%
Opcodes Cost 87,080 87,080 0 0.00%
Precompiles Cost 239,618 239,618 0 0.00%
Memory Cost 430,806 430,698 -108 -0.03%
Variable Cost 2,606,696 2,606,180 -516 -0.02%
Base Cost 293,601,280 293,601,280 0 0.00%
Total Cost 296,207,976 296,207,460 -516 -0.00%
Frops Cost 106,125 106,125 0 0.00%

🔴 increase (regression) · 🟢 decrease (improvement) · ➖ no change. STEPS and all COSTS are deterministic functions of (ELF, input).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread rom-setup/src/asm_setup.rs
Comment thread rom-setup/src/asm_setup.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comment thread rom-setup/build.rs Outdated
Comment thread rom-setup/build.rs
Comment thread tools/test_asm_cache_invalidation.sh
Comment thread .github/workflows/asm_cache_invalidation.yml
Comment thread lib-c/c/Makefile Outdated
Copilot AI review requested due to automatic review settings June 4, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Comment thread tools/test_asm_cache_invalidation.sh
Comment thread .github/workflows/asm_cache_invalidation.yml
Comment thread rom-setup/build.rs
Comment thread rom-setup/Cargo.toml
The asm binaries and ROM/verkey were cached by guest-ELF hash alone, so a
change to the transpiler, the embedded float ELF, or the linked C libs
reused stale artifacts — including returning the wrong program vk.

Fold a fingerprint of those inputs into the cache filenames: build.rs bakes
build-time hashes of the transpiler + float (ROM) and + emulator-asm sources
(asm); asm_setup.rs adds the runtime lib contents; utils.rs keys the
ROM/verkey on them. lib-c uses  so the hash is stable.

Adds unit tests, a before/after script, and a CI workflow.
@RogerTaule RogerTaule force-pushed the fix/cache-undeterminism branch from 5add28a to 514c511 Compare June 9, 2026 07:14
@RogerTaule RogerTaule self-assigned this Jun 9, 2026
@RogerTaule RogerTaule added this to the Release 1.0.0-beta milestone Jun 9, 2026

@xavi-pinsach xavi-pinsach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants