removes OrderedIterator and transaction batch iteration order (#16153)

In TransactionBatch,
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/transaction_batch.rs#L4-L11
lock_results[i] is aligned with transactions[iteration_order[i]]:
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/bank.rs#L2414-L2424
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/accounts.rs#L788-L817

However load_and_execute_transactions is iterating over
  lock_results[iteration_order[i]]
https://github.com/solana-labs/solana/blob/e50f59844/runtime/src/bank.rs#L2878-L2889
and then returning i as for the index of the retryable transaction.

If iteratorion_order is [1, 2, 0], and i is 0, then:
  lock_results[iteration_order[i]] = lock_results[1]
which corresponds to
  transactions[iteration_order[1]] = transactions[2]
so neither i = 0, nor iteration_order[i] = 1 gives the correct index for the
corresponding transaction (which is 2).

This commit removes OrderedIterator and transaction batch iteration order
entirely. There is only one place in blockstore processor which the
iteration order is not ordinal:
https://github.com/solana-labs/solana/blob/e50f59844/ledger/src/blockstore_processor.rs#L269-L271
It seems like, instead of using an iteration order, that can shuffle entry
transactions in-place.
This commit is contained in:
behzad nouri
2021-03-31 23:59:19 +00:00
committed by GitHub
parent ad7f8e7f23
commit 3f63ed9a72
14 changed files with 161 additions and 352 deletions

View File

@ -754,7 +754,6 @@ impl BankingStage {
if num_to_commit != 0 {
let tx_results = bank.commit_transactions(
txs,
None,
&mut loaded_accounts,
&results,
tx_count,
@ -769,7 +768,6 @@ impl BankingStage {
transaction_status_sender.send_transaction_status_batch(
bank.clone(),
batch.transactions(),
batch.iteration_order_vec(),
tx_results.execution_results,
TransactionBalancesSet::new(pre_balances, post_balances),
TransactionTokenBalancesSet::new(pre_token_balances, post_token_balances),
@ -810,7 +808,7 @@ impl BankingStage {
let mut lock_time = Measure::start("lock_time");
// Once accounts are locked, other threads cannot encode transactions that will modify the
// same account state
let batch = bank.prepare_batch(txs, None);
let batch = bank.prepare_batch(txs);
lock_time.stop();
let (result, mut retryable_txs) = Self::process_and_record_transactions_locked(
@ -1003,7 +1001,6 @@ impl BankingStage {
};
let result = bank.check_transactions(
transactions,
None,
&filter,
(MAX_PROCESSING_AGE)
.saturating_sub(max_tx_fwd_delay)

View File

@ -3103,7 +3103,7 @@ pub(crate) mod tests {
let fail_tx =
system_transaction::transfer(&mint_keypair, &keypair2.pubkey(), 2, Hash::default());
let entry_3 = next_entry(&entry_2.hash, 1, vec![fail_tx]);
let entries = vec![entry_1, entry_2, entry_3];
let mut entries = vec![entry_1, entry_2, entry_3];
let shreds = entries_to_test_shreds(entries.clone(), slot, previous_slot, true, 0);
blockstore.insert_shreds(shreds, None, false).unwrap();
@ -3122,7 +3122,7 @@ pub(crate) mod tests {
// that they are matched properly by get_rooted_block
let _result = blockstore_processor::process_entries(
&bank,
&entries,
&mut entries,
true,
Some(TransactionStatusSender {
sender: transaction_status_sender,

View File

@ -4,9 +4,8 @@ use solana_ledger::{
blockstore::Blockstore,
blockstore_processor::{TransactionStatusBatch, TransactionStatusMessage},
};
use solana_runtime::{
bank::{Bank, InnerInstructionsList, NonceRollbackInfo, TransactionLogMessages},
transaction_utils::OrderedIterator,
use solana_runtime::bank::{
Bank, InnerInstructionsList, NonceRollbackInfo, TransactionLogMessages,
};
use solana_transaction_status::{InnerInstructions, TransactionStatusMeta};
use std::{
@ -58,7 +57,6 @@ impl TransactionStatusService {
TransactionStatusMessage::Batch(TransactionStatusBatch {
bank,
transactions,
iteration_order,
statuses,
balances,
token_balances,
@ -80,7 +78,7 @@ impl TransactionStatusService {
Box::new(std::iter::repeat_with(Vec::new))
};
for (
(_, transaction),
transaction,
(status, nonce_rollback),
pre_balances,
post_balances,
@ -89,7 +87,7 @@ impl TransactionStatusService {
inner_instructions,
log_messages,
) in izip!(
OrderedIterator::new(&transactions, iteration_order.as_deref()),
&transactions,
statuses,
balances.pre_balances,
balances.post_balances,