|
|
@@ -40,7 +40,10 @@ use {
|
|
|
SanitizedMessage,
|
|
|
},
|
|
|
native_loader,
|
|
|
- nonce::{state::Versions as NonceVersions, State as NonceState},
|
|
|
+ nonce::{
|
|
|
+ state::{DurableNonce, Versions as NonceVersions},
|
|
|
+ State as NonceState,
|
|
|
+ },
|
|
|
pubkey::Pubkey,
|
|
|
slot_hashes::SlotHashes,
|
|
|
system_program,
|
|
|
@@ -1193,7 +1196,7 @@ impl Accounts {
|
|
|
res: &'a [TransactionExecutionResult],
|
|
|
loaded: &'a mut [TransactionLoadResult],
|
|
|
rent_collector: &RentCollector,
|
|
|
- blockhash: &Hash,
|
|
|
+ durable_nonce: &DurableNonce,
|
|
|
lamports_per_signature: u64,
|
|
|
leave_nonce_on_success: bool,
|
|
|
) {
|
|
|
@@ -1202,7 +1205,7 @@ impl Accounts {
|
|
|
res,
|
|
|
loaded,
|
|
|
rent_collector,
|
|
|
- blockhash,
|
|
|
+ durable_nonce,
|
|
|
lamports_per_signature,
|
|
|
leave_nonce_on_success,
|
|
|
);
|
|
|
@@ -1225,7 +1228,7 @@ impl Accounts {
|
|
|
execution_results: &'a [TransactionExecutionResult],
|
|
|
load_results: &'a mut [TransactionLoadResult],
|
|
|
rent_collector: &RentCollector,
|
|
|
- blockhash: &Hash,
|
|
|
+ durable_nonce: &DurableNonce,
|
|
|
lamports_per_signature: u64,
|
|
|
leave_nonce_on_success: bool,
|
|
|
) -> Vec<(&'a Pubkey, &'a AccountSharedData)> {
|
|
|
@@ -1279,7 +1282,7 @@ impl Accounts {
|
|
|
execution_status,
|
|
|
is_fee_payer,
|
|
|
maybe_nonce,
|
|
|
- blockhash,
|
|
|
+ durable_nonce,
|
|
|
lamports_per_signature,
|
|
|
);
|
|
|
|
|
|
@@ -1306,13 +1309,13 @@ impl Accounts {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-pub fn prepare_if_nonce_account<'a>(
|
|
|
+fn prepare_if_nonce_account<'a>(
|
|
|
address: &Pubkey,
|
|
|
account: &mut AccountSharedData,
|
|
|
execution_result: &Result<()>,
|
|
|
is_fee_payer: bool,
|
|
|
maybe_nonce: Option<(&'a NonceFull, bool)>,
|
|
|
- blockhash: &Hash,
|
|
|
+ durable_nonce: &DurableNonce,
|
|
|
lamports_per_signature: u64,
|
|
|
) -> bool {
|
|
|
if let Some((nonce, rollback)) = maybe_nonce {
|
|
|
@@ -1338,7 +1341,7 @@ pub fn prepare_if_nonce_account<'a>(
|
|
|
account
|
|
|
.set_state(&NonceVersions::new_current(NonceState::new_initialized(
|
|
|
&data.authority,
|
|
|
- blockhash,
|
|
|
+ *durable_nonce,
|
|
|
lamports_per_signature,
|
|
|
)))
|
|
|
.unwrap();
|
|
|
@@ -3025,7 +3028,7 @@ mod tests {
|
|
|
&execution_results,
|
|
|
loaded.as_mut_slice(),
|
|
|
&rent_collector,
|
|
|
- &Hash::default(),
|
|
|
+ &DurableNonce::default(),
|
|
|
0,
|
|
|
true, // leave_nonce_on_success
|
|
|
);
|
|
|
@@ -3171,7 +3174,7 @@ mod tests {
|
|
|
Pubkey,
|
|
|
AccountSharedData,
|
|
|
AccountSharedData,
|
|
|
- Hash,
|
|
|
+ DurableNonce,
|
|
|
u64,
|
|
|
Option<AccountSharedData>,
|
|
|
) {
|
|
|
@@ -3184,7 +3187,7 @@ mod tests {
|
|
|
Pubkey::default(),
|
|
|
pre_account,
|
|
|
account,
|
|
|
- Hash::new(&[1u8; 32]),
|
|
|
+ DurableNonce::from_blockhash(&Hash::new(&[1u8; 32]), /*separate_domains:*/ true),
|
|
|
1234,
|
|
|
None,
|
|
|
)
|
|
|
@@ -3196,7 +3199,7 @@ mod tests {
|
|
|
tx_result: &Result<()>,
|
|
|
is_fee_payer: bool,
|
|
|
maybe_nonce: Option<(&NonceFull, bool)>,
|
|
|
- blockhash: &Hash,
|
|
|
+ durable_nonce: &DurableNonce,
|
|
|
lamports_per_signature: u64,
|
|
|
expect_account: &AccountSharedData,
|
|
|
) -> bool {
|
|
|
@@ -3216,7 +3219,7 @@ mod tests {
|
|
|
tx_result,
|
|
|
is_fee_payer,
|
|
|
maybe_nonce,
|
|
|
- blockhash,
|
|
|
+ durable_nonce,
|
|
|
lamports_per_signature,
|
|
|
);
|
|
|
assert_eq!(expect_account, account);
|
|
|
@@ -3370,7 +3373,7 @@ mod tests {
|
|
|
)),
|
|
|
false,
|
|
|
Some((&nonce, true)),
|
|
|
- &Hash::default(),
|
|
|
+ &DurableNonce::default(),
|
|
|
1,
|
|
|
&post_fee_payer_account.clone(),
|
|
|
));
|
|
|
@@ -3381,7 +3384,7 @@ mod tests {
|
|
|
&Ok(()),
|
|
|
true,
|
|
|
Some((&nonce, true)),
|
|
|
- &Hash::default(),
|
|
|
+ &DurableNonce::default(),
|
|
|
1,
|
|
|
&post_fee_payer_account.clone(),
|
|
|
));
|
|
|
@@ -3395,7 +3398,7 @@ mod tests {
|
|
|
)),
|
|
|
true,
|
|
|
None,
|
|
|
- &Hash::default(),
|
|
|
+ &DurableNonce::default(),
|
|
|
1,
|
|
|
&post_fee_payer_account.clone(),
|
|
|
));
|
|
|
@@ -3409,7 +3412,7 @@ mod tests {
|
|
|
)),
|
|
|
true,
|
|
|
Some((&nonce, true)),
|
|
|
- &Hash::default(),
|
|
|
+ &DurableNonce::default(),
|
|
|
1,
|
|
|
&pre_fee_payer_account,
|
|
|
));
|
|
|
@@ -3424,8 +3427,10 @@ mod tests {
|
|
|
let from = keypair_from_seed(&[1; 32]).unwrap();
|
|
|
let from_address = from.pubkey();
|
|
|
let to_address = Pubkey::new_unique();
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let nonce_state = NonceVersions::new_current(NonceState::Initialized(
|
|
|
- nonce::state::Data::new(nonce_authority.pubkey(), Hash::new_unique(), 0),
|
|
|
+ nonce::state::Data::new(nonce_authority.pubkey(), durable_nonce, 0),
|
|
|
));
|
|
|
let nonce_account_post =
|
|
|
AccountSharedData::new_data(43, &nonce_state, &system_program::id()).unwrap();
|
|
|
@@ -3449,8 +3454,10 @@ mod tests {
|
|
|
];
|
|
|
let tx = new_sanitized_tx(&[&nonce_authority, &from], message, blockhash);
|
|
|
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let nonce_state = NonceVersions::new_current(NonceState::Initialized(
|
|
|
- nonce::state::Data::new(nonce_authority.pubkey(), Hash::new_unique(), 0),
|
|
|
+ nonce::state::Data::new(nonce_authority.pubkey(), durable_nonce, 0),
|
|
|
));
|
|
|
let nonce_account_pre =
|
|
|
AccountSharedData::new_data(42, &nonce_state, &system_program::id()).unwrap();
|
|
|
@@ -3474,7 +3481,8 @@ mod tests {
|
|
|
|
|
|
let mut loaded = vec![loaded];
|
|
|
|
|
|
- let next_blockhash = Hash::new_unique();
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let accounts = Accounts::new_with_config_for_tests(
|
|
|
Vec::new(),
|
|
|
&ClusterType::Development,
|
|
|
@@ -3495,7 +3503,7 @@ mod tests {
|
|
|
&execution_results,
|
|
|
loaded.as_mut_slice(),
|
|
|
&rent_collector,
|
|
|
- &next_blockhash,
|
|
|
+ &durable_nonce,
|
|
|
0,
|
|
|
true, // leave_nonce_on_success
|
|
|
);
|
|
|
@@ -3521,7 +3529,7 @@ mod tests {
|
|
|
);
|
|
|
assert!(nonce_account::verify_nonce_account(
|
|
|
&collected_nonce_account,
|
|
|
- &next_blockhash
|
|
|
+ durable_nonce.as_hash(),
|
|
|
));
|
|
|
}
|
|
|
|
|
|
@@ -3534,8 +3542,10 @@ mod tests {
|
|
|
let from = keypair_from_seed(&[1; 32]).unwrap();
|
|
|
let from_address = from.pubkey();
|
|
|
let to_address = Pubkey::new_unique();
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let nonce_state = NonceVersions::new_current(NonceState::Initialized(
|
|
|
- nonce::state::Data::new(nonce_authority.pubkey(), Hash::new_unique(), 0),
|
|
|
+ nonce::state::Data::new(nonce_authority.pubkey(), durable_nonce, 0),
|
|
|
));
|
|
|
let nonce_account_post =
|
|
|
AccountSharedData::new_data(43, &nonce_state, &system_program::id()).unwrap();
|
|
|
@@ -3559,8 +3569,10 @@ mod tests {
|
|
|
];
|
|
|
let tx = new_sanitized_tx(&[&nonce_authority, &from], message, blockhash);
|
|
|
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let nonce_state = NonceVersions::new_current(NonceState::Initialized(
|
|
|
- nonce::state::Data::new(nonce_authority.pubkey(), Hash::new_unique(), 0),
|
|
|
+ nonce::state::Data::new(nonce_authority.pubkey(), durable_nonce, 0),
|
|
|
));
|
|
|
let nonce_account_pre =
|
|
|
AccountSharedData::new_data(42, &nonce_state, &system_program::id()).unwrap();
|
|
|
@@ -3583,7 +3595,8 @@ mod tests {
|
|
|
|
|
|
let mut loaded = vec![loaded];
|
|
|
|
|
|
- let next_blockhash = Hash::new_unique();
|
|
|
+ let durable_nonce =
|
|
|
+ DurableNonce::from_blockhash(&Hash::new_unique(), /*separate_domains:*/ true);
|
|
|
let accounts = Accounts::new_with_config_for_tests(
|
|
|
Vec::new(),
|
|
|
&ClusterType::Development,
|
|
|
@@ -3604,7 +3617,7 @@ mod tests {
|
|
|
&execution_results,
|
|
|
loaded.as_mut_slice(),
|
|
|
&rent_collector,
|
|
|
- &next_blockhash,
|
|
|
+ &durable_nonce,
|
|
|
0,
|
|
|
true, // leave_nonce_on_success
|
|
|
);
|
|
|
@@ -3621,7 +3634,7 @@ mod tests {
|
|
|
);
|
|
|
assert!(nonce_account::verify_nonce_account(
|
|
|
&collected_nonce_account,
|
|
|
- &next_blockhash
|
|
|
+ durable_nonce.as_hash(),
|
|
|
));
|
|
|
}
|
|
|
|