From adad6d31b4be4ce3d220b7072806ca568ef814d9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 15 Apr 2023 01:31:16 +0200 Subject: [PATCH] Revert "Revert "chore: enable tx inserts via p2p" (#2252)" (#2259) --- crates/net/network/src/transactions.rs | 13 +++++++------ crates/transaction-pool/src/error.rs | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/net/network/src/transactions.rs b/crates/net/network/src/transactions.rs index 5c93d941cd..0859a59503 100644 --- a/crates/net/network/src/transactions.rs +++ b/crates/net/network/src/transactions.rs @@ -528,14 +528,15 @@ where this.on_good_import(hash); } Err(err) => { - if err.is_bad_transaction() { + // if we're syncing and the transaction is bad we ignore it, otherwise we + // penalize the peer that sent the bad transaction with the assumption that the + // peer should have known that this transaction is bad. (e.g. consensus rules) + if err.is_bad_transaction() && !this.network.is_syncing() { trace!(target: "net::tx", ?err, "Bad transaction import"); - // TODO disabled until properly tested - // this.on_bad_import(*err.hash()); - this.on_good_import(*err.hash()); - } else { - this.on_good_import(*err.hash()); + this.on_bad_import(*err.hash()); + continue } + this.on_good_import(*err.hash()); } } } diff --git a/crates/transaction-pool/src/error.rs b/crates/transaction-pool/src/error.rs index 3f08c4f102..ef8c91b246 100644 --- a/crates/transaction-pool/src/error.rs +++ b/crates/transaction-pool/src/error.rs @@ -113,9 +113,6 @@ pub enum InvalidPoolTransactionError { /// respect the max_init_code_size. #[error("Transaction's size {0} exceeds max_init_code_size {1}.")] ExceedsMaxInitCodeSize(usize, usize), - /// Thrown if the transaction contains an invalid signature - #[error("Invalid sender")] - AccountNotFound, /// Thrown if the input data of a transaction is greater /// than some meaningful limit a user might use. This is not a consensus error /// making the transaction invalid, rather a DOS protection.