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

fix: validate gas used #7459

Merged
merged 3 commits into from
Jul 15, 2024
Merged

fix: validate gas used #7459

merged 3 commits into from
Jul 15, 2024

Conversation

LeilaWang
Copy link
Collaborator

Please read contributing guidelines and remove this line.

Copy link
Contributor

github-actions bot commented Jul 12, 2024

Changes to circuit sizes

Generated at commit: be92666659623e09bb704eec284bfb507068de0c, compared to commit: 66d257bdb9121a5663759da5a6363ab1e7cfce07

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_empty_simulated 0 ➖ 0.00% +31 ❌ +7.97%
private_kernel_tail_simulated 0 ➖ 0.00% +31 ❌ +7.97%
public_kernel_tail_simulated 0 ➖ 0.00% +31 ❌ +7.97%
rollup_base +1,769 ❌ +0.52% +75,084 ❌ +2.00%
private_kernel_tail_to_public_simulated 0 ➖ 0.00% +16 ❌ +0.48%
public_kernel_app_logic_simulated 0 ➖ 0.00% +16 ❌ +0.48%
public_kernel_setup_simulated 0 ➖ 0.00% +16 ❌ +0.48%
public_kernel_teardown_simulated 0 ➖ 0.00% +16 ❌ +0.48%
private_kernel_empty +31 ❌ +1.74% +62 ❌ +0.01%
public_kernel_tail +367 ❌ +0.04% -17,564 ✅ -0.38%
public_kernel_teardown -226 ✅ -0.09% -26,997 ✅ -1.64%
public_kernel_setup -342 ✅ -0.19% -27,113 ✅ -1.71%
public_kernel_app_logic -226 ✅ -0.09% -27,093 ✅ -4.61%
private_kernel_tail_to_public -486 ✅ -0.78% -53,930 ✅ -10.86%
private_kernel_tail -1,560 ✅ -7.45% -73,962 ✅ -12.11%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_empty_simulated 1 (0) 0.00% 420 (+31) +7.97%
private_kernel_tail_simulated 1 (0) 0.00% 420 (+31) +7.97%
public_kernel_tail_simulated 1 (0) 0.00% 420 (+31) +7.97%
rollup_base 341,542 (+1,769) +0.52% 3,836,142 (+75,084) +2.00%
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,344 (+16) +0.48%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,344 (+16) +0.48%
public_kernel_setup_simulated 1 (0) 0.00% 3,344 (+16) +0.48%
public_kernel_teardown_simulated 1 (0) 0.00% 3,344 (+16) +0.48%
private_kernel_empty 1,811 (+31) +1.74% 1,041,821 (+62) +0.01%
public_kernel_tail 965,693 (+367) +0.04% 4,645,487 (-17,564) -0.38%
public_kernel_teardown 241,730 (-226) -0.09% 1,618,002 (-26,997) -1.64%
public_kernel_setup 183,195 (-342) -0.19% 1,554,056 (-27,113) -1.71%
public_kernel_app_logic 240,368 (-226) -0.09% 560,162 (-27,093) -4.61%
private_kernel_tail_to_public 61,801 (-486) -0.78% 442,572 (-53,930) -10.86%
private_kernel_tail 19,368 (-1,560) -7.45% 536,962 (-73,962) -12.11%

@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:transfer_public): 62.8 (+45%)
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.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256_ms 5,511 (+2%) 1,499 (+2%) 669 (+1%) 703 (-3%) 741 (+2%)
proof_construction_time_sha256_30_ms 11,024 (+1%) 2,969 1,304 1,348 (-2%) 1,385 (-1%)
proof_construction_time_sha256_100_ms 42,035 (+1%) 11,559 (+2%) 5,564 (+10%) 5,431 (-4%) 5,116 (+1%)
proof_construction_time_poseidon_hash_ms 75.0 34.0 34.0 59.0 (+4%) 91.0 (+2%)
proof_construction_time_poseidon_hash_30_ms 1,456 (+1%) 405 (+1%) 196 (+1%) 221 (+3%) 256 (-2%)
proof_construction_time_poseidon_hash_100_ms 5,433 (+2%) 1,468 (+1%) 650 (+1%) 700 (+2%) 717 (+1%)

L2 block published to L1

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

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 708 708 708
l1_rollup_calldata_gas 6,576 6,582 6,588
l1_rollup_execution_gas 583,038 583,195 583,352
l2_block_processing_time_in_ms 800 (-1%) 1,508 2,860 (-2%)
l2_block_building_time_in_ms 13,489 (-2%) 26,930 52,203 (-2%)
l2_block_rollup_simulation_time_in_ms 13,489 (-2%) 26,930 52,202 (-2%)
l2_block_public_tx_process_time_in_ms 11,344 (-2%) 24,510 49,755 (-2%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 7,482 10,533 (+1%)
node_database_size_in_bytes 12,501,072 16,441,424
pxe_database_size_in_bytes 16,254 26,813

Circuits stats

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

Circuit simulation_time_in_ms witness_generation_time_in_ms input_size_in_bytes output_size_in_bytes proving_time_in_ms proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 119 (-2%) 408 (+3%) 21,732 54,085 N/A N/A N/A N/A
private-kernel-inner 234 (-1%) 723 (+2%) 81,199 54,264 N/A N/A N/A N/A
private-kernel-tail 1,129 (-1%) 2,549 (+2%) 61,827 61,554 N/A N/A N/A N/A
base-parity 6.91 (+2%) 842 (-2%) 160 96.0 2,082 (+4%) 12,676 3.00 131,072
root-parity 111 126 (+8%) 64,860 96.0 48,484 (-4%) 12,676 3.00 4,194,304
base-rollup 4,324 (-1%) 4,987 (+1%) 180,315 632 48,375 13,476 28.0 4,194,304
root-rollup 161 126 (+4%) 51,261 652 42,139 (+4%) 13,412 26.0 4,194,304
public-kernel-setup 198 (-3%) 2,467 (+1%) 112,536 80,310 22,341 (+1%) 118,916 3,323 2,097,152
public-kernel-app-logic 153 (-1%) 3,447 (+6%) 112,536 80,310 10,333 (+3%) 118,916 3,323 1,048,576
public-kernel-tail 919 27,467 (+1%) 409,413 10,046 71,942 (-1%) 24,868 384 8,388,608
private-kernel-reset-tiny 309 1,011 (+1%) 77,007 53,954 N/A N/A N/A N/A
private-kernel-tail-to-public 6,937 (+2%) 2,925 (+3%) 796,650 (+2%) 1,632 N/A N/A N/A N/A
public-kernel-teardown 144 (-1%) 3,357 (+3%) 112,536 80,310 22,864 (+1%) 118,916 3,323 2,097,152
merge-rollup 59.2 (-3%) N/A 33,566 632 N/A N/A N/A N/A
undefined N/A N/A N/A N/A 162,971 (+1%) N/A N/A N/A

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms
ContractClassRegisterer:register 1,312 9,344 408 N/A N/A
ContractInstanceDeployer:deploy 1,376 9,344 26.4 (+1%) N/A N/A
MultiCallEntrypoint:entrypoint 1,888 9,344 651 (-1%) N/A N/A
GasToken:deploy 1,344 9,344 595 (+1%) N/A N/A
SchnorrAccount:constructor 1,280 9,344 458 N/A N/A
SchnorrAccount:entrypoint 2,272 9,344 816 N/A N/A
Token:privately_mint_private_note 1,248 9,344 575 (+9%) N/A N/A
FPC:fee_entrypoint_public 1,312 9,344 105 (+2%) N/A N/A
Token:transfer 1,280 9,344 1,558 (+1%) N/A N/A
AuthRegistry:set_authorized (avm) 19,222 N/A N/A 95,392 2,181 (+3%)
FPC:prepare_fee (avm) 26,664 N/A N/A 95,456 2,951 (+5%)
Token:transfer_public (avm) 42,914 N/A N/A 95,456 3,334 (+4%)
AuthRegistry:consume (avm) 33,100 N/A N/A 95,424 2,821
FPC:pay_refund (avm) 36,829 N/A N/A 95,424 11,257 (+2%)
Benchmarking:create_note 1,312 9,344 464 (-1%) N/A N/A
SchnorrAccount:verify_private_authwit 1,248 9,344 44.9 (-2%) N/A N/A
Token:unshield 1,344 9,344 1,263 (-2%) N/A N/A
FPC:fee_entrypoint_private 1,344 9,344 1,656 (-1%) N/A N/A

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
GasToken:_increase_public_balance 102 (+3%) 13,790
GasToken:set_portal 11.8 (-9%) 3,339
Token:constructor 126 (-2%) 23,692
FPC:constructor 95.8 (+5%) 13,592
GasToken:mint_public 84.4 (+3%) 10,158
Token:mint_public 342 (-2%) 19,034
Token:assert_minter_and_mint 51.1 (+4%) 12,925
AuthRegistry:set_authorized 52.9 (+10%) 7,812
FPC:prepare_fee 121 15,062
Token:transfer_public ⚠️ 62.8 (+45%) 31,218
FPC:pay_refund 145 (+13%) 25,260
Benchmarking:increment_balance 1,380 (-1%) 15,267
Token:_increase_public_balance 20.6 (+12%) 15,006
FPC:pay_refund_with_shielded_rebate 195 (-3%) 26,347

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.154 (+1%)

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 256 leaves 512 leaves 1024 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.8 17.5 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.626 0.539 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 50.3 80.0 (-1%) 139 (-1%) 261 501 (-1%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.515 0.493 (-1%) 0.477 (-1%) 0.473 0.468 (-1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 62.5 118 (-1%) 193 (-2%) 375 735 (-1%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.528 0.530 0.507 (-1%) 0.507 0.505 (-1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 76.7 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 133 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.546 N/A N/A N/A N/A

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 76,837 667,838

Transaction size based on fee payment method

| Metric | |
| - | |

@LeilaWang LeilaWang marked this pull request as ready for review July 15, 2024 14:37
Copy link
Collaborator

@sirasistant sirasistant left a comment

Choose a reason for hiding this comment

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

Yay!

@LeilaWang LeilaWang merged commit 6dc7598 into master Jul 15, 2024
92 checks passed
@LeilaWang LeilaWang deleted the lw/tail_output_validator branch July 15, 2024 17:21
rahul-kothari pushed a commit that referenced this pull request Jul 16, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](#7421))
([103f099](103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

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

##
[0.46.7](barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

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

##
[0.46.7](aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](#7448))
([699fb79](699fb79))
* Add unconstrained getters to sharedmutable
([#7429](#7429))
([c0ff566](c0ff566))
* Devnet updates
([#7421](#7421))
([103f099](103f099))
* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))
* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](#7481))
([a3f6feb](a3f6feb))
* Fix msg_sender direct call exploit
([#7404](#7404))
([1dcae45](1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](#7493))
([b209fad](b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](#7336))
([0c7459b](0c7459b))
* Validate gas used
([#7459](#7459))
([6dc7598](6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](#7491))
([1e8a597](1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](71960d4))
* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
</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 Jul 17, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

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

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

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

##
[0.46.7](AztecProtocol/aztec-packages@aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](AztecProtocol/aztec-packages#7448))
([699fb79](AztecProtocol/aztec-packages@699fb79))
* Add unconstrained getters to sharedmutable
([#7429](AztecProtocol/aztec-packages#7429))
([c0ff566](AztecProtocol/aztec-packages@c0ff566))
* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))
* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))
* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](AztecProtocol/aztec-packages#7481))
([a3f6feb](AztecProtocol/aztec-packages@a3f6feb))
* Fix msg_sender direct call exploit
([#7404](AztecProtocol/aztec-packages#7404))
([1dcae45](AztecProtocol/aztec-packages@1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](AztecProtocol/aztec-packages#7493))
([b209fad](AztecProtocol/aztec-packages@b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](AztecProtocol/aztec-packages#7336))
([0c7459b](AztecProtocol/aztec-packages@0c7459b))
* Validate gas used
([#7459](AztecProtocol/aztec-packages#7459))
([6dc7598](AztecProtocol/aztec-packages@6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](AztecProtocol/aztec-packages#7491))
([1e8a597](AztecProtocol/aztec-packages@1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](AztecProtocol/aztec-packages@71960d4))
* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
</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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants