Sunce86/fix tx pool locals for 1559 (#431)

* fixed handling of local txs after 1559 activation
This commit is contained in:
Dusan Stanivukovic 2021-06-11 10:19:08 +02:00 committed by GitHub
parent b928380b64
commit 5dec58ba9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -131,8 +131,12 @@ where
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;
}
}
// We are only sending an event in case of penalization.
// So just lower the priority of all non-local transactions.
Change::Event(event) => {
@ -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;
}
}
}
}

View File

@ -1169,7 +1169,7 @@ impl miner::MinerService for Miner {
ordering: miner::PendingOrdering,
) -> Vec<Arc<VerifiedTransaction>>
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 {

View File

@ -226,7 +226,7 @@ pub trait MinerService: Send + Sync {
ordering: PendingOrdering,
) -> Vec<Arc<VerifiedTransaction>>
where
C: ChainInfo + Nonce + Sync;
C: BlockChain + Nonce + Sync;
/// Get an unfiltered list of all ready transactions.
fn ready_transactions<C>(
@ -236,7 +236,7 @@ pub trait MinerService: Send + Sync {
ordering: PendingOrdering,
) -> Vec<Arc<VerifiedTransaction>>
where
C: ChainInfo + Nonce + Sync,
C: BlockChain + Nonce + Sync,
{
self.ready_transactions_filtered(chain, max_len, None, ordering)
}