diff --git a/bin/silius/src/bundler.rs b/bin/silius/src/bundler.rs index 9eb445a6..e167eba3 100644 --- a/bin/silius/src/bundler.rs +++ b/bin/silius/src/bundler.rs @@ -152,6 +152,7 @@ where client, uopool_grpc_client, metrics_args.enable_metrics, + args.enable_access_list, ); } SendStrategy::Flashbots => { @@ -180,6 +181,7 @@ where client, uopool_grpc_client, metrics_args.enable_metrics, + args.enable_access_list, ); } } diff --git a/bin/silius/src/cli/args.rs b/bin/silius/src/cli/args.rs index 24f411ea..feb7cc33 100644 --- a/bin/silius/src/cli/args.rs +++ b/bin/silius/src/cli/args.rs @@ -66,6 +66,10 @@ pub struct BundlerArgs { /// By default, this option is set to `ethereum-client`. #[clap(long, default_value = "ethereum-client", value_parser=parse_send_bundle_mode)] pub send_bundle_mode: SendStrategy, + + /// Indicates whether the access list is enabled. + #[clap(long)] + pub enable_access_list: bool, } /// UoPool CLI args @@ -352,6 +356,7 @@ mod tests { send_bundle_mode: SendStrategy::EthereumClient, bundler_addr: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), bundler_port: 3002, + enable_access_list: false, }, BundlerArgs::try_parse_from(args).unwrap() ); diff --git a/crates/bundler/src/bundler.rs b/crates/bundler/src/bundler.rs index 31121e18..e639fa3d 100644 --- a/crates/bundler/src/bundler.rs +++ b/crates/bundler/src/bundler.rs @@ -1,4 +1,4 @@ -use alloy_chains::{Chain, NamedChain}; +use alloy_chains::Chain; use ethers::{ providers::Middleware, signers::Signer, @@ -45,6 +45,8 @@ where pub eth_client: Arc, /// Client that sends the bundle to some network pub client: Arc, + /// Whether add access list into tx + pub enable_access_list: bool, } impl Bundler @@ -56,6 +58,7 @@ where /// /// # Returns /// * `Self` - A new `Bundler` instance + #[allow(clippy::too_many_arguments)] pub fn new( wallet: Wallet, beneficiary: Address, @@ -64,8 +67,18 @@ where min_balance: U256, eth_client: Arc, client: Arc, + enable_access_list: bool, ) -> Self { - Self { wallet, beneficiary, entry_point, chain, min_balance, eth_client, client } + Self { + wallet, + beneficiary, + entry_point, + chain, + min_balance, + eth_client, + client, + enable_access_list, + } } /// Functions that generates a bundle of user operations (i.e., @@ -95,34 +108,30 @@ where ) .tx; - match Chain::from_id(self.chain.id()).named() { - // Mumbai - Some(NamedChain::PolygonMumbai) => { - tx.set_nonce(nonce).set_chain_id(self.chain.id()); - } - // All other surpported networks, including Mainnet, Goerli - _ => { - let accesslist = self.eth_client.create_access_list(&tx, None).await?.access_list; - tx.set_access_list(accesslist.clone()); - let estimated_gas = self.eth_client.estimate_gas(&tx, None).await?; + let accesslist = if self.enable_access_list { + let accesslist = self.eth_client.create_access_list(&tx, None).await?.access_list; + tx.set_access_list(accesslist.clone()); + accesslist + } else { + Default::default() + }; + let estimated_gas = self.eth_client.estimate_gas(&tx, None).await?; - let (max_fee_per_gas, max_priority_fee) = - self.eth_client.estimate_eip1559_fees(None).await?; + let (max_fee_per_gas, max_priority_fee) = + self.eth_client.estimate_eip1559_fees(None).await?; - tx = TypedTransaction::Eip1559(Eip1559TransactionRequest { - to: tx.to().cloned(), - from: Some(self.wallet.signer.address()), - data: tx.data().cloned(), - chain_id: Some(U64::from(self.chain.id())), - max_priority_fee_per_gas: Some(max_priority_fee), - max_fee_per_gas: Some(max_fee_per_gas), - gas: Some(estimated_gas), - nonce: Some(nonce), - value: None, - access_list: accesslist, - }); - } - }; + tx = TypedTransaction::Eip1559(Eip1559TransactionRequest { + to: tx.to().cloned(), + from: Some(self.wallet.signer.address()), + data: tx.data().cloned(), + chain_id: Some(U64::from(self.chain.id())), + max_priority_fee_per_gas: Some(max_priority_fee), + max_fee_per_gas: Some(max_fee_per_gas), + gas: Some(estimated_gas), + nonce: Some(nonce), + value: None, + access_list: accesslist, + }); Ok(tx) } diff --git a/crates/bundler/tests/bundler.rs b/crates/bundler/tests/bundler.rs index 6623acd7..953ae36d 100644 --- a/crates/bundler/tests/bundler.rs +++ b/crates/bundler/tests/bundler.rs @@ -93,6 +93,7 @@ async fn setup() -> eyre::Result, FlashbotsClient( client: Arc, uopool_grpc_client: UoPoolClient, enable_metrics: bool, + enable_access_list: bool, ) where M: Middleware + Clone + 'static, S: SendBundleOp + Clone + 'static, @@ -190,6 +191,7 @@ pub fn bundler_service_run( min_balance, eth_client.clone(), client.clone(), + enable_access_list, ) }) .collect();