Skip to content

Commit

Permalink
Merge pull request #1327 from EspressoSystems/rm/fix-docker-2
Browse files Browse the repository at this point in the history
Fix Demo
  • Loading branch information
rob-maron authored Apr 12, 2024
2 parents bd0c6d1 + f094eb2 commit 6a1ca73
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ESPRESSO_ORCHESTRATOR_NEXT_VIEW_TIMEOUT=30s
ESPRESSO_ORCHESTRATOR_MIN_TRANSACTIONS=50
ESPRESSO_ORCHESTRATOR_MIN_PROPOSE_TIME=1s
ESPRESSO_ORCHESTRATOR_MAX_PROPOSE_TIME=2s
ESPRESSO_SEQUENCER_CDN_ENDPOINT=marshal:${ESPRESSO_CDN_SERVER_PORT}
ESPRESSO_SEQUENCER_CDN_ENDPOINT=marshal-0:${ESPRESSO_CDN_SERVER_PORT}
ESPRESSO_SEQUENCER_ORCHESTRATOR_URL=http://orchestrator:${ESPRESSO_ORCHESTRATOR_PORT}
ESPRESSO_SEQUENCER_API_PORT=50000
ESPRESSO_SEQUENCER1_API_PORT=50001
Expand Down
32 changes: 24 additions & 8 deletions builder/src/bin/permissioned-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hotshot_types::traits::node_implementation::ConsensusTime;
use sequencer::persistence::no_storage::NoStorage;
use sequencer::{BuilderParams, L1Params, NetworkParams};
use snafu::Snafu;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::num::NonZeroUsize;
use std::{collections::HashMap, path::PathBuf, str::FromStr, time::Duration};
use url::Url;
Expand Down Expand Up @@ -44,24 +44,24 @@ pub struct PermissionedBuilderOptions {
)]
pub cdn_endpoint: String,

/// The address to bind to for Libp2p (in `IP:port` form)
/// The address to bind to for Libp2p (in `host:port` form)
#[clap(
short,
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS",
default_value = "0.0.0.0:1769"
)]
pub libp2p_bind_address: SocketAddr,
pub libp2p_bind_address: String,

/// The address we advertise to other nodes as being a Libp2p endpoint.
/// Should be supplied in `IP:port` form.
/// Should be supplied in `host:port` form.
#[clap(
short,
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS",
default_value = "127.0.0.1:1769"
default_value = "localhost:1769"
)]
pub libp2p_advertise_address: SocketAddr,
pub libp2p_advertise_address: String,

/// URL of the Light Client State Relay Server
#[clap(
Expand Down Expand Up @@ -210,10 +210,26 @@ async fn main() -> anyhow::Result<()> {
// get from the private key
let builder_pub_key = BLSPubKey::from_private(&private_staking_key);

// Parse supplied Libp2p addresses to their socket form
// We expect all nodes to be reachable via IPv4, so we filter out any IPv6 addresses.
// Downstream in HotShot we pin the IP address to v4, but this can be fixed in the future.
let libp2p_advertise_address = opt
.libp2p_advertise_address
.to_socket_addrs()?
.find(|x| x.is_ipv4())
.ok_or(anyhow::anyhow!(
"Failed to resolve Libp2p advertise address"
))?;
let libp2p_bind_address = opt
.libp2p_bind_address
.to_socket_addrs()?
.find(|x| x.is_ipv4())
.ok_or(anyhow::anyhow!("Failed to resolve Libp2p bind address"))?;

let network_params = NetworkParams {
cdn_endpoint: opt.cdn_endpoint,
libp2p_advertise_address: opt.libp2p_advertise_address,
libp2p_bind_address: opt.libp2p_bind_address,
libp2p_advertise_address,
libp2p_bind_address,
orchestrator_url: opt.orchestrator_url,
state_relay_server_url: opt.state_relay_server_url,
private_staking_key: private_staking_key.clone(),
Expand Down
2 changes: 1 addition & 1 deletion docker/cdn-broker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN chmod +x /bin/cdn-broker

ENV RUST_LOG="info"

HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_CDN_SERVER_METRICS_PORT} || exit 1
HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_CDN_SERVER_METRICS_PORT}/metrics || exit 1
ENTRYPOINT ["cdn-broker"]
2 changes: 1 addition & 1 deletion docker/cdn-marshal.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN chmod +x /bin/cdn-marshal

ENV RUST_LOG="info"

HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_CDN_SERVER_METRICS_PORT} || exit 1
HEALTHCHECK --interval=1s --timeout=1s --retries=100 CMD curl --fail http://localhost:${ESPRESSO_CDN_SERVER_METRICS_PORT}/metrics || exit 1
ENTRYPOINT ["cdn-marshal"]
8 changes: 4 additions & 4 deletions process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ processes:
environment:
- ESPRESSO_SEQUENCER_API_PORT=$ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_0
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=127.0.0.1:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_0
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=localhost:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_0
- ESPRESSO_SEQUENCER_API_PEERS=http://localhost:$ESPRESSO_SEQUENCER1_API_PORT
- ESPRESSO_SEQUENCER_STATE_PEERS=http://localhost:$ESPRESSO_SEQUENCER1_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq0
Expand Down Expand Up @@ -109,7 +109,7 @@ processes:
environment:
- ESPRESSO_SEQUENCER_API_PORT=$ESPRESSO_SEQUENCER1_API_PORT
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_1
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=127.0.0.1:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_1
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=localhost:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_1
- ESPRESSO_SEQUENCER_API_PEERS=http://localhost:$ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STATE_PEERS=http://localhost:$ESPRESSO_SEQUENCER2_API_PORT
- ESPRESSO_SEQUENCER_POSTGRES_HOST=localhost
Expand Down Expand Up @@ -147,7 +147,7 @@ processes:
environment:
- ESPRESSO_SEQUENCER_API_PORT=$ESPRESSO_SEQUENCER2_API_PORT
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_2
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=127.0.0.1:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_2
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=localhost:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_2
- ESPRESSO_SEQUENCER_STATE_PEERS=http://localhost:$ESPRESSO_SEQUENCER3_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq2
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_2
Expand Down Expand Up @@ -179,7 +179,7 @@ processes:
environment:
- ESPRESSO_SEQUENCER_API_PORT=$ESPRESSO_SEQUENCER3_API_PORT
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_3
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=127.0.0.1:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_3
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=localhost:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_3
- ESPRESSO_SEQUENCER_STATE_PEERS=http://localhost:$ESPRESSO_SEQUENCER4_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq3
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_3
Expand Down
23 changes: 21 additions & 2 deletions sequencer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::net::ToSocketAddrs;

use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use es_version::SEQUENCER_VERSION;
Expand Down Expand Up @@ -55,10 +57,27 @@ where
prefunded_accounts: opt.prefunded_builder_accounts,
eth_account_index: opt.eth_account_index,
};

// Parse supplied Libp2p addresses to their socket form
// We expect all nodes to be reachable via IPv4, so we filter out any IPv6 addresses.
// Downstream in HotShot we pin the IP address to v4, but this can be fixed in the future.
let libp2p_advertise_address = opt
.libp2p_advertise_address
.to_socket_addrs()?
.find(|x| x.is_ipv4())
.ok_or(anyhow::anyhow!(
"Failed to resolve Libp2p advertise address"
))?;
let libp2p_bind_address = opt
.libp2p_bind_address
.to_socket_addrs()?
.find(|x| x.is_ipv4())
.ok_or(anyhow::anyhow!("Failed to resolve Libp2p bind address"))?;

let network_params = NetworkParams {
cdn_endpoint: opt.cdn_endpoint,
libp2p_advertise_address: opt.libp2p_advertise_address,
libp2p_bind_address: opt.libp2p_bind_address,
libp2p_advertise_address,
libp2p_bind_address,
orchestrator_url: opt.orchestrator_url,
state_relay_server_url: opt.state_relay_server_url,
private_staking_key,
Expand Down
11 changes: 5 additions & 6 deletions sequencer/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use snafu::Snafu;
use std::{
collections::{HashMap, HashSet},
iter::once,
net::SocketAddr,
path::PathBuf,
str::FromStr,
time::Duration,
Expand Down Expand Up @@ -60,24 +59,24 @@ pub struct Options {
)]
pub cdn_endpoint: String,

/// The address to bind to for Libp2p (in `IP:port` form)
/// The address to bind to for Libp2p (in `host:port` form)
#[clap(
short,
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS",
default_value = "0.0.0.0:1769"
)]
pub libp2p_bind_address: SocketAddr,
pub libp2p_bind_address: String,

/// The address we advertise to other nodes as being a Libp2p endpoint.
/// Should be supplied in `IP:port` form.
/// Should be supplied in `host:port` form.
#[clap(
short,
long,
env = "ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS",
default_value = "127.0.0.1:1769"
default_value = "localhost:1769"
)]
pub libp2p_advertise_address: SocketAddr,
pub libp2p_advertise_address: String,

/// URL of the Light Client State Relay Server
#[clap(
Expand Down

0 comments on commit 6a1ca73

Please sign in to comment.