Skip to content

Commit a2d104a

Browse files
authored
fix: released contract artifact aztec version (#23470)
2 parents 2ee327c + ce6c984 commit a2d104a

4 files changed

Lines changed: 40 additions & 12 deletions

File tree

ci3/release_prep_package_json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ for deps in dependencies devDependencies peerDependencies; do
2222
mv tmp.json package.json
2323
done
2424
done
25+
26+
# Stamp aztec_version into any published noir contract artifacts in artifacts/*.json. The build-time stamp in
27+
# noir-projects/noir-contracts/bootstrap.sh writes "dev"; $version here is the authoritative release version about to
28+
# be written to package.json. We cannot stamp real version in bootstrap because there we don't have access to it.
29+
if [ -d artifacts ]; then
30+
for f in artifacts/*.json; do
31+
[ -e "$f" ] || continue
32+
jq --arg v "$version" '.aztec_version = $v' "$f" >$tmp && mv $tmp "$f"
33+
done
34+
fi

noir-projects/noir-contracts/bootstrap.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,16 @@ function get_contract_path {
9393
}
9494
export -f get_contract_path
9595

96-
# Stamps the aztec version into a contract artifact JSON in place. Mirrors stampAztecVersion in
97-
# yarn-project/aztec/src/cli/cmds/compile.ts so monorepo-built artifacts match those produced by `aztec compile`.
98-
# On release builds (REF_NAME is valid semver) the tag without the leading "v" is used; otherwise "dev".
99-
function stamp_aztec_version {
96+
# Stamps "dev" (DEV_VERSION) as the artifact's aztec_version - that is the expected version of a locally checked out
97+
# monorepo. The real release version is applied at publish time by whichever path owns it:
98+
# ci3/release_prep_package_json for npm packages, release-image/Dockerfile for the docker image.
99+
function stamp_dev_aztec_version {
100100
local json_path=$1
101-
# "dev" here corresponds to DEV_VERSION in yarn-project/stdlib/src/update-checker/dev_version.ts.
102-
local version="dev"
103-
semver check "$REF_NAME" 2>/dev/null && version="${REF_NAME#v}"
104101
local tmp=$(mktemp)
105-
jq --arg v "$version" '.aztec_version = $v' "$json_path" > "$tmp"
102+
jq '.aztec_version = "dev"' "$json_path" > "$tmp"
106103
mv "$tmp" "$json_path"
107104
}
108-
export -f stamp_aztec_version
105+
export -f stamp_dev_aztec_version
109106

110107
# This compiles a noir contract, transpiles public functions, strips internal prefixes,
111108
# and generates verification keys for private functions via 'bb aztec_process'.
@@ -127,9 +124,9 @@ function compile {
127124
$BB aztec_process -i $json_path
128125
cache_upload contract-$contract_hash.tar.gz $json_path
129126
fi
130-
# Stamp the current version after the cache block so the field always matches the build's version, whether
131-
# the artifact came from a fresh compile or a cache hit.
132-
stamp_aztec_version "$json_path"
127+
# Stamp the version after the cache block so the field is always present, whether the artifact came from a fresh
128+
# compile or a cache hit.
129+
stamp_dev_aztec_version "$json_path"
133130
}
134131
export -f compile
135132

release-image/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,16 @@ RUN echo '{".": "'$VERSION'"}' > /usr/src/.release-please-manifest.json
2222
RUN jq --arg v "$VERSION" '.version = $v' /usr/src/yarn-project/stdlib/package.json > /tmp/p.json \
2323
&& mv /tmp/p.json /usr/src/yarn-project/stdlib/package.json
2424

25+
# Stamp aztec_version into the shipped contract artifacts. The build-time stamp in
26+
# noir-projects/noir-contracts/bootstrap.sh writes "dev" unconditionally; $VERSION here is the authoritative release
27+
# version for this image.
28+
RUN for dir in \
29+
/usr/src/yarn-project/accounts/artifacts \
30+
/usr/src/yarn-project/noir-contracts.js/artifacts \
31+
/usr/src/yarn-project/noir-test-contracts.js/artifacts; do \
32+
for f in "$dir"/*.json; do \
33+
jq --arg v "$VERSION" '.aztec_version = $v' "$f" > /tmp/a.json && mv /tmp/a.json "$f"; \
34+
done; \
35+
done
36+
2537
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"]

yarn-project/end-to-end/src/fixtures/setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationP
5454
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
5555
import { tryStop } from '@aztec/stdlib/interfaces/server';
5656
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
57+
import { DEV_VERSION } from '@aztec/stdlib/update-checker';
5758
import {
5859
type TelemetryClient,
5960
type TelemetryClientConfig,
@@ -283,6 +284,14 @@ function assertContractArtifactsVersion() {
283284
);
284285
return;
285286
}
287+
// TODO(F-557): Remove once v4.3.0 drops off the compat matrix. The v4.3.0 npm release shipped with
288+
// aztec_version: "dev" baked into the artifact JSONs because of a bug.
289+
if (expected === '4.3.0' && aztecVersion === DEV_VERSION) {
290+
createLogger('e2e:setup').warn(
291+
`Skipping artifact version check: v4.3.0 artifacts shipped with aztec_version="dev"`,
292+
);
293+
return;
294+
}
286295
if (aztecVersion !== expected) {
287296
throw new Error(
288297
`Artifact version mismatch: expected ${expected} but got ${aztecVersion}. ` +

0 commit comments

Comments
 (0)