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: use brillig optimized sha256 #11696

Merged
merged 16 commits into from
Feb 13, 2025
Merged

Conversation

TomAFrench
Copy link
Member

Please read contributing guidelines and remove this line.

@TomAFrench TomAFrench marked this pull request as ready for review February 3, 2025 17:18
Copy link
Contributor

github-actions bot commented Feb 3, 2025

Changes to public function bytecode sizes

Generated at commit: f35e4d0e6bc00a06958eb93f25baa9f4edec8898, compared to commit: 5efdd57c2c19daed3bb5d60fff915e9618b4a146

🧾 Summary (100% most significant diffs)

Program Bytecode size in bytes (+/-) %
AvmGadgetsTest::sha256_hash_20 +369 ❌ +10.95%
AvmGadgetsTest::sha256_hash_40 +374 ❌ +10.66%
AvmGadgetsTest::sha256_hash_10 +352 ❌ +10.61%
AvmGadgetsTest::sha256_hash_30 +350 ❌ +10.12%
AvmGadgetsTest::sha256_hash_50 +350 ❌ +9.71%
AvmGadgetsTest::sha256_hash_60 +307 ❌ +8.26%
AvmGadgetsTest::keccak_hash +106 ❌ +4.89%
AvmTest::u128_addition_overflow +36 ❌ +2.84%
AvmTest::bulk_testing +458 ❌ +2.09%
DocsExample::public_dispatch +64 ❌ +1.32%
NFT::constructor +41 ❌ +0.91%
Token::constructor +41 ❌ +0.85%
AvmTest::public_dispatch +489 ❌ +0.84%
AvmTest::emit_public_log +18 ❌ +0.76%
AppSubscription::constructor +23 ❌ +0.65%
AvmTest::external_call_to_divide_by_zero_recovers +18 ❌ +0.64%
Token::transfer_in_public +23 ❌ +0.53%
Parent::public_nested_static_call +18 ❌ +0.51%
AppSubscription::public_dispatch +23 ❌ +0.49%
NFT::finalize_transfer_to_private +18 ❌ +0.39%
NFT::_finalize_transfer_to_private_unsafe +18 ❌ +0.39%
Token::finalize_mint_to_private +18 ❌ +0.38%
Token::_finalize_mint_to_private_unsafe +18 ❌ +0.37%
Token::finalize_transfer_to_private +18 ❌ +0.35%
Token::_finalize_transfer_to_private_unsafe +18 ❌ +0.35%
Token::public_dispatch +105 ❌ +0.33%
NFT::public_dispatch +82 ❌ +0.32%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 +18 ❌ +0.27%
Parent::public_dispatch +18 ❌ +0.24%
Uniswap::public_dispatch +12 ❌ +0.05%
Uniswap::swap_public -6 ✅ -0.04%
TokenBridge::exit_to_l1_public -18 ✅ -0.23%
Test::consume_message_from_arbitrary_sender_public -60 ✅ -0.80%
AvmGadgetsTest::sha256_hash_90 -80 ✅ -1.70%
AvmGadgetsTest::sha256_hash_80 -80 ✅ -1.73%
AvmGadgetsTest::sha256_hash_70 -80 ✅ -1.76%
AvmGadgetsTest::sha256_hash_100 -85 ✅ -1.78%
Test::public_dispatch -366 ✅ -2.02%
AvmGadgetsTest::sha256_hash_511 -181 ✅ -2.30%
TokenBridge::public_dispatch -473 ✅ -2.30%
TokenBridge::claim_public -312 ✅ -2.52%
Test::consume_mint_to_public_message -312 ✅ -2.96%
AvmGadgetsTest::sha256_hash_255 -181 ✅ -2.98%
AvmGadgetsTest::sha256_hash_2048 -788 ✅ -4.26%
AvmGadgetsTest::public_dispatch -2,419 ✅ -5.08%
AvmGadgetsTest::sha256_hash_512 -788 ✅ -10.15%
AvmGadgetsTest::sha256_hash_256 -791 ✅ -13.24%

