Skip to content

Commit

Permalink
feat: support all available chains
Browse files Browse the repository at this point in the history
  • Loading branch information
zsluedem committed Dec 30, 2023
1 parent a05d4ef commit a84cb80
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Bundler was tested on the following networks:
| Ethereum | :soon: | :soon: (Goerli), :heavy_check_mark: (Sepolia) |
| Polygon PoS | :soon: | :heavy_check_mark: (Mumbai) |

**You could also try any other evm network but it is possible you would meet some problems so use is at your own risk. You are welcomed to open any issues when you meet a problem**

## Supported entry point
The address of the entry point smart contract is the same on all EVM networks.
| Address | Version | Commit | Audited |
Expand Down
29 changes: 22 additions & 7 deletions bin/silius/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
},
utils::unwrap_path_or_home,
};
use alloy_chains::Chain;
use alloy_chains::{Chain, NamedChain};
use ethers::{providers::Middleware, types::Address};
use parking_lot::RwLock;
use silius_contracts::EntryPoint;
Expand Down Expand Up @@ -46,7 +46,7 @@ use std::{
str::FromStr,
sync::Arc,
};
use tracing::info;
use tracing::{info, warn};

pub async fn launch_bundler<M>(
bundler_args: BundlerArgs,
Expand All @@ -63,7 +63,7 @@ where
uopool_args.clone(),
eth_client.clone(),
block_streams,
common_args.chain.clone(),
common_args.chain,
common_args.entry_points.clone(),
)
.await?;
Expand All @@ -90,7 +90,7 @@ where
pub async fn launch_bundling<M>(
args: BundlerArgs,
eth_client: Arc<M>,
chain: Option<String>,
chain: Option<NamedChain>,
entry_points: Vec<Address>,
uopool_grpc_listen_address: String,
) -> eyre::Result<()>
Expand Down Expand Up @@ -149,7 +149,7 @@ pub async fn launch_uopool<M>(
args: UoPoolArgs,
eth_client: Arc<M>,
block_streams: Vec<BlockStream>,
chain: Option<String>,
chain: Option<NamedChain>,
entry_points: Vec<Address>,
) -> eyre::Result<()>
where
Expand Down Expand Up @@ -483,12 +483,27 @@ pub fn create_wallet(args: CreateWalletArgs) -> eyre::Result<()> {
Ok(())
}

async fn check_connected_chain<M>(eth_client: Arc<M>, chain: Option<String>) -> eyre::Result<String>
async fn check_connected_chain<M>(
eth_client: Arc<M>,
chain: Option<NamedChain>,
) -> eyre::Result<String>
where
M: Middleware + Clone + 'static,
{
if let Some(chain) = chain {
let chain = Chain::from_str(chain.as_str())?;
match chain {
NamedChain::Mainnet |
NamedChain::Goerli |
NamedChain::Sepolia |
NamedChain::PolygonMumbai |
NamedChain::Dev => {}
_ => {
warn!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
warn!("Chain {:?} is not officially supported yet! You could possibly meet a lot of problems with silius. Use at your own risk!!", chain);
warn!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
let chain: Chain = chain.into();

let chain_id = eth_client.get_chainid().await?.as_u64();
if chain.id() != chain_id {
Expand Down
10 changes: 6 additions & 4 deletions bin/silius/src/cli/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::utils::{
parse_address, parse_duration, parse_enr, parse_send_bundle_mode, parse_u256, parse_uopool_mode,
};
use alloy_chains::NamedChain;
use clap::{Parser, ValueEnum};
use discv5::Enr;
use ethers::types::{Address, U256};
Expand All @@ -12,7 +13,6 @@ use silius_primitives::{
bundler::BUNDLE_INTERVAL,
grpc::{BUNDLER_PORT, MEMPOOL_PORT},
rpc::{HTTP_PORT, WS_PORT},
supported_chains::SUPPORTED_NAMED_CHAINS,
},
UoPoolMode,
};
Expand Down Expand Up @@ -119,8 +119,8 @@ pub struct BundlerAndUoPoolArgs {
pub eth_client_address: String,

/// Chain information.
#[clap(long, value_parser = SUPPORTED_NAMED_CHAINS)]
pub chain: Option<String>,
#[clap(long)]
pub chain: Option<NamedChain>,

/// Entry point addresses.
#[clap(long, value_delimiter=',', value_parser=parse_address)]
Expand Down Expand Up @@ -339,6 +339,8 @@ mod tests {
"bundleranduopoolargs",
"--eth-client-address",
"http://127.0.0.1:8545",
"--chain",
"holesky",
"--entry-points",
"0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990",
"--poll-interval",
Expand All @@ -347,7 +349,7 @@ mod tests {
assert_eq!(
BundlerAndUoPoolArgs {
eth_client_address: String::from("http://127.0.0.1:8545"),
chain: None,
chain: Some(NamedChain::Holesky),
entry_points: vec![
Address::from_str("0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990").unwrap()
],
Expand Down
1 change: 0 additions & 1 deletion crates/primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ pub mod flashbots_relay_endpoints {
/// Supported chains
pub mod supported_chains {
pub const SUPPORTED_CHAINS: [u64; 5] = [MAINNET, GOERLI, SEPOLIA, DEV, MUMBAI];
pub const SUPPORTED_NAMED_CHAINS: [&str; 5] = ["mainnet", "goerli", "sepolia", "dev", "mumbai"];

// dev
pub const DEV: u64 = 1337;
Expand Down

0 comments on commit a84cb80

Please sign in to comment.