Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransactionBatch - hold RuntimeTransaction #3041

Merged
Merged
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions banks-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ solana-banks-interface = { workspace = true }
solana-client = { workspace = true }
solana-feature-set = { workspace = true }
solana-runtime = { workspace = true }
solana-runtime-transaction = { workspace = true }
solana-sdk = { workspace = true }
solana-send-transaction-service = { workspace = true }
solana-svm = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use {
commitment::BlockCommitmentCache,
verify_precompiles::verify_precompiles,
},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{
account::Account,
clock::Slot,
Expand Down Expand Up @@ -178,7 +179,7 @@ fn simulate_transaction(
bank: &Bank,
transaction: VersionedTransaction,
) -> BanksTransactionResultWithSimulation {
let sanitized_transaction = match SanitizedTransaction::try_create(
let sanitized_transaction = match RuntimeTransaction::try_create(
transaction,
MessageHash::Compute,
Some(false), // is_simple_vote_tx
Expand Down
5 changes: 3 additions & 2 deletions core/benches/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use {
poh_service::PohService,
},
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{
account::{Account, ReadableAccount},
signature::Keypair,
Expand Down Expand Up @@ -66,7 +67,7 @@ fn create_funded_accounts(bank: &Bank, num: usize) -> Vec<Keypair> {
accounts
}

fn create_transactions(bank: &Bank, num: usize) -> Vec<SanitizedTransaction> {
fn create_transactions(bank: &Bank, num: usize) -> Vec<RuntimeTransaction<SanitizedTransaction>> {
let funded_accounts = create_funded_accounts(bank, 2 * num);
funded_accounts
.into_par_iter()
Expand All @@ -76,7 +77,7 @@ fn create_transactions(bank: &Bank, num: usize) -> Vec<SanitizedTransaction> {
let to = &chunk[1];
system_transaction::transfer(from, &to.pubkey(), 1, bank.last_blockhash())
})
.map(SanitizedTransaction::from_transaction_for_tests)
.map(RuntimeTransaction::from_transaction_for_tests)
.collect()
}

Expand Down
7 changes: 5 additions & 2 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ mod tests {
poh_service::PohService,
},
solana_runtime::{bank::Bank, genesis_utils::bootstrap_validator_stake_lamports},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{
hash::Hash,
poh_config::PohConfig,
Expand All @@ -867,9 +868,11 @@ mod tests {
(node, cluster_info)
}

pub(crate) fn sanitize_transactions(txs: Vec<Transaction>) -> Vec<SanitizedTransaction> {
pub(crate) fn sanitize_transactions(
txs: Vec<Transaction>,
) -> Vec<RuntimeTransaction<SanitizedTransaction>> {
txs.into_iter()
.map(SanitizedTransaction::from_transaction_for_tests)
.map(RuntimeTransaction::from_transaction_for_tests)
.collect()
}

Expand Down
11 changes: 9 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, sync::Arc},
std::{borrow::Borrow, collections::HashMap, sync::Arc},
};

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -134,7 +135,13 @@ impl Committer {
starting_transaction_index: Option<usize>,
) {
if let Some(transaction_status_sender) = &self.transaction_status_sender {
let txs = batch.sanitized_transactions().to_vec();
// Clone `SanitizedTransaction` out of `RuntimeTransaction`, this is
// done to send over the status sender.
let txs = batch
.sanitized_transactions()
.iter()
.map(|tx| tx.as_sanitized_transaction().borrow().clone())
.collect_vec();
let post_balances = bank.collect_balances(batch);
let post_token_balances =
collect_token_balances(bank, batch, &mut pre_balance_info.mint_decimals);
Expand Down
7 changes: 3 additions & 4 deletions core/src/banking_stage/consume_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ mod tests {
bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache,
vote_sender_types::ReplayVoteReceiver,
},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{
address_lookup_table::AddressLookupTableAccount,
clock::{Slot, MAX_PROCESSING_AGE},
Expand All @@ -746,9 +747,7 @@ mod tests {
signature::Keypair,
signer::Signer,
system_instruction, system_transaction,
transaction::{
MessageHash, SanitizedTransaction, TransactionError, VersionedTransaction,
},
transaction::{MessageHash, TransactionError, VersionedTransaction},
},
solana_svm_transaction::svm_message::SVMMessage,
std::{
Expand Down Expand Up @@ -1101,7 +1100,7 @@ mod tests {
readonly: vec![],
};
let loader = SimpleAddressLoader::Enabled(loaded_addresses);
SanitizedTransaction::try_create(
RuntimeTransaction::try_create(
VersionedTransaction::try_new(
VersionedMessage::V0(
v0::Message::try_compile(
Expand Down
22 changes: 13 additions & 9 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use {
transaction_batch::TransactionBatch,
verify_precompiles::verify_precompiles,
},
solana_runtime_transaction::instructions_processor::process_compute_budget_instructions,
solana_runtime_transaction::{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that execute_and_commit_transactions_locked is recomputing the compute budget details still rather than using them from runtime tx?

instructions_processor::process_compute_budget_instructions,
runtime_transaction::RuntimeTransaction,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also how come check_fee_payer_unlocked isn't using runtime tx now?

},
solana_sdk::{
clock::{FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET, MAX_PROCESSING_AGE},
fee::FeeBudgetLimits,
Expand Down Expand Up @@ -228,7 +231,7 @@ impl Consumer {
&self,
bank: &Arc<Bank>,
bank_creation_time: &Instant,
sanitized_transactions: &[SanitizedTransaction],
sanitized_transactions: &[RuntimeTransaction<SanitizedTransaction>],
banking_stage_stats: &BankingStageStats,
slot_metrics_tracker: &mut LeaderSlotMetricsTracker,
) -> ProcessTransactionsSummary {
Expand Down Expand Up @@ -284,7 +287,7 @@ impl Consumer {
&self,
bank: &Arc<Bank>,
bank_creation_time: &Instant,
transactions: &[SanitizedTransaction],
transactions: &[RuntimeTransaction<SanitizedTransaction>],
) -> ProcessTransactionsSummary {
let mut chunk_start = 0;
let mut all_retryable_tx_indexes = vec![];
Expand Down Expand Up @@ -386,7 +389,7 @@ impl Consumer {
pub fn process_and_record_transactions(
&self,
bank: &Arc<Bank>,
txs: &[SanitizedTransaction],
txs: &[RuntimeTransaction<SanitizedTransaction>],
chunk_offset: usize,
) -> ProcessTransactionBatchOutput {
let mut error_counters = TransactionErrorMetrics::default();
Expand Down Expand Up @@ -429,7 +432,7 @@ impl Consumer {
pub fn process_and_record_aged_transactions(
&self,
bank: &Arc<Bank>,
txs: &[SanitizedTransaction],
txs: &[RuntimeTransaction<SanitizedTransaction>],
max_ages: &[MaxAge],
) -> ProcessTransactionBatchOutput {
let move_precompile_verification_to_svm = bank
Expand Down Expand Up @@ -473,7 +476,7 @@ impl Consumer {
fn process_and_record_transactions_with_pre_results(
&self,
bank: &Arc<Bank>,
txs: &[SanitizedTransaction],
txs: &[RuntimeTransaction<SanitizedTransaction>],
chunk_offset: usize,
pre_results: impl Iterator<Item = Result<(), TransactionError>>,
) -> ProcessTransactionBatchOutput {
Expand Down Expand Up @@ -803,7 +806,7 @@ impl Consumer {
/// * `pending_indexes` - identifies which indexes in the `transactions` list are still pending
fn filter_pending_packets_from_pending_txs(
bank: &Bank,
transactions: &[SanitizedTransaction],
transactions: &[RuntimeTransaction<SanitizedTransaction>],
pending_indexes: &[usize],
) -> Vec<usize> {
let filter =
Expand Down Expand Up @@ -887,7 +890,7 @@ mod tests {
signature::Keypair,
signer::Signer,
system_instruction, system_program, system_transaction,
transaction::{MessageHash, Transaction, VersionedTransaction},
transaction::{Transaction, VersionedTransaction},
},
solana_svm::account_loader::CheckedTransactionDetails,
solana_timings::ProgramTiming,
Expand All @@ -902,6 +905,7 @@ mod tests {
thread::{Builder, JoinHandle},
time::Duration,
},
transaction::MessageHash,
};

fn execute_transactions_with_dummy_poh_service(
Expand Down Expand Up @@ -2059,7 +2063,7 @@ mod tests {
});

let tx = VersionedTransaction::try_new(message, &[&keypair]).unwrap();
let sanitized_tx = SanitizedTransaction::try_create(
let sanitized_tx = RuntimeTransaction::try_create(
tx.clone(),
MessageHash::Compute,
Some(false),
Expand Down
26 changes: 17 additions & 9 deletions core/src/banking_stage/forward_packet_batches_by_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
solana_feature_set::FeatureSet,
solana_perf::packet::Packet,
solana_sdk::transaction::SanitizedTransaction,
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_svm_transaction::svm_message::SVMMessage,
std::sync::Arc,
};
Expand Down Expand Up @@ -106,7 +106,7 @@ impl ForwardPacketBatchesByAccounts {

pub fn try_add_packet(
&mut self,
sanitized_transaction: &SanitizedTransaction,
sanitized_transaction: &RuntimeTransaction<impl SVMMessage>,
immutable_packet: Arc<ImmutableDeserializedPacket>,
feature_set: &FeatureSet,
) -> bool {
Expand Down Expand Up @@ -171,14 +171,15 @@ mod tests {
use {
super::*,
crate::banking_stage::unprocessed_packet_batches::DeserializedPacket,
lazy_static::lazy_static,
solana_cost_model::transaction_cost::{UsageCostDetails, WritableKeysTransaction},
solana_feature_set::FeatureSet,
solana_sdk::{
compute_budget::ComputeBudgetInstruction,
message::{Message, TransactionSignatureDetails},
message::Message,
pubkey::Pubkey,
system_instruction,
transaction::Transaction,
transaction::{SanitizedTransaction, Transaction},
},
};

Expand All @@ -187,7 +188,11 @@ mod tests {
fn build_test_transaction_and_packet(
priority: u64,
write_to_account: &Pubkey,
) -> (SanitizedTransaction, DeserializedPacket, u32) {
) -> (
RuntimeTransaction<SanitizedTransaction>,
DeserializedPacket,
u32,
) {
let from_account = solana_sdk::pubkey::new_rand();

let transaction = Transaction::new_unsigned(Message::new(
Expand All @@ -198,7 +203,7 @@ mod tests {
Some(&from_account),
));
let sanitized_transaction =
SanitizedTransaction::from_transaction_for_tests(transaction.clone());
RuntimeTransaction::from_transaction_for_tests(transaction.clone());
let tx_cost = CostModel::calculate_cost(&sanitized_transaction, &FeatureSet::all_enabled());
let cost = tx_cost.sum();
let deserialized_packet =
Expand All @@ -211,7 +216,10 @@ mod tests {
}

fn zero_transaction_cost() -> TransactionCost<'static, WritableKeysTransaction> {
static DUMMY_TRANSACTION: WritableKeysTransaction = WritableKeysTransaction(vec![]);
lazy_static! {
static ref DUMMY_TRANSACTION: RuntimeTransaction<WritableKeysTransaction> =
RuntimeTransaction::new_for_tests(WritableKeysTransaction(vec![]));
};

TransactionCost::Transaction(UsageCostDetails {
transaction: &DUMMY_TRANSACTION,
Expand All @@ -221,7 +229,6 @@ mod tests {
programs_execution_cost: 0,
loaded_accounts_data_size_cost: 0,
allocated_accounts_data_size: 0,
signature_details: TransactionSignatureDetails::new(0, 0, 0),
})
}

Expand Down Expand Up @@ -370,7 +377,8 @@ mod tests {
ForwardPacketBatchesByAccounts::new_with_default_batch_limits();
forward_packet_batches_by_accounts.batch_vote_limit = test_cost + 1;

let dummy_transaction = WritableKeysTransaction(vec![]);
let dummy_transaction =
RuntimeTransaction::new_for_tests(WritableKeysTransaction(vec![]));
let transaction_cost = TransactionCost::SimpleVote {
transaction: &dummy_transaction,
};
Expand Down
6 changes: 4 additions & 2 deletions core/src/banking_stage/forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ use {
solana_perf::{data_budget::DataBudget, packet::Packet},
solana_poh::poh_recorder::PohRecorder,
solana_runtime::bank_forks::BankForks,
solana_sdk::{pubkey::Pubkey, transaction::SanitizedTransaction, transport::TransportError},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{pubkey::Pubkey, transport::TransportError},
solana_streamer::sendmmsg::batch_send,
solana_svm_transaction::svm_message::SVMMessage,
std::{
iter::repeat,
net::{SocketAddr, UdpSocket},
Expand Down Expand Up @@ -64,7 +66,7 @@ impl<T: LikeClusterInfo> Forwarder<T> {

pub fn try_add_packet(
&mut self,
sanitized_transaction: &SanitizedTransaction,
sanitized_transaction: &RuntimeTransaction<impl SVMMessage>,
immutable_packet: Arc<ImmutableDeserializedPacket>,
feature_set: &FeatureSet,
) -> bool {
Expand Down
Loading
Loading