Transaction Queue banning (#2524)

* Blacklisting transaction queue

* Using blacklisting queue in miner

* Restoring todo [ci:skip]

* Blacklisting recipients and code

* Renaming blacklisting->banning

* CLI option for banning.

* Fixing submodule commit [ci:skip]

* Fixing RPC tests

* Additional logging when dropping transactions

* whitespace

[ci:skip]

* Configurable ban duration

* Reverting fix for pruning history from config file
This commit is contained in:
Tomasz Drwięga
2016-10-27 19:28:34 +02:00
committed by Gav Wood
parent ce37b6dcb9
commit 152a551e8b
13 changed files with 457 additions and 15 deletions

View File

@@ -74,7 +74,10 @@ gas_cap = "6283184"
tx_queue_size = 1024
tx_queue_gas = "auto"
tx_queue_strategy = "gas_factor"
tx_queue_ban_count = 1
tx_queue_ban_time = 180 #s
tx_gas_limit = "6283184"
tx_time_limit = 100 #ms
extra_data = "Parity"
remove_solved = false
notify_work = ["http://localhost:3001"]

View File

@@ -187,6 +187,8 @@ usage! {
or |c: &Config| otry!(c.mining).work_queue_size.clone(),
flag_tx_gas_limit: Option<String> = None,
or |c: &Config| otry!(c.mining).tx_gas_limit.clone().map(Some),
flag_tx_time_limit: Option<u64> = None,
or |c: &Config| otry!(c.mining).tx_time_limit.clone().map(Some),
flag_relay_set: String = "cheap",
or |c: &Config| otry!(c.mining).relay_set.clone(),
flag_usd_per_tx: String = "0",
@@ -207,6 +209,10 @@ usage! {
or |c: &Config| otry!(c.mining).tx_queue_gas.clone(),
flag_tx_queue_strategy: String = "gas_price",
or |c: &Config| otry!(c.mining).tx_queue_strategy.clone(),
flag_tx_queue_ban_count: u16 = 1u16,
or |c: &Config| otry!(c.mining).tx_queue_ban_count.clone(),
flag_tx_queue_ban_time: u16 = 180u16,
or |c: &Config| otry!(c.mining).tx_queue_ban_time.clone(),
flag_remove_solved: bool = false,
or |c: &Config| otry!(c.mining).remove_solved.clone(),
flag_notify_work: Option<String> = None,
@@ -361,6 +367,7 @@ struct Mining {
reseal_min_period: Option<u64>,
work_queue_size: Option<usize>,
tx_gas_limit: Option<String>,
tx_time_limit: Option<u64>,
relay_set: Option<String>,
usd_per_tx: Option<String>,
usd_per_eth: Option<String>,
@@ -371,6 +378,8 @@ struct Mining {
tx_queue_size: Option<usize>,
tx_queue_gas: Option<String>,
tx_queue_strategy: Option<String>,
tx_queue_ban_count: Option<u16>,
tx_queue_ban_time: Option<u16>,
remove_solved: Option<bool>,
notify_work: Option<Vec<String>>,
}
@@ -558,6 +567,7 @@ mod tests {
flag_reseal_min_period: 4000u64,
flag_work_queue_size: 20usize,
flag_tx_gas_limit: Some("6283184".into()),
flag_tx_time_limit: Some(100u64),
flag_relay_set: "cheap".into(),
flag_usd_per_tx: "0".into(),
flag_usd_per_eth: "auto".into(),
@@ -568,6 +578,8 @@ mod tests {
flag_tx_queue_size: 1024usize,
flag_tx_queue_gas: "auto".into(),
flag_tx_queue_strategy: "gas_factor".into(),
flag_tx_queue_ban_count: 1u16,
flag_tx_queue_ban_time: 180u16,
flag_remove_solved: false,
flag_notify_work: Some("http://localhost:3001".into()),
@@ -727,7 +739,10 @@ mod tests {
tx_queue_size: Some(1024),
tx_queue_gas: Some("auto".into()),
tx_queue_strategy: None,
tx_queue_ban_count: None,
tx_queue_ban_time: None,
tx_gas_limit: None,
tx_time_limit: None,
extra_data: None,
remove_solved: None,
notify_work: None,

View File

@@ -166,6 +166,11 @@ Sealing/Mining Options:
--tx-gas-limit GAS Apply a limit of GAS as the maximum amount of gas
a single transaction may have for it to be mined.
(default: {flag_tx_gas_limit:?})
--tx-time-limit MS Maximal time for processing single transaction.
If enabled senders/recipients/code of transactions
offending the limit will be banned from being included
in transaction queue for 180 seconds.
(default: {flag_tx_time_limit:?})
--relay-set SET Set of transactions to relay. SET may be:
cheap - Relay any transaction in the queue (this
may include invalid transactions);
@@ -203,6 +208,13 @@ Sealing/Mining Options:
gas_price - Prioritize txs with high gas price;
gas_factor - Prioritize txs using gas price
and gas limit ratio (default: {flag_tx_queue_strategy}).
--tx-queue-ban-count C Number of times maximal time for execution (--tx-time-limit)
can be exceeded before banning sender/recipient/code.
(default: {flag_tx_queue_ban_count})
--tx-queue-ban-time SEC Banning time (in seconds) for offenders of specified
execution time limit. Also number of offending actions
have to reach the threshold within that time.
(default: {flag_tx_queue_ban_time} seconds)
--remove-solved Move solved blocks from the work package queue
instead of cloning them. This gives a slightly
faster import speed, but means that extra solutions

View File

@@ -24,7 +24,7 @@ use util::{Hashable, U256, Uint, Bytes, version_data, Secret, Address};
use util::log::Colour;
use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP};
use ethcore::client::{VMType, Mode};
use ethcore::miner::MinerOptions;
use ethcore::miner::{MinerOptions, Banning};
use rpc::{IpcConfiguration, HttpConfiguration};
use ethcore_rpc::NetworkSettings;
@@ -387,6 +387,14 @@ impl Configuration {
reseal_min_period: Duration::from_millis(self.args.flag_reseal_min_period),
work_queue_size: self.args.flag_work_queue_size,
enable_resubmission: !self.args.flag_remove_solved,
tx_queue_banning: match self.args.flag_tx_time_limit {
Some(limit) => Banning::Enabled {
min_offends: self.args.flag_tx_queue_ban_count,
offend_threshold: Duration::from_millis(limit),
ban_duration: Duration::from_secs(self.args.flag_tx_queue_ban_time as u64),
},
None => Banning::Disabled,
}
};
Ok(options)