Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expose http debug page #2952

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
1,909 changes: 952 additions & 957 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions core/lib/config/src/configs/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,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
1 change: 1 addition & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,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: 4 additions & 0 deletions core/lib/protobuf_config/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ impl ProtoRepr for proto::Config {
.context("gossip_static_outbound")?,
genesis_spec: read_optional_repr(&self.genesis_spec),
rpc: read_optional_repr(&self.rpc_config),
debug_page_addr: required(&self.debug_page_addr)
.and_then(|x| Ok(x.parse()?))
.ok(),
})
}

Expand All @@ -195,6 +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: this.debug_page_addr.as_ref().map(|x| x.to_string()),
}
}
}
4 changes: 4 additions & 0 deletions core/lib/protobuf_config/src/proto/core/consensus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,9 @@ message Config {
// RPC rate limits configuration.
// If missing, defaults are used.
optional RpcConfig rpc_config = 9; // optional

// IP:port to expose the debug page.
// Use `127.0.0.1:<port>` to only allow local access to the page.
optional string debug_page_addr = 11; // required; IpAddr
}

10 changes: 8 additions & 2 deletions core/node/consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use zksync_config::{
};
use zksync_consensus_crypto::{Text, TextFmt};
use zksync_consensus_executor as executor;
use zksync_consensus_network as network;
use zksync_consensus_roles::{attester, node, validator};
use zksync_dal::consensus_dal;
use zksync_types::ethabi;
Expand Down Expand Up @@ -157,6 +158,12 @@ pub(super) fn executor(
refresh: time::Duration::ZERO,
};

let debug_page = cfg.debug_page_addr.map(|addr| network::debug_page::Config {
addr,
credentials: None,
tls: None,
});

Ok(executor::Config {
build_version,
server_addr: cfg.server_addr,
Expand All @@ -176,8 +183,7 @@ pub(super) fn executor(
.context("gossip_static_inbound")?,
gossip_static_outbound,
rpc,
// TODO: Add to configuration
debug_page: None,
debug_page,
batch_poll_interval: time::Duration::seconds(1),
})
}
1 change: 1 addition & 0 deletions core/node/consensus/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fn make_config(
// genesis generator for zksync-era tests.
genesis_spec,
rpc: None,
debug_page_addr: None,
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server_addr: '0.0.0.0:3054'
public_addr: '127.0.0.1:3054'
debug_page_addr: '127.0.0.1:5000'
max_payload_size: 5000000
gossip_dynamic_inbound_limit: 100
gossip_static_outbound:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server_addr: '0.0.0.0:3054'
public_addr: '127.0.0.1:3054'
debug_page_addr: '127.0.0.1:5000'
max_payload_size: 5000000
gossip_dynamic_inbound_limit: 100
gossip_static_outbound:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
[
"/usr/bin/entrypoint.sh",
# Uncomment the following line to enable consensus
# "--enable-consensus",
"--enable-consensus",
]
restart: always
depends_on:
Expand All @@ -79,6 +79,7 @@ services:
- "127.0.0.1:3060:3060"
- "127.0.0.1:3061:3061"
- "127.0.0.1:3081:3081"
- "127.0.0.1:5000:5000"
volumes:
- rocksdb:/db
- ./configs:/configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
[
"/usr/bin/entrypoint.sh",
# Uncomment the following line to enable consensus
# "--enable-consensus",
"--enable-consensus",
]
restart: always
depends_on:
Expand All @@ -79,6 +79,7 @@ services:
- "127.0.0.1:3060:3060"
- "127.0.0.1:3061:3061"
- "127.0.0.1:3081:3081"
- "127.0.0.1:5000:5000"
volumes:
- rocksdb:/db
- ./configs:/configs
Expand Down
Loading
Loading