Skip to content

Commit

Permalink
generic get nonce and ix signers (#2826)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Sep 25, 2024
1 parent ba03bd1 commit 56672cd
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 7 deletions.
1 change: 1 addition & 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 programs/sbf/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 runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ solana-loader-v4-program = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-perf = { workspace = true }
solana-program = { workspace = true }
solana-program-runtime = { workspace = true }
solana-rayon-threadlimit = { workspace = true }
solana-runtime-transaction = { workspace = true }
Expand Down
12 changes: 6 additions & 6 deletions runtime/src/bank/check_transactions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
super::{Bank, BankStatusCache},
crate::nonce_extraction::{get_durable_nonce, get_ix_signers},
solana_accounts_db::blockhash_queue::BlockhashQueue,
solana_perf::perf_libs,
solana_sdk::{
Expand All @@ -9,7 +10,6 @@ use {
MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
},
message::SanitizedMessage,
nonce::{
state::{
Data as NonceData, DurableNonce, State as NonceState, Versions as NonceVersions,
Expand All @@ -25,6 +25,7 @@ use {
nonce_info::NonceInfo,
transaction_error_metrics::TransactionErrorMetrics,
},
solana_svm_transaction::svm_message::SVMMessage,
};

impl Bank {
Expand Down Expand Up @@ -135,7 +136,7 @@ impl Bank {

pub(super) fn check_load_and_advance_message_nonce_account(
&self,
message: &SanitizedMessage,
message: &impl SVMMessage,
next_durable_nonce: &DurableNonce,
next_lamports_per_signature: u64,
) -> Option<(NonceInfo, u64)> {
Expand Down Expand Up @@ -165,15 +166,14 @@ impl Bank {

pub(super) fn load_message_nonce_account(
&self,
message: &SanitizedMessage,
message: &impl SVMMessage,
) -> Option<(Pubkey, AccountSharedData, NonceData)> {
let nonce_address = message.get_durable_nonce()?;
let nonce_address = get_durable_nonce(message)?;
let nonce_account = self.get_account_with_fixed_root(nonce_address)?;
let nonce_data =
nonce_account::verify_nonce_account(&nonce_account, message.recent_blockhash())?;

let nonce_is_authorized = message
.get_ix_signers(NONCED_TX_MARKER_IX_INDEX as usize)
let nonce_is_authorized = get_ix_signers(message, NONCED_TX_MARKER_IX_INDEX as usize)
.any(|signer| signer == &nonce_data.authority);
if !nonce_is_authorized {
return None;
Expand Down
1 change: 1 addition & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod genesis_utils;
pub mod installed_scheduler_pool;
pub mod loader_utils;
pub mod non_circulating_supply;
mod nonce_extraction;
pub mod prioritization_fee;
pub mod prioritization_fee_cache;
pub mod rent_collector;
Expand Down
Loading

0 comments on commit 56672cd

Please sign in to comment.