diff --git a/ci3/release_prep_package_json b/ci3/release_prep_package_json index ee6aa8bb7839..f135df7b44a5 100755 --- a/ci3/release_prep_package_json +++ b/ci3/release_prep_package_json @@ -22,3 +22,13 @@ for deps in dependencies devDependencies peerDependencies; do mv tmp.json package.json done done + +# Stamp aztec_version into any published noir contract artifacts in artifacts/*.json. The build-time stamp in +# noir-projects/noir-contracts/bootstrap.sh writes "dev"; $version here is the authoritative release version about to +# be written to package.json. We cannot stamp real version in bootstrap because there we don't have access to it. +if [ -d artifacts ]; then + for f in artifacts/*.json; do + [ -e "$f" ] || continue + jq --arg v "$version" '.aztec_version = $v' "$f" >$tmp && mv $tmp "$f" + done +fi diff --git a/noir-projects/noir-contracts/bootstrap.sh b/noir-projects/noir-contracts/bootstrap.sh index 3e8f14e1abb1..4e4566f4d7a9 100755 --- a/noir-projects/noir-contracts/bootstrap.sh +++ b/noir-projects/noir-contracts/bootstrap.sh @@ -93,19 +93,16 @@ function get_contract_path { } export -f get_contract_path -# Stamps the aztec version into a contract artifact JSON in place. Mirrors stampAztecVersion in -# yarn-project/aztec/src/cli/cmds/compile.ts so monorepo-built artifacts match those produced by `aztec compile`. -# On release builds (REF_NAME is valid semver) the tag without the leading "v" is used; otherwise "dev". -function stamp_aztec_version { +# Stamps "dev" (DEV_VERSION) as the artifact's aztec_version - that is the expected version of a locally checked out +# monorepo. The real release version is applied at publish time by whichever path owns it: +# ci3/release_prep_package_json for npm packages, release-image/Dockerfile for the docker image. +function stamp_dev_aztec_version { local json_path=$1 - # "dev" here corresponds to DEV_VERSION in yarn-project/stdlib/src/update-checker/dev_version.ts. - local version="dev" - semver check "$REF_NAME" 2>/dev/null && version="${REF_NAME#v}" local tmp=$(mktemp) - jq --arg v "$version" '.aztec_version = $v' "$json_path" > "$tmp" + jq '.aztec_version = "dev"' "$json_path" > "$tmp" mv "$tmp" "$json_path" } -export -f stamp_aztec_version +export -f stamp_dev_aztec_version # This compiles a noir contract, transpiles public functions, strips internal prefixes, # and generates verification keys for private functions via 'bb aztec_process'. @@ -127,9 +124,9 @@ function compile { $BB aztec_process -i $json_path cache_upload contract-$contract_hash.tar.gz $json_path fi - # Stamp the current version after the cache block so the field always matches the build's version, whether - # the artifact came from a fresh compile or a cache hit. - stamp_aztec_version "$json_path" + # Stamp the version after the cache block so the field is always present, whether the artifact came from a fresh + # compile or a cache hit. + stamp_dev_aztec_version "$json_path" } export -f compile diff --git a/release-image/Dockerfile b/release-image/Dockerfile index 4cd9d90a4407..19f135002afc 100644 --- a/release-image/Dockerfile +++ b/release-image/Dockerfile @@ -22,4 +22,16 @@ RUN echo '{".": "'$VERSION'"}' > /usr/src/.release-please-manifest.json RUN jq --arg v "$VERSION" '.version = $v' /usr/src/yarn-project/stdlib/package.json > /tmp/p.json \ && mv /tmp/p.json /usr/src/yarn-project/stdlib/package.json +# Stamp aztec_version into the shipped contract artifacts. The build-time stamp in +# noir-projects/noir-contracts/bootstrap.sh writes "dev" unconditionally; $VERSION here is the authoritative release +# version for this image. +RUN for dir in \ + /usr/src/yarn-project/accounts/artifacts \ + /usr/src/yarn-project/noir-contracts.js/artifacts \ + /usr/src/yarn-project/noir-test-contracts.js/artifacts; do \ + for f in "$dir"/*.json; do \ + jq --arg v "$VERSION" '.aztec_version = $v' "$f" > /tmp/a.json && mv /tmp/a.json "$f"; \ + done; \ + done + ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"] diff --git a/yarn-project/end-to-end/src/fixtures/setup.ts b/yarn-project/end-to-end/src/fixtures/setup.ts index 3b785184226c..0bf8c911c982 100644 --- a/yarn-project/end-to-end/src/fixtures/setup.ts +++ b/yarn-project/end-to-end/src/fixtures/setup.ts @@ -54,6 +54,7 @@ import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationP import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; import { tryStop } from '@aztec/stdlib/interfaces/server'; import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees'; +import { DEV_VERSION } from '@aztec/stdlib/update-checker'; import { type TelemetryClient, type TelemetryClientConfig, @@ -283,6 +284,14 @@ function assertContractArtifactsVersion() { ); return; } + // TODO(F-557): Remove once v4.3.0 drops off the compat matrix. The v4.3.0 npm release shipped with + // aztec_version: "dev" baked into the artifact JSONs because of a bug. + if (expected === '4.3.0' && aztecVersion === DEV_VERSION) { + createLogger('e2e:setup').warn( + `Skipping artifact version check: v4.3.0 artifacts shipped with aztec_version="dev"`, + ); + return; + } if (aztecVersion !== expected) { throw new Error( `Artifact version mismatch: expected ${expected} but got ${aztecVersion}. ` +