Skip to content

Commit

Permalink
feat: Expose http debug page (matter-labs#2952)
Browse files Browse the repository at this point in the history
## What ❔
Exposes the consensus http debug on port 5000.
Fixes BFT-508
  • Loading branch information
brunoffranca authored Sep 30, 2024
1 parent e7ead76 commit e0b6488
Show file tree
Hide file tree
Showing 13 changed files with 1,452 additions and 1,368 deletions.
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
7 changes: 7 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,12 @@ 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: self
.debug_page_addr
.as_ref()
.map(|x| Ok::<_, anyhow::Error>(x.parse()?))
.transpose()
.context("debug_page_addr")?,
})
}

Expand All @@ -195,6 +201,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

0 comments on commit e0b6488

Please sign in to comment.