Skip to content

Commit

Permalink
use SVMTransactionAdapter for as_sanitized_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Oct 30, 2024
1 parent abc2691 commit 2c50748
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions core/src/banking_stage/committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use {
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
},
solana_runtime_transaction::svm_transaction_adapter::SVMTransactionAdapter,
solana_sdk::{pubkey::Pubkey, saturating_add_assign, transaction::SanitizedTransaction},
solana_svm::{
transaction_commit_result::{TransactionCommitResult, TransactionCommitResultExtensions},
Expand All @@ -22,7 +23,7 @@ use {
solana_transaction_status::{
token_balances::TransactionTokenBalancesSet, TransactionTokenBalance,
},
std::{collections::HashMap, ops::Deref, sync::Arc},
std::{borrow::Borrow, collections::HashMap, sync::Arc},
};

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -139,7 +140,7 @@ impl Committer {
let txs = batch
.sanitized_transactions()
.iter()
.map(|tx| tx.deref().clone())
.map(|tx| tx.as_sanitized_transaction().borrow().clone())
.collect_vec();
let post_balances = bank.collect_balances(batch);
let post_token_balances =
Expand Down
9 changes: 6 additions & 3 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ use {
transaction_batch::{OwnedOrBorrowed, TransactionBatch},
vote_sender_types::ReplayVoteSender,
},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_runtime_transaction::{
runtime_transaction::RuntimeTransaction, svm_transaction_adapter::SVMTransactionAdapter,
},
solana_sdk::{
clock::{Slot, MAX_PROCESSING_AGE},
genesis_config::GenesisConfig,
Expand All @@ -60,8 +62,9 @@ use {
solana_transaction_status::token_balances::TransactionTokenBalancesSet,
solana_vote::vote_account::VoteAccountsHashMap,
std::{
borrow::Borrow,
collections::{HashMap, HashSet},
ops::{Deref, Index, Range},
ops::{Index, Range},
path::PathBuf,
result,
sync::{
Expand Down Expand Up @@ -205,7 +208,7 @@ pub fn execute_batch(
let transactions: Vec<SanitizedTransaction> = batch
.sanitized_transactions()
.iter()
.map(|tx| tx.deref().clone())
.map(|tx| tx.as_sanitized_transaction().borrow().clone())
.collect();
let post_token_balances = if record_token_balances {
collect_token_balances(bank, batch, &mut mint_decimals)
Expand Down
13 changes: 7 additions & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ use {
},
solana_runtime_transaction::{
instructions_processor::process_compute_budget_instructions,
runtime_transaction::RuntimeTransaction,
runtime_transaction::RuntimeTransaction, svm_transaction_adapter::SVMTransactionAdapter,
transaction_meta::StaticMeta,
},
solana_sdk::{
account::{
Expand Down Expand Up @@ -186,7 +187,7 @@ use {
collections::{HashMap, HashSet},
convert::TryFrom,
fmt,
ops::{AddAssign, Deref, RangeFull, RangeInclusive},
ops::{AddAssign, RangeFull, RangeInclusive},
path::PathBuf,
slice,
sync::{
Expand Down Expand Up @@ -3309,7 +3310,7 @@ impl Bank {
// 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(
tx.message().recent_blockhash(),
tx.recent_blockhash(),
tx.message_hash(),
self.slot(),
processed_tx.status(),
Expand All @@ -3318,7 +3319,7 @@ impl Bank {
// can be queried by transaction signature over RPC. In the future, this should
// only be added for API nodes because voting validators don't need to do this.
status_cache.insert(
tx.message().recent_blockhash(),
tx.recent_blockhash(),
tx.signature(),
self.slot(),
processed_tx.status(),
Expand Down Expand Up @@ -4036,7 +4037,7 @@ impl Bank {
.then(|| {
sanitized_txs
.iter()
.map(|tx| tx.deref())
.map(|tx| tx.as_sanitized_transaction())
.collect::<Vec<_>>()
});

Expand Down Expand Up @@ -6316,7 +6317,7 @@ impl Bank {
})
.filter(|(_, executed_tx)| executed_tx.was_successful())
.flat_map(|(tx, executed_tx)| {
let num_account_keys = tx.message().account_keys().len();
let num_account_keys = tx.account_keys().len();
let loaded_tx = &executed_tx.loaded_transaction;
loaded_tx.accounts.iter().take(num_account_keys)
})
Expand Down

0 comments on commit 2c50748

Please sign in to comment.