From aca3a6f044620d88879cfee17f17a956d132b2b5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 16:55:57 +0000 Subject: [PATCH 01/20] try no parallel in builder --- .github/ensure-builder/wrapper | 7 ------- barretenberg/acir_tests/browser-test-app/yarn.lock | 6 +++--- scripts/earthly-ci | 3 ++- yarn-project/end-to-end/package.json | 10 ++++------ 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/ensure-builder/wrapper b/.github/ensure-builder/wrapper index a3d2dcaf994..482df3c08bb 100755 --- a/.github/ensure-builder/wrapper +++ b/.github/ensure-builder/wrapper @@ -31,13 +31,6 @@ if ! command -v jq >/dev/null; then chmod +x ./jq sudo mv ./jq /usr/bin/jq fi -function install_parallel() { - sudo apt update && sudo apt install parallel -} -export -f install_parallel -if ! command -v parallel >/dev/null; then - DENOISE=1 ci3/denoise install_parallel -fi [ -x /usr/local/bin/earthly ] || ci3/dump_fail ci3/earthly_install # Run the test. ci3/aws_handle_evict "set -eu; $2" \ No newline at end of file diff --git a/barretenberg/acir_tests/browser-test-app/yarn.lock b/barretenberg/acir_tests/browser-test-app/yarn.lock index d209e4296d3..fd86aaec1ff 100644 --- a/barretenberg/acir_tests/browser-test-app/yarn.lock +++ b/barretenberg/acir_tests/browser-test-app/yarn.lock @@ -6,8 +6,8 @@ __metadata: cacheKey: 10c0 "@aztec/bb.js@file:../../ts::locator=browser-test-app%40workspace%3A.": - version: 0.67.0 - resolution: "@aztec/bb.js@file:../../ts#../../ts::hash=e236e3&locator=browser-test-app%40workspace%3A." + version: 0.67.1 + resolution: "@aztec/bb.js@file:../../ts#../../ts::hash=6f2e66&locator=browser-test-app%40workspace%3A." dependencies: comlink: "npm:^4.4.1" commander: "npm:^12.1.0" @@ -17,7 +17,7 @@ __metadata: tslib: "npm:^2.4.0" bin: bb.js: ./dest/node/main.js - checksum: 10c0/4ca2234f9d1a4b59a60733979f97c5ca09f508e4d3091bf33755ee6a80f03f733e393ea848b812bc73bc1f0673a3d92f96462a1cbd5aa01eeca4e9d5a3be367f + checksum: 10c0/bd20c826ae2127797959ca2a7ba170063b424c2a94b064902b0971b65c5be9f60ea1e1bc42d96fd6e980a72124d480dbb8cec498fe596202484c4f5f86e1c121 languageName: node linkType: hard diff --git a/scripts/earthly-ci b/scripts/earthly-ci index b120eab6351..c8a6f660cd9 100755 --- a/scripts/earthly-ci +++ b/scripts/earthly-ci @@ -68,7 +68,8 @@ while [ $ATTEMPT_COUNT -lt $MAX_ATTEMPTS ]; do || grep 'docker: unexpected EOF' $OUTPUT_FILE >/dev/null; then # try to wait it out echo sleep 20 + else + exit $earthly_exit_code fi - exit $earthly_exit_code fi done \ No newline at end of file diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 4a96cb434a0..7b4cbb8b0b5 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -13,18 +13,16 @@ "build:dev": "tsc -b --watch", "build:web": "webpack", "clean": "rm -rf ./dest .tsbuildinfo", + "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", + "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures", "test:with-alerts": "./scripts/test-with-alerts.sh", - "test:e2e": "./scripts/test.sh simple", - "test:e2e-no-docker": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit", "test:profile": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 0x --output-dir \"flame_graph/{pid}.0x\" -- node --experimental-vm-modules ../node_modules/jest/bin/jest.js --runInBand --testTimeout=300000 --forceExit", "serve:flames": "python3 -m http.server --directory \"flame_graph\" 8000", "test:debug": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 node --inspect --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit", "test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"", "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures", - "test:compose": "./scripts/test.sh compose", - "formatting": "run -T prettier --check ./src && run -T eslint ./src" + "test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures" }, "dependencies": { "@aztec/accounts": "workspace:^", @@ -82,7 +80,7 @@ "lodash.every": "^4.6.0", "memdown": "^6.1.1", "process": "^0.11.10", - "puppeteer-core": "^22.2", + "puppeteer": "^22.2", "resolve-typescript-plugin": "^2.0.1", "solc": "^0.8.27", "stream-browserify": "^3.0.0", From 74038097639b28ec715dcc9b2a744b74b71a4fd9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 18:27:05 +0000 Subject: [PATCH 02/20] lock apt install --- .github/ensure-builder/action.yml | 2 +- .github/ensure-builder/wrapper | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/ensure-builder/action.yml b/.github/ensure-builder/action.yml index d1f39fff679..6ff89d78471 100644 --- a/.github/ensure-builder/action.yml +++ b/.github/ensure-builder/action.yml @@ -31,7 +31,7 @@ runs: if [[ $TYPE == builder-x86 ]]; then # 128-core x86 instance types, aws chooses for us based on capacity echo "instance_type=m6a.32xlarge m6i.32xlarge m6in.32xlarge m7a.32xlarge r6a.32xlarge r6i.32xlarge r6in.32xlarge" >> $GITHUB_OUTPUT - echo "ami_id=ami-052a1e16394277fdf" >> $GITHUB_OUTPUT + echo "ami_id=ami-044f8e99cd65daf76" >> $GITHUB_OUTPUT echo "runner_concurrency=20" >> $GITHUB_OUTPUT echo "runner_label=$USERNAME-x86" >> $GITHUB_OUTPUT echo "ttl=40" >> $GITHUB_OUTPUT diff --git a/.github/ensure-builder/wrapper b/.github/ensure-builder/wrapper index 482df3c08bb..3b2bac2858d 100755 --- a/.github/ensure-builder/wrapper +++ b/.github/ensure-builder/wrapper @@ -31,6 +31,13 @@ if ! command -v jq >/dev/null; then chmod +x ./jq sudo mv ./jq /usr/bin/jq fi +function install_parallel() { + sudo apt update && sudo apt install parallel +} +export -f install_parallel +if ! command -v parallel >/dev/null; then + DENOISE=1 flock /var/lock/apt.lock ci3/denoise install_parallel +fi [ -x /usr/local/bin/earthly ] || ci3/dump_fail ci3/earthly_install # Run the test. ci3/aws_handle_evict "set -eu; $2" \ No newline at end of file From 595fc4cd88466f783c77dc727df2bb5a4d0d27db Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 18:27:31 +0000 Subject: [PATCH 03/20] Update --- yarn-project/end-to-end/package.json | 10 ++++++---- yarn-project/yarn.lock | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 7b4cbb8b0b5..4a96cb434a0 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -13,16 +13,18 @@ "build:dev": "tsc -b --watch", "build:web": "webpack", "clean": "rm -rf ./dest .tsbuildinfo", - "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures", "test:with-alerts": "./scripts/test-with-alerts.sh", + "test:e2e": "./scripts/test.sh simple", + "test:e2e-no-docker": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit", "test:profile": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 0x --output-dir \"flame_graph/{pid}.0x\" -- node --experimental-vm-modules ../node_modules/jest/bin/jest.js --runInBand --testTimeout=300000 --forceExit", "serve:flames": "python3 -m http.server --directory \"flame_graph\" 8000", "test:debug": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 node --inspect --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit", "test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"", "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json", - "test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures" + "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures", + "test:compose": "./scripts/test.sh compose", + "formatting": "run -T prettier --check ./src && run -T eslint ./src" }, "dependencies": { "@aztec/accounts": "workspace:^", @@ -80,7 +82,7 @@ "lodash.every": "^4.6.0", "memdown": "^6.1.1", "process": "^0.11.10", - "puppeteer": "^22.2", + "puppeteer-core": "^22.2", "resolve-typescript-plugin": "^2.0.1", "solc": "^0.8.27", "stream-browserify": "^3.0.0", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index f2a2b724146..9f7fdbb12f1 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -586,7 +586,7 @@ __metadata: lodash.every: "npm:^4.6.0" memdown: "npm:^6.1.1" process: "npm:^0.11.10" - puppeteer: "npm:^22.2" + puppeteer-core: "npm:^22.2" resolve-typescript-plugin: "npm:^2.0.1" solc: "npm:^0.8.27" stream-browserify: "npm:^3.0.0" @@ -16495,7 +16495,7 @@ __metadata: languageName: node linkType: hard -"puppeteer-core@npm:22.15.0": +"puppeteer-core@npm:22.15.0, puppeteer-core@npm:^22.2": version: 22.15.0 resolution: "puppeteer-core@npm:22.15.0" dependencies: @@ -16522,7 +16522,7 @@ __metadata: languageName: node linkType: hard -"puppeteer@npm:^22.2, puppeteer@npm:^22.4.1": +"puppeteer@npm:^22.4.1": version: 22.15.0 resolution: "puppeteer@npm:22.15.0" dependencies: From 4c12bdf99a9b58017ab7dd05182bead19a2c941f Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:00:36 +0000 Subject: [PATCH 04/20] fix parallel clone --- .github/ensure-builder/run | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index 4a85aba0751..c10e0cc8768 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -4,14 +4,19 @@ ttl=$1 scripts/run_on_builder " set -eu; sudo shutdown -P $ttl; - if ! [ -d ~/run-$RUN_ID ]; then - mkdir -p ~/run-$RUN_ID; - cd ~/run-$RUN_ID; - git init >/dev/null 2>&1; - git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; - git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; - git checkout FETCH_HEAD >/dev/null 2>&1; - fi; + function clone { + if ! [ -d ~/run-$RUN_ID ]; then + mkdir -p ~/run-$RUN_ID; + cd ~/run-$RUN_ID; + git init >/dev/null 2>&1; + git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; + git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; + git checkout FETCH_HEAD >/dev/null 2>&1; + fi; + } + export RUN_ID GIT_COMMIT + export -f clone + flock bash -c clone cd ~/run-$RUN_ID; .github/ensure-builder/wrapper $DOCKERHUB_PASSWORD '$INPUT'; " From df38ace9c08637311fce361b105a10e711d2f77a Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:01:02 +0000 Subject: [PATCH 05/20] fix parallel clone --- .github/ensure-builder/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index c10e0cc8768..e6d1a8e3207 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -16,7 +16,7 @@ scripts/run_on_builder " } export RUN_ID GIT_COMMIT export -f clone - flock bash -c clone + flock /var/lock/clone.lock bash -c clone cd ~/run-$RUN_ID; .github/ensure-builder/wrapper $DOCKERHUB_PASSWORD '$INPUT'; " From c38a4f1f028dd56ae169fafe3e72543fd41e127e Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:24:50 +0000 Subject: [PATCH 06/20] try fix --- .github/ensure-builder/run | 5 +++- .github/ensure-builder/wrapper | 43 ---------------------------------- .github/ensure-tester/run | 5 +++- .github/ensure-tester/wrapper | 33 -------------------------- 4 files changed, 8 insertions(+), 78 deletions(-) delete mode 100755 .github/ensure-builder/wrapper delete mode 100755 .github/ensure-tester/wrapper diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index e6d1a8e3207..dcadd96217e 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -18,7 +18,10 @@ scripts/run_on_builder " export -f clone flock /var/lock/clone.lock bash -c clone cd ~/run-$RUN_ID; - .github/ensure-builder/wrapper $DOCKERHUB_PASSWORD '$INPUT'; + # Install deps. + flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD '$INPUT'; + # Run the test. + ci3/aws_handle_evict "set -eu; $2" " exit_code=$? if [ $exit_code = 255 ]; then diff --git a/.github/ensure-builder/wrapper b/.github/ensure-builder/wrapper deleted file mode 100755 index 3b2bac2858d..00000000000 --- a/.github/ensure-builder/wrapper +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -set -eu -# One-time config. -if ! [ -f ~/maybe_exit_spot.sh ] ; then - cp scripts/ci/maybe_exit_spot.sh ~/maybe_exit_spot.sh - # Run maybe_exit_spot.sh every minute - chmod +x ~/maybe_exit_spot.sh - echo "* * * * * ~/maybe_exit_spot.sh" | crontab - - echo "Configured instance exit cron job." -else - echo "Chron jobs already configured." -fi -set +x -# Ensure docker is active. -i=0 -while ! systemctl is-active --quiet docker; do - sleep 2 - if [ $(( i++ )) -gt 60 ]; then - echo "Docker service not found! Report this." - exit 1 - fi -done -echo $1 | ci3/dump_fail docker login -u aztecprotocolci --password-stdin -if ! command -v yq >/dev/null; then - ci3/dump_fail wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_$(ci3/arch) -O ./yq - chmod +x ./yq - sudo mv ./yq /usr/bin/yq -fi -if ! command -v jq >/dev/null; then - ci3/dump_fail wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$(ci3/arch) -O ./jq 2>&1 >/dev/null - chmod +x ./jq - sudo mv ./jq /usr/bin/jq -fi -function install_parallel() { - sudo apt update && sudo apt install parallel -} -export -f install_parallel -if ! command -v parallel >/dev/null; then - DENOISE=1 flock /var/lock/apt.lock ci3/denoise install_parallel -fi -[ -x /usr/local/bin/earthly ] || ci3/dump_fail ci3/earthly_install -# Run the test. -ci3/aws_handle_evict "set -eu; $2" \ No newline at end of file diff --git a/.github/ensure-tester/run b/.github/ensure-tester/run index dc1e8a75f21..2827f777c09 100755 --- a/.github/ensure-tester/run +++ b/.github/ensure-tester/run @@ -13,7 +13,10 @@ scripts/run_on_tester " git checkout FETCH_HEAD >/dev/null 2>&1; fi; cd ~/run-$RUN_ID; - .github/ensure-tester/wrapper $DOCKERHUB_PASSWORD '$INPUT'; + # Install deps. + .github/ensure-tester/install $DOCKERHUB_PASSWORD '$INPUT'; + # Run the test. + ci3/aws_handle_evict "set -eu; $2" " exit_code=$? if [ $exit_code = 255 ]; then diff --git a/.github/ensure-tester/wrapper b/.github/ensure-tester/wrapper deleted file mode 100755 index b65b45e2dfa..00000000000 --- a/.github/ensure-tester/wrapper +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -set -eu -# One-time config. -mkdir -p ~/.ssh -echo $BUILD_INSTANCE_SSH_KEY | base64 --decode > ~/.ssh/build_instance_key -chmod 600 ~/.ssh/build_instance_key -set +x -# Ensure docker is active. -echo "Waiting for Docker service to become active..." -i=0 -set +x -while ! systemctl is-active --quiet docker; do - sleep 2 - if [ $(( i++ )) -gt 60 ]; then - echo "Docker service not found! Report this." - exit 1 - fi -done -echo $1 | ci3/dump_fail docker login -u aztecprotocolci --password-stdin -ci3/dump_fail wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_$(ci3/arch) -O ./yq 2>&1 >/dev/null -chmod +x ./yq -sudo mv ./yq /usr/bin/yq -ci3/dump_fail wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$(ci3/arch) -O ./jq -chmod +x ./jq -sudo mv ./jq /usr/bin/jq -ci3/dump_fail ci3/earthly_install -function install_parallel() { - sudo apt update && sudo apt install parallel -} -export -f install_parallel -DENOISE=1 ci3/denoise install_parallel -# Run command. -ci3/aws_handle_evict "set -eu; $2" \ No newline at end of file From 492a9b5da7fd8d79aa92f54fa196fddc38687bf7 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:25:10 +0000 Subject: [PATCH 07/20] Deterministic parser --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 4 ++++ .../src/brillig/brillig_ir/artifact.rs | 4 ++-- .../noirc_evaluator/src/ssa/opt/unrolling.rs | 6 ++++-- .../compiler/noirc_frontend/src/ast/statement.rs | 13 ++++++------- noir/noir-repo/tooling/nargo_cli/build.rs | 3 +++ .../tooling/nargo_cli/src/cli/compile_cmd.rs | 14 ++++++++++++++ 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index 9318e4d2b5c..1b311504b5c 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -150,6 +150,10 @@ pub struct CompileOptions { /// A lower value keeps the original program if it was smaller, even if it has more jumps. #[arg(long, hide = true, allow_hyphen_values = true)] pub max_bytecode_increase_percent: Option, + + /// Used internally to test for non-determinism in the compiler. + #[clap(long, hide = true)] + pub check_non_determinism: bool, } pub fn parse_expression_width(input: &str) -> Result { diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs index be4a6b84bc1..3654a95a03f 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs @@ -27,7 +27,7 @@ pub(crate) struct GeneratedBrillig { pub(crate) locations: BTreeMap, pub(crate) error_types: BTreeMap, pub(crate) name: String, - pub(crate) procedure_locations: HashMap, + pub(crate) procedure_locations: BTreeMap, } #[derive(Default, Debug, Clone)] @@ -61,7 +61,7 @@ pub(crate) struct BrilligArtifact { /// This is created as artifacts are linked together and allows us to determine /// which opcodes originate from reusable procedures.s /// The range is inclusive for both start and end opcode locations. - pub(crate) procedure_locations: HashMap, + pub(crate) procedure_locations: BTreeMap, } /// A pointer to a location in the opcode. diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs index 2a272236195..ab4256197b9 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs @@ -18,6 +18,8 @@ //! //! When unrolling ACIR code, we remove reference count instructions because they are //! only used by Brillig bytecode. +use std::collections::BTreeSet; + use acvm::{acir::AcirField, FieldElement}; use im::HashSet; @@ -117,7 +119,7 @@ pub(super) struct Loop { back_edge_start: BasicBlockId, /// All the blocks contained within the loop, including `header` and `back_edge_start`. - pub(super) blocks: HashSet, + pub(super) blocks: BTreeSet, } pub(super) struct Loops { @@ -238,7 +240,7 @@ impl Loop { back_edge_start: BasicBlockId, cfg: &ControlFlowGraph, ) -> Self { - let mut blocks = HashSet::default(); + let mut blocks = BTreeSet::default(); blocks.insert(header); let mut insert = |block, stack: &mut Vec| { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs index c77fe7513a1..641ee835c26 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs @@ -1,5 +1,4 @@ use std::fmt::Display; -use std::sync::atomic::{AtomicU32, Ordering}; use acvm::acir::AcirField; use acvm::FieldElement; @@ -839,10 +838,9 @@ impl ForRange { block: Expression, for_loop_span: Span, ) -> Statement { - /// Counter used to generate unique names when desugaring - /// code in the parser requires the creation of fresh variables. - /// The parser is stateless so this is a static global instead. - static UNIQUE_NAME_COUNTER: AtomicU32 = AtomicU32::new(0); + // Counter used to generate unique names when desugaring + // code in the parser requires the creation of fresh variables. + let mut unique_name_counter: u32 = 0; match self { ForRange::Range(..) => { @@ -853,7 +851,8 @@ impl ForRange { let start_range = ExpressionKind::integer(FieldElement::zero()); let start_range = Expression::new(start_range, array_span); - let next_unique_id = UNIQUE_NAME_COUNTER.fetch_add(1, Ordering::Relaxed); + let next_unique_id = unique_name_counter; + unique_name_counter += 1; let array_name = format!("$i{next_unique_id}"); let array_span = array.span; let array_ident = Ident::new(array_name, array_span); @@ -886,7 +885,7 @@ impl ForRange { })); let end_range = Expression::new(end_range, array_span); - let next_unique_id = UNIQUE_NAME_COUNTER.fetch_add(1, Ordering::Relaxed); + let next_unique_id = unique_name_counter; let index_name = format!("$i{next_unique_id}"); let fresh_identifier = Ident::new(index_name.clone(), array_span); diff --git a/noir/noir-repo/tooling/nargo_cli/build.rs b/noir/noir-repo/tooling/nargo_cli/build.rs index 8db2c1786d8..003897489c4 100644 --- a/noir/noir-repo/tooling/nargo_cli/build.rs +++ b/noir/noir-repo/tooling/nargo_cli/build.rs @@ -215,6 +215,9 @@ fn test_{test_name}(force_brillig: ForceBrillig, inliner_aggressiveness: Inliner // Set the maximum increase so that part of the optimization is exercised (it might fail). nargo.arg("--max-bytecode-increase-percent"); nargo.arg("50"); + + // Check whether the test case is non-deterministic + nargo.arg("--check-non-determinism"); }} {test_content} diff --git a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs index 2ecf6959a94..f718021c351 100644 --- a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -216,6 +216,20 @@ fn compile_programs( cached_program, )?; + if compile_options.check_non_determinism { + let (program_two, _) = compile_program( + file_manager, + parsed_files, + workspace, + package, + compile_options, + load_cached_program(package), + )?; + if fxhash::hash64(&program) != fxhash::hash64(&program_two) { + panic!("Non deterministic result compiling {}", package.name); + } + } + // Choose the target width for the final, backend specific transformation. let target_width = get_target_width(package.expression_width, compile_options.expression_width); From d5c8a91597d0a7efd6ecd9762e5477530acde2c6 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:27:01 +0000 Subject: [PATCH 08/20] install --- .github/ensure-builder/install | 41 ++++++++++++++++++++++++++++++++++ .github/ensure-tester/install | 31 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 .github/ensure-builder/install create mode 100755 .github/ensure-tester/install diff --git a/.github/ensure-builder/install b/.github/ensure-builder/install new file mode 100755 index 00000000000..aa53c3a8854 --- /dev/null +++ b/.github/ensure-builder/install @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -eu +# One-time config. +if ! [ -f ~/maybe_exit_spot.sh ] ; then + cp scripts/ci/maybe_exit_spot.sh ~/maybe_exit_spot.sh + # Run maybe_exit_spot.sh every minute + chmod +x ~/maybe_exit_spot.sh + echo "* * * * * ~/maybe_exit_spot.sh" | crontab - + echo "Configured instance exit cron job." +else + echo "Chron jobs already configured." +fi +set +x +# Ensure docker is active. +i=0 +while ! systemctl is-active --quiet docker; do + sleep 2 + if [ $(( i++ )) -gt 60 ]; then + echo "Docker service not found! Report this." + exit 1 + fi +done +echo $1 | ci3/dump_fail docker login -u aztecprotocolci --password-stdin +if ! command -v yq >/dev/null; then + ci3/dump_fail wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_$(ci3/arch) -O ./yq + chmod +x ./yq + sudo mv ./yq /usr/bin/yq +fi +if ! command -v jq >/dev/null; then + ci3/dump_fail wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$(ci3/arch) -O ./jq 2>&1 >/dev/null + chmod +x ./jq + sudo mv ./jq /usr/bin/jq +fi +function install_parallel() { + sudo apt update && sudo apt install parallel +} +export -f install_parallel +if ! command -v parallel >/dev/null; then + DENOISE=1 ci3/denoise install_parallel +fi +[ -x /usr/local/bin/earthly ] || ci3/dump_fail ci3/earthly_install \ No newline at end of file diff --git a/.github/ensure-tester/install b/.github/ensure-tester/install new file mode 100755 index 00000000000..3c3bceabcac --- /dev/null +++ b/.github/ensure-tester/install @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -eu +# One-time config. +mkdir -p ~/.ssh +echo $BUILD_INSTANCE_SSH_KEY | base64 --decode > ~/.ssh/build_instance_key +chmod 600 ~/.ssh/build_instance_key +set +x +# Ensure docker is active. +echo "Waiting for Docker service to become active..." +i=0 +set +x +while ! systemctl is-active --quiet docker; do + sleep 2 + if [ $(( i++ )) -gt 60 ]; then + echo "Docker service not found! Report this." + exit 1 + fi +done +echo $1 | ci3/dump_fail docker login -u aztecprotocolci --password-stdin +ci3/dump_fail wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_$(ci3/arch) -O ./yq 2>&1 >/dev/null +chmod +x ./yq +sudo mv ./yq /usr/bin/yq +ci3/dump_fail wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$(ci3/arch) -O ./jq +chmod +x ./jq +sudo mv ./jq /usr/bin/jq +ci3/dump_fail ci3/earthly_install +function install_parallel() { + sudo apt update && sudo apt install parallel +} +export -f install_parallel +DENOISE=1 ci3/denoise install_parallel \ No newline at end of file From 3218e420fdcb6d3590ff6cdbd6daccdf9497019e Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:37:13 +0000 Subject: [PATCH 09/20] handle evict --- .github/ensure-builder/run | 8 ++++---- .github/ensure-tester/run | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index dcadd96217e..153497abeba 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -21,14 +21,14 @@ scripts/run_on_builder " # Install deps. flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD '$INPUT'; # Run the test. - ci3/aws_handle_evict "set -eu; $2" + ci3/aws_handle_evict $DOCKERHUB_PASSWORD \"set -eu; $2\" " exit_code=$? if [ $exit_code = 255 ]; then - echo "Treating ssh termination as spot eviction."; + echo "Treating ssh termination as spot eviction." exit_code=155 -fi; -echo "exit_code=$exit_code" >> $GITHUB_OUTPUT; +fi +echo "exit_code=$exit_code" >> $GITHUB_OUTPUT if [ $exit_code = 155 ]; then echo "Spot eviction detected - retrying with on-demand." fi \ No newline at end of file diff --git a/.github/ensure-tester/run b/.github/ensure-tester/run index 2827f777c09..932907be743 100755 --- a/.github/ensure-tester/run +++ b/.github/ensure-tester/run @@ -16,7 +16,7 @@ scripts/run_on_tester " # Install deps. .github/ensure-tester/install $DOCKERHUB_PASSWORD '$INPUT'; # Run the test. - ci3/aws_handle_evict "set -eu; $2" + ci3/aws_handle_evict $DOCKERHUB_PASSWORD \"set -eu; $2\" " exit_code=$? if [ $exit_code = 255 ]; then From 03cd739285a50c5ada830b06374f6f76b7e3e755 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 19:48:16 +0000 Subject: [PATCH 10/20] fix --- .github/ensure-builder/run | 8 +++----- .github/ensure-tester/run | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index 153497abeba..cb3e37f3093 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -17,11 +17,9 @@ scripts/run_on_builder " export RUN_ID GIT_COMMIT export -f clone flock /var/lock/clone.lock bash -c clone - cd ~/run-$RUN_ID; - # Install deps. - flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD '$INPUT'; - # Run the test. - ci3/aws_handle_evict $DOCKERHUB_PASSWORD \"set -eu; $2\" + cd ~/run-$RUN_ID + flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD + ci3/aws_handle_evict 'set -eu; $INPUT' " exit_code=$? if [ $exit_code = 255 ]; then diff --git a/.github/ensure-tester/run b/.github/ensure-tester/run index 932907be743..855d358e2c9 100755 --- a/.github/ensure-tester/run +++ b/.github/ensure-tester/run @@ -13,10 +13,8 @@ scripts/run_on_tester " git checkout FETCH_HEAD >/dev/null 2>&1; fi; cd ~/run-$RUN_ID; - # Install deps. - .github/ensure-tester/install $DOCKERHUB_PASSWORD '$INPUT'; - # Run the test. - ci3/aws_handle_evict $DOCKERHUB_PASSWORD \"set -eu; $2\" + .github/ensure-tester/install $DOCKERHUB_PASSWORD + ci3/aws_handle_evict 'set -eu; $INPUT' " exit_code=$? if [ $exit_code = 255 ]; then From c33e2c92d8ea9d161f88439eee9568764c8c0cbd Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 20:01:24 +0000 Subject: [PATCH 11/20] disable l1 cheatcodes --- yarn-project/end-to-end/src/e2e_cheat_codes.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 280a8e5b743..42e58a350a3 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -52,7 +52,8 @@ describe('e2e_cheat_codes', () => { afterAll(() => teardown()); describe('L1 cheatcodes', () => { - describe('mine', () => { + // TODO(#10775): example fail https://github.com/AztecProtocol/aztec-packages/actions/runs/12418969358/job/34674141249 + describe.skip('mine', () => { it(`mine block`, async () => { const blockNumber = await cc.eth.blockNumber(); await cc.eth.mine(); From ad9879864402f50db14d14f6ee1cfeffae97003c Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 19 Dec 2024 20:27:11 +0000 Subject: [PATCH 12/20] aesthetic --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 673bb2cd83b..8b971a9bc5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,7 +153,7 @@ jobs: steps: - uses: actions/checkout@v4 with: { ref: "${{ env.GIT_COMMIT }}" } - - name: "CI (l1-contracts, avm-transpiler, noir-projects, yarn-project)" + - name: "Bootstrap (l1-contracts, avm-transpiler, noir-projects, yarn-project)" uses: ./.github/ensure-builder timeout-minutes: 40 with: @@ -447,7 +447,7 @@ jobs: - name: Copy Network Logs if: always() run: scripts/copy_from_tester yarn-project/end-to-end/scripts/network-test.log network-test.log || true - + - name: Upload Network Logs if: always() uses: actions/upload-artifact@v4 From b61783c71d9bdbcb958498e9898a8055567c57c1 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:15:23 +0000 Subject: [PATCH 13/20] Revert "Deterministic parser" This reverts commit 492a9b5da7fd8d79aa92f54fa196fddc38687bf7. --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 4 ---- .../src/brillig/brillig_ir/artifact.rs | 4 ++-- .../noirc_evaluator/src/ssa/opt/unrolling.rs | 6 ++---- .../compiler/noirc_frontend/src/ast/statement.rs | 13 +++++++------ noir/noir-repo/tooling/nargo_cli/build.rs | 3 --- .../tooling/nargo_cli/src/cli/compile_cmd.rs | 14 -------------- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index 1b311504b5c..9318e4d2b5c 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -150,10 +150,6 @@ pub struct CompileOptions { /// A lower value keeps the original program if it was smaller, even if it has more jumps. #[arg(long, hide = true, allow_hyphen_values = true)] pub max_bytecode_increase_percent: Option, - - /// Used internally to test for non-determinism in the compiler. - #[clap(long, hide = true)] - pub check_non_determinism: bool, } pub fn parse_expression_width(input: &str) -> Result { diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs index 3654a95a03f..be4a6b84bc1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/artifact.rs @@ -27,7 +27,7 @@ pub(crate) struct GeneratedBrillig { pub(crate) locations: BTreeMap, pub(crate) error_types: BTreeMap, pub(crate) name: String, - pub(crate) procedure_locations: BTreeMap, + pub(crate) procedure_locations: HashMap, } #[derive(Default, Debug, Clone)] @@ -61,7 +61,7 @@ pub(crate) struct BrilligArtifact { /// This is created as artifacts are linked together and allows us to determine /// which opcodes originate from reusable procedures.s /// The range is inclusive for both start and end opcode locations. - pub(crate) procedure_locations: BTreeMap, + pub(crate) procedure_locations: HashMap, } /// A pointer to a location in the opcode. diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs index ab4256197b9..2a272236195 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs @@ -18,8 +18,6 @@ //! //! When unrolling ACIR code, we remove reference count instructions because they are //! only used by Brillig bytecode. -use std::collections::BTreeSet; - use acvm::{acir::AcirField, FieldElement}; use im::HashSet; @@ -119,7 +117,7 @@ pub(super) struct Loop { back_edge_start: BasicBlockId, /// All the blocks contained within the loop, including `header` and `back_edge_start`. - pub(super) blocks: BTreeSet, + pub(super) blocks: HashSet, } pub(super) struct Loops { @@ -240,7 +238,7 @@ impl Loop { back_edge_start: BasicBlockId, cfg: &ControlFlowGraph, ) -> Self { - let mut blocks = BTreeSet::default(); + let mut blocks = HashSet::default(); blocks.insert(header); let mut insert = |block, stack: &mut Vec| { diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs index 641ee835c26..c77fe7513a1 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs @@ -1,4 +1,5 @@ use std::fmt::Display; +use std::sync::atomic::{AtomicU32, Ordering}; use acvm::acir::AcirField; use acvm::FieldElement; @@ -838,9 +839,10 @@ impl ForRange { block: Expression, for_loop_span: Span, ) -> Statement { - // Counter used to generate unique names when desugaring - // code in the parser requires the creation of fresh variables. - let mut unique_name_counter: u32 = 0; + /// Counter used to generate unique names when desugaring + /// code in the parser requires the creation of fresh variables. + /// The parser is stateless so this is a static global instead. + static UNIQUE_NAME_COUNTER: AtomicU32 = AtomicU32::new(0); match self { ForRange::Range(..) => { @@ -851,8 +853,7 @@ impl ForRange { let start_range = ExpressionKind::integer(FieldElement::zero()); let start_range = Expression::new(start_range, array_span); - let next_unique_id = unique_name_counter; - unique_name_counter += 1; + let next_unique_id = UNIQUE_NAME_COUNTER.fetch_add(1, Ordering::Relaxed); let array_name = format!("$i{next_unique_id}"); let array_span = array.span; let array_ident = Ident::new(array_name, array_span); @@ -885,7 +886,7 @@ impl ForRange { })); let end_range = Expression::new(end_range, array_span); - let next_unique_id = unique_name_counter; + let next_unique_id = UNIQUE_NAME_COUNTER.fetch_add(1, Ordering::Relaxed); let index_name = format!("$i{next_unique_id}"); let fresh_identifier = Ident::new(index_name.clone(), array_span); diff --git a/noir/noir-repo/tooling/nargo_cli/build.rs b/noir/noir-repo/tooling/nargo_cli/build.rs index 003897489c4..8db2c1786d8 100644 --- a/noir/noir-repo/tooling/nargo_cli/build.rs +++ b/noir/noir-repo/tooling/nargo_cli/build.rs @@ -215,9 +215,6 @@ fn test_{test_name}(force_brillig: ForceBrillig, inliner_aggressiveness: Inliner // Set the maximum increase so that part of the optimization is exercised (it might fail). nargo.arg("--max-bytecode-increase-percent"); nargo.arg("50"); - - // Check whether the test case is non-deterministic - nargo.arg("--check-non-determinism"); }} {test_content} diff --git a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs index f718021c351..2ecf6959a94 100644 --- a/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/noir-repo/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -216,20 +216,6 @@ fn compile_programs( cached_program, )?; - if compile_options.check_non_determinism { - let (program_two, _) = compile_program( - file_manager, - parsed_files, - workspace, - package, - compile_options, - load_cached_program(package), - )?; - if fxhash::hash64(&program) != fxhash::hash64(&program_two) { - panic!("Non deterministic result compiling {}", package.name); - } - } - // Choose the target width for the final, backend specific transformation. let target_width = get_target_width(package.expression_width, compile_options.expression_width); From 6b9eb3a4ab5f59fd7da0149a4fb0c8da6d924e8a Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:21:40 +0000 Subject: [PATCH 14/20] try retry kludge around parallel install --- .github/ensure-tester/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ensure-tester/install b/.github/ensure-tester/install index 3c3bceabcac..e6e3bd4ed0c 100755 --- a/.github/ensure-tester/install +++ b/.github/ensure-tester/install @@ -28,4 +28,4 @@ function install_parallel() { sudo apt update && sudo apt install parallel } export -f install_parallel -DENOISE=1 ci3/denoise install_parallel \ No newline at end of file +DENOISE=1 ci3/denoise ci3/retry install_parallel \ No newline at end of file From d73cb9c3ae748fec9109e98af12f19e103f7146d Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:22:07 +0000 Subject: [PATCH 15/20] attempts --- .github/ensure-builder/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ensure-builder/install b/.github/ensure-builder/install index aa53c3a8854..eecdbd8bee4 100755 --- a/.github/ensure-builder/install +++ b/.github/ensure-builder/install @@ -36,6 +36,6 @@ function install_parallel() { } export -f install_parallel if ! command -v parallel >/dev/null; then - DENOISE=1 ci3/denoise install_parallel + DENOISE=1 ci3/denoise ci3/retry install_parallel fi [ -x /usr/local/bin/earthly ] || ci3/dump_fail ci3/earthly_install \ No newline at end of file From 35d8ceecabb477b54aa5e4c5d83d316a141d9807 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:26:21 +0000 Subject: [PATCH 16/20] fix install scripts --- .github/ensure-builder/run | 2 ++ .github/ensure-tester/install | 31 ------------------------------- .github/ensure-tester/run | 29 ++++++++++++++++++----------- 3 files changed, 20 insertions(+), 42 deletions(-) delete mode 100755 .github/ensure-tester/install diff --git a/.github/ensure-builder/run b/.github/ensure-builder/run index cb3e37f3093..fe1b3ff8d0b 100755 --- a/.github/ensure-builder/run +++ b/.github/ensure-builder/run @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -u exit_code=254 ttl=$1 scripts/run_on_builder " @@ -18,6 +19,7 @@ scripts/run_on_builder " export -f clone flock /var/lock/clone.lock bash -c clone cd ~/run-$RUN_ID + flock /var/lock/install.lock .github/ensure-builder/chron flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD ci3/aws_handle_evict 'set -eu; $INPUT' " diff --git a/.github/ensure-tester/install b/.github/ensure-tester/install deleted file mode 100755 index e6e3bd4ed0c..00000000000 --- a/.github/ensure-tester/install +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -eu -# One-time config. -mkdir -p ~/.ssh -echo $BUILD_INSTANCE_SSH_KEY | base64 --decode > ~/.ssh/build_instance_key -chmod 600 ~/.ssh/build_instance_key -set +x -# Ensure docker is active. -echo "Waiting for Docker service to become active..." -i=0 -set +x -while ! systemctl is-active --quiet docker; do - sleep 2 - if [ $(( i++ )) -gt 60 ]; then - echo "Docker service not found! Report this." - exit 1 - fi -done -echo $1 | ci3/dump_fail docker login -u aztecprotocolci --password-stdin -ci3/dump_fail wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_$(ci3/arch) -O ./yq 2>&1 >/dev/null -chmod +x ./yq -sudo mv ./yq /usr/bin/yq -ci3/dump_fail wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$(ci3/arch) -O ./jq -chmod +x ./jq -sudo mv ./jq /usr/bin/jq -ci3/dump_fail ci3/earthly_install -function install_parallel() { - sudo apt update && sudo apt install parallel -} -export -f install_parallel -DENOISE=1 ci3/denoise ci3/retry install_parallel \ No newline at end of file diff --git a/.github/ensure-tester/run b/.github/ensure-tester/run index 855d358e2c9..0bf096e1517 100755 --- a/.github/ensure-tester/run +++ b/.github/ensure-tester/run @@ -1,19 +1,26 @@ #!/usr/bin/env bash +set -u exit_code=254 ttl=$1 scripts/run_on_tester " set -eu; sudo shutdown -P $ttl; - if ! [ -d ~/run-$RUN_ID ]; then - mkdir -p ~/run-$RUN_ID; - cd ~/run-$RUN_ID; - git init >/dev/null 2>&1; - git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; - git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; - git checkout FETCH_HEAD >/dev/null 2>&1; - fi; - cd ~/run-$RUN_ID; - .github/ensure-tester/install $DOCKERHUB_PASSWORD + function clone { + if ! [ -d ~/run-$RUN_ID ]; then + mkdir -p ~/run-$RUN_ID; + cd ~/run-$RUN_ID; + git init >/dev/null 2>&1; + git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; + git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; + git checkout FETCH_HEAD >/dev/null 2>&1; + fi; + } + export RUN_ID GIT_COMMIT + export -f clone + flock /var/lock/clone.lock bash -c clone + cd ~/run-$RUN_ID + # reuse script from ensure-builder, but don't set up chron + flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD ci3/aws_handle_evict 'set -eu; $INPUT' " exit_code=$? @@ -24,4 +31,4 @@ fi echo "exit_code=$exit_code" >> $GITHUB_OUTPUT if [ $exit_code = 155 ]; then echo "Spot eviction detected - retrying with on-demand." -fi +fi \ No newline at end of file From 186df8a4333736186d39f77f809ea52aa3ad55d2 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:26:32 +0000 Subject: [PATCH 17/20] fix --- .github/ensure-builder/chron | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/ensure-builder/chron diff --git a/.github/ensure-builder/chron b/.github/ensure-builder/chron new file mode 100644 index 00000000000..591ce2fd870 --- /dev/null +++ b/.github/ensure-builder/chron @@ -0,0 +1,11 @@ +set -eu +# One-time config only on builder. +if ! [ -f ~/maybe_exit_spot.sh ] ; then + cp scripts/ci/maybe_exit_spot.sh ~/maybe_exit_spot.sh + # Run maybe_exit_spot.sh every minute + chmod +x ~/maybe_exit_spot.sh + echo "* * * * * ~/maybe_exit_spot.sh" | crontab - + echo "Configured instance exit cron job." +else + echo "Chron jobs already configured." +fi \ No newline at end of file From 1fccef7f8f9933690a1efcb5d8a9147f6adda4f3 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:27:58 +0000 Subject: [PATCH 18/20] retry utility --- ci3/retry | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 ci3/retry diff --git a/ci3/retry b/ci3/retry new file mode 100755 index 00000000000..43351f9cef3 --- /dev/null +++ b/ci3/retry @@ -0,0 +1,19 @@ +#!/bin/bash +set -u # not -e +[ "${BUILD_SYSTEM_DEBUG:-}" = 1 ] && set -x + +if [ -n "${RETRY_DISABLED:-}" ]; then + set -e + eval "$" + exit +fi + +ATTEMPTS=3 +# Retries up to 3 times with 5 second intervals +for i in $(seq 1 $ATTEMPTS); do + eval "$*" && exit + [ "$i" != "$ATTEMPTS" ] && sleep 5 +done + +>&2 echo "$@ failed after $ATTEMPTS attempts" +exit 1 \ No newline at end of file From 81e99c5364b8117ddef2b4f7d44528bfc06d800d Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:33:54 +0000 Subject: [PATCH 19/20] try fix --- .github/ensure-builder/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ensure-builder/install b/.github/ensure-builder/install index eecdbd8bee4..336b20d68d0 100755 --- a/.github/ensure-builder/install +++ b/.github/ensure-builder/install @@ -32,7 +32,7 @@ if ! command -v jq >/dev/null; then sudo mv ./jq /usr/bin/jq fi function install_parallel() { - sudo apt update && sudo apt install parallel + sudo apt update && sudo systemctl stop unattended-upgrades && sudo apt install parallel } export -f install_parallel if ! command -v parallel >/dev/null; then From 614191bb7e12b9cbe7413a1f2b2a05377d630d63 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 20 Dec 2024 20:36:49 +0000 Subject: [PATCH 20/20] gogo --- .github/ensure-builder/chron | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/ensure-builder/chron diff --git a/.github/ensure-builder/chron b/.github/ensure-builder/chron old mode 100644 new mode 100755