Refactor: Add trait for loading addresses (#22903)
This commit is contained in:
@ -37,15 +37,14 @@ use {
|
||||
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
|
||||
},
|
||||
feature_set,
|
||||
message::{
|
||||
v0::{LoadedAddresses, MessageAddressTableLookup},
|
||||
Message,
|
||||
},
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
short_vec::decode_shortu16_len,
|
||||
signature::Signature,
|
||||
timing::{duration_as_ms, timestamp, AtomicInterval},
|
||||
transaction::{self, SanitizedTransaction, TransactionError, VersionedTransaction},
|
||||
transaction::{
|
||||
self, AddressLoader, SanitizedTransaction, TransactionError, VersionedTransaction,
|
||||
},
|
||||
},
|
||||
solana_streamer::sendmmsg::{batch_send, SendPktsError},
|
||||
solana_transaction_status::token_balances::{
|
||||
@ -1394,7 +1393,7 @@ impl BankingStage {
|
||||
transaction_indexes: &[usize],
|
||||
feature_set: &Arc<feature_set::FeatureSet>,
|
||||
votes_only: bool,
|
||||
address_loader: impl Fn(&[MessageAddressTableLookup]) -> transaction::Result<LoadedAddresses>,
|
||||
address_loader: &impl AddressLoader,
|
||||
) -> (Vec<SanitizedTransaction>, Vec<usize>) {
|
||||
transaction_indexes
|
||||
.iter()
|
||||
@ -1411,7 +1410,7 @@ impl BankingStage {
|
||||
tx,
|
||||
message_hash,
|
||||
Some(p.meta.is_simple_vote_tx()),
|
||||
&address_loader,
|
||||
address_loader,
|
||||
)
|
||||
.ok()?;
|
||||
tx.verify_precompiles(feature_set).ok()?;
|
||||
@ -1477,7 +1476,7 @@ impl BankingStage {
|
||||
&packet_indexes,
|
||||
&bank.feature_set,
|
||||
bank.vote_only_bank(),
|
||||
|lookup| bank.load_lookup_table_addresses(lookup),
|
||||
bank.as_ref(),
|
||||
);
|
||||
packet_conversion_time.stop();
|
||||
inc_new_counter_info!("banking_stage-packet_conversion", 1);
|
||||
@ -1555,7 +1554,7 @@ impl BankingStage {
|
||||
transaction_indexes,
|
||||
&bank.feature_set,
|
||||
bank.vote_only_bank(),
|
||||
|lookup| bank.load_lookup_table_addresses(lookup),
|
||||
bank.as_ref(),
|
||||
);
|
||||
unprocessed_packet_conversion_time.stop();
|
||||
|
||||
@ -1778,12 +1777,15 @@ mod tests {
|
||||
account::AccountSharedData,
|
||||
hash::Hash,
|
||||
instruction::InstructionError,
|
||||
message::{v0, MessageHeader, VersionedMessage},
|
||||
message::{
|
||||
v0::{self, MessageAddressTableLookup},
|
||||
MessageHeader, VersionedMessage,
|
||||
},
|
||||
poh_config::PohConfig,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction::SystemError,
|
||||
system_transaction,
|
||||
transaction::{Transaction, TransactionError},
|
||||
transaction::{DisabledAddressLoader, Transaction, TransactionError},
|
||||
},
|
||||
solana_streamer::{recvmmsg::recv_mmsg, socket::SocketAddrSpace},
|
||||
solana_transaction_status::{TransactionStatusMeta, VersionedTransactionWithStatusMeta},
|
||||
@ -3111,15 +3113,12 @@ mod tests {
|
||||
let tx = VersionedTransaction::try_new(message, &[&keypair]).unwrap();
|
||||
let message_hash = tx.message.hash();
|
||||
let sanitized_tx =
|
||||
SanitizedTransaction::try_create(tx.clone(), message_hash, Some(false), |lookups| {
|
||||
Ok(bank.load_lookup_table_addresses(lookups).unwrap())
|
||||
})
|
||||
.unwrap();
|
||||
SanitizedTransaction::try_create(tx.clone(), message_hash, Some(false), bank.as_ref())
|
||||
.unwrap();
|
||||
|
||||
let entry = next_versioned_entry(&genesis_config.hash(), 1, vec![tx]);
|
||||
let entries = vec![entry];
|
||||
|
||||
// todo: check if sig fees are needed
|
||||
bank.transfer(1, &mint_keypair, &keypair.pubkey()).unwrap();
|
||||
|
||||
let ledger_path = get_tmp_ledger_path_auto_delete!();
|
||||
@ -3753,7 +3752,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(2, txs.len());
|
||||
assert_eq!(vec![0, 1], tx_packet_index);
|
||||
@ -3764,7 +3763,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(0, txs.len());
|
||||
assert_eq!(0, tx_packet_index.len());
|
||||
@ -3784,7 +3783,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(3, txs.len());
|
||||
assert_eq!(vec![0, 1, 2], tx_packet_index);
|
||||
@ -3795,7 +3794,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(2, txs.len());
|
||||
assert_eq!(vec![0, 2], tx_packet_index);
|
||||
@ -3815,7 +3814,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(3, txs.len());
|
||||
assert_eq!(vec![0, 1, 2], tx_packet_index);
|
||||
@ -3826,7 +3825,7 @@ mod tests {
|
||||
&packet_indexes,
|
||||
&Arc::new(FeatureSet::default()),
|
||||
votes_only,
|
||||
|_| Err(TransactionError::UnsupportedVersion),
|
||||
&DisabledAddressLoader,
|
||||
);
|
||||
assert_eq!(3, txs.len());
|
||||
assert_eq!(vec![0, 1, 2], tx_packet_index);
|
||||
|
Reference in New Issue
Block a user