Full diff report 👇
Program Bytecode size in bytes (+/-) %
AvmGadgetsTest::sha256_hash_20 3,739 (+369) +10.95%
AvmGadgetsTest::sha256_hash_40 3,884 (+374) +10.66%
AvmGadgetsTest::sha256_hash_10 3,669 (+352) +10.61%
AvmGadgetsTest::sha256_hash_30 3,809 (+350) +10.12%
AvmGadgetsTest::sha256_hash_50 3,954 (+350) +9.71%
AvmGadgetsTest::sha256_hash_60 4,024 (+307) +8.26%
AvmGadgetsTest::keccak_hash 2,275 (+106) +4.89%
AvmTest::u128_addition_overflow 1,302 (+36) +2.84%
AvmTest::bulk_testing 22,378 (+458) +2.09%
DocsExample::public_dispatch 4,925 (+64) +1.32%
NFT::constructor 4,538 (+41) +0.91%
Token::constructor 4,847 (+41) +0.85%
AvmTest::public_dispatch 58,818 (+489) +0.84%
AvmTest::emit_public_log 2,390 (+18) +0.76%
AppSubscription::constructor 3,587 (+23) +0.65%
AvmTest::external_call_to_divide_by_zero_recovers 2,828 (+18) +0.64%
Token::transfer_in_public 4,351 (+23) +0.53%
Parent::public_nested_static_call 3,514 (+18) +0.51%
AppSubscription::public_dispatch 4,731 (+23) +0.49%
NFT::finalize_transfer_to_private 4,606 (+18) +0.39%
NFT::_finalize_transfer_to_private_unsafe 4,653 (+18) +0.39%
Token::finalize_mint_to_private 4,805 (+18) +0.38%
Token::_finalize_mint_to_private_unsafe 4,852 (+18) +0.37%
Token::finalize_transfer_to_private 5,131 (+18) +0.35%
Token::_finalize_transfer_to_private_unsafe 5,178 (+18) +0.35%
Token::public_dispatch 32,282 (+105) +0.33%
NFT::public_dispatch 25,467 (+82) +0.32%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 6,617 (+18) +0.27%
Parent::public_dispatch 7,637 (+18) +0.24%
Uniswap::public_dispatch 23,927 (+12) +0.05%
Uniswap::swap_public 14,737 (-6) -0.04%
TokenBridge::exit_to_l1_public 7,784 (-18) -0.23%
Test::consume_message_from_arbitrary_sender_public 7,438 (-60) -0.80%
AvmGadgetsTest::sha256_hash_90 4,617 (-80) -1.70%
AvmGadgetsTest::sha256_hash_80 4,547 (-80) -1.73%
AvmGadgetsTest::sha256_hash_70 4,477 (-80) -1.76%
AvmGadgetsTest::sha256_hash_100 4,682 (-85) -1.78%
Test::public_dispatch 17,780 (-366) -2.02%
AvmGadgetsTest::sha256_hash_511 7,705 (-181) -2.30%
TokenBridge::public_dispatch 20,062 (-473) -2.30%
TokenBridge::claim_public 12,081 (-312) -2.52%
Test::consume_mint_to_public_message 10,222 (-312) -2.96%
AvmGadgetsTest::sha256_hash_255 5,901 (-181) -2.98%
AvmGadgetsTest::sha256_hash_2048 17,729 (-788) -4.26%
AvmGadgetsTest::public_dispatch 45,245 (-2,419) -5.08%
AvmGadgetsTest::sha256_hash_512 6,972 (-788) -10.15%
AvmGadgetsTest::sha256_hash_256 5,183 (-791) -13.24%

@TomAFrench
Copy link
Member Author

@dbanks12 @fcarreiro This is showing good improvements when testing sha256 on it's own. Can you check that this doesn't cause regressions in aztec contracts?

@dbanks12
Copy link
Collaborator

dbanks12 commented Feb 7, 2025

dbanks12 fcarreiro This is showing good improvements when testing sha256 on it's own. Can you check that this doesn't cause regressions in aztec contracts?

I'll test once bootstrap is fixed 👍

@TomAFrench
Copy link
Member Author

@dbanks12 this should be good to go now.

@dbanks12
Copy link
Collaborator

@dbanks12 this should be good to go now.

Will test tomorrow!

Copy link
Collaborator

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

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

I see pretty much no difference in sha execution lengths on my end. Is this PR meant to improve #instructions executed? Maybe I'm seeing a bootstrap-fast bug?

@TomAFrench
Copy link
Member Author

You're likely testing on the new contract you added last week which uses the old sha256. I've updated it now.

