Store FeeCalculator with blockhash in nonce accounts (#8650)
* Copy current state version to v0 * Add `FeeCalculator` to nonce state * fixup compile * Dump v0 handling... Since we new account data is all zeros, new `Current` versioned accounts look like v0. We could hack around this with some data size checks, but the `account_utils::*State` traits are applied to `Account`, not the state data, so we're kind SOL... * Create more representative test `RecentBlockhashes` * Improve CLI nonce account display Co-Authored-By: Michael Vines <mvines@gmail.com> * Fix that last bank test... * clippy/fmt Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -3269,6 +3269,7 @@ mod tests {
|
||||
nonce::state::Versions::new_current(nonce::State::Initialized(nonce::state::Data {
|
||||
authority: config.signers[0].pubkey(),
|
||||
blockhash,
|
||||
fee_calculator: FeeCalculator::default(),
|
||||
}));
|
||||
let nonce_response = json!(Response {
|
||||
context: RpcResponseContext { slot: 1 },
|
||||
@ -3297,6 +3298,7 @@ mod tests {
|
||||
nonce::state::Versions::new_current(nonce::State::Initialized(nonce::state::Data {
|
||||
authority: bob_pubkey,
|
||||
blockhash,
|
||||
fee_calculator: FeeCalculator::default(),
|
||||
}));
|
||||
let nonce_authority_response = json!(Response {
|
||||
context: RpcResponseContext { slot: 1 },
|
||||
|
@ -569,10 +569,15 @@ pub fn process_show_nonce_account(
|
||||
match data {
|
||||
Some(ref data) => {
|
||||
println!("Nonce: {}", data.blockhash);
|
||||
println!(
|
||||
"Fee: {} lamports per signature",
|
||||
data.fee_calculator.lamports_per_signature
|
||||
);
|
||||
println!("Authority: {}", data.authority);
|
||||
}
|
||||
None => {
|
||||
println!("Nonce: uninitialized");
|
||||
println!("Fees: uninitialized");
|
||||
println!("Authority: uninitialized");
|
||||
}
|
||||
}
|
||||
@ -626,6 +631,7 @@ mod tests {
|
||||
use crate::cli::{app, parse_command};
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::hash,
|
||||
nonce::{self, State},
|
||||
signature::{read_keypair_file, write_keypair, Keypair, Signer},
|
||||
@ -906,6 +912,7 @@ mod tests {
|
||||
let data = Versions::new_current(State::Initialized(nonce::state::Data {
|
||||
authority: nonce_pubkey,
|
||||
blockhash,
|
||||
fee_calculator: FeeCalculator::default(),
|
||||
}));
|
||||
let valid = Account::new_data(1, &data, &system_program::ID);
|
||||
assert!(check_nonce_account(&valid.unwrap(), &nonce_pubkey, &blockhash).is_ok());
|
||||
@ -929,6 +936,7 @@ mod tests {
|
||||
let data = Versions::new_current(State::Initialized(nonce::state::Data {
|
||||
authority: nonce_pubkey,
|
||||
blockhash: hash(b"invalid"),
|
||||
fee_calculator: FeeCalculator::default(),
|
||||
}));
|
||||
let invalid_hash = Account::new_data(1, &data, &system_program::ID);
|
||||
assert_eq!(
|
||||
@ -939,6 +947,7 @@ mod tests {
|
||||
let data = Versions::new_current(State::Initialized(nonce::state::Data {
|
||||
authority: Pubkey::new_rand(),
|
||||
blockhash,
|
||||
fee_calculator: FeeCalculator::default(),
|
||||
}));
|
||||
let invalid_authority = Account::new_data(1, &data, &system_program::ID);
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user