diff --git a/conformance/src/txn_execute.zig b/conformance/src/txn_execute.zig index 0bfb5db0fe..8c857aebec 100644 --- a/conformance/src/txn_execute.zig +++ b/conformance/src/txn_execute.zig @@ -110,6 +110,7 @@ const Rent = sig.runtime.sysvar.Rent; const SysvarCache = sig.runtime.SysvarCache; const RuntimeTransaction = transaction_execution.RuntimeTransaction; const TransactionExecutionEnvironment = transaction_execution.TransactionExecutionEnvironment; +const LAMPORTS_PER_SIGNATURE = sig.runtime.check_transactions.LAMPORTS_PER_SIGNATURE; const ProcessedTransaction = transaction_execution.ProcessedTransaction; const TransactionResult = transaction_execution.TransactionResult; @@ -702,7 +703,7 @@ fn executeTxnContext( // juggles the many different versions of lamports_per_signature. .next_lamports_per_signature = last_lamports_per_signature, .last_lamports_per_signature = last_lamports_per_signature, - .lamports_per_signature = 5000, + .lamports_per_signature = LAMPORTS_PER_SIGNATURE, }; var failed_accounts = sig.runtime.account_loader.LoadedTransactionAccounts.Accounts{}; diff --git a/v1/src/replay/execution.zig b/v1/src/replay/execution.zig index c626b133ea..ce619b0a3e 100644 --- a/v1/src/replay/execution.zig +++ b/v1/src/replay/execution.zig @@ -22,6 +22,7 @@ const AccountStore = sig.accounts_db.AccountStore; const ForkProgress = sig.consensus.progress_map.ForkProgress; const ParsedVote = sig.consensus.vote_listener.vote_parser.ParsedVote; const ProcessedTransaction = sig.runtime.transaction_execution.ProcessedTransaction; +const LAMPORTS_PER_SIGNATURE = sig.runtime.check_transactions.LAMPORTS_PER_SIGNATURE; const SlotHashes = sig.runtime.sysvar.SlotHashes; const TransactionError = sig.ledger.transaction_status.TransactionError; @@ -1131,7 +1132,7 @@ pub const TestState = struct { .ancestors = ancestors, .slot = 0, .max_age = max_age, - .lamports_per_signature = 5000, + .lamports_per_signature = LAMPORTS_PER_SIGNATURE, .blockhash_queue = .init(blockhash_queue), .feature_set = .ALL_DISABLED, .rent_collector = .DEFAULT, diff --git a/v1/src/rpc/hook_contexts/Account.zig b/v1/src/rpc/hook_contexts/Account.zig index 81885ce325..5bc71cf256 100644 --- a/v1/src/rpc/hook_contexts/Account.zig +++ b/v1/src/rpc/hook_contexts/Account.zig @@ -423,7 +423,7 @@ pub fn getFeeForMessage( const fee_budget_limits = FeeBudgetLimits.fromComputeBudgetLimits(budget_limits); fee_details = FeeDetails.init( SignatureCounts.fromTransaction(&runtime_txn), - 5_000, + bq_lps, fee_budget_limits.prioritization_fee, budget_limits.compute_unit_price, ); diff --git a/v1/src/transaction_sender/MockTransferService.zig b/v1/src/transaction_sender/MockTransferService.zig index 50b737cfe8..063ed553d5 100644 --- a/v1/src/transaction_sender/MockTransferService.zig +++ b/v1/src/transaction_sender/MockTransferService.zig @@ -21,6 +21,8 @@ const TransactionInfo = sig.TransactionSenderService.TransactionInfo; const Commitment = sig.rpc.methods.common.Commitment; +const LAMPORTS_PER_SIGNATURE = sig.runtime.check_transactions.LAMPORTS_PER_SIGNATURE; + const Logger = sig.trace.Logger("MockTransferService"); pub const Service = @This(); @@ -40,8 +42,7 @@ successful: u64 = 0, const TRANSFERS: u64 = 10; const TRANSFER_AMOUNT: u64 = 1e6; -const TRANSFER_FEE: u64 = 5000; -const TRANSFER_COST: u64 = TRANSFER_AMOUNT + TRANSFER_FEE; +const TRANSFER_COST: u64 = TRANSFER_AMOUNT + LAMPORTS_PER_SIGNATURE; pub const ACCOUNT_0: Account = .init("account_0", .{ // Pubkey: H67JSziFxAZR1KSQshWfa8Rdpr7LSv1VkT2cFQHL79rd .public_key = .{ .bytes = .{ diff --git a/v2/components/runtime/runtime/check_transactions.zig b/v2/components/runtime/runtime/check_transactions.zig index 9584e5a98a..a459f1d81c 100644 --- a/v2/components/runtime/runtime/check_transactions.zig +++ b/v2/components/runtime/runtime/check_transactions.zig @@ -83,19 +83,12 @@ pub fn checkFeePayer( // This means that lamports_per_signature is in effect *always* 5000, even // when the fee rate governor disagrees. // - // The other fields of FeeStructure, lamports_per_write_lock and - // compute_fee_bins, are also effectively unused. - // - // TODO: Stop hardcoding this value. - // This will probably be fixed in Agave at some point, we should fix this - // when they do. - // // [agave] https://github.com/anza-xyz/agave/blob/b6c96e84b10396b92912d4574dae7d03f606da26/runtime/src/bank/check_transactions.rs#L106-L112 const fee_budget_limits = FeeBudgetLimits.fromComputeBudgetLimits(compute_budget_limits.*); const fee_details = FeeDetails.init( SignatureCounts.fromTransaction(transaction), - 5_000, + LAMPORTS_PER_SIGNATURE, fee_budget_limits.prioritization_fee, compute_budget_limits.compute_unit_price, ); @@ -179,6 +172,8 @@ pub const SignatureCounts = struct { } }; +pub const LAMPORTS_PER_SIGNATURE: u64 = 5_000; + pub const FeeDetails = struct { transaction_fee: u64, prioritization_fee: u64, @@ -776,12 +771,12 @@ test "checkFeePayer: happy path fee payer only" { const fee_details, const rollbacks, const prepared_fee_payer = result.ok; defer prepared_fee_payer.account.deinit(allocator); - try std.testing.expectEqual(5000, fee_details.transaction_fee); + try std.testing.expectEqual(LAMPORTS_PER_SIGNATURE, fee_details.transaction_fee); try std.testing.expectEqual(0, fee_details.prioritization_fee); try std.testing.expectEqual(1, rollbacks.slice().len); const payer = rollbacks.slice()[0]; - try std.testing.expectEqual(995_000, payer.account.lamports); + try std.testing.expectEqual(1_000_000 - LAMPORTS_PER_SIGNATURE, payer.account.lamports); try std.testing.expectEqual(0, payer.account.rent_epoch); } @@ -847,9 +842,9 @@ test "checkFeePayer: happy path with same nonce and fee payer" { try std.testing.expectEqual(1, rollbacks.len); const rollback_account = rollbacks.get(0).account; - try std.testing.expectEqual(5000, fee_details.transaction_fee); + try std.testing.expectEqual(LAMPORTS_PER_SIGNATURE, fee_details.transaction_fee); try std.testing.expectEqual(0, fee_details.prioritization_fee); - try std.testing.expectEqual(995_000, rollback_account.lamports); + try std.testing.expectEqual(1_000_000 - LAMPORTS_PER_SIGNATURE, rollback_account.lamports); try std.testing.expectEqual(std.math.maxInt(u64), rollback_account.rent_epoch); } @@ -915,10 +910,13 @@ test "checkFeePayer: happy path with separate nonce and fee payer" { const rollback_nonce_account = rollbacks.get(0).account; const rollback_fee_payer_account = rollbacks.get(1).account; - try std.testing.expectEqual(5000, fee_details.transaction_fee); + try std.testing.expectEqual(LAMPORTS_PER_SIGNATURE, fee_details.transaction_fee); try std.testing.expectEqual(0, fee_details.prioritization_fee); try std.testing.expectEqual(1_000, rollback_nonce_account.lamports); try std.testing.expectEqual(0, rollback_nonce_account.rent_epoch); - try std.testing.expectEqual(995_000, rollback_fee_payer_account.lamports); + try std.testing.expectEqual( + 1_000_000 - LAMPORTS_PER_SIGNATURE, + rollback_fee_payer_account.lamports, + ); try std.testing.expectEqual(std.math.maxInt(u64), rollback_fee_payer_account.rent_epoch); } diff --git a/v2/components/runtime/runtime/transaction_execution.zig b/v2/components/runtime/runtime/transaction_execution.zig index fa078201e1..4256e29313 100644 --- a/v2/components/runtime/runtime/transaction_execution.zig +++ b/v2/components/runtime/runtime/transaction_execution.zig @@ -25,6 +25,7 @@ const EpochStakeReader = sig.runtime.execution_interfaces.EpochStakeReader; const LoadedAccount = sig.runtime.account_loader.LoadedAccount; const FeatureSet = solana.features.Set; const FeeDetails = sig.runtime.check_transactions.FeeDetails; +const LAMPORTS_PER_SIGNATURE = sig.runtime.check_transactions.LAMPORTS_PER_SIGNATURE; const InstructionInfo = sig.runtime.InstructionInfo; const LoadedTransactionAccounts = sig.runtime.account_loader.LoadedTransactionAccounts; const LogCollector = sig.runtime.LogCollector; @@ -873,7 +874,7 @@ test "loadAndExecuteTransaction: simple transfer transaction" { .next_durable_nonce = Hash.ZEROES, .next_lamports_per_signature = 0, .last_lamports_per_signature = 0, - .lamports_per_signature = 5000, // Default value + .lamports_per_signature = LAMPORTS_PER_SIGNATURE, }; const config = TransactionExecutionConfig{ @@ -912,10 +913,10 @@ test "loadAndExecuteTransaction: simple transfer transaction" { const sender_account = account_map.get(sender_key).?; const receiver_account = account_map.get(receiver_key).?; - try std.testing.expectEqual(5_000, transaction_fee); + try std.testing.expectEqual(LAMPORTS_PER_SIGNATURE, transaction_fee); try std.testing.expectEqual(0, prioritization_fee); try std.testing.expectEqual(0, processed_transaction.rent); - try std.testing.expectEqual(4_995_000, sender_account.lamports); + try std.testing.expectEqual(5_000_000 - LAMPORTS_PER_SIGNATURE, sender_account.lamports); try std.testing.expectEqual(15_000_000, receiver_account.lamports); try std.testing.expectEqual(null, processed_transaction.err); try std.testing.expectEqual(null, executed_transaction.log_collector); @@ -957,10 +958,10 @@ test "loadAndExecuteTransaction: simple transfer transaction" { const sender_account = account_map.get(sender_key).?; const receiver_account = account_map.get(receiver_key).?; - try std.testing.expectEqual(5_000, transaction_fee); + try std.testing.expectEqual(LAMPORTS_PER_SIGNATURE, transaction_fee); try std.testing.expectEqual(0, prioritization_fee); try std.testing.expectEqual(0, processed_transaction.rent); - try std.testing.expectEqual(4_990_000, sender_account.lamports); + try std.testing.expectEqual(5_000_000 - 2 * LAMPORTS_PER_SIGNATURE, sender_account.lamports); try std.testing.expectEqual(15_000_000, receiver_account.lamports); try std.testing.expectEqual(0, processed_transaction.err.?.InstructionError[0]); try std.testing.expectEqual(