Skip to content

Commit

Permalink
Merge branch 'master' into 04-12-refactor_update_nullifier_derivation…
Browse files Browse the repository at this point in the history
…_verification
  • Loading branch information
benesjan committed Apr 19, 2024
2 parents 2a260fb + e14cffa commit ab73b47
Show file tree
Hide file tree
Showing 98 changed files with 3,159 additions and 1,744 deletions.
File renamed without changes.
23 changes: 23 additions & 0 deletions .devcontainer/react/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "React App",
"image": "node:lts-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": "cp -R /root/workspace /root/scripts && rm -rf /root/workspace/* && sh /root/scripts/onCreateCommand.sh app react",
"postAttachCommand": "sh /root/scripts/postAttachCommand.sh app react",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/scripts,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace",
"forwardPorts": [8080]
}
22 changes: 22 additions & 0 deletions .devcontainer/scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

TYPE=$1
NAME=$2

apt install gh

curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s
docker compose -f $HOME/.aztec/docker-compose.yml pull

if ! grep -q "PXE_URL" ~/.bashrc; then
echo "export PXE_URL=https://\$CODESPACE_NAME-8080.preview.\$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" >> ~/.bashrc
fi

yes | npx create-aztec-app -t $TYPE -n $NAME -s
mv react/* react/.* .
rm -rf react

yarn

npx -y playwright install --with-deps
yarn prep
64 changes: 64 additions & 0 deletions .devcontainer/scripts/postAttachCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
TYPE=$1
NAME=$2

gh codespace ports visibility 8080:public -c $CODESPACE_NAME

(nohup /usr/local/bin/aztec sandbox &)

r=$(tput sgr0) # Reset color
bold=$(tput bold) # Bold text
g=$(tput setaf 46) # Light Green
b=$(tput setaf 21) # Bright Blue
p=$(tput setaf 13) # Magenta
y=$(tput setaf 226) # Bright Yellow
c=$(tput setaf 51) # Cyan
o=$(tput setaf 208) # Orange

# Function to print colored text
print_colored() {
case $2 in
green)
color=$g
;;
blue)
color=$b
;;
magenta)
color=$p
;;
yellow)
color=$y
;;
cyan)
color=$c
;;
orange)
color=$o
;;
*)
color=$r
;;
esac
echo "${color}$1${r}"
}

echo
echo "${bold}${c} █████╗ ███████╗████████╗███████╗ ██████╗${r}"
echo "${bold}${o}██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝${r}"
echo "${bold}${g}███████║ ███╔╝ ██║ █████╗ ██║${r}"
echo "${bold}${b}██╔══██║ ███╔╝ ██║ ██╔══╝ ██║${r}"
echo "${bold}${p}██║ ██║███████╗ ██║ ███████╗╚██████╗${r}"
echo "${bold}${y}╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝${r}"
echo
print_colored "${bold}Sandbox Codespace" "cyan"
print_colored "${bold}Your codespace is ready with your chosen box! 🎉" "cyan"
echo
print_colored "All the packages are already installed, and you can now run yarn dev or any other package.json script." "magenta"
print_colored "You can also use this codespace for its running sandbox, by connecting your local environment to it." "magenta"
echo
print_colored "To do so, set the PXE_URL to this codespace's sandbox URL:" "magenta"
print_colored "${PXE_URL}" "green"
print_colored "ex. PXE_URL=\"${PXE_URL}\" yarn dev"
echo
print_colored "${bold}Enjoy your sandbox! 🏖️" "orange"
30 changes: 30 additions & 0 deletions .devcontainer/token/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Token Contract Only",
"image": "node:lts-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": ".devcontainer/scripts/onCreateCommand.sh contract token_contract",
"postAttachCommand": ".devcontainer/scripts/postAttachCommand.sh contract token_contract",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/token_contract,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace",
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"mounts": [
{
"source": "${localWorkspaceFolder}/.devcontainer/scripts",
"target": "/root/workspace/.devcontainer/scripts",
"type": "bind"
}
],
"forwardPorts": [8080]
}
30 changes: 30 additions & 0 deletions .devcontainer/vanilla/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Vanilla Typescript App",
"image": "node:lts-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": ".devcontainer/scripts/onCreateCommand.sh app vanilla",
"postAttachCommand": ".devcontainer/scripts/postAttachCommand.sh app vanilla",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/vanilla,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace",
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"mounts": [
{
"source": "${localWorkspaceFolder}/.devcontainer/scripts",
"target": "/root/workspace/.devcontainer/scripts",
"type": "bind"
}
],
"forwardPorts": [8080]
}
15 changes: 15 additions & 0 deletions .github/workflows/ci-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ jobs:
working-directory: ./yarn-project/end-to-end/
timeout-minutes: 15
run: earthly -P --no-output +uniswap-trade-on-l1-from-l2 --e2e_mode=cache

notify:
needs: [e2e]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' && failure() }}
steps:
- name: Send notification to aztec3-ci channel if workflow failed on master
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WORKFLOW_TRIGGER_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
runner_label: ${{ github.actor }}-x86
ebs_cache_size_gb: 256
runner_concurrency: 50
runner_concurrency: 20
subaction: ${{ github.event.inputs.runner_action || 'start' }}
ec2_instance_type: m6a.32xlarge
ec2_ami_id: ami-04d8422a9ba4de80f
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/setup-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
ec2_ami_id:
required: true
type: string
# how much time to add to shutdown when a job finishes or starts
ec2_instance_ttl:
required: true
type: number
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:
group: start-builder-${{ inputs.runner_label }}
steps:
- name: Start EC2 runner
uses: AztecProtocol/ec2-action-builder@v0.13
uses: AztecProtocol/ec2-action-builder@v0.14e
with:
github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down Expand Up @@ -96,15 +97,20 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: ./scripts/attach_ebs_cache.sh ${{ inputs.runner_label }} ${{ inputs.ebs_cache_size_gb }}

- name: Configure and Restart Docker
- name: Configure Machine
shell: bash
run: |
# We need to restart after attaching disk cache
# Both only happen once, so we just make sure this happens once
# One-time config
if ! [ -f /etc/docker/daemon.json ] ; then
echo '{"default-address-pools":[{"base":"172.17.0.0/12","size":20}, {"base":"10.99.0.0/12","size":20}, {"base":"192.168.0.0/16","size":24}]}' > /etc/docker/daemon.json
sudo service docker restart
echo "Configured docker daemon for making many networks."
# Run maybe_exit_spot.sh every minute
cp scripts/ci/spot_runner_graceful_exit.sh /run/spot_runner_graceful_exit.sh
cp scripts/ci/maybe_exit_spot.sh /run/maybe_exit_spot.sh
chmod +x /run/spot_runner_graceful_exit.sh
chmod +x /run/maybe_exit_spot.sh
echo "* * * * * /run/maybe_exit_spot.sh" | crontab -
else
echo "Docker daemon already configured."
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/start-spot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
with:
runner_label: ${{ github.actor }}-x86
ebs_cache_size_gb: 256
runner_concurrency: 50
runner_concurrency: 20
subaction: start
ec2_instance_type: m6a.32xlarge
ec2_ami_id: ami-04d8422a9ba4de80f
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stop-spot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
subaction: stop
# not used:
ebs_cache_size_gb: 128
runner_concurrency: 50
runner_concurrency: 20
ec2_instance_type: m6a.32xlarge
ec2_ami_id: ami-0d8a9b0419ddb331a
ec2_instance_ttl: 40
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = ed310b6d7e43b47913afacb717513cd4ff2d57dd
parent = 3fb94c0cd5ffba20a99b97c0088ae5ef357c205d
commit = 1b2ec21d9f8372ec5d79a510273e043bd3d79bb2
parent = ec21fb8251c34d535fd0c5e08f354cfa22c25320
method = merge
cmdver = 0.4.6
59 changes: 51 additions & 8 deletions barretenberg/cpp/pil/avm/avm_alu.pil
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ namespace avm_alu(256);
pol commit op_div;
pol commit op_not;
pol commit op_eq;
pol commit op_cast;
pol commit op_cast_prev; // Predicate on whether op_cast is enabled at previous row
pol commit alu_sel; // Predicate to activate the copy of intermediate registers to ALU table.
pol commit op_lt;
pol commit op_lte;
pol commit cmp_sel; // Predicate if LT or LTE is set
pol commit rng_chk_sel; // Predicate representing a range check row.
pol commit rng_chk_sel; // Predicate representing a range check row used in LT/LTE.

// Instruction tag (1: u8, 2: u16, 3: u32, 4: u64, 5: u128, 6: field) copied from Main table
pol commit in_tag;
Expand Down Expand Up @@ -59,7 +61,7 @@ namespace avm_alu(256);
pol commit cf;

// Compute predicate telling whether there is a row entry in the ALU table.
alu_sel = op_add + op_sub + op_mul + op_not + op_eq + op_lt + op_lte;
alu_sel = op_add + op_sub + op_mul + op_not + op_eq + op_cast + op_lt + op_lte;
cmp_sel = op_lt + op_lte;

// ========= Type Constraints =============================================
Expand Down Expand Up @@ -282,15 +284,15 @@ namespace avm_alu(256);
// (x - y - 1) * q + (y - x) (1 - q) = result

// If LT, then swap ia and ib else keep the same
pol INPUT_IA = op_lt * ib + op_lte * ia;
pol INPUT_IA = op_lt * ib + (op_lte + op_cast) * ia;
pol INPUT_IB = op_lt * ia + op_lte * ib;

pol commit borrow;
pol commit a_lo;
pol commit a_hi;
// Check INPUT_IA is well formed from its lo and hi limbs
#[INPUT_DECOMP_1]
INPUT_IA = (a_lo + 2 ** 128 * a_hi) * cmp_sel;
INPUT_IA = (a_lo + 2 ** 128 * a_hi) * (cmp_sel + op_cast);

pol commit b_lo;
pol commit b_hi;
Expand All @@ -311,9 +313,9 @@ namespace avm_alu(256);
// First condition is if borrow = 0, second condition is if borrow = 1
// This underflow check is done by the 128-bit check that is performed on each of these lo and hi limbs.
#[SUB_LO_1]
(p_sub_a_lo - (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128)) * cmp_sel = 0;
(p_sub_a_lo - (53438638232309528389504892708671455232 - a_lo + p_a_borrow * 2 ** 128)) * (cmp_sel + op_cast) = 0;
#[SUB_HI_1]
(p_sub_a_hi - (64323764613183177041862057485226039389 - a_hi - p_a_borrow)) * cmp_sel = 0;
(p_sub_a_hi - (64323764613183177041862057485226039389 - a_hi - p_a_borrow)) * (cmp_sel + op_cast) = 0;

pol commit p_sub_b_lo;
pol commit p_sub_b_hi;
Expand Down Expand Up @@ -432,11 +434,11 @@ namespace avm_alu(256);
cmp_rng_ctr * ((1 - rng_chk_sel) * (1 - op_eq_diff_inv) + op_eq_diff_inv) - rng_chk_sel = 0;

// We perform a range check if we have some range checks remaining or we are performing a comparison op
pol RNG_CHK_OP = rng_chk_sel + cmp_sel;
pol RNG_CHK_OP = rng_chk_sel + cmp_sel + op_cast + op_cast_prev;

pol commit rng_chk_lookup_selector;
#[RNG_CHK_LOOKUP_SELECTOR]
rng_chk_lookup_selector' = cmp_sel' + rng_chk_sel' + op_add' + op_sub' + op_mul' + op_mul * u128_tag;
rng_chk_lookup_selector' = cmp_sel' + rng_chk_sel' + op_add' + op_sub' + op_mul' + op_mul * u128_tag + op_cast' + op_cast_prev';

// Perform 128-bit range check on lo part
#[LOWER_CMP_RNG_CHK]
Expand Down Expand Up @@ -467,3 +469,44 @@ namespace avm_alu(256);
(p_sub_b_lo' - res_lo) * rng_chk_sel'= 0;
(p_sub_b_hi' - res_hi) * rng_chk_sel'= 0;


// ========= CAST Operation Constraints ===============================
// We handle the input ia independently of its tag, i.e., we suppose it can take
// any value between 0 and p-1.
// We decompose the input ia in 8-bit/16-bit limbs and prove that the decomposition
// sums up to ia over the integers (i.e., no modulo p wrapping). To prove this, we
// re-use techniques above from LT/LTE opcode. The following relations are toggled for CAST:
// - #[INPUT_DECOMP_1] shows a = a_lo + 2 ** 128 * a_hi
// - #[SUB_LO_1] and #[SUB_LO_1] shows that the above does not overflow modulo p.
// - We toggle RNG_CHK_OP with op_cast to show that a_lo, a_hi are correctly decomposed
// over the 8/16-bit ALU registers in #[LOWER_CMP_RNG_CHK] and #[UPPER_CMP_RNG_CHK].
// - The 128-bit range checks for a_lo, a_hi are activated in #[RNG_CHK_LOOKUP_SELECTOR].
// - We copy p_sub_a_lo resp. p_sub_a_hi into next row in columns a_lo resp. a_hi so
// that decomposition into the 8/16-bit ALU registers and range checks are performed.
// Copy is done in #[OP_CAST_RNG_CHECK_P_SUB_A_LOW/HIGH] below.
// Activation of decomposition and range check is achieved by adding op_cast_prev in
// #[LOWER_CMP_RNG_CHK], #[UPPER_CMP_RNG_CHK] and #[RNG_CHK_LOOKUP_SELECTOR].
// - Finally, the truncated result SUM_TAG is copied in ic as part of #[ALU_OP_CAST] below.
// - Note that the tag of return value must be constrained to be in_tag and is enforced in
// the main and memory traces.
//
// TODO: Potential optimization is to un-toggle all CAST relevant operations when ff_tag is
// enabled. In this case, ic = ia trivially.
// Another one is to activate range checks in a more granular way depending on the tag.

#[OP_CAST_PREV_LINE]
op_cast_prev' = op_cast;

#[ALU_OP_CAST]
op_cast * (SUM_TAG + ff_tag * ia - ic) = 0;

#[OP_CAST_RNG_CHECK_P_SUB_A_LOW]
op_cast * (a_lo' - p_sub_a_lo) = 0;

#[OP_CAST_RNG_CHECK_P_SUB_A_HIGH]
op_cast * (a_hi' - p_sub_a_hi) = 0;

// 128-bit multiplication and CAST need two rows in ALU trace. We need to ensure
// that another ALU operation does not start in the second row.
#[TWO_LINE_OP_NO_OVERLAP]
(op_mul * ff_tag + op_cast) * alu_sel' = 0;
Loading

0 comments on commit ab73b47

Please sign in to comment.