Skip to content

Commit

Permalink
Made debug page optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoffranca committed Sep 27, 2024
1 parent ebe91ce commit 067b973
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions core/lib/config/src/configs/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ pub struct ConsensusConfig {
/// node.
pub public_addr: Host,

/// Local socket address to expose the node debug page.
pub debug_page_addr: std::net::SocketAddr,

/// Maximal allowed size of the payload in bytes.
pub max_payload_size: usize,

Expand All @@ -151,6 +148,9 @@ pub struct ConsensusConfig {

/// Rate limiting configuration for the p2p RPCs.
pub rpc: Option<RpcConfig>,

/// Local socket address to expose the node debug page.
pub debug_page_addr: Option<std::net::SocketAddr>,
}

impl ConsensusConfig {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ impl Distribution<configs::consensus::ConsensusConfig> for EncodeDist {
ConsensusConfig {
server_addr: self.sample(rng),
public_addr: Host(self.sample(rng)),
debug_page_addr: self.sample(rng),
max_payload_size: self.sample(rng),
max_batch_size: self.sample(rng),
gossip_dynamic_inbound_limit: self.sample(rng),
Expand All @@ -812,6 +811,7 @@ impl Distribution<configs::consensus::ConsensusConfig> for EncodeDist {
.collect(),
genesis_spec: self.sample(rng),
rpc: self.sample(rng),
debug_page_addr: self.sample(rng),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/lib/protobuf_config/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl ProtoRepr for proto::Config {
rpc: read_optional_repr(&self.rpc_config),
debug_page_addr: required(&self.debug_page_addr)
.and_then(|x| Ok(x.parse()?))
.context("debug_page_addr")?,
.ok(),
})
}

Expand All @@ -198,7 +198,7 @@ impl ProtoRepr for proto::Config {
.collect(),
genesis_spec: this.genesis_spec.as_ref().map(ProtoRepr::build),
rpc_config: this.rpc.as_ref().map(ProtoRepr::build),
debug_page_addr: Some(this.debug_page_addr.to_string()),
debug_page_addr: this.debug_page_addr.as_ref().map(|x| x.to_string()),
}
}
}
15 changes: 10 additions & 5 deletions core/node/consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ pub(super) fn executor(
refresh: time::Duration::ZERO,
};

let debug_page = match cfg.debug_page_addr {
Some(addr) => Some(network::debug_page::Config {
addr,
credentials: None,
tls: None,
}),
None => None,
};

Ok(executor::Config {
build_version,
server_addr: cfg.server_addr,
Expand All @@ -177,11 +186,7 @@ pub(super) fn executor(
.context("gossip_static_inbound")?,
gossip_static_outbound,
rpc,
debug_page: Some(network::debug_page::Config {
addr: cfg.debug_page_addr,
credentials: None,
tls: None,
}),
debug_page,
batch_poll_interval: time::Duration::seconds(1),
})
}
5 changes: 1 addition & 4 deletions core/node/consensus/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ fn make_config(
config::ConsensusConfig {
server_addr: *cfg.server_addr,
public_addr: config::Host(cfg.public_addr.0.clone()),
debug_page_addr: std::net::SocketAddr::new(
std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)),
5000,
),
max_payload_size: usize::MAX,
max_batch_size: usize::MAX,
gossip_dynamic_inbound_limit: cfg.gossip.dynamic_inbound_limit,
Expand All @@ -182,6 +178,7 @@ fn make_config(
// genesis generator for zksync-era tests.
genesis_spec,
rpc: None,
debug_page_addr: None,
}
}

Expand Down

0 comments on commit 067b973

Please sign in to comment.