Skip to content

Commit

Permalink
Merge branch 'master' into chore/typo-redo-5913
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad authored Apr 22, 2024
2 parents 937d6ce + d8254ef commit d27d5c2
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 135 deletions.
87 changes: 0 additions & 87 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -807,8 +726,6 @@ workflows:

- l1-contracts: *defaults

- mainnet-fork: *defaults

- noir-projects:
requires:
- avm-transpiler
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
12 changes: 0 additions & 12 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -234,10 +226,6 @@ end-to-end:
runDependencies:
- aztec

mainnet-fork:
buildDir: iac/mainnet-fork
projectDir: iac/mainnet-fork

docs:
buildDir: .
dockerfile: docs/Dockerfile
Expand Down
54 changes: 25 additions & 29 deletions docs/docs/protocol-specs/gas-and-fees/fee-payments-and-metering.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -282,50 +280,49 @@ 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)
FPA->>FPA: calculate fee based on inputs to VM circuit
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
Expand All @@ -342,21 +339,20 @@ 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
DApp->>Alice: finished private execution
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
Expand Down
Loading

0 comments on commit d27d5c2

Please sign in to comment.