Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Oct 20, 2024
1 parent 5692890 commit d0d5847
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
38 changes: 37 additions & 1 deletion sequencer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ pub struct NetworkParams {
/// The (optional) bootstrap node addresses for Libp2p. If supplied, these will
/// override the bootstrap nodes specified in the config file.
pub libp2p_bootstrap_nodes: Option<Vec<Multiaddr>>,

/// The heartbeat interval
pub libp2p_heartbeat_interval: Duration,

/// The number of past heartbeats to gossip about
pub libp2p_history_gossip: usize,
/// The number of past heartbeats to remember the full messages for
pub libp2p_history_length: usize,

/// The target number of peers in the mesh
pub libp2p_mesh_n: usize,
/// The maximum number of peers in the mesh
pub libp2p_mesh_n_high: usize,
/// The minimum number of peers in the mesh
pub libp2p_mesh_n_low: usize,
/// The minimum number of mesh peers that must be outbound
pub libp2p_mesh_outbound_min: usize,

/// The maximum gossip message size
pub libp2p_max_transmit_size: usize,

pub libp2p_max_ihave_length: usize,
pub libp2p_max_ihave_messages: usize,
}

pub struct L1Params {
Expand Down Expand Up @@ -321,12 +344,25 @@ pub async fn init_node<P: PersistenceOptions, V: Versions>(
)
.with_context(|| "Failed to create CDN network")?;

let gossip_config = GossipConfig {
heartbeat_interval: network_params.libp2p_heartbeat_interval,
history_gossip: network_params.libp2p_history_gossip,
history_length: network_params.libp2p_history_length,
mesh_n: network_params.libp2p_mesh_n,
mesh_n_high: network_params.libp2p_mesh_n_high,
mesh_n_low: network_params.libp2p_mesh_n_low,
mesh_outbound_min: network_params.libp2p_mesh_outbound_min,
max_ihave_messages: network_params.libp2p_max_ihave_messages,
max_transmit_size: network_params.libp2p_max_transmit_size,
max_ihave_length: network_params.libp2p_max_ihave_length,
};

// Initialize the Libp2p network (if enabled)
#[cfg(feature = "libp2p")]
let network = {
let p2p_network = Libp2pNetwork::from_config::<SeqTypes>(
config.clone(),
GossipConfig::default(),
gossip_config,
network_params.libp2p_bind_address,
&my_config.public_key,
// We need the private key so we can derive our Libp2p keypair
Expand Down
10 changes: 10 additions & 0 deletions sequencer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ where
libp2p_advertise_address,
libp2p_bind_address,
libp2p_bootstrap_nodes: opt.libp2p_bootstrap_nodes,
libp2p_history_gossip: opt.libp2p_history_gossip,
libp2p_history_length: opt.libp2p_history_length,
libp2p_max_ihave_length: opt.libp2p_max_ihave_length,
libp2p_max_ihave_messages: opt.libp2p_max_ihave_messages,
libp2p_max_transmit_size: 2_000_000_000,
libp2p_mesh_n: opt.libp2p_mesh_n,
libp2p_mesh_n_high: opt.libp2p_mesh_n_high,
libp2p_heartbeat_interval: opt.libp2p_heartbeat_interval,
libp2p_mesh_n_low: opt.libp2p_mesh_n_low,
libp2p_mesh_outbound_min: opt.libp2p_mesh_outbound_min,
orchestrator_url: opt.orchestrator_url,
state_relay_server_url: opt.state_relay_server_url,
public_api_url: opt.public_api_url,
Expand Down
58 changes: 57 additions & 1 deletion sequencer/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use std::{
fmt::{self, Formatter},
iter::once,
path::PathBuf,
time::Duration,
};

use anyhow::{bail, Context};
use clap::{error::ErrorKind, Args, FromArgMatches, Parser};
use derivative::Derivative;
use espresso_types::BackoffParams;
use espresso_types::{parse_duration, BackoffParams};
use hotshot_types::{light_client::StateSignKey, signature_key::BLSPrivKey};
use libp2p::Multiaddr;
use url::Url;
Expand Down Expand Up @@ -83,6 +84,61 @@ pub struct Options {
)]
pub libp2p_advertise_address: String,

#[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_HEARTBEAT_INTERVAL", default_value = "1s", value_parser = parse_duration)]
pub libp2p_heartbeat_interval: Duration,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_HISTORY_GOSSIP",
default_value = "3"
)]
pub libp2p_history_gossip: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_HISTORY_LENGTH",
default_value = "5"
)]
pub libp2p_history_length: usize,

#[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N", default_value = "8")]
pub libp2p_mesh_n: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N_HIGH",
default_value = "12"
)]
pub libp2p_mesh_n_high: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N_LOW",
default_value = "6"
)]
pub libp2p_mesh_n_low: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_OUTBOUND_MIN",
default_value = "2"
)]
pub libp2p_mesh_outbound_min: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_IHAVE_LENGTH",
default_value = "2000"
)]
pub libp2p_max_ihave_length: usize,

#[clap(
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_IHAVE_MESSAGES",
default_value = "10"
)]
pub libp2p_max_ihave_messages: usize,

/// A comma-separated list of Libp2p multiaddresses to use as bootstrap
/// nodes.
///
Expand Down

0 comments on commit d0d5847

Please sign in to comment.