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: Gas Utils for L1 operations #9834

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

feat: Gas Utils for L1 operations #9834

wants to merge 23 commits into from

Conversation

spypsy
Copy link
Member

@spypsy spypsy commented Nov 8, 2024

Fixes #9833
Also

  • add some env var parsing in local native tests scripts to run against different networks
  • Add getNodeInfo to AztecNode interface

@spypsy spypsy marked this pull request as ready for review November 11, 2024 15:04
Copy link
Contributor

github-actions bot commented Nov 13, 2024

Changes to circuit sizes

Generated at commit: 13bef478a268e9dcbc341db5623161102cf31272, compared to commit: 451feed4fb355b81acedeba05ebc62468c3c7316

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset_4_4_4_4_4_4_4_4_1 +1 ❌ +0.00% +2 ❌ +0.00%
rollup_base_public -40 ✅ -0.01% +52 ❌ +0.00%
private_kernel_reset +1 ❌ +0.00% +1 ❌ +0.00%
private_kernel_empty +1 ❌ +0.16% +1 ❌ +0.00%
parity_root -3 ✅ -0.06% -3 ✅ -0.00%
rollup_block_root -4 ✅ -0.09% -4 ✅ -0.00%
rollup_block_merge -4 ✅ -0.03% -4 ✅ -0.00%
rollup_root -4 ✅ -0.03% -4 ✅ -0.00%
rollup_merge -4 ✅ -0.12% -4 ✅ -0.00%
rollup_base_private -38 ✅ -0.01% -31 ✅ -0.00%
parity_base -3 ✅ -0.07% -3 ✅ -0.01%
private_kernel_tail -1 ✅ -0.02% -2 ✅ -0.02%
private_kernel_tail_to_public -3 ✅ -0.02% -10 ✅ -0.03%
private_kernel_inner -23 ✅ -0.06% -19 ✅ -0.03%
private_kernel_init -18 ✅ -0.08% -16 ✅ -0.05%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset_4_4_4_4_4_4_4_4_1 32,456 (+1) +0.00% 86,602 (+2) +0.00%
rollup_base_public 470,052 (-40) -0.01% 3,770,650 (+52) +0.00%
private_kernel_reset 84,098 (+1) +0.00% 618,118 (+1) +0.00%
private_kernel_empty 608 (+1) +0.16% 942,835 (+1) +0.00%
parity_root 5,031 (-3) -0.06% 3,801,549 (-3) -0.00%
rollup_block_root 4,485 (-4) -0.09% 2,863,248 (-4) -0.00%
rollup_block_merge 12,001 (-4) -0.03% 1,940,916 (-4) -0.00%
rollup_root 11,985 (-4) -0.03% 1,940,902 (-4) -0.00%
rollup_merge 3,415 (-4) -0.12% 1,909,442 (-4) -0.00%
rollup_base_private 332,869 (-38) -0.01% 3,432,522 (-31) -0.00%
parity_base 4,298 (-3) -0.07% 30,695 (-3) -0.01%
private_kernel_tail 4,492 (-1) -0.02% 13,043 (-2) -0.02%
private_kernel_tail_to_public 18,849 (-3) -0.02% 31,290 (-10) -0.03%
private_kernel_inner 38,070 (-23) -0.06% 57,511 (-19) -0.03%
private_kernel_init 21,708 (-18) -0.08% 34,871 (-16) -0.05%

Copy link
Contributor

github-actions bot commented Nov 13, 2024

Changes to public function bytecode sizes

Generated at commit: 13bef478a268e9dcbc341db5623161102cf31272, compared to commit: 451feed4fb355b81acedeba05ebc62468c3c7316

🧾 Summary (100% most significant diffs)

Program Bytecode size in bytes (+/-) %
Token::public_dispatch +2,515 ❌ +7.36%
AvmTest::bulk_testing +1,712 ❌ +7.20%
TokenBridge::public_dispatch +670 ❌ +3.05%
Benchmarking::public_dispatch +28 ❌ +0.49%
Uniswap::public_dispatch +32 ❌ +0.13%
Uniswap::swap_public -12 ✅ -0.08%
TokenBridge::claim_public -12 ✅ -0.10%
Test::consume_mint_public_message -12 ✅ -0.11%
Lending::_withdraw -12 ✅ -0.13%
Lending::_borrow -12 ✅ -0.13%
TokenBridge::exit_to_l1_public -12 ✅ -0.15%
Test::consume_message_from_arbitrary_sender_public -12 ✅ -0.15%
TokenBlacklist::constructor -12 ✅ -0.15%
CardGame::public_dispatch -25 ✅ -0.15%
TokenBlacklist::update_roles -12 ✅ -0.16%
Token::_finalize_transfer_to_private_unsafe -12 ✅ -0.16%
CardGame::on_cards_claimed -12 ✅ -0.16%
Token::finalize_transfer_to_private -12 ✅ -0.16%
Token::_finalize_mint_to_private_unsafe -12 ✅ -0.17%
Token::finalize_mint_to_private -12 ✅ -0.17%
CardGame::start_game -12 ✅ -0.17%
NFT::_finalize_transfer_to_private_unsafe -12 ✅ -0.18%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 -12 ✅ -0.19%
NFT::finalize_transfer_to_private -12 ✅ -0.19%
TokenBlacklist::shield -12 ✅ -0.19%
TokenBlacklist::transfer_public -12 ✅ -0.19%
Lending::_repay -12 ✅ -0.19%
Token::complete_refund -12 ✅ -0.20%
Auth::set_authorized -12 ✅ -0.20%
CardGame::on_card_played -12 ✅ -0.20%
Auth::set_authorized_delay -12 ✅ -0.20%
TokenBlacklist::burn_public -12 ✅ -0.20%
Lending::update_accumulator -12 ✅ -0.21%
StatefulTest::public_dispatch -17 ✅ -0.21%
Lending::get_position -12 ✅ -0.23%
Token::constructor -12 ✅ -0.23%
CardGame::on_game_joined -12 ✅ -0.24%
Token::transfer_public -12 ✅ -0.25%
NFT::constructor -12 ✅ -0.25%
Token::burn_public -12 ✅ -0.26%
TokenBlacklist::mint_public -12 ✅ -0.26%
TokenBlacklist::mint_private -12 ✅ -0.28%
AvmTest::sha256_hash -12 ✅ -0.31%
StatefulTest::public_constructor -12 ✅ -0.31%
FPC::public_dispatch -27 ✅ -0.32%
NFT::transfer_in_public -12 ✅ -0.32%
Benchmarking::increment_balance -12 ✅ -0.32%
Test::public_dispatch -64 ✅ -0.32%
AppSubscription::constructor -12 ✅ -0.32%
Crowdfunding::init -12 ✅ -0.34%
Token::mint_public -12 ✅ -0.34%
NFT::mint -12 ✅ -0.36%
Parent::public_nested_static_call -12 ✅ -0.36%
Claim::constructor -12 ✅ -0.37%
EasyPrivateVoting::constructor -12 ✅ -0.37%
AuthRegistry::consume -12 ✅ -0.37%
Lending::init -12 ✅ -0.37%
FPC::constructor -12 ✅ -0.38%
Auth::constructor -12 ✅ -0.39%
Uniswap::constructor -12 ✅ -0.39%
Lending::_deposit -12 ✅ -0.39%
AvmTest::emit_unencrypted_log -12 ✅ -0.40%
AvmTest::pedersen_hash -12 ✅ -0.41%
AvmTest::pedersen_hash_with_index -12 ✅ -0.41%
TokenBlacklist::_increase_public_balance -12 ✅ -0.42%
Token::_increase_public_balance -12 ✅ -0.42%
TokenBlacklist::public_dispatch -107 ✅ -0.42%
NFT::owner_of -12 ✅ -0.43%
Spam::public_spam -12 ✅ -0.43%
TokenBlacklist::get_roles -12 ✅ -0.43%
AvmTest::keccak_hash -12 ✅ -0.44%
EasyPrivateVoting::public_dispatch -27 ✅ -0.44%
InclusionProofs::constructor -12 ✅ -0.46%
FeeJuice::_increase_public_balance -12 ✅ -0.46%
Crowdfunding::public_dispatch -29 ✅ -0.46%
EasyPrivateVoting::add_to_tally_public -12 ✅ -0.47%
AvmInitializerTest::constructor -12 ✅ -0.47%
Lending::deposit_public -12 ✅ -0.47%
FeeJuice::check_balance -12 ✅ -0.49%
Lending::repay_public -12 ✅ -0.49%
StaticParent::public_nested_static_call -12 ✅ -0.49%
Auth::get_authorized_delay -12 ✅ -0.50%
AvmTest::add_storage_map -12 ✅ -0.52%
Lending::get_asset -12 ✅ -0.54%
Lending::public_dispatch -154 ✅ -0.54%
NFT::set_minter -12 ✅ -0.54%
Token::set_minter -12 ✅ -0.54%
StatefulTest::increment_public_value -12 ✅ -0.56%
AuthRegistry::is_consumable -12 ✅ -0.56%
TokenBlacklist::balance_of_public -12 ✅ -0.56%
Token::balance_of_public -12 ✅ -0.56%
StatefulTest::increment_public_value_no_init_check -12 ✅ -0.57%
FeeJuice::balance_of_public -12 ✅ -0.58%
NFT::public_dispatch -153 ✅ -0.58%
AuthRegistry::_set_authorized -12 ✅ -0.58%
Auth::get_authorized -12 ✅ -0.58%
FPC::pay_refund -12 ✅ -0.59%
Test::create_l2_to_l1_message_public -12 ✅ -0.59%
NFT::is_minter -12 ✅ -0.59%
Token::is_minter -12 ✅ -0.59%
AuthRegistry::set_authorized -12 ✅ -0.59%
AvmTest::returndata_copy_oracle -12 ✅ -0.60%
Benchmarking::broadcast -12 ✅ -0.60%
PriceFeed::get_price -12 ✅ -0.60%
FPC::prepare_fee -12 ✅ -0.60%
AuthRegistry::is_reject_all -12 ✅ -0.61%
StatefulTest::get_public_value -12 ✅ -0.61%
AvmTest::set_storage_map -12 ✅ -0.61%
PriceFeed::set_price -12 ✅ -0.61%
Auth::get_scheduled_authorized -12 ✅ -0.61%
AvmTest::read_storage_map -12 ✅ -0.62%
NFT::_finish_transfer_to_public -12 ✅ -0.62%
Lending::borrow_public -12 ✅ -0.63%
Lending::withdraw_public -12 ✅ -0.63%
TestLog::emit_unencrypted_events -12 ✅ -0.64%
InclusionProofs::public_dispatch -27 ✅ -0.64%
AuthRegistry::set_reject_all -12 ✅ -0.65%
AvmTest::get_args_hash -12 ✅ -0.66%
AvmTest::poseidon2_hash -12 ✅ -0.69%
Test::emit_unencrypted -12 ✅ -0.70%
NFT::_store_payload_in_transient_storage_unsafe -12 ✅ -0.85%
Token::_store_payload_in_transient_storage_unsafe -12 ✅ -0.85%
Crowdfunding::_publish_donation_receipts -12 ✅ -0.86%
AvmTest::u128_addition_overflow -12 ✅ -0.90%
AvmTest::debug_logging -12 ✅ -0.93%
Auth::public_dispatch -103 ✅ -0.95%
AvmTest::pedersen_commit -12 ✅ -0.97%
Child::set_value_twice_with_nested_last -12 ✅ -0.98%
Child::set_value_twice_with_nested_first -12 ✅ -0.98%
Parent::public_static_call -12 ✅ -1.05%
StaticParent::public_static_call -12 ✅ -1.05%
Token::_reduce_total_supply -12 ✅ -1.07%
TokenBlacklist::_reduce_total_supply -12 ✅ -1.07%
Uniswap::_assert_token_is_same -12 ✅ -1.07%
Child::set_value_with_two_nested_calls -12 ✅ -1.08%
Router::public_dispatch -29 ✅ -1.11%
FeeJuice::set_portal -12 ✅ -1.11%
FeeJuice::public_dispatch -74 ✅ -1.17%
DocsExample::get_shared_immutable_constrained_public_indirect -12 ✅ -1.17%
Router::_check_timestamp -12 ✅ -1.21%
Parent::pub_entry_point_twice -12 ✅ -1.21%
AuthRegistry::public_dispatch -103 ✅ -1.22%
AvmTest::nested_static_call_to_add -12 ✅ -1.23%
AvmTest::nested_call_to_assert_same -12 ✅ -1.23%
AvmTest::nested_call_to_add -12 ✅ -1.23%
Router::_check_block_number -12 ✅ -1.23%
StaticParent::public_get_value_from_child -12 ✅ -1.24%
AvmTest::nested_call_to_add_with_gas -12 ✅ -1.26%
DocsExample::initialize_shared_immutable -12 ✅ -1.27%
DocsExample::initialize_public_immutable -12 ✅ -1.27%
AppSubscription::public_dispatch -64 ✅ -1.27%
Lending::get_assets -12 ✅ -1.31%
AvmTest::external_call_to_divide_by_zero -12 ✅ -1.31%
Child::pub_inc_value_internal -12 ✅ -1.38%
StaticChild::pub_illegal_inc_value -12 ✅ -1.39%
Parent::public_dispatch -119 ✅ -1.40%
Child::pub_inc_value -12 ✅ -1.46%
StaticChild::pub_inc_value -12 ✅ -1.46%
AvmTest::u128_from_integer_overflow -12 ✅ -1.47%
NFT::set_admin -12 ✅ -1.47%
Token::set_admin -12 ✅ -1.47%
EasyPrivateVoting::end_vote -12 ✅ -1.47%
Claim::public_dispatch -64 ✅ -1.49%
DocsExample::get_shared_immutable_constrained_public_multiple -12 ✅ -1.52%
TokenBlacklist::total_supply -12 ✅ -1.61%
Token::total_supply -12 ✅ -1.61%
StaticParent::public_dispatch -119 ✅ -1.62%
AvmTest::set_read_storage_single -12 ✅ -1.64%
Spam::public_dispatch -64 ✅ -1.67%
AvmTest::elliptic_curve_add_and_double -12 ✅ -1.68%
AvmTest::read_storage_list -12 ✅ -1.71%
TokenBridge::_assert_token_is_same -12 ✅ -1.81%
TokenBridge::get_portal_address_public -12 ✅ -1.81%
AvmTest::public_dispatch -1,115 ✅ -1.82%
Token::public_get_decimals -12 ✅ -1.86%
NFT::get_admin -12 ✅ -1.90%
NFT::public_get_name -12 ✅ -1.90%
Token::public_get_symbol -12 ✅ -1.90%
Token::public_get_name -12 ✅ -1.90%
DocsExample::get_shared_immutable_constrained_public -12 ✅ -1.90%
AuthWitTest::consume_public -12 ✅ -1.92%
NFT::public_get_symbol -12 ✅ -1.92%
TokenBridge::get_token -12 ✅ -1.92%
Token::get_admin -12 ✅ -1.92%
TestLog::public_dispatch -64 ✅ -1.95%
AvmInitializerTest::read_storage_immutable -12 ✅ -2.05%
Parent::pub_entry_point -12 ✅ -2.06%
StaticParent::public_call -12 ✅ -2.06%
AvmTest::elliptic_curve_add -12 ✅ -2.07%
Child::public_dispatch -134 ✅ -2.19%
AvmTest::assert_calldata_copy -12 ✅ -2.26%
AvmTest::read_storage_single -12 ✅ -2.26%
AvmTest::create_different_nullifier_in_nested_call -12 ✅ -2.41%
AvmTest::keccak_f1600 -12 ✅ -2.41%
AvmTest::create_same_nullifier_in_nested_call -12 ✅ -2.46%
ImportTest::pub_call_public_fn -12 ✅ -2.48%
AvmTest::nested_static_call_to_set_storage -12 ✅ -2.49%
AvmTest::external_call_to_assertion_failure -12 ✅ -2.56%
AvmTest::variable_base_msm -12 ✅ -2.58%
AvmTest::test_get_contract_instance -12 ✅ -2.62%
AvmTest::test_get_contract_instance_matches -12 ✅ -2.65%
PriceFeed::public_dispatch -111 ✅ -2.74%
AvmTest::to_radix_le -12 ✅ -2.85%
AvmTest::revert_oracle -12 ✅ -2.88%
Child::pub_set_value -12 ✅ -2.94%
StaticChild::pub_set_value -12 ✅ -2.94%
Test::assert_public_global_vars -12 ✅ -3.00%
DocsExample::update_leader -12 ✅ -3.08%
AuthWitTest::public_dispatch -64 ✅ -3.25%
AvmInitializerTest::public_dispatch -116 ✅ -3.37%
AvmTest::set_storage_list -12 ✅ -3.61%
DocsExample::public_dispatch -228 ✅ -3.76%
StaticChild::public_dispatch -119 ✅ -3.78%
AvmTest::set_storage_single -12 ✅ -3.85%
TokenBridge::constructor -130 ✅ -3.87%
ImportTest::public_dispatch -64 ✅ -3.96%
AvmTest::add_u128 -12 ✅ -4.74%
AvmTest::check_selector -12 ✅ -5.29%
AvmTest::assertion_failure -12 ✅ -5.58%
StaticChild::pub_get_value -12 ✅ -5.61%
InclusionProofs::test_nullifier_inclusion_from_public -12 ✅ -5.97%
AvmTest::get_function_selector -12 ✅ -6.25%
InclusionProofs::push_nullifier_public -12 ✅ -6.86%
AvmTest::assert_same -12 ✅ -7.06%
AvmTest::emit_nullifier_and_check -12 ✅ -7.06%
Child::pub_get_value -12 ✅ -7.14%
AvmTest::assert_nullifier_exists -12 ✅ -7.23%
AvmTest::assert_timestamp -12 ✅ -7.27%
Test::dummy_public_call -12 ✅ -7.64%
Test::is_time_equal -12 ✅ -7.64%
AvmTest::set_opcode_really_big_field -12 ✅ -7.79%
AvmTest::set_opcode_big_field -12 ✅ -7.79%
AvmTest::modulo2 -12 ✅ -8.33%
AvmTest::l1_to_l2_msg_exists -12 ✅ -8.51%
AvmTest::note_hash_exists -12 ✅ -8.51%
AvmTest::nullifier_exists -12 ✅ -8.57%
AvmTest::set_opcode_small_field -12 ✅ -8.70%
AvmTest::add_args_return -12 ✅ -8.70%
AvmTest::divide_by_zero -12 ✅ -8.82%
DocsExample::spend_public_authwit -12 ✅ -9.09%
AvmTest::set_opcode_u64 -12 ✅ -9.23%
AvmTest::send_l2_to_l1_msg -12 ✅ -9.30%
Test::create_l2_to_l1_message_arbitrary_recipient_public -12 ✅ -9.30%
AvmTest::set_opcode_u32 -12 ✅ -9.52%
AvmTest::nullifier_collision -12 ✅ -9.60%
AvmTest::get_transaction_fee -12 ✅ -9.84%
AvmTest::get_address -12 ✅ -9.84%
AvmTest::get_version -12 ✅ -9.84%
AvmTest::get_block_number -12 ✅ -9.84%
AvmTest::get_fee_per_l2_gas -12 ✅ -9.84%
AvmTest::get_l2_gas_left -12 ✅ -9.84%
AvmTest::get_sender -12 ✅ -9.84%
AvmTest::get_chain_id -12 ✅ -9.84%
AvmTest::get_fee_per_da_gas -12 ✅ -9.84%
AvmTest::get_timestamp -12 ✅ -9.84%
AvmTest::get_da_gas_left -12 ✅ -9.84%
AvmTest::set_opcode_u8 -12 ✅ -9.84%
AvmTest::new_nullifier -12 ✅ -9.92%
AvmTest::new_note_hash -12 ✅ -9.92%
Test::emit_nullifier_public -12 ✅ -9.92%
AvmTest::return_oracle -64 ✅ -15.31%

Full diff report 👇
Program Bytecode size in bytes (+/-) %
Token::public_dispatch 36,704 (+2,515) +7.36%
AvmTest::bulk_testing 25,497 (+1,712) +7.20%
TokenBridge::public_dispatch 22,625 (+670) +3.05%
Benchmarking::public_dispatch 5,687 (+28) +0.49%
Uniswap::public_dispatch 25,046 (+32) +0.13%
Uniswap::swap_public 15,701 (-12) -0.08%
TokenBridge::claim_public 12,458 (-12) -0.10%
Test::consume_mint_public_message 10,606 (-12) -0.11%
Lending::_withdraw 9,273 (-12) -0.13%
Lending::_borrow 9,009 (-12) -0.13%
TokenBridge::exit_to_l1_public 8,214 (-12) -0.15%
Test::consume_message_from_arbitrary_sender_public 7,955 (-12) -0.15%
TokenBlacklist::constructor 7,916 (-12) -0.15%
CardGame::public_dispatch 16,234 (-25) -0.15%
TokenBlacklist::update_roles 7,677 (-12) -0.16%
Token::_finalize_transfer_to_private_unsafe 7,362 (-12) -0.16%
CardGame::on_cards_claimed 7,338 (-12) -0.16%
Token::finalize_transfer_to_private 7,315 (-12) -0.16%
Token::_finalize_mint_to_private_unsafe 7,152 (-12) -0.17%
Token::finalize_mint_to_private 7,105 (-12) -0.17%
CardGame::start_game 6,982 (-12) -0.17%
NFT::_finalize_transfer_to_private_unsafe 6,482 (-12) -0.18%
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 6,451 (-12) -0.19%
NFT::finalize_transfer_to_private 6,435 (-12) -0.19%
TokenBlacklist::shield 6,416 (-12) -0.19%
TokenBlacklist::transfer_public 6,311 (-12) -0.19%
Lending::_repay 6,179 (-12) -0.19%
Token::complete_refund 6,044 (-12) -0.20%
Auth::set_authorized 6,032 (-12) -0.20%
CardGame::on_card_played 5,947 (-12) -0.20%
Auth::set_authorized_delay 5,946 (-12) -0.20%
TokenBlacklist::burn_public 5,878 (-12) -0.20%
Lending::update_accumulator 5,764 (-12) -0.21%
StatefulTest::public_dispatch 8,122 (-17) -0.21%
Lending::get_position 5,238 (-12) -0.23%
Token::constructor 5,143 (-12) -0.23%
CardGame::on_game_joined 5,046 (-12) -0.24%
Token::transfer_public 4,797 (-12) -0.25%
NFT::constructor 4,787 (-12) -0.25%
Token::burn_public 4,689 (-12) -0.26%
TokenBlacklist::mint_public 4,611 (-12) -0.26%
TokenBlacklist::mint_private 4,294 (-12) -0.28%
AvmTest::sha256_hash 3,878 (-12) -0.31%
StatefulTest::public_constructor 3,860 (-12) -0.31%
FPC::public_dispatch 8,362 (-27) -0.32%
NFT::transfer_in_public 3,714 (-12) -0.32%
Benchmarking::increment_balance 3,713 (-12) -0.32%
Test::public_dispatch 19,751 (-64) -0.32%
AppSubscription::constructor 3,690 (-12) -0.32%
Crowdfunding::init 3,535 (-12) -0.34%
Token::mint_public 3,525 (-12) -0.34%
NFT::mint 3,364 (-12) -0.36%
Parent::public_nested_static_call 3,364 (-12) -0.36%
Claim::constructor 3,269 (-12) -0.37%
EasyPrivateVoting::constructor 3,223 (-12) -0.37%
AuthRegistry::consume 3,222 (-12) -0.37%
Lending::init 3,192 (-12) -0.37%
FPC::constructor 3,152 (-12) -0.38%
Auth::constructor 3,097 (-12) -0.39%
Uniswap::constructor 3,056 (-12) -0.39%
Lending::_deposit 3,041 (-12) -0.39%
AvmTest::emit_unencrypted_log 2,995 (-12) -0.40%
AvmTest::pedersen_hash 2,923 (-12) -0.41%
AvmTest::pedersen_hash_with_index 2,923 (-12) -0.41%
TokenBlacklist::_increase_public_balance 2,855 (-12) -0.42%
Token::_increase_public_balance 2,855 (-12) -0.42%
TokenBlacklist::public_dispatch 25,197 (-107) -0.42%
NFT::owner_of 2,796 (-12) -0.43%
Spam::public_spam 2,796 (-12) -0.43%
TokenBlacklist::get_roles 2,773 (-12) -0.43%
AvmTest::keccak_hash 2,737 (-12) -0.44%
EasyPrivateVoting::public_dispatch 6,085 (-27) -0.44%
InclusionProofs::constructor 2,621 (-12) -0.46%
FeeJuice::_increase_public_balance 2,586 (-12) -0.46%
Crowdfunding::public_dispatch 6,212 (-29) -0.46%
EasyPrivateVoting::add_to_tally_public 2,547 (-12) -0.47%
AvmInitializerTest::constructor 2,545 (-12) -0.47%
Lending::deposit_public 2,543 (-12) -0.47%
FeeJuice::check_balance 2,441 (-12) -0.49%
Lending::repay_public 2,426 (-12) -0.49%
StaticParent::public_nested_static_call 2,413 (-12) -0.49%
Auth::get_authorized_delay 2,398 (-12) -0.50%
AvmTest::add_storage_map 2,316 (-12) -0.52%
Lending::get_asset 2,209 (-12) -0.54%
Lending::public_dispatch 28,339 (-154) -0.54%
NFT::set_minter 2,205 (-12) -0.54%
Token::set_minter 2,200 (-12) -0.54%
StatefulTest::increment_public_value 2,147 (-12) -0.56%
AuthRegistry::is_consumable 2,137 (-12) -0.56%
TokenBlacklist::balance_of_public 2,122 (-12) -0.56%
Token::balance_of_public 2,122 (-12) -0.56%
StatefulTest::increment_public_value_no_init_check 2,098 (-12) -0.57%
FeeJuice::balance_of_public 2,068 (-12) -0.58%
NFT::public_dispatch 26,233 (-153) -0.58%
AuthRegistry::_set_authorized 2,054 (-12) -0.58%
Auth::get_authorized 2,041 (-12) -0.58%
FPC::pay_refund 2,038 (-12) -0.59%
Test::create_l2_to_l1_message_public 2,030 (-12) -0.59%
NFT::is_minter 2,024 (-12) -0.59%
Token::is_minter 2,024 (-12) -0.59%
AuthRegistry::set_authorized 2,007 (-12) -0.59%
AvmTest::returndata_copy_oracle 1,998 (-12) -0.60%
Benchmarking::broadcast 1,994 (-12) -0.60%
PriceFeed::get_price 1,988 (-12) -0.60%
FPC::prepare_fee 1,983 (-12) -0.60%
AuthRegistry::is_reject_all 1,970 (-12) -0.61%
StatefulTest::get_public_value 1,960 (-12) -0.61%
AvmTest::set_storage_map 1,956 (-12) -0.61%
PriceFeed::set_price 1,946 (-12) -0.61%
Auth::get_scheduled_authorized 1,941 (-12) -0.61%
AvmTest::read_storage_map 1,929 (-12) -0.62%
NFT::_finish_transfer_to_public 1,929 (-12) -0.62%
Lending::borrow_public 1,891 (-12) -0.63%
Lending::withdraw_public 1,891 (-12) -0.63%
TestLog::emit_unencrypted_events 1,853 (-12) -0.64%
InclusionProofs::public_dispatch 4,169 (-27) -0.64%
AuthRegistry::set_reject_all 1,845 (-12) -0.65%
AvmTest::get_args_hash 1,804 (-12) -0.66%
AvmTest::poseidon2_hash 1,734 (-12) -0.69%
Test::emit_unencrypted 1,702 (-12) -0.70%
NFT::_store_payload_in_transient_storage_unsafe 1,403 (-12) -0.85%
Token::_store_payload_in_transient_storage_unsafe 1,403 (-12) -0.85%
Crowdfunding::_publish_donation_receipts 1,391 (-12) -0.86%
AvmTest::u128_addition_overflow 1,325 (-12) -0.90%
AvmTest::debug_logging 1,280 (-12) -0.93%
Auth::public_dispatch 10,782 (-103) -0.95%
AvmTest::pedersen_commit 1,223 (-12) -0.97%
Child::set_value_twice_with_nested_last 1,216 (-12) -0.98%
Child::set_value_twice_with_nested_first 1,216 (-12) -0.98%
Parent::public_static_call 1,130 (-12) -1.05%
StaticParent::public_static_call 1,130 (-12) -1.05%
Token::_reduce_total_supply 1,112 (-12) -1.07%
TokenBlacklist::_reduce_total_supply 1,107 (-12) -1.07%
Uniswap::_assert_token_is_same 1,106 (-12) -1.07%
Child::set_value_with_two_nested_calls 1,100 (-12) -1.08%
Router::public_dispatch 2,583 (-29) -1.11%
FeeJuice::set_portal 1,066 (-12) -1.11%
FeeJuice::public_dispatch 6,261 (-74) -1.17%
DocsExample::get_shared_immutable_constrained_public_indirect 1,013 (-12) -1.17%
Router::_check_timestamp 981 (-12) -1.21%
Parent::pub_entry_point_twice 976 (-12) -1.21%
AuthRegistry::public_dispatch 8,363 (-103) -1.22%
AvmTest::nested_static_call_to_add 967 (-12) -1.23%
AvmTest::nested_call_to_assert_same 967 (-12) -1.23%
AvmTest::nested_call_to_add 967 (-12) -1.23%
Router::_check_block_number 964 (-12) -1.23%
StaticParent::public_get_value_from_child 953 (-12) -1.24%
AvmTest::nested_call_to_add_with_gas 942 (-12) -1.26%
DocsExample::initialize_shared_immutable 935 (-12) -1.27%
DocsExample::initialize_public_immutable 935 (-12) -1.27%
AppSubscription::public_dispatch 4,973 (-64) -1.27%
Lending::get_assets 905 (-12) -1.31%
AvmTest::external_call_to_divide_by_zero 904 (-12) -1.31%
Child::pub_inc_value_internal 855 (-12) -1.38%
StaticChild::pub_illegal_inc_value 850 (-12) -1.39%
Parent::public_dispatch 8,381 (-119) -1.40%
Child::pub_inc_value 809 (-12) -1.46%
StaticChild::pub_inc_value 809 (-12) -1.46%
AvmTest::u128_from_integer_overflow 805 (-12) -1.47%
NFT::set_admin 803 (-12) -1.47%
Token::set_admin 803 (-12) -1.47%
EasyPrivateVoting::end_vote 802 (-12) -1.47%
Claim::public_dispatch 4,227 (-64) -1.49%
DocsExample::get_shared_immutable_constrained_public_multiple 775 (-12) -1.52%
TokenBlacklist::total_supply 732 (-12) -1.61%
Token::total_supply 732 (-12) -1.61%
StaticParent::public_dispatch 7,220 (-119) -1.62%
AvmTest::set_read_storage_single 718 (-12) -1.64%
Spam::public_dispatch 3,765 (-64) -1.67%
AvmTest::elliptic_curve_add_and_double 701 (-12) -1.68%
AvmTest::read_storage_list 688 (-12) -1.71%
TokenBridge::_assert_token_is_same 651 (-12) -1.81%
TokenBridge::get_portal_address_public 651 (-12) -1.81%
AvmTest::public_dispatch 60,132 (-1,115) -1.82%
Token::public_get_decimals 634 (-12) -1.86%
NFT::get_admin 619 (-12) -1.90%
NFT::public_get_name 619 (-12) -1.90%
Token::public_get_symbol 619 (-12) -1.90%
Token::public_get_name 619 (-12) -1.90%
DocsExample::get_shared_immutable_constrained_public 618 (-12) -1.90%
AuthWitTest::consume_public 614 (-12) -1.92%
NFT::public_get_symbol 614 (-12) -1.92%
TokenBridge::get_token 614 (-12) -1.92%
Token::get_admin 614 (-12) -1.92%
TestLog::public_dispatch 3,219 (-64) -1.95%
AvmInitializerTest::read_storage_immutable 573 (-12) -2.05%
Parent::pub_entry_point 570 (-12) -2.06%
StaticParent::public_call 570 (-12) -2.06%
AvmTest::elliptic_curve_add 568 (-12) -2.07%
Child::public_dispatch 5,981 (-134) -2.19%
AvmTest::assert_calldata_copy 519 (-12) -2.26%
AvmTest::read_storage_single 519 (-12) -2.26%
AvmTest::create_different_nullifier_in_nested_call 486 (-12) -2.41%
AvmTest::keccak_f1600 486 (-12) -2.41%
AvmTest::create_same_nullifier_in_nested_call 476 (-12) -2.46%
ImportTest::pub_call_public_fn 471 (-12) -2.48%
AvmTest::nested_static_call_to_set_storage 470 (-12) -2.49%
AvmTest::external_call_to_assertion_failure 456 (-12) -2.56%
AvmTest::variable_base_msm 453 (-12) -2.58%
AvmTest::test_get_contract_instance 446 (-12) -2.62%
AvmTest::test_get_contract_instance_matches 441 (-12) -2.65%
PriceFeed::public_dispatch 3,947 (-111) -2.74%
AvmTest::to_radix_le 409 (-12) -2.85%
AvmTest::revert_oracle 404 (-12) -2.88%
Child::pub_set_value 396 (-12) -2.94%
StaticChild::pub_set_value 396 (-12) -2.94%
Test::assert_public_global_vars 388 (-12) -3.00%
DocsExample::update_leader 378 (-12) -3.08%
AuthWitTest::public_dispatch 1,907 (-64) -3.25%
AvmInitializerTest::public_dispatch 3,326 (-116) -3.37%
AvmTest::set_storage_list 320 (-12) -3.61%
DocsExample::public_dispatch 5,838 (-228) -3.76%
StaticChild::public_dispatch 3,033 (-119) -3.78%
AvmTest::set_storage_single 300 (-12) -3.85%
TokenBridge::constructor 3,232 (-130) -3.87%
ImportTest::public_dispatch 1,551 (-64) -3.96%
AvmTest::add_u128 241 (-12) -4.74%
AvmTest::check_selector 215 (-12) -5.29%
AvmTest::assertion_failure 203 (-12) -5.58%
StaticChild::pub_get_value 202 (-12) -5.61%
InclusionProofs::test_nullifier_inclusion_from_public 189 (-12) -5.97%
AvmTest::get_function_selector 180 (-12) -6.25%
InclusionProofs::push_nullifier_public 163 (-12) -6.86%
AvmTest::assert_same 158 (-12) -7.06%
AvmTest::emit_nullifier_and_check 158 (-12) -7.06%
Child::pub_get_value 156 (-12) -7.14%
AvmTest::assert_nullifier_exists 154 (-12) -7.23%
AvmTest::assert_timestamp 153 (-12) -7.27%
Test::dummy_public_call 145 (-12) -7.64%
Test::is_time_equal 145 (-12) -7.64%
AvmTest::set_opcode_really_big_field 142 (-12) -7.79%
AvmTest::set_opcode_big_field 142 (-12) -7.79%
AvmTest::modulo2 132 (-12) -8.33%
AvmTest::l1_to_l2_msg_exists 129 (-12) -8.51%
AvmTest::note_hash_exists 129 (-12) -8.51%
AvmTest::nullifier_exists 128 (-12) -8.57%
AvmTest::set_opcode_small_field 126 (-12) -8.70%
AvmTest::add_args_return 126 (-12) -8.70%
AvmTest::divide_by_zero 124 (-12) -8.82%
DocsExample::spend_public_authwit 120 (-12) -9.09%
AvmTest::set_opcode_u64 118 (-12) -9.23%
AvmTest::send_l2_to_l1_msg 117 (-12) -9.30%
Test::create_l2_to_l1_message_arbitrary_recipient_public 117 (-12) -9.30%
AvmTest::set_opcode_u32 114 (-12) -9.52%
AvmTest::nullifier_collision 113 (-12) -9.60%
AvmTest::get_transaction_fee 110 (-12) -9.84%
AvmTest::get_address 110 (-12) -9.84%
AvmTest::get_version 110 (-12) -9.84%
AvmTest::get_block_number 110 (-12) -9.84%
AvmTest::get_fee_per_l2_gas 110 (-12) -9.84%
AvmTest::get_l2_gas_left 110 (-12) -9.84%
AvmTest::get_sender 110 (-12) -9.84%
AvmTest::get_chain_id 110 (-12) -9.84%
AvmTest::get_fee_per_da_gas 110 (-12) -9.84%
AvmTest::get_timestamp 110 (-12) -9.84%
AvmTest::get_da_gas_left 110 (-12) -9.84%
AvmTest::set_opcode_u8 110 (-12) -9.84%
AvmTest::new_nullifier 109 (-12) -9.92%
AvmTest::new_note_hash 109 (-12) -9.92%
Test::emit_nullifier_public 109 (-12) -9.92%
AvmTest::return_oracle 354 (-64) -15.31%

Copy link
Collaborator

@spalladino spalladino left a comment

Choose a reason for hiding this comment

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

The scripts look good, but I think the gas utils have a few issues mostly around race conditions and maxFee vs maxPrioFee. We could split up this PR to get the scripts in, while we keep iterating on the gas utils.

Aside from the issues, I'm worried the API for using it makes it much more verbose. It'd be good to have an API where we just pass in the result of simulate, and then the util handles the first send, the monitoring, the retries, etc. Something like:

      const { request } = await this.rollupContract.simulate.submitEpochRootProof(txArgs);
      return await waitWithRetries(request, walletClient, gasOpts);

We should also tweak the e2e test (which maybe we can degrade to a "unit" test that calls startAnvil, using a lower block time?) so that it exercises more scenarios: priority fee spiking instead of just base fee spiking, tx getting dropped (anvil_dropTransaction cheat code is your friend), an older replacement tx getting mined, etc.

Comment on lines 56 to 60
if (isAnvilTestChain(chainId)) {
dualLog(`Funding validator on L1`);
const cheatCodes = new EthCheatCodes(rpcUrl, debugLogger);
await cheatCodes.setBalance(validatorAddress, 10n ** 20n);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we check balance if we're not on anvil, and emit a noisy log remembering the user to fund the address manually?

.addOption(pxeOption)
.description('Gets the information of an Aztec node from a PXE or directly from an Aztec node.')
.option('--node-url <string>', 'URL of the node.', `http://${LOCALHOST}:8080`)
.option('--from-node', 'Get the info directly from an Aztec node.', false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not decide based on whether node-url or pxe-url is set, instead of having this flag?

Copy link
Member Author

@spypsy spypsy Nov 14, 2024

Choose a reason for hiding this comment

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

I realize now that's what it actually does in the action below, I forgot to remove this option

@@ -42,4 +42,4 @@ function filter_noise() {
}

# Start the Aztec node with the sequencer and archiver
node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe 2>&1 | filter_noise
Copy link
Collaborator

Choose a reason for hiding this comment

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

We were starting an entire PXE just to answer getNodeInfo? Damn.

export L1_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY
export SEQ_PUBLISHER_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY
export DEBUG=${DEBUG:-"aztec:*,-aztec:avm_simulator*,-aztec:libp2p_service*,-aztec:circuits:artifact_hash,-json-rpc*,-aztec:l2_block_stream,-aztec:world-state:*"}
export ETHEREUM_HOST="http://127.0.0.1:8545"
export ETHEREUM_HOST=${ETHEREUM_HOST:-"http://127.0.0.1:8545"}
export IS_ANVIL=${IS_ANVIL:-"true"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use something along these lines (with a try/catch!) to query whether it is anvil or not, so we don't risk forgetting it:

curl -s -H "Content-Type: application/json" -X POST --data '{"method":"web3_clientVersion","params":[],"id":49,"jsonrpc":"2.0"}' $ETHEREUM_HOST | jq .result | grep -q anvil

P2P_PORT=$((40401 + i))
IDX=$((i + 1))

# Use empty string as default if variables are not set
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be safer to fail loudly if the private key is not set?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't actually want to fail if it's not set, these would only be set when running against public networks like Sepolia where we need to use funded accounts.
In local testing the keys & addresses are later generated in validator.sh and funded when doing add-l1-validator

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense! Could you add a comment with that, so next reader doesn't fall into the same?

Comment on lines 183 to 184
// Transaction not found and enough time has passed - might be stuck
if (Date.now() - lastSeen > config.stallTimeMs && attempts < config.maxAttempts) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC this bumps gas price if nodes drop the tx altogether, but not if it just sits in the mempool without being mined. We should add another condition for that.

Comment on lines 120 to 129
return retry(
async () => {
const gas = await estimator();
return gas + (gas * this.gasConfig.bufferPercentage) / 100n;
},
'gas estimation',
makeBackoff([1, 2, 3]),
this.logger,
false,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the retry here as opposed to on other rpc calls? If we are seeing flaky rpc endpoints where we need to retry, we should tackle that at a lower level (on viem's "transport" most likely).

this.logger?.info(`Transaction ${currentTxHash} pending`);
if (tx) {
lastSeen = Date.now();
await new Promise(resolve => setTimeout(resolve, config.checkIntervalMs));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
await new Promise(resolve => setTimeout(resolve, config.checkIntervalMs));
await sleep(config.checkIntervalMs);

Comment on lines 175 to 176
const tx = await this.publicClient.getTransaction({ hash: currentTxHash });
this.logger?.info(`Transaction ${currentTxHash} pending`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can do the same trick as with the receipt here. Instead of doing getTx on every hash you've sent, you can query getTxCount using the pending tag, which should consider the txs that are sitting on the mempool for the given sender.

data: originalTx.data,
nonce: originalTx.nonce,
gas: originalTx.gasLimit,
maxFeePerGas: newGasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if bumping only maxFeePerGas without touching maxPriorityFeePerGas has the intended effect. If maxPriorityFeePerGas is not set, then viem defaults it to either a chain default or to whatever the json rpc interface returns (see here). So we're not actually bumping the priority fee, we're just setting it to whatever nodes say is the latest value to use, and ignoring the gasPriceIncrease.

Maybe we should be setting maxPriorityFeePerGas as well? I'm thinking we could just always set maxFeePerGas to gasConfig.maxGwei, and then just handle stuck txs by bumping the maxPriorityFeePerGas, since the user never gets charged more than baseFee + priorityFee. We could get the max prio fee from either eth_maxPriorityFeePerGas RPC as viem does, or from a gas price oracle like BlockNative. Then, for every successive retry, we bump the maxPrioFee to the new eth_maxPriorityFeePerGas we see, or to a multiplier of the previous prio fee, whatever's greater.

@spalladino
Copy link
Collaborator

I guess you're not going to choose me as reviewer in the future, sorry for so throwing in many comments.

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.

Handle L1 tx retries and volatile gas prices
2 participants