Skip to content

Commit

Permalink
Merge branch 'master' into docs/sandbox-command-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
catmcgee authored May 2, 2024
2 parents 7771991 + 5b133f2 commit 3f2f498
Show file tree
Hide file tree
Showing 502 changed files with 13,750 additions and 8,330 deletions.
99 changes: 14 additions & 85 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,29 @@ jobs:
command: create_ecr_manifest yarn-project x86_64,arm64
aztec_manifest_key: yarn-project

prover-client-test:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
aztec-package:
machine:
image: default
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Build and test"
command: cond_spot_run_build prover-client-test 128
aztec_manifest_key: prover-client-test
command: build aztec
aztec_manifest_key: aztec

aztec-package:
aztec-builder:
machine:
image: default
resource_class: large
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build and test"
command: build aztec
aztec_manifest_key: aztec
name: "Build image"
command: build aztec-builder
aztec_manifest_key: aztec-builder

boxes:
docker:
Expand Down Expand Up @@ -482,55 +482,6 @@ jobs:
# For old e2e tests see yarn-project/end-to-end/Earthfile
# Semantics are similar to Dockerfile

# NOTE: Unlike other e2e, these will be re-enabled here as currently the logs functionality is not in the new earthfile setup
bench-publish-rollup:
steps:
- *checkout
- *setup_env
- run:
name: "Benchmark"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=benchmarks/bench_publish_rollup.test.ts DEBUG=aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees
aztec_manifest_key: end-to-end
<<: *defaults_e2e_test

bench-process-history:
steps:
- *checkout
- *setup_env
- run:
name: "Benchmark"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=benchmarks/bench_process_history.test.ts DEBUG=aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees
aztec_manifest_key: end-to-end
<<: *defaults_e2e_test

bench-tx-size:
steps:
- *checkout
- *setup_env
- run:
name: "Benchmark"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=benchmarks/bench_tx_size_fees.test.ts ENABLE_GAS=1 DEBUG=aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees
aztec_manifest_key: end-to-end
<<: *defaults_e2e_test

build-docs:
machine:
image: default
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Build docs"
command: |
echo "Building docs"
build docs
- run:
name: "Deploy docs"
command: |
echo "Deploying docs"
docs/deploy_netlify.sh $BRANCH $PULL_REQUEST
e2e-join:
docker:
- image: cimg/base:2023.09
Expand All @@ -549,16 +500,6 @@ jobs:
name: "Noop"
command: echo Noop

bench-summary:
machine:
image: default
steps:
- *checkout
- *setup_env
- run:
name: "Assemble benchmark summary from uploaded logs"
command: ./scripts/ci/assemble_e2e_benchmark.sh

# Deploy & release jobs.
deploy-and-release:
machine:
Expand All @@ -573,6 +514,7 @@ jobs:
should_release || exit 0
deploy_dockerhub noir
deploy_dockerhub aztec
deploy_dockerhub aztec-builder
- run:
name: "Release canary to NPM: bb.js"
command: |
Expand Down Expand Up @@ -741,8 +683,6 @@ workflows:
- noir-projects
<<: *defaults
- end-to-end: *defaults_yarn_project
- build-docs: *defaults_yarn_project_pre_join
- prover-client-test: *defaults_yarn_project
- yarn-project-x86_64: *defaults_yarn_project_pre_join
- yarn-project-arm64: *defaults_yarn_project_pre_join
- yarn-project-ecr-manifest:
Expand All @@ -753,6 +693,7 @@ workflows:

# Artifacts
- aztec-package: *defaults_yarn_project
- aztec-builder: *defaults_yarn_project

# Boxes.
- boxes:
Expand Down Expand Up @@ -787,23 +728,11 @@ workflows:
- barretenberg-acir-tests-bb
- barretenberg-acir-tests-bb-sol
- barretenberg-docs
- build-docs
- boxes-vanilla
- boxes-react
- noir-packages-tests
- prover-client-test
- e2e-join
<<: *defaults

# Benchmark jobs.
- bench-publish-rollup: *e2e_test
- bench-process-history: *e2e_test
- bench-tx-size: *e2e_test
- bench-summary:
requires:
- bench-publish-rollup
- bench-process-history
- bench-tx-size
- aztec-builder
<<: *defaults

