From 672eddecf620b9e5363200dc3ee553d1ade4b3be Mon Sep 17 00:00:00 2001 From: Matthias Wright Date: Sat, 1 Jun 2024 03:44:02 +0800 Subject: [PATCH] chore: refactor out secondary nonce --- core/application/src/genesis.rs | 1 - core/application/src/state.rs | 11 +-- core/application/src/tests.rs | 105 +++++++---------------------- core/cli/src/commands/opt.rs | 4 -- core/rep-collector/src/tests.rs | 1 - core/signer/src/lib.rs | 40 +++-------- core/test-utils/src/transaction.rs | 1 - core/types/src/state.rs | 3 - core/types/src/transaction.rs | 6 -- 9 files changed, 35 insertions(+), 137 deletions(-) diff --git a/core/application/src/genesis.rs b/core/application/src/genesis.rs index dea66e8c9..bf478ddcc 100644 --- a/core/application/src/genesis.rs +++ b/core/application/src/genesis.rs @@ -114,7 +114,6 @@ impl From<&GenesisNode> for NodeInfo { stake: value.stake.clone(), participation: Participation::True, nonce: 0, - secondary_nonce: 0, ports: value.ports.clone(), } } diff --git a/core/application/src/state.rs b/core/application/src/state.rs index b97781bb1..85c4532d2 100644 --- a/core/application/src/state.rs +++ b/core/application/src/state.rs @@ -620,7 +620,6 @@ impl State { ports, participation: Participation::False, nonce: 0, - secondary_nonce: 0, }; self.create_node(node); } else { @@ -1615,9 +1614,7 @@ impl State { TransactionSender::NodeMain(node) => { if let Some(index) = self.pub_key_to_index.get(&node) { if let Some(info) = self.node_info.get(&index) { - if txn.payload.nonce != info.nonce + 1 - || txn.payload.secondary_nonce <= info.secondary_nonce - { + if txn.payload.nonce != info.nonce + 1 { return Err(ExecutionError::InvalidNonce); } } else { @@ -1630,9 +1627,7 @@ impl State { TransactionSender::NodeConsensus(node) => { if let Some(index) = self.consensus_key_to_index.get(&node) { if let Some(info) = self.node_info.get(&index) { - if txn.payload.nonce != info.nonce + 1 - || txn.payload.secondary_nonce <= info.secondary_nonce - { + if txn.payload.nonce != info.nonce + 1 { return Err(ExecutionError::InvalidNonce); } } @@ -1753,14 +1748,12 @@ impl State { let index = self.pub_key_to_index.get(&node).unwrap(); let mut node_info = self.node_info.get(&index).unwrap(); node_info.nonce += 1; - node_info.secondary_nonce += 1; self.node_info.set(index, node_info); }, TransactionSender::NodeConsensus(node) => { let index = self.consensus_key_to_index.get(&node).unwrap(); let mut node_info = self.node_info.get(&index).unwrap(); node_info.nonce += 1; - node_info.secondary_nonce += 1; self.node_info.set(index, node_info); }, TransactionSender::AccountOwner(account) => { diff --git a/core/application/src/tests.rs b/core/application/src/tests.rs index 2af8fe110..366abac71 100644 --- a/core/application/src/tests.rs +++ b/core/application/src/tests.rs @@ -211,7 +211,6 @@ macro_rules! change_epoch { UpdateMethod::ChangeEpoch { epoch: $epoch }, $secret_key, $nonce, - None, ); run_update!(req, $socket) }}; @@ -267,7 +266,6 @@ macro_rules! submit_reputation_measurements { }, $secret_key, $nonce, - None, ); expect_tx_success!(req, $socket) }}; @@ -743,13 +741,10 @@ fn prepare_update_request_node( method: UpdateMethod, secret_key: &NodeSecretKey, nonce: u64, - secondary_nonce: Option, ) -> UpdateRequest { - let secondary_nonce = secondary_nonce.unwrap_or(nonce as u128); let payload = UpdatePayload { sender: secret_key.to_pk().into(), nonce, - secondary_nonce, method, chain_id: CHAIN_ID, }; @@ -771,7 +766,6 @@ fn prepare_update_request_consensus( let payload = UpdatePayload { sender: secret_key.to_pk().into(), nonce, - secondary_nonce: nonce as u128, // we can probably use the nonce as the secondary nonce here method, chain_id: CHAIN_ID, }; @@ -793,7 +787,6 @@ fn prepare_update_request_account( let payload = UpdatePayload { sender: secret_key.to_pk().into(), nonce, - secondary_nonce: nonce as u128, // we can probably use the nonce as the secondary nonce here method, chain_id: CHAIN_ID, }; @@ -948,7 +941,6 @@ fn prepare_pod_request( }, secret_key, nonce, - None, ) } @@ -979,7 +971,7 @@ fn prepare_change_epoch_request( secret_key: &NodeSecretKey, nonce: u64, ) -> UpdateRequest { - prepare_update_request_node(UpdateMethod::ChangeEpoch { epoch }, secret_key, nonce, None) + prepare_update_request_node(UpdateMethod::ChangeEpoch { epoch }, secret_key, nonce) } /// Prepare an `UpdateRequest` for `UpdateMethod::Transfer` signed with `AccountOwnerSecretKey`. @@ -1031,7 +1023,6 @@ fn prepare_content_registry_update( UpdateMethod::UpdateContentRegistry { updates }, secret_key, nonce, - None, ) } @@ -1316,7 +1307,7 @@ async fn test_change_epoch_reverts_node_does_not_exist() { let node_secret_key = NodeSecretKey::generate(); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 0 }; - let update = prepare_update_request_node(change_epoch, &node_secret_key, 1, None); + let update = prepare_update_request_node(change_epoch, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::NodeDoesNotExist); } @@ -1345,7 +1336,7 @@ async fn test_change_epoch_reverts_insufficient_stake() { ); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 0 }; - let update = prepare_update_request_node(change_epoch, &node_secret_key, 1, None); + let update = prepare_update_request_node(change_epoch, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::InsufficientStake); } @@ -1361,7 +1352,7 @@ async fn test_epoch_change_reverts_epoch_already_changed() { assert_eq!(query_runner.get_epoch_info().epoch, 1); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 0 }; - let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 2, None); + let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 2); expect_tx_revert!(update, &update_socket, ExecutionError::EpochAlreadyChanged); } @@ -1373,7 +1364,7 @@ async fn test_epoch_change_reverts_epoch_has_not_started() { let (update_socket, _query_runner) = test_init_app(committee); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 1 }; - let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 1, None); + let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::EpochHasNotStarted); } @@ -1401,7 +1392,7 @@ async fn test_epoch_change_reverts_not_committee_member() { ); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 0 }; - let update = prepare_update_request_node(change_epoch, &node_secret_key, 1, None); + let update = prepare_update_request_node(change_epoch, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::NotCommitteeMember); } @@ -1413,12 +1404,11 @@ async fn test_epoch_change_reverts_already_signaled() { let (update_socket, _query_runner) = test_init_app(committee); let change_epoch = UpdateMethod::ChangeEpoch { epoch: 0 }; - let update = - prepare_update_request_node(change_epoch.clone(), &keystore[0].node_secret_key, 1, None); + let update = prepare_update_request_node(change_epoch.clone(), &keystore[0].node_secret_key, 1); expect_tx_success!(update, &update_socket); // Second update - let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 2, None); + let update = prepare_update_request_node(change_epoch, &keystore[0].node_secret_key, 2); expect_tx_revert!(update, &update_socket, ExecutionError::AlreadySignaled); } @@ -1478,7 +1468,6 @@ async fn test_submit_rep_measurements_too_many_times() { }, &keystore[0].node_secret_key, 1 + i as u64, - None, ); expect_tx_success!(req, &update_socket); } @@ -1486,7 +1475,6 @@ async fn test_submit_rep_measurements_too_many_times() { UpdateMethod::SubmitReputationMeasurements { measurements: map }, &keystore[0].node_secret_key, 1 + MAX_MEASUREMENTS_SUBMIT as u64, - None, ); expect_tx_revert!( req, @@ -1833,7 +1821,7 @@ async fn test_submit_pod_reverts_node_does_not_exist() { proofs: vec![DeliveryAcknowledgmentProof], metadata: None, }; - let update = prepare_update_request_node(submit_pod, &node_secret_key, 1, None); + let update = prepare_update_request_node(submit_pod, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::NodeDoesNotExist); } @@ -1867,7 +1855,7 @@ async fn test_submit_pod_reverts_insufficient_stake() { proofs: vec![DeliveryAcknowledgmentProof], metadata: None, }; - let update = prepare_update_request_node(submit_pod, &node_secret_key, 1, None); + let update = prepare_update_request_node(submit_pod, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::InsufficientStake); } @@ -1975,7 +1963,7 @@ async fn test_change_protocol_params_reverts_not_account_key() { // Assert that reverts for Node Key let update = - prepare_update_request_node(change_method.clone(), &keystore[0].node_secret_key, 1, None); + prepare_update_request_node(change_method.clone(), &keystore[0].node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::OnlyAccountOwner); assert_eq!( query_runner.get_protocol_param(¶m).unwrap(), @@ -2446,7 +2434,7 @@ async fn test_revert_transfer_not_account_key() { // Check that trying to transfer funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; - let update_node_key = prepare_update_request_node(transfer.clone(), node_secret_key, 1, None); + let update_node_key = prepare_update_request_node(transfer.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -2559,7 +2547,7 @@ async fn test_revert_deposit_not_account_key() { // Check that trying to deposit funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; - let update_node_key = prepare_update_request_node(deposit.clone(), node_secret_key, 1, None); + let update_node_key = prepare_update_request_node(deposit.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -2623,7 +2611,7 @@ async fn test_opt_in_reverts_node_does_not_exist() { // Unknown Node Key (without Stake) let node_secret_key = NodeSecretKey::generate(); let opt_in = UpdateMethod::OptIn {}; - let update = prepare_update_request_node(opt_in, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_in, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::NodeDoesNotExist); } @@ -2652,7 +2640,7 @@ async fn test_opt_in_reverts_insufficient_stake() { ); let opt_in = UpdateMethod::OptIn {}; - let update = prepare_update_request_node(opt_in, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_in, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::InsufficientStake); assert_ne!( get_node_participation(&query_runner, &node_secret_key.to_pk()), @@ -2689,7 +2677,7 @@ async fn test_opt_in_works() { ); let opt_in = UpdateMethod::OptIn {}; - let update = prepare_update_request_node(opt_in, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_in, &node_secret_key, 1); expect_tx_success!(update, &update_socket); assert_eq!( @@ -2722,7 +2710,7 @@ async fn test_opt_out_reverts_node_does_not_exist() { // Unknown Node Key (without Stake) let node_secret_key = NodeSecretKey::generate(); let opt_out = UpdateMethod::OptOut {}; - let update = prepare_update_request_node(opt_out, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_out, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::NodeDoesNotExist); } @@ -2751,7 +2739,7 @@ async fn test_opt_out_reverts_insufficient_stake() { ); let opt_out = UpdateMethod::OptOut {}; - let update = prepare_update_request_node(opt_out, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_out, &node_secret_key, 1); expect_tx_revert!(update, &update_socket, ExecutionError::InsufficientStake); assert_ne!( get_node_participation(&query_runner, &node_secret_key.to_pk()), @@ -2788,7 +2776,7 @@ async fn test_opt_out_works() { ); let opt_out = UpdateMethod::OptOut {}; - let update = prepare_update_request_node(opt_out, &node_secret_key, 1, None); + let update = prepare_update_request_node(opt_out, &node_secret_key, 1); expect_tx_success!(update, &update_socket); assert_eq!( @@ -2817,7 +2805,7 @@ async fn test_revert_stake_not_account_key() { // Check that trying to Stake funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; - let update_node_key = prepare_update_request_node(stake.clone(), node_secret_key, 1, None); + let update_node_key = prepare_update_request_node(stake.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -2997,7 +2985,7 @@ async fn test_stake_lock_reverts_not_account_key() { // Check that trying to StakeLock funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; - let update_node_key = prepare_update_request_node(stake_lock.clone(), node_secret_key, 1, None); + let update_node_key = prepare_update_request_node(stake_lock.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -3133,7 +3121,7 @@ async fn test_unstake_reverts_not_account_key() { // Check that trying to Unstake funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; - let update_node_key = prepare_update_request_node(unstake.clone(), node_secret_key, 1, None); + let update_node_key = prepare_update_request_node(unstake.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -3204,7 +3192,7 @@ async fn test_withdraw_unstaked_reverts_not_account_key() { // Check that trying to Stake funds with Node Key reverts let node_secret_key = &keystore[0].node_secret_key; let update_node_key = - prepare_update_request_node(withdraw_unstaked.clone(), node_secret_key, 1, None); + prepare_update_request_node(withdraw_unstaked.clone(), node_secret_key, 1); expect_tx_revert!( update_node_key, &update_socket, @@ -3386,7 +3374,6 @@ async fn test_submit_reputation_measurements_reverts_node_does_not_exist() { UpdateMethod::SubmitReputationMeasurements { measurements }, &NodeSecretKey::generate(), 1, - None, ); expect_tx_revert!(update, &update_socket, ExecutionError::NodeDoesNotExist); @@ -3427,7 +3414,6 @@ async fn test_submit_reputation_measurements_reverts_insufficient_stake() { UpdateMethod::SubmitReputationMeasurements { measurements }, &node_secret_key, 1, - None, ); expect_tx_revert!(update, &update_socket, ExecutionError::InsufficientStake); @@ -3466,7 +3452,6 @@ async fn test_submit_reputation_measurements_too_many_measurements() { UpdateMethod::SubmitReputationMeasurements { measurements }, &node_secret_key, 1, - None, ); expect_tx_revert!(update, &update_socket, ExecutionError::TooManyMeasurements); @@ -3891,7 +3876,6 @@ async fn test_invalid_chain_id() { let payload = UpdatePayload { sender: secret_key.to_pk().into(), nonce: 1, - secondary_nonce: 1, method: UpdateMethod::OptIn {}, chain_id, }; @@ -3904,48 +3888,6 @@ async fn test_invalid_chain_id() { expect_tx_revert!(update, &update_socket, ExecutionError::InvalidChainId); } -#[tokio::test] -async fn test_reject_invalid_secondary_nonce() { - let committee_size = 4; - let (committee, keystore) = create_genesis_committee(committee_size); - let (update_socket, query_runner) = test_init_app(committee); - let mut rng = random::get_seedable_rng(); - - let mut measurements = BTreeMap::new(); - let _ = update_reputation_measurements( - &query_runner, - &mut measurements, - &keystore[1].node_secret_key.to_pk(), - reputation::generate_reputation_measurements(&mut rng, 0.1), - ); - - let method = UpdateMethod::SubmitReputationMeasurements { measurements }; - let request = prepare_update_request_node(method, &keystore[0].node_secret_key, 1, Some(0)); - - expect_tx_revert!(request, &update_socket, ExecutionError::InvalidNonce); -} - -#[tokio::test] -async fn test_accept_valid_secondary_nonce() { - let committee_size = 4; - let (committee, keystore) = create_genesis_committee(committee_size); - let (update_socket, query_runner) = test_init_app(committee); - let mut rng = random::get_seedable_rng(); - - let mut measurements = BTreeMap::new(); - let _ = update_reputation_measurements( - &query_runner, - &mut measurements, - &keystore[1].node_secret_key.to_pk(), - reputation::generate_reputation_measurements(&mut rng, 0.1), - ); - - let method = UpdateMethod::SubmitReputationMeasurements { measurements }; - let request = prepare_update_request_node(method, &keystore[0].node_secret_key, 1, Some(99)); - - expect_tx_success!(request, &update_socket); -} - // (dalton) Since the quick sort used to select the winners of the auctions takes &self of the whole // state, since it has to do reputation lookups on the compare nodes side of things I am going to // repeate the modified quick sort algorithm here so we can have unit tests on just the actual @@ -4024,7 +3966,6 @@ fn quick_sort_mock_node_list() -> Vec<(NodeIndex, NodeInfo)> { participation: Participation::True, nonce: 0, ports: Default::default(), - secondary_nonce: 0, }, )); } diff --git a/core/cli/src/commands/opt.rs b/core/cli/src/commands/opt.rs index 2383eff86..cee34b56b 100644 --- a/core/cli/src/commands/opt.rs +++ b/core/cli/src/commands/opt.rs @@ -81,7 +81,6 @@ async fn opt_in(config_path: ResolvedPathBuf) -> Result<()> { UpdateMethod::OptIn {}, secret_key, node_info.nonce + 1, - node_info.secondary_nonce + 1, chain_id, ); @@ -139,7 +138,6 @@ async fn opt_out(config_path: ResolvedPathBuf) -> Result<()> { UpdateMethod::OptOut {}, secret_key, node_info.nonce + 1, - node_info.secondary_nonce + 1, chain_id, ); @@ -246,13 +244,11 @@ fn create_update_request( method: UpdateMethod, secret_key: NodeSecretKey, nonce: u64, - secondary_nonce: u128, chain_id: ChainId, ) -> UpdateRequest { let payload = UpdatePayload { sender: TransactionSender::NodeMain(secret_key.to_pk()), nonce, - secondary_nonce, method, chain_id, }; diff --git a/core/rep-collector/src/tests.rs b/core/rep-collector/src/tests.rs index 298a2bef9..4bdc96ec2 100644 --- a/core/rep-collector/src/tests.rs +++ b/core/rep-collector/src/tests.rs @@ -512,7 +512,6 @@ async fn test_reputation_calculation_and_query() { let payload = UpdatePayload { sender: node.get_ed25519_pk().into(), nonce, - secondary_nonce: nonce as u128, method, chain_id, }; diff --git a/core/signer/src/lib.rs b/core/signer/src/lib.rs index a46ed2c6f..9428921f0 100644 --- a/core/signer/src/lib.rs +++ b/core/signer/src/lib.rs @@ -51,7 +51,6 @@ struct SignerState { chain_id: Option, base_nonce: u64, next_nonce: u64, - next_secondary_nonce: u128, base_timestamp: Option, pending_transactions: VecDeque, } @@ -70,7 +69,6 @@ impl Signer { chain_id: None, base_nonce: 0, next_nonce: 0, - next_secondary_nonce: 0, base_timestamp: None, pending_transactions: VecDeque::new(), }; @@ -100,8 +98,8 @@ impl Signer { let mut guard = worker.state.lock().await; let mut node_index = LazyNodeIndex::new(guard.node_public_key); let chain_id = query_runner.get_chain_id(); - let (nonce, secondary_nonce) = node_index.query_nonce(&query_runner); - guard.init_state(chain_id, nonce, secondary_nonce); + let nonce = node_index.query_nonce(&query_runner); + guard.init_state(chain_id, nonce); drop(guard); spawn!( @@ -127,10 +125,9 @@ impl SignerInterface for Signer { } impl SignerState { - fn init_state(&mut self, chain_id: u32, base_nonce: u64, secondary_nonce: u128) { + fn init_state(&mut self, chain_id: u32, base_nonce: u64) { self.base_nonce = base_nonce; self.next_nonce = base_nonce + 1; - self.next_secondary_nonce = secondary_nonce + 1; self.chain_id = Some(chain_id); } @@ -140,7 +137,6 @@ impl SignerState { sender: TransactionSender::NodeMain(self.node_public_key), method, nonce: assigned_nonce, - secondary_nonce: self.next_secondary_nonce, chain_id: self.chain_id.unwrap(), }; @@ -163,9 +159,6 @@ impl SignerState { // Optimistically increment nonce self.next_nonce += 1; - // Always increment secondary nonce - self.next_secondary_nonce += 1; - let timestamp = SystemTime::now(); self.pending_transactions.push_back(PendingTransaction { update_request, @@ -181,19 +174,13 @@ impl SignerState { assigned_nonce } - async fn sync_with_application( - &mut self, - application_nonce: u64, - secondary_nonce: u128, - query_runner: &Q, - ) where + async fn sync_with_application(&mut self, application_nonce: u64, query_runner: &Q) + where Q: SyncQueryRunnerInterface, { // All transactions in range [base_nonce, application_nonce] have // been ordered, so we can remove them from `pending_transactions`. self.base_nonce = application_nonce; - // If the next secondary nonce is now greater than our next sec nonce, we update it. - self.next_secondary_nonce = self.next_secondary_nonce.max(secondary_nonce + 1); while !self.pending_transactions.is_empty() && self.pending_transactions[0].update_request.payload.nonce <= application_nonce @@ -227,7 +214,6 @@ impl SignerState { sender: TransactionSender::NodeMain(self.node_public_key), method, nonce: self.next_nonce, - secondary_nonce: self.next_secondary_nonce, chain_id: self.chain_id.unwrap(), }; let digest = update_payload.to_digest(); @@ -241,7 +227,6 @@ impl SignerState { // Note: with the change to using the increment nonce txn, this check // should not be necessary anymore. tx.update_request.payload.nonce = self.next_nonce; - tx.update_request.payload.secondary_nonce = self.next_secondary_nonce; let digest = tx.update_request.payload.to_digest(); let signature = self.node_secret_key.sign(&digest); @@ -254,7 +239,6 @@ impl SignerState { } self.next_nonce += 1; - self.next_secondary_nonce += 1; } for pending_tx in self.pending_transactions.iter_mut() { @@ -283,7 +267,7 @@ impl LazyNodeIndex { } /// Query the application layer for the last nonce and returns it. - fn query_nonce(&mut self, query_runner: &Q) -> (u64, u128) + fn query_nonce(&mut self, query_runner: &Q) -> u64 where Q: SyncQueryRunnerInterface, { @@ -292,10 +276,8 @@ impl LazyNodeIndex { } self.node_index - .and_then(|node_index| { - query_runner.get_node_info(&node_index, |n| (n.nonce, n.secondary_nonce)) - }) - .unwrap_or((0, 0)) + .and_then(|node_index| query_runner.get_node_info(&node_index, |n| n.nonce)) + .unwrap_or(0) } } @@ -331,12 +313,10 @@ async fn new_block_task( query_runner: Q, ) { while let Some(_notification) = subscriber.last().await { - let (nonce, secondary_nonce) = node_index.query_nonce(&query_runner); + let nonce = node_index.query_nonce(&query_runner); // TODO(qti3e): Get the lock only if we have to. Timeout should get sep from block. // Right now we are relying on the existence of new blocks to handle timeout. let mut guard = worker.state.lock().await; - guard - .sync_with_application(nonce, secondary_nonce, &query_runner) - .await; + guard.sync_with_application(nonce, &query_runner).await; } } diff --git a/core/test-utils/src/transaction.rs b/core/test-utils/src/transaction.rs index b034ee7c1..185cd4c5b 100644 --- a/core/test-utils/src/transaction.rs +++ b/core/test-utils/src/transaction.rs @@ -14,7 +14,6 @@ pub fn get_update_transactions(num_txns: usize) -> Vec { let payload = UpdatePayload { sender, nonce: 0, - secondary_nonce: 1, method, chain_id: 1337, }; diff --git a/core/types/src/state.rs b/core/types/src/state.rs index 9aa845248..b7617ec9e 100644 --- a/core/types/src/state.rs +++ b/core/types/src/state.rs @@ -220,9 +220,6 @@ pub struct NodeInfo { /// The nonce of the node. Added to each transaction before signed to prevent replays and /// enforce ordering pub nonce: u64, - /// The secondary nonce. This nonce is used to invalidate transactions that we already sent to - /// the mempool in case we have to resent a transaction with an updated nonce. - pub secondary_nonce: u128, } #[derive(Debug, Serialize, Deserialize, Clone, schemars::JsonSchema)] diff --git a/core/types/src/transaction.rs b/core/types/src/transaction.rs index 5963b615f..f54a490bb 100644 --- a/core/types/src/transaction.rs +++ b/core/types/src/transaction.rs @@ -300,8 +300,6 @@ pub struct UpdatePayload { pub sender: TransactionSender, /// The counter or nonce of this request. pub nonce: u64, - /// The secondary nonce. - pub secondary_nonce: u128, /// The transition function (and parameters) for this update request. pub method: UpdateMethod, /// The chain ID. @@ -440,7 +438,6 @@ impl ToDigest for UpdatePayload { fn transcript(&self) -> TranscriptBuilder { let mut transcript_builder = TranscriptBuilder::empty(FN_TXN_PAYLOAD_DOMAIN) .with("nonce", &self.nonce) - .with("secondary_nonce", &self.secondary_nonce) .with("chain_id", &self.chain_id); match &self.sender { @@ -715,7 +712,6 @@ mod tests { let payload = UpdatePayload { sender: TransactionSender::AccountOwner(EthAddress([0; 20])), nonce: 0, - secondary_nonce: 0, method: update_method, chain_id: CHAIN_ID, }; @@ -741,7 +737,6 @@ mod tests { let payload_1 = UpdatePayload { sender: TransactionSender::AccountOwner(EthAddress([0; 20])), nonce: 0, - secondary_nonce: 0, method: update_method, chain_id: chain_id_1, }; @@ -773,7 +768,6 @@ mod tests { payload: UpdatePayload { sender: TransactionSender::NodeMain(NodePublicKey([9; 32])), nonce: 0, - secondary_nonce: 0, method: UpdateMethod::ChangeEpoch { epoch: 0 }, chain_id: 69, },