From 93056edbc75662e78bdc719780685b79f24a8e03 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 Mar 2023 23:57:00 +0200 Subject: [PATCH] fix(txpool): use default account if non existing (#2015) --- crates/transaction-pool/src/validate.rs | 30 ++++++++----------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/crates/transaction-pool/src/validate.rs b/crates/transaction-pool/src/validate.rs index 107a8b536d..42fd4a0122 100644 --- a/crates/transaction-pool/src/validate.rs +++ b/crates/transaction-pool/src/validate.rs @@ -230,30 +230,18 @@ where .latest() .and_then(|state| state.basic_account(transaction.sender())) { - Ok(account) => account, + Ok(account) => account.unwrap_or_default(), Err(err) => return TransactionValidationOutcome::Error(transaction, Box::new(err)), }; - let account = match account { - Some(account) => { - // Signer account shouldn't have bytecode. Presence of bytecode means this is a - // smartcontract. - if account.has_bytecode() { - return TransactionValidationOutcome::Invalid( - transaction, - InvalidTransactionError::SignerAccountHasBytecode.into(), - ) - } else { - account - } - } - None => { - return TransactionValidationOutcome::Invalid( - transaction, - InvalidPoolTransactionError::AccountNotFound, - ) - } - }; + // Signer account shouldn't have bytecode. Presence of bytecode means this is a + // smartcontract. + if account.has_bytecode() { + return TransactionValidationOutcome::Invalid( + transaction, + InvalidTransactionError::SignerAccountHasBytecode.into(), + ) + } // Checks for nonce if transaction.nonce() < account.nonce {