|
|
@@ -26,7 +26,7 @@ use {
|
|
|
},
|
|
|
solana_clock::{Epoch, Slot},
|
|
|
solana_feature_set::{remove_accounts_executable_flag_checks, FeatureSet},
|
|
|
- solana_fee_structure::{FeeDetails, FeeStructure},
|
|
|
+ solana_fee_structure::FeeStructure,
|
|
|
solana_hash::Hash,
|
|
|
solana_instruction::TRANSACTION_LEVEL_STACK_HEIGHT,
|
|
|
solana_log_collector::LogCollector,
|
|
|
@@ -411,12 +411,10 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
tx,
|
|
|
tx_details,
|
|
|
&environment.blockhash,
|
|
|
- environment.fee_lamports_per_signature,
|
|
|
environment
|
|
|
.rent_collector
|
|
|
.unwrap_or(&RentCollector::default()),
|
|
|
&mut error_metrics,
|
|
|
- callbacks,
|
|
|
)
|
|
|
}));
|
|
|
validate_fees_us = validate_fees_us.saturating_add(single_validate_fees_us);
|
|
|
@@ -512,10 +510,8 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
message: &impl SVMMessage,
|
|
|
checked_details: CheckedTransactionDetails,
|
|
|
environment_blockhash: &Hash,
|
|
|
- fee_lamports_per_signature: u64,
|
|
|
rent_collector: &dyn SVMRentCollector,
|
|
|
error_counters: &mut TransactionErrorMetrics,
|
|
|
- callbacks: &CB,
|
|
|
) -> TransactionResult<ValidatedTransactionDetails> {
|
|
|
// If this is a nonce transaction, validate the nonce info.
|
|
|
// This must be done for every transaction to support SIMD83 because
|
|
|
@@ -542,10 +538,8 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
account_loader,
|
|
|
message,
|
|
|
checked_details,
|
|
|
- fee_lamports_per_signature,
|
|
|
rent_collector,
|
|
|
error_counters,
|
|
|
- callbacks,
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -556,14 +550,12 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
account_loader: &mut AccountLoader<CB>,
|
|
|
message: &impl SVMMessage,
|
|
|
checked_details: CheckedTransactionDetails,
|
|
|
- fee_lamports_per_signature: u64,
|
|
|
rent_collector: &dyn SVMRentCollector,
|
|
|
error_counters: &mut TransactionErrorMetrics,
|
|
|
- callbacks: &CB,
|
|
|
) -> TransactionResult<ValidatedTransactionDetails> {
|
|
|
let CheckedTransactionDetails {
|
|
|
nonce,
|
|
|
- lamports_per_signature,
|
|
|
+ lamports_per_signature: _,
|
|
|
compute_budget_and_limits,
|
|
|
} = checked_details;
|
|
|
|
|
|
@@ -588,17 +580,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
)
|
|
|
.rent_amount;
|
|
|
|
|
|
- let fee_details = if lamports_per_signature == 0 {
|
|
|
- FeeDetails::default()
|
|
|
- } else {
|
|
|
- callbacks.calculate_fee(
|
|
|
- message,
|
|
|
- fee_lamports_per_signature,
|
|
|
- compute_budget_and_limits.priority_fee,
|
|
|
- account_loader.feature_set.as_ref(),
|
|
|
- )
|
|
|
- };
|
|
|
-
|
|
|
let fee_payer_index = 0;
|
|
|
validate_fee_payer(
|
|
|
fee_payer_address,
|
|
|
@@ -606,7 +587,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
fee_payer_index,
|
|
|
error_counters,
|
|
|
rent_collector,
|
|
|
- fee_details.total_fee(),
|
|
|
+ compute_budget_and_limits.fee_details.total_fee(),
|
|
|
)?;
|
|
|
|
|
|
// Capture fee-subtracted fee payer account and next nonce account state
|
|
|
@@ -620,7 +601,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
|
|
);
|
|
|
|
|
|
Ok(ValidatedTransactionDetails {
|
|
|
- fee_details,
|
|
|
+ fee_details: compute_budget_and_limits.fee_details,
|
|
|
rollback_accounts,
|
|
|
loaded_accounts_bytes_limit: compute_budget_and_limits.loaded_accounts_data_size_limit,
|
|
|
compute_budget: compute_budget_and_limits.budget,
|
|
|
@@ -1205,7 +1186,7 @@ mod tests {
|
|
|
solana_epoch_schedule::EpochSchedule,
|
|
|
solana_feature_set::FeatureSet,
|
|
|
solana_fee_calculator::FeeCalculator,
|
|
|
- solana_fee_structure::{FeeDetails, FeeStructure},
|
|
|
+ solana_fee_structure::FeeDetails,
|
|
|
solana_hash::Hash,
|
|
|
solana_keypair::Keypair,
|
|
|
solana_message::{LegacyMessage, Message, MessageHeader, SanitizedMessage},
|
|
|
@@ -1296,13 +1277,13 @@ mod tests {
|
|
|
.or_default()
|
|
|
.push((account, is_writable));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- fn calculate_fee(
|
|
|
- &self,
|
|
|
+ impl MockBankCallback {
|
|
|
+ pub fn calculate_fee_details(
|
|
|
message: &impl SVMMessage,
|
|
|
lamports_per_signature: u64,
|
|
|
prioritization_fee: u64,
|
|
|
- _feature_set: &FeatureSet,
|
|
|
) -> FeeDetails {
|
|
|
let signature_count = message
|
|
|
.num_transaction_signatures()
|
|
|
@@ -2178,7 +2159,7 @@ mod tests {
|
|
|
compute_unit_limit: 2000,
|
|
|
..SVMTransactionExecutionBudget::default()
|
|
|
},
|
|
|
- priority_fee,
|
|
|
+ fee_details: FeeDetails::new(transaction_fee, priority_fee),
|
|
|
..SVMTransactionExecutionAndFeeBudgetLimits::default()
|
|
|
};
|
|
|
let result =
|
|
|
@@ -2191,10 +2172,8 @@ mod tests {
|
|
|
Ok(compute_budget_and_limits),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&rent_collector,
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
let post_validation_fee_payer_account = {
|
|
|
@@ -2260,7 +2239,9 @@ mod tests {
|
|
|
let mut account_loader = (&mock_bank).into();
|
|
|
|
|
|
let mut error_counters = TransactionErrorMetrics::default();
|
|
|
- let compute_budget_and_limits = SVMTransactionExecutionAndFeeBudgetLimits::default();
|
|
|
+ let compute_budget_and_limits = SVMTransactionExecutionAndFeeBudgetLimits::with_fee(
|
|
|
+ MockBankCallback::calculate_fee_details(&message, lamports_per_signature, 0),
|
|
|
+ );
|
|
|
let result =
|
|
|
TransactionBatchProcessor::<TestForkGraph>::validate_transaction_nonce_and_fee_payer(
|
|
|
&mut account_loader,
|
|
|
@@ -2271,10 +2252,8 @@ mod tests {
|
|
|
Ok(compute_budget_and_limits),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&rent_collector,
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
let post_validation_fee_payer_account = {
|
|
|
@@ -2326,10 +2305,8 @@ mod tests {
|
|
|
Ok(SVMTransactionExecutionAndFeeBudgetLimits::default()),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&RentCollector::default(),
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(error_counters.account_not_found.0, 1);
|
|
|
@@ -2359,13 +2336,17 @@ mod tests {
|
|
|
CheckedTransactionDetails::new(
|
|
|
None,
|
|
|
lamports_per_signature,
|
|
|
- Ok(SVMTransactionExecutionAndFeeBudgetLimits::default()),
|
|
|
+ Ok(SVMTransactionExecutionAndFeeBudgetLimits::with_fee(
|
|
|
+ MockBankCallback::calculate_fee_details(
|
|
|
+ &message,
|
|
|
+ lamports_per_signature,
|
|
|
+ 0,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&RentCollector::default(),
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(error_counters.insufficient_funds.0, 1);
|
|
|
@@ -2399,13 +2380,17 @@ mod tests {
|
|
|
CheckedTransactionDetails::new(
|
|
|
None,
|
|
|
lamports_per_signature,
|
|
|
- Ok(SVMTransactionExecutionAndFeeBudgetLimits::default()),
|
|
|
+ Ok(SVMTransactionExecutionAndFeeBudgetLimits::with_fee(
|
|
|
+ MockBankCallback::calculate_fee_details(
|
|
|
+ &message,
|
|
|
+ lamports_per_signature,
|
|
|
+ 0,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&rent_collector,
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(
|
|
|
@@ -2437,13 +2422,17 @@ mod tests {
|
|
|
CheckedTransactionDetails::new(
|
|
|
None,
|
|
|
lamports_per_signature,
|
|
|
- Ok(SVMTransactionExecutionAndFeeBudgetLimits::default()),
|
|
|
+ Ok(SVMTransactionExecutionAndFeeBudgetLimits::with_fee(
|
|
|
+ MockBankCallback::calculate_fee_details(
|
|
|
+ &message,
|
|
|
+ lamports_per_signature,
|
|
|
+ 0,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&RentCollector::default(),
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(error_counters.invalid_account_for_fee.0, 1);
|
|
|
@@ -2474,10 +2463,8 @@ mod tests {
|
|
|
Err(DuplicateInstruction(1)),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&RentCollector::default(),
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(error_counters.invalid_compute_budget.0, 1);
|
|
|
@@ -2498,13 +2485,13 @@ mod tests {
|
|
|
Some(&Pubkey::new_unique()),
|
|
|
&last_blockhash,
|
|
|
));
|
|
|
+ let transaction_fee = lamports_per_signature;
|
|
|
let compute_budget_and_limits = SVMTransactionExecutionAndFeeBudgetLimits {
|
|
|
- priority_fee: compute_unit_limit,
|
|
|
+ fee_details: FeeDetails::new(transaction_fee, compute_unit_limit),
|
|
|
..SVMTransactionExecutionAndFeeBudgetLimits::default()
|
|
|
};
|
|
|
let fee_payer_address = message.fee_payer();
|
|
|
let min_balance = Rent::default().minimum_balance(nonce::state::State::size());
|
|
|
- let transaction_fee = lamports_per_signature;
|
|
|
let priority_fee = compute_unit_limit;
|
|
|
|
|
|
// Sufficient Fees
|
|
|
@@ -2550,10 +2537,8 @@ mod tests {
|
|
|
&message,
|
|
|
tx_details,
|
|
|
&environment_blockhash,
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&rent_collector,
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
let post_validation_fee_payer_account = {
|
|
|
@@ -2611,10 +2596,8 @@ mod tests {
|
|
|
&message,
|
|
|
CheckedTransactionDetails::new(None, lamports_per_signature, Ok(compute_budget_and_limits)),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&rent_collector,
|
|
|
&mut error_counters,
|
|
|
- &mock_bank,
|
|
|
);
|
|
|
|
|
|
assert_eq!(error_counters.insufficient_funds.0, 1);
|
|
|
@@ -2655,13 +2638,13 @@ mod tests {
|
|
|
CheckedTransactionDetails::new(
|
|
|
None,
|
|
|
5000,
|
|
|
- Ok(SVMTransactionExecutionAndFeeBudgetLimits::default()),
|
|
|
+ Ok(SVMTransactionExecutionAndFeeBudgetLimits::with_fee(
|
|
|
+ MockBankCallback::calculate_fee_details(&message, 5000, 0),
|
|
|
+ )),
|
|
|
),
|
|
|
&Hash::default(),
|
|
|
- FeeStructure::default().lamports_per_signature,
|
|
|
&RentCollector::default(),
|
|
|
&mut TransactionErrorMetrics::default(),
|
|
|
- &mock_bank,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|