diff --git a/Cargo.toml b/Cargo.toml index a229d047..2b614bcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ rust-version = "1.73.0" alloy-chains = "0.1.2" async-stream = "0.3.5" async-trait = "0.1" -discv5 = { version = "0.3.0", features = ["libp2p"] } +discv5 = { version = "0.3.1", features = ["libp2p"] } ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "fa3017715a298728d9fb341933818a5d0d84c2dc", features = [ "ws", ] } diff --git a/Makefile b/Makefile index 024a79e8..e5522299 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ build: cargo build --release + build-debug-mode: cargo build + run-silius: - cargo run --release -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws + cargo run --release -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws run-silius-bundling: - cargo run --release -- bundling --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 + cargo run --release -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 run-silius-uopool: cargo run --release -- uopool --eth-client-address http://127.0.0.1:8545 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 @@ -18,10 +20,10 @@ run-silius-create-wallet: cargo run --release -- create-wallet --output-path ${HOME}/.silius run-silius-debug: - cargo run --release -- bundler --eth-client-address ws://127.0.0.1:8546 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws --http.api eth,debug,web3 --ws.api eth,debug,web3 + cargo run --release -- node --eth-client-address ws://127.0.0.1:8546 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws --http.api eth,debug,web3 --ws.api eth,debug,web3 run-silius-debug-mode: - cargo run --profile debug-fast -- bundler --verbosity 4 --eth-client-address ws://127.0.0.1:8546 --mnemonic-file /home/vid/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws --http.api eth,debug,web3 --ws.api eth,debug,web3 + cargo run --profile debug-fast -- node --verbosity 4 --eth-client-address ws://127.0.0.1:8546 --mnemonic-file /home/vid/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws --http.api eth,debug,web3 --ws.api eth,debug,web3 fetch-thirdparty: git submodule update --init diff --git a/README.md b/README.md index a8d571ce..c8e6f22e 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,13 @@ cargo run --release -- create-wallet --output-path ${HOME}/.silius --chain-id 5 Run bundler (with user operation pool and JSON-RPC API): ```bash -cargo run --release -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws +cargo run --release -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --ws ``` Run only bundling component: ```bash -cargo run --release -- bundling --eth-client-address ws://127.0.0.1:8546 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 +cargo run --release -- bundler --eth-client-address ws://127.0.0.1:8546 --mnemonic-file ${HOME}/.silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 ``` Run only user operation pool: @@ -69,7 +69,7 @@ cargo run --release -- rpc --http --ws ### Docker ```bash -docker run --net=host -v ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:/data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -v ./db:/data/silius/db ghcr.io/silius-rs/silius:latest bundler --eth-client-address http://127.0.0.1:8545 --datadir data/silius --mnemonic-file data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789 --http --http.addr 0.0.0.0 --http.port 3000 --http.api eth,debug,web3 --ws --ws.addr 0.0.0.0 --ws.port 3001 --ws.api eth,debug,web3 --eth-client-proxy-address http://127.0.0.1:8545 +docker run --net=host -v ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:/data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -v ./db:/data/silius/db ghcr.io/silius-rs/silius:latest node --eth-client-address http://127.0.0.1:8545 --datadir data/silius --mnemonic-file data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789 --http --http.addr 0.0.0.0 --http.port 3000 --http.api eth,debug,web3 --ws --ws.addr 0.0.0.0 --ws.port 3001 --ws.api eth,debug,web3 --eth-client-proxy-address http://127.0.0.1:8545 ``` ## Supported networks diff --git a/bin/silius/src/bundler.rs b/bin/silius/src/bundler.rs index f8668c71..e6bde51a 100644 --- a/bin/silius/src/bundler.rs +++ b/bin/silius/src/bundler.rs @@ -14,7 +14,10 @@ use silius_grpc::{ }; use silius_primitives::{ bundler::SendBundleMode, - consts::{entry_point, flashbots_relay_endpoints, p2p::DISCOVERY_SECRET_FILE_NAME}, + consts::{ + entry_point, flashbots_relay_endpoints, + p2p::{NODE_ENR_FILE_NAME, NODE_KEY_FILE_NAME}, + }, consts::{ p2p::DB_FOLDER_NAME, reputation::{ @@ -182,7 +185,11 @@ where let node_key_file = match args.p2p_opts.node_key.clone() { Some(key_file) => key_file, - None => datadir.join(DISCOVERY_SECRET_FILE_NAME), + None => datadir.join(NODE_KEY_FILE_NAME), + }; + let node_enr_file = match args.p2p_opts.node_enr.clone() { + Some(enr_file) => enr_file, + None => datadir.join(NODE_ENR_FILE_NAME), }; let entrypoint_api = EntryPoint::new( @@ -236,6 +243,7 @@ where validator, args.p2p_opts.enable_p2p, node_key_file, + node_enr_file, args.p2p_opts.to_config(), args.p2p_opts.bootnodes, ) @@ -288,6 +296,7 @@ where validator, args.p2p_opts.enable_p2p, node_key_file, + node_enr_file, args.p2p_opts.to_config(), args.p2p_opts.bootnodes, ) @@ -343,6 +352,7 @@ where validator, args.p2p_opts.enable_p2p, node_key_file, + node_enr_file, args.p2p_opts.to_config(), args.p2p_opts.bootnodes, ) @@ -395,6 +405,7 @@ where validator, args.p2p_opts.enable_p2p, node_key_file, + node_enr_file, args.p2p_opts.to_config(), args.p2p_opts.bootnodes, ) diff --git a/bin/silius/src/cli/args.rs b/bin/silius/src/cli/args.rs index 2e7d516b..68eedc58 100644 --- a/bin/silius/src/cli/args.rs +++ b/bin/silius/src/cli/args.rs @@ -259,8 +259,12 @@ pub struct P2PArgs { pub bootnodes: Vec, /// The path to the file where the p2p private key is stored. - #[clap(long)] + #[clap(long = "nodekey")] pub node_key: Option, + + /// The path to the file where the p2p enr is stored. + #[clap(long = "nodeenr")] + pub node_enr: Option, } impl P2PArgs { @@ -608,8 +612,10 @@ mod tests { "4337", "--bootnodes", &binding, - "--node-key", - "~/.silius/discovery-secret", + "--nodekey", + "~/.silius/p2p/node-key", + "--nodeenr", + "~/.silius/p2p/node-enr", ]; assert_eq!( P2PArgs { @@ -619,7 +625,8 @@ mod tests { tcp4_port: 4337, udp4_port: 4337, bootnodes: vec![enr], - node_key: Some(PathBuf::from("~/.silius/discovery-secret")), + node_key: Some(PathBuf::from("~/.silius/p2p/node-key")), + node_enr: Some(PathBuf::from("~/.silius/p2p/node-enr")) }, P2PArgs::try_parse_from(args).unwrap() ) diff --git a/bin/silius/src/cli/commands.rs b/bin/silius/src/cli/commands.rs index 95d302b0..72051b2c 100644 --- a/bin/silius/src/cli/commands.rs +++ b/bin/silius/src/cli/commands.rs @@ -8,7 +8,7 @@ use std::{future::pending, sync::Arc}; /// Start the bundler with all components (bundling component, user operation mempool, RPC server) #[derive(Debug, Parser)] -pub struct BundlerCommand { +pub struct NodeCommand { /// All Bundler specific args #[clap(flatten)] bundler: BundlerArgs, @@ -26,7 +26,7 @@ pub struct BundlerCommand { rpc: RpcArgs, } -impl BundlerCommand { +impl NodeCommand { /// Execute the command pub async fn execute(self) -> eyre::Result<()> { if self.common.eth_client_address.clone().starts_with("http") { @@ -63,7 +63,7 @@ impl BundlerCommand { /// Start the bundling component #[derive(Debug, Parser)] -pub struct BundlingCommand { +pub struct BundlerCommand { /// All Bundler specific args #[clap(flatten)] bundler: BundlerArgs, @@ -77,7 +77,7 @@ pub struct BundlingCommand { pub uopool_grpc_listen_address: String, } -impl BundlingCommand { +impl BundlerCommand { /// Execute the command pub async fn execute(self) -> eyre::Result<()> { if self.common.eth_client_address.clone().starts_with("http") { diff --git a/bin/silius/src/cli/mod.rs b/bin/silius/src/cli/mod.rs index 66f2e7ac..09a0db97 100644 --- a/bin/silius/src/cli/mod.rs +++ b/bin/silius/src/cli/mod.rs @@ -36,12 +36,12 @@ impl Cli { #[derive(Debug, Subcommand)] pub enum Commands { /// Start the bundler with all components (bundling component, user operation mempool, RPC server) - #[command(name = "bundler")] - Bundler(Box), + #[command(name = "node")] + Node(Box), /// Start the bundling component - #[command(name = "bundling")] - Bundling(commands::BundlingCommand), + #[command(name = "bundler")] + Bundler(commands::BundlerCommand), /// Start the user operation mempool #[command(name = "uopool")] @@ -76,8 +76,8 @@ pub fn run() -> eyre::Result<()> { let task = async move { match cli.command { + Commands::Node(command) => command.execute().await, Commands::Bundler(command) => command.execute().await, - Commands::Bundling(command) => command.execute().await, Commands::UoPool(command) => command.execute().await, Commands::Rpc(command) => command.execute().await, Commands::CreateWallet(command) => command.execute(), diff --git a/bundler-spec-tests/launcher.sh b/bundler-spec-tests/launcher.sh index 09d03b04..f20a767a 100755 --- a/bundler-spec-tests/launcher.sh +++ b/bundler-spec-tests/launcher.sh @@ -11,7 +11,7 @@ case $1 in start) docker-compose up -d sleep 2 - silius bundler \ + silius node \ --verbosity 4 \ --eth-client-address http://127.0.0.1:8545 \ --mnemonic-file keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ diff --git a/bundler-spec-tests/p2p/node-enr b/bundler-spec-tests/p2p/node-enr new file mode 100644 index 00000000..35eb53cf --- /dev/null +++ b/bundler-spec-tests/p2p/node-enr @@ -0,0 +1 @@ +enr:-Iu4QCDkGSYoIMe5ISDuqXgwHwGpkj2lYsUDbmR7f3GJRV_6YyKvoTFVgjV77l07stYbgBgCq0SHa0DuYzSoGQFzD2oBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQN5PrrJ6hQerKiUV6eULP8BwP0KEIbykGS1bVzjr3GVSoN0Y3CCIyiDdWRwgiMo \ No newline at end of file diff --git a/bundler-spec-tests/p2p/node-key b/bundler-spec-tests/p2p/node-key new file mode 100644 index 00000000..ca5bea1c --- /dev/null +++ b/bundler-spec-tests/p2p/node-key @@ -0,0 +1 @@ + z}USP'6gJBp +Zd \ No newline at end of file diff --git a/crates/grpc/src/uopool.rs b/crates/grpc/src/uopool.rs index 024c28f1..c0a4e272 100644 --- a/crates/grpc/src/uopool.rs +++ b/crates/grpc/src/uopool.rs @@ -16,6 +16,7 @@ use futures::StreamExt; use libp2p_identity::{secp256k1, Keypair}; use parking_lot::RwLock; use silius_p2p::config::Config; +use silius_p2p::enr::{build_enr, keypair_to_combined}; use silius_p2p::network::{EntrypointChannels, Network}; use silius_primitives::provider::BlockStream; use silius_primitives::uopool::AddError; @@ -32,6 +33,7 @@ use std::collections::HashMap; use std::env; use std::os::unix::prelude::PermissionsExt; use std::path::PathBuf; +use std::str::FromStr; use std::{net::SocketAddr, sync::Arc, time::Duration}; use tonic::{Code, Request, Response, Status}; use tracing::{debug, error, info}; @@ -415,6 +417,7 @@ pub async fn uopool_service_run( validator: StandardUserOperationValidator, p2p_enabled: bool, node_key_file: PathBuf, + node_enr_file: PathBuf, config: Config, bootnodes: Vec, ) -> Result<()> @@ -484,22 +487,41 @@ where .into(); keypair.into() } else { - info!("The p2p spec private key is not exist. Creating one now!"); + info!("The p2p spec private key doesn't exist. Creating one now!"); let keypair = Keypair::generate_secp256k1(); + std::fs::create_dir_all(node_key_file.parent().expect("Key file path error")) + .expect("Creating key file directory failed"); std::fs::write( node_key_file.clone(), keypair .to_protobuf_encoding() - .expect("discovery secret encode failed"), + .expect("Discovery secret encoding failed"), ) - .expect("write discoveray secret file failed"); + .expect("Discovery secret writing failed"); std::fs::set_permissions(node_key_file, std::fs::Permissions::from_mode(0o600)) .expect("Setting key file permission failed"); + keypair }; + + let enr = if node_enr_file.exists() { + let content = std::fs::read_to_string(node_enr_file).expect("enr file currupted"); + Enr::from_str(&content).expect("enr file currupted") + } else { + let combined_key = + keypair_to_combined(discovery_secret.clone()).expect("key error"); + let enr = build_enr(&combined_key, &config).expect("enr building failed"); + std::fs::create_dir_all(node_enr_file.parent().expect("Key file path error")) + .expect("Creating key file directory failed"); + std::fs::write(node_enr_file, enr.to_base64()).expect("enr writing failed"); + enr + }; + info!("Enr: {}", enr); + let listen_addrs = config.listen_addr.to_multi_addr(); let mut p2p_network = Network::new( + enr, discovery_secret, config, entrypoint_channels, @@ -507,7 +529,7 @@ where 30, ) .expect("p2p network init failed"); - info!("Enr: {}", p2p_network.local_enr().to_base64()); + for listen_addr in listen_addrs.into_iter() { info!("P2P node listened on {}", listen_addr); p2p_network @@ -518,6 +540,7 @@ where if bootnodes.is_empty() { info!("Start p2p mode without bootnodes"); } + for enr in bootnodes { info!("Trying to dial p2p node {enr:}"); p2p_network.dial(enr).expect("Dial bootnode failed"); diff --git a/crates/p2p/src/behaviour.rs b/crates/p2p/src/behaviour.rs index 89ad0f8d..7e091dd2 100644 --- a/crates/p2p/src/behaviour.rs +++ b/crates/p2p/src/behaviour.rs @@ -1,10 +1,10 @@ use crate::config::Config; use crate::discovery::{self, Discovery}; -use crate::enr::build_enr; use crate::gossipsub::{create_gossisub, Gossipsub}; use crate::peer_manager::{PeerManager, PeerManagerEvent}; use crate::request_response; use discv5::enr::CombinedKey; +use discv5::Enr; use libp2p::gossipsub; use libp2p::swarm::NetworkBehaviour; use std::time::Duration; @@ -25,13 +25,13 @@ pub struct Behaviour { impl Behaviour { pub fn new( + enr: Enr, key: CombinedKey, config: Config, p2p_mempool_id: Vec, ping_interval: Duration, target_peers: usize, ) -> eyre::Result { - let enr = build_enr(&key, &config)?; let gossipsub = create_gossisub(p2p_mempool_id).map_err(|e| eyre::anyhow!(e))?; let reqrep = request_response::Behaviour::new(Default::default()); let discovery = Discovery::new(enr, key, config)?; diff --git a/crates/p2p/src/config.rs b/crates/p2p/src/config.rs index 08502cc7..a55f4b82 100644 --- a/crates/p2p/src/config.rs +++ b/crates/p2p/src/config.rs @@ -15,6 +15,7 @@ pub struct ListenAddr { } /// Variant of ListenAddr that can be ipv4, ipv6 or dual. +#[derive(Clone, Debug)] pub enum ListenAddress { Ipv4(ListenAddr), Ipv6(ListenAddr), @@ -46,6 +47,7 @@ impl Default for ListenAddress { } } +#[derive(Clone, Debug)] pub struct Config { pub listen_addr: ListenAddress, diff --git a/crates/p2p/src/enr.rs b/crates/p2p/src/enr.rs index 5c848523..32df2a25 100644 --- a/crates/p2p/src/enr.rs +++ b/crates/p2p/src/enr.rs @@ -13,7 +13,7 @@ use libp2p::{ }; /// Convert a libp2p Keypair into a discv5 CombinedKey -pub fn keypair_to_combine(keypair: Keypair) -> eyre::Result { +pub fn keypair_to_combined(keypair: Keypair) -> eyre::Result { match keypair.try_into_secp256k1() { Ok(key) => { let secret = @@ -28,6 +28,7 @@ pub fn keypair_to_combine(keypair: Keypair) -> eyre::Result { /// Build an ENR from a libp2p Keypair and config pub fn build_enr(enr_key: &CombinedKey, config: &Config) -> eyre::Result { let mut enr_builder = EnrBuilder::new("v4"); + if let Some(ip) = config.ipv4_addr { enr_builder.ip4(ip); } @@ -48,6 +49,7 @@ pub fn build_enr(enr_key: &CombinedKey, config: &Config) -> eyre::Result { } let enr = enr_builder.build(enr_key)?; + Ok(enr) } diff --git a/crates/p2p/src/network.rs b/crates/p2p/src/network.rs index 3c59fcd3..c69e34ab 100644 --- a/crates/p2p/src/network.rs +++ b/crates/p2p/src/network.rs @@ -2,7 +2,7 @@ use crate::{ behaviour::Behaviour, config::Config, discovery, - enr::{keypair_to_combine, EnrExt}, + enr::{keypair_to_combined, EnrExt}, gossipsub::topic, peer_manager::PeerManagerEvent, request_response::{self, Ping, Request, RequestId, Response}, @@ -99,15 +99,18 @@ impl From for Swarm { impl Network { #[allow(clippy::too_many_arguments)] pub fn new( + enr: Enr, key: Keypair, config: Config, entrypoint_channels: EntrypointChannels, ping_interval: Duration, target_peers: usize, ) -> eyre::Result { - let combine_key = keypair_to_combine(key.clone())?; + let combined_key = keypair_to_combined(key.clone())?; + let behaviour = Behaviour::new( - combine_key, + enr, + combined_key, config, entrypoint_channels .iter() diff --git a/crates/p2p/src/tests/mod.rs b/crates/p2p/src/tests/mod.rs index 47c2d7cd..fdd5a4f8 100644 --- a/crates/p2p/src/tests/mod.rs +++ b/crates/p2p/src/tests/mod.rs @@ -1,5 +1,6 @@ use crate::{ config::{Config, ListenAddr}, + enr::{build_enr, keypair_to_combined}, network::{Network, NetworkEvent}, }; use alloy_chains::Chain; @@ -50,7 +51,9 @@ fn build_p2p_instance() -> eyre::Result { let listen_addrs = config.listen_addr.to_multi_addr(); let (_, rv) = unbounded(); let (sd, _) = unbounded(); + let enr = build_enr(&keypair_to_combined(key.clone())?, &config).unwrap(); let mut network = Network::new( + enr, key, config, vec![(Chain::from(5), Default::default(), rv, sd)], diff --git a/crates/primitives/src/consts.rs b/crates/primitives/src/consts.rs index 62a7c858..d4ff64bf 100644 --- a/crates/primitives/src/consts.rs +++ b/crates/primitives/src/consts.rs @@ -102,8 +102,10 @@ pub mod networking { pub mod p2p { /// The dafault database folder name used for storing the database files pub const DB_FOLDER_NAME: &str = "db"; - /// The default discovery secret file name used for storing the discovery secret - pub const DISCOVERY_SECRET_FILE_NAME: &str = "discovery-secret"; + /// The default node key file name used for storing the node p2p key + pub const NODE_KEY_FILE_NAME: &str = "p2p/node-key"; + /// The default node enr file name used for storing enr + pub const NODE_ENR_FILE_NAME: &str = "p2p/node-enr"; /// The prefix protocol id for request-response protocol pub const REQREP_PROTOCOL_PREFIX: &str = "/account_abstraction/req"; /// The topic hash prefix for gossisub protocol diff --git a/docker-compose.yml b/docker-compose.yml index b1d8d2bb..f3c152b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,9 @@ services: volumes: - ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:/data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 - ./db:/data/silius/db + - ./bundler-spec-tests/p2p:/data/silius/p2p command: - - bundler + - node - --eth-client-address - http://127.0.0.1:8545 - --datadir @@ -35,3 +36,6 @@ services: - eth,debug,web3 - --eth-client-proxy-address - http://127.0.0.1:8545 + - --p2p.baddr + - 127.0.0.1 + - --enable-p2p diff --git a/docs/P2P.md b/docs/P2P.md index 2eb18e78..71ac8ed6 100644 --- a/docs/P2P.md +++ b/docs/P2P.md @@ -9,19 +9,19 @@ ## Run bootnode ``` -cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --enable-p2p +cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --enable-p2p ``` ## Run peer node ``` -cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 +cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 ``` ## Run Silius bundler with env seed set (used for generation of P2P peer keys) ``` -P2P_PRIVATE_SEED=1 cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 +P2P_PRIVATE_SEED=1 cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 ``` ## Run cluster of Silius bundlers @@ -29,17 +29,17 @@ P2P_PRIVATE_SEED=1 cargo run -- bundler --eth-client-address http://127.0.0.1:85 Run bootnode ``` -cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --enable-p2p +cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --enable-p2p ``` Run first peer node ``` -cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4001 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 +cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4001 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1 ``` Run second peer node ``` -cargo run -- bundler --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4002 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4339 --p2p.port 4339 --datadir ./.local/node2 +cargo run -- node --eth-client-address http://127.0.0.1:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4002 --eth-client-proxy-address http://127.0.0.1:8545 --p2p.baddr 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4339 --p2p.port 4339 --datadir ./.local/node2 ```