Skip to content

Commit

Permalink
chore fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zsluedem committed Nov 12, 2023
1 parent efd42f3 commit ea308fc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bin/silius/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ pub struct P2PArgs {
pub enable_p2p: bool,

/// Sets the p2p listen address.
#[clap(long, default_value = "0.0.0.0")]
#[clap(long = "p2p.addr", default_value = "0.0.0.0")]
pub p2p_listen_address: Ipv4Addr,

/// The ipv4 address to broadcast to peers about which address we are listening on.
#[clap(long)]
#[clap(long = "p2p.baddr")]
pub p2p_broadcast_address: Option<Ipv4Addr>,

/// The udp4 port to broadcast to peers in order to reach back for discovery.
Expand Down Expand Up @@ -586,9 +586,9 @@ mod tests {
let args = vec![
"p2popts",
"--enable-p2p",
"--p2p-listen-address",
"--p2p.addr",
"0.0.0.0",
"--p2p-broadcast-address",
"--p2p.baddr",
"127.0.0.1",
"--discovery.port",
"4337",
Expand Down
12 changes: 11 additions & 1 deletion crates/grpc/src/uopool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use expanded_pathbuf::ExpandedPathBuf;
use eyre::Result;
use futures::channel::mpsc::unbounded;
use futures::StreamExt;
use libp2p_identity::Keypair;
use libp2p_identity::{secp256k1, Keypair};
use silius_p2p::config::Config;
use silius_p2p::network::{EntrypointChannels, Network};
use silius_primitives::consts::p2p::DB_FOLDER_NAME;
Expand All @@ -29,6 +29,7 @@ use silius_uopool::{
mempool_id, validate::validator::StandardUserOperationValidator, MempoolId, Reputation,
UoPool as UserOperationPool, UoPoolBuilder,
};
use std::env;
use std::fmt::{Debug, Display};
use std::os::unix::prelude::PermissionsExt;
use std::path::PathBuf;
Expand Down Expand Up @@ -431,8 +432,17 @@ where
let content =
std::fs::read(node_key_file).expect("discovery secret file currupted");
Keypair::from_protobuf_encoding(&content).expect("discovery secret file currupted")
} else if let Ok(p2p_private_seed) = env::var("P2P_PRIVATE_SEED") {
// Mostly test purpose
let private_bytes = p2p_private_seed.as_bytes().to_vec();
let keypair: secp256k1::Keypair =
secp256k1::SecretKey::try_from_bytes(private_bytes)
.expect("Env P2P_PRIVATE_SEED is not valid private bytes")
.into();
keypair.into()
} else {
info!("The p2p spec private key is not exist. Creating one now!");

let keypair = Keypair::generate_secp256k1();
std::fs::write(
node_key_file.clone(),
Expand Down
8 changes: 5 additions & 3 deletions crates/p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ impl Network {
pub fn poll_network(&mut self, cx: &mut Context) -> Poll<NetworkEvent> {
let mut msg_to_publish = Vec::new();
for (chain, ep, waiting_to_publish_ch, _) in self.entrypoint_channels.iter_mut() {
while let Ok(Some((pub_userop, verified_block))) = waiting_to_publish_ch.try_next() {
info!("Got userop {pub_userop:?} from ep {ep:} verified in {verified_block:?} to publish to p2p network!");
while let Ok(Some((pub_userop, verified_at_block_hash))) =
waiting_to_publish_ch.try_next()
{
info!("Got userop {pub_userop:?} from ep {ep:?} verified in {verified_at_block_hash:?} to publish to p2p network!");
let pub_msg = UserOperationsWithEntryPoint::new(
*ep,
verified_block,
verified_at_block_hash,
chain.id().into(),
vec![pub_userop],
);
Expand Down
4 changes: 2 additions & 2 deletions crates/p2p/src/request_response/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ impl Behaviour {
if connections.is_empty() {
return Some(request);
}
let ix = (request.request_id.0 as usize) % connections.len();
let conn = &mut connections[ix];
let id = (request.request_id.0 as usize) % connections.len();
let conn = &mut connections[id];
conn.pending_inbound_responses.insert(request.request_id);
self.pending_events.push_back(ToSwarm::NotifyHandler {
peer_id: *peer,
Expand Down
4 changes: 2 additions & 2 deletions crates/uopool/src/uopool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use silius_primitives::{
};
use std::collections::{HashMap, HashSet};
use std::fmt::{Debug, Display};
use tracing::trace;
use tracing::{info, trace};

pub type VecUo = Vec<UserOperation>;
pub type VecCh = Vec<CodeHash>;
Expand Down Expand Up @@ -232,7 +232,7 @@ where
if let Some(code_hashes) = res.code_hashes {
let _ = self.mempool.set_code_hashes(&uo_hash, &code_hashes);
}

info!("{uo_hash:?} added to the mempool {:?}", self.id);
trace!("{uo:?} added to the mempool {:?}", self.id);

// update reputation
Expand Down
3 changes: 3 additions & 0 deletions docs/P2P.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ cargo run -- bundler --eth-client-address http://localhost:8545 --mnemonic-file
cargo run -- bundler --eth-client-address http://localhost:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://localhost:8545 --p2p-broadcast-address 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1
```

## Run silius with env p2p key
P2P_PRIVATE_SEED=1 cargo run -- bundler --eth-client-address http://localhost:8545 --mnemonic-file ./bundler-spec-tests/keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --entry-points 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 --http --http.port 4000 --eth-client-proxy-address http://localhost:8545 --p2p-broadcast-address 127.0.0.1 --bootnodes "enr:-Iu4QBh2tesC8BokO61v1w43MnbfHF5H95ZJNHVEQaRq_MjFFuxmeVQnoEXxUDk5qKJCHM944gC72Xg4dYwRkGt9zA4BgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKRdyIA8OvArCcZbt3hoJHu4nVe6CblqjO0CnrbGACi-IN0Y3CCEPGDdWRwghDx" --enable-p2p --discovery.port 4338 --p2p.port 4338 --datadir ./.local/node1

## Run cluster of Silius bundler


Expand Down

0 comments on commit ea308fc

Please sign in to comment.