Skip to content

Commit b8403db

Browse files
committed
refactor(standard-contracts): switch pinning to v4-style build-time tarball substitution
Replaces the per-contract pinned JSON + sha256 reproducibility test with the same mechanism v4 uses for protocol contracts: a single committed pinned-standard-contracts.tar.gz whose presence at build time causes noir-contracts/bootstrap.sh to extract the pinned artifacts into target/ and skip recompilation of contracts under contracts/standard/. The tarball is intentionally not committed in this PR. Its absence makes the extraction block a no-op on next; the mechanism activates when a release branch (e.g. v5) is cut and someone runs `./bootstrap.sh pin-standard-build` and commits the resulting tarball. Adds: - noir-projects/noir-contracts/standard_contracts.json (manifest mirroring protocol_contracts.json) - extraction block in build() gated on tarball presence - pin-standard-build function + case arm Removes: - yarn-project/standard-contracts/src/reproducibility.test.ts - yarn-project/standard-contracts/src/pinned/*.json (three pinned artifacts) - the matching .prettierignore entry
1 parent cd5d856 commit b8403db

7 files changed

Lines changed: 31 additions & 43 deletions

File tree

noir-projects/noir-contracts/bootstrap.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,17 @@ function build {
144144

145145
if [ "$#" -eq 0 ]; then
146146
rm -rf target
147+
mkdir -p target
147148
local contracts=$(grep -oP "(?<=$folder_name/)[^\"]+" Nargo.toml)
149+
150+
# If a pinned standard-contracts archive is present, extract it into target/ and skip
151+
# recompilation of those contracts. The archive is only committed on release branches; on
152+
# next it is absent and this block is a no-op (everything compiles fresh).
153+
if [ -f pinned-standard-contracts.tar.gz ]; then
154+
echo_stderr "Using pinned-standard-contracts.tar.gz for pinned standard contracts."
155+
tar xzf pinned-standard-contracts.tar.gz -C target
156+
contracts=$(echo "$contracts" | grep -vE "^standard/")
157+
fi
148158
else
149159
local contracts="$@"
150160
fi
@@ -217,6 +227,19 @@ function format {
217227
$NARGO fmt
218228
}
219229

230+
# Force-builds standard contracts and tar-balls their artifacts into pinned-standard-contracts.tar.gz.
231+
# Run this at release-branch cut time, then commit the resulting tarball to the release branch.
232+
# Mirrors the v4 `pin-build` mechanism that pins protocol contracts.
233+
function pin-standard-build {
234+
rm -f pinned-standard-contracts.tar.gz
235+
local standard_contracts=$(grep -oP '(?<=contracts/)[^"]+' Nargo.toml | grep "^standard/")
236+
build $standard_contracts
237+
local standard_artifacts=$(jq -r '.[]' standard_contracts.json | sed 's/$/.json/')
238+
echo_stderr "Creating pinned-standard-contracts.tar.gz..."
239+
(cd target && tar czf ../pinned-standard-contracts.tar.gz $standard_artifacts)
240+
echo_stderr "Done. pinned-standard-contracts.tar.gz created. Commit it to pin these artifacts."
241+
}
242+
220243
case "$cmd" in
221244
"clean-keys")
222245
for artifact in target/*.json; do
@@ -231,6 +254,9 @@ case "$cmd" in
231254
"compile")
232255
VERBOSE=${VERBOSE:-1} build "$@"
233256
;;
257+
"pin-standard-build")
258+
pin-standard-build
259+
;;
234260
*)
235261
default_cmd_handler "$@"
236262
;;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
"auth_registry_contract-AuthRegistry",
3+
"public_checks_contract-PublicChecks",
4+
"multi_call_entrypoint_contract-MultiCallEntrypoint"
5+
]

yarn-project/.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ noir-contracts.js/**/*.json
55
noir-contracts.js/src
66
noir-test-contracts.js/**/*.json
77
noir-test-contracts.js/src
8-
standard-contracts/src/**/pinned/*.json
98
noir-protocol-circuits-types/src/target/*
109
*.md
1110
end-to-end/src/fixtures/dumps/*.json

yarn-project/standard-contracts/src/pinned/AuthRegistry.artifact.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

yarn-project/standard-contracts/src/pinned/MultiCallEntrypoint.artifact.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

yarn-project/standard-contracts/src/pinned/PublicChecks.artifact.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

yarn-project/standard-contracts/src/reproducibility.test.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)