diff --git a/banks-server/src/banks_server.rs b/banks-server/src/banks_server.rs index bc04a38feef3f8..6744154d5e4398 100644 --- a/banks-server/src/banks_server.rs +++ b/banks-server/src/banks_server.rs @@ -181,7 +181,7 @@ fn simulate_transaction( ) -> BanksTransactionResultWithSimulation { let sanitized_transaction = match RuntimeTransaction::try_create( transaction, - None, // message_hash + MessageHash::Compute, Some(false), // is_simple_vote_tx bank, bank.get_reserved_account_keys(), diff --git a/core/src/banking_stage/consume_worker.rs b/core/src/banking_stage/consume_worker.rs index abf1de27b20064..37f5bf6ac5dc7e 100644 --- a/core/src/banking_stage/consume_worker.rs +++ b/core/src/banking_stage/consume_worker.rs @@ -722,7 +722,7 @@ mod tests { signature::Keypair, signer::Signer, system_instruction, system_transaction, - transaction::VersionedTransaction, + transaction::{MessageHash, VersionedTransaction}, }, solana_svm_transaction::svm_message::SVMMessage, std::{ @@ -1092,7 +1092,7 @@ mod tests { &[&payer], ) .unwrap(), - None, + MessageHash::Compute, None, loader, &HashSet::default(), diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index 94f25d2a2a99a0..ac118c77d243ca 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -906,6 +906,7 @@ mod tests { thread::{Builder, JoinHandle}, time::Duration, }, + transaction::MessageHash, }; fn execute_transactions_with_dummy_poh_service( @@ -2065,7 +2066,7 @@ mod tests { let tx = VersionedTransaction::try_new(message, &[&keypair]).unwrap(); let sanitized_tx = RuntimeTransaction::try_create( tx.clone(), - None, + MessageHash::Compute, Some(false), bank.as_ref(), &ReservedAccountKeys::empty_key_set(), diff --git a/core/src/banking_stage/immutable_deserialized_packet.rs b/core/src/banking_stage/immutable_deserialized_packet.rs index 85c77a109bdfde..afd5d34dc4fd16 100644 --- a/core/src/banking_stage/immutable_deserialized_packet.rs +++ b/core/src/banking_stage/immutable_deserialized_packet.rs @@ -14,7 +14,9 @@ use { message::{v0::LoadedAddresses, AddressLoaderError, Message, SimpleAddressLoader}, pubkey::Pubkey, signature::Signature, - transaction::{SanitizedTransaction, SanitizedVersionedTransaction, VersionedTransaction}, + transaction::{ + MessageHash, SanitizedTransaction, SanitizedVersionedTransaction, VersionedTransaction, + }, }, solana_short_vec::decode_shortu16_len, solana_svm_transaction::{ @@ -132,7 +134,7 @@ impl ImmutableDeserializedPacket { let address_loader = SimpleAddressLoader::Enabled(loaded_addresses); let tx = RuntimeTransaction::::try_from( self.transaction.clone(), - Some(self.message_hash), + MessageHash::Precomputed(self.message_hash), Some(self.is_simple_vote), ) .and_then(|tx| { diff --git a/cost-model/src/transaction_cost.rs b/cost-model/src/transaction_cost.rs index fb9ebb956db7bb..712e11378f75a7 100644 --- a/cost-model/src/transaction_cost.rs +++ b/cost-model/src/transaction_cost.rs @@ -234,8 +234,11 @@ mod tests { solana_feature_set::FeatureSet, solana_runtime_transaction::runtime_transaction::RuntimeTransaction, solana_sdk::{ - hash::Hash, message::SimpleAddressLoader, reserved_account_keys::ReservedAccountKeys, - signer::keypair::Keypair, transaction::VersionedTransaction, + hash::Hash, + message::SimpleAddressLoader, + reserved_account_keys::ReservedAccountKeys, + signer::keypair::Keypair, + transaction::{MessageHash, VersionedTransaction}, }, solana_vote_program::{vote_state::TowerSync, vote_transaction}, }; @@ -258,7 +261,7 @@ mod tests { // create a sanitized vote transaction let vote_transaction = RuntimeTransaction::try_create( VersionedTransaction::from(transaction.clone()), - None, + MessageHash::Compute, Some(true), SimpleAddressLoader::Disabled, &ReservedAccountKeys::empty_key_set(), @@ -268,7 +271,7 @@ mod tests { // create a identical sanitized transaction, but identified as non-vote let none_vote_transaction = RuntimeTransaction::try_create( VersionedTransaction::from(transaction), - None, + MessageHash::Compute, Some(false), SimpleAddressLoader::Disabled, &ReservedAccountKeys::empty_key_set(), diff --git a/entry/benches/entry_sigverify.rs b/entry/benches/entry_sigverify.rs index d91f63ce91f951..7df8eb017ff8b5 100644 --- a/entry/benches/entry_sigverify.rs +++ b/entry/benches/entry_sigverify.rs @@ -8,8 +8,8 @@ use { hash::Hash, reserved_account_keys::ReservedAccountKeys, transaction::{ - Result, SanitizedTransaction, SimpleAddressLoader, TransactionVerificationMode, - VersionedTransaction, + MessageHash, Result, SanitizedTransaction, SimpleAddressLoader, + TransactionVerificationMode, VersionedTransaction, }, }, std::sync::Arc, @@ -40,7 +40,7 @@ fn bench_gpusigverify(bencher: &mut Bencher) { RuntimeTransaction::try_create( versioned_tx, - Some(message_hash), + MessageHash::Precomputed(message_hash), None, SimpleAddressLoader::Disabled, &ReservedAccountKeys::empty_key_set(), @@ -84,7 +84,7 @@ fn bench_cpusigverify(bencher: &mut Bencher) { let message_hash = versioned_tx.verify_and_hash_message()?; RuntimeTransaction::try_create( versioned_tx, - Some(message_hash), + MessageHash::Precomputed(message_hash), None, SimpleAddressLoader::Disabled, &ReservedAccountKeys::empty_key_set(), diff --git a/entry/src/entry.rs b/entry/src/entry.rs index 7de3245ab35682..e044c932d00a09 100644 --- a/entry/src/entry.rs +++ b/entry/src/entry.rs @@ -1001,7 +1001,8 @@ mod tests { signature::{Keypair, Signer}, system_transaction, transaction::{ - Result, SanitizedTransaction, SimpleAddressLoader, VersionedTransaction, + MessageHash, Result, SanitizedTransaction, SimpleAddressLoader, + VersionedTransaction, }, }, }; @@ -1097,7 +1098,7 @@ mod tests { RuntimeTransaction::try_create( versioned_tx, - Some(message_hash), + MessageHash::Precomputed(message_hash), None, SimpleAddressLoader::Disabled, &ReservedAccountKeys::empty_key_set(), diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 797eed56e7774a..1c5b1e28acdf01 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -74,7 +74,7 @@ use { shred_version::compute_shred_version, stake::{self, state::StakeStateV2}, system_program, - transaction::SimpleAddressLoader, + transaction::{MessageHash, SimpleAddressLoader}, }, solana_stake_program::{points::PointValue, stake_state}, solana_transaction_status::parse_ui_instruction, @@ -475,7 +475,7 @@ fn compute_slot_cost( .filter_map(|transaction| { RuntimeTransaction::try_create( transaction, - None, + MessageHash::Compute, None, SimpleAddressLoader::Disabled, &reserved_account_keys.active, diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 58753eb859b952..c8ae831e49c6cc 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -76,8 +76,8 @@ use { signature::{Keypair, Signature, Signer}, system_instruction, transaction::{ - self, AddressLoader, SanitizedTransaction, TransactionError, VersionedTransaction, - MAX_TX_ACCOUNT_LOCKS, + self, AddressLoader, MessageHash, SanitizedTransaction, TransactionError, + VersionedTransaction, MAX_TX_ACCOUNT_LOCKS, }, }, solana_send_transaction_service::{ @@ -4215,7 +4215,7 @@ fn sanitize_transaction( ) -> Result> { RuntimeTransaction::try_create( transaction, - None, + MessageHash::Compute, None, address_loader, reserved_account_keys, diff --git a/runtime-transaction/src/runtime_transaction.rs b/runtime-transaction/src/runtime_transaction.rs index 254cfbf8b20a6a..e611f0353a6ce6 100644 --- a/runtime-transaction/src/runtime_transaction.rs +++ b/runtime-transaction/src/runtime_transaction.rs @@ -25,7 +25,8 @@ use { signature::Signature, simple_vote_transaction_checker::is_simple_vote_transaction, transaction::{ - Result, SanitizedTransaction, SanitizedVersionedTransaction, VersionedTransaction, + MessageHash, Result, SanitizedTransaction, SanitizedVersionedTransaction, + VersionedTransaction, }, }, solana_svm_transaction::{ @@ -73,13 +74,15 @@ impl Deref for RuntimeTransaction { impl RuntimeTransaction { pub fn try_from( sanitized_versioned_tx: SanitizedVersionedTransaction, - message_hash: Option, + message_hash: MessageHash, is_simple_vote_tx: Option, ) -> Result { + let message_hash = match message_hash { + MessageHash::Precomputed(hash) => hash, + MessageHash::Compute => sanitized_versioned_tx.get_message().message.hash(), + }; let is_simple_vote_tx = is_simple_vote_tx .unwrap_or_else(|| is_simple_vote_transaction(&sanitized_versioned_tx)); - let message_hash = - message_hash.unwrap_or_else(|| sanitized_versioned_tx.get_message().message.hash()); let precompile_signature_details = get_precompile_signature_details( sanitized_versioned_tx @@ -122,7 +125,7 @@ impl RuntimeTransaction { /// unsanitized `VersionedTransaction`. pub fn try_create( tx: VersionedTransaction, - message_hash: Option, + message_hash: MessageHash, is_simple_vote_tx: Option, address_loader: impl AddressLoader, reserved_account_keys: &HashSet, @@ -178,7 +181,7 @@ impl RuntimeTransaction { let versioned_transaction = VersionedTransaction::from(transaction); Self::try_create( versioned_transaction, - None, + MessageHash::Compute, None, solana_sdk::message::SimpleAddressLoader::Disabled, &HashSet::new(), @@ -361,10 +364,14 @@ mod tests { svt: SanitizedVersionedTransaction, is_simple_vote: Option, ) -> bool { - RuntimeTransaction::::try_from(svt, None, is_simple_vote) - .unwrap() - .meta - .is_simple_vote_transaction + RuntimeTransaction::::try_from( + svt, + MessageHash::Compute, + is_simple_vote, + ) + .unwrap() + .meta + .is_simple_vote_transaction } assert!(!get_is_simple_vote( @@ -395,7 +402,7 @@ mod tests { let statically_loaded_transaction = RuntimeTransaction::::try_from( non_vote_sanitized_versioned_transaction(), - Some(hash), + MessageHash::Precomputed(hash), None, ) .unwrap(); @@ -430,7 +437,7 @@ mod tests { .add_compute_unit_price(compute_unit_price) .add_loaded_accounts_bytes(loaded_accounts_bytes) .to_sanitized_versioned_transaction(), - Some(hash), + MessageHash::Precomputed(hash), None, ) .unwrap(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 777a1e45f795d9..1ba2ba191acff7 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -152,7 +152,7 @@ use { sysvar::{self, last_restart_slot::LastRestartSlot, Sysvar, SysvarId}, timing::years_as_slots, transaction::{ - Result, SanitizedTransaction, Transaction, TransactionError, + MessageHash, Result, SanitizedTransaction, Transaction, TransactionError, TransactionVerificationMode, VersionedTransaction, MAX_TX_ACCOUNT_LOCKS, }, transaction_context::{TransactionAccount, TransactionReturnData}, @@ -3421,7 +3421,7 @@ impl Bank { .map(|tx| { RuntimeTransaction::try_create( tx, - None, + MessageHash::Compute, None, self, self.get_reserved_account_keys(), @@ -5850,7 +5850,7 @@ impl Bank { RuntimeTransaction::try_create( tx, - Some(message_hash), + MessageHash::Precomputed(message_hash), None, self, self.get_reserved_account_keys(),