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

refactor: towards plain struct flavor entities #3216

Merged
merged 54 commits into from
Nov 10, 2023
Merged

Conversation

ludamad
Copy link
Collaborator

@ludamad ludamad commented Nov 3, 2023

Step towards removing the array backing in the flavor entity classes. This systematically removes all usage of operator[] so that the array backing can be deleted in a followup. This is achieved by having a pointer_view method that is defined in const and non-const forms (cleanest way I could find was through a simple macro) and returns an array of each pointer. Pointers were used over references to not have to deal with references decaying into values.

Happy to take feedback on the approach, it isn't cleaning up much just yet, but will make way for a followup PR that removes the backing arrays.

Also:

  • Adds a zip_view class that aims to get us using zip_view before C++2023 fully lands. I yoinked some open source and slimmed it down a bit for what we're likely to use.

@ludamad ludamad changed the title refactor: towards flavor entity classes not needing array backing refactor: towards plain struct flavor entities Nov 3, 2023
Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

Everything here seems fine to me but it's a bit hard for me to evaluate without having a full picture of how the final structure will look. Normally I'm all for the incremental approach but do you feel confident that you've thought through the simplifications that this will allow in the flavor classes? I'm a bit worried that if this ultimately relies on different collections of polys being adjacent in the struct (e.g. all "precomputed" or "to-be-shifted" are grouped together and accessible via a contiguous range) then this will lead to difficulties and possibly be too restrictive. Of course maybe we could explicitly specify subsets but then I'm not sure how much we've gained. Perhaps I just don't have enough insight into the plan - just want to make sure the path forward is clear enough to get in this intermediate work. Happy that you're on the case!

@ludamad
Copy link
Collaborator Author

ludamad commented Nov 3, 2023

Summarizing slack discussion: Luke and I got to the understanding that this won't be that much of an overhaul, it will largely keep stuff as-is, this is the most dramatic of the rewriting right here, the followup would just be using this to remove the array backing so these structs don't have self-references to their own data (and thus won't be footguns that can't be copy-constructed)

@AztecProtocol AztecProtocol deleted a comment from AztecBot Nov 3, 2023
@AztecBot
Copy link
Collaborator

AztecBot commented Nov 3, 2023

Benchmark results

No metrics with a significant change found.

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 ec2b805e 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,912 868,268 3,449,648
l1_rollup_execution_gas 841,999 3,595,376 22,205,017
l2_block_processing_time_in_ms 2,023 (+1%) 7,576 (-1%) 29,890 (-1%)
note_successful_decrypting_time_in_ms 292 (-1%) 870 (-1%) 3,181 (-2%)
note_trial_decrypting_time_in_ms 93.7 (-4%) 78.2 (-11%) 134
l2_block_building_time_in_ms 13,374 (+1%) 52,695 210,635
l2_block_rollup_simulation_time_in_ms 12,021 (+1%) 47,399 189,520
l2_block_public_tx_process_time_in_ms 1,312 (-1%) 5,166 (-1%) 20,605

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 21,802 42,320
note_history_successful_decrypting_time_in_ms 2,021 3,948 (+1%)
note_history_trial_decrypting_time_in_ms 121 143 (+1%)
node_database_size_in_bytes 1,628,701 1,096,881
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 762 61,697 18,905
private-kernel-ordering 125 24,297 8,153
base-rollup 1,766 656,311 814
root-rollup 169 4,072 1,097
private-kernel-inner 786 81,568 18,905
public-kernel-private-input 41.1 41,519 18,841
public-kernel-non-first-iteration 25.8 41,497 18,841
merge-rollup 15.1 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

@ludamad ludamad marked this pull request as ready for review November 4, 2023 01:57
"environment": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Debug",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was not building in its own folder, nor was it compatible with the gdb on mainframe

Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

All LGTM

for (size_t i = 0; i < NUM_POLYNOMIALS; i++) {
auto partially_evaluated_polynomials_array = sumcheck.partially_evaluated_polynomials.pointer_view();
size_t i = 0;
for (auto* full_polynomial_pointer : full_polynomials.pointer_view()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this not be zipped?

@ludamad ludamad merged commit 3ba89cf into master Nov 10, 2023
79 checks passed
@ludamad ludamad deleted the ad/chore/flavor-refactor branch November 10, 2023 16:31
ludamad pushed a commit that referenced this pull request Nov 17, 2023
🤖 I have created a release *beep* *boop*
---


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

##
[0.15.0](aztec-packages-v0.14.2...aztec-packages-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))

### Features

* **bb:** Add msan preset
([#3284](#3284))
([bcf025c](bcf025c))
* Enable merge and root rollup circuits in noir
([#3248](#3248))
([68555fc](68555fc))
* Protogalaxy combiner quotient
([#3245](#3245))
([db0f3ab](db0f3ab))
* Public kernel in noir
([#3186](#3186))
([15a522b](15a522b))
* Ultra honk arith from ultra
([#3274](#3274))
([ec2b805](ec2b805))


### Bug Fixes

* Debug build
([#3283](#3283))
([aca2624](aca2624))
* Fix block constraint key divergence bug.
([#3256](#3256))
([1c71a0c](1c71a0c))
* Main.md typo
([#3278](#3278))
([cb87c4d](cb87c4d))
* Typo fix roundup
([#3302](#3302))
([9dd778d](9dd778d))


### Miscellaneous

* **bb:** Remove -Wfatal-errors
([#3318](#3318))
([4229173](4229173))
* Clarify that barretenberg mirror should not take PRs
([#3303](#3303))
([13f1a1d](13f1a1d))
* Clean up Plonk widgets
([#3305](#3305))
([4623d91](4623d91))
* **docs:** Aztec.nr logging page
([#3281](#3281))
([11e6ca7](11e6ca7))
* **docs:** Update netlify.toml and fix build
([#3304](#3304))
([df76636](df76636))
* Explicitly instantiate Goblin translator relations
([#3239](#3239))
([e3b5fb0](e3b5fb0))
* Plain struct flavor entities
([#3277](#3277))
([f109512](f109512))
* Remove bn254 instantiation of eccvm plus naming changes
([#3330](#3330))
([23d1e2d](23d1e2d))
* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))
([87eeb71](87eeb71))
* Revert build-debug folder for debug preset
([#3324](#3324))
([43a2e6b](43a2e6b))
* Towards plain struct flavor entities
([#3216](#3216))
([3ba89cf](3ba89cf))
* Typo fixes based on cspell
([#3319](#3319))
([8ae44dd](8ae44dd))
</details>

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

##
[0.15.0](barretenberg.js-v0.14.2...barretenberg.js-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))

### Bug Fixes

* Fix block constraint key divergence bug.
([#3256](#3256))
([1c71a0c](1c71a0c))


### Miscellaneous

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))
([87eeb71](87eeb71))
* Typo fixes based on cspell
([#3319](#3319))
([8ae44dd](8ae44dd))
</details>

<details><summary>barretenberg: 0.15.0</summary>

##
[0.15.0](barretenberg-v0.14.2...barretenberg-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))

### Features

* **bb:** Add msan preset
([#3284](#3284))
([bcf025c](bcf025c))
* Protogalaxy combiner quotient
([#3245](#3245))
([db0f3ab](db0f3ab))
* Ultra honk arith from ultra
([#3274](#3274))
([ec2b805](ec2b805))


### Bug Fixes

* Debug build
([#3283](#3283))
([aca2624](aca2624))
* Fix block constraint key divergence bug.
([#3256](#3256))
([1c71a0c](1c71a0c))


### Miscellaneous

* **bb:** Remove -Wfatal-errors
([#3318](#3318))
([4229173](4229173))
* Clarify that barretenberg mirror should not take PRs
([#3303](#3303))
([13f1a1d](13f1a1d))
* Clean up Plonk widgets
([#3305](#3305))
([4623d91](4623d91))
* Explicitly instantiate Goblin translator relations
([#3239](#3239))
([e3b5fb0](e3b5fb0))
* Plain struct flavor entities
([#3277](#3277))
([f109512](f109512))
* Remove bn254 instantiation of eccvm plus naming changes
([#3330](#3330))
([23d1e2d](23d1e2d))
* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](#3114))
([87eeb71](87eeb71))
* Revert build-debug folder for debug preset
([#3324](#3324))
([43a2e6b](43a2e6b))
* Towards plain struct flavor entities
([#3216](#3216))
([3ba89cf](3ba89cf))
* Typo fixes based on cspell
([#3319](#3319))
([8ae44dd](8ae44dd))
</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 19, 2023
🤖 I have created a release *beep* *boop*
---


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

##
[0.15.0](AztecProtocol/aztec-packages@aztec-packages-v0.14.2...aztec-packages-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))

### Features

* **bb:** Add msan preset
([#3284](AztecProtocol/aztec-packages#3284))
([bcf025c](AztecProtocol/aztec-packages@bcf025c))
* Enable merge and root rollup circuits in noir
([#3248](AztecProtocol/aztec-packages#3248))
([68555fc](AztecProtocol/aztec-packages@68555fc))
* Protogalaxy combiner quotient
([#3245](AztecProtocol/aztec-packages#3245))
([db0f3ab](AztecProtocol/aztec-packages@db0f3ab))
* Public kernel in noir
([#3186](AztecProtocol/aztec-packages#3186))
([15a522b](AztecProtocol/aztec-packages@15a522b))
* Ultra honk arith from ultra
([#3274](AztecProtocol/aztec-packages#3274))
([ec2b805](AztecProtocol/aztec-packages@ec2b805))


### Bug Fixes

* Debug build
([#3283](AztecProtocol/aztec-packages#3283))
([aca2624](AztecProtocol/aztec-packages@aca2624))
* Fix block constraint key divergence bug.
([#3256](AztecProtocol/aztec-packages#3256))
([1c71a0c](AztecProtocol/aztec-packages@1c71a0c))
* Main.md typo
([#3278](AztecProtocol/aztec-packages#3278))
([cb87c4d](AztecProtocol/aztec-packages@cb87c4d))
* Typo fix roundup
([#3302](AztecProtocol/aztec-packages#3302))
([9dd778d](AztecProtocol/aztec-packages@9dd778d))


### Miscellaneous

* **bb:** Remove -Wfatal-errors
([#3318](AztecProtocol/aztec-packages#3318))
([4229173](AztecProtocol/aztec-packages@4229173))
* Clarify that barretenberg mirror should not take PRs
([#3303](AztecProtocol/aztec-packages#3303))
([13f1a1d](AztecProtocol/aztec-packages@13f1a1d))
* Clean up Plonk widgets
([#3305](AztecProtocol/aztec-packages#3305))
([4623d91](AztecProtocol/aztec-packages@4623d91))
* **docs:** Aztec.nr logging page
([#3281](AztecProtocol/aztec-packages#3281))
([11e6ca7](AztecProtocol/aztec-packages@11e6ca7))
* **docs:** Update netlify.toml and fix build
([#3304](AztecProtocol/aztec-packages#3304))
([df76636](AztecProtocol/aztec-packages@df76636))
* Explicitly instantiate Goblin translator relations
([#3239](AztecProtocol/aztec-packages#3239))
([e3b5fb0](AztecProtocol/aztec-packages@e3b5fb0))
* Plain struct flavor entities
([#3277](AztecProtocol/aztec-packages#3277))
([f109512](AztecProtocol/aztec-packages@f109512))
* Remove bn254 instantiation of eccvm plus naming changes
([#3330](AztecProtocol/aztec-packages#3330))
([23d1e2d](AztecProtocol/aztec-packages@23d1e2d))
* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))
([87eeb71](AztecProtocol/aztec-packages@87eeb71))
* Revert build-debug folder for debug preset
([#3324](AztecProtocol/aztec-packages#3324))
([43a2e6b](AztecProtocol/aztec-packages@43a2e6b))
* Towards plain struct flavor entities
([#3216](AztecProtocol/aztec-packages#3216))
([3ba89cf](AztecProtocol/aztec-packages@3ba89cf))
* Typo fixes based on cspell
([#3319](AztecProtocol/aztec-packages#3319))
([8ae44dd](AztecProtocol/aztec-packages@8ae44dd))
</details>

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

##
[0.15.0](AztecProtocol/aztec-packages@barretenberg.js-v0.14.2...barretenberg.js-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))

### Bug Fixes

* Fix block constraint key divergence bug.
([#3256](AztecProtocol/aztec-packages#3256))
([1c71a0c](AztecProtocol/aztec-packages@1c71a0c))


### Miscellaneous

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))
([87eeb71](AztecProtocol/aztec-packages@87eeb71))
* Typo fixes based on cspell
([#3319](AztecProtocol/aztec-packages#3319))
([8ae44dd](AztecProtocol/aztec-packages@8ae44dd))
</details>

<details><summary>barretenberg: 0.15.0</summary>

##
[0.15.0](AztecProtocol/aztec-packages@barretenberg-v0.14.2...barretenberg-v0.15.0)
(2023-11-16)


### ⚠ BREAKING CHANGES

* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))

### Features

* **bb:** Add msan preset
([#3284](AztecProtocol/aztec-packages#3284))
([bcf025c](AztecProtocol/aztec-packages@bcf025c))
* Protogalaxy combiner quotient
([#3245](AztecProtocol/aztec-packages#3245))
([db0f3ab](AztecProtocol/aztec-packages@db0f3ab))
* Ultra honk arith from ultra
([#3274](AztecProtocol/aztec-packages#3274))
([ec2b805](AztecProtocol/aztec-packages@ec2b805))


### Bug Fixes

* Debug build
([#3283](AztecProtocol/aztec-packages#3283))
([aca2624](AztecProtocol/aztec-packages@aca2624))
* Fix block constraint key divergence bug.
([#3256](AztecProtocol/aztec-packages#3256))
([1c71a0c](AztecProtocol/aztec-packages@1c71a0c))


### Miscellaneous

* **bb:** Remove -Wfatal-errors
([#3318](AztecProtocol/aztec-packages#3318))
([4229173](AztecProtocol/aztec-packages@4229173))
* Clarify that barretenberg mirror should not take PRs
([#3303](AztecProtocol/aztec-packages#3303))
([13f1a1d](AztecProtocol/aztec-packages@13f1a1d))
* Clean up Plonk widgets
([#3305](AztecProtocol/aztec-packages#3305))
([4623d91](AztecProtocol/aztec-packages@4623d91))
* Explicitly instantiate Goblin translator relations
([#3239](AztecProtocol/aztec-packages#3239))
([e3b5fb0](AztecProtocol/aztec-packages@e3b5fb0))
* Plain struct flavor entities
([#3277](AztecProtocol/aztec-packages#3277))
([f109512](AztecProtocol/aztec-packages@f109512))
* Remove bn254 instantiation of eccvm plus naming changes
([#3330](AztecProtocol/aztec-packages#3330))
([23d1e2d](AztecProtocol/aztec-packages@23d1e2d))
* Replace computing hashes in circuits wasm, with computing them in ts
via bb.js pedersen call.
([#3114](AztecProtocol/aztec-packages#3114))
([87eeb71](AztecProtocol/aztec-packages@87eeb71))
* Revert build-debug folder for debug preset
([#3324](AztecProtocol/aztec-packages#3324))
([43a2e6b](AztecProtocol/aztec-packages@43a2e6b))
* Towards plain struct flavor entities
([#3216](AztecProtocol/aztec-packages#3216))
([3ba89cf](AztecProtocol/aztec-packages@3ba89cf))
* Typo fixes based on cspell
([#3319](AztecProtocol/aztec-packages#3319))
([8ae44dd](AztecProtocol/aztec-packages@8ae44dd))
</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.

4 participants