From 22becf6d11650b341ee4fde219acae18a3a7afc9 Mon Sep 17 00:00:00 2001 From: WillQ Date: Thu, 1 Feb 2024 11:21:06 +0800 Subject: [PATCH 1/3] fix: accesslist request not insufficient funds --- bin/silius/src/bundler.rs | 2 + bin/silius/src/cli/args.rs | 5 +++ crates/bundler/src/bundler.rs | 65 +++++++++++++++++++-------------- crates/bundler/tests/bundler.rs | 1 + crates/grpc/src/bundler.rs | 2 + 5 files changed, 47 insertions(+), 28 deletions(-) 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(); From 12f477574e3f2cc52f6324f45dcaad5245a26d2e Mon Sep 17 00:00:00 2001 From: WillQ Date: Thu, 1 Feb 2024 14:25:22 +0800 Subject: [PATCH 2/3] chore: init metrics --- crates/metrics/src/grpc.rs | 3 +++ crates/metrics/src/mempool.rs | 9 ++++++++- crates/metrics/src/rpc.rs | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/metrics/src/grpc.rs b/crates/metrics/src/grpc.rs index 84f5442a..491bcbcc 100644 --- a/crates/metrics/src/grpc.rs +++ b/crates/metrics/src/grpc.rs @@ -71,4 +71,7 @@ pub fn describe_grpc_metrics() { describe_counter!(GRPC_REQUEST, "grpc request count"); describe_counter!(GRPC_REQUEST_SUCCESS, "grpc request success count"); describe_counter!(GRPC_REQUEST_FAILED, "grpc request failed count"); + counter!(GRPC_REQUEST).absolute(0); + counter!(GRPC_REQUEST_SUCCESS).absolute(0); + counter!(GRPC_REQUEST_FAILED).absolute(0); } diff --git a/crates/metrics/src/mempool.rs b/crates/metrics/src/mempool.rs index 83e192cd..4fe63a34 100644 --- a/crates/metrics/src/mempool.rs +++ b/crates/metrics/src/mempool.rs @@ -129,5 +129,12 @@ pub fn describe_mempool_metrics() { describe_counter!( REPUTATION_SET_ENTRY_ERROR, "The number of errors when setting a reputation entry" - ) + ); + counter!(MEMPOOL_ADD_ERROR).absolute(0); + counter!(MEMPOOL_REMOVE_ERROR).absolute(0); + counter!(REPUTATION_SET_ENTRY_ERROR).absolute(0); + gauge!(MEMPOOL_SIZE).set(0f64); + gauge!(REPUTATION_UO_SEEN).set(0f64); + gauge!(REPUTATION_UO_INCLUDED).set(0f64); + gauge!(REPUTATION_STATUS).set(0f64); } diff --git a/crates/metrics/src/rpc.rs b/crates/metrics/src/rpc.rs index 4caeaa42..7d55cae8 100644 --- a/crates/metrics/src/rpc.rs +++ b/crates/metrics/src/rpc.rs @@ -103,5 +103,8 @@ impl> Future for MetricsFuture { pub fn describe_json_rpc_metrics() { describe_counter!(RPC_REQUEST, "The number of json rpc requests so far"); describe_counter!(RPC_REQUEST_SUCCESS, "The number of successful json rpc requests so far"); - describe_counter!(RPC_REQUEST_FAILED, "The number of failed json rpc requests so far") + describe_counter!(RPC_REQUEST_FAILED, "The number of failed json rpc requests so far"); + counter!(RPC_REQUEST).absolute(0); + counter!(RPC_REQUEST_SUCCESS).absolute(0); + counter!(RPC_REQUEST_FAILED).absolute(0); } From 5328e01ae81758023af94cf43324f109c14fba31 Mon Sep 17 00:00:00 2001 From: WillQ Date: Thu, 1 Feb 2024 15:02:32 +0800 Subject: [PATCH 3/3] chore: update public endpoints --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 66c52a5a..b5ad470e 100644 --- a/README.md +++ b/README.md @@ -78,26 +78,26 @@ Silius was tested on the following networks, and some public endpoints are avail | Chain | Supported Status | Public RPC URL | | :--------: | :-------: | :-------: | -| Ethereum | :heavy_check_mark:| :soon: | +| Ethereum | :heavy_check_mark:| | | Ethereum Goerli | :heavy_check_mark: | | | Ethereum Sepolia| :heavy_check_mark: | | | Ethereum Holesky| :heavy_check_mark: | | -| Polygon | :x: | :soon: | +| Polygon | :heavy_check_mark: | | | Polygon Mumbai| :heavy_check_mark: | | -| Linea | :x: | :soon: | +| Linea | :heavy_check_mark: | | | Linea Goerli | :heavy_check_mark: | | -| Optimism | :x: | :soon: | +| Optimism | :heavy_check_mark: | | | Optimism Goerli | :heavy_check_mark: | | | Optimism Sepolia | :heavy_check_mark: | | -| Arbitrum | :x: | :soon: | +| Arbitrum | :heavy_check_mark: | | | Arbitrum Goerli | :heavy_check_mark: | | | Arbitrum Sepolia | :heavy_check_mark: | | -| BSC | :x: | :soon: | +| BSC | :heavy_check_mark: | | | BSC Testnet | :heavy_check_mark: | | -| Base | :x: | :soon: | +| Base | :heavy_check_mark: | | | Base Goerli | :heavy_check_mark: | | | Base Sepolia | :heavy_check_mark: | | -| Avalanche | :x: | :soon: | +| Avalanche | :heavy_check_mark: | | | Avalanche Fuji | :heavy_check_mark: | | Bundler's account: `0x0a4E15d25E97e747bD568979A3B7dbEb95970Eb3`