Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Yellow paper section on Gas and Fees #3327

Merged
merged 5 commits into from
Nov 20, 2023
Merged

Conversation

PhilWindle
Copy link
Collaborator

This PR contains the section of the yellow paper for Gas and Fees

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@PhilWindle PhilWindle enabled auto-merge (squash) November 17, 2023 18:00
@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • note_trial_decrypting_time_in_ms (32): 52.1 (-35%)
Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Values are compared against data from master at commit 5a18615f and shown if the difference exceeds 1%.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 128 txs
l1_rollup_calldata_size_in_bytes 45,444 179,588 716,132
l1_rollup_calldata_gas 222,972 867,692 3,449,660
l1_rollup_execution_gas 842,059 3,594,800 22,205,029
l2_block_processing_time_in_ms 2,236 (+11%) 8,566 (+13%) 33,536 (+12%)
note_successful_decrypting_time_in_ms 298 (+2%) 943 (+8%) 3,314 (+4%)
note_trial_decrypting_time_in_ms 99.9 (+4%) ⚠️ 52.1 (-35%) 135 (-15%)
l2_block_building_time_in_ms 21,017 (+2%) 84,398 (+3%) 337,503 (+3%)
l2_block_rollup_simulation_time_in_ms 12,348 (+3%) 49,792 (+5%) 198,192 (+5%)
l2_block_public_tx_process_time_in_ms 8,628 (+1%) 34,467 (+1%) 138,782 (+1%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 22,518 (+2%) 47,201 (+10%)
note_history_successful_decrypting_time_in_ms 2,142 (+2%) 4,414 (+9%)
note_history_trial_decrypting_time_in_ms 122 (+2%) 159 (+10%)
node_database_size_in_bytes 1,628,380 1,094,571
pxe_database_size_in_bytes 29,748 59,307

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 767 (+1%) 61,697 18,905
private-kernel-ordering 127 (+2%) 24,297 8,153
base-rollup 1,796 (+1%) 656,428 873
root-rollup 172 4,072 1,097
private-kernel-inner 792 (+1%) 81,568 18,905
public-kernel-private-input 573 (+1%) 41,519 18,905
public-kernel-non-first-iteration 410 (+1%) 41,561 18,905
merge-rollup 15.8 (+4%) 2,592 873

Miscellaneous

Transaction sizes based on how many contracts are deployed in the tx.

Metric 0 deployed contracts 1 deployed contracts
tx_size_in_bytes 8,787 27,547

Copy link
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Just a couple of minor typos


### Fee Distribution

This component consists of a single public function call to a contract function specified by the client. The function will have a specific signature that will require the sequencer to provide information about the gas consumed throughout the execution of the transaction payload. This function will perform the necessary steps to finalise the payment to the sequencer and any refund owed to the client.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component consists of a single public function call to a contract function specified by the client.

Would this be the same contract as the one used for fee preparation or a different one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be either.


The sequencer will need to specify the intended size of the rollup (determined as part of the sequencer selection commitment phase) and use this value to calculate gas amortisation. These values of amortised L1 and L2 gas will be added to the `l1GasUsed` and `l2GasUsed` accumulators. These accumulators will need to accurately reflect the gas consumption of the transaction prior to public function execution including state updates produced as part of private execution.

Any enqueued public function calls can be simulated by the sequencer to obtain an accurate gas profile of the execution. This simulation will enable the sequencer to compute the number of additional state updates to be made, the number of public function calls and the L2 gas consumption of each of those calls. If either the L1 or L2 gas limits are breached, simulation will identify where in the execution trace this takes place and so the sequencer will only need to perform iterations of the public VM and public kernel circuits for the calls that either partially or completely succeeded. This ensures that the sequencer is not forced to exeucte and prove circuits for which they will not be compensated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Any enqueued public function calls can be simulated by the sequencer to obtain an accurate gas profile of the execution. This simulation will enable the sequencer to compute the number of additional state updates to be made, the number of public function calls and the L2 gas consumption of each of those calls. If either the L1 or L2 gas limits are breached, simulation will identify where in the execution trace this takes place and so the sequencer will only need to perform iterations of the public VM and public kernel circuits for the calls that either partially or completely succeeded. This ensures that the sequencer is not forced to exeucte and prove circuits for which they will not be compensated.
Any enqueued public function calls can be simulated by the sequencer to obtain an accurate gas profile of the execution. This simulation will enable the sequencer to compute the number of additional state updates to be made, the number of public function calls and the L2 gas consumption of each of those calls. If either the L1 or L2 gas limits are breached, simulation will identify where in the execution trace this takes place and so the sequencer will only need to perform iterations of the public VM and public kernel circuits for the calls that either partially or completely succeeded. This ensures that the sequencer is not forced to execute and prove circuits for which they will not be compensated.


Once public function execution has completed (or hit the gas limit), the fee distribution component is executed. This is a public function and will also need to be proven via the VM and publc kernel circuits. The sequencer will have agency over which functions they are willing to accept and this will be part of the earlier transaction acceptance.

The total fee taken by the sequencer is calculated from the values of consumed L1 and L2 gas and the `feePerGas` values provided with the transaction. Any balance reamining must be refunded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The total fee taken by the sequencer is calculated from the values of consumed L1 and L2 gas and the `feePerGas` values provided with the transaction. Any balance reamining must be refunded.
The total fee taken by the sequencer is calculated from the values of consumed L1 and L2 gas and the `feePerGas` values provided with the transaction. Any balance remaining must be refunded.

@PhilWindle PhilWindle merged commit caa7e10 into master Nov 20, 2023
79 checks passed
@PhilWindle PhilWindle deleted the pw/yellow-paper-fees branch November 20, 2023 08:23
rahul-kothari pushed a commit that referenced this pull request Nov 21, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.15.1</summary>

##
[0.15.1](aztec-packages-v0.15.0...aztec-packages-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](#3335))
([c99862c](c99862c))
* DataBus PoC (UltraHonk as extension of Ultra)
([#3181](#3181))
([dd9dd84](dd9dd84))
* Deploy docs from CCI w/ netlify-cli
([#3348](#3348))
([624d733](624d733))
* Fold batching challenge (alpha)
([#3291](#3291))
([bc99a4f](bc99a4f))
* Open transcript polys as univariates in ECCVM
([#3331](#3331))
([436b22e](436b22e))
* Sandbox packages
([#3360](#3360))
([0dc2d58](0dc2d58))
* Slow updates experimentation
([#2732](#2732))
([193e6c8](193e6c8))
* ZM updates for Translator concatenated polys
([#3343](#3343))
([0e425db](0e425db))


### Bug Fixes

* Bootstrap bbjs.
([#3337](#3337))
([06aedcb](06aedcb))
* Noir-compiler breadth-first resolver
([#3307](#3307))
([02348cf](02348cf))
* Update command looks at devDeps
([#3276](#3276))
([54ee38d](54ee38d)),
closes
[#3275](#3275)
* Updating pedersen benchmarks
([#3211](#3211))
([7e89ff3](7e89ff3))
* Warn on circular imports.
([#3350](#3350))
([5bfbddb](5bfbddb))


### Miscellaneous

* All hashes in ts
([#3333](#3333))
([6307e12](6307e12))
* Compute function tree root in ts.
([#3326](#3326))
([48d8c7f](48d8c7f))
* **docs:** Suggest CLI install per project
([#3267](#3267))
([b4c967b](b4c967b))
* Enforce bracing around blocks. Generally considered easier to read and
less error prone.
([#3349](#3349))
([ee11dec](ee11dec))
* Fix circulars in foundation. Also cleanup fields and optimise to be
buffer underlying.
([#3351](#3351))
([c4bf8d3](c4bf8d3))
* Public kernel tests
([#3325](#3325))
([bace972](bace972))


### Documentation

* Fixed errors in Gas and Fees yellow paper
([#3363](#3363))
([d818206](d818206))
* Initial network section of yellow paper
([#3341](#3341))
([5a18615](5a18615))
* Yellow paper section on Gas and Fees
([#3327](#3327))
([caa7e10](caa7e10))
</details>

<details><summary>barretenberg.js: 0.15.1</summary>

##
[0.15.1](barretenberg.js-v0.15.0...barretenberg.js-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](#3335))
([c99862c](c99862c))


### Miscellaneous

* All hashes in ts
([#3333](#3333))
([6307e12](6307e12))
</details>

<details><summary>barretenberg: 0.15.1</summary>

##
[0.15.1](barretenberg-v0.15.0...barretenberg-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](#3335))
([c99862c](c99862c))
* DataBus PoC (UltraHonk as extension of Ultra)
([#3181](#3181))
([dd9dd84](dd9dd84))
* Fold batching challenge (alpha)
([#3291](#3291))
([bc99a4f](bc99a4f))
* Open transcript polys as univariates in ECCVM
([#3331](#3331))
([436b22e](436b22e))
* ZM updates for Translator concatenated polys
([#3343](#3343))
([0e425db](0e425db))


### Bug Fixes

* Bootstrap bbjs.
([#3337](#3337))
([06aedcb](06aedcb))
* Updating pedersen benchmarks
([#3211](#3211))
([7e89ff3](7e89ff3))


### Miscellaneous

* All hashes in ts
([#3333](#3333))
([6307e12](6307e12))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Nov 23, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.15.1</summary>

##
[0.15.1](AztecProtocol/aztec-packages@aztec-packages-v0.15.0...aztec-packages-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](AztecProtocol/aztec-packages#3335))
([c99862c](AztecProtocol/aztec-packages@c99862c))
* DataBus PoC (UltraHonk as extension of Ultra)
([#3181](AztecProtocol/aztec-packages#3181))
([dd9dd84](AztecProtocol/aztec-packages@dd9dd84))
* Deploy docs from CCI w/ netlify-cli
([#3348](AztecProtocol/aztec-packages#3348))
([624d733](AztecProtocol/aztec-packages@624d733))
* Fold batching challenge (alpha)
([#3291](AztecProtocol/aztec-packages#3291))
([bc99a4f](AztecProtocol/aztec-packages@bc99a4f))
* Open transcript polys as univariates in ECCVM
([#3331](AztecProtocol/aztec-packages#3331))
([436b22e](AztecProtocol/aztec-packages@436b22e))
* Sandbox packages
([#3360](AztecProtocol/aztec-packages#3360))
([0dc2d58](AztecProtocol/aztec-packages@0dc2d58))
* Slow updates experimentation
([#2732](AztecProtocol/aztec-packages#2732))
([193e6c8](AztecProtocol/aztec-packages@193e6c8))
* ZM updates for Translator concatenated polys
([#3343](AztecProtocol/aztec-packages#3343))
([0e425db](AztecProtocol/aztec-packages@0e425db))


### Bug Fixes

* Bootstrap bbjs.
([#3337](AztecProtocol/aztec-packages#3337))
([06aedcb](AztecProtocol/aztec-packages@06aedcb))
* Noir-compiler breadth-first resolver
([#3307](AztecProtocol/aztec-packages#3307))
([02348cf](AztecProtocol/aztec-packages@02348cf))
* Update command looks at devDeps
([#3276](AztecProtocol/aztec-packages#3276))
([54ee38d](AztecProtocol/aztec-packages@54ee38d)),
closes
[#3275](AztecProtocol/aztec-packages#3275)
* Updating pedersen benchmarks
([#3211](AztecProtocol/aztec-packages#3211))
([7e89ff3](AztecProtocol/aztec-packages@7e89ff3))
* Warn on circular imports.
([#3350](AztecProtocol/aztec-packages#3350))
([5bfbddb](AztecProtocol/aztec-packages@5bfbddb))


### Miscellaneous

* All hashes in ts
([#3333](AztecProtocol/aztec-packages#3333))
([6307e12](AztecProtocol/aztec-packages@6307e12))
* Compute function tree root in ts.
([#3326](AztecProtocol/aztec-packages#3326))
([48d8c7f](AztecProtocol/aztec-packages@48d8c7f))
* **docs:** Suggest CLI install per project
([#3267](AztecProtocol/aztec-packages#3267))
([b4c967b](AztecProtocol/aztec-packages@b4c967b))
* Enforce bracing around blocks. Generally considered easier to read and
less error prone.
([#3349](AztecProtocol/aztec-packages#3349))
([ee11dec](AztecProtocol/aztec-packages@ee11dec))
* Fix circulars in foundation. Also cleanup fields and optimise to be
buffer underlying.
([#3351](AztecProtocol/aztec-packages#3351))
([c4bf8d3](AztecProtocol/aztec-packages@c4bf8d3))
* Public kernel tests
([#3325](AztecProtocol/aztec-packages#3325))
([bace972](AztecProtocol/aztec-packages@bace972))


### Documentation

* Fixed errors in Gas and Fees yellow paper
([#3363](AztecProtocol/aztec-packages#3363))
([d818206](AztecProtocol/aztec-packages@d818206))
* Initial network section of yellow paper
([#3341](AztecProtocol/aztec-packages#3341))
([5a18615](AztecProtocol/aztec-packages@5a18615))
* Yellow paper section on Gas and Fees
([#3327](AztecProtocol/aztec-packages#3327))
([caa7e10](AztecProtocol/aztec-packages@caa7e10))
</details>

<details><summary>barretenberg.js: 0.15.1</summary>

##
[0.15.1](AztecProtocol/aztec-packages@barretenberg.js-v0.15.0...barretenberg.js-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](AztecProtocol/aztec-packages#3335))
([c99862c](AztecProtocol/aztec-packages@c99862c))


### Miscellaneous

* All hashes in ts
([#3333](AztecProtocol/aztec-packages#3333))
([6307e12](AztecProtocol/aztec-packages@6307e12))
</details>

<details><summary>barretenberg: 0.15.1</summary>

##
[0.15.1](AztecProtocol/aztec-packages@barretenberg-v0.15.0...barretenberg-v0.15.1)
(2023-11-21)


### Features

* **bb:** Add ability to write pk to file or stdout
([#3335](AztecProtocol/aztec-packages#3335))
([c99862c](AztecProtocol/aztec-packages@c99862c))
* DataBus PoC (UltraHonk as extension of Ultra)
([#3181](AztecProtocol/aztec-packages#3181))
([dd9dd84](AztecProtocol/aztec-packages@dd9dd84))
* Fold batching challenge (alpha)
([#3291](AztecProtocol/aztec-packages#3291))
([bc99a4f](AztecProtocol/aztec-packages@bc99a4f))
* Open transcript polys as univariates in ECCVM
([#3331](AztecProtocol/aztec-packages#3331))
([436b22e](AztecProtocol/aztec-packages@436b22e))
* ZM updates for Translator concatenated polys
([#3343](AztecProtocol/aztec-packages#3343))
([0e425db](AztecProtocol/aztec-packages@0e425db))


### Bug Fixes

* Bootstrap bbjs.
([#3337](AztecProtocol/aztec-packages#3337))
([06aedcb](AztecProtocol/aztec-packages@06aedcb))
* Updating pedersen benchmarks
([#3211](AztecProtocol/aztec-packages#3211))
([7e89ff3](AztecProtocol/aztec-packages@7e89ff3))


### Miscellaneous

* All hashes in ts
([#3333](AztecProtocol/aztec-packages#3333))
([6307e12](AztecProtocol/aztec-packages@6307e12))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants