diff --git a/bin/oe/run.rs b/bin/oe/run.rs index eaf582bc69..22762416ca 100644 --- a/bin/oe/run.rs +++ b/bin/oe/run.rs @@ -377,6 +377,7 @@ pub fn execute(cmd: RunCmd, logger: Arc) -> Result, allow_non_eoa_sender: bool, + gas_price: Option, ) { - trace!(target: "miner", "minimal_gas_price: recalibrating..."); - let txq = self.transaction_queue.clone(); - let mut options = self.options.pool_verification_options.clone(); - self.gas_pricer.lock().recalibrate(move |gas_price| { - debug!(target: "miner", "minimal_gas_price: Got gas price! {}", gas_price); - options.minimal_gas_price = gas_price; - options.block_gas_limit = block_gas_limit; - options.block_base_fee = block_base_fee; - options.allow_non_eoa_sender = allow_non_eoa_sender; - txq.set_verifier_options(options); - }); - + if let Some(new_price) = gas_price { + match *self.gas_pricer.lock() { + // Binding the gas pricer to `gp` here to prevent + // a deadlock when calling recalibrate() + ref mut gp @ GasPricer::Fixed(_) => { + trace!(target: "miner", "minimal_gas_price: recalibrating fixed..."); + *gp = GasPricer::new_fixed(new_price); + + let txq = self.transaction_queue.clone(); + let mut options = self.options.pool_verification_options.clone(); + gp.recalibrate(move |gas_price| { + debug!(target: "miner", "minimal_gas_price: Got gas price! {}", gas_price); + options.minimal_gas_price = gas_price; + options.block_gas_limit = block_gas_limit; + options.block_base_fee = block_base_fee; + options.allow_non_eoa_sender = allow_non_eoa_sender; + txq.set_verifier_options(options); + }); + } + #[cfg(feature = "price-info")] + GasPricer::Calibrated(_) => { + debug!(target: "miner","Can't update fixed gas price while automatic gas calibration is enabled."); + } + } + } else { + trace!(target: "miner", "minimal_gas_price: recalibrating..."); + let txq = self.transaction_queue.clone(); + let mut options = self.options.pool_verification_options.clone(); + self.gas_pricer.lock().recalibrate(move |gas_price| { + debug!(target: "miner", "minimal_gas_price: Got gas price! {}", gas_price); + options.minimal_gas_price = gas_price; + options.block_gas_limit = block_gas_limit; + options.block_base_fee = block_base_fee; + options.allow_non_eoa_sender = allow_non_eoa_sender; + txq.set_verifier_options(options); + }); + } match block_base_fee { Some(block_base_fee) => self.transaction_queue.update_scoring(block_base_fee), None => (), @@ -1490,7 +1516,8 @@ impl miner::MinerService for Miner { let allow_non_eoa_sender = self .engine .allow_non_eoa_sender(chain.best_block_header().number() + 1); - self.update_transaction_queue_limits(gas_limit, base_fee, allow_non_eoa_sender); + let gas_price = self.engine.current_gas_price(&chain.best_block_header()); + self.update_transaction_queue_limits(gas_limit, base_fee, allow_non_eoa_sender, gas_price); // t_nb 10.2 Then import all transactions from retracted blocks (retracted means from side chain). let client = self.pool_client(chain);