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(avm): full poseidon2 #9141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IlyasRidhuan
Copy link
Contributor

@IlyasRidhuan IlyasRidhuan commented Oct 10, 2024

Poseidon2 implementation for internal use by the avm in bytecode hashing / address derivation etc

Copy link
Contributor Author

IlyasRidhuan commented Oct 10, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @IlyasRidhuan and the rest of your teammates on Graphite Graphite

@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review October 10, 2024 10:17
@IlyasRidhuan IlyasRidhuan force-pushed the ir/10-08-feat_avm_full_poseidon2 branch from 32f661e to bcb9217 Compare October 10, 2024 10:19
@IlyasRidhuan IlyasRidhuan removed the request for review from Maddiaa0 October 10, 2024 10:35
@IlyasRidhuan IlyasRidhuan force-pushed the ir/10-08-feat_avm_full_poseidon2 branch from bcb9217 to 787b8ae Compare October 10, 2024 10:53
Copy link
Contributor

@jeanmon jeanmon left a comment

Choose a reason for hiding this comment

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

LGTM in general. Please address my comments.

@@ -44,4 +44,4 @@ typename Poseidon2<Params>::FF Poseidon2<Params>::hash_buffer(const std::vector<
}

template class Poseidon2<Poseidon2Bn254ScalarFieldParams>;
} // namespace bb::crypto
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: convention that we keep an empty line before end of namespace


// If poseidon perm is active, it must be either a mem op or immediate but not both
sel_poseidon_perm * (1 - sel_poseidon_perm_mem_op + sel_poseidon_perm_immediate) = 0;
// If inactive the mem op or immediate selectors must be 0
Copy link
Contributor

Choose a reason for hiding this comment

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

"... the mem op or immediate" ... I think you meant "... the mem op and immediate"

pol commit sel_poseidon_perm_immediate;
sel_poseidon_perm_immediate * (1 - sel_poseidon_perm_immediate) = 0;

// If poseidon perm is active, it must be either a mem op or immediate but not both
Copy link
Contributor

Choose a reason for hiding this comment

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

You can actually replace both relations by a single one:
sel_poseidon_perm = sel_poseidon_perm_mem_op + sel_poseidon_perm_immediate

Then later #[skippable_if] becomes simply:
sel_poseidon_perm = 0

// Selector for if values are read from memory or already loaded in registers
pol commit sel_poseidon_perm_mem_op;
sel_poseidon_perm_mem_op * (1 - sel_poseidon_perm_mem_op) = 0;
pol commit sel_poseidon_perm_immediate;
Copy link
Contributor

Choose a reason for hiding this comment

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

As there is no use of sel_poseidon_perm_immediate in this file, I would mention that the selector is used in poseidon2_full.pil

@@ -9,9 +9,20 @@ namespace poseidon2(256);
// Selector is boolean
sel_poseidon_perm * (1 - sel_poseidon_perm) = 0;

// Selector for if values are read from memory or already loaded in registers
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate a bit more? This sentence is not super clear.


return current_state;
std::array<FF, 4> AvmPoseidon2TraceBuilder::poseidon2_permutation(std::array<FF, 4> const& input,
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: we try to establish the style "const type" rather than "type const"

{
using Poseidon2 = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>;
FF output = Poseidon2::hash(input);
// 64 rounds of hashing should be enough (1 << 6 == 64) per full hash
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe let us introduce a constant for this 64 and some explanations (related to sub clock, etc...)

const FF iv = (static_cast<uint256_t>(input.size()) << 64);
std::array<FF, 4> input_array = { 0, 0, 0, iv };

size_t padded_size = input.size() % 3 == 0 ? input.size() : input.size() + (3 - input.size() % 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should do the job: const size_t padded_size = 3 * ((input.size()+2) / 3)


for (const auto& src : poseidon2_hash_trace) {
size_t padded_size =
src.input_length % 3 == 0 ? src.input_length : src.input_length + (3 - src.input_length % 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

num_rounds_rem--;
}
// Careful - we assume here that the permutation events are in order
std::advance(perm_event, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this equivalent to perm_event++ ?

Copy link
Contributor

Changes to public function bytecode sizes

Generated at commit: a904a0065b10ab10680e5f0d54bd77210f803787, compared to commit: 26f406b0591b3f88cb37c5e8f7cb3cbfc625315e

🧾 Summary (100% most significant diffs)

Program Bytecode size in bytes (+/-) %
TokenBlacklist::public_dispatch +105,471 ❌ +415.91%
Lending::public_dispatch +51,722 ❌ +195.13%
AuthRegistry::public_dispatch +15,178 ❌ +188.99%
Auth::public_dispatch +19,052 ❌ +177.01%
AuthRegistry::consume +5,251 ❌ +175.68%
TokenBlacklist::transfer_public +9,332 ❌ +149.79%
Lending::update_accumulator +7,454 ❌ +139.88%
Token::public_dispatch +38,683 ❌ +136.24%
TokenBlacklist::mint_public +5,292 ❌ +123.36%
AvmTest::add_storage_map +2,133 ❌ +103.04%
Token::transfer_public +4,929 ❌ +102.71%
Lending::_borrow +7,697 ❌ +100.89%
TokenBlacklist::update_roles +7,302 ❌ +100.47%
NFT::mint +2,876 ❌ +94.33%
TokenBlacklist::constructor +6,725 ❌ +83.85%
TokenBlacklist::shield +5,260 ❌ +79.93%
NFT::public_dispatch +17,569 ❌ +78.81%
Test::public_dispatch +14,311 ❌ +77.53%
Auth::set_authorized +4,389 ❌ +77.05%
TokenBlacklist::burn_public +4,462 ❌ +76.73%
Auth::set_authorized_delay +4,275 ❌ +76.15%
Lending::_repay +4,044 ❌ +76.10%
CardGame::public_dispatch +11,973 ❌ +75.54%
Lending::_withdraw +5,650 ❌ +73.48%
FeeJuice::public_dispatch +3,984 ❌ +67.77%
AvmTest::public_dispatch +36,597 ❌ +64.23%
Token::shield +3,430 ❌ +62.97%
Token::mint_public +2,004 ❌ +62.00%
StatefulTest::public_dispatch +4,758 ❌ +61.38%
AuthRegistry::set_authorized +1,108 ❌ +61.11%
AuthRegistry::_set_authorized +1,108 ❌ +60.22%
AvmTest::set_storage_map +1,038 ❌ +58.98%
AuthRegistry::is_consumable +1,110 ❌ +57.66%
TokenBridge::public_dispatch +11,736 ❌ +57.39%
Lending::get_position +2,765 ❌ +57.23%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 +3,409 ❌ +57.03%
Token::burn_public +2,627 ❌ +56.06%
AppSubscription::constructor +2,132 ❌ +54.13%
AppSubscription::public_dispatch +2,780 ❌ +52.85%
Token::complete_refund +1,619 ❌ +51.71%
NFT::transfer_in_public +1,847 ❌ +49.76%
EasyPrivateVoting::public_dispatch +2,997 ❌ +48.39%
Test::consume_mint_public_message +4,314 ❌ +47.68%
NFT::constructor +2,366 ❌ +47.51%
EasyPrivateVoting::add_to_tally_public +1,084 ❌ +47.36%
Token::constructor +2,503 ❌ +46.94%
FeeJuice::_increase_public_balance +983 ❌ +41.78%
TokenBridge::claim_public +4,334 ❌ +41.43%
Benchmarking::public_dispatch +2,038 ❌ +40.95%
TokenBlacklist::mint_private +1,634 ❌ +38.77%
Uniswap::public_dispatch +8,936 ❌ +36.42%
Crowdfunding::init +1,341 ❌ +35.40%
Router::public_dispatch +985 ❌ +34.42%
Spam::public_spam +849 ❌ +33.41%
Parent::public_dispatch +2,794 ❌ +32.94%
PriceFeed::public_dispatch +1,202 ❌ +32.25%
StaticParent::public_dispatch +1,852 ❌ +31.27%
InclusionProofs::constructor +896 ❌ +31.23%
TokenBlacklist::get_roles +791 ❌ +31.08%
TokenBlacklist::_increase_public_balance +791 ❌ +30.67%
Token::_increase_public_balance +791 ❌ +30.67%
NFT::owner_of +760 ❌ +30.32%
Claim::constructor +1,054 ❌ +30.11%
Benchmarking::increment_balance +916 ❌ +29.92%
InclusionProofs::public_dispatch +1,298 ❌ +29.87%
Token::mint_private +1,000 ❌ +29.65%
Spam::public_dispatch +1,032 ❌ +29.28%
Crowdfunding::public_dispatch +1,839 ❌ +28.93%
Claim::public_dispatch +1,232 ❌ +27.54%
EasyPrivateVoting::constructor +952 ❌ +27.29%
FPC::public_dispatch +2,495 ❌ +27.05%
StaticChild::public_dispatch +759 ❌ +25.99%
Test::consume_message_from_arbitrary_sender_public +1,747 ❌ +25.41%
FPC::constructor +842 ❌ +25.35%
Uniswap::constructor +842 ❌ +25.35%
Auth::constructor +842 ❌ +25.19%
StatefulTest::public_constructor +898 ❌ +24.54%
AvmTest::bulk_testing +6,142 ❌ +23.79%
PrivateFPC::constructor +756 ❌ +22.65%
PrivateFPC::public_dispatch +939 ❌ +21.81%
TokenBridge::constructor +752 ❌ +21.61%
TestLog::emit_unencrypted_events +349 ❌ +19.60%
Parent::public_nested_static_call +603 ❌ +15.47%
Lending::deposit_public +259 ❌ +14.64%
AvmTest::sha256_hash +446 ❌ +14.39%
Lending::repay_public +200 ❌ +12.06%
CardGame::start_game +775 ❌ +11.91%
TokenBridge::exit_to_l1_public +853 ❌ +11.88%
TestLog::public_dispatch +314 ❌ +10.00%
DocsExample::public_dispatch +512 ❌ +9.68%
Auth::get_scheduled_authorized +149 ❌ +8.61%
Auth::get_authorized +153 ❌ +8.37%
AvmTest::u128_addition_overflow +97 ❌ +7.70%
FeeJuice::set_portal +68 ❌ +7.17%
Lending::_deposit +166 ❌ +7.15%
NFT::finalize_transfer_to_private +349 ❌ +6.00%
CardGame::on_card_played +314 ❌ +5.81%
Token::assert_minter_and_mint +118 ❌ +5.07%
Lending::get_assets +40 ❌ +4.98%
NFT::_finish_transfer_to_public +79 ❌ +4.66%
NFT::is_minter +81 ❌ +4.52%
Token::is_minter +81 ❌ +4.52%
StatefulTest::increment_public_value +85 ❌ +4.49%
AuthRegistry::set_reject_all +73 ❌ +4.42%
NFT::set_minter +85 ❌ +4.42%
Token::set_minter +85 ❌ +4.42%
Benchmarking::broadcast +79 ❌ +4.40%
TokenBlacklist::balance_of_public +81 ❌ +4.32%
Token::balance_of_public +81 ❌ +4.32%
AvmTest::read_storage_map +75 ❌ +4.31%
StatefulTest::get_public_value +75 ❌ +4.29%
AuthRegistry::is_reject_all +75 ❌ +4.26%
StatefulTest::increment_public_value_no_init_check +79 ❌ +4.24%
PriceFeed::get_price +75 ❌ +4.21%
PriceFeed::set_price +73 ❌ +4.20%
Lending::borrow_public +48 ❌ +4.10%
Lending::withdraw_public +48 ❌ +4.10%
FeeJuice::balance_of_public +75 ❌ +4.07%
FPC::prepare_fee +50 ❌ +4.03%
StaticParent::public_nested_static_call +53 ❌ +4.01%
Lending::get_asset +71 ❌ +3.56%
CardGame::on_game_joined +163 ❌ +3.54%
Auth::get_authorized_delay +70 ❌ +3.28%
AvmInitializerTest::public_dispatch +84 ❌ +2.34%
AuthWitTest::public_dispatch +50 ❌ +2.32%
AvmInitializerTest::constructor +54 ❌ +1.91%
CardGame::on_cards_claimed +89 ❌ +1.21%
AvmTest::elliptic_curve_add +5 ❌ +0.97%
AvmTest::debug_logging +9 ❌ +0.68%
Uniswap::swap_public +102 ❌ +0.67%
TokenBridge::_call_mint_on_token +7 ❌ +0.56%
ImportTest::public_dispatch +9 ❌ +0.52%
FeeJuice::check_balance +11 ❌ +0.51%
AvmTest::keccak_hash +11 ❌ +0.41%
Child::set_value_twice_with_nested_first +3 ❌ +0.33%
Child::set_value_twice_with_nested_last +3 ❌ +0.33%
Parent::public_static_call +3 ❌ +0.31%
StaticParent::public_static_call +3 ❌ +0.31%
AvmTest::emit_unencrypted_log +3 ❌ +0.10%
AvmTest::poseidon2_hash -1 ✅ -0.06%
AvmTest::nested_static_call_to_add -1 ✅ -0.12%
AvmTest::nested_call_to_add -1 ✅ -0.12%
AvmTest::nested_call_to_assert_same -1 ✅ -0.12%
AvmTest::nested_call_to_add_with_gas -1 ✅ -0.12%
Parent::pub_entry_point -1 ✅ -0.14%
StaticParent::public_call -1 ✅ -0.14%
StaticParent::public_get_value_from_child -1 ✅ -0.14%
Test::emit_unencrypted -3 ✅ -0.18%
Uniswap::_assert_token_is_same -1 ✅ -0.21%
Delegator::public_dispatch -6 ✅ -0.30%
Crowdfunding::_publish_donation_receipts -5 ✅ -0.39%
DelegatedOn::public_dispatch -5 ✅ -0.40%
AvmTest::create_different_nullifier_in_nested_call -3 ✅ -0.43%
AvmTest::create_same_nullifier_in_nested_call -3 ✅ -0.44%
AuthWitTest::consume_public -5 ✅ -0.57%
AvmTest::get_args_hash -11 ✅ -0.67%
ImportTest::pub_call_public_fn -5 ✅ -0.73%
AvmTest::nested_static_call_to_set_storage -5 ✅ -0.73%
AvmTest::pedersen_hash -37 ✅ -1.08%
AvmTest::pedersen_hash_with_index -37 ✅ -1.08%
NFT::set_admin -7 ✅ -1.08%
Token::set_admin -7 ✅ -1.08%
EasyPrivateVoting::end_vote -7 ✅ -1.09%
DocsExample::initialize_public_immutable -9 ✅ -1.13%
DocsExample::initialize_shared_immutable -9 ✅ -1.13%
Child::pub_inc_value_internal -9 ✅ -1.26%
StaticChild::pub_illegal_inc_value -9 ✅ -1.27%
Child::pub_inc_value -9 ✅ -1.31%
StaticChild::pub_inc_value -9 ✅ -1.31%
DocsExample::get_shared_immutable_constrained_public_multiple -11 ✅ -1.51%
Test::create_l2_to_l1_message_public -39 ✅ -1.65%
AvmTest::read_storage_list -11 ✅ -1.74%
TokenBlacklist::total_supply -11 ✅ -1.79%
Token::total_supply -11 ✅ -1.79%
TokenBridge::get_portal_address_public -11 ✅ -2.01%
Token::public_get_decimals -11 ✅ -2.07%
TokenBridge::_assert_token_is_same -11 ✅ -2.08%
NFT::public_get_name -11 ✅ -2.13%
NFT::get_admin -11 ✅ -2.13%
Token::public_get_symbol -11 ✅ -2.13%
Token::public_get_name -11 ✅ -2.13%
NFT::public_get_symbol -11 ✅ -2.15%
TokenBridge::get_token -11 ✅ -2.15%
Token::get_admin -11 ✅ -2.15%
AvmTest::set_read_storage_single -13 ✅ -2.16%
AvmInitializerTest::read_storage_immutable -11 ✅ -2.24%
Delegator::public_delegate_set_value -21 ✅ -2.33%
AvmTest::test_get_contract_instance -21 ✅ -2.44%
DocsExample::get_shared_immutable_constrained_public_indirect -11 ✅ -2.55%
FPC::pay_refund -44 ✅ -2.58%
AvmTest::keccak_f1600 -13 ✅ -2.72%
AvmTest::u128_from_integer_overflow -23 ✅ -3.08%
DocsExample::get_shared_immutable_constrained_public -17 ✅ -3.15%
Child::public_dispatch -183 ✅ -3.22%
AvmTest::variable_base_msm -15 ✅ -3.28%
AvmTest::assert_calldata_copy -15 ✅ -3.39%
NFT::_store_point_in_transient_storage -13 ✅ -3.71%
AvmTest::read_storage_single -17 ✅ -3.72%
Child::pub_set_value -15 ✅ -4.56%
StaticChild::pub_set_value -15 ✅ -4.56%
TokenBlacklist::_reduce_total_supply -44 ✅ -4.78%
Token::_reduce_total_supply -44 ✅ -4.78%
AvmTest::return_oracle -17 ✅ -4.93%
AvmTest::to_radix_le -13 ✅ -5.35%
Lending::init -158 ✅ -5.43%
AvmTest::test_get_contract_instance_raw -23 ✅ -5.93%
AvmTest::pedersen_commit -23 ✅ -6.17%
FPC::pay_refund_with_shielded_rebate -101 ✅ -6.17%
DocsExample::update_leader -19 ✅ -6.33%
AvmTest::set_storage_list -19 ✅ -7.25%
DelegatedOn::public_set_value -19 ✅ -7.69%
InclusionProofs::test_nullifier_inclusion_from_public -11 ✅ -7.69%
AvmTest::set_storage_single -19 ✅ -7.88%
Router::_check_timestamp -110 ✅ -8.42%
Router::_check_block_number -110 ✅ -8.53%
AvmTest::add_u128 -19 ✅ -9.13%
Test::assert_public_global_vars -23 ✅ -9.20%
AvmTest::check_selector -17 ✅ -9.39%
AvmTest::get_function_selector -17 ✅ -10.24%
StaticChild::pub_get_value -19 ✅ -11.31%
Parent::pub_entry_point_twice -141 ✅ -11.85%
InclusionProofs::push_nullifier_public -15 ✅ -12.10%
AvmTest::emit_nullifier_and_check -15 ✅ -12.61%
Child::pub_get_value -19 ✅ -13.38%
AvmTest::assert_nullifier_exists -17 ✅ -14.78%
AvmTest::l1_to_l2_msg_exists -17 ✅ -15.32%
AvmTest::note_hash_exists -17 ✅ -15.32%
AvmTest::nullifier_exists -17 ✅ -15.45%
AvmTest::assert_same -19 ✅ -15.83%
AvmTest::set_opcode_really_big_field -23 ✅ -18.55%
AvmTest::set_opcode_big_field -23 ✅ -18.55%
Test::is_time_equal -23 ✅ -19.01%
AvmTest::send_l2_to_l1_msg -19 ✅ -19.19%
Test::create_l2_to_l1_message_arbitrary_recipient_public -19 ✅ -19.19%
AvmTest::assert_timestamp -23 ✅ -20.00%
AvmTest::nullifier_collision -19 ✅ -20.00%
AvmTest::modulo2 -23 ✅ -20.18%
AvmTest::add_args_return -23 ✅ -21.10%
AvmTest::set_opcode_small_field -23 ✅ -21.30%
Test::dummy_public_call -23 ✅ -21.50%
DocsExample::spend_public_authwit -23 ✅ -22.55%
AvmTest::set_opcode_u64 -23 ✅ -23.00%
AvmTest::new_nullifier -21 ✅ -23.08%
AvmTest::new_note_hash -21 ✅ -23.08%
Test::emit_nullifier_public -21 ✅ -23.08%
AvmTest::set_opcode_u32 -23 ✅ -23.96%
AvmTest::get_fee_per_l2_gas -23 ✅ -25.00%
AvmTest::set_opcode_u8 -23 ✅ -25.00%
AvmTest::get_sender -23 ✅ -25.00%
AvmTest::get_timestamp -23 ✅ -25.00%
AvmTest::get_l2_gas_left -23 ✅ -25.00%
AvmTest::get_chain_id -23 ✅ -25.00%
AvmTest::get_fee_per_da_gas -23 ✅ -25.00%
AvmTest::get_address -23 ✅ -25.00%
AvmTest::get_storage_address -23 ✅ -25.00%
AvmTest::get_da_gas_left -23 ✅ -25.00%
AvmTest::get_version -23 ✅ -25.00%
AvmTest::get_block_number -23 ✅ -25.00%
AvmTest::get_transaction_fee -23 ✅ -25.00%
Child::set_value_with_two_nested_calls -575 ✅ -43.79%
AvmTest::assertion_failure -75 ✅ -47.17%
AvmTest::elliptic_curve_add_and_double -474 ✅ -73.49%

Full diff report 👇
Program Bytecode size in bytes (+/-) %
TokenBlacklist::public_dispatch 130,830 (+105,471) +415.91%
Lending::public_dispatch 78,229 (+51,722) +195.13%
AuthRegistry::public_dispatch 23,209 (+15,178) +188.99%
Auth::public_dispatch 29,815 (+19,052) +177.01%
AuthRegistry::consume 8,240 (+5,251) +175.68%
TokenBlacklist::transfer_public 15,562 (+9,332) +149.79%
Lending::update_accumulator 12,783 (+7,454) +139.88%
Token::public_dispatch 67,077 (+38,683) +136.24%
TokenBlacklist::mint_public 9,582 (+5,292) +123.36%
AvmTest::add_storage_map 4,203 (+2,133) +103.04%
Token::transfer_public 9,728 (+4,929) +102.71%
Lending::_borrow 15,326 (+7,697) +100.89%
TokenBlacklist::update_roles 14,570 (+7,302) +100.47%
NFT::mint 5,925 (+2,876) +94.33%
TokenBlacklist::constructor 14,745 (+6,725) +83.85%
TokenBlacklist::shield 11,841 (+5,260) +79.93%
NFT::public_dispatch 39,861 (+17,569) +78.81%
Test::public_dispatch 32,770 (+14,311) +77.53%
Auth::set_authorized 10,085 (+4,389) +77.05%
TokenBlacklist::burn_public 10,277 (+4,462) +76.73%
Auth::set_authorized_delay 9,889 (+4,275) +76.15%
Lending::_repay 9,358 (+4,044) +76.10%
CardGame::public_dispatch 27,822 (+11,973) +75.54%
Lending::_withdraw 13,339 (+5,650) +73.48%
FeeJuice::public_dispatch 9,863 (+3,984) +67.77%
AvmTest::public_dispatch 93,571 (+36,597) +64.23%
Token::shield 8,877 (+3,430) +62.97%
Token::mint_public 5,236 (+2,004) +62.00%
StatefulTest::public_dispatch 12,510 (+4,758) +61.38%
AuthRegistry::set_authorized 2,921 (+1,108) +61.11%
AuthRegistry::_set_authorized 2,948 (+1,108) +60.22%
AvmTest::set_storage_map 2,798 (+1,038) +58.98%
AuthRegistry::is_consumable 3,035 (+1,110) +57.66%
TokenBridge::public_dispatch 32,186 (+11,736) +57.39%
Lending::get_position 7,596 (+2,765) +57.23%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 9,387 (+3,409) +57.03%
Token::burn_public 7,313 (+2,627) +56.06%
AppSubscription::constructor 6,071 (+2,132) +54.13%
AppSubscription::public_dispatch 8,040 (+2,780) +52.85%
Token::complete_refund 4,750 (+1,619) +51.71%
NFT::transfer_in_public 5,559 (+1,847) +49.76%
EasyPrivateVoting::public_dispatch 9,190 (+2,997) +48.39%
Test::consume_mint_public_message 13,361 (+4,314) +47.68%
NFT::constructor 7,346 (+2,366) +47.51%
EasyPrivateVoting::add_to_tally_public 3,373 (+1,084) +47.36%
Token::constructor 7,835 (+2,503) +46.94%
FeeJuice::_increase_public_balance 3,336 (+983) +41.78%
TokenBridge::claim_public 14,796 (+4,334) +41.43%
Benchmarking::public_dispatch 7,015 (+2,038) +40.95%
TokenBlacklist::mint_private 5,849 (+1,634) +38.77%
Uniswap::public_dispatch 33,470 (+8,936) +36.42%
Crowdfunding::init 5,129 (+1,341) +35.40%
Router::public_dispatch 3,847 (+985) +34.42%
Spam::public_spam 3,390 (+849) +33.41%
Parent::public_dispatch 11,276 (+2,794) +32.94%
PriceFeed::public_dispatch 4,929 (+1,202) +32.25%
StaticParent::public_dispatch 7,774 (+1,852) +31.27%
InclusionProofs::constructor 3,765 (+896) +31.23%
TokenBlacklist::get_roles 3,336 (+791) +31.08%
TokenBlacklist::_increase_public_balance 3,370 (+791) +30.67%
Token::_increase_public_balance 3,370 (+791) +30.67%
NFT::owner_of 3,267 (+760) +30.32%
Claim::constructor 4,555 (+1,054) +30.11%
Benchmarking::increment_balance 3,978 (+916) +29.92%
InclusionProofs::public_dispatch 5,643 (+1,298) +29.87%
Token::mint_private 4,373 (+1,000) +29.65%
Spam::public_dispatch 4,556 (+1,032) +29.28%
Crowdfunding::public_dispatch 8,195 (+1,839) +28.93%
Claim::public_dispatch 5,705 (+1,232) +27.54%
EasyPrivateVoting::constructor 4,440 (+952) +27.29%
FPC::public_dispatch 11,720 (+2,495) +27.05%
StaticChild::public_dispatch 3,679 (+759) +25.99%
Test::consume_message_from_arbitrary_sender_public 8,621 (+1,747) +25.41%
FPC::constructor 4,163 (+842) +25.35%
Uniswap::constructor 4,163 (+842) +25.35%
Auth::constructor 4,185 (+842) +25.19%
StatefulTest::public_constructor 4,558 (+898) +24.54%
AvmTest::bulk_testing 31,964 (+6,142) +23.79%
PrivateFPC::constructor 4,094 (+756) +22.65%
PrivateFPC::public_dispatch 5,244 (+939) +21.81%
TokenBridge::constructor 4,232 (+752) +21.61%
TestLog::emit_unencrypted_events 2,130 (+349) +19.60%
Parent::public_nested_static_call 4,500 (+603) +15.47%
Lending::deposit_public 2,028 (+259) +14.64%
AvmTest::sha256_hash 3,546 (+446) +14.39%
Lending::repay_public 1,858 (+200) +12.06%
CardGame::start_game 7,282 (+775) +11.91%
TokenBridge::exit_to_l1_public 8,035 (+853) +11.88%
TestLog::public_dispatch 3,455 (+314) +10.00%
DocsExample::public_dispatch 5,800 (+512) +9.68%
Auth::get_scheduled_authorized 1,879 (+149) +8.61%
Auth::get_authorized 1,980 (+153) +8.37%
AvmTest::u128_addition_overflow 1,357 (+97) +7.70%
FeeJuice::set_portal 1,017 (+68) +7.17%
Lending::_deposit 2,488 (+166) +7.15%
NFT::finalize_transfer_to_private 6,166 (+349) +6.00%
CardGame::on_card_played 5,723 (+314) +5.81%
Token::assert_minter_and_mint 2,444 (+118) +5.07%
Lending::get_assets 844 (+40) +4.98%
NFT::_finish_transfer_to_public 1,775 (+79) +4.66%
NFT::is_minter 1,874 (+81) +4.52%
Token::is_minter 1,874 (+81) +4.52%
StatefulTest::increment_public_value 1,978 (+85) +4.49%
AuthRegistry::set_reject_all 1,726 (+73) +4.42%
NFT::set_minter 2,010 (+85) +4.42%
Token::set_minter 2,010 (+85) +4.42%
Benchmarking::broadcast 1,875 (+79) +4.40%
TokenBlacklist::balance_of_public 1,956 (+81) +4.32%
Token::balance_of_public 1,956 (+81) +4.32%
AvmTest::read_storage_map 1,814 (+75) +4.31%
StatefulTest::get_public_value 1,825 (+75) +4.29%
AuthRegistry::is_reject_all 1,835 (+75) +4.26%
StatefulTest::increment_public_value_no_init_check 1,944 (+79) +4.24%
PriceFeed::get_price 1,856 (+75) +4.21%
PriceFeed::set_price 1,810 (+73) +4.20%
Lending::borrow_public 1,218 (+48) +4.10%
Lending::withdraw_public 1,218 (+48) +4.10%
FeeJuice::balance_of_public 1,917 (+75) +4.07%
FPC::prepare_fee 1,291 (+50) +4.03%
StaticParent::public_nested_static_call 1,374 (+53) +4.01%
Lending::get_asset 2,064 (+71) +3.56%
CardGame::on_game_joined 4,764 (+163) +3.54%
Auth::get_authorized_delay 2,205 (+70) +3.28%
AvmInitializerTest::public_dispatch 3,671 (+84) +2.34%
AuthWitTest::public_dispatch 2,201 (+50) +2.32%
AvmInitializerTest::constructor 2,877 (+54) +1.91%
CardGame::on_cards_claimed 7,472 (+89) +1.21%
AvmTest::elliptic_curve_add 521 (+5) +0.97%
AvmTest::debug_logging 1,331 (+9) +0.68%
Uniswap::swap_public 15,316 (+102) +0.67%
TokenBridge::_call_mint_on_token 1,249 (+7) +0.56%
ImportTest::public_dispatch 1,732 (+9) +0.52%
FeeJuice::check_balance 2,176 (+11) +0.51%
AvmTest::keccak_hash 2,719 (+11) +0.41%
Child::set_value_twice_with_nested_first 920 (+3) +0.33%
Child::set_value_twice_with_nested_last 920 (+3) +0.33%
Parent::public_static_call 982 (+3) +0.31%
StaticParent::public_static_call 982 (+3) +0.31%
AvmTest::emit_unencrypted_log 2,927 (+3) +0.10%
AvmTest::poseidon2_hash 1,563 (-1) -0.06%
AvmTest::nested_static_call_to_add 863 (-1) -0.12%
AvmTest::nested_call_to_add 863 (-1) -0.12%
AvmTest::nested_call_to_assert_same 863 (-1) -0.12%
AvmTest::nested_call_to_add_with_gas 838 (-1) -0.12%
Parent::pub_entry_point 718 (-1) -0.14%
StaticParent::public_call 718 (-1) -0.14%
StaticParent::public_get_value_from_child 709 (-1) -0.14%
Test::emit_unencrypted 1,623 (-3) -0.18%
Uniswap::_assert_token_is_same 466 (-1) -0.21%
Delegator::public_dispatch 2,025 (-6) -0.30%
Crowdfunding::_publish_donation_receipts 1,270 (-5) -0.39%
DelegatedOn::public_dispatch 1,256 (-5) -0.40%
AvmTest::create_different_nullifier_in_nested_call 695 (-3) -0.43%
AvmTest::create_same_nullifier_in_nested_call 684 (-3) -0.44%
AuthWitTest::consume_public 878 (-5) -0.57%
AvmTest::get_args_hash 1,629 (-11) -0.67%
ImportTest::pub_call_public_fn 677 (-5) -0.73%
AvmTest::nested_static_call_to_set_storage 676 (-5) -0.73%
AvmTest::pedersen_hash 3,401 (-37) -1.08%
AvmTest::pedersen_hash_with_index 3,401 (-37) -1.08%
NFT::set_admin 639 (-7) -1.08%
Token::set_admin 639 (-7) -1.08%
EasyPrivateVoting::end_vote 638 (-7) -1.09%
DocsExample::initialize_public_immutable 786 (-9) -1.13%
DocsExample::initialize_shared_immutable 786 (-9) -1.13%
Child::pub_inc_value_internal 703 (-9) -1.26%
StaticChild::pub_illegal_inc_value 698 (-9) -1.27%
Child::pub_inc_value 677 (-9) -1.31%
StaticChild::pub_inc_value 677 (-9) -1.31%
DocsExample::get_shared_immutable_constrained_public_multiple 716 (-11) -1.51%
Test::create_l2_to_l1_message_public 2,330 (-39) -1.65%
AvmTest::read_storage_list 621 (-11) -1.74%
TokenBlacklist::total_supply 602 (-11) -1.79%
Token::total_supply 602 (-11) -1.79%
TokenBridge::get_portal_address_public 537 (-11) -2.01%
Token::public_get_decimals 520 (-11) -2.07%
TokenBridge::_assert_token_is_same 517 (-11) -2.08%
NFT::public_get_name 505 (-11) -2.13%
NFT::get_admin 505 (-11) -2.13%
Token::public_get_symbol 505 (-11) -2.13%
Token::public_get_name 505 (-11) -2.13%
NFT::public_get_symbol 500 (-11) -2.15%
TokenBridge::get_token 500 (-11) -2.15%
Token::get_admin 500 (-11) -2.15%
AvmTest::set_read_storage_single 589 (-13) -2.16%
AvmInitializerTest::read_storage_immutable 479 (-11) -2.24%
Delegator::public_delegate_set_value 879 (-21) -2.33%
AvmTest::test_get_contract_instance 841 (-21) -2.44%
DocsExample::get_shared_immutable_constrained_public_indirect 421 (-11) -2.55%
FPC::pay_refund 1,661 (-44) -2.58%
AvmTest::keccak_f1600 465 (-13) -2.72%
AvmTest::u128_from_integer_overflow 723 (-23) -3.08%
DocsExample::get_shared_immutable_constrained_public 522 (-17) -3.15%
Child::public_dispatch 5,494 (-183) -3.22%
AvmTest::variable_base_msm 442 (-15) -3.28%
AvmTest::assert_calldata_copy 427 (-15) -3.39%
NFT::_store_point_in_transient_storage 337 (-13) -3.71%
AvmTest::read_storage_single 440 (-17) -3.72%
Child::pub_set_value 314 (-15) -4.56%
StaticChild::pub_set_value 314 (-15) -4.56%
TokenBlacklist::_reduce_total_supply 876 (-44) -4.78%
Token::_reduce_total_supply 876 (-44) -4.78%
AvmTest::return_oracle 328 (-17) -4.93%
AvmTest::to_radix_le 230 (-13) -5.35%
Lending::init 2,754 (-158) -5.43%
AvmTest::test_get_contract_instance_raw 365 (-23) -5.93%
AvmTest::pedersen_commit 350 (-23) -6.17%
FPC::pay_refund_with_shielded_rebate 1,536 (-101) -6.17%
DocsExample::update_leader 281 (-19) -6.33%
AvmTest::set_storage_list 243 (-19) -7.25%
DelegatedOn::public_set_value 228 (-19) -7.69%
InclusionProofs::test_nullifier_inclusion_from_public 132 (-11) -7.69%
AvmTest::set_storage_single 222 (-19) -7.88%
Router::_check_timestamp 1,197 (-110) -8.42%
Router::_check_block_number 1,180 (-110) -8.53%
AvmTest::add_u128 189 (-19) -9.13%
Test::assert_public_global_vars 227 (-23) -9.20%
AvmTest::check_selector 164 (-17) -9.39%
AvmTest::get_function_selector 149 (-17) -10.24%
StaticChild::pub_get_value 149 (-19) -11.31%
Parent::pub_entry_point_twice 1,049 (-141) -11.85%
InclusionProofs::push_nullifier_public 109 (-15) -12.10%
AvmTest::emit_nullifier_and_check 104 (-15) -12.61%
Child::pub_get_value 123 (-19) -13.38%
AvmTest::assert_nullifier_exists 98 (-17) -14.78%
AvmTest::l1_to_l2_msg_exists 94 (-17) -15.32%
AvmTest::note_hash_exists 94 (-17) -15.32%
AvmTest::nullifier_exists 93 (-17) -15.45%
AvmTest::assert_same 101 (-19) -15.83%
AvmTest::set_opcode_really_big_field 101 (-23) -18.55%
AvmTest::set_opcode_big_field 101 (-23) -18.55%
Test::is_time_equal 98 (-23) -19.01%
AvmTest::send_l2_to_l1_msg 80 (-19) -19.19%
Test::create_l2_to_l1_message_arbitrary_recipient_public 80 (-19) -19.19%
AvmTest::assert_timestamp 92 (-23) -20.00%
AvmTest::nullifier_collision 76 (-19) -20.00%
AvmTest::modulo2 91 (-23) -20.18%
AvmTest::add_args_return 86 (-23) -21.10%
AvmTest::set_opcode_small_field 85 (-23) -21.30%
Test::dummy_public_call 84 (-23) -21.50%
DocsExample::spend_public_authwit 79 (-23) -22.55%
AvmTest::set_opcode_u64 77 (-23) -23.00%
AvmTest::new_nullifier 70 (-21) -23.08%
AvmTest::new_note_hash 70 (-21) -23.08%
Test::emit_nullifier_public 70 (-21) -23.08%
AvmTest::set_opcode_u32 73 (-23) -23.96%
AvmTest::get_fee_per_l2_gas 69 (-23) -25.00%
AvmTest::set_opcode_u8 69 (-23) -25.00%
AvmTest::get_sender 69 (-23) -25.00%
AvmTest::get_timestamp 69 (-23) -25.00%
AvmTest::get_l2_gas_left 69 (-23) -25.00%
AvmTest::get_chain_id 69 (-23) -25.00%
AvmTest::get_fee_per_da_gas 69 (-23) -25.00%
AvmTest::get_address 69 (-23) -25.00%
AvmTest::get_storage_address 69 (-23) -25.00%
AvmTest::get_da_gas_left 69 (-23) -25.00%
AvmTest::get_version 69 (-23) -25.00%
AvmTest::get_block_number 69 (-23) -25.00%
AvmTest::get_transaction_fee 69 (-23) -25.00%
Child::set_value_with_two_nested_calls 738 (-575) -43.79%
AvmTest::assertion_failure 84 (-75) -47.17%
AvmTest::elliptic_curve_add_and_double 171 (-474) -73.49%

Copy link
Contributor

Changes to circuit sizes

Generated at commit: a904a0065b10ab10680e5f0d54bd77210f803787, compared to commit: 2b09709932885b8a0de4bf2b91fb381d39baf6b2

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail +96 ❌ +2.07% +20 ❌ +0.22%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail 4,744 (+96) +2.07% 9,041 (+20) +0.22%

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.

2 participants