@fcarreiro fcarreiro requested a review from dbanks12 February 13, 2025 12:09
@fcarreiro fcarreiro removed their request for review February 13, 2025 12:09
@TomAFrench TomAFrench merged commit 438c905 into master Feb 13, 2025
52 checks passed
@TomAFrench TomAFrench deleted the tf/brillig-optimized-sha256 branch February 13, 2025 14:44
sklppy88 pushed a commit that referenced this pull request Feb 13, 2025
🤖 I have created a release *beep* *boop*
---


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

##
[0.76.4](aztec-package-v0.76.3...aztec-package-v0.76.4)
(2025-02-13)


### Miscellaneous

* **aztec-package:** Synchronize aztec-packages versions
</details>

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

##
[0.76.4](barretenberg.js-v0.76.3...barretenberg.js-v0.76.4)
(2025-02-13)


### Miscellaneous

* Unify webpack dev server versions
([#11965](#11965))
([921d2cd](921d2cd))
</details>

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

##
[0.76.4](aztec-packages-v0.76.3...aztec-packages-v0.76.4)
(2025-02-13)


### Features

* `FunctionDefinition::as_typed_expr`
(noir-lang/noir#7358)
([5efdd57](5efdd57))
* Aes decryption oracle
([#11907](#11907))
([c4ce913](c4ce913))
* **avm:** Constrained ec_add
([#11525](#11525))
([f8fe602](f8fe602))
* **avm:** Interaction testing
([#11947](#11947))
([fc647eb](fc647eb))
* **avm:** Relation microbenchmarks
([#11974](#11974))
([95b581d](95b581d))
* **cli:** Add `--target-dir` option
(noir-lang/noir#7350)
([5efdd57](5efdd57))
* Indexed protocol contracts tree
([#11897](#11897))
([96e84d4](96e84d4))
* **performance:** Check sub operations against induction variables
(noir-lang/noir#7356)
([5efdd57](5efdd57))
* **performance:** Use unchecked ops based upon known induction
variables (noir-lang/noir#7344)
([5efdd57](5efdd57))
* Small blob fixes/improvements
([#11686](#11686))
([4eab9fc](4eab9fc))
* Update fee model
([#11953](#11953))
([2798d58](2798d58))
* Use brillig optimized sha256
([#11696](#11696))
([438c905](438c905))


### Bug Fixes

* Ci fixes
([#11973](#11973))
([6386f4e](6386f4e))
* **cli:** Only lock the packages selected in the workspace
(noir-lang/noir#7345)
([5efdd57](5efdd57))
* Deterministic generation of vkeys in ts
([#11951](#11951))
([7901cac](7901cac))
* Incorrect secondary file in LSP errors
(noir-lang/noir#7347)
([5efdd57](5efdd57))
* Lock git dependencies folder when resolving workspace
(noir-lang/noir#7327)
([5efdd57](5efdd57))
* Perform SSA constraints check on final SSA
(noir-lang/noir#7334)
([5efdd57](5efdd57))
* Remove deprecated artifacts
([#11979](#11979))
([4f0dce7](4f0dce7))
* Remove serial queue in broker facade
([#11956](#11956))
([3485b52](3485b52))
* **ssa:** Make the lookback feature opt-in
(noir-lang/noir#7190)
([5efdd57](5efdd57))


### Miscellaneous

* **avm:** Tracegen interactions assertion
([#11972](#11972))
([b865ccc](b865ccc))
* Avoid doing all brillig integer arithmetic on u128s
(noir-lang/noir#7357)
([5efdd57](5efdd57))
* Basic test for MSM in Noir to catch performance improvements and
regressions (noir-lang/noir#7341)
([5efdd57](5efdd57))
* Bump devnet boot node resources
([#11958](#11958))
([bbcdefc](bbcdefc))
* **ci:** Add Vecs and vecs to cspell
(noir-lang/noir#7342)
([5efdd57](5efdd57))
* Deprecate keccak256 (noir-lang/noir#7361)
([5efdd57](5efdd57))
* Fix warnings (noir-lang/noir#7330)
([5efdd57](5efdd57))
* Mark sha256 as deprecated from the stdlib
(noir-lang/noir#7351)
([5efdd57](5efdd57))
* Moving storage slot out of `NoteHeader`
([#11904](#11904))
([8c4bb1c](8c4bb1c))
* Normalize path displayed by `nargo new`
(noir-lang/noir#7328)
([5efdd57](5efdd57))
* Redo typo PR by osrm (noir-lang/noir#7238)
([5efdd57](5efdd57))
* Release Noir(1.0.0-beta.2)
(noir-lang/noir#6914)
([5efdd57](5efdd57))
* Remove foreign calls array from Brillig VM constructor
(noir-lang/noir#7337)
([5efdd57](5efdd57))
* Remove misleading output from `nargo check`
(noir-lang/noir#7329)
([5efdd57](5efdd57))
* Remove some unused types and functions in the AST
(noir-lang/noir#7339)
([5efdd57](5efdd57))
* Remove unnecessary constants
(noir-lang/noir#7326)
([5efdd57](5efdd57))
* Revive browser test before killing it
([#11964](#11964))
([cb47cc0](cb47cc0))
* Split acirgen into multiple modules
(noir-lang/noir#7310)
([5efdd57](5efdd57))
* Unify webpack dev server versions
([#11965](#11965))
([921d2cd](921d2cd))
</details>

<details><summary>barretenberg: 0.76.4</summary>

##
[0.76.4](barretenberg-v0.76.3...barretenberg-v0.76.4)
(2025-02-13)


### Features

* Aes decryption oracle
([#11907](#11907))
([c4ce913](c4ce913))
* **avm:** Constrained ec_add
([#11525](#11525))
([f8fe602](f8fe602))
* **avm:** Interaction testing
([#11947](#11947))
([fc647eb](fc647eb))
* **avm:** Relation microbenchmarks
([#11974](#11974))
([95b581d](95b581d))


### Miscellaneous

* **avm:** Tracegen interactions assertion
([#11972](#11972))
([b865ccc](b865ccc))
* Unify webpack dev server versions
([#11965](#11965))
([921d2cd](921d2cd))
</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 Feb 14, 2025
🤖 I have created a release *beep* *boop*
---


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

##
[0.76.4](AztecProtocol/aztec-packages@aztec-package-v0.76.3...aztec-package-v0.76.4)
(2025-02-13)


### Miscellaneous

* **aztec-package:** Synchronize aztec-packages versions
</details>

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

##
[0.76.4](AztecProtocol/aztec-packages@barretenberg.js-v0.76.3...barretenberg.js-v0.76.4)
(2025-02-13)


### Miscellaneous

* Unify webpack dev server versions
([#11965](AztecProtocol/aztec-packages#11965))
([921d2cd](AztecProtocol/aztec-packages@921d2cd))
</details>

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

##
[0.76.4](AztecProtocol/aztec-packages@aztec-packages-v0.76.3...aztec-packages-v0.76.4)
(2025-02-13)


### Features

* `FunctionDefinition::as_typed_expr`
(noir-lang/noir#7358)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Aes decryption oracle
([#11907](AztecProtocol/aztec-packages#11907))
([c4ce913](AztecProtocol/aztec-packages@c4ce913))
* **avm:** Constrained ec_add
([#11525](AztecProtocol/aztec-packages#11525))
([f8fe602](AztecProtocol/aztec-packages@f8fe602))
* **avm:** Interaction testing
([#11947](AztecProtocol/aztec-packages#11947))
([fc647eb](AztecProtocol/aztec-packages@fc647eb))
* **avm:** Relation microbenchmarks
([#11974](AztecProtocol/aztec-packages#11974))
([95b581d](AztecProtocol/aztec-packages@95b581d))
* **cli:** Add `--target-dir` option
(noir-lang/noir#7350)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Indexed protocol contracts tree
([#11897](AztecProtocol/aztec-packages#11897))
([96e84d4](AztecProtocol/aztec-packages@96e84d4))
* **performance:** Check sub operations against induction variables
(noir-lang/noir#7356)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* **performance:** Use unchecked ops based upon known induction
variables (noir-lang/noir#7344)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Small blob fixes/improvements
([#11686](AztecProtocol/aztec-packages#11686))
([4eab9fc](AztecProtocol/aztec-packages@4eab9fc))
* Update fee model
([#11953](AztecProtocol/aztec-packages#11953))
([2798d58](AztecProtocol/aztec-packages@2798d58))
* Use brillig optimized sha256
([#11696](AztecProtocol/aztec-packages#11696))
([438c905](AztecProtocol/aztec-packages@438c905))


### Bug Fixes

* Ci fixes
([#11973](AztecProtocol/aztec-packages#11973))
([6386f4e](AztecProtocol/aztec-packages@6386f4e))
* **cli:** Only lock the packages selected in the workspace
(noir-lang/noir#7345)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Deterministic generation of vkeys in ts
([#11951](AztecProtocol/aztec-packages#11951))
([7901cac](AztecProtocol/aztec-packages@7901cac))
* Incorrect secondary file in LSP errors
(noir-lang/noir#7347)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Lock git dependencies folder when resolving workspace
(noir-lang/noir#7327)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Perform SSA constraints check on final SSA
(noir-lang/noir#7334)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Remove deprecated artifacts
([#11979](AztecProtocol/aztec-packages#11979))
([4f0dce7](AztecProtocol/aztec-packages@4f0dce7))
* Remove serial queue in broker facade
([#11956](AztecProtocol/aztec-packages#11956))
([3485b52](AztecProtocol/aztec-packages@3485b52))
* **ssa:** Make the lookback feature opt-in
(noir-lang/noir#7190)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))


### Miscellaneous

* **avm:** Tracegen interactions assertion
([#11972](AztecProtocol/aztec-packages#11972))
([b865ccc](AztecProtocol/aztec-packages@b865ccc))
* Avoid doing all brillig integer arithmetic on u128s
(noir-lang/noir#7357)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Basic test for MSM in Noir to catch performance improvements and
regressions (noir-lang/noir#7341)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Bump devnet boot node resources
([#11958](AztecProtocol/aztec-packages#11958))
([bbcdefc](AztecProtocol/aztec-packages@bbcdefc))
* **ci:** Add Vecs and vecs to cspell
(noir-lang/noir#7342)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Deprecate keccak256 (noir-lang/noir#7361)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Fix warnings (noir-lang/noir#7330)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Mark sha256 as deprecated from the stdlib
(noir-lang/noir#7351)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Moving storage slot out of `NoteHeader`
([#11904](AztecProtocol/aztec-packages#11904))
([8c4bb1c](AztecProtocol/aztec-packages@8c4bb1c))
* Normalize path displayed by `nargo new`
(noir-lang/noir#7328)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Redo typo PR by osrm (noir-lang/noir#7238)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Release Noir(1.0.0-beta.2)
(noir-lang/noir#6914)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Remove foreign calls array from Brillig VM constructor
(noir-lang/noir#7337)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Remove misleading output from `nargo check`
(noir-lang/noir#7329)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Remove some unused types and functions in the AST
(noir-lang/noir#7339)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Remove unnecessary constants
(noir-lang/noir#7326)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Revive browser test before killing it
([#11964](AztecProtocol/aztec-packages#11964))
([cb47cc0](AztecProtocol/aztec-packages@cb47cc0))
* Split acirgen into multiple modules
(noir-lang/noir#7310)
([5efdd57](AztecProtocol/aztec-packages@5efdd57))
* Unify webpack dev server versions
([#11965](AztecProtocol/aztec-packages#11965))
([921d2cd](AztecProtocol/aztec-packages@921d2cd))
</details>

<details><summary>barretenberg: 0.76.4</summary>

##
[0.76.4](AztecProtocol/aztec-packages@barretenberg-v0.76.3...barretenberg-v0.76.4)
(2025-02-13)


### Features

* Aes decryption oracle
([#11907](AztecProtocol/aztec-packages#11907))
([c4ce913](AztecProtocol/aztec-packages@c4ce913))
* **avm:** Constrained ec_add
([#11525](AztecProtocol/aztec-packages#11525))
([f8fe602](AztecProtocol/aztec-packages@f8fe602))
* **avm:** Interaction testing
([#11947](AztecProtocol/aztec-packages#11947))
([fc647eb](AztecProtocol/aztec-packages@fc647eb))
* **avm:** Relation microbenchmarks
([#11974](AztecProtocol/aztec-packages#11974))
([95b581d](AztecProtocol/aztec-packages@95b581d))


### Miscellaneous

* **avm:** Tracegen interactions assertion
([#11972](AztecProtocol/aztec-packages#11972))
([b865ccc](AztecProtocol/aztec-packages@b865ccc))
* Unify webpack dev server versions
([#11965](AztecProtocol/aztec-packages#11965))
([921d2cd](AztecProtocol/aztec-packages@921d2cd))
</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