Add runtime support for address table lookups (backport #22223) (#22354)

This commit is contained in:
Justin Starry
2022-01-08 07:57:04 +08:00
committed by GitHub
parent 662c6be51e
commit 1f00926874
21 changed files with 663 additions and 159 deletions

View File

@ -34,7 +34,10 @@ use {
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
},
feature_set,
message::Message,
message::{
v0::{LoadedAddresses, MessageAddressTableLookup},
Message,
},
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
@ -1121,6 +1124,7 @@ impl BankingStage {
transaction_indexes: &[usize],
feature_set: &Arc<feature_set::FeatureSet>,
votes_only: bool,
address_loader: impl Fn(&[MessageAddressTableLookup]) -> transaction::Result<LoadedAddresses>,
) -> (Vec<SanitizedTransaction>, Vec<usize>) {
transaction_indexes
.iter()
@ -1137,7 +1141,7 @@ impl BankingStage {
tx,
message_hash,
Some(p.meta.is_simple_vote_tx()),
|_| Err(TransactionError::UnsupportedVersion),
&address_loader,
)
.ok()?;
tx.verify_precompiles(feature_set).ok()?;
@ -1203,6 +1207,7 @@ impl BankingStage {
&packet_indexes,
&bank.feature_set,
bank.vote_only_bank(),
|lookup| bank.load_lookup_table_addresses(lookup),
);
packet_conversion_time.stop();
inc_new_counter_info!("banking_stage-packet_conversion", 1);
@ -1277,6 +1282,7 @@ impl BankingStage {
transaction_indexes,
&bank.feature_set,
bank.vote_only_bank(),
|lookup| bank.load_lookup_table_addresses(lookup),
);
unprocessed_packet_conversion_time.stop();
@ -3226,6 +3232,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(2, txs.len());
assert_eq!(vec![0, 1], tx_packet_index);
@ -3236,6 +3243,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(0, txs.len());
assert_eq!(0, tx_packet_index.len());
@ -3255,6 +3263,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(3, txs.len());
assert_eq!(vec![0, 1, 2], tx_packet_index);
@ -3265,6 +3274,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(2, txs.len());
assert_eq!(vec![0, 2], tx_packet_index);
@ -3284,6 +3294,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(3, txs.len());
assert_eq!(vec![0, 1, 2], tx_packet_index);
@ -3294,6 +3305,7 @@ mod tests {
&packet_indexes,
&Arc::new(FeatureSet::default()),
votes_only,
|_| Err(TransactionError::UnsupportedVersion),
);
assert_eq!(3, txs.len());
assert_eq!(vec![0, 1, 2], tx_packet_index);