# Production releases.
Expand Down
33 changes: 19 additions & 14 deletions .devcontainer/dev/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"image": "node:lts-bookworm-slim",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
"name": "Development",
"build": {
"dockerfile": "../../build-images/Dockerfile",
"context": "../../build-images",
"target": "devbox"
},
"postCreateCommand": "curl -s install.aztec.network | VERSION=master NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s",
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"noir-lang.vscode-noir"
]
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace"
"containerUser": "aztec-dev",
// ubuntu:noble is currently not supported.
// Can possibly workaround cherry-picking from here:
// https://github.com/devcontainers/features/blob/main/src/docker-in-docker/install.sh
//
// "image": "aztecprotocol/codespace",
// "features": {
// "docker-in-docker": {
// "version": "latest",
// "moby": true,
// "dockerDashComposeVersion": "v1"
// }
// },
"mounts": ["source=devbox-home,target=/home/aztec-dev,type=volume"]
}
11 changes: 7 additions & 4 deletions .github/ci-setup-action/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Reusable setup workflow for CI tasks
name: Setup Workflow
description: 'Reusable setup steps'
description: "Reusable setup steps"

inputs:
dockerhub_password:
required: true
description: 'DockerHub Password'
description: "DockerHub Password"
concurrency_key:
required: false
description: 'Concurrency key for locking jobs'
description: "Concurrency key for locking jobs"
runs:
# define an action, runs in OS of caller
using: composite
Expand Down Expand Up @@ -43,11 +43,14 @@ runs:
with:
# permission issue with spot runners, simpler to leave out
use-cache: false
version: 'v0.8.5'
version: "v0.8.5"

- name: Setup Env
shell: bash
run: ./scripts/setup_env.sh ${{ inputs.dockerhub_password }}
env:
PULL_REQUEST: "${{ github.event.pull_request.number }}"
BRANCH: "${{ github.ref_name }}"

# As detailed in https://github.com/ben-z/gh-action-mutex
# things do not become 'pending' in github actions, and instead just cancel one another
Expand Down
4 changes: 0 additions & 4 deletions .github/spot-runner-action/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ inputs:
ec2_ami_id:
description: 'Ec2 ami ID'
required: true
ec2_instance_iam_role:
description: 'IAM role for to associate with ec2 instance'
required: false
default: ''
ec2_instance_tags:
description: 'List of extra aws resource tags for ec2 instance'
required: false
Expand Down
53 changes: 18 additions & 35 deletions .github/spot-runner-action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ActionConfig {
// Ec2 params
this.ec2InstanceType = core.getInput("ec2_instance_type").split(" ");
this.ec2AmiId = core.getInput("ec2_ami_id");
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
Expand Down Expand Up @@ -244,21 +243,23 @@ class Ec2Instance {
getLaunchTemplate() {
return __awaiter(this, void 0, void 0, function* () {
const client = yield this.getEc2Client();
// NOTE: This should be deterministic or we will create a launch template each time
const userData = yield new userdata_1.UserData(this.config).getUserData();
const ec2InstanceTypeHash = this.getHashOfStringArray(this.config.ec2InstanceType.concat([userData]).concat([JSON.stringify(this.tags)]));
const ec2InstanceTypeHash = this.getHashOfStringArray(this.config.ec2InstanceType.concat([userData, JSON.stringify(this.tags), this.config.ec2KeyName]));
const launchTemplateName = "aztec-packages-spot-" + this.config.ec2AmiId + "-" + ec2InstanceTypeHash;
const launchTemplateParams = {
LaunchTemplateName: launchTemplateName,
LaunchTemplateData: {
ImageId: this.config.ec2AmiId,
InstanceInitiatedShutdownBehavior: "terminate",
InstanceRequirements: {
// We do not know what the instance types correspond to
// just let the user send a list of allowed instance types
VCpuCount: { Min: 0 },
MemoryMiB: { Min: 0 },
AllowedInstanceTypes: this.config.ec2InstanceType,
},
SecurityGroupIds: [this.config.ec2SecurityGroupId],
KeyName: this.config.ec2KeyName,
UserData: userData,
TagSpecifications: [
{
Expand All @@ -276,33 +277,20 @@ class Ec2Instance {
],
},
};
let arr = [];
try {
arr = (yield client
.describeLaunchTemplates({
LaunchTemplateNames: [launchTemplateName],
})
.promise()).LaunchTemplates || [];
}
catch (err) {
core.info("Launch templates describe error, note this will be likely resolved by creating the template in the next step: " + err);
}
core.info("Launch templates found: " + JSON.stringify(arr, null, 2));
if (arr.length <= 0) {
core.info("Creating launch template: " + launchTemplateName);
yield client.createLaunchTemplate(launchTemplateParams).promise();
}
core.info("Creating launch template: " + launchTemplateName);
yield client.createLaunchTemplate(launchTemplateParams).promise();
return launchTemplateName;
});
}
requestMachine(useOnDemand) {
return __awaiter(this, void 0, void 0, function* () {
// Note advice re max bid: "If you specify a maximum price, your instances will be interrupted more frequently than if you do not specify this parameter."
const launchTemplateName = yield this.getLaunchTemplate();
const availabilityZone = yield this.getSubnetAz();
const fleetLaunchConfig = {
LaunchTemplateSpecification: {
Version: "$Latest",
LaunchTemplateName: yield this.getLaunchTemplate(),
LaunchTemplateName: launchTemplateName,
},
Overrides: this.config.ec2InstanceType.map((instanceType) => ({
InstanceType: instanceType,
Expand All @@ -323,6 +311,10 @@ class Ec2Instance {
const client = yield this.getEc2Client();
const fleet = yield client.createFleet(createFleetRequest).promise();
const instances = ((fleet === null || fleet === void 0 ? void 0 : fleet.Instances) || [])[0] || {};
// cleanup
yield client.deleteLaunchTemplate({
LaunchTemplateName: launchTemplateName,
});
return (instances.InstanceIds || [])[0];
});
}
Expand Down Expand Up @@ -871,23 +863,14 @@ class UserData {
`mkdir -p shutdown-refcount`,
// Shutdown rules:
// - github actions job starts and ends always bump +ec2InstanceTtl minutes
// - when the amount of started jobs (start_run_* files) equal the amount of finished jobs (end_run_* files), we shutdown in 5 minutes
`echo "${bumpShutdown}; touch /run/shutdown-refcount/start_run_\\$(date +%s)_\\$RANDOM" > /run/delay_shutdown.sh`,
// `echo "[ \\$(find /run/shutdown-refcount/ -name 'start_run_*' | wc -l) -eq \\$(find /run/shutdown-refcount/ -name 'end_run_*' | wc -l) ] && shutdown -P 5 ; true" > /run/if_refcount0_shutdown.sh`,
`echo "echo refcounting disabled for now" > /run/if_refcount0_shutdown.sh`,
`echo "${bumpShutdown}; touch /run/shutdown-refcount/end_run_\\$(date +%s)_\\$RANDOM ; /run/if_refcount0_shutdown.sh " > /run/refcount_and_delay_shutdown.sh`,
`echo "flock /run/refcount-lock /run/delay_shutdown.sh" > /run/safe_delay_shutdown.sh`,
`echo "flock /run/refcount-lock /run/refcount_and_delay_shutdown.sh" > /run/safe_refcount_and_delay_shutdown.sh`,
// - when the amount of started jobs (start_run_* files) equal the amount of finished jobs (end_run_* files), we shutdown in 5 minutes (with a reaper script installed later)
`echo "${bumpShutdown}" > /run/delay_shutdown.sh`,
"chmod +x /run/delay_shutdown.sh",
"chmod +x /run/refcount_and_delay_shutdown.sh",
"chmod +x /run/if_refcount0_shutdown.sh",
"chmod +x /run/safe_refcount_and_delay_shutdown.sh",
"chmod +x /run/safe_if_refcount0_shutdown.sh",
"export ACTIONS_RUNNER_HOOK_JOB_STARTED=/run/safe_delay_shutdown.sh",
"export ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/run/safe_refcount_and_delay_shutdown.sh",
"export ACTIONS_RUNNER_HOOK_JOB_STARTED=/run/delay_shutdown.sh",
"export ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/run/delay_shutdown.sh",
"mkdir -p actions-runner && cd actions-runner",
'echo "ACTIONS_RUNNER_HOOK_JOB_STARTED=/run/safe_delay_shutdown.sh" > .env',
'echo "ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/run/safe_refcount_and_delay_shutdown.sh" > .env',
'echo "ACTIONS_RUNNER_HOOK_JOB_STARTED=/run/delay_shutdown.sh" > .env',
'echo "ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/run/delay_shutdown.sh" > .env',
`GH_RUNNER_VERSION=${githubActionRunnerVersion}`,
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
"curl -O -L https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${GH_RUNNER_VERSION}.tar.gz",
Expand Down
3 changes: 0 additions & 3 deletions .github/spot-runner-action/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface ConfigInterface {

ec2InstanceType: string[];
ec2AmiId: string;
ec2InstanceIamRole: string;
ec2InstanceTags: string;
ec2InstanceTtl: string;
ec2SecurityGroupId: string;
Expand All @@ -46,7 +45,6 @@ export class ActionConfig implements ConfigInterface {

ec2InstanceType: string[];
ec2AmiId: string;
ec2InstanceIamRole: string;
ec2InstanceTags: string;
ec2InstanceTtl: string;
ec2SecurityGroupId: string;
Expand Down Expand Up @@ -77,7 +75,6 @@ export class ActionConfig implements ConfigInterface {
// Ec2 params
this.ec2InstanceType = core.getInput("ec2_instance_type").split(" ");
this.ec2AmiId = core.getInput("ec2_ami_id");
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
Expand Down
Loading

0 comments on commit 3f2f498

Please sign in to comment.