diff --git a/Cargo.lock b/Cargo.lock index 0c03ac2360..65c36f33bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1315,11 +1315,11 @@ dependencies = [ "hotshot-orchestrator", "hotshot-stake-table", "hotshot-state-prover", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-merkle-tree", "jf-signature", "libp2p", - "libp2p-networking", + "libp2p-networking 0.5.78 (git+https://github.com/EspressoSystems//HotShot.git?tag=0.5.78-patch1)", "marketplace-builder-shared", "portpicker", "rand 0.8.5", @@ -2976,7 +2976,7 @@ dependencies = [ "hotshot-orchestrator", "hotshot-query-service", "hotshot-testing", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "itertools 0.12.1", "jf-merkle-tree", "jf-utils", @@ -4114,7 +4114,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-broadcast", @@ -4138,10 +4138,10 @@ dependencies = [ "futures", "hotshot-task", "hotshot-task-impls", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-signature", "libp2p-identity", - "libp2p-networking", + "libp2p-networking 0.5.78 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "lru 0.12.5", "num_enum", "parking_lot", @@ -4161,14 +4161,14 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "async-trait", "clap", "committable", "derive_more 1.0.0", "futures", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "serde", "tagged-base64", "thiserror", @@ -4197,7 +4197,7 @@ dependencies = [ "hotshot", "hotshot-builder-api", "hotshot-events-service", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "lru 0.12.5", "marketplace-builder-shared", "serde", @@ -4226,7 +4226,7 @@ dependencies = [ "contract-bindings", "diff-test-bn254", "ethers", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-pcs", "jf-plonk", "jf-utils", @@ -4249,7 +4249,7 @@ dependencies = [ "derive_more 0.99.18", "either", "futures", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "rand 0.8.5", "serde", "snafu 0.8.4", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-broadcast", @@ -4279,7 +4279,7 @@ dependencies = [ "hotshot", "hotshot-task", "hotshot-task-impls", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "rand 0.8.5", "reqwest 0.12.8", "serde", @@ -4296,7 +4296,7 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4304,7 +4304,7 @@ dependencies = [ "async-trait", "futures", "hotshot-example-types", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "rand 0.8.5", "serde", "tide-disco", @@ -4316,7 +4316,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "derive_builder", "proc-macro2", @@ -4327,7 +4327,7 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4338,7 +4338,7 @@ dependencies = [ "clap", "csv", "futures", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "libp2p", "multiaddr", "serde", @@ -4377,7 +4377,7 @@ dependencies = [ "hotshot", "hotshot-example-types", "hotshot-testing", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "include_dir", "itertools 0.12.1", "jf-merkle-tree", @@ -4409,7 +4409,7 @@ dependencies = [ [[package]] name = "hotshot-stake-table" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4418,7 +4418,7 @@ dependencies = [ "ark-std", "digest 0.10.7", "ethereum-types", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-crhf", "jf-rescue", "jf-signature", @@ -4447,7 +4447,7 @@ dependencies = [ "futures", "hotshot-contract-adapter", "hotshot-stake-table", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "itertools 0.12.1", "jf-crhf", "jf-pcs", @@ -4471,7 +4471,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-broadcast", @@ -4486,7 +4486,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-broadcast", @@ -4503,7 +4503,7 @@ dependencies = [ "futures", "hotshot-builder-api", "hotshot-task", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-signature", "jf-vid", "rand 0.8.5", @@ -4523,7 +4523,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-broadcast", @@ -4545,7 +4545,7 @@ dependencies = [ "hotshot-orchestrator", "hotshot-task", "hotshot-task-impls", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "itertools 0.13.0", "jf-signature", "jf-vid", @@ -4569,7 +4569,66 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://github.com/EspressoSystems//HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" +dependencies = [ + "anyhow", + "ark-bn254", + "ark-ed-on-bn254", + "ark-ff", + "ark-serialize", + "ark-srs", + "ark-std", + "async-compatibility-layer", + "async-lock 2.8.0", + "async-std", + "async-trait", + "bincode", + "bitvec", + "blake3", + "cdn-proto 0.4.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.7)", + "clap", + "committable", + "custom_debug 0.5.1", + "derivative", + "digest 0.10.7", + "displaydoc", + "dyn-clone 1.0.17 (git+https://github.com/dtolnay/dyn-clone?tag=1.0.17)", + "either", + "espresso-systems-common 0.4.1", + "ethereum-types", + "futures", + "jf-pcs", + "jf-signature", + "jf-utils", + "jf-vid", + "lazy_static", + "libp2p", + "memoize", + "rand 0.8.5", + "rand_chacha 0.3.1", + "reqwest 0.12.8", + "serde", + "serde-inline-default", + "serde_bytes", + "serde_json", + "sha2 0.10.8", + "surf-disco", + "tagged-base64", + "thiserror", + "time 0.3.36", + "tokio", + "toml", + "tracing", + "typenum", + "url", + "vbs", + "vec1", +] + +[[package]] +name = "hotshot-types" +version = "0.1.11" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "ark-bn254", @@ -5830,7 +5889,42 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78#be7d9be60abbf8f293b7e95940ff77eff2e0739e" +source = "git+https://github.com/EspressoSystems//HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" +dependencies = [ + "anyhow", + "async-compatibility-layer", + "async-lock 2.8.0", + "async-std", + "async-trait", + "bincode", + "blake3", + "custom_debug 0.5.1", + "delegate", + "derive_builder", + "either", + "futures", + "hotshot-types 0.1.11 (git+https://github.com/EspressoSystems//HotShot.git?tag=0.5.78-patch1)", + "lazy_static", + "libp2p", + "libp2p-identity", + "libp2p-swarm-derive", + "pin-project", + "portpicker", + "rand 0.8.5", + "serde", + "serde_bytes", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "void", +] + +[[package]] +name = "libp2p-networking" +version = "0.5.78" +source = "git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1#09db1dd99fb2d7ea3cd99dd7a309abfe45930096" dependencies = [ "anyhow", "async-compatibility-layer", @@ -5844,7 +5938,7 @@ dependencies = [ "derive_builder", "either", "futures", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "lazy_static", "libp2p", "libp2p-identity", @@ -6198,7 +6292,7 @@ dependencies = [ "hotshot-orchestrator", "hotshot-query-service", "hotshot-stake-table", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-merkle-tree", "jf-signature", "marketplace-builder-core", @@ -6237,7 +6331,7 @@ dependencies = [ "hotshot-builder-api", "hotshot-events-service", "hotshot-task-impls", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "lru 0.12.5", "marketplace-builder-shared", "multimap", @@ -6271,7 +6365,7 @@ dependencies = [ "hotshot-builder-api", "hotshot-events-service", "hotshot-task-impls", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "surf-disco", "tracing", "url", @@ -6295,7 +6389,7 @@ dependencies = [ "hotshot", "hotshot-events-service", "hotshot-query-service", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "jf-signature", "portpicker", "rand 0.8.5", @@ -6678,7 +6772,7 @@ dependencies = [ "hotshot", "hotshot-query-service", "hotshot-stake-table", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "prometheus-parse", "reqwest 0.12.8", "serde", @@ -8689,7 +8783,7 @@ dependencies = [ "hotshot-stake-table", "hotshot-state-prover", "hotshot-testing", - "hotshot-types", + "hotshot-types 0.1.11 (git+https://www.github.com/EspressoSystems/HotShot.git?tag=0.5.78-patch1)", "include_dir", "itertools 0.12.1", "jf-crhf", @@ -8698,7 +8792,7 @@ dependencies = [ "jf-signature", "jf-vid", "libp2p", - "libp2p-networking", + "libp2p-networking 0.5.78 (git+https://github.com/EspressoSystems//HotShot.git?tag=0.5.78-patch1)", "marketplace-builder-core", "marketplace-builder-shared", "marketplace-solver", diff --git a/Cargo.toml b/Cargo.toml index b5d258cadf..ba112cc03f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,3 +155,15 @@ debug = false strip = "debuginfo" [profile.dev.package."*"] opt-level = 3 + +[patch."https://github.com/EspressoSystems/HotShot.git"] +hotshot = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-builder-api = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-orchestrator = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-stake-table = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-task ={ git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-task-impls ={ git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-testing ={ git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +hotshot-types = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } +libp2p-networking = { git = "https://github.com/EspressoSystems//HotShot.git", tag = "0.5.78-patch1" } +hotshot-example-types = { git = "https://www.github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch1" } diff --git a/sequencer/src/lib.rs b/sequencer/src/lib.rs index cc8eeca0fc..fab292c6d8 100644 --- a/sequencer/src/lib.rs +++ b/sequencer/src/lib.rs @@ -123,6 +123,62 @@ 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>, + + /// 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, + + /// The maximum number of IHAVE messages to accept from a Libp2p peer within a heartbeat + pub libp2p_max_ihave_length: usize, + + /// The maximum number of IHAVE messages to accept from a Libp2p peer within a heartbeat + pub libp2p_max_ihave_messages: usize, + + /// The time period that message hashes are stored in the cache + pub libp2p_published_message_ids_cache_time: Duration, + + /// The time to wait for a Libp2p message requested through IWANT following an IHAVE advertisement + pub libp2p_iwant_followup_time: Duration, + + /// The maximum number of Libp2p messages we will process in a given RPC + pub libp2p_max_messages_per_rpc: Option, + + /// How many times we will allow a peer to request the same message id through IWANT gossip before we start ignoring them + pub libp2p_gossip_retransmission: u32, + + /// If enabled newly created messages will always be sent to all peers that are subscribed to the topic and have a good enough score + pub libp2p_flood_publish: bool, + + /// The time period that Libp2p message hashes are stored in the cache + pub libp2p_duplicate_cache_time: Duration, + + /// Time to live for Libp2p fanout peers + pub libp2p_fanout_ttl: Duration, + + /// Initial delay in each Libp2p heartbeat + pub libp2p_heartbeat_initial_delay: Duration, + + /// How many Libp2p peers we will emit gossip to at each heartbeat + pub libp2p_gossip_factor: f64, + + /// Minimum number of Libp2p peers to emit gossip to during a heartbeat + pub libp2p_gossip_lazy: usize, } pub struct L1Params { @@ -337,12 +393,36 @@ pub async fn init_node( ) .with_context(|| format!("Failed to create CDN network {node_index}"))?; + // Configure gossipsub based on the command line options + 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, + published_message_ids_cache_time: network_params.libp2p_published_message_ids_cache_time, + iwant_followup_time: network_params.libp2p_iwant_followup_time, + max_messages_per_rpc: network_params.libp2p_max_messages_per_rpc, + gossip_retransmission: network_params.libp2p_gossip_retransmission, + flood_publish: network_params.libp2p_flood_publish, + duplicate_cache_time: network_params.libp2p_duplicate_cache_time, + fanout_ttl: network_params.libp2p_fanout_ttl, + heartbeat_initial_delay: network_params.libp2p_heartbeat_initial_delay, + gossip_factor: network_params.libp2p_gossip_factor, + gossip_lazy: network_params.libp2p_gossip_lazy, + }; + // Initialize the Libp2p network (if enabled) #[cfg(feature = "libp2p")] let network = { let p2p_network = Libp2pNetwork::from_config( config.clone(), - GossipConfig::default(), + gossip_config, libp2p_bind_address, &my_config.public_key, // We need the private key so we can derive our Libp2p keypair diff --git a/sequencer/src/main.rs b/sequencer/src/main.rs index c95b2c2054..2678afec68 100644 --- a/sequencer/src/main.rs +++ b/sequencer/src/main.rs @@ -166,6 +166,26 @@ where state_peers: opt.state_peers, config_peers: opt.config_peers, catchup_backoff: opt.catchup_backoff, + 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: opt.libp2p_max_transmit_size, + 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, + libp2p_published_message_ids_cache_time: opt.libp2p_published_message_ids_cache_time, + libp2p_iwant_followup_time: opt.libp2p_iwant_followup_time, + libp2p_max_messages_per_rpc: opt.libp2p_max_messages_per_rpc, + libp2p_gossip_retransmission: opt.libp2p_gossip_retransmission, + libp2p_flood_publish: opt.libp2p_flood_publish, + libp2p_duplicate_cache_time: opt.libp2p_duplicate_cache_time, + libp2p_fanout_ttl: opt.libp2p_fanout_ttl, + libp2p_heartbeat_initial_delay: opt.libp2p_heartbeat_initial_delay, + libp2p_gossip_factor: opt.libp2p_gossip_factor, + libp2p_gossip_lazy: opt.libp2p_gossip_lazy, }; let marketplace_config = MarketplaceConfig { diff --git a/sequencer/src/options.rs b/sequencer/src/options.rs index 2b4a5a0207..14e93e5c51 100644 --- a/sequencer/src/options.rs +++ b/sequencer/src/options.rs @@ -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; @@ -69,6 +70,138 @@ pub struct Options { )] pub libp2p_bind_address: String, + /// Time between each Libp2p heartbeat + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_HEARTBEAT_INTERVAL", default_value = "1s", value_parser = parse_duration)] + pub libp2p_heartbeat_interval: Duration, + + /// Number of past heartbeats to gossip about on Libp2p + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_HISTORY_GOSSIP", + default_value = "3" + )] + pub libp2p_history_gossip: usize, + + /// Number of heartbeats to keep in the Libp2p `memcache` + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_HISTORY_LENGTH", + default_value = "5" + )] + pub libp2p_history_length: usize, + + /// Target number of peers for the Libp2p mesh network + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N", default_value = "8")] + pub libp2p_mesh_n: usize, + + /// Maximum number of peers in the Libp2p mesh network before removing some + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N_HIGH", + default_value = "12" + )] + pub libp2p_mesh_n_high: usize, + + /// Minimum number of peers in the Libp2p mesh network before adding more + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_N_LOW", + default_value = "6" + )] + pub libp2p_mesh_n_low: usize, + + /// Minimum number of outbound Libp2p peers in the mesh network before adding more + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MESH_OUTBOUND_MIN", + default_value = "2" + )] + pub libp2p_mesh_outbound_min: usize, + + /// The maximum number of messages to include in a Libp2p IHAVE message + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_IHAVE_LENGTH", + default_value = "5000" + )] + pub libp2p_max_ihave_length: usize, + + /// The maximum number of IHAVE messages to accept from a Libp2p peer within a heartbeat + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_IHAVE_MESSAGES", + default_value = "10" + )] + pub libp2p_max_ihave_messages: usize, + + /// Libp2p published message ids time cache duration + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_PUBLISHED_MESSAGE_IDS_CACHE_TIME", default_value = "10s", value_parser = parse_duration)] + pub libp2p_published_message_ids_cache_time: Duration, + + /// Time to wait for a Libp2p message requested through IWANT following an IHAVE advertisement + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_IWANT_FOLLOWUP_TIME", + default_value = "3s", value_parser = parse_duration + )] + pub libp2p_iwant_followup_time: Duration, + + /// The maximum number of Libp2p messages we will process in a given RPC + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_MESSAGES_PER_RPC")] + pub libp2p_max_messages_per_rpc: Option, + + /// How many times we will allow a Libp2p peer to request the same message id through IWANT gossip before we start ignoring them + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_GOSSIP_RETRANSMISSION", + default_value = "3" + )] + pub libp2p_gossip_retransmission: u32, + + /// If enabled newly created messages will always be sent to all peers that are subscribed to the topic and have a good enough score + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_FLOOD_PUBLISH", + default_value = "true" + )] + pub libp2p_flood_publish: bool, + + /// The time period that Libp2p message hashes are stored in the cache + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_DUPLICATE_CACHE_TIME", default_value = "20m", value_parser = parse_duration)] + pub libp2p_duplicate_cache_time: Duration, + + /// Time to live for Libp2p fanout peers + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_FANOUT_TTL", default_value = "60s", value_parser = parse_duration)] + pub libp2p_fanout_ttl: Duration, + + /// Initial delay in each Libp2p heartbeat + #[clap(long, env = "ESPRESSO_SEQUENCER_LIBP2P_HEARTBEAT_INITIAL_DELAY", default_value = "5s", value_parser = parse_duration)] + pub libp2p_heartbeat_initial_delay: Duration, + + /// How many Libp2p peers we will emit gossip to at each heartbeat + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_GOSSIP_FACTOR", + default_value = "0.25" + )] + pub libp2p_gossip_factor: f64, + + /// Minimum number of Libp2p peers to emit gossip to during a heartbeat + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_GOSSIP_LAZY", + default_value = "6" + )] + pub libp2p_gossip_lazy: usize, + + /// The maximum number of bytes we will send in a single Libp2p gossip message + #[clap( + long, + env = "ESPRESSO_SEQUENCER_LIBP2P_MAX_TRANSMIT_SIZE", + default_value = "2000000" + )] + pub libp2p_max_transmit_size: usize, + /// The URL we advertise to other nodes as being for our public API. /// Should be supplied in `http://host:port` form. #[clap(long, env = "ESPRESSO_SEQUENCER_PUBLIC_API_URL")]