Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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
6 changes: 5 additions & 1 deletion core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,20 +788,24 @@ impl BankingStage {
results: &[TransactionExecutionResult],
recorder: &TransactionRecorder,
) -> (Result<usize, PohRecorderError>, Vec<usize>) {
let mut dropped_vote_count = 0;
let mut processed_generation = Measure::start("record::process_generation");
let (processed_transactions, processed_transactions_indexes): (Vec<_>, Vec<_>) = results
.iter()
.zip(txs)
.enumerate()
.filter_map(|(i, ((r, _n), tx))| {
if Bank::can_commit(r) {
if Bank::can_commit(tx.message(), r, true, &mut dropped_vote_count) {
Some((tx.to_versioned_transaction(), i))
} else {
None
}
})
.unzip();

if dropped_vote_count > 0 {
inc_new_counter_info!("leader-dropped_vote", dropped_vote_count);
}
processed_generation.stop();
let num_to_commit = processed_transactions.len();
debug!("num_to_commit: {} ", num_to_commit);
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl TransactionStatusService {
transaction_logs_iter,
rent_debits,
) {
if Bank::can_commit(&status) {
if Bank::can_commit(transaction.message(), &status, false, &mut 0usize) {
let lamports_per_signature = nonce_rollback
.map(|nonce_rollback| nonce_rollback.lamports_per_signature())
.unwrap_or_else(|| {
Expand Down
40 changes: 35 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3177,10 +3177,37 @@ impl Bank {
.clear_slot_entries(slot);
}

pub fn can_commit(result: &Result<()>) -> bool {
pub fn can_commit(
message: &solana_sdk::message::SanitizedMessage,
result: &Result<()>,
from_block_producer: bool,
dropped_vote_count: &mut usize,
) -> bool {
match result {
Ok(_) => true,
Err(TransactionError::InstructionError(_, _)) => true,
Err(TransactionError::InstructionError(error_index, error)) => {
if from_block_producer
&& solana_vote_program::check_id(
message.get_account_key(*error_index as usize).unwrap(),
)
{
match error {
InstructionError::Custom(error_code) => {
let vote_too_old_err: u32 =
solana_vote_program::vote_instruction::VoteError::VoteTooOld as u32;
if vote_too_old_err != *error_code {
*dropped_vote_count += 1;
true
} else {
false
}
}
_ => true,
}
} else {
true
}
}
Err(_) => false,
}
}
Expand All @@ -3193,7 +3220,7 @@ impl Bank {
let mut status_cache = self.src.status_cache.write().unwrap();
assert_eq!(sanitized_txs.len(), res.len());
for (tx, (res, _nonce_rollback)) in sanitized_txs.iter().zip(res) {
if Self::can_commit(res) {
if Self::can_commit(tx.message(), res, false, &mut 0usize) {
// Add the message hash to the status cache to ensure that this message
// won't be processed again with a different signature.
status_cache.insert(
Expand Down Expand Up @@ -3932,7 +3959,7 @@ impl Bank {
}
}

if Self::can_commit(r) // Skip log collection for unprocessed transactions
if Self::can_commit(tx.message(), r, false, &mut 0usize) // Skip log collection for unprocessed transactions
&& transaction_log_collector_config.filter != TransactionLogCollectorFilter::None
{
let mut transaction_log_collector = self.transaction_log_collector.write().unwrap();
Expand Down Expand Up @@ -4106,7 +4133,10 @@ impl Bank {

if executed
.iter()
.any(|(res, _nonce_rollback)| Self::can_commit(res))
.zip(sanitized_txs.iter())
.any(|((res, _nonce_rollback), tx)| {
Self::can_commit(tx.message(), res, false, &mut 0usize)
})
{
self.is_delta.store(true, Relaxed);
}
Expand Down