Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3b3f8ca
Ignore the clone
aakoshh Mar 6, 2025
f9ee1b9
Sync script
aakoshh Mar 7, 2025
920780a
noir-repo-ref with a commit
aakoshh Mar 7, 2025
1e44c52
Fix commit msg
aakoshh Mar 7, 2025
abfd9c2
Fix cd. Rebase pull. --track
aakoshh Mar 7, 2025
c6bedad
switch_repo
aakoshh Mar 7, 2025
cddeec9
Look for patch in the last 100 commits
aakoshh Mar 7, 2025
6e1424d
Look for patch in any commit log
aakoshh Mar 7, 2025
eea3c1f
Handle tags
aakoshh Mar 7, 2025
25554a8
Add env var override
aakoshh Mar 7, 2025
dd530f0
Use a nightly ref
aakoshh Mar 7, 2025
1c57904
Fix env var when empty
aakoshh Mar 7, 2025
1cadcba
Update docs
aakoshh Mar 7, 2025
d38dc05
Typo
aakoshh Mar 7, 2025
9f7f83f
Take the Rust version from avm-transpiler during top level toolchain …
aakoshh Mar 7, 2025
c2848b3
Fix has_tag_commit
aakoshh Mar 7, 2025
8bacdc3
Add make-patch command
aakoshh Mar 7, 2025
e43b4a6
Apply patch file WIP
aakoshh Mar 7, 2025
2b8836a
Fix patch creation to filter empty patches
aakoshh Mar 7, 2025
d849100
Make a full checkout on a dev machine
aakoshh Mar 7, 2025
29c2c01
Add NOIR_REPO_VERBOSE to enable logs
aakoshh Mar 7, 2025
21e4c30
Fix has_tag_commit
aakoshh Mar 7, 2025
8859664
Add marker after creating patch file
aakoshh Mar 7, 2025
6c31aab
Add post-checkout hook
aakoshh Mar 7, 2025
f87a15c
Update noir/README.md
aakoshh Mar 8, 2025
c2950be
Add missing chmod
aakoshh Mar 8, 2025
ddaa3fb
Remove bkp from gitignore
aakoshh Mar 8, 2025
bebe7a5
Return exit code from needs-patch
aakoshh Mar 10, 2025
634acad
info command
aakoshh Mar 10, 2025
910fe7d
needs_switch
aakoshh Mar 10, 2025
2a95481
Get rid of the last ref
aakoshh Mar 10, 2025
db46e66
Fix branch name to be short
aakoshh Mar 10, 2025
23790f7
Do not update on make-patch
aakoshh Mar 10, 2025
6d81e4d
Remove obsolete file from .gitignore
aakoshh Mar 10, 2025
8ea110f
Update when command is empty
aakoshh Mar 10, 2025
bd376b5
Remove patch file
aakoshh Mar 10, 2025
585a1fb
Comments
aakoshh Mar 10, 2025
b11f823
Handle the case where the fixup is removed
aakoshh Mar 10, 2025
2630f62
Add latest-nightly
aakoshh Mar 10, 2025
2eae01b
Change pull-noir workflow to update the tag from nightly
aakoshh Mar 10, 2025
dab5208
Use bump-noir instead of sync-noir to not clash with the existing PR
aakoshh Mar 10, 2025
cc14c5b
Remove noir-repo after message is calculated
aakoshh Mar 10, 2025
4991d55
Change PR title
aakoshh Mar 10, 2025
36b534b
Only commit noir
aakoshh Mar 10, 2025
7107a61
Update PR commit message
aakoshh Mar 10, 2025
e10525e
Pass parameters to postcheckout.sh
aakoshh Mar 10, 2025
5da35e5
Comment about overwriting the remote branch
aakoshh Mar 10, 2025
f85215d
Push to existing bump-noir branch
aakoshh Mar 10, 2025
4682ce5
Just move on if there is nothing to commit
aakoshh Mar 10, 2025
c032119
Add bootstrap.sh/bump-noir-repo-ref
aakoshh Mar 11, 2025
55b9d6e
Handle the case where noir-repo exists but it's not a git repo
aakoshh Mar 11, 2025
7cbeba0
Update noir/scripts/sync.sh
aakoshh Mar 11, 2025
ee75c71
Update noir/scripts/sync.sh
aakoshh Mar 11, 2025
e37c85c
Fix script name
aakoshh Mar 11, 2025
ecb8a37
Try -c with advice config
aakoshh Mar 11, 2025
f19d89f
Set advice during clone
aakoshh Mar 11, 2025
80f083a
Replace local links with remote repo in DSL readme
aakoshh Mar 11, 2025
698e5c0
Handle the case where the repo isn't checked out yet
aakoshh Mar 13, 2025
fdd23a4
Reduce indent and no default in postcheckout
aakoshh Mar 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 20 additions & 77 deletions .github/workflows/pull-noir.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Create a pull request from current Noir master.
# Create a pull request from current Noir nightly.
Copy link
Collaborator

@ludamad ludamad Mar 13, 2025

Choose a reason for hiding this comment

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

I dont know if you guys still want a workflow to make PRs into noir with the patch, but otherwise we can delete the other side of the sync noir workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought opening a PR could involve some mechanical steps, such as rebasing on the remote branch without the fixup and patch marker commit, which could benefit from automation, even if it's just manually triggered, but we should definitely disable any automation for now. I thought we can return to this question once we actually have a situation and understand better what's a nice way to do it. @TomAFrench ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm fine with doing this manually in the short term and automating it later.

name: Pull from noir repo

# Don't allow multiple of these running at once:
Expand All @@ -23,25 +23,23 @@ jobs:
fetch-depth: 0
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}

# Determine if there is already a PR to overwrite, and the current plus latest tags.
- name: Check for existing PR
run: |
set -xue # print commands
# Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot
export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}"
# Do we have a PR active?
PR_URL=$(gh pr list --repo AztecProtocol/aztec-packages --head sync-noir --json url --jq ".[0].url")
PR_URL=$(gh pr list --repo AztecProtocol/aztec-packages --head bump-noir --json url --jq ".[0].url")
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
# What was our last merge on noir side?
# Detect our last sync commit (written by this action before pushing) with a fallback for the first time we ever do this
BASE_NOIR_COMMIT=$(curl https://raw.githubusercontent.com/AztecProtocol/aztec-packages/master/.noir-sync-commit)
if [ "$BASE_NOIR_COMMIT" = "404: Not Found" ] ; then
BASE_NOIR_COMMIT="50d2735825454a8638a308156d4ea23b3c4420d8"
fi
echo "BASE_NOIR_COMMIT=$BASE_NOIR_COMMIT" >> $GITHUB_ENV
# What was our last sync on aztec side?
BASE_AZTEC_COMMIT=`curl https://raw.githubusercontent.com/noir-lang/noir/master/.aztec-sync-commit`
echo "BASE_AZTEC_COMMIT=$BASE_AZTEC_COMMIT" >> $GITHUB_ENV
# Get the current Noir target
CURRENT_NOIR_REF=$(noir/scripts/sync.sh read-noir-repo-ref)
echo "CURRENT_NOIR_REF=$CURRENT_NOIR_REF" >> $GITHUB_ENV
# Get the latest nightly tag we can point to in Noir
LATEST_NOIR_NIGHTLY=$(noir/scripts/sync.sh latest-nightly)
echo "LATEST_NOIR_NIGHTLY=$LATEST_NOIR_NIGHTLY" >> $GITHUB_ENV

# Set PR body to be the concatenation of every message that happened in Noir since the last sync.
- name: Generate PR body
run: |
# clone noir repo for manipulations, we use aztec bot token for writeability
Expand All @@ -52,7 +50,7 @@ jobs:
function compute_commit_message() {
cd noir-repo
# Create a filtered git log for release-please changelog / metadata
RAW_MESSAGE=$(git log --pretty=format:"%s" $BASE_NOIR_COMMIT..HEAD || true)
RAW_MESSAGE=$(git log --pretty=format:"%s" $CURRENT_NOIR_REF..$LATEST_NOIR_NIGHTLY || true)
# Fix Noir PR links and output message
echo "$RAW_MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/noir-lang\/noir\/pull\/\1)/g'
cd ..
Expand All @@ -65,85 +63,30 @@ jobs:
git config --global user.name AztecBot
git config --global user.email tech@aztecprotocol.com

# We push using git subrepo (https://github.com/ingydotnet/git-subrepo)
# and push all Aztec commits as a single commit with metadata.
# Push a commit to the `bump-noir` branch that overrides the Noir ref.
- name: Push to branch
run: |
set -xue # print commands
SUBREPO_PATH=noir/noir-repo
BRANCH=sync-noir
if [[ "$PR_URL" == "" ]]; then
# if no staging branch, we can overwrite
STAGING_BRANCH=$BRANCH
else
# otherwise we first reset our staging branch
STAGING_BRANCH=$BRANCH-staging
fi

# Get the last sync PR's last commit state
COMMIT_MESSAGE=$(cat .PR_BODY_MESSAGE)
LINES=$(echo $COMMIT_MESSAGE | wc -l)

function force_sync_staging() {
# reset to last noir merge
git checkout $STAGING_BRANCH || git checkout -b $STAGING_BRANCH
git reset --hard "$BASE_AZTEC_COMMIT"
# Reset our branch to our expected target
git push origin $STAGING_BRANCH --force
# force gitrepo to point to the right HEAD (we ignore .gitrepo contents otherwise)
git config --file="$SUBREPO_PATH/.gitrepo" subrepo.commit "$BASE_NOIR_COMMIT"
# we need to commit for git-subrepo
git commit -am "[$LINES changes] $COMMIT_MESSAGE"
if ./scripts/git-subrepo/lib/git-subrepo pull --force $SUBREPO_PATH --branch=master; then
# Read our actual commit sync from git subrepo, stash to file for next time
COMMIT=$(git config --file="$SUBREPO_PATH/.gitrepo" subrepo.commit)
echo "$COMMIT" > .noir-sync-commit && git add .noir-sync-commit
git reset --soft "$BASE_AZTEC_COMMIT"
# We don't really need the sync commit on our side, and don't need .gitrepo at all except just in time for the command.
git checkout origin/master -- noir/noir-repo/.aztec-sync-commit noir/noir-repo/.gitrepo
git commit -am "[$LINES changes] $COMMIT_MESSAGE"

# There's various changes which we need to make to account for CI differences so we run this script to apply them.
git checkout origin/master -- noir/scripts/sync-in-fixup.sh
noir/scripts/sync-in-fixup.sh
git commit -am "chore: apply sync fixes"

git push origin $STAGING_BRANCH --force
else
echo "Problems syncing noir. Needs manual attention, might be a merge conflict."
exit 1
fi
}
# merge_staging_branch: Merge our staging branch into aztec-packages.
function merge_staging_branch() {
# Fix PR branch
git fetch # see recent change
git checkout $BRANCH || git checkout -b $BRANCH
if ! git merge -Xtheirs origin/$STAGING_BRANCH -m "$COMMIT_MESSAGE" ; then
# resolve modify/delete conflicts
git diff --name-only --diff-filter=U | xargs git rm
git commit -m "$COMMIT_MESSAGE"
fi
git push origin $BRANCH
}
force_sync_staging
if [[ "$PR_URL" != "" ]]; then
merge_staging_branch
fi
BRANCH=bump-noir
cd noir
./bootstrap.sh bump-noir-repo-ref $BRANCH $LATEST_NOIR_NIGHTLY

# Update the PR from `bump-noir` to `master` with the latest message body.
- name: Update PR
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
set -xue # print commands
# Formatted for updating the PR, overrides for release-please commit message parsing
PR_BODY="""
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec.
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
$(cat .PR_BODY_MESSAGE)
END_COMMIT_OVERRIDE"""
# for cross-opening PR in noir repo, we use aztecbot's token
export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
if [[ "$PR_URL" == "" ]]; then
gh pr create --repo AztecProtocol/aztec-packages --title "feat: Sync from noir" --body "$PR_BODY" --base master --head sync-noir
gh pr create --repo AztecProtocol/aztec-packages --title "chore: Bump Noir reference" --body "$PR_BODY" --base $BRANCH_NAME --head bump-noir
else
echo "Updating existing PR."
gh pr edit "$PR_URL" --body "$PR_BODY"
Expand Down
10 changes: 6 additions & 4 deletions barretenberg/cpp/src/barretenberg/dsl/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Domain Specific Language

This package adds support to use [ACIR](https://github.com/noir-lang/noir/tree/master/acvm-repo/acir) with barretenberg.
This package adds support to use [ACIR](https://github.com/noir-lang/noir/blob/master/tree/master/acvm-repo/acir) with barretenberg.

## Serialization Changes

There are two types of breaking serialization changes. One that alters the internal ACIR structure passed to barretenberg, and one that changes how we serialize the buffer passed to barretenberg.

1. Internal Structure Change

Go to the ACVM `acir` crate and re-run the [serde reflection test](../../../../../noir/noir-repo/acvm-repo/acir/src/lib.rs#L51). Remember to comment out the hash check to write the updated C++ serde file. Copy that file into the `dsl` package's [serde folder](./acir_format/serde/) where you will see an `acir.hpp` file.
Go to the ACVM `acir` crate and re-run the [serde reflection test](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/lib.rs#L51). Remember to comment out the hash check to write the updated C++ serde file. Copy that file into the `dsl` package's [serde folder](./acir_format/serde/) where you will see an `acir.hpp` file.

You will have to update a couple things in the new `acir.hpp`:

- Replace all `throw serde::deserialization_error` with `throw_or_abort`
- The top-level struct (such as `Program`) will still use its own namespace for its internal fields. This extra `Program::` can be removed from the top-level `struct Program { .. }` object.

Expand All @@ -20,14 +21,15 @@ The same can then be done for any breaking changes introduced to `witness_stack.

This type of breaking change is rarely expected to happen, however, due to its nature there are multiple consumers of the pre-existing serialization you should be aware of if you ever need to make this change.

A full change is when you attempt to change the object whose buffer we are actually deserializing in barretenberg. To give more detail, when [deserializing the constraint buffer](./acir_format/acir_to_constraint_buf.hpp#366) if the object for which we call `bincodeDeserialize` on changes, anything that has pre-existing ACIR using the previous object's `bincodeDeserialize` method will now fail. The serialization is once again determined by the top-level object in the [acir crate](../../../../../noir/noir-repo/acvm-repo/acir/src/circuit/mod.rs). After performing the steps outlined for an internal structure breaking change as listed in (1) above, we need to update all consumers of barretenberg.
A full change is when you attempt to change the object whose buffer we are actually deserializing in barretenberg. To give more detail, when [deserializing the constraint buffer](./acir_format/acir_to_constraint_buf.hpp#366) if the object for which we call `bincodeDeserialize` on changes, anything that has pre-existing ACIR using the previous object's `bincodeDeserialize` method will now fail. The serialization is once again determined by the top-level object in the [acir crate](https://github.com/noir-lang/noir/blob/master/acvm-repo/acir/src/circuit/mod.rs). After performing the steps outlined for an internal structure breaking change as listed in (1) above, we need to update all consumers of barretenberg.

Even if you correctly update all serialization in [acvm_js](../../../../../noir/noir-repo/acvm-repo/acvm_js/README.md) such as during [execution](../../../../../noir/noir-repo/acvm-repo/acvm_js/src/execute.rs#57), there is multiple places the `yarn-project` uses the ACIR top-level serialization. The `yarn-project` sequencer also uses the native `acvm_cli tool` that has an execute method that [expects raw byte code](../../../../../noir/noir-repo/tooling/acvm_cli/src/cli/execute_cmd.rs#63).
Even if you correctly update all serialization in [acvm_js](https://github.com/noir-lang/noir/blob/master/acvm-repo/acvm_js/README.md) such as during [execution](https://github.com/noir-lang/noir/blob/master/acvm-repo/acvm_js/src/execute.rs#57), there is multiple places the `yarn-project` uses the ACIR top-level serialization. The `yarn-project` sequencer also uses the native `acvm_cli tool` that has an execute method that [expects raw byte code](https://github.com/noir-lang/noir/blob/master/tooling/acvm_cli/src/cli/execute_cmd.rs#63).

In the context of Aztec we need to regenerate all the artifacts in [noir-projects](../../../../../noir-projects/bootstrap.sh). This regeneration assumes that we have rebuilt the compilers (Noir compiler and AVM transpiler) to use the new serialization. After regenerating these artifacts we can bootstrap the yarn-project. There are multiple packages in the yarn-project that rely on pre-computed artifacts such as `yarn-project/stdlib` and `yarn-project/protocol-contracts`.

The Aztec artifacts can be individually regenerated as well using `yarn test -u`.
You can also run the command on the relevant workspaces, which at the time are the following:

```
yarn workspace @aztec/stdlib test -u
yarn workspace @aztec/protocol-contracts test -u
Expand Down
4 changes: 3 additions & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function check_toolchains {
exit 1
fi
# Check rustup installed.
local rust_version=$(yq '.toolchain.channel' ./noir/noir-repo/rust-toolchain.toml)
local rust_version=$(yq '.toolchain.channel' ./avm-transpiler/rust-toolchain.toml)
if ! command -v rustup > /dev/null; then
encourage_dev_container
echo "Rustup not installed."
Expand Down Expand Up @@ -114,6 +114,8 @@ function install_hooks {
echo "./noir-projects/precommit.sh" >>$hooks_dir/pre-commit
echo "./yarn-project/constants/precommit.sh" >>$hooks_dir/pre-commit
chmod +x $hooks_dir/pre-commit
echo "(cd noir && ./postcheckout.sh $@)" >$hooks_dir/post-checkout
chmod +x $hooks_dir/post-checkout
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should do this right after checking out submodules? As this is basically "getting a submodule" our own way.
Also would mean going to the transpiler for the version above not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't actually check out the noir-repo, it does not initialise it, it just checks whether it has commits that should be patched. (I just pushed a fix to make sure it works correctly if the repo doesn't exist yet).

The other difference I think is that if I put it after the update of submodules, it would print this message whenever the developer runs a build and there are commits in the noir-repo. I don't want that, because they might just be running builds on the same branch over and over; what I want is to warn them iff they switch away to a different aztec-packages branch, before they initiate a build on the new branch, which could end up checking out a different branch/tag/commit of noir-repo for them. Before they do so they should think about switching back to where they came from, create a patch there and commit it. If it's okay, then until they switch branches again they can work in peace.

}

function test_cmds {
Expand Down
1 change: 1 addition & 0 deletions noir/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/package.tgz
packages
noir-repo
32 changes: 26 additions & 6 deletions noir/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
# Aztec's Build of Noir

We subrepo noir into the folder `noir-repo`.
We subrepo [noir](https://github.com/noir-lang/noir) into the folder `noir-repo` during the build.
This folder contains dockerfiles and scripts for performing our custom build of noir for the monorepo.

# Syncing with the main Noir repository

In order to keep aztec-packages in step with the main Noir repository we need to periodically sync between them.

Syncing from aztec-packages into noir currently attempts to revert any changes in Noir since the last sync so it's recommended to always sync from Noir first to ensure that aztec-packages is up-to-date.
Ideally there should be a one-way sync from Noir to aztec-packages, but occasionally, when the `bb` interface changes,
or if some integration test fails and the Noir bug is fixed locally, changes have to go both ways.

## Syncing from Noir to aztec-packages.
## Syncing from Noir to aztec-packages

To start the sync run [this action](https://github.com/AztecProtocol/aztec-packages/actions/workflows/pull-noir.yml) manually (click the "Run Workflow" button in the top right). aztec-bot will then open a new PR which does the initial sync, this will have merge conflicts with master which will need to be resolved.
During the build the Noir repository is cloned or updated according to the contents of the [noir-repo-ref](./noir-repo-ref)
file, which can be a tag, branch name or commit hash. The value can be overriden using the `NOIR_REPO_REF` environment variable,
for example to run the integration tests in aztec-packages against a yet-to-be-released branch of Noir.

## Syncing from aztec-packages to Noir.
If the ref contains a branch, it's pulled with each build triggered by `bootstrap.sh`, but for repeatable builds it should
point at a tag instead or commit instead, which would be updated with a regular PR opened in aztec-packages, so we can run
the test suite before changes take effect.

To start the sync run [this action](https://github.com/AztecProtocol/aztec-packages/actions/workflows/pull-noir.yml) manually (click the "Run Workflow" button in the top right). aztec-bot will then open a new PR which updates the reference. This will might merge conflicts with master which will need to be resolved.

## Syncing from aztec-packages to Noir

When syncing from aztec-packages to Noir it's important to check that the latest release of `bb` uses the same ACIR serialization format as the current master commit. This is because Noir uses a released version of barretenberg rather than being developed in sync with it, it's then not possible to sync if there's been serialization changes since the latest release.

To start the sync run [this action](https://github.com/AztecProtocol/aztec-packages/actions/workflows/mirror-noir-subrepo.yml) manually (click the "Run Workflow" button in the top right). aztec-bot will then open a new PR in the `noir-lang/noir` repository which does the initial sync, this will have merge conflicts with master which will need to be resolved.
When we make changes in `noir-repo` and commit them, we can check out a branch and push them back to Noir, where a PR can be opened to merge them back
into an appropriate branch (could be `master` or some kind of integration branch). It is important to exclude the [fixup](./scripts/sync-in-fixup.sh) that the local checkout performs from the PR by running the [fixdown](./scripts/sync-out-fixup.sh) script.

Syncing can be postponed by creating a few commits in `noir-repo`, but instead of opening a PR against Noir, creating a [git patch](https://git-scm.com/docs/git-format-patch) instead using, which is committed to aztec-packages and is applied to any subsequent checkout. A patch file can be made using the following command:

```shell
./bootstrap.sh make-patch
```

After this `./noir-repo.patch` should have the changes committed on top of the latest checkout, and if we commit this file to `aztec-packages` then it is automatically applied by any subsequent checkouts of `noir-repo`.

To start an automated sync run [this action](https://github.com/AztecProtocol/aztec-packages/actions/workflows/mirror-noir-subrepo.yml) manually (click the "Run Workflow" button in the top right). aztec-bot will then open a new PR in the `noir-lang/noir` repository which does the initial sync, this will have merge conflicts with master which will need to be resolved.
35 changes: 34 additions & 1 deletion noir/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/usr/bin/env bash
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap

set -eou pipefail

cmd=${1:-}
[ -n "$cmd" ] && shift

# Update the noir-repo before we hash its content, unless the command is exempt.
no_update=(clean make-patch bump-noir-repo-ref)
if [[ -z "$cmd" || ! ${no_update[*]} =~ "$cmd" ]]; then
Copy link
Collaborator

@ludamad ludamad Mar 13, 2025

Choose a reason for hiding this comment

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

Why not just hash the ref and the patch file? (tho we should still disable the cache if there's any local changes to noir repo, hmm)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to fundamentally change what the hashes work with: have we compiled and cached this code or not, including pending changes and local commits that may not be in the hash file.

scripts/sync.sh init
scripts/sync.sh update
fi

export hash=$(cache_content_hash .rebuild_patterns)
export test_hash=$(cache_content_hash .rebuild_patterns .rebuild_patterns_tests)

Expand Down Expand Up @@ -183,9 +192,27 @@ function release_commit {
release_packages next "$CURRENT_VERSION-commit.$COMMIT_HASH"
}

# Bump the Noir repo reference on a given branch to a given ref.
# The branch might already exist, e.g. this could be a daily job bumping the version to the
# latest nightly, and we might have to deal with updating the patch file because the latest
# Noir code conflicts with the contents of the patch, or we're debugging some integration
# test failure on CI. In that case just push another commit to the branch to bump the version
# further without losing any other commit on the branch.
function bump_noir_repo_ref {
branch=$1
ref=$2
git fetch --depth 1 origin $branch || true
git checkout --track origin/$branch || git checkout $branch || git checkout -b $branch
scripts/sync.sh write-noir-repo-ref $ref
git add .
git commit -m "chore: Update noir-repo-ref to $ref" || true
do_or_dryrun git push --set-upstream origin $branch
}

case "$cmd" in
"clean")
git clean -fdx
# Double `f` needed to delete the nested git repository.
git clean -ffdx
;;
"ci")
build
Expand All @@ -203,6 +230,12 @@ case "$cmd" in
"hash-test")
echo $test_hash
;;
"make-patch")
scripts/sync.sh make-patch
;;
"bump-noir-repo-ref")
bump_noir_repo_ref $@
;;
*)
echo "Unknown command: $cmd"
exit 1
Expand Down
1 change: 1 addition & 0 deletions noir/noir-repo-ref
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2025-03-07
Loading