Handle xdai zero gas prices with minimum gas price
Sometimes xdai nodes want to return zero gas price averages. Even when
that's clearly not accepted by any of the nodes.
@@ -28,6 +28,8 @@ use std::time::Duration;
use std::time::Instant;
use web30::client::Web3;
+const MIN_GAS: u128 = 1_000_000_000;
+
pub struct Oracle {
/// An instant representing the start of a short period where the balance can
/// actually go to zero. This is becuase full nodes (incluing Infura) have an infuriating
@@ -222,7 +224,7 @@ fn update_gas_price(web3: &Web3, full_node: String) {
let res = web3
.eth_gas_price()
.then(move |gas_price| match gas_price {
- Ok(value) => {
+ Ok(mut value) => {
info!(
"Got response from {} for gas price request {:?}",
full_node, value
@@ -230,6 +232,12 @@ fn update_gas_price(web3: &Web3, full_node: String) {
// Dynamic fee computation
let mut payment_settings = SETTING.get_payment_mut();
+ // somtimes xdai advertises zero gas prices, it's not actually serious about these prices
+ // as no one will accept transactions with zero gas, it's just very very low.
+ if value == Uint256::zero() {
+ info!("gas price is zero setting to! {}", MIN_GAS);
+ value = MIN_GAS.into();
+ }
// use 105% of the gas price provided by the full node, this is designed
// to keep us above the median price provided by the full node.
// This should ensure that we maintain a higher-than-median priority even
