Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Added --tx-queue-no-early-reject flag to disable early tx queue rejects #9143

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ethcore/private-tx/src/private_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl Default for VerificationStore {
minimal_gas_price: 0.into(),
block_gas_limit: 8_000_000.into(),
tx_gas_limit: U256::max_value(),
tx_queue_no_early_reject: false
},
pool::PrioritizationStrategy::GasPriceOnly,
)
Expand Down
4 changes: 4 additions & 0 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl Default for MinerOptions {
minimal_gas_price: DEFAULT_MINIMAL_GAS_PRICE.into(),
block_gas_limit: U256::max_value(),
tx_gas_limit: U256::max_value(),
tx_queue_no_early_reject: false,
},
}
}
Expand Down Expand Up @@ -272,6 +273,7 @@ impl Miner {
minimal_gas_price,
block_gas_limit: U256::max_value(),
tx_gas_limit: U256::max_value(),
tx_queue_no_early_reject: false,
},
reseal_min_period: Duration::from_secs(0),
..Default::default()
Expand Down Expand Up @@ -1297,12 +1299,14 @@ mod tests {
tx_queue_penalization: Penalization::Disabled,
tx_queue_strategy: PrioritizationStrategy::GasPriceOnly,
tx_queue_no_unfamiliar_locals: false,
tx_queue_no_early_reject: false,
refuse_service_transactions: false,
pool_limits: Default::default(),
pool_verification_options: pool::verifier::Options {
minimal_gas_price: 0.into(),
block_gas_limit: U256::max_value(),
tx_gas_limit: U256::max_value(),
tx_queue_no_early_reject: false,
},
},
GasPricer::new_fixed(0u64.into()),
Expand Down
12 changes: 8 additions & 4 deletions miner/src/pool/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,15 @@ impl TransactionQueue {
let options = self.options.read().clone();

let transaction_to_replace = {
let pool = self.pool.read();
if pool.is_full() {
pool.worst_transaction().map(|worst| (pool.scoring().clone(), worst))
} else {
if options.tx_queue_no_early_reject {
None
} else {
let pool = self.pool.read();
if pool.is_full() {
pool.worst_transaction().map(|worst| (pool.scoring().clone(), worst))
} else {
None
}
}
};

Expand Down
5 changes: 4 additions & 1 deletion miner/src/pool/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct Options {
pub block_gas_limit: U256,
/// Maximal gas limit for a single transaction.
pub tx_gas_limit: U256,
/// Skip check checks
pub tx_queue_no_early_reject: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be named just no_early_reject, we are in the context of tx_queue already.

Also the comment could be a bit more clear :) Maybe something like:

Skip checks for early rejection, to make sure that local transactions are always imported.

Copy link
Author

@peterbitfly peterbitfly Jul 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that comment was a leftover typo. Will fix it & also fix the failing tests.

}

#[cfg(test)]
Expand All @@ -52,6 +54,7 @@ impl Default for Options {
minimal_gas_price: 0.into(),
block_gas_limit: U256::max_value(),
tx_gas_limit: U256::max_value(),
tx_queue_no_early_reject: false,
}
}
}
Expand Down Expand Up @@ -204,7 +207,7 @@ impl<C: Client> txpool::Verifier<Transaction> for Verifier<C, ::pool::scoring::N
//
// We're checking if the transaction is below configured minimal gas price
// or the effective minimal gas price in case the pool is full.
if !tx.gas_price().is_zero() && !is_own {
if !tx.gas_price().is_zero() && !is_own {
if tx.gas_price() < &self.options.minimal_gas_price {
trace!(
target: "txqueue",
Expand Down
6 changes: 6 additions & 0 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ usage! {
"--tx-queue-no-unfamiliar-locals",
"Local transactions sent through JSON-RPC (HTTP, WebSockets, etc) will be treated as 'external' if the sending account is unknown.",

FLAG flag_tx_queue_no_early_reject: (bool) = false, or |c: &Config| c.mining.as_ref()?.tx_queue_no_early_reject.clone(),
"--tx-queue-no-early-reject",
"Disables transaction queue optimization to early reject transactions below minimal effective gas price. This allows local transactions to always enter the pool, despite it being full, but requires additional ecrecover on every transaction.",

FLAG flag_refuse_service_transactions: (bool) = false, or |c: &Config| c.mining.as_ref()?.refuse_service_transactions.clone(),
"--refuse-service-transactions",
"Always refuse service transactions.",
Expand Down Expand Up @@ -1308,6 +1312,7 @@ struct Mining {
tx_queue_ban_count: Option<u16>,
tx_queue_ban_time: Option<u16>,
tx_queue_no_unfamiliar_locals: Option<bool>,
tx_queue_no_early_reject: Option<bool>,
remove_solved: Option<bool>,
notify_work: Option<Vec<String>>,
refuse_service_transactions: Option<bool>,
Expand Down Expand Up @@ -1996,6 +2001,7 @@ mod tests {
tx_queue_ban_count: None,
tx_queue_ban_time: None,
tx_queue_no_unfamiliar_locals: None,
tx_queue_no_early_reject: None,
tx_gas_limit: None,
tx_time_limit: None,
extra_data: None,
Expand Down
1 change: 1 addition & 0 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ impl Configuration {
Some(ref d) => to_u256(d)?,
None => U256::max_value(),
},
tx_queue_no_early_reject: self.args.flag_tx_queue_no_early_reject,
})
}

Expand Down