Verb-noun-ify Nonce API (#7925)

* Verb-noun-ify Nonce API

* Unify instruction naming with API naming

The more verbose nonce_account/NonceAccount was chosen for clarity
that these instructions work on a unique species of system account
This commit is contained in:
Trent Nelson 2020-01-22 16:31:39 -07:00 committed by GitHub
parent 934c32cbc6
commit 964ff522be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 91 deletions

View File

@ -14,8 +14,9 @@ use solana_sdk::{
pubkey::Pubkey, pubkey::Pubkey,
signature::{Keypair, KeypairUtil}, signature::{Keypair, KeypairUtil},
system_instruction::{ system_instruction::{
create_address_with_seed, create_nonce_account, create_nonce_account_with_seed, advance_nonce_account, authorize_nonce_account, create_address_with_seed,
nonce_advance, nonce_authorize, nonce_withdraw, NonceError, SystemError, create_nonce_account, create_nonce_account_with_seed, withdraw_nonce_account, NonceError,
SystemError,
}, },
system_program, system_program,
transaction::Transaction, transaction::Transaction,
@ -379,7 +380,7 @@ pub fn process_authorize_nonce_account(
let nonce_authority = nonce_authority let nonce_authority = nonce_authority
.map(|a| a.keypair()) .map(|a| a.keypair())
.unwrap_or(&config.keypair); .unwrap_or(&config.keypair);
let ix = nonce_authorize(nonce_account, &nonce_authority.pubkey(), new_authority); let ix = authorize_nonce_account(nonce_account, &nonce_authority.pubkey(), new_authority);
let mut tx = Transaction::new_signed_with_payer( let mut tx = Transaction::new_signed_with_payer(
vec![ix], vec![ix],
Some(&config.keypair.pubkey()), Some(&config.keypair.pubkey()),
@ -525,7 +526,7 @@ pub fn process_new_nonce(
let nonce_authority = nonce_authority let nonce_authority = nonce_authority
.map(|a| a.keypair()) .map(|a| a.keypair())
.unwrap_or(&config.keypair); .unwrap_or(&config.keypair);
let ix = nonce_advance(&nonce_account, &nonce_authority.pubkey()); let ix = advance_nonce_account(&nonce_account, &nonce_authority.pubkey());
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?; let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
let mut tx = Transaction::new_signed_with_payer( let mut tx = Transaction::new_signed_with_payer(
vec![ix], vec![ix],
@ -600,7 +601,7 @@ pub fn process_withdraw_from_nonce_account(
let nonce_authority = nonce_authority let nonce_authority = nonce_authority
.map(|a| a.keypair()) .map(|a| a.keypair())
.unwrap_or(&config.keypair); .unwrap_or(&config.keypair);
let ix = nonce_withdraw( let ix = withdraw_nonce_account(
nonce_account, nonce_account,
&nonce_authority.pubkey(), &nonce_authority.pubkey(),
destination_account_pubkey, destination_account_pubkey,

View File

@ -1104,7 +1104,7 @@ impl Bank {
.map(|acc| (*nonce_pubkey, acc)) .map(|acc| (*nonce_pubkey, acc))
}) })
.filter(|(_pubkey, nonce_account)| { .filter(|(_pubkey, nonce_account)| {
nonce_utils::verify_nonce(nonce_account, &tx.message().recent_blockhash) nonce_utils::verify_nonce_account(nonce_account, &tx.message().recent_blockhash)
}) })
} }
@ -4945,7 +4945,7 @@ mod tests {
} }
} }
fn get_nonce(bank: &Bank, nonce_pubkey: &Pubkey) -> Option<Hash> { fn get_nonce_account(bank: &Bank, nonce_pubkey: &Pubkey) -> Option<Hash> {
bank.get_account(&nonce_pubkey) bank.get_account(&nonce_pubkey)
.and_then(|acc| match acc.state() { .and_then(|acc| match acc.state() {
Ok(nonce_state::NonceState::Initialized(_meta, hash)) => Some(hash), Ok(nonce_state::NonceState::Initialized(_meta, hash)) => Some(hash),
@ -5016,10 +5016,10 @@ mod tests {
let custodian_pubkey = custodian_keypair.pubkey(); let custodian_pubkey = custodian_keypair.pubkey();
let nonce_pubkey = nonce_keypair.pubkey(); let nonce_pubkey = nonce_keypair.pubkey();
let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap(); let nonce_hash = get_nonce_account(&bank, &nonce_pubkey).unwrap();
let tx = Transaction::new_signed_with_payer( let tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5040,11 +5040,11 @@ mod tests {
let custodian_pubkey = custodian_keypair.pubkey(); let custodian_pubkey = custodian_keypair.pubkey();
let nonce_pubkey = nonce_keypair.pubkey(); let nonce_pubkey = nonce_keypair.pubkey();
let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap(); let nonce_hash = get_nonce_account(&bank, &nonce_pubkey).unwrap();
let tx = Transaction::new_signed_with_payer( let tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000),
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
&[&custodian_keypair, &nonce_keypair], &[&custodian_keypair, &nonce_keypair],
@ -5060,10 +5060,10 @@ mod tests {
let custodian_pubkey = custodian_keypair.pubkey(); let custodian_pubkey = custodian_keypair.pubkey();
let nonce_pubkey = nonce_keypair.pubkey(); let nonce_pubkey = nonce_keypair.pubkey();
let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap(); let nonce_hash = get_nonce_account(&bank, &nonce_pubkey).unwrap();
let mut tx = Transaction::new_signed_with_payer( let mut tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5083,10 +5083,10 @@ mod tests {
let missing_keypair = Keypair::new(); let missing_keypair = Keypair::new();
let missing_pubkey = missing_keypair.pubkey(); let missing_pubkey = missing_keypair.pubkey();
let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap(); let nonce_hash = get_nonce_account(&bank, &nonce_pubkey).unwrap();
let tx = Transaction::new_signed_with_payer( let tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&missing_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&missing_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5105,7 +5105,7 @@ mod tests {
let tx = Transaction::new_signed_with_payer( let tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &nonce_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5169,7 +5169,7 @@ mod tests {
assert_eq!(bank.get_balance(&nonce_pubkey), 250_000); assert_eq!(bank.get_balance(&nonce_pubkey), 250_000);
/* Grab the hash stored in the nonce account */ /* Grab the hash stored in the nonce account */
let nonce_hash = get_nonce(&bank, &nonce_pubkey).unwrap(); let nonce_hash = get_nonce_account(&bank, &nonce_pubkey).unwrap();
/* Kick nonce hash off the blockhash_queue */ /* Kick nonce hash off the blockhash_queue */
for _ in 0..MAX_RECENT_BLOCKHASHES + 1 { for _ in 0..MAX_RECENT_BLOCKHASHES + 1 {
@ -5193,7 +5193,7 @@ mod tests {
/* Durable Nonce transfer */ /* Durable Nonce transfer */
let durable_tx = Transaction::new_signed_with_payer( let durable_tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5208,13 +5208,13 @@ mod tests {
assert_eq!(bank.get_balance(&alice_pubkey), 100_000); assert_eq!(bank.get_balance(&alice_pubkey), 100_000);
/* Confirm stored nonce has advanced */ /* Confirm stored nonce has advanced */
let new_nonce = get_nonce(&bank, &nonce_pubkey).unwrap(); let new_nonce = get_nonce_account(&bank, &nonce_pubkey).unwrap();
assert_ne!(nonce_hash, new_nonce); assert_ne!(nonce_hash, new_nonce);
/* Durable Nonce re-use fails */ /* Durable Nonce re-use fails */
let durable_tx = Transaction::new_signed_with_payer( let durable_tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000), system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5227,7 +5227,7 @@ mod tests {
); );
/* Check fee not charged and nonce not advanced */ /* Check fee not charged and nonce not advanced */
assert_eq!(bank.get_balance(&custodian_pubkey), 4_640_000); assert_eq!(bank.get_balance(&custodian_pubkey), 4_640_000);
assert_eq!(new_nonce, get_nonce(&bank, &nonce_pubkey).unwrap()); assert_eq!(new_nonce, get_nonce_account(&bank, &nonce_pubkey).unwrap());
let nonce_hash = new_nonce; let nonce_hash = new_nonce;
@ -5239,7 +5239,7 @@ mod tests {
let durable_tx = Transaction::new_signed_with_payer( let durable_tx = Transaction::new_signed_with_payer(
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000_000), system_instruction::transfer(&custodian_pubkey, &alice_pubkey, 100_000_000),
], ],
Some(&custodian_pubkey), Some(&custodian_pubkey),
@ -5255,7 +5255,7 @@ mod tests {
); );
/* Check fee charged and nonce has advanced */ /* Check fee charged and nonce has advanced */
assert_eq!(bank.get_balance(&custodian_pubkey), 4_630_000); assert_eq!(bank.get_balance(&custodian_pubkey), 4_630_000);
assert_ne!(nonce_hash, get_nonce(&bank, &nonce_pubkey).unwrap()); assert_ne!(nonce_hash, get_nonce_account(&bank, &nonce_pubkey).unwrap());
/* Confirm replaying a TX that failed with InstructionError::* now /* Confirm replaying a TX that failed with InstructionError::* now
* fails with TransactionError::BlockhashNotFound * fails with TransactionError::BlockhashNotFound
*/ */

View File

@ -39,7 +39,7 @@ pub fn get_nonce_pubkey_from_instruction<'a>(
}) })
} }
pub fn verify_nonce(acc: &Account, hash: &Hash) -> bool { pub fn verify_nonce_account(acc: &Account, hash: &Hash) -> bool {
match acc.state() { match acc.state() {
Ok(NonceState::Initialized(_meta, ref nonce)) => hash == nonce, Ok(NonceState::Initialized(_meta, ref nonce)) => hash == nonce,
_ => false, _ => false,
@ -93,7 +93,7 @@ mod tests {
let tx = Transaction::new_signed_instructions( let tx = Transaction::new_signed_instructions(
&[&from_keypair, &nonce_keypair], &[&from_keypair, &nonce_keypair],
vec![ vec![
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42), system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
], ],
Hash::default(), Hash::default(),
@ -131,7 +131,7 @@ mod tests {
&[&from_keypair, &nonce_keypair], &[&from_keypair, &nonce_keypair],
vec![ vec![
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42), system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
system_instruction::nonce_advance(&nonce_pubkey, &nonce_pubkey), system_instruction::advance_nonce_account(&nonce_pubkey, &nonce_pubkey),
], ],
Hash::default(), Hash::default(),
); );
@ -147,7 +147,12 @@ mod tests {
let tx = Transaction::new_signed_instructions( let tx = Transaction::new_signed_instructions(
&[&from_keypair, &nonce_keypair], &[&from_keypair, &nonce_keypair],
vec![ vec![
system_instruction::nonce_withdraw(&nonce_pubkey, &nonce_pubkey, &from_pubkey, 42), system_instruction::withdraw_nonce_account(
&nonce_pubkey,
&nonce_pubkey,
&from_pubkey,
42,
),
system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42), system_instruction::transfer(&from_pubkey, &nonce_pubkey, 42),
], ],
Hash::default(), Hash::default(),
@ -194,9 +199,9 @@ mod tests {
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = nonce_account.unsigned_key().clone(); let authorized = nonce_account.unsigned_key().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &Rent::free()) .initialize_nonce_account(&authorized, &recent_blockhashes, &Rent::free())
.unwrap(); .unwrap();
assert!(verify_nonce( assert!(verify_nonce_account(
&nonce_account.account.borrow(), &nonce_account.account.borrow(),
&recent_blockhashes[0] &recent_blockhashes[0]
)); ));
@ -206,7 +211,7 @@ mod tests {
#[test] #[test]
fn verify_nonce_bad_acc_state_fail() { fn verify_nonce_bad_acc_state_fail() {
with_test_keyed_account(42, true, |nonce_account| { with_test_keyed_account(42, true, |nonce_account| {
assert!(!verify_nonce( assert!(!verify_nonce_account(
&nonce_account.account.borrow(), &nonce_account.account.borrow(),
&Hash::default() &Hash::default()
)); ));
@ -224,9 +229,9 @@ mod tests {
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = nonce_account.unsigned_key().clone(); let authorized = nonce_account.unsigned_key().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &Rent::free()) .initialize_nonce_account(&authorized, &recent_blockhashes, &Rent::free())
.unwrap(); .unwrap();
assert!(!verify_nonce( assert!(!verify_nonce_account(
&nonce_account.account.borrow(), &nonce_account.account.borrow(),
&recent_blockhashes[1] &recent_blockhashes[1]
)); ));

View File

@ -237,7 +237,7 @@ pub fn process_instruction(
} }
SystemInstruction::AdvanceNonceAccount => { SystemInstruction::AdvanceNonceAccount => {
let me = &mut next_keyed_account(keyed_accounts_iter)?; let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_advance( me.advance_nonce_account(
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?, &RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
&signers, &signers,
) )
@ -245,7 +245,7 @@ pub fn process_instruction(
SystemInstruction::WithdrawNonceAccount(lamports) => { SystemInstruction::WithdrawNonceAccount(lamports) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?; let me = &mut next_keyed_account(keyed_accounts_iter)?;
let to = &mut next_keyed_account(keyed_accounts_iter)?; let to = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_withdraw( me.withdraw_nonce_account(
lamports, lamports,
to, to,
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?, &RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
@ -255,7 +255,7 @@ pub fn process_instruction(
} }
SystemInstruction::InitializeNonceAccount(authorized) => { SystemInstruction::InitializeNonceAccount(authorized) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?; let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_initialize( me.initialize_nonce_account(
&authorized, &authorized,
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?, &RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
&Rent::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?, &Rent::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
@ -263,7 +263,7 @@ pub fn process_instruction(
} }
SystemInstruction::AuthorizeNonceAccount(nonce_authority) => { SystemInstruction::AuthorizeNonceAccount(nonce_authority) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?; let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_authorize(&nonce_authority, &signers) me.authorize_nonce_account(&nonce_authority, &signers)
} }
SystemInstruction::Allocate { space } => { SystemInstruction::Allocate { space } => {
let keyed_account = next_keyed_account(keyed_accounts_iter)?; let keyed_account = next_keyed_account(keyed_accounts_iter)?;
@ -1045,7 +1045,7 @@ mod tests {
#[test] #[test]
fn test_process_nonce_ix_no_acc_data_fail() { fn test_process_nonce_ix_no_acc_data_fail() {
assert_eq!( assert_eq!(
process_nonce_instruction(&system_instruction::nonce_advance( process_nonce_instruction(&system_instruction::advance_nonce_account(
&Pubkey::default(), &Pubkey::default(),
&Pubkey::default() &Pubkey::default()
)), )),
@ -1142,7 +1142,7 @@ mod tests {
#[test] #[test]
fn test_process_withdraw_ix_no_acc_data_fail() { fn test_process_withdraw_ix_no_acc_data_fail() {
assert_eq!( assert_eq!(
process_nonce_instruction(&system_instruction::nonce_withdraw( process_nonce_instruction(&system_instruction::withdraw_nonce_account(
&Pubkey::default(), &Pubkey::default(),
&Pubkey::default(), &Pubkey::default(),
&Pubkey::default(), &Pubkey::default(),
@ -1379,7 +1379,7 @@ mod tests {
#[test] #[test]
fn test_process_authorize_bad_account_data_fail() { fn test_process_authorize_bad_account_data_fail() {
assert_eq!( assert_eq!(
process_nonce_instruction(&system_instruction::nonce_authorize( process_nonce_instruction(&system_instruction::authorize_nonce_account(
&Pubkey::default(), &Pubkey::default(),
&Pubkey::default(), &Pubkey::default(),
&Pubkey::default(), &Pubkey::default(),

View File

@ -45,12 +45,12 @@ impl NonceState {
} }
pub trait NonceAccount { pub trait NonceAccount {
fn nonce_advance( fn advance_nonce_account(
&mut self, &mut self,
recent_blockhashes: &RecentBlockhashes, recent_blockhashes: &RecentBlockhashes,
signers: &HashSet<Pubkey>, signers: &HashSet<Pubkey>,
) -> Result<(), InstructionError>; ) -> Result<(), InstructionError>;
fn nonce_withdraw( fn withdraw_nonce_account(
&mut self, &mut self,
lamports: u64, lamports: u64,
to: &mut KeyedAccount, to: &mut KeyedAccount,
@ -58,13 +58,13 @@ pub trait NonceAccount {
rent: &Rent, rent: &Rent,
signers: &HashSet<Pubkey>, signers: &HashSet<Pubkey>,
) -> Result<(), InstructionError>; ) -> Result<(), InstructionError>;
fn nonce_initialize( fn initialize_nonce_account(
&mut self, &mut self,
nonce_authority: &Pubkey, nonce_authority: &Pubkey,
recent_blockhashes: &RecentBlockhashes, recent_blockhashes: &RecentBlockhashes,
rent: &Rent, rent: &Rent,
) -> Result<(), InstructionError>; ) -> Result<(), InstructionError>;
fn nonce_authorize( fn authorize_nonce_account(
&mut self, &mut self,
nonce_authority: &Pubkey, nonce_authority: &Pubkey,
signers: &HashSet<Pubkey>, signers: &HashSet<Pubkey>,
@ -72,7 +72,7 @@ pub trait NonceAccount {
} }
impl<'a> NonceAccount for KeyedAccount<'a> { impl<'a> NonceAccount for KeyedAccount<'a> {
fn nonce_advance( fn advance_nonce_account(
&mut self, &mut self,
recent_blockhashes: &RecentBlockhashes, recent_blockhashes: &RecentBlockhashes,
signers: &HashSet<Pubkey>, signers: &HashSet<Pubkey>,
@ -97,7 +97,7 @@ impl<'a> NonceAccount for KeyedAccount<'a> {
self.set_state(&NonceState::Initialized(meta, recent_blockhashes[0])) self.set_state(&NonceState::Initialized(meta, recent_blockhashes[0]))
} }
fn nonce_withdraw( fn withdraw_nonce_account(
&mut self, &mut self,
lamports: u64, lamports: u64,
to: &mut KeyedAccount, to: &mut KeyedAccount,
@ -137,7 +137,7 @@ impl<'a> NonceAccount for KeyedAccount<'a> {
Ok(()) Ok(())
} }
fn nonce_initialize( fn initialize_nonce_account(
&mut self, &mut self,
nonce_authority: &Pubkey, nonce_authority: &Pubkey,
recent_blockhashes: &RecentBlockhashes, recent_blockhashes: &RecentBlockhashes,
@ -161,7 +161,7 @@ impl<'a> NonceAccount for KeyedAccount<'a> {
self.set_state(&NonceState::Initialized(meta, recent_blockhashes[0])) self.set_state(&NonceState::Initialized(meta, recent_blockhashes[0]))
} }
fn nonce_authorize( fn authorize_nonce_account(
&mut self, &mut self,
nonce_authority: &Pubkey, nonce_authority: &Pubkey,
signers: &HashSet<Pubkey>, signers: &HashSet<Pubkey>,
@ -240,7 +240,7 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(95); let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
keyed_account keyed_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let state: NonceState = keyed_account.state().unwrap(); let state: NonceState = keyed_account.state().unwrap();
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
@ -248,7 +248,7 @@ mod test {
assert_eq!(state, NonceState::Initialized(meta, stored)); assert_eq!(state, NonceState::Initialized(meta, stored));
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
keyed_account keyed_account
.nonce_advance(&recent_blockhashes, &signers) .advance_nonce_account(&recent_blockhashes, &signers)
.unwrap(); .unwrap();
let state: NonceState = keyed_account.state().unwrap(); let state: NonceState = keyed_account.state().unwrap();
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
@ -256,7 +256,7 @@ mod test {
assert_eq!(state, NonceState::Initialized(meta, stored)); assert_eq!(state, NonceState::Initialized(meta, stored));
let recent_blockhashes = create_test_recent_blockhashes(31); let recent_blockhashes = create_test_recent_blockhashes(31);
keyed_account keyed_account
.nonce_advance(&recent_blockhashes, &signers) .advance_nonce_account(&recent_blockhashes, &signers)
.unwrap(); .unwrap();
let state: NonceState = keyed_account.state().unwrap(); let state: NonceState = keyed_account.state().unwrap();
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
@ -269,7 +269,7 @@ mod test {
keyed_account.account.borrow().lamports - withdraw_lamports; keyed_account.account.borrow().lamports - withdraw_lamports;
let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
keyed_account keyed_account
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -301,7 +301,7 @@ mod test {
let authorized = nonce_account.unsigned_key().clone(); let authorized = nonce_account.unsigned_key().clone();
let meta = Meta::new(&authorized); let meta = Meta::new(&authorized);
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let pubkey = nonce_account.account.borrow().owner.clone(); let pubkey = nonce_account.account.borrow().owner.clone();
let mut nonce_account = KeyedAccount::new(&pubkey, false, nonce_account.account); let mut nonce_account = KeyedAccount::new(&pubkey, false, nonce_account.account);
@ -309,7 +309,7 @@ mod test {
assert_eq!(state, NonceState::Initialized(meta, stored)); assert_eq!(state, NonceState::Initialized(meta, stored));
let signers = HashSet::new(); let signers = HashSet::new();
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let result = nonce_account.nonce_advance(&recent_blockhashes, &signers); let result = nonce_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Err(InstructionError::MissingRequiredSignature),); assert_eq!(result, Err(InstructionError::MissingRequiredSignature),);
}) })
} }
@ -327,10 +327,10 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
keyed_account keyed_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let recent_blockhashes = RecentBlockhashes::from_iter(vec![].into_iter()); let recent_blockhashes = RecentBlockhashes::from_iter(vec![].into_iter());
let result = keyed_account.nonce_advance(&recent_blockhashes, &signers); let result = keyed_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Err(NonceError::NoRecentBlockhashes.into())); assert_eq!(result, Err(NonceError::NoRecentBlockhashes.into()));
}) })
} }
@ -348,9 +348,9 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
keyed_account keyed_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let result = keyed_account.nonce_advance(&recent_blockhashes, &signers); let result = keyed_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Err(NonceError::NotExpired.into())); assert_eq!(result, Err(NonceError::NotExpired.into()));
}) })
} }
@ -366,7 +366,7 @@ mod test {
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(keyed_account.signer_key().unwrap().clone()); signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let result = keyed_account.nonce_advance(&recent_blockhashes, &signers); let result = keyed_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Err(NonceError::BadAccountState.into())); assert_eq!(result, Err(NonceError::BadAccountState.into()));
}) })
} }
@ -385,12 +385,12 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = nonce_authority.unsigned_key().clone(); let authorized = nonce_authority.unsigned_key().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(nonce_authority.signer_key().unwrap().clone()); signers.insert(nonce_authority.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(31); let recent_blockhashes = create_test_recent_blockhashes(31);
let result = nonce_account.nonce_advance(&recent_blockhashes, &signers); let result = nonce_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Ok(())); assert_eq!(result, Ok(()));
}); });
}); });
@ -410,9 +410,9 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = nonce_authority.unsigned_key().clone(); let authorized = nonce_authority.unsigned_key().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let result = nonce_account.nonce_advance(&recent_blockhashes, &signers); let result = nonce_account.advance_nonce_account(&recent_blockhashes, &signers);
assert_eq!(result, Err(InstructionError::MissingRequiredSignature),); assert_eq!(result, Err(InstructionError::MissingRequiredSignature),);
}); });
}); });
@ -437,7 +437,7 @@ mod test {
nonce_keyed.account.borrow().lamports - withdraw_lamports; nonce_keyed.account.borrow().lamports - withdraw_lamports;
let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let expect_to_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
nonce_keyed nonce_keyed
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -471,7 +471,7 @@ mod test {
let signers = HashSet::new(); let signers = HashSet::new();
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let lamports = nonce_keyed.account.borrow().lamports; let lamports = nonce_keyed.account.borrow().lamports;
let result = nonce_keyed.nonce_withdraw( let result = nonce_keyed.withdraw_nonce_account(
lamports, lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -498,7 +498,7 @@ mod test {
signers.insert(nonce_keyed.signer_key().unwrap().clone()); signers.insert(nonce_keyed.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let lamports = nonce_keyed.account.borrow().lamports + 1; let lamports = nonce_keyed.account.borrow().lamports + 1;
let result = nonce_keyed.nonce_withdraw( let result = nonce_keyed.withdraw_nonce_account(
lamports, lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -527,7 +527,7 @@ mod test {
nonce_keyed.account.borrow().lamports - withdraw_lamports; nonce_keyed.account.borrow().lamports - withdraw_lamports;
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
nonce_keyed nonce_keyed
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -544,7 +544,7 @@ mod test {
nonce_keyed.account.borrow().lamports - withdraw_lamports; nonce_keyed.account.borrow().lamports - withdraw_lamports;
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
nonce_keyed nonce_keyed
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -574,7 +574,7 @@ mod test {
let authorized = nonce_keyed.unsigned_key().clone(); let authorized = nonce_keyed.unsigned_key().clone();
let meta = Meta::new(&authorized); let meta = Meta::new(&authorized);
nonce_keyed nonce_keyed
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let state: NonceState = nonce_keyed.state().unwrap(); let state: NonceState = nonce_keyed.state().unwrap();
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
@ -585,7 +585,7 @@ mod test {
nonce_keyed.account.borrow().lamports - withdraw_lamports; nonce_keyed.account.borrow().lamports - withdraw_lamports;
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
nonce_keyed nonce_keyed
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -604,7 +604,7 @@ mod test {
nonce_keyed.account.borrow().lamports - withdraw_lamports; nonce_keyed.account.borrow().lamports - withdraw_lamports;
let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports; let to_expect_lamports = to_keyed.account.borrow().lamports + withdraw_lamports;
nonce_keyed nonce_keyed
.nonce_withdraw( .withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -629,13 +629,13 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = nonce_keyed.unsigned_key().clone(); let authorized = nonce_keyed.unsigned_key().clone();
nonce_keyed nonce_keyed
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
with_test_keyed_account(42, false, |mut to_keyed| { with_test_keyed_account(42, false, |mut to_keyed| {
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(nonce_keyed.signer_key().unwrap().clone()); signers.insert(nonce_keyed.signer_key().unwrap().clone());
let withdraw_lamports = nonce_keyed.account.borrow().lamports; let withdraw_lamports = nonce_keyed.account.borrow().lamports;
let result = nonce_keyed.nonce_withdraw( let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -658,14 +658,14 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(95); let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = nonce_keyed.unsigned_key().clone(); let authorized = nonce_keyed.unsigned_key().clone();
nonce_keyed nonce_keyed
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
with_test_keyed_account(42, false, |mut to_keyed| { with_test_keyed_account(42, false, |mut to_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(nonce_keyed.signer_key().unwrap().clone()); signers.insert(nonce_keyed.signer_key().unwrap().clone());
let withdraw_lamports = nonce_keyed.account.borrow().lamports + 1; let withdraw_lamports = nonce_keyed.account.borrow().lamports + 1;
let result = nonce_keyed.nonce_withdraw( let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -688,14 +688,14 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(95); let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = nonce_keyed.unsigned_key().clone(); let authorized = nonce_keyed.unsigned_key().clone();
nonce_keyed nonce_keyed
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
with_test_keyed_account(42, false, |mut to_keyed| { with_test_keyed_account(42, false, |mut to_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(nonce_keyed.signer_key().unwrap().clone()); signers.insert(nonce_keyed.signer_key().unwrap().clone());
let withdraw_lamports = nonce_keyed.account.borrow().lamports - min_lamports + 1; let withdraw_lamports = nonce_keyed.account.borrow().lamports - min_lamports + 1;
let result = nonce_keyed.nonce_withdraw( let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports, withdraw_lamports,
&mut to_keyed, &mut to_keyed,
&recent_blockhashes, &recent_blockhashes,
@ -723,7 +723,8 @@ mod test {
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
let meta = Meta::new(&authorized); let meta = Meta::new(&authorized);
let result = keyed_account.nonce_initialize(&authorized, &recent_blockhashes, &rent); let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Ok(())); assert_eq!(result, Ok(()));
let state: NonceState = keyed_account.state().unwrap(); let state: NonceState = keyed_account.state().unwrap();
assert_eq!(state, NonceState::Initialized(meta, stored)); assert_eq!(state, NonceState::Initialized(meta, stored));
@ -742,7 +743,8 @@ mod test {
signers.insert(keyed_account.signer_key().unwrap().clone()); signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = RecentBlockhashes::from_iter(vec![].into_iter()); let recent_blockhashes = RecentBlockhashes::from_iter(vec![].into_iter());
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
let result = keyed_account.nonce_initialize(&authorized, &recent_blockhashes, &rent); let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Err(NonceError::NoRecentBlockhashes.into())); assert_eq!(result, Err(NonceError::NoRecentBlockhashes.into()));
}) })
} }
@ -758,10 +760,11 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(31); let recent_blockhashes = create_test_recent_blockhashes(31);
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
keyed_account keyed_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let recent_blockhashes = create_test_recent_blockhashes(0); let recent_blockhashes = create_test_recent_blockhashes(0);
let result = keyed_account.nonce_initialize(&authorized, &recent_blockhashes, &rent); let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Err(NonceError::BadAccountState.into())); assert_eq!(result, Err(NonceError::BadAccountState.into()));
}) })
} }
@ -776,7 +779,8 @@ mod test {
with_test_keyed_account(min_lamports - 42, true, |keyed_account| { with_test_keyed_account(min_lamports - 42, true, |keyed_account| {
let recent_blockhashes = create_test_recent_blockhashes(63); let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = keyed_account.unsigned_key().clone(); let authorized = keyed_account.unsigned_key().clone();
let result = keyed_account.nonce_initialize(&authorized, &recent_blockhashes, &rent); let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Err(InstructionError::InsufficientFunds)); assert_eq!(result, Err(InstructionError::InsufficientFunds));
}) })
} }
@ -795,11 +799,11 @@ mod test {
let stored = recent_blockhashes[0]; let stored = recent_blockhashes[0];
let authorized = nonce_account.unsigned_key().clone(); let authorized = nonce_account.unsigned_key().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let authorized = &Pubkey::default().clone(); let authorized = &Pubkey::default().clone();
let meta = Meta::new(&authorized); let meta = Meta::new(&authorized);
let result = nonce_account.nonce_authorize(&Pubkey::default(), &signers); let result = nonce_account.authorize_nonce_account(&Pubkey::default(), &signers);
assert_eq!(result, Ok(())); assert_eq!(result, Ok(()));
let state: NonceState = nonce_account.state().unwrap(); let state: NonceState = nonce_account.state().unwrap();
assert_eq!(state, NonceState::Initialized(meta, stored)); assert_eq!(state, NonceState::Initialized(meta, stored));
@ -816,7 +820,7 @@ mod test {
with_test_keyed_account(min_lamports + 42, true, |nonce_account| { with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
let mut signers = HashSet::new(); let mut signers = HashSet::new();
signers.insert(nonce_account.signer_key().unwrap().clone()); signers.insert(nonce_account.signer_key().unwrap().clone());
let result = nonce_account.nonce_authorize(&Pubkey::default(), &signers); let result = nonce_account.authorize_nonce_account(&Pubkey::default(), &signers);
assert_eq!(result, Err(NonceError::BadAccountState.into())); assert_eq!(result, Err(NonceError::BadAccountState.into()));
}) })
} }
@ -834,9 +838,9 @@ mod test {
let recent_blockhashes = create_test_recent_blockhashes(31); let recent_blockhashes = create_test_recent_blockhashes(31);
let authorized = &Pubkey::default().clone(); let authorized = &Pubkey::default().clone();
nonce_account nonce_account
.nonce_initialize(&authorized, &recent_blockhashes, &rent) .initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap(); .unwrap();
let result = nonce_account.nonce_authorize(&Pubkey::default(), &signers); let result = nonce_account.authorize_nonce_account(&Pubkey::default(), &signers);
assert_eq!(result, Err(InstructionError::MissingRequiredSignature)); assert_eq!(result, Err(InstructionError::MissingRequiredSignature));
}) })
} }

View File

@ -363,7 +363,7 @@ pub fn create_nonce_account(
] ]
} }
pub fn nonce_advance(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction { pub fn advance_nonce_account(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
let account_metas = vec![ let account_metas = vec![
AccountMeta::new(*nonce_pubkey, false), AccountMeta::new(*nonce_pubkey, false),
AccountMeta::new_readonly(recent_blockhashes::id(), false), AccountMeta::new_readonly(recent_blockhashes::id(), false),
@ -376,7 +376,7 @@ pub fn nonce_advance(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instr
) )
} }
pub fn nonce_withdraw( pub fn withdraw_nonce_account(
nonce_pubkey: &Pubkey, nonce_pubkey: &Pubkey,
authorized_pubkey: &Pubkey, authorized_pubkey: &Pubkey,
to_pubkey: &Pubkey, to_pubkey: &Pubkey,
@ -396,7 +396,7 @@ pub fn nonce_withdraw(
) )
} }
pub fn nonce_authorize( pub fn authorize_nonce_account(
nonce_pubkey: &Pubkey, nonce_pubkey: &Pubkey,
authorized_pubkey: &Pubkey, authorized_pubkey: &Pubkey,
new_authority: &Pubkey, new_authority: &Pubkey,

View File

@ -110,8 +110,10 @@ impl Transaction {
nonce_authority_pubkey: &Pubkey, nonce_authority_pubkey: &Pubkey,
nonce_hash: Hash, nonce_hash: Hash,
) -> Self { ) -> Self {
let nonce_ix = let nonce_ix = system_instruction::advance_nonce_account(
system_instruction::nonce_advance(&nonce_account_pubkey, &nonce_authority_pubkey); &nonce_account_pubkey,
&nonce_authority_pubkey,
);
instructions.insert(0, nonce_ix); instructions.insert(0, nonce_ix);
Self::new_signed_with_payer(instructions, payer, signing_keypairs, nonce_hash) Self::new_signed_with_payer(instructions, payer, signing_keypairs, nonce_hash)
} }