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

feat: stdlib databus #5598

Merged
merged 14 commits into from
Apr 9, 2024
Merged

feat: stdlib databus #5598

merged 14 commits into from
Apr 9, 2024

Conversation

ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented Apr 6, 2024

Introduces a stdlib::DataBus class to facilitate calldata/return_data reads/writes. The work also includes:

  • Circuit checker functionality for checking the validity of databus read gates (simply checks whether the {idx, value} pair in the gate corresponds to data in the corresponding bus vector). Closes Integrate ecc ops and databus into check_circuit barretenberg#842
  • Tests for the stdlib DataBus (including failure tests and demonstration of check circuit)
  • Minor updates to the builder notion of DataBus; now an array of BusVectors to improve interface from stdlib

@AztecBot
Copy link
Collaborator

AztecBot commented Apr 6, 2024

Benchmark results

Metrics with a significant change:

  • tx_sequencer_processing_time_ms (5): 1,752 (-17%)
  • tx_sequencer_processing_time_ms (8): 586 (-19%)
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 f038b704 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 64 txs
l1_rollup_calldata_size_in_bytes 676 676 676
l1_rollup_calldata_gas 6,424 6,412 6,424
l1_rollup_execution_gas 585,757 585,745 585,757
l2_block_processing_time_in_ms 1,284 (-3%) 4,708 8,909 (-4%)
note_successful_decrypting_time_in_ms 226 (-3%) 572 (+2%) 919 (-14%)
note_trial_decrypting_time_in_ms 28.5 (-13%) 80.1 (+10%) 37.2 (-49%)
l2_block_building_time_in_ms 11,544 (-2%) 41,699 (-3%) 81,505 (-3%)
l2_block_rollup_simulation_time_in_ms 11,511 (-2%) 41,588 (-3%) 81,287 (-3%)
l2_block_public_tx_process_time_in_ms 5,933 (-3%) 23,311 (-3%) 46,608 (-3%)

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 14,529 (+2%) 27,878 (+2%)
note_history_successful_decrypting_time_in_ms 1,335 (+3%) 2,346 (-4%)
note_history_trial_decrypting_time_in_ms 63.3 (-8%) 101 (-4%)
node_database_size_in_bytes 18,636,880 35,057,744 (+1%)
pxe_database_size_in_bytes 29,859 59,414

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 178 (-1%) 44,377 26,164
private-kernel-ordering 160 (-1%) 50,830 39,026
base-parity 3,973 128 311
root-parity 1,061 (-2%) 1,244 311
base-rollup 13,944 (-2%) 110,464 861
root-rollup 49.0 (-2%) 4,359 725
private-kernel-inner 216 71,744 26,164
public-kernel-app-logic 119 47,695 40,661
public-kernel-tail 162 (-1%) 53,372 7,125
merge-rollup 9.25 (-16%) 2,568 861
public-kernel-teardown 117 (-18%) 47,695 40,661
public-kernel-setup 116 (-1%) 47,695 40,661

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 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 9.92 (-1%) 16.0 (-2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.6 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.577 (-2%) 0.495 (-2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 45.4 (-3%) 71.0 (-2%) 223 (-4%) 447 844 (-3%) 1,677 (-3%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 96.0 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.466 (-3%) 0.438 (-2%) 0.406 (-4%) 0.417 0.400 (-3%) 0.400 (-3%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 53.7 (-3%) 104 (-3%) 327 (-4%) 664 1,270 (-3%) 2,534 (-3%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.474 (-2%) 0.471 (-3%) 0.442 (-4%) 0.456 0.438 (-3%) 0.438 (-4%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 60.5 (-2%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 109
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.528 (-2%)

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 40,372 496,534

Transaction size based on fee payment method

Metric native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 905 1,161 1,377

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 1,681 (-1%) 1,069 5,418
Metric 1 public data writes 2 public data writes 3 public data writes 4 public data writes 5 public data writes 8 public data writes
tx_sequencer_processing_time_ms 570 (-1%) 402 1,070 527 (+1%) ⚠️ 1,752 (-17%) ⚠️ 586 (-19%)

@ledwards2225 ledwards2225 self-assigned this Apr 8, 2024
@ledwards2225 ledwards2225 marked this pull request as ready for review April 8, 2024 19:52

template <typename Builder> field_t<Builder> databus<Builder>::bus_vector::operator[](const field_pt& index) const
{
auto raw_index = static_cast<size_t>(uint256_t(index.get_value()).data[0]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's discuss this constant code path. I based the design of this class after the ROM table class which is why it's here. Originally thought it made sense but I'm not sure there's a valid reason to be able to extract databus entries without creating a gate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the prover be able to replace the value in the witness, since there is nothing connecting the variable to databus column?

Copy link
Contributor

@Rumata888 Rumata888 left a comment

Choose a reason for hiding this comment

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

Everything looks good apart from the issue you've highlighted. Could you check that it doesn't create a soundness issue?

@ledwards2225 ledwards2225 merged commit 633a711 into master Apr 9, 2024
104 checks passed
@ledwards2225 ledwards2225 deleted the lde/stdlib_databus branch April 9, 2024 18:46
rahul-kothari pushed a commit that referenced this pull request Apr 10, 2024
🤖 I have created a release *beep* *boop*
---


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

##
[0.34.0](aztec-package-v0.33.0...aztec-package-v0.34.0)
(2024-04-10)


### Miscellaneous

* Reduce log verbosity in local e2e tests
([#5622](#5622))
([c496a10](c496a10))
</details>

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

##
[0.34.0](barretenberg.js-v0.33.0...barretenberg.js-v0.34.0)
(2024-04-10)


### Miscellaneous

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

<details><summary>aztec-cli: 0.34.0</summary>

##
[0.34.0](aztec-cli-v0.33.0...aztec-cli-v0.34.0)
(2024-04-10)


### Miscellaneous

* Reduce log verbosity in local e2e tests
([#5622](#5622))
([c496a10](c496a10))
</details>

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

##
[0.34.0](aztec-packages-v0.33.0...aztec-packages-v0.34.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* remove fixed-length keccak256
([#5617](#5617))

### Features

* **acvm_js:** Execute program
(noir-lang/noir#4694)
([ff28080](ff28080))
* Add `remove_enable_side_effects` SSA pass
(noir-lang/noir#4224)
([ff28080](ff28080))
* Allow slices to brillig entry points
(noir-lang/noir#4713)
([ff28080](ff28080))
* **avm:** Basic AVM-ACVM interoperability
([#5595](#5595))
([d872445](d872445))
* **avm:** Make authwit work with avm
([#5594](#5594))
([b02d1e1](b02d1e1))
* **docs:** Documenting noir codegen
(noir-lang/noir#4454)
([ff28080](ff28080))
* Generalize protogalaxy to multiple instances
([#5510](#5510))
([f038b70](f038b70))
* Improve nargo check cli with --override flag and feedback for existing
files (noir-lang/noir#4575)
([ff28080](ff28080))
* Improve optimisations on range constraints
(noir-lang/noir#4690)
([ff28080](ff28080))
* Improve SSA type-awareness in EQ and MUL instructions
(noir-lang/noir#4691)
([ff28080](ff28080))
* **nargo:** Multiple circuits info for binary programs
(noir-lang/noir#4719)
([ff28080](ff28080))
* Stdlib databus
([#5598](#5598))
([633a711](633a711))


### Bug Fixes

* **acvm:** Mark outputs of Opcode::Call solvable
(noir-lang/noir#4708)
([ff28080](ff28080))
* Do not retry RPC requests on 4xx errors
([#5634](#5634))
([5af2b95](5af2b95))
* Field comparisons (noir-lang/noir#4704)
([ff28080](ff28080))
* Last use analysis & make it an SSA pass
(noir-lang/noir#4686)
([ff28080](ff28080))
* **ssa:** Do not use get_value_max_num_bits when we want pure type
information (noir-lang/noir#4700)
([ff28080](ff28080))
* Unknown slice lengths coming from as_slice
(noir-lang/noir#4725)
([ff28080](ff28080))
* Use empty artifact in test
([#5640](#5640))
([1d18a5e](1d18a5e))


### Miscellaneous

* Check for references to private functions during path resolution
(noir-lang/noir#4622)
([ff28080](ff28080))
* **ci:** Fix cutting new versions of the docs
(noir-lang/noir#4737)
([ff28080](ff28080))
* **ci:** Replace `yarn build:js:only` script
(noir-lang/noir#4735)
([ff28080](ff28080))
* **ci:** Stop updating version list before cutting new docs version
(noir-lang/noir#4726)
([ff28080](ff28080))
* Disable earthly cloud
([#5639](#5639))
([47e9c25](47e9c25))
* Fix clippy errors (noir-lang/noir#4684)
([ff28080](ff28080))
* Reduce log verbosity in local e2e tests
([#5622](#5622))
([c496a10](c496a10))
* Remove `FunctionInput::dummy`
(noir-lang/noir#4723)
([ff28080](ff28080))
* Remove conditional compilation around `acvm_js` package
(noir-lang/noir#4702)
([ff28080](ff28080))
* Remove docker CI flow (noir-lang/noir#4724)
([ff28080](ff28080))
* Remove fixed-length keccak256
([#5617](#5617))
([40480b3](40480b3))
* Remove last traces of nix
(noir-lang/noir#4679)
([ff28080](ff28080))
* Remove unused env vars from `Cross.toml`
(noir-lang/noir#4717)
([ff28080](ff28080))
* Replace relative paths to noir-protocol-circuits
([bc214c5](bc214c5))
* Simplify how `acvm_backend.wasm` is embedded
(noir-lang/noir#4703)
([ff28080](ff28080))
* Simplify how blns is loaded into tests
(noir-lang/noir#4705)
([ff28080](ff28080))
* Update condition for clearing warning comment on release PRs
(noir-lang/noir#4739)
([ff28080](ff28080))
* Update from vulnerable version of h2
(noir-lang/noir#4714)
([ff28080](ff28080))
* Update JS publish workflow to upload build artifacts correctly.
(noir-lang/noir#4734)
([ff28080](ff28080))
* Use is_entry_point helper on RuntimeType
(noir-lang/noir#4678)
([ff28080](ff28080))
</details>

<details><summary>barretenberg: 0.34.0</summary>

##
[0.34.0](barretenberg-v0.33.0...barretenberg-v0.34.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* remove fixed-length keccak256
([#5617](#5617))

### Features

* Generalize protogalaxy to multiple instances
([#5510](#5510))
([f038b70](f038b70))
* Stdlib databus
([#5598](#5598))
([633a711](633a711))


### Miscellaneous

* Remove fixed-length keccak256
([#5617](#5617))
([40480b3](40480b3))
</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 Apr 11, 2024
🤖 I have created a release *beep* *boop*
---


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

##
[0.34.0](AztecProtocol/aztec-packages@aztec-package-v0.33.0...aztec-package-v0.34.0)
(2024-04-10)


### Miscellaneous

* Reduce log verbosity in local e2e tests
([#5622](AztecProtocol/aztec-packages#5622))
([c496a10](AztecProtocol/aztec-packages@c496a10))
</details>

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

##
[0.34.0](AztecProtocol/aztec-packages@barretenberg.js-v0.33.0...barretenberg.js-v0.34.0)
(2024-04-10)


### Miscellaneous

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

<details><summary>aztec-cli: 0.34.0</summary>

##
[0.34.0](AztecProtocol/aztec-packages@aztec-cli-v0.33.0...aztec-cli-v0.34.0)
(2024-04-10)


### Miscellaneous

* Reduce log verbosity in local e2e tests
([#5622](AztecProtocol/aztec-packages#5622))
([c496a10](AztecProtocol/aztec-packages@c496a10))
</details>

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

##
[0.34.0](AztecProtocol/aztec-packages@aztec-packages-v0.33.0...aztec-packages-v0.34.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* remove fixed-length keccak256
([#5617](AztecProtocol/aztec-packages#5617))

### Features

* **acvm_js:** Execute program
(noir-lang/noir#4694)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Add `remove_enable_side_effects` SSA pass
(noir-lang/noir#4224)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Allow slices to brillig entry points
(noir-lang/noir#4713)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **avm:** Basic AVM-ACVM interoperability
([#5595](AztecProtocol/aztec-packages#5595))
([d872445](AztecProtocol/aztec-packages@d872445))
* **avm:** Make authwit work with avm
([#5594](AztecProtocol/aztec-packages#5594))
([b02d1e1](AztecProtocol/aztec-packages@b02d1e1))
* **docs:** Documenting noir codegen
(noir-lang/noir#4454)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Generalize protogalaxy to multiple instances
([#5510](AztecProtocol/aztec-packages#5510))
([f038b70](AztecProtocol/aztec-packages@f038b70))
* Improve nargo check cli with --override flag and feedback for existing
files (noir-lang/noir#4575)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Improve optimisations on range constraints
(noir-lang/noir#4690)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Improve SSA type-awareness in EQ and MUL instructions
(noir-lang/noir#4691)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **nargo:** Multiple circuits info for binary programs
(noir-lang/noir#4719)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Stdlib databus
([#5598](AztecProtocol/aztec-packages#5598))
([633a711](AztecProtocol/aztec-packages@633a711))


### Bug Fixes

* **acvm:** Mark outputs of Opcode::Call solvable
(noir-lang/noir#4708)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Do not retry RPC requests on 4xx errors
([#5634](AztecProtocol/aztec-packages#5634))
([5af2b95](AztecProtocol/aztec-packages@5af2b95))
* Field comparisons (noir-lang/noir#4704)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Last use analysis & make it an SSA pass
(noir-lang/noir#4686)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **ssa:** Do not use get_value_max_num_bits when we want pure type
information (noir-lang/noir#4700)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Unknown slice lengths coming from as_slice
(noir-lang/noir#4725)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Use empty artifact in test
([#5640](AztecProtocol/aztec-packages#5640))
([1d18a5e](AztecProtocol/aztec-packages@1d18a5e))


### Miscellaneous

* Check for references to private functions during path resolution
(noir-lang/noir#4622)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **ci:** Fix cutting new versions of the docs
(noir-lang/noir#4737)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **ci:** Replace `yarn build:js:only` script
(noir-lang/noir#4735)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* **ci:** Stop updating version list before cutting new docs version
(noir-lang/noir#4726)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Disable earthly cloud
([#5639](AztecProtocol/aztec-packages#5639))
([47e9c25](AztecProtocol/aztec-packages@47e9c25))
* Fix clippy errors (noir-lang/noir#4684)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Reduce log verbosity in local e2e tests
([#5622](AztecProtocol/aztec-packages#5622))
([c496a10](AztecProtocol/aztec-packages@c496a10))
* Remove `FunctionInput::dummy`
(noir-lang/noir#4723)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Remove conditional compilation around `acvm_js` package
(noir-lang/noir#4702)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Remove docker CI flow (noir-lang/noir#4724)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Remove fixed-length keccak256
([#5617](AztecProtocol/aztec-packages#5617))
([40480b3](AztecProtocol/aztec-packages@40480b3))
* Remove last traces of nix
(noir-lang/noir#4679)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Remove unused env vars from `Cross.toml`
(noir-lang/noir#4717)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Replace relative paths to noir-protocol-circuits
([bc214c5](AztecProtocol/aztec-packages@bc214c5))
* Simplify how `acvm_backend.wasm` is embedded
(noir-lang/noir#4703)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Simplify how blns is loaded into tests
(noir-lang/noir#4705)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Update condition for clearing warning comment on release PRs
(noir-lang/noir#4739)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Update from vulnerable version of h2
(noir-lang/noir#4714)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Update JS publish workflow to upload build artifacts correctly.
(noir-lang/noir#4734)
([ff28080](AztecProtocol/aztec-packages@ff28080))
* Use is_entry_point helper on RuntimeType
(noir-lang/noir#4678)
([ff28080](AztecProtocol/aztec-packages@ff28080))
</details>

<details><summary>barretenberg: 0.34.0</summary>

##
[0.34.0](AztecProtocol/aztec-packages@barretenberg-v0.33.0...barretenberg-v0.34.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* remove fixed-length keccak256
([#5617](AztecProtocol/aztec-packages#5617))

### Features

* Generalize protogalaxy to multiple instances
([#5510](AztecProtocol/aztec-packages#5510))
([f038b70](AztecProtocol/aztec-packages@f038b70))
* Stdlib databus
([#5598](AztecProtocol/aztec-packages#5598))
([633a711](AztecProtocol/aztec-packages@633a711))


### Miscellaneous

* Remove fixed-length keccak256
([#5617](AztecProtocol/aztec-packages#5617))
([40480b3](AztecProtocol/aztec-packages@40480b3))
</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.

Integrate ecc ops and databus into check_circuit
3 participants