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

Remove dead code that still fetches lamports-per-signature from nonce or from blockhash_queue #34943

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl Banks for BanksServer {
) -> Option<u64> {
let bank = self.bank(commitment);
let sanitized_message = SanitizedMessage::try_from(message).ok()?;
bank.get_fee_for_message(&sanitized_message)
Some(bank.get_fee_for_message(&sanitized_message))
}
}

Expand Down
1 change: 0 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ impl Consumer {
process_compute_budget_instructions(message.program_instructions_iter())?.into();
let fee = bank.fee_structure.calculate_fee(
message,
bank.get_lamports_per_signature(),
&budget_limits,
bank.feature_set.is_active(
&feature_set::include_loaded_accounts_data_size_in_fee_calculation::id(),
Expand Down
18 changes: 2 additions & 16 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
parse_bpf_upgradeable_loader, BpfUpgradeableLoaderAccountType,
},
solana_accounts_db::transaction_results::{
DurableNonceFee, InnerInstruction, TransactionExecutionDetails, TransactionExecutionResult,
InnerInstruction, TransactionExecutionDetails, TransactionExecutionResult,
TransactionResults,
},
solana_ledger::token_balances::collect_token_balances,
Expand Down Expand Up @@ -190,25 +190,13 @@ fn execute_transactions(
status,
log_messages,
inner_instructions,
durable_nonce_fee,
return_data,
executed_units,
..
} = details;

let lamports_per_signature = match durable_nonce_fee {
Some(DurableNonceFee::Valid(lamports_per_signature)) => {
Some(lamports_per_signature)
}
Some(DurableNonceFee::Invalid) => None,
None => bank.get_lamports_per_signature_for_blockhash(
&tx.message().recent_blockhash,
),
}
.expect("lamports_per_signature must be available");
let fee = bank.get_fee_for_message_with_lamports_per_signature(
let fee = bank.get_fee_for_message(
&SanitizedMessage::try_from(tx.message().clone()).unwrap(),
lamports_per_signature,
);

let inner_instructions = inner_instructions.map(|inner_instructions| {
Expand Down Expand Up @@ -3985,7 +3973,6 @@ fn test_program_fees() {
let sanitized_message = SanitizedMessage::try_from(message.clone()).unwrap();
let expected_normal_fee = fee_structure.calculate_fee(
&sanitized_message,
congestion_multiplier,
&process_compute_budget_instructions(sanitized_message.program_instructions_iter())
.unwrap_or_default()
.into(),
Expand All @@ -4008,7 +3995,6 @@ fn test_program_fees() {
let sanitized_message = SanitizedMessage::try_from(message.clone()).unwrap();
let expected_prioritized_fee = fee_structure.calculate_fee(
&sanitized_message,
congestion_multiplier,
&process_compute_budget_instructions(sanitized_message.program_instructions_iter())
.unwrap_or_default()
.into(),
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4106,7 +4106,7 @@ pub mod rpc_full {
.map_err(|err| {
Error::invalid_params(format!("invalid transaction message: {err}"))
})?;
let fee = bank.get_fee_for_message(&sanitized_message);
let fee = Some(bank.get_fee_for_message(&sanitized_message));
Ok(new_response(bank, fee))
}

Expand Down
19 changes: 3 additions & 16 deletions rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
crate::transaction_notifier_interface::TransactionNotifierArc,
crossbeam_channel::{Receiver, RecvTimeoutError},
itertools::izip,
solana_accounts_db::transaction_results::{DurableNonceFee, TransactionExecutionDetails},
solana_accounts_db::transaction_results::TransactionExecutionDetails,
solana_ledger::{
blockstore::Blockstore,
blockstore_processor::{TransactionStatusBatch, TransactionStatusMessage},
Expand Down Expand Up @@ -99,25 +99,11 @@ impl TransactionStatusService {
status,
log_messages,
inner_instructions,
durable_nonce_fee,
return_data,
executed_units,
..
} = details;
let lamports_per_signature = match durable_nonce_fee {
Some(DurableNonceFee::Valid(lamports_per_signature)) => {
Some(lamports_per_signature)
}
Some(DurableNonceFee::Invalid) => None,
None => bank.get_lamports_per_signature_for_blockhash(
transaction.message().recent_blockhash(),
),
}
.expect("lamports_per_signature must be available");
let fee = bank.get_fee_for_message_with_lamports_per_signature(
transaction.message(),
lamports_per_signature,
);
let fee = bank.get_fee_for_message(transaction.message());
let tx_account_locks = transaction.get_account_locks_unchecked();

let inner_instructions = inner_instructions.map(|inner_instructions| {
Expand Down Expand Up @@ -215,6 +201,7 @@ pub(crate) mod tests {
solana_accounts_db::{
nonce_info::{NonceFull, NoncePartial},
rent_debits::RentDebits,
transaction_results::DurableNonceFee,
},
solana_ledger::{genesis_utils::create_genesis_config, get_tmp_ledger_path_auto_delete},
solana_runtime::bank::{Bank, TransactionBalancesSet},
Expand Down
31 changes: 3 additions & 28 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4005,20 +4005,6 @@ impl Bank {
&self.fee_rate_governor
}

pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> Option<u64> {
let lamports_per_signature = {
let blockhash_queue = self.blockhash_queue.read().unwrap();
blockhash_queue.get_lamports_per_signature(message.recent_blockhash())
}
.or_else(|| {
self.check_message_for_nonce(message)
.and_then(|(address, account)| {
NoncePartial::new(address, account).lamports_per_signature()
})
})?;
Some(self.get_fee_for_message_with_lamports_per_signature(message, lamports_per_signature))
}

/// Returns true when startup accounts hash verification has completed or never had to run in background.
pub fn get_startup_verification_complete(&self) -> &Arc<AtomicBool> {
&self
Expand Down Expand Up @@ -4050,14 +4036,9 @@ impl Bank {
.verification_complete()
}

pub fn get_fee_for_message_with_lamports_per_signature(
&self,
message: &SanitizedMessage,
lamports_per_signature: u64,
) -> u64 {
pub fn get_fee_for_message(&self, message: &SanitizedMessage) -> u64 {
self.fee_structure.calculate_fee(
message,
lamports_per_signature,
&process_compute_budget_instructions(message.program_instructions_iter())
.unwrap_or_default()
.into(),
Expand Down Expand Up @@ -5342,7 +5323,6 @@ impl Bank {
&self.ancestors,
sanitized_txs,
check_results,
&self.blockhash_queue.read().unwrap(),
error_counters,
&self.rent_collector,
&self.feature_set,
Expand Down Expand Up @@ -5529,7 +5509,7 @@ impl Bank {
TransactionExecutionResult::NotExecuted(err) => Err(err.clone()),
}?;

let (lamports_per_signature, is_nonce) = durable_nonce_fee
let (_lamports_per_signature, is_nonce) = durable_nonce_fee
.map(|durable_nonce_fee| durable_nonce_fee.lamports_per_signature())
.map(|maybe_lamports_per_signature| (maybe_lamports_per_signature, true))
.unwrap_or_else(|| {
Expand All @@ -5539,12 +5519,7 @@ impl Bank {
)
});

let lamports_per_signature =
lamports_per_signature.ok_or(TransactionError::BlockhashNotFound)?;
let fee = self.get_fee_for_message_with_lamports_per_signature(
tx.message(),
lamports_per_signature,
);
let fee = self.get_fee_for_message(tx.message());

// In case of instruction error, even though no accounts
// were stored we still need to charge the payer the
Expand Down
Loading
Loading