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 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,972 changes: 977 additions & 995 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ tower-http = "0.5.2"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-opentelemetry = "0.25.0"
time = "0.3.36" # Has to be same as used by `tracing-subscriber`
time = "0.3.36" # Has to be same as used by `tracing-subscriber`
url = "2"
web3 = "0.19.0"
fraction = "0.15.3"
Expand Down Expand Up @@ -230,16 +230,16 @@ zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" }
zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "74577d9be13b1bff9d1a712389731f669b179e47" }

# Consensus dependencies.
zksync_concurrency = "=0.1.1"
zksync_consensus_bft = "=0.1.1"
zksync_consensus_crypto = "=0.1.1"
zksync_consensus_executor = "=0.1.1"
zksync_consensus_network = "=0.1.1"
zksync_consensus_roles = "=0.1.1"
zksync_consensus_storage = "=0.1.1"
zksync_consensus_utils = "=0.1.1"
zksync_protobuf = "=0.1.1"
zksync_protobuf_build = "=0.1.1"
zksync_concurrency = "=0.2.0"
zksync_consensus_bft = "=0.2.0"
zksync_consensus_crypto = "=0.2.0"
zksync_consensus_executor = "=0.2.0"
zksync_consensus_network = "=0.2.0"
zksync_consensus_roles = "=0.2.0"
zksync_consensus_storage = "=0.2.0"
zksync_consensus_utils = "=0.2.0"
zksync_protobuf = "=0.2.0"
zksync_protobuf_build = "=0.2.0"

# "Local" dependencies
zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" }
Expand Down
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 @@ -122,6 +122,9 @@ 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 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 @@ -798,6 +798,7 @@ 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 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()?))
.context("debug_page_addr")?,
})
}

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: Some(this.debug_page_addr.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
}

8 changes: 6 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 @@ -176,8 +177,11 @@ pub(super) fn executor(
.context("gossip_static_inbound")?,
gossip_static_outbound,
rpc,
// TODO: Add to configuration
debug_page: None,
debug_page: Some(network::debug_page::Config {
addr: cfg.debug_page_addr,
credentials: None,
tls: None,
}),
batch_poll_interval: time::Duration::seconds(1),
})
}
4 changes: 4 additions & 0 deletions core/node/consensus/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ 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(127, 0, 0, 1)),
8080,
),
max_payload_size: usize::MAX,
max_batch_size: usize::MAX,
gossip_dynamic_inbound_limit: cfg.gossip.dynamic_inbound_limit,
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