mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
fix double nonce increment in privacy preserving tx
This commit is contained in:
parent
f08ed17509
commit
83542b310c
@ -61,7 +61,9 @@ fn main() {
|
||||
public_pre_states.push(pre_states[i].clone());
|
||||
|
||||
let mut post = post_states[i].clone();
|
||||
post.nonce += 1;
|
||||
if pre_states[i].is_authorized {
|
||||
post.nonce += 1;
|
||||
}
|
||||
if post.program_owner == DEFAULT_PROGRAM_ID {
|
||||
// Claim account
|
||||
post.program_owner = program_id;
|
||||
|
||||
@ -140,12 +140,6 @@ impl V01State {
|
||||
*current_account = post;
|
||||
}
|
||||
|
||||
// // 5. Increment nonces
|
||||
for address in tx.signer_addresses() {
|
||||
let current_account = self.get_account_by_address_mut(address);
|
||||
current_account.nonce += 1;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -925,6 +919,13 @@ pub mod tests {
|
||||
&state,
|
||||
);
|
||||
|
||||
let expected_sender_post = {
|
||||
let mut this = state.get_account_by_address(&sender_keys.address());
|
||||
this.balance -= balance_to_move;
|
||||
this.nonce += 1;
|
||||
this
|
||||
};
|
||||
|
||||
let [expected_new_commitment] = tx.message().new_commitments.clone().try_into().unwrap();
|
||||
assert!(!state.private_state.0.contains(&expected_new_commitment));
|
||||
|
||||
@ -932,6 +933,8 @@ pub mod tests {
|
||||
.transition_from_privacy_preserving_transaction(&tx)
|
||||
.unwrap();
|
||||
|
||||
let sender_post = state.get_account_by_address(&sender_keys.address());
|
||||
assert_eq!(sender_post, expected_sender_post);
|
||||
assert!(state.private_state.0.contains(&expected_new_commitment));
|
||||
|
||||
assert_eq!(
|
||||
@ -1024,6 +1027,12 @@ pub mod tests {
|
||||
|
||||
let balance_to_move = 37;
|
||||
|
||||
let expected_recipient_post = {
|
||||
let mut this = state.get_account_by_address(&recipient_keys.address());
|
||||
this.balance += balance_to_move;
|
||||
this
|
||||
};
|
||||
|
||||
let tx = deshielded_balance_transfer_for_tests(
|
||||
&sender_keys,
|
||||
&sender_private_account,
|
||||
@ -1054,6 +1063,9 @@ pub mod tests {
|
||||
.transition_from_privacy_preserving_transaction(&tx)
|
||||
.unwrap();
|
||||
|
||||
|
||||
let recipient_post = state.get_account_by_address(&recipient_keys.address());
|
||||
assert_eq!(recipient_post, expected_recipient_post);
|
||||
assert!(state.private_state.0.contains(&sender_pre_commitment));
|
||||
assert!(state.private_state.0.contains(&expected_new_commitment));
|
||||
assert!(state.private_state.1.contains(&expected_new_nullifier));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user