From 5dec58ba9f9032b720887fccee0cc2f768f0036d Mon Sep 17 00:00:00 2001 From: Dusan Stanivukovic Date: Fri, 11 Jun 2021 10:19:08 +0200 Subject: [PATCH] Sunce86/fix tx pool locals for 1559 (#431) * fixed handling of local txs after 1559 activation --- crates/concensus/miner/src/pool/scoring.rs | 18 +++++++++++++++++- crates/ethcore/src/miner/miner.rs | 7 +++++-- crates/ethcore/src/miner/mod.rs | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/concensus/miner/src/pool/scoring.rs b/crates/concensus/miner/src/pool/scoring.rs index 4d9cad188..9ef384768 100644 --- a/crates/concensus/miner/src/pool/scoring.rs +++ b/crates/concensus/miner/src/pool/scoring.rs @@ -131,7 +131,11 @@ where super::Priority::Retracted => 10, super::Priority::Regular => 0, }; - scores[i] = scores[i] << boost; + + //boost local and retracted only if they are currently includable (base fee criteria) + if self.block_base_fee.is_none() || scores[i] >= self.block_base_fee.unwrap() { + scores[i] = scores[i] << boost; + } } // We are only sending an event in case of penalization. // So just lower the priority of all non-local transactions. @@ -148,6 +152,18 @@ where ScoringEvent::BlockBaseFeeChanged => { for i in 0..txs.len() { scores[i] = txs[i].transaction.effective_gas_price(self.block_base_fee); + let boost = match txs[i].priority() { + super::Priority::Local => 15, + super::Priority::Retracted => 10, + super::Priority::Regular => 0, + }; + + //boost local and retracted only if they are currently includable (base fee criteria) + if self.block_base_fee.is_none() + || scores[i] >= self.block_base_fee.unwrap() + { + scores[i] = scores[i] << boost; + } } } } diff --git a/crates/ethcore/src/miner/miner.rs b/crates/ethcore/src/miner/miner.rs index cebb53f2b..fc9c34664 100644 --- a/crates/ethcore/src/miner/miner.rs +++ b/crates/ethcore/src/miner/miner.rs @@ -1169,7 +1169,7 @@ impl miner::MinerService for Miner { ordering: miner::PendingOrdering, ) -> Vec> where - C: ChainInfo + Nonce + Sync, + C: BlockChain + Nonce + Sync, { let chain_info = chain.chain_info(); @@ -1186,7 +1186,10 @@ impl miner::MinerService for Miner { nonce_cap, max_len, ordering, - includable_boundary: Default::default(), + includable_boundary: self + .engine + .calculate_base_fee(&chain.best_block_header()) + .unwrap_or_default(), }; if let Some(ref f) = filter { diff --git a/crates/ethcore/src/miner/mod.rs b/crates/ethcore/src/miner/mod.rs index 1efb98197..eff4320ee 100644 --- a/crates/ethcore/src/miner/mod.rs +++ b/crates/ethcore/src/miner/mod.rs @@ -226,7 +226,7 @@ pub trait MinerService: Send + Sync { ordering: PendingOrdering, ) -> Vec> where - C: ChainInfo + Nonce + Sync; + C: BlockChain + Nonce + Sync; /// Get an unfiltered list of all ready transactions. fn ready_transactions( @@ -236,7 +236,7 @@ pub trait MinerService: Send + Sync { ordering: PendingOrdering, ) -> Vec> where - C: ChainInfo + Nonce + Sync, + C: BlockChain + Nonce + Sync, { self.ready_transactions_filtered(chain, max_len, None, ordering) }