Skip to content

Commit

Permalink
Merge pull request #13 from ambrosus/fixgasprice
Browse files Browse the repository at this point in the history
Fix zero gas price
  • Loading branch information
SigismundSchlomo authored Feb 1, 2024
2 parents ba11b2e + 6ad8d56 commit 2c77dd0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions bin/oe/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
*client.best_block_header().gas_limit(),
base_fee,
allow_non_eoa_sender,
None,
);

let connection_filter = connection_filter_address.map(|a| {
Expand Down
53 changes: 40 additions & 13 deletions crates/ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,45 @@ impl Miner {
block_gas_limit: U256,
block_base_fee: Option<U256>,
allow_non_eoa_sender: bool,
gas_price: Option<U256>,
) {
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 => (),
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2c77dd0

Please sign in to comment.