From 7224b4547d688c5c1616c58c09f5d8560b72270a Mon Sep 17 00:00:00 2001 From: Jouzo <15011228+Jouzo@users.noreply.github.com> Date: Wed, 6 Sep 2023 09:42:01 +0100 Subject: [PATCH] Txqueue track transferdomain nonce (#2421) --- lib/ain-evm/src/txqueue.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/ain-evm/src/txqueue.rs b/lib/ain-evm/src/txqueue.rs index a799859f04c..23fe06c1022 100644 --- a/lib/ain-evm/src/txqueue.rs +++ b/lib/ain-evm/src/txqueue.rs @@ -10,7 +10,10 @@ use rand::Rng; use crate::{ core::XHash, receipt::Receipt, - transaction::{system::SystemTx, SignedTx}, + transaction::{ + system::{SystemTx, TransferDomainData}, + SignedTx, + }, }; type Result = std::result::Result; @@ -269,15 +272,21 @@ impl TransactionQueue { pub fn queue_tx(&self, tx: QueueTx, tx_hash: XHash, gas_used: U256) -> Result<()> { let mut data = self.data.lock().unwrap(); - if let QueueTx::SignedTx(signed_tx) = &tx { - if let Some(nonce) = data.account_nonces.get(&signed_tx.sender) { - if signed_tx.nonce() != nonce + 1 { - return Err(QueueError::InvalidNonce((signed_tx.clone(), *nonce))); + match &tx { + QueueTx::SignedTx(signed_tx) + | QueueTx::SystemTx(SystemTx::TransferDomain(TransferDomainData { + signed_tx, .. + })) => { + if let Some(nonce) = data.account_nonces.get(&signed_tx.sender) { + if signed_tx.nonce() != nonce + 1 { + return Err(QueueError::InvalidNonce((signed_tx.clone(), *nonce))); + } } + data.account_nonces + .insert(signed_tx.sender, signed_tx.nonce()); + data.total_gas_used += gas_used; } - data.account_nonces - .insert(signed_tx.sender, signed_tx.nonce()); - data.total_gas_used += gas_used; + _ => (), } data.transactions.push(QueueTxItem { tx,