Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

remove fee_calculator from nonce data #34959

Closed
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
3 changes: 2 additions & 1 deletion account-decoder/src/parse_nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ pub fn parse_nonce(data: &[u8]) -> Result<UiNonceState, ParseAccountError> {
State::Initialized(data) => Ok(UiNonceState::Initialized(UiNonceData {
authority: data.authority.to_string(),
blockhash: data.blockhash().to_string(),
fee_calculator: data.fee_calculator.into(),
// NOTE: plug a dummy fee_calculator for decorder for now.
fee_calculator: UiFeeCalculator::default(),
})),
}
}
Expand Down
33 changes: 2 additions & 31 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,13 @@ impl Accounts {
loaded: &mut [TransactionLoadResult],
rent_collector: &RentCollector,
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
) {
let (accounts_to_store, transactions) = self.collect_accounts_to_store(
txs,
res,
loaded,
rent_collector,
durable_nonce,
lamports_per_signature,
);
self.accounts_db
.store_cached_inline_update_index((slot, &accounts_to_store[..]), Some(&transactions));
Expand All @@ -691,7 +689,6 @@ impl Accounts {
load_results: &'a mut [TransactionLoadResult],
_rent_collector: &RentCollector,
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
) -> (
Vec<(&'a Pubkey, &'a AccountSharedData)>,
Vec<Option<&'a SanitizedTransaction>>,
Expand Down Expand Up @@ -741,7 +738,6 @@ impl Accounts {
is_fee_payer,
maybe_nonce,
durable_nonce,
lamports_per_signature,
);

if execution_status.is_ok() || is_nonce_account || is_fee_payer {
Expand All @@ -763,7 +759,6 @@ fn prepare_if_nonce_account(
is_fee_payer: bool,
maybe_nonce: Option<(&NonceFull, bool)>,
&durable_nonce: &DurableNonce,
lamports_per_signature: u64,
) -> bool {
if let Some((nonce, rollback)) = maybe_nonce {
if address == nonce.address() {
Expand All @@ -786,7 +781,6 @@ fn prepare_if_nonce_account(
let nonce_state = NonceState::new_initialized(
&data.authority,
durable_nonce,
lamports_per_signature,
);
let nonce_versions = NonceVersions::new(nonce_state);
account.set_state(&nonce_versions).unwrap();
Expand Down Expand Up @@ -1583,7 +1577,6 @@ mod tests {
loaded.as_mut_slice(),
&rent_collector,
&DurableNonce::default(),
0,
);
assert_eq!(collected_accounts.len(), 2);
assert!(collected_accounts
Expand Down Expand Up @@ -1639,7 +1632,6 @@ mod tests {
AccountSharedData,
AccountSharedData,
DurableNonce,
u64,
Option<AccountSharedData>,
) {
let data = NonceVersions::new(NonceState::Initialized(nonce::state::Data::default()));
Expand All @@ -1652,7 +1644,6 @@ mod tests {
pre_account,
account,
durable_nonce,
1234,
None,
)
}
Expand All @@ -1664,7 +1655,6 @@ mod tests {
is_fee_payer: bool,
maybe_nonce: Option<(&NonceFull, bool)>,
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
expect_account: &AccountSharedData,
) -> bool {
// Verify expect_account's relationship
Expand All @@ -1684,7 +1674,6 @@ mod tests {
is_fee_payer,
maybe_nonce,
durable_nonce,
lamports_per_signature,
);
assert_eq!(expect_account, account);
expect_account == account
Expand All @@ -1697,7 +1686,6 @@ mod tests {
pre_account,
mut post_account,
blockhash,
lamports_per_signature,
maybe_fee_payer_account,
) = create_accounts_prepare_if_nonce_account();
let post_account_address = pre_account_address;
Expand All @@ -1710,7 +1698,7 @@ mod tests {
let mut expect_account = pre_account;
expect_account
.set_state(&NonceVersions::new(NonceState::Initialized(
nonce::state::Data::new(Pubkey::default(), blockhash, lamports_per_signature),
nonce::state::Data::new(Pubkey::default(), blockhash),
)))
.unwrap();

Expand All @@ -1721,7 +1709,6 @@ mod tests {
false,
Some((&nonce, true)),
&blockhash,
lamports_per_signature,
&expect_account,
));
}
Expand All @@ -1733,7 +1720,6 @@ mod tests {
_pre_account,
_post_account,
blockhash,
lamports_per_signature,
_maybe_fee_payer_account,
) = create_accounts_prepare_if_nonce_account();
let post_account_address = pre_account_address;
Expand All @@ -1747,7 +1733,6 @@ mod tests {
false,
None,
&blockhash,
lamports_per_signature,
&expect_account,
));
}
Expand All @@ -1759,7 +1744,6 @@ mod tests {
pre_account,
mut post_account,
blockhash,
lamports_per_signature,
maybe_fee_payer_account,
) = create_accounts_prepare_if_nonce_account();

Expand All @@ -1774,7 +1758,6 @@ mod tests {
false,
Some((&nonce, true)),
&blockhash,
lamports_per_signature,
&expect_account,
));
}
Expand All @@ -1786,7 +1769,6 @@ mod tests {
pre_account,
mut post_account,
blockhash,
lamports_per_signature,
maybe_fee_payer_account,
) = create_accounts_prepare_if_nonce_account();
let post_account_address = pre_account_address;
Expand All @@ -1796,7 +1778,7 @@ mod tests {

expect_account
.set_state(&NonceVersions::new(NonceState::Initialized(
nonce::state::Data::new(Pubkey::default(), blockhash, lamports_per_signature),
nonce::state::Data::new(Pubkey::default(), blockhash),
)))
.unwrap();

Expand All @@ -1810,7 +1792,6 @@ mod tests {
false,
Some((&nonce, true)),
&blockhash,
lamports_per_signature,
&expect_account,
));
}
Expand Down Expand Up @@ -1838,7 +1819,6 @@ mod tests {
false,
Some((&nonce, true)),
&DurableNonce::default(),
1,
&post_fee_payer_account,
));

Expand All @@ -1849,7 +1829,6 @@ mod tests {
true,
Some((&nonce, true)),
&DurableNonce::default(),
1,
&post_fee_payer_account,
));

Expand All @@ -1863,7 +1842,6 @@ mod tests {
true,
None,
&DurableNonce::default(),
1,
&post_fee_payer_account,
));

Expand All @@ -1877,7 +1855,6 @@ mod tests {
true,
Some((&nonce, true)),
&DurableNonce::default(),
1,
&pre_fee_payer_account,
));
}
Expand All @@ -1895,7 +1872,6 @@ mod tests {
let nonce_state = NonceVersions::new(NonceState::Initialized(nonce::state::Data::new(
nonce_authority.pubkey(),
durable_nonce,
0,
)));
let nonce_account_post =
AccountSharedData::new_data(43, &nonce_state, &system_program::id()).unwrap();
Expand Down Expand Up @@ -1923,7 +1899,6 @@ mod tests {
let nonce_state = NonceVersions::new(NonceState::Initialized(nonce::state::Data::new(
nonce_authority.pubkey(),
durable_nonce,
0,
)));
let nonce_account_pre =
AccountSharedData::new_data(42, &nonce_state, &system_program::id()).unwrap();
Expand Down Expand Up @@ -1964,7 +1939,6 @@ mod tests {
loaded.as_mut_slice(),
&rent_collector,
&durable_nonce,
0,
);
assert_eq!(collected_accounts.len(), 2);
assert_eq!(
Expand Down Expand Up @@ -2005,7 +1979,6 @@ mod tests {
let nonce_state = NonceVersions::new(NonceState::Initialized(nonce::state::Data::new(
nonce_authority.pubkey(),
durable_nonce,
0,
)));
let nonce_account_post =
AccountSharedData::new_data(43, &nonce_state, &system_program::id()).unwrap();
Expand Down Expand Up @@ -2033,7 +2006,6 @@ mod tests {
let nonce_state = NonceVersions::new(NonceState::Initialized(nonce::state::Data::new(
nonce_authority.pubkey(),
durable_nonce,
0,
)));
let nonce_account_pre =
AccountSharedData::new_data(42, &nonce_state, &system_program::id()).unwrap();
Expand Down Expand Up @@ -2073,7 +2045,6 @@ mod tests {
loaded.as_mut_slice(),
&rent_collector,
&durable_nonce,
0,
);
assert_eq!(collected_accounts.len(), 1);
let collected_nonce_account = collected_accounts
Expand Down
17 changes: 0 additions & 17 deletions accounts-db/src/nonce_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use {
solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
message::SanitizedMessage,
nonce_account,
pubkey::Pubkey,
transaction::{self, TransactionError},
transaction_context::TransactionAccount,
Expand All @@ -13,7 +12,6 @@ use {
pub trait NonceInfo {
fn address(&self) -> &Pubkey;
fn account(&self) -> &AccountSharedData;
fn lamports_per_signature(&self) -> Option<u64>;
fn fee_payer_account(&self) -> Option<&AccountSharedData>;
}

Expand All @@ -37,9 +35,6 @@ impl NonceInfo for NoncePartial {
fn account(&self) -> &AccountSharedData {
&self.account
}
fn lamports_per_signature(&self) -> Option<u64> {
nonce_account::lamports_per_signature_of(&self.account)
}
fn fee_payer_account(&self) -> Option<&AccountSharedData> {
None
}
Expand Down Expand Up @@ -108,9 +103,6 @@ impl NonceInfo for NonceFull {
fn account(&self) -> &AccountSharedData {
&self.account
}
fn lamports_per_signature(&self) -> Option<u64> {
nonce_account::lamports_per_signature_of(&self.account)
}
fn fee_payer_account(&self) -> Option<&AccountSharedData> {
self.fee_payer_account.as_ref()
}
Expand Down Expand Up @@ -139,8 +131,6 @@ mod tests {

#[test]
fn test_nonce_info() {
let lamports_per_signature = 42;

let nonce_authority = keypair_from_seed(&[0; 32]).unwrap();
let nonce_address = nonce_authority.pubkey();
let from = keypair_from_seed(&[1; 32]).unwrap();
Expand All @@ -153,7 +143,6 @@ mod tests {
&nonce::state::Versions::new(nonce::State::Initialized(nonce::state::Data::new(
Pubkey::default(),
durable_nonce,
lamports_per_signature,
))),
&system_program::id(),
)
Expand Down Expand Up @@ -183,10 +172,6 @@ mod tests {
let partial = NoncePartial::new(nonce_address, rent_collected_nonce_account.clone());
assert_eq!(*partial.address(), nonce_address);
assert_eq!(*partial.account(), rent_collected_nonce_account);
assert_eq!(
partial.lamports_per_signature(),
Some(lamports_per_signature)
);
assert_eq!(partial.fee_payer_account(), None);

// Add rent debits to ensure the rollback captures accounts without rent fees
Expand Down Expand Up @@ -225,7 +210,6 @@ mod tests {
NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap();
assert_eq!(*full.address(), nonce_address);
assert_eq!(*full.account(), rent_collected_nonce_account);
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
assert_eq!(
full.fee_payer_account(),
Some(&from_account),
Expand Down Expand Up @@ -256,7 +240,6 @@ mod tests {
NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap();
assert_eq!(*full.address(), nonce_address);
assert_eq!(*full.account(), nonce_account);
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
assert_eq!(full.fee_payer_account(), None);
}

Expand Down
10 changes: 4 additions & 6 deletions accounts-db/src/transaction_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pub use solana_sdk::inner_instruction::{InnerInstruction, InnerInstructionsList};
use {
crate::{
nonce_info::{NonceFull, NonceInfo, NoncePartial},
nonce_info::{NonceFull, NoncePartial},
rent_debits::RentDebits,
},
solana_program_runtime::loaded_programs::LoadedProgramsForTxBatch,
Expand Down Expand Up @@ -87,18 +87,16 @@ pub struct TransactionExecutionDetails {
pub accounts_data_len_delta: i64,
}

// TODO - remove `DurableNonceFee` as it'd always be Invalid.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should have a prequel PR to remove DurableNonceFee first? Will that break something else?

#[derive(Debug, Clone)]
pub enum DurableNonceFee {
Valid(u64),
Invalid,
}

impl From<&NonceFull> for DurableNonceFee {
fn from(nonce: &NonceFull) -> Self {
match nonce.lamports_per_signature() {
Some(lamports_per_signature) => Self::Valid(lamports_per_signature),
None => Self::Invalid,
}
fn from(_nonce: &NonceFull) -> Self {
Self::Invalid
}
}

Expand Down
Loading
Loading