diff --git a/.circleci/config.yml b/.circleci/config.yml index 49f9588d930..ac54d75ec06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -407,18 +407,6 @@ jobs: command: create_ecr_manifest yarn-project x86_64,arm64 aztec_manifest_key: yarn-project - yarn-project-test: - docker: - - image: aztecprotocol/alpine-build-image - resource_class: small - steps: - - *checkout - - *setup_env - - run: - name: "Build and test" - command: cond_spot_run_build yarn-project-test 64 - aztec_manifest_key: yarn-project-test - prover-client-test: docker: - image: aztecprotocol/alpine-build-image @@ -443,30 +431,6 @@ jobs: command: build aztec aztec_manifest_key: aztec - mainnet-fork: - machine: - image: default - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: "Build" - command: build mainnet-fork | add_timestamps - aztec_manifest_key: mainnet-fork - - aztec-faucet: - machine: - image: default - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: "Build and test" - command: build aztec-faucet | add_timestamps - aztec_manifest_key: aztec-faucet - boxes: docker: - image: aztecprotocol/alpine-build-image @@ -609,14 +573,6 @@ jobs: should_release || exit 0 deploy_dockerhub noir deploy_dockerhub aztec - deploy_dockerhub aztec-faucet - deploy_dockerhub mainnet-fork - - run: - name: "Deploy mainnet fork" - command: | - should_deploy || exit 0 - deploy_terraform_services iac/mainnet-fork mainnet-fork mainnet-fork aws_efs_file_system.aztec_mainnet_fork_data_store - ./iac/mainnet-fork/scripts/wait_for_fork - run: name: "Release canary to NPM: bb.js" command: | @@ -647,43 +603,6 @@ jobs: command: | should_release || exit 0 deploy_npm l1-contracts latest - - run: - name: "Deploy L1 contracts to mainnet fork" - working_directory: l1-contracts - command: | - should_deploy || exit 0 - ./scripts/ci_deploy_contracts.sh - - run: - name: "Deploy P2P bootstrap servers to AWS" - command: | - should_deploy 0 || exit 0 - # Export variables for Terraform. - export TF_VAR_BOOTNODE_1_PRIVATE_KEY=$BOOTNODE_1_PRIVATE_KEY - export TF_VAR_BOOTNODE_2_PRIVATE_KEY=$BOOTNODE_2_PRIVATE_KEY - deploy_terraform_services yarn-project/p2p-bootstrap aztec - - run: - name: "Deploy Aztec Nodes to AWS" - command: | - should_deploy 0 || exit 0 - export TF_VAR_BOOTNODE_1_PEER_ID=$BOOTNODE_1_PEER_ID - export TF_VAR_BOOTNODE_2_PEER_ID=$BOOTNODE_2_PEER_ID - export TF_VAR_SEQ_1_PUBLISHER_PRIVATE_KEY=$SEQ_1_PUBLISHER_PRIVATE_KEY - export TF_VAR_SEQ_2_PUBLISHER_PRIVATE_KEY=$SEQ_2_PUBLISHER_PRIVATE_KEY - export TF_VAR_NODE_1_PRIVATE_KEY=$NODE_1_PRIVATE_KEY - export TF_VAR_NODE_2_PRIVATE_KEY=$NODE_2_PRIVATE_KEY - # Check if l1-contracts have changed - if [ "$CONTRACTS_DEPLOYED" -eq 1 ]; then - echo "Contracts have changed, taint nodes to force redeploy.." - deploy_terraform_services yarn-project/aztec-node aztec aztec-node "aws_ecs_task_definition.aztec-node[0],aws_ecs_task_definition.aztec-node[1]" 1 - else - deploy_terraform_services yarn-project/aztec-node aztec - fi - - run: - name: "Deploy Aztec Faucet to AWS" - command: | - should_deploy 0 || exit 0 - export TF_VAR_FAUCET_PRIVATE_KEY=$FAUCET_PRIVATE_KEY - deploy_terraform_services yarn-project/aztec-faucet aztec # Repeatable config for defining the workflow below. defaults: &defaults @@ -807,8 +726,6 @@ workflows: - l1-contracts: *defaults - - mainnet-fork: *defaults - - noir-projects: requires: - avm-transpiler @@ -824,10 +741,8 @@ workflows: - noir-projects <<: *defaults - end-to-end: *defaults_yarn_project - - aztec-faucet: *defaults_yarn_project_pre_join - build-docs: *defaults_yarn_project_pre_join - prover-client-test: *defaults_yarn_project - - yarn-project-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: @@ -873,11 +788,9 @@ workflows: - barretenberg-acir-tests-bb-sol - barretenberg-docs - build-docs - - mainnet-fork - boxes-vanilla - boxes-react - noir-packages-tests - - yarn-project-test - prover-client-test - e2e-join <<: *defaults diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fee521f74c..23c4d074d2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,8 +77,6 @@ jobs: bb-native-tests: needs: setup runs-on: ${{ inputs.username || github.actor }}-x86 - strategy: - fail-fast: false steps: - {uses: actions/checkout@v4, with: { ref: "${{ github.event.pull_request.head.sha }}"}} # Only allow one memory-hunger prover test to use this runner @@ -93,6 +91,34 @@ jobs: # limit our parallelism to half our cores run: earthly --no-output +test --hardware_concurrency=64 + yarn-project-formatting: + needs: setup + runs-on: ${{ github.actor }}-x86 + steps: + - {uses: actions/checkout@v4, with: { ref: "${{ github.event.pull_request.head.sha }}"}} + # Only allow one memory-hunger prover test to use this runner + - uses: ./.github/ci-setup-action + with: + dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}" + concurrency_key: yarn-project-test-${{ github.actor }}-x86 + - name: "Yarn Project Tests" + timeout-minutes: 25 + run: earthly --no-output ./yarn-project/+format-check + + yarn-project-test: + needs: setup + runs-on: ${{ github.actor }}-x86 + steps: + - {uses: actions/checkout@v4, with: { ref: "${{ github.event.pull_request.head.sha }}"}} + # Only allow one memory-hunger prover test to use this runner + - uses: ./.github/ci-setup-action + with: + dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}" + concurrency_key: yarn-project-test-${{ github.actor }}-x86 + - name: "Yarn Project Tests" + timeout-minutes: 25 + run: earthly --no-output ./yarn-project/+test + # push benchmarking binaries to dockerhub registry bb-bench-binaries: needs: setup @@ -142,13 +168,13 @@ jobs: run: earthly --no-output +bench-ultra-honk --bench_mode=cache merge-check: - runs-on: ${{ inputs.username || github.actor }}-x86 - needs: [e2e, bb-native-tests, bb-bench] + runs-on: ubuntu-latest + needs: [e2e, bb-native-tests, bb-bench, yarn-project-formatting, yarn-project-test] steps: - run: echo Pull request merging now allowed. notify: - needs: [e2e, bb-native-tests, bb-bench] + needs: [e2e, bb-native-tests, bb-bench, yarn-project-formatting, yarn-project-test] runs-on: ubuntu-latest if: ${{ github.ref == 'refs/heads/master' && failure() }} steps: diff --git a/.github/workflows/setup-runner.yml b/.github/workflows/setup-runner.yml index 2863a7a63f2..b0b4139d8bf 100644 --- a/.github/workflows/setup-runner.yml +++ b/.github/workflows/setup-runner.yml @@ -58,7 +58,7 @@ jobs: group: start-builder-${{ inputs.runner_label }} steps: - name: Start EC2 runner - uses: AztecProtocol/ec2-action-builder@v0.15 + 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 }} diff --git a/build_manifest.yml b/build_manifest.yml index 7fa488e722f..6c79c6810d4 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -201,14 +201,6 @@ aztec: - yarn-project multiarch: buildx -# Aztec faucet server. Has these dependencies because it's part of workspace. Consider moving out? -aztec-faucet: - buildDir: yarn-project - projectDir: yarn-project/aztec-faucet - dependencies: - - bb.js - - noir-packages - # Builds all the boxes. They are then independently tested in the container. boxes: buildDir: boxes @@ -234,10 +226,6 @@ end-to-end: runDependencies: - aztec -mainnet-fork: - buildDir: iac/mainnet-fork - projectDir: iac/mainnet-fork - docs: buildDir: . dockerfile: docs/Dockerfile diff --git a/docs/docs/protocol-specs/gas-and-fees/fee-payments-and-metering.md b/docs/docs/protocol-specs/gas-and-fees/fee-payments-and-metering.md index b8a7c1db90e..1e3f882b4b5 100644 --- a/docs/docs/protocol-specs/gas-and-fees/fee-payments-and-metering.md +++ b/docs/docs/protocol-specs/gas-and-fees/fee-payments-and-metering.md @@ -57,7 +57,7 @@ All of these phases occur **within the same transaction**, ultimately resulting ![Transaction Components](/img/protocol-specs/gas-and-fees/Transaction.png) -The fee preparation and fee distribution phases respectively are responsible for ensuring that sufficient quantity of the fee payment asset is made available for the transaction and that it is correctly distributed to the sequencer with any refund being returned to the transaction sender. The sequencer will have have agency over which contract methods they are willing to accept for execution in these phases and will have visibility over the arguments passed to them. This is important as these functions must be successfully executed in order for the sequencer to be paid. It is assumed that the network will settle on a number of universally recognised fee payment contracts implementing fee preparation and distribution. +The fee preparation and fee distribution phases respectively are responsible for ensuring that sufficient quantity of the fee payment asset is made available for the transaction and that it is correctly distributed to the sequencer with any refund being returned to the transaction sender. The sequencer will have have agency over which contract methods they are willing to accept for execution in these phases and will have visibility over the arguments passed to them. This is important as these functions must be successfully executed in order for the sequencer to be paid. It is assumed that the network will settle on a number of universally recognized fee payment contracts implementing fee preparation and distribution. ## Gas Metering @@ -80,15 +80,15 @@ A comprehensive table of gas consuming operations can be found in the [fee sched ## Paying Transaction Fees -Transactions will need to be provided with sufficient fees to cover their gas consumption. The [private kernel circuits](../circuits/high-level-topology.md) understand a transaction's private execution as having 2 phases. The first phase is for the payment of fees. It is during this phase that the private execution must generate side-effects and enqueued function calls for the fee preparation and fee distribution phases of the transaction. These side-effects are deemed non-revertible. Typically, only contracts designed to be written as transaction entrypoints will need to be concerned with these phases and once the fee payment execution is complete, the transaction is moved to the second phase where all execution is considered the appication logic. The [private kernel circuits](../circuits/high-level-topology.md) maintain a 'high water mark' of side effects below which those side effects are deemed non-revertible. +Transactions will need to be provided with sufficient fees to cover their gas consumption. The [private kernel circuits](../circuits/high-level-topology.md) understand a transaction's private execution as having 2 phases. The first phase is for the payment of fees. It is during this phase that the private execution must generate side-effects and enqueued function calls for the fee preparation and fee distribution phases of the transaction. These side-effects are deemed non-revertible. Typically, only contracts designed to be written as transaction entrypoints will need to be concerned with these phases and once the fee payment execution is complete, the transaction is moved to the second phase where all execution is considered the application logic. The [private kernel circuits](../circuits/high-level-topology.md) maintain a 'high water mark' of side effects below which those side effects are deemed non-revertible. Transaction senders will need to compute a sufficient fee for the transaction considering both the transaction specific and amortized gas consumption. Transaction specific L1, L2, and DA gas can be calculated via simulation whereas amortized gas will need to be calculated by using a transaction sender specified minimum amortization. This minimum amortization is simply the minimum sized rollup that the transaction sender is willing to be included in. From this value, the amortized L1, L2 and DA gas values can be determined. Finally, a fixed amount of gas for the execution of fee distribution will need to be specified. An example of L2 gas amortization could be the transaction sender specifying a minimum amortization of 1024 transactions. The transaction sender would then compute the amount of amortized gas required for a rollup of that size: ``` -TotalGasToBeAmortised = (1024 - 2) * GMerge + GRoot -L2AmortizedGasLimit = TotalGasToBeAmortised / 1024 +TotalGasToBeAmortized = (1024 - 2) * GMerge + GRoot +L2AmortizedGasLimit = TotalGasToBeAmortized / 1024 Where GMerge = The gas cost of proving the merge rollup circuit. @@ -197,18 +197,16 @@ sequenceDiagram Alice->>AccountContract: run entrypoint AccountContract->>FPA: enqueue FPA.pay_fee(max_fee) msg_sender == Alice as fee distribution function AccountContract->>App: app logic - App->>AccountContract: + App->>AccountContract: response AccountContract->>Alice: finished private execution Alice->>Sequencer: tx object - Sequencer->>Sequencer: Recognise whitelisted function FPA.pay_fee(max_fee) and msg.sender == Alice + Sequencer->>Sequencer: Recognize whitelisted function FPA.pay_fee(max_fee) and msg.sender == Alice Sequencer->>FPA: verify that Alice has >= funds required from tx object FPA->>Sequencer: Alice has >= funds required from tx object - Sequencer->>App: app logic - App->>Sequencer: - + App->>Sequencer: response Sequencer->>FPA: FPA.pay_fee(max_fee) FPA->>FPA: calculate fee based on inputs to VM circuit FPA->>Alice: Alice's balance is reduced by fee amount @@ -241,19 +239,19 @@ sequenceDiagram FPC->>AST: AST.transfer(FPC, max_fee + commission, nonce) AST->>AccountContract: check auth witness FPC->>FPC: enqueue FPA.private_fee_payment(max_fee) msg_sender == FPC as fee distribution function - FPC->>AccountContract: + FPC->>AccountContract: response AccountContract->>App: app logic - App->>AccountContract: + App->>AccountContract: response AccountContract->>Alice: finished private execution Alice->>Sequencer: tx object - Sequencer->>Sequencer: Recognise whitelisted function FPA.private_fee_payment(max_fee) and msg.sender == FPC + Sequencer->>Sequencer: Recognize whitelisted function FPA.private_fee_payment(max_fee) and msg.sender == FPC Sequencer->>FPA: verify that FPC has >= funds required from tx object FPA->>Sequencer: FPC has >= funds required from tx object Sequencer->>App: app logic - App->>Sequencer: + App->>Sequencer: response Sequencer->>FPA: FPA.private_fee_payment(max_fee) FPA->>FPA: calculate fee based on inputs to VM circuit @@ -282,35 +280,34 @@ sequenceDiagram end Alice->>AccountContract: run entrypoint - AccountContract->>AccountContract: pulic auth witness for AST transfer + AccountContract->>AccountContract: public auth witness for AST transfer AccountContract->>FPC: public_fee_entrypoint(AST, max_fee, nonce) activate FPC FPC->>FPC: enqueue FPC.public_fee_preparation(Alice, AST, max_fee, nonce) as fee preparation with msg_sender == FPC FPC->>FPC: enqueue FPC.public_fee_payment(Alice, AST, max_fee) as fee distribution with msg_sender == FPC - FPC->>AccountContract: - deactivate FPC + FPC->>AccountContract: deactivate FPC AccountContract->>App: app logic - App->>AccountContract: + App->>AccountContract: response AccountContract->>Alice: finished private execution Alice->>Sequencer: tx object - Sequencer->>Sequencer: Recognise whitelisted function FPC.public_fee_preparation(Alice, AST, max_fee, nonce) and msg.sender == FPC + Sequencer->>Sequencer: Recognize whitelisted function FPC.public_fee_preparation(Alice, AST, max_fee, nonce) and msg.sender == FPC Sequencer->>FPC: FPC.public_fee_preparation(Alice, AST, max_fee, nonce) activate FPC FPC->>AST: AST.transfer_public(Alice, FPC, max_fee + commission, nonce) AST->>AccountContract: check auth witness - AccountContract->>AST: - AST->>FPC: + AccountContract->>AST: response + AST->>FPC: response FPC->>FPA: FPA.check_balance(max_fee) - FPA->>FPC: + FPA->>FPC: response FPC->>Sequencer: FPC has the funds deactivate FPC Sequencer->>App: app logic - App->>Sequencer: + App->>Sequencer: response - Sequencer->>Sequencer: Recognise whitelisted function FPC.public_fee_payment(Alice, AST, max_fee) and msg.sender == FPC + Sequencer->>Sequencer: Recognize whitelisted function FPC.public_fee_payment(Alice, AST, max_fee) and msg.sender == FPC Sequencer->>FPC: FPC.public_fee_payment(Alice, AST, max_fee) activate FPC FPC->>FPA: FPA.pay_fee(max_fee) @@ -318,14 +315,14 @@ sequenceDiagram FPA->>Sequencer: Sequencer's balance is increased by fee amount FPA->>FPC: rebate value FPC->>AST: AST.transfer_public(FPC, Alice, rebate, 0) - AST->>FPC: + AST->>FPC: response FPC->>Alice: Alice's balance is increased by rebate value deactivate FPC ``` ### DApp Sponsorship -In this scenario a DApp wishes to pay the fee on behalf of a user for interactng with it. The DApp has a balance of FPA from which it wishes to pay for the transaction. It shares many similarities with the previous native asset fee payment scenario. +In this scenario a DApp wishes to pay the fee on behalf of a user for interacting with it. The DApp has a balance of FPA from which it wishes to pay for the transaction. It shares many similarities with the previous native asset fee payment scenario. ```mermaid sequenceDiagram @@ -342,7 +339,7 @@ sequenceDiagram Alice->>DApp: run entrypoint DApp->>AccountContract: check auth witness - AccountContract->>DApp: + AccountContract->>DApp: app logic DApp->>DApp: check if will sponsor action DApp->>FPA: enqueue FPA.pay_fee(max_fee) and msg_sender == DApp as fee distribution DApp->>DApp: app logic @@ -350,13 +347,12 @@ sequenceDiagram Alice->>Sequencer: tx object - Sequencer->>Sequencer: Recognise whitelisted function FPA.pay_fee(max_fee) and msg.sender == DApp + Sequencer->>Sequencer: Recognize whitelisted function FPA.pay_fee(max_fee) and msg.sender == DApp Sequencer->>FPA: verify that DApp has >= funds required from tx object FPA->>Sequencer: DApp has >= funds required from tx object Sequencer->>DApp: app logic - DApp->>Sequencer: - + DApp->>Sequencer: response Sequencer->>FPA: FPA.pay_fee(max_fee) FPA->>FPA: calculate fee based on inputs to VM circuit FPA->>DApp: DApp's balance is reduced by fee amount diff --git a/docs/docs/protocol-specs/l1-smart-contracts/index.md b/docs/docs/protocol-specs/l1-smart-contracts/index.md index 0a2f7a924d8..a7ea92cc4b6 100644 --- a/docs/docs/protocol-specs/l1-smart-contracts/index.md +++ b/docs/docs/protocol-specs/l1-smart-contracts/index.md @@ -12,7 +12,8 @@ The purpose of the L1 contracts are simple: - Facilitate cross-chain communication such that L1 liquidity can be used on L2 - Act as a validating light node for L2 that every L1 node implicitly run - ::: + +::: ## Overview @@ -41,10 +42,12 @@ def process(block: ProvenBlock, proof: Proof): ``` :::info Why `math.ceil(log2(MAX_NEW_L2_TO_L1_MSGS_PER_TX))`? + The argument to the `insert` function is the `outbox` is the heigh of the message tree. Since every transaction can hold more than 1 message, it might add multiple layers to the tree. For a binary tree, the number of extra layers to add is computed as `math.ceil(log2(MAX_NEW_L2_TO_L1_MSGS_PER_TX))`. Currently, `MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2` which means that we are simply adding 1 extra layer. + ::: While the `ProvenBlock` must be published and available for nodes to build the state of the rollup, we can build the validating light node (the contract) such that as long as the node can be _convinced_ that the data is available we can progress the state. diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 0118394dc78..c582587cd7d 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -93,3 +93,11 @@ export-end-to-end: SAVE IMAGE aztecprotocol/end-to-end:$EARTHLY_GIT_HASH FROM +aztec SAVE IMAGE aztecprotocol/aztec:$EARTHLY_GIT_HASH + +format-check: + FROM +build + RUN yarn formatting + +test: + FROM +build + RUN yarn test \ No newline at end of file