parent
5f103ee33d
commit
1f7fb1591d
@ -90,6 +90,8 @@ pub struct MinerOptions {
|
|||||||
pub reseal_on_own_tx: bool,
|
pub reseal_on_own_tx: bool,
|
||||||
/// Minimum period between transaction-inspired reseals.
|
/// Minimum period between transaction-inspired reseals.
|
||||||
pub reseal_min_period: Duration,
|
pub reseal_min_period: Duration,
|
||||||
|
/// Maximum period between blocks (enables force sealing after that).
|
||||||
|
pub reseal_max_period: Duration,
|
||||||
/// Maximum amount of gas to bother considering for block insertion.
|
/// Maximum amount of gas to bother considering for block insertion.
|
||||||
pub tx_gas_limit: U256,
|
pub tx_gas_limit: U256,
|
||||||
/// Maximum size of the transaction queue.
|
/// Maximum size of the transaction queue.
|
||||||
@ -123,6 +125,7 @@ impl Default for MinerOptions {
|
|||||||
tx_queue_strategy: PrioritizationStrategy::GasPriceOnly,
|
tx_queue_strategy: PrioritizationStrategy::GasPriceOnly,
|
||||||
pending_set: PendingSet::AlwaysQueue,
|
pending_set: PendingSet::AlwaysQueue,
|
||||||
reseal_min_period: Duration::from_secs(2),
|
reseal_min_period: Duration::from_secs(2),
|
||||||
|
reseal_max_period: Duration::from_secs(120),
|
||||||
work_queue_size: 20,
|
work_queue_size: 20,
|
||||||
enable_resubmission: true,
|
enable_resubmission: true,
|
||||||
tx_queue_banning: Banning::Disabled,
|
tx_queue_banning: Banning::Disabled,
|
||||||
@ -212,6 +215,7 @@ pub struct Miner {
|
|||||||
transaction_queue: Arc<Mutex<BanningTransactionQueue>>,
|
transaction_queue: Arc<Mutex<BanningTransactionQueue>>,
|
||||||
sealing_work: Mutex<SealingWork>,
|
sealing_work: Mutex<SealingWork>,
|
||||||
next_allowed_reseal: Mutex<Instant>,
|
next_allowed_reseal: Mutex<Instant>,
|
||||||
|
next_mandatory_reseal: RwLock<Instant>,
|
||||||
sealing_block_last_request: Mutex<u64>,
|
sealing_block_last_request: Mutex<u64>,
|
||||||
// for sealing...
|
// for sealing...
|
||||||
options: MinerOptions,
|
options: MinerOptions,
|
||||||
@ -268,6 +272,7 @@ impl Miner {
|
|||||||
Miner {
|
Miner {
|
||||||
transaction_queue: Arc::new(Mutex::new(txq)),
|
transaction_queue: Arc::new(Mutex::new(txq)),
|
||||||
next_allowed_reseal: Mutex::new(Instant::now()),
|
next_allowed_reseal: Mutex::new(Instant::now()),
|
||||||
|
next_mandatory_reseal: RwLock::new(Instant::now() + options.reseal_max_period),
|
||||||
sealing_block_last_request: Mutex::new(0),
|
sealing_block_last_request: Mutex::new(0),
|
||||||
sealing_work: Mutex::new(SealingWork{
|
sealing_work: Mutex::new(SealingWork{
|
||||||
queue: UsingQueue::new(options.work_queue_size),
|
queue: UsingQueue::new(options.work_queue_size),
|
||||||
@ -298,7 +303,9 @@ impl Miner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn forced_sealing(&self) -> bool {
|
fn forced_sealing(&self) -> bool {
|
||||||
self.options.force_sealing || !self.options.new_work_notify.is_empty()
|
self.options.force_sealing
|
||||||
|
|| !self.options.new_work_notify.is_empty()
|
||||||
|
|| Instant::now() > *self.next_mandatory_reseal.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear all pending block states
|
/// Clear all pending block states
|
||||||
@ -482,6 +489,7 @@ impl Miner {
|
|||||||
// Save proposal for later seal submission and broadcast it.
|
// Save proposal for later seal submission and broadcast it.
|
||||||
Seal::Proposal(seal) => {
|
Seal::Proposal(seal) => {
|
||||||
trace!(target: "miner", "Received a Proposal seal.");
|
trace!(target: "miner", "Received a Proposal seal.");
|
||||||
|
*self.next_mandatory_reseal.write() = Instant::now() + self.options.reseal_max_period;
|
||||||
{
|
{
|
||||||
let mut sealing_work = self.sealing_work.lock();
|
let mut sealing_work = self.sealing_work.lock();
|
||||||
sealing_work.queue.push(block.clone());
|
sealing_work.queue.push(block.clone());
|
||||||
@ -497,7 +505,8 @@ impl Miner {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// Directly import a regular sealed block.
|
// Directly import a regular sealed block.
|
||||||
Seal::Regular(seal) =>
|
Seal::Regular(seal) => {
|
||||||
|
*self.next_mandatory_reseal.write() = Instant::now() + self.options.reseal_max_period;
|
||||||
block
|
block
|
||||||
.lock()
|
.lock()
|
||||||
.seal(&*self.engine, seal)
|
.seal(&*self.engine, seal)
|
||||||
@ -505,7 +514,8 @@ impl Miner {
|
|||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!("ERROR: seal failed when given internally generated seal: {}", e);
|
warn!("ERROR: seal failed when given internally generated seal: {}", e);
|
||||||
false
|
false
|
||||||
}),
|
})
|
||||||
|
},
|
||||||
Seal::None => false,
|
Seal::None => false,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1290,6 +1300,7 @@ mod tests {
|
|||||||
reseal_on_external_tx: false,
|
reseal_on_external_tx: false,
|
||||||
reseal_on_own_tx: true,
|
reseal_on_own_tx: true,
|
||||||
reseal_min_period: Duration::from_secs(5),
|
reseal_min_period: Duration::from_secs(5),
|
||||||
|
reseal_max_period: Duration::from_secs(120),
|
||||||
tx_gas_limit: !U256::zero(),
|
tx_gas_limit: !U256::zero(),
|
||||||
tx_queue_size: 1024,
|
tx_queue_size: 1024,
|
||||||
tx_queue_gas_limit: GasLimit::None,
|
tx_queue_gas_limit: GasLimit::None,
|
||||||
|
@ -85,6 +85,7 @@ engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
|||||||
force_sealing = true
|
force_sealing = true
|
||||||
reseal_on_txs = "all"
|
reseal_on_txs = "all"
|
||||||
reseal_min_period = 4000
|
reseal_min_period = 4000
|
||||||
|
reseal_max_period = 60000
|
||||||
work_queue_size = 20
|
work_queue_size = 20
|
||||||
relay_set = "cheap"
|
relay_set = "cheap"
|
||||||
usd_per_tx = "0.0025"
|
usd_per_tx = "0.0025"
|
||||||
|
@ -50,6 +50,7 @@ engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
|||||||
force_sealing = true
|
force_sealing = true
|
||||||
reseal_on_txs = "all"
|
reseal_on_txs = "all"
|
||||||
reseal_min_period = 4000
|
reseal_min_period = 4000
|
||||||
|
reseal_max_period = 60000
|
||||||
price_update_period = "hourly"
|
price_update_period = "hourly"
|
||||||
tx_queue_size = 1024
|
tx_queue_size = 1024
|
||||||
tx_queue_gas = "auto"
|
tx_queue_gas = "auto"
|
||||||
|
@ -224,6 +224,8 @@ usage! {
|
|||||||
or |c: &Config| otry!(c.mining).reseal_on_txs.clone(),
|
or |c: &Config| otry!(c.mining).reseal_on_txs.clone(),
|
||||||
flag_reseal_min_period: u64 = 2000u64,
|
flag_reseal_min_period: u64 = 2000u64,
|
||||||
or |c: &Config| otry!(c.mining).reseal_min_period.clone(),
|
or |c: &Config| otry!(c.mining).reseal_min_period.clone(),
|
||||||
|
flag_reseal_max_period: u64 = 120000u64,
|
||||||
|
or |c: &Config| otry!(c.mining).reseal_max_period.clone(),
|
||||||
flag_work_queue_size: usize = 20usize,
|
flag_work_queue_size: usize = 20usize,
|
||||||
or |c: &Config| otry!(c.mining).work_queue_size.clone(),
|
or |c: &Config| otry!(c.mining).work_queue_size.clone(),
|
||||||
flag_tx_gas_limit: Option<String> = None,
|
flag_tx_gas_limit: Option<String> = None,
|
||||||
@ -460,6 +462,7 @@ struct Mining {
|
|||||||
force_sealing: Option<bool>,
|
force_sealing: Option<bool>,
|
||||||
reseal_on_txs: Option<String>,
|
reseal_on_txs: Option<String>,
|
||||||
reseal_min_period: Option<u64>,
|
reseal_min_period: Option<u64>,
|
||||||
|
reseal_max_period: Option<u64>,
|
||||||
work_queue_size: Option<usize>,
|
work_queue_size: Option<usize>,
|
||||||
tx_gas_limit: Option<String>,
|
tx_gas_limit: Option<String>,
|
||||||
tx_time_limit: Option<u64>,
|
tx_time_limit: Option<u64>,
|
||||||
@ -701,6 +704,7 @@ mod tests {
|
|||||||
flag_force_sealing: true,
|
flag_force_sealing: true,
|
||||||
flag_reseal_on_txs: "all".into(),
|
flag_reseal_on_txs: "all".into(),
|
||||||
flag_reseal_min_period: 4000u64,
|
flag_reseal_min_period: 4000u64,
|
||||||
|
flag_reseal_max_period: 60000u64,
|
||||||
flag_work_queue_size: 20usize,
|
flag_work_queue_size: 20usize,
|
||||||
flag_tx_gas_limit: Some("6283184".into()),
|
flag_tx_gas_limit: Some("6283184".into()),
|
||||||
flag_tx_time_limit: Some(100u64),
|
flag_tx_time_limit: Some(100u64),
|
||||||
@ -900,6 +904,7 @@ mod tests {
|
|||||||
force_sealing: Some(true),
|
force_sealing: Some(true),
|
||||||
reseal_on_txs: Some("all".into()),
|
reseal_on_txs: Some("all".into()),
|
||||||
reseal_min_period: Some(4000),
|
reseal_min_period: Some(4000),
|
||||||
|
reseal_max_period: Some(60000),
|
||||||
work_queue_size: None,
|
work_queue_size: None,
|
||||||
relay_set: None,
|
relay_set: None,
|
||||||
usd_per_tx: None,
|
usd_per_tx: None,
|
||||||
|
@ -224,6 +224,9 @@ Sealing/Mining Options:
|
|||||||
--reseal-min-period MS Specify the minimum time between reseals from
|
--reseal-min-period MS Specify the minimum time between reseals from
|
||||||
incoming transactions. MS is time measured in
|
incoming transactions. MS is time measured in
|
||||||
milliseconds (default: {flag_reseal_min_period}).
|
milliseconds (default: {flag_reseal_min_period}).
|
||||||
|
--reseal-max-period MS Specify the maximum time since last block to enable
|
||||||
|
force-sealing. MS is time measured in
|
||||||
|
milliseconds (default: {flag_reseal_max_period}).
|
||||||
--work-queue-size ITEMS Specify the number of historical work packages
|
--work-queue-size ITEMS Specify the number of historical work packages
|
||||||
which are kept cached lest a solution is found for
|
which are kept cached lest a solution is found for
|
||||||
them later. High values take more memory but result
|
them later. High values take more memory but result
|
||||||
|
@ -522,6 +522,7 @@ impl Configuration {
|
|||||||
tx_queue_strategy: to_queue_strategy(&self.args.flag_tx_queue_strategy)?,
|
tx_queue_strategy: to_queue_strategy(&self.args.flag_tx_queue_strategy)?,
|
||||||
pending_set: to_pending_set(&self.args.flag_relay_set)?,
|
pending_set: to_pending_set(&self.args.flag_relay_set)?,
|
||||||
reseal_min_period: Duration::from_millis(reseal_min_period),
|
reseal_min_period: Duration::from_millis(reseal_min_period),
|
||||||
|
reseal_max_period: Duration::from_millis(self.args.flag_reseal_max_period),
|
||||||
work_queue_size: self.args.flag_work_queue_size,
|
work_queue_size: self.args.flag_work_queue_size,
|
||||||
enable_resubmission: !self.args.flag_remove_solved,
|
enable_resubmission: !self.args.flag_remove_solved,
|
||||||
tx_queue_banning: match self.args.flag_tx_time_limit {
|
tx_queue_banning: match self.args.flag_tx_time_limit {
|
||||||
|
@ -64,6 +64,7 @@ fn miner_service(spec: &Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
|
|||||||
tx_queue_banning: Banning::Disabled,
|
tx_queue_banning: Banning::Disabled,
|
||||||
pending_set: PendingSet::SealingOrElseQueue,
|
pending_set: PendingSet::SealingOrElseQueue,
|
||||||
reseal_min_period: Duration::from_secs(0),
|
reseal_min_period: Duration::from_secs(0),
|
||||||
|
reseal_max_period: Duration::from_secs(120),
|
||||||
work_queue_size: 50,
|
work_queue_size: 50,
|
||||||
enable_resubmission: true,
|
enable_resubmission: true,
|
||||||
refuse_service_transactions: false,
|
refuse_service_transactions: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user