From aad0381e10e3c4a6507d9aa2e57588e6dc6fc995 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Fri, 25 Oct 2024 05:23:40 -0500 Subject: [PATCH] remove test-only bool arg from calculate_fee (#3211) --- cli/tests/address_lookup_table.rs | 14 +- cli/tests/nonce.rs | 49 +++++- cli/tests/program.rs | 84 ++++++--- cli/tests/request_airdrop.rs | 7 +- cli/tests/stake.rs | 55 ++++-- cli/tests/validator_info.rs | 7 +- cli/tests/vote.rs | 41 +++-- client-test/tests/client.rs | 2 +- ...nd_and_confirm_transactions_in_parallel.rs | 4 +- core/src/banking_stage/consumer.rs | 1 - fee/src/lib.rs | 8 +- programs/sbf/tests/programs.rs | 4 +- rpc-test/tests/rpc.rs | 14 +- runtime/src/bank.rs | 55 ++++-- runtime/src/bank/fee_distribution.rs | 1 - runtime/src/bank/tests.rs | 165 ++---------------- sdk/src/fee.rs | 11 ++ svm/src/transaction_processor.rs | 3 +- test-validator/src/lib.rs | 2 +- tokens/src/commands.rs | 2 +- tokens/tests/commands.rs | 2 +- 21 files changed, 267 insertions(+), 264 deletions(-) diff --git a/cli/tests/address_lookup_table.rs b/cli/tests/address_lookup_table.rs index 9bf7db320cb010..58946fd6fc4a95 100644 --- a/cli/tests/address_lookup_table.rs +++ b/cli/tests/address_lookup_table.rs @@ -23,8 +23,11 @@ fn test_cli_create_extend_and_freeze_address_lookup_table() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let mut config = CliConfig::recent_for_tests(); let keypair = Keypair::new(); @@ -138,8 +141,11 @@ fn test_cli_create_and_deactivate_address_lookup_table() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let mut config = CliConfig::recent_for_tests(); let keypair = Keypair::new(); diff --git a/cli/tests/nonce.rs b/cli/tests/nonce.rs index a9edd06656efd6..6381a6c9faa629 100644 --- a/cli/tests/nonce.rs +++ b/cli/tests/nonce.rs @@ -31,8 +31,11 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -43,15 +46,16 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric let payer = Keypair::new(); config_payer.signers = vec![&payer]; + let airdrop_amount = sol_to_lamports(2000.0); request_and_confirm_airdrop( &rpc_client, &config_payer, &config_payer.signers[0].pubkey(), - sol_to_lamports(2000.0), + airdrop_amount, ) .unwrap(); check_balance!( - sol_to_lamports(2000.0), + airdrop_amount, &rpc_client, &config_payer.signers[0].pubkey(), ); @@ -80,23 +84,26 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric }; // Create nonce account + let spend_amount = sol_to_lamports(1000.0); config_payer.signers.push(&nonce_keypair); config_payer.command = CliCommand::CreateNonceAccount { nonce_account: 1, seed, nonce_authority: optional_authority, memo: None, - amount: SpendAmount::Some(sol_to_lamports(1000.0)), + amount: SpendAmount::Some(spend_amount), compute_unit_price, }; process_command(&config_payer).unwrap(); + let priority_fee = compute_unit_price.map(|_| 600).unwrap_or(0); + let expected_payer_balance = airdrop_amount - spend_amount - priority_fee; check_balance!( - sol_to_lamports(1000.0), + expected_payer_balance, &rpc_client, &config_payer.signers[0].pubkey(), ); - check_balance!(sol_to_lamports(1000.0), &rpc_client, &nonce_account); + check_balance!(spend_amount, &rpc_client, &nonce_account); // Get nonce config_payer.signers.pop(); @@ -129,6 +136,14 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric }; process_command(&config_payer).unwrap(); + let priority_fee = compute_unit_price.map(|_| 450).unwrap_or(0); + let expected_payer_balance = expected_payer_balance - priority_fee; + check_balance!( + expected_payer_balance, + &rpc_client, + &config_payer.signers[0].pubkey(), + ); + // Get nonce config_payer.signers = vec![&payer]; config_payer.command = CliCommand::GetNonce(nonce_account); @@ -149,8 +164,9 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric compute_unit_price, }; process_command(&config_payer).unwrap(); + let expected_payer_balance = expected_payer_balance - priority_fee; check_balance!( - sol_to_lamports(1000.0), + expected_payer_balance, &rpc_client, &config_payer.signers[0].pubkey(), ); @@ -175,6 +191,13 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric }; process_command(&config_payer).unwrap(); + let expected_payer_balance = expected_payer_balance - priority_fee; + check_balance!( + expected_payer_balance, + &rpc_client, + &config_payer.signers[0].pubkey(), + ); + // Old authority fails now config_payer.command = CliCommand::NewNonce { nonce_account, @@ -194,6 +217,13 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric }; process_command(&config_payer).unwrap(); + let expected_payer_balance = expected_payer_balance - priority_fee; + check_balance!( + expected_payer_balance, + &rpc_client, + &config_payer.signers[0].pubkey(), + ); + // New authority can withdraw from nonce account config_payer.command = CliCommand::WithdrawFromNonceAccount { nonce_account, @@ -204,8 +234,9 @@ fn test_nonce(seed: Option, use_nonce_authority: bool, compute_unit_pric compute_unit_price, }; process_command(&config_payer).unwrap(); + let expected_payer_balance = expected_payer_balance - priority_fee; check_balance!( - sol_to_lamports(1000.0), + expected_payer_balance, &rpc_client, &config_payer.signers[0].pubkey(), ); diff --git a/cli/tests/program.rs b/cli/tests/program.rs index f1c441a8654ea4..4be0354b7430e6 100644 --- a/cli/tests/program.rs +++ b/cli/tests/program.rs @@ -81,8 +81,11 @@ fn test_cli_program_deploy_non_upgradeable() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -286,8 +289,11 @@ fn test_cli_program_deploy_no_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -678,8 +684,11 @@ fn test_cli_program_deploy_with_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1079,8 +1088,11 @@ fn test_cli_program_upgrade_auto_extend() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1232,8 +1244,11 @@ fn test_cli_program_close_program() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1351,8 +1366,11 @@ fn test_cli_program_extend_program() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1521,8 +1539,11 @@ fn test_cli_program_write_buffer() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2008,8 +2029,11 @@ fn test_cli_program_set_buffer_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2180,8 +2204,11 @@ fn test_cli_program_mismatch_buffer_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2306,8 +2333,11 @@ fn test_cli_program_deploy_with_offline_signing(use_offline_signer_as_fee_payer: let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2499,8 +2529,11 @@ fn test_cli_program_show() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2696,8 +2729,11 @@ fn test_cli_program_dump() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); diff --git a/cli/tests/request_airdrop.rs b/cli/tests/request_airdrop.rs index 1004507aa03f88..c6bf323cd7d636 100644 --- a/cli/tests/request_airdrop.rs +++ b/cli/tests/request_airdrop.rs @@ -17,8 +17,11 @@ fn test_cli_request_airdrop() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let mut bob_config = CliConfig::recent_for_tests(); bob_config.json_rpc_url = test_validator.rpc_url(); diff --git a/cli/tests/stake.rs b/cli/tests/stake.rs index f679de5aacfec4..f85801670babc8 100644 --- a/cli/tests/stake.rs +++ b/cli/tests/stake.rs @@ -205,8 +205,11 @@ fn test_seed_stake_delegation_and_deactivation(compute_unit_price: Option) let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -301,8 +304,11 @@ fn test_stake_delegation_and_deactivation(compute_unit_price: Option) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -393,8 +399,11 @@ fn test_offline_stake_delegation_and_deactivation(compute_unit_price: Option let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -682,8 +694,11 @@ fn test_stake_authorize(compute_unit_price: Option) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1641,8 +1656,11 @@ fn test_offline_nonced_create_stake_account_and_withdraw(compute_unit_price: Opt let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1673,10 +1691,10 @@ fn test_offline_nonced_create_stake_account_and_withdraw(compute_unit_price: Opt &rpc_client, &config_offline, &offline_pubkey, - 100_000_000_000, + 200_000_000_000, ) .unwrap(); - check_balance!(100_000_000_000, &rpc_client, &offline_pubkey); + check_balance!(200_000_000_000, &rpc_client, &offline_pubkey); // Create nonce account let minimum_nonce_balance = rpc_client @@ -1884,8 +1902,11 @@ fn test_stake_checked_instructions() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2119,7 +2140,7 @@ fn test_stake_checked_instructions() { #[test] fn test_stake_minimum_delegation() { let test_validator = - TestValidator::with_no_fees(Pubkey::new_unique(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(Pubkey::new_unique(), None, SocketAddrSpace::Unspecified); let mut config = CliConfig::recent_for_tests(); config.json_rpc_url = test_validator.rpc_url(); diff --git a/cli/tests/validator_info.rs b/cli/tests/validator_info.rs index 293fa2dc4a71bb..3aec972e2bef44 100644 --- a/cli/tests/validator_info.rs +++ b/cli/tests/validator_info.rs @@ -23,8 +23,11 @@ fn test_publish(compute_unit_price: Option) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index 2a3f1104526186..8b193866dbcb6d 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -26,8 +26,11 @@ fn test_vote_authorize_and_withdraw(compute_unit_price: Option) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -37,8 +40,14 @@ fn test_vote_authorize_and_withdraw(compute_unit_price: Option) { config.json_rpc_url = test_validator.rpc_url(); config.signers = vec![&default_signer]; - request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 100_000) - .unwrap(); + let priority_fee = 200_000 * compute_unit_price.unwrap_or(0); + request_and_confirm_airdrop( + &rpc_client, + &config, + &config.signers[0].pubkey(), + 100_000 + priority_fee, + ) + .unwrap(); // Create vote account let vote_account_keypair = Keypair::new(); @@ -231,8 +240,11 @@ fn test_offline_vote_authorize_and_withdraw(compute_unit_price: Option) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidator::with_no_base_fees( + mint_pubkey, + Some(faucet_addr), + SocketAddrSpace::Unspecified, + ); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -250,23 +262,32 @@ fn test_offline_vote_authorize_and_withdraw(compute_unit_price: Option) { // Verify that we cannot reach the cluster process_command(&config_offline).unwrap_err(); + let airdrop_amount = 100_000_000; request_and_confirm_airdrop( &rpc_client, &config_payer, &config_payer.signers[0].pubkey(), - 100_000, + airdrop_amount, ) .unwrap(); - check_balance!(100_000, &rpc_client, &config_payer.signers[0].pubkey()); + check_balance!( + airdrop_amount, + &rpc_client, + &config_payer.signers[0].pubkey() + ); request_and_confirm_airdrop( &rpc_client, &config_offline, &config_offline.signers[0].pubkey(), - 100_000, + airdrop_amount, ) .unwrap(); - check_balance!(100_000, &rpc_client, &config_offline.signers[0].pubkey()); + check_balance!( + airdrop_amount, + &rpc_client, + &config_offline.signers[0].pubkey() + ); // Create vote account with specific withdrawer let vote_account_keypair = Keypair::new(); diff --git a/client-test/tests/client.rs b/client-test/tests/client.rs index 96c0a8cd82c883..48c49b32aa2065 100644 --- a/client-test/tests/client.rs +++ b/client-test/tests/client.rs @@ -64,7 +64,7 @@ fn test_rpc_client() { let alice = Keypair::new(); let test_validator = - TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let bob_pubkey = solana_sdk::pubkey::new_rand(); diff --git a/client-test/tests/send_and_confirm_transactions_in_parallel.rs b/client-test/tests/send_and_confirm_transactions_in_parallel.rs index 44f8738983bdcb..0373d38eb51999 100644 --- a/client-test/tests/send_and_confirm_transactions_in_parallel.rs +++ b/client-test/tests/send_and_confirm_transactions_in_parallel.rs @@ -36,7 +36,7 @@ fn test_send_and_confirm_transactions_in_parallel_without_tpu_client() { let alice = Keypair::new(); let test_validator = - TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let bob_pubkey = solana_sdk::pubkey::new_rand(); let alice_pubkey = alice.pubkey(); @@ -86,7 +86,7 @@ fn test_send_and_confirm_transactions_in_parallel_with_tpu_client() { let alice = Keypair::new(); let test_validator = - TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let bob_pubkey = solana_sdk::pubkey::new_rand(); let alice_pubkey = alice.pubkey(); diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index f2ae4dc905841c..064fc5cfc6553e 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -761,7 +761,6 @@ impl Consumer { )?); let fee = solana_fee::calculate_fee( message, - bank.get_lamports_per_signature() == 0, bank.fee_structure().lamports_per_signature, fee_budget_limits.prioritization_fee, bank.feature_set diff --git a/fee/src/lib.rs b/fee/src/lib.rs index 869d4dc7f4711c..e1408ff8f41922 100644 --- a/fee/src/lib.rs +++ b/fee/src/lib.rs @@ -1,16 +1,14 @@ use {solana_sdk::fee::FeeDetails, solana_svm_transaction::svm_message::SVMMessage}; -/// Calculate fee for `SanitizedMessage` +/// Calculate fee for `SVMMessage` pub fn calculate_fee( message: &impl SVMMessage, - zero_fees_for_test: bool, lamports_per_signature: u64, prioritization_fee: u64, remove_rounding_in_fee_calculation: bool, ) -> u64 { calculate_fee_details( message, - zero_fees_for_test, lamports_per_signature, prioritization_fee, remove_rounding_in_fee_calculation, @@ -20,14 +18,10 @@ pub fn calculate_fee( pub fn calculate_fee_details( message: &impl SVMMessage, - zero_fees_for_test: bool, lamports_per_signature: u64, prioritization_fee: u64, remove_rounding_in_fee_calculation: bool, ) -> FeeDetails { - if zero_fees_for_test { - return FeeDetails::default(); - } let signature_fee = message .num_total_signatures() .saturating_mul(lamports_per_signature); diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index e176d7cac37fcc..e3bc82bdb01efc 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -3854,7 +3854,7 @@ fn test_program_fees() { let mut bank = Bank::new_for_tests(&genesis_config); let fee_structure = FeeStructure::new(0.000005, 0.0, vec![(200, 0.0000005), (1400000, 0.000005)]); - bank.set_fee_structure(&fee_structure); + bank.set_fee_structure(fee_structure.clone()); let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests(); let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); @@ -3886,7 +3886,6 @@ fn test_program_fees() { ); let expected_normal_fee = solana_fee::calculate_fee( &sanitized_message, - congestion_multiplier == 0, fee_structure.lamports_per_signature, fee_budget_limits.prioritization_fee, true, @@ -3918,7 +3917,6 @@ fn test_program_fees() { ); let expected_prioritized_fee = solana_fee::calculate_fee( &sanitized_message, - congestion_multiplier == 0, fee_structure.lamports_per_signature, fee_budget_limits.prioritization_fee, true, diff --git a/rpc-test/tests/rpc.rs b/rpc-test/tests/rpc.rs index 67d229d43a1823..f373c125812a59 100644 --- a/rpc-test/tests/rpc.rs +++ b/rpc-test/tests/rpc.rs @@ -69,7 +69,7 @@ fn test_rpc_send_tx() { let alice = Keypair::new(); let test_validator = - TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let rpc_url = test_validator.rpc_url(); let bob_pubkey = solana_sdk::pubkey::new_rand(); @@ -141,7 +141,8 @@ fn test_simulation_replaced_blockhash() -> ClientResult<()> { solana_logger::setup(); let alice = Keypair::new(); - let validator = TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + let validator = + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let rpc_client = RpcClient::new(validator.rpc_url()); let bob = Keypair::new(); @@ -187,7 +188,7 @@ fn test_rpc_invalid_requests() { let alice = Keypair::new(); let test_validator = - TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let rpc_url = test_validator.rpc_url(); let bob_pubkey = solana_sdk::pubkey::new_rand(); @@ -219,7 +220,7 @@ fn test_rpc_slot_updates() { solana_logger::setup(); let test_validator = - TestValidator::with_no_fees(Pubkey::new_unique(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(Pubkey::new_unique(), None, SocketAddrSpace::Unspecified); // Track when slot updates are ready let (update_sender, update_receiver) = unbounded::(); @@ -497,7 +498,7 @@ fn run_tpu_send_transaction(tpu_use_quic: bool) { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let test_validator = - TestValidator::with_no_fees(mint_pubkey, None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(mint_pubkey, None, SocketAddrSpace::Unspecified); let rpc_client = Arc::new(RpcClient::new_with_commitment( test_validator.rpc_url(), CommitmentConfig::processed(), @@ -559,7 +560,8 @@ fn deserialize_rpc_error() -> ClientResult<()> { solana_logger::setup(); let alice = Keypair::new(); - let validator = TestValidator::with_no_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); + let validator = + TestValidator::with_no_base_fees(alice.pubkey(), None, SocketAddrSpace::Unspecified); let rpc_client = RpcClient::new(validator.rpc_url()); let bob = Keypair::new(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e5357ec62a2fcc..de8923f378b10a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1109,6 +1109,21 @@ impl Bank { #[cfg(feature = "dev-context-only-utils")] bank.process_genesis_config(genesis_config, collector_id_for_tests, genesis_hash); + // Many tests (including local-cluster tests) rely on the fact + // that transaction fees are zero. + // This was previously handled by the `FeeRateGovernor` + // in the `genesis_config`, but that is no longer the case. + // However, for testing, we can set the fee structure to + // result in zero base fees for all transactions IF the + // lamports_per_signature is zero on the `FeeRateGovernor`. + if genesis_config + .fee_rate_governor + .target_lamports_per_signature + == 0 + { + bank.fee_structure = FeeStructure::zero_fees(); + } + bank.finish_init( genesis_config, additional_builtins, @@ -1701,6 +1716,21 @@ impl Bank { block_id: RwLock::new(None), }; + // Many tests (including local-cluster tests) rely on the fact + // that transaction fees are zero. + // This was previously handled by the `FeeRateGovernor` + // in the `genesis_config`, but that is no longer the case. + // However, for testing, we can set the fee structure to + // result in zero base fees for all transactions IF the + // lamports_per_signature is zero on the `FeeRateGovernor`. + if genesis_config + .fee_rate_governor + .target_lamports_per_signature + == 0 + { + bank.fee_structure = FeeStructure::zero_fees(); + } + bank.transaction_processor = TransactionBatchProcessor::new_uninitialized(bank.slot, bank.epoch); @@ -3154,17 +3184,14 @@ impl Bank { self.rent_collector.rent.minimum_balance(data_len).max(1) } - pub fn get_lamports_per_signature(&self) -> u64 { - self.fee_rate_governor.lamports_per_signature - } - - pub fn get_lamports_per_signature_for_blockhash(&self, hash: &Hash) -> Option { - let blockhash_queue = self.blockhash_queue.read().unwrap(); - blockhash_queue.get_lamports_per_signature(hash) - } - pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> Option { - let lamports_per_signature = { + // It used to be required to get the lamports_per_signature from the + // blockhash_queue, which had the added benefit of ensuring that the + // transaction or nonce is not expired. + // This is no longer strictly required, but RPC users may have relied + // on this behavior. So even though the value is not used, we still + // fetch it to keep behavior consistent. + let _lamports_per_signature = { let blockhash_queue = self.blockhash_queue.read().unwrap(); blockhash_queue.get_lamports_per_signature(message.recent_blockhash()) } @@ -3175,7 +3202,7 @@ impl Bank { }, ) })?; - Some(self.get_fee_for_message_with_lamports_per_signature(message, lamports_per_signature)) + Some(self.get_fee_for_message_with_lamports_per_signature(message)) } /// Returns true when startup accounts hash verification has completed or never had to run in background. @@ -3204,7 +3231,6 @@ impl Bank { pub fn get_fee_for_message_with_lamports_per_signature( &self, message: &impl SVMMessage, - lamports_per_signature: u64, ) -> u64 { let fee_budget_limits = FeeBudgetLimits::from( process_compute_budget_instructions(message.program_instructions_iter()) @@ -3212,7 +3238,6 @@ impl Bank { ); solana_fee::calculate_fee( message, - lamports_per_signature == 0, self.fee_structure().lamports_per_signature, fee_budget_limits.prioritization_fee, self.feature_set @@ -7166,8 +7191,8 @@ impl Bank { &self.transaction_processor } - pub fn set_fee_structure(&mut self, fee_structure: &FeeStructure) { - self.fee_structure = fee_structure.clone(); + pub fn set_fee_structure(&mut self, fee_structure: FeeStructure) { + self.fee_structure = fee_structure; } pub fn load_program( diff --git a/runtime/src/bank/fee_distribution.rs b/runtime/src/bank/fee_distribution.rs index e0be18d5e609fc..90368d7827ee81 100644 --- a/runtime/src/bank/fee_distribution.rs +++ b/runtime/src/bank/fee_distribution.rs @@ -78,7 +78,6 @@ impl Bank { ) -> u64 { let fee_details = solana_fee::calculate_fee_details( transaction, - self.get_lamports_per_signature() == 0, self.fee_structure().lamports_per_signature, fee_budget_limits.prioritization_fee, self.feature_set diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 161a0ffc53aac9..f267eb13ea1df5 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -2693,10 +2693,6 @@ fn test_bank_tx_compute_unit_fee() { let expected_fee_paid = calculate_test_fee( &new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))), - genesis_config - .fee_rate_governor - .create_fee_calculator() - .lamports_per_signature, bank.fee_structure(), ); @@ -2784,130 +2780,6 @@ fn test_bank_tx_compute_unit_fee() { ); } -#[test] -fn test_bank_blockhash_fee_structure() { - //solana_logger::setup(); - - let leader = solana_sdk::pubkey::new_rand(); - let GenesisConfigInfo { - mut genesis_config, - mint_keypair, - .. - } = create_genesis_config_with_leader(1_000_000, &leader, 3); - genesis_config - .fee_rate_governor - .target_lamports_per_signature = 5000; - genesis_config.fee_rate_governor.target_signatures_per_slot = 0; - - let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); - goto_end_of_slot(bank.clone()); - let cheap_blockhash = bank.last_blockhash(); - let cheap_lamports_per_signature = bank.get_lamports_per_signature(); - assert_eq!(cheap_lamports_per_signature, 0); - - let bank = new_bank_from_parent_with_bank_forks(bank_forks.as_ref(), bank, &leader, 1); - goto_end_of_slot(bank.clone()); - let expensive_blockhash = bank.last_blockhash(); - let expensive_lamports_per_signature = bank.get_lamports_per_signature(); - assert!(cheap_lamports_per_signature < expensive_lamports_per_signature); - - let bank = new_bank_from_parent_with_bank_forks(bank_forks.as_ref(), bank, &leader, 2); - - // Send a transfer using cheap_blockhash - let key = solana_sdk::pubkey::new_rand(); - let initial_mint_balance = bank.get_balance(&mint_keypair.pubkey()); - let tx = system_transaction::transfer(&mint_keypair, &key, 1, cheap_blockhash); - assert_eq!(bank.process_transaction(&tx), Ok(())); - assert_eq!(bank.get_balance(&key), 1); - let cheap_fee = calculate_test_fee( - &new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))), - cheap_lamports_per_signature, - bank.fee_structure(), - ); - assert_eq!( - bank.get_balance(&mint_keypair.pubkey()), - initial_mint_balance - 1 - cheap_fee - ); - - // Send a transfer using expensive_blockhash - let key = solana_sdk::pubkey::new_rand(); - let initial_mint_balance = bank.get_balance(&mint_keypair.pubkey()); - let tx = system_transaction::transfer(&mint_keypair, &key, 1, expensive_blockhash); - assert_eq!(bank.process_transaction(&tx), Ok(())); - assert_eq!(bank.get_balance(&key), 1); - let expensive_fee = calculate_test_fee( - &new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))), - expensive_lamports_per_signature, - bank.fee_structure(), - ); - assert_eq!( - bank.get_balance(&mint_keypair.pubkey()), - initial_mint_balance - 1 - expensive_fee - ); -} - -#[test] -fn test_bank_blockhash_compute_unit_fee_structure() { - //solana_logger::setup(); - - let leader = solana_sdk::pubkey::new_rand(); - let GenesisConfigInfo { - mut genesis_config, - mint_keypair, - .. - } = create_genesis_config_with_leader(1_000_000_000, &leader, 3); - genesis_config - .fee_rate_governor - .target_lamports_per_signature = 1000; - genesis_config.fee_rate_governor.target_signatures_per_slot = 1; - - let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); - goto_end_of_slot(bank.clone()); - let cheap_blockhash = bank.last_blockhash(); - let cheap_lamports_per_signature = bank.get_lamports_per_signature(); - assert_eq!(cheap_lamports_per_signature, 0); - - let bank = new_bank_from_parent_with_bank_forks(bank_forks.as_ref(), bank, &leader, 1); - goto_end_of_slot(bank.clone()); - let expensive_blockhash = bank.last_blockhash(); - let expensive_lamports_per_signature = bank.get_lamports_per_signature(); - assert!(cheap_lamports_per_signature < expensive_lamports_per_signature); - - let bank = new_bank_from_parent_with_bank_forks(bank_forks.as_ref(), bank, &leader, 2); - - // Send a transfer using cheap_blockhash - let key = solana_sdk::pubkey::new_rand(); - let initial_mint_balance = bank.get_balance(&mint_keypair.pubkey()); - let tx = system_transaction::transfer(&mint_keypair, &key, 1, cheap_blockhash); - assert_eq!(bank.process_transaction(&tx), Ok(())); - assert_eq!(bank.get_balance(&key), 1); - let cheap_fee = calculate_test_fee( - &new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))), - cheap_lamports_per_signature, - bank.fee_structure(), - ); - assert_eq!( - bank.get_balance(&mint_keypair.pubkey()), - initial_mint_balance - 1 - cheap_fee - ); - - // Send a transfer using expensive_blockhash - let key = solana_sdk::pubkey::new_rand(); - let initial_mint_balance = bank.get_balance(&mint_keypair.pubkey()); - let tx = system_transaction::transfer(&mint_keypair, &key, 1, expensive_blockhash); - assert_eq!(bank.process_transaction(&tx), Ok(())); - assert_eq!(bank.get_balance(&key), 1); - let expensive_fee = calculate_test_fee( - &new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))), - expensive_lamports_per_signature, - bank.fee_structure(), - ); - assert_eq!( - bank.get_balance(&mint_keypair.pubkey()), - initial_mint_balance - 1 - expensive_fee - ); -} - #[test] fn test_filter_program_errors_and_collect_fee() { let leader = solana_sdk::pubkey::new_rand(); @@ -10192,18 +10064,13 @@ fn test_call_precomiled_program() { bank.process_transaction(&tx).unwrap(); } -fn calculate_test_fee( - message: &impl SVMMessage, - lamports_per_signature: u64, - fee_structure: &FeeStructure, -) -> u64 { +fn calculate_test_fee(message: &impl SVMMessage, fee_structure: &FeeStructure) -> u64 { let fee_budget_limits = FeeBudgetLimits::from( process_compute_budget_instructions(message.program_instructions_iter()) .unwrap_or_default(), ); solana_fee::calculate_fee( message, - lamports_per_signature == 0, fee_structure.lamports_per_signature, fee_budget_limits.prioritization_fee, true, @@ -10217,7 +10084,6 @@ fn test_calculate_fee() { assert_eq!( calculate_test_fee( &message, - 0, &FeeStructure { lamports_per_signature: 0, ..FeeStructure::default() @@ -10230,7 +10096,6 @@ fn test_calculate_fee() { assert_eq!( calculate_test_fee( &message, - 1, &FeeStructure { lamports_per_signature: 1, ..FeeStructure::default() @@ -10248,7 +10113,6 @@ fn test_calculate_fee() { assert_eq!( calculate_test_fee( &message, - 2, &FeeStructure { lamports_per_signature: 2, ..FeeStructure::default() @@ -10271,7 +10135,7 @@ fn test_calculate_fee_compute_units() { let message = new_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))); assert_eq!( - calculate_test_fee(&message, 1, &fee_structure,), + calculate_test_fee(&message, &fee_structure,), max_fee + lamports_per_signature ); @@ -10281,7 +10145,7 @@ fn test_calculate_fee_compute_units() { let ix1 = system_instruction::transfer(&Pubkey::new_unique(), &Pubkey::new_unique(), 1); let message = new_sanitized_message(Message::new(&[ix0, ix1], Some(&Pubkey::new_unique()))); assert_eq!( - calculate_test_fee(&message, 1, &fee_structure,), + calculate_test_fee(&message, &fee_structure,), max_fee + 3 * lamports_per_signature ); @@ -10313,7 +10177,7 @@ fn test_calculate_fee_compute_units() { ], Some(&Pubkey::new_unique()), )); - let fee = calculate_test_fee(&message, 1, &fee_structure); + let fee = calculate_test_fee(&message, &fee_structure); assert_eq!( fee, lamports_per_signature + prioritization_fee_details.get_fee() @@ -10344,11 +10208,7 @@ fn test_calculate_prioritization_fee() { Some(&Pubkey::new_unique()), )); - let fee = calculate_test_fee( - &message, - fee_structure.lamports_per_signature, - &fee_structure, - ); + let fee = calculate_test_fee(&message, &fee_structure); assert_eq!( fee, fee_structure.lamports_per_signature + prioritization_fee @@ -10384,7 +10244,7 @@ fn test_calculate_fee_secp256k1() { ], Some(&key0), )); - assert_eq!(calculate_test_fee(&message, 1, &fee_structure,), 2); + assert_eq!(calculate_test_fee(&message, &fee_structure,), 2); secp_instruction1.data = vec![0]; secp_instruction2.data = vec![10]; @@ -10392,7 +10252,7 @@ fn test_calculate_fee_secp256k1() { &[ix0, secp_instruction1, secp_instruction2], Some(&key0), )); - assert_eq!(calculate_test_fee(&message, 1, &fee_structure,), 11); + assert_eq!(calculate_test_fee(&message, &fee_structure,), 11); } #[test] @@ -11931,10 +11791,6 @@ fn test_feature_hashes_per_tick() { #[test] fn test_calculate_fee_with_congestion_multiplier() { - let lamports_scale: u64 = 5; - let base_lamports_per_signature: u64 = 5_000; - let cheap_lamports_per_signature: u64 = base_lamports_per_signature / lamports_scale; - let expensive_lamports_per_signature: u64 = base_lamports_per_signature * lamports_scale; let signature_count: u64 = 2; let signature_fee: u64 = 10; let fee_structure = FeeStructure { @@ -11952,14 +11808,14 @@ fn test_calculate_fee_with_congestion_multiplier() { // assert when lamports_per_signature is less than BASE_LAMPORTS, turnning on/off // congestion_multiplier has no effect on fee. assert_eq!( - calculate_test_fee(&message, cheap_lamports_per_signature, &fee_structure), + calculate_test_fee(&message, &fee_structure), signature_fee * signature_count ); // assert when lamports_per_signature is more than BASE_LAMPORTS, turnning on/off // congestion_multiplier will change calculated fee. assert_eq!( - calculate_test_fee(&message, expensive_lamports_per_signature, &fee_structure,), + calculate_test_fee(&message, &fee_structure,), signature_fee * signature_count ); } @@ -11968,7 +11824,6 @@ fn test_calculate_fee_with_congestion_multiplier() { fn test_calculate_fee_with_request_heap_frame_flag() { let key0 = Pubkey::new_unique(); let key1 = Pubkey::new_unique(); - let lamports_per_signature: u64 = 5_000; let signature_fee: u64 = 10; let request_cu: u64 = 1; let lamports_per_cu: u64 = 5; @@ -11989,7 +11844,7 @@ fn test_calculate_fee_with_request_heap_frame_flag() { // assert when request_heap_frame is presented in tx, prioritization fee will be counted // into transaction fee assert_eq!( - calculate_test_fee(&message, lamports_per_signature, &fee_structure), + calculate_test_fee(&message, &fee_structure), signature_fee + request_cu * lamports_per_cu ); } diff --git a/sdk/src/fee.rs b/sdk/src/fee.rs index 08a825cd1ba2a2..13ce1020ff32dd 100644 --- a/sdk/src/fee.rs +++ b/sdk/src/fee.rs @@ -82,6 +82,17 @@ impl FeeDetails { pub const ACCOUNT_DATA_COST_PAGE_SIZE: u64 = 32_u64.saturating_mul(1024); impl FeeStructure { + pub fn zero_fees() -> Self { + Self { + lamports_per_signature: 0, + lamports_per_write_lock: 0, + compute_fee_bins: vec![FeeBin { + limit: u64::MAX, + fee: 0, + }], + } + } + pub fn new( sol_per_signature: f64, sol_per_write_lock: f64, diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 7b54dfbf878297..6fd09f438dcb51 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -479,13 +479,12 @@ impl TransactionBatchProcessor { let CheckedTransactionDetails { nonce, - lamports_per_signature, + lamports_per_signature: _, } = checked_details; let fee_budget_limits = FeeBudgetLimits::from(compute_budget_limits); let fee_details = solana_fee::calculate_fee_details( message, - lamports_per_signature == 0, fee_structure.lamports_per_signature, fee_budget_limits.prioritization_fee, feature_set.is_active(&remove_rounding_in_fee_calculation::id()), diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 199c61237ed403..d001dd0c1f8214 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -702,7 +702,7 @@ impl TestValidator { /// Faucet optional. /// /// This function panics on initialization failure. - pub fn with_no_fees( + pub fn with_no_base_fees( mint_address: Pubkey, faucet_addr: Option, socket_addr_space: SocketAddrSpace, diff --git a/tokens/src/commands.rs b/tokens/src/commands.rs index e5f4b6b8aba57f..ade7e53b0fefd1 100644 --- a/tokens/src/commands.rs +++ b/tokens/src/commands.rs @@ -1350,7 +1350,7 @@ mod tests { fn simple_test_validator_no_fees(pubkey: Pubkey) -> TestValidator { let test_validator = - TestValidator::with_no_fees(pubkey, None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(pubkey, None, SocketAddrSpace::Unspecified); test_validator.set_startup_verification_complete_for_tests(); test_validator } diff --git a/tokens/tests/commands.rs b/tokens/tests/commands.rs index c3a960e7707ef0..9e97bfaeaf2332 100644 --- a/tokens/tests/commands.rs +++ b/tokens/tests/commands.rs @@ -12,7 +12,7 @@ fn test_process_distribute_with_rpc_client() { let mint_keypair = Keypair::new(); let test_validator = - TestValidator::with_no_fees(mint_keypair.pubkey(), None, SocketAddrSpace::Unspecified); + TestValidator::with_no_base_fees(mint_keypair.pubkey(), None, SocketAddrSpace::Unspecified); let client = RpcClient::new(test_validator.rpc_url()); test_process_distribute_tokens_with_client(&client, mint_keypair, None);