Add code to disable the fallback gas filler

This commit is contained in:
Omar Abdulla
2025-12-04 10:52:07 +03:00
parent 3edaebdcae
commit c88f5715a4
6 changed files with 87 additions and 14 deletions
+14 -4
View File
@@ -91,7 +91,8 @@ impl Platform for GethEvmSolcPlatform {
let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context);
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let node = GethNode::new(context);
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node = GethNode::new(context, use_fallback_gas_filler);
let node = spawn_node::<GethNode>(node, genesis)?;
Ok(Box::new(node) as Box<_>)
}))
@@ -145,7 +146,8 @@ impl Platform for LighthouseGethEvmSolcPlatform {
let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context);
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let node = LighthouseGethNode::new(context);
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node = LighthouseGethNode::new(context, use_fallback_gas_filler);
let node = spawn_node::<LighthouseGethNode>(node, genesis)?;
Ok(Box::new(node) as Box<_>)
}))
@@ -206,12 +208,14 @@ impl Platform for ReviveDevNodePolkavmResolcPlatform {
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node = SubstrateNode::new(
revive_dev_node_path,
SubstrateNode::REVIVE_DEV_NODE_EXPORT_CHAINSPEC_COMMAND,
Some(revive_dev_node_consensus),
context,
&eth_rpc_connection_strings,
use_fallback_gas_filler,
);
let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>)
@@ -274,12 +278,14 @@ impl Platform for ReviveDevNodeRevmSolcPlatform {
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node = SubstrateNode::new(
revive_dev_node_path,
SubstrateNode::REVIVE_DEV_NODE_EXPORT_CHAINSPEC_COMMAND,
Some(revive_dev_node_consensus),
context,
&eth_rpc_connection_strings,
use_fallback_gas_filler,
);
let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>)
@@ -338,7 +344,9 @@ impl Platform for ZombienetPolkavmResolcPlatform {
.clone();
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let node = ZombienetNode::new(polkadot_parachain_path, context);
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node =
ZombienetNode::new(polkadot_parachain_path, context, use_fallback_gas_filler);
let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>)
}))
@@ -395,7 +403,9 @@ impl Platform for ZombienetRevmSolcPlatform {
.clone();
let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || {
let node = ZombienetNode::new(polkadot_parachain_path, context);
let use_fallback_gas_filler = matches!(context, Context::Test(..));
let node =
ZombienetNode::new(polkadot_parachain_path, context, use_fallback_gas_filler);
let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>)
}))
+6 -2
View File
@@ -76,6 +76,7 @@ pub struct GethNode {
wallet: Arc<EthereumWallet>,
nonce_manager: CachedNonceManager,
provider: OnceCell<ConcreteProvider<Ethereum, Arc<EthereumWallet>>>,
use_fallback_gas_filler: bool,
}
impl GethNode {
@@ -100,6 +101,7 @@ impl GethNode {
+ AsRef<WalletConfiguration>
+ AsRef<GethConfiguration>
+ Clone,
use_fallback_gas_filler: bool,
) -> Self {
let working_directory_configuration =
AsRef::<WorkingDirectoryConfiguration>::as_ref(&context);
@@ -126,6 +128,7 @@ impl GethNode {
wallet: wallet.clone(),
nonce_manager: Default::default(),
provider: Default::default(),
use_fallback_gas_filler,
}
}
@@ -246,7 +249,8 @@ impl GethNode {
.get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>(
self.connection_string.as_str(),
FallbackGasFiller::default(),
FallbackGasFiller::default()
.with_use_fallback_gas_filler(self.use_fallback_gas_filler),
ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(),
@@ -742,7 +746,7 @@ mod tests {
fn new_node() -> (TestExecutionContext, GethNode) {
let context = test_config();
let mut node = GethNode::new(&context);
let mut node = GethNode::new(&context, true);
node.init(context.genesis_configuration.genesis().unwrap().clone())
.expect("Failed to initialize the node")
.spawn_process()
@@ -106,6 +106,8 @@ pub struct LighthouseGethNode {
persistent_http_provider: OnceCell<ConcreteProvider<Ethereum, Arc<EthereumWallet>>>,
persistent_ws_provider: OnceCell<ConcreteProvider<Ethereum, Arc<EthereumWallet>>>,
use_fallback_gas_filler: bool,
}
impl LighthouseGethNode {
@@ -127,6 +129,7 @@ impl LighthouseGethNode {
+ AsRef<WalletConfiguration>
+ AsRef<KurtosisConfiguration>
+ Clone,
use_fallback_gas_filler: bool,
) -> Self {
let working_directory_configuration =
AsRef::<WorkingDirectoryConfiguration>::as_ref(&context);
@@ -176,6 +179,7 @@ impl LighthouseGethNode {
nonce_manager: Default::default(),
persistent_http_provider: OnceCell::const_new(),
persistent_ws_provider: OnceCell::const_new(),
use_fallback_gas_filler,
}
}
@@ -374,7 +378,8 @@ impl LighthouseGethNode {
.get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>(
self.ws_connection_string.as_str(),
FallbackGasFiller::default(),
FallbackGasFiller::default()
.with_use_fallback_gas_filler(self.use_fallback_gas_filler),
ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(),
@@ -1152,7 +1157,7 @@ mod tests {
let _guard = NODE_START_MUTEX.lock().unwrap();
let context = test_config();
let mut node = LighthouseGethNode::new(&context);
let mut node = LighthouseGethNode::new(&context, true);
node.init(context.genesis_configuration.genesis().unwrap().clone())
.expect("Failed to initialize the node")
.spawn_process()
@@ -79,6 +79,7 @@ pub struct SubstrateNode {
nonce_manager: CachedNonceManager,
provider: OnceCell<ConcreteProvider<Ethereum, Arc<EthereumWallet>>>,
consensus: Option<String>,
use_fallback_gas_filler: bool,
}
impl SubstrateNode {
@@ -105,6 +106,7 @@ impl SubstrateNode {
+ AsRef<EthRpcConfiguration>
+ AsRef<WalletConfiguration>,
existing_connection_strings: &[String],
use_fallback_gas_filler: bool,
) -> Self {
let working_directory_path =
AsRef::<WorkingDirectoryConfiguration>::as_ref(&context).as_path();
@@ -137,6 +139,7 @@ impl SubstrateNode {
nonce_manager: Default::default(),
provider: Default::default(),
consensus,
use_fallback_gas_filler,
}
}
@@ -324,7 +327,12 @@ impl SubstrateNode {
.get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>(
self.rpc_url.as_str(),
FallbackGasFiller::new(u64::MAX, 50_000_000_000, 1_000_000_000),
FallbackGasFiller::new(
u64::MAX,
50_000_000_000,
1_000_000_000,
self.use_fallback_gas_filler,
),
ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(),
@@ -825,6 +833,7 @@ mod tests {
None,
&context,
&[],
true,
);
node.init(context.genesis_configuration.genesis().unwrap().clone())
.expect("Failed to initialize the node")
@@ -896,6 +905,7 @@ mod tests {
None,
&context,
&[],
true,
);
// Call `init()`
@@ -114,6 +114,8 @@ pub struct ZombienetNode {
nonce_manager: CachedNonceManager,
provider: OnceCell<ConcreteProvider<Ethereum, Arc<EthereumWallet>>>,
use_fallback_gas_filler: bool,
}
impl ZombienetNode {
@@ -137,6 +139,7 @@ impl ZombienetNode {
context: impl AsRef<WorkingDirectoryConfiguration>
+ AsRef<EthRpcConfiguration>
+ AsRef<WalletConfiguration>,
use_fallback_gas_filler: bool,
) -> Self {
let eth_proxy_binary = AsRef::<EthRpcConfiguration>::as_ref(&context)
.path
@@ -164,6 +167,7 @@ impl ZombienetNode {
connection_string: String::new(),
node_rpc_port: None,
provider: Default::default(),
use_fallback_gas_filler,
}
}
@@ -330,7 +334,12 @@ impl ZombienetNode {
.get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>(
self.connection_string.as_str(),
FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
FallbackGasFiller::new(
u64::MAX,
5_000_000_000,
1_000_000_000,
self.use_fallback_gas_filler,
),
ChainIdFiller::default(), // TODO: use CHAIN_ID constant
NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(),
@@ -823,6 +832,7 @@ mod tests {
let mut node = ZombienetNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
true,
);
let genesis = context.genesis_configuration.genesis().unwrap().clone();
node.init(genesis).unwrap();
@@ -936,6 +946,7 @@ mod tests {
let node = ZombienetNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
true,
);
// Act
@@ -956,6 +967,7 @@ mod tests {
let node = ZombienetNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
true,
);
// Act
@@ -4,7 +4,7 @@ use alloy::{
Provider, SendableTx,
fillers::{GasFiller, TxFiller},
},
transports::TransportResult,
transports::{TransportError, TransportResult},
};
// Percentage padding applied to estimated gas (e.g. 120 = 20% padding)
@@ -17,6 +17,7 @@ pub struct FallbackGasFiller {
default_gas_limit: u64,
default_max_fee_per_gas: u128,
default_priority_fee: u128,
use_fallback_gas_filler: bool,
}
impl FallbackGasFiller {
@@ -24,19 +25,41 @@ impl FallbackGasFiller {
default_gas_limit: u64,
default_max_fee_per_gas: u128,
default_priority_fee: u128,
use_fallback_gas_filler: bool,
) -> Self {
Self {
inner: GasFiller,
default_gas_limit,
default_max_fee_per_gas,
default_priority_fee,
use_fallback_gas_filler,
}
}
pub fn with_default_gas_limit(mut self, default_gas_limit: u64) -> Self {
self.default_gas_limit = default_gas_limit;
self
}
pub fn with_default_max_fee_per_gas(mut self, default_max_fee_per_gas: u128) -> Self {
self.default_max_fee_per_gas = default_max_fee_per_gas;
self
}
pub fn with_default_priority_fee(mut self, default_priority_fee: u128) -> Self {
self.default_priority_fee = default_priority_fee;
self
}
pub fn with_use_fallback_gas_filler(mut self, use_fallback_gas_filler: bool) -> Self {
self.use_fallback_gas_filler = use_fallback_gas_filler;
self
}
}
impl Default for FallbackGasFiller {
fn default() -> Self {
FallbackGasFiller::new(25_000_000, 1_000_000_000, 1_000_000_000)
FallbackGasFiller::new(25_000_000, 1_000_000_000, 1_000_000_000, true)
}
}
@@ -64,7 +87,12 @@ where
Ok(fill) => Ok(Some(fill)),
Err(err) => {
tracing::debug!(error = ?err, "Gas Provider Estimation Failed, using fallback");
Ok(None)
if !self.use_fallback_gas_filler {
Err(err)
} else {
Ok(None)
}
}
}
}
@@ -86,13 +114,17 @@ where
}
}
Ok(tx)
} else {
} else if self.use_fallback_gas_filler {
if let Some(builder) = tx.as_mut_builder() {
builder.set_gas_limit(self.default_gas_limit);
builder.set_max_fee_per_gas(self.default_max_fee_per_gas);
builder.set_max_priority_fee_per_gas(self.default_priority_fee);
}
Ok(tx)
} else {
Err(TransportError::UnsupportedFeature(
"Fallback gas filler is disabled and we're attempting to do a gas estimate on a failing transaction",
))
}
}
}