Skip to content

Commit cfd0f2e

Browse files
committed
Try fetching remote forkpoint.toml and validators.toml on startup
1 parent 609f416 commit cfd0f2e

File tree

5 files changed

+205
-86
lines changed

5 files changed

+205
-86
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

monad-node-config/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,7 @@ pub type ForkpointConfig = monad_consensus_types::checkpoint::Checkpoint<
8989
ExecutionProtocolType,
9090
>;
9191
#[cfg(feature = "crypto")]
92+
pub type ValidatorsConfigType =
93+
monad_consensus_types::validator_data::ValidatorsConfig<SignatureCollectionType>;
94+
#[cfg(feature = "crypto")]
9295
pub type MonadNodeConfig = NodeConfig<SignatureType>;

monad-node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ opentelemetry-otlp = { workspace = true, features = ["metrics", "grpc-tonic"] }
5151
opentelemetry-semantic-conventions = { workspace = true }
5252
rand_chacha = { workspace = true }
5353
rayon = { workspace = true }
54+
reqwest = { workspace = true, features = ["blocking"] }
5455
thiserror = { workspace = true }
5556
tokio = { workspace = true, features = ["rt-multi-thread", "signal"] }
5657
toml = { workspace = true }

monad-node/src/main.rs

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ use std::{
2222
time::{Duration, Instant},
2323
};
2424

25-
use agent::AgentBuilder;
2625
use alloy_rlp::{Decodable, Encodable};
2726
use chrono::Utc;
2827
use clap::CommandFactory;
2928
use futures_util::{FutureExt, StreamExt};
3029
use monad_chain_config::ChainConfig;
3130
use monad_consensus_state::ConsensusConfig;
32-
use monad_consensus_types::{
33-
metrics::Metrics,
34-
validator_data::{ValidatorSetDataWithEpoch, ValidatorsConfig},
35-
};
36-
use monad_control_panel::{ipc::ControlPanelIpcReceiver, TracingReload};
31+
use monad_consensus_types::{metrics::Metrics, validator_data::ValidatorSetDataWithEpoch};
32+
use monad_control_panel::ipc::ControlPanelIpcReceiver;
3733
use monad_crypto::{
3834
certificate_signature::{
3935
CertificateKeyPair, CertificateSignaturePubKey, CertificateSignatureRecoverable, PubKey,
@@ -79,12 +75,6 @@ use opentelemetry_otlp::{MetricExporter, WithExportConfig};
7975
use rand_chacha::{rand_core::SeedableRng, ChaCha8Rng};
8076
use tokio::signal::unix::{signal, SignalKind};
8177
use tracing::{error, event, info, warn, Instrument, Level};
82-
use tracing_manytrace::{ManytraceLayer, TracingExtension};
83-
use tracing_subscriber::{
84-
fmt::{format::FmtSpan, Layer as FmtLayer},
85-
layer::SubscriberExt,
86-
Layer,
87-
};
8878

8979
use self::{cli::Cli, error::NodeSetupError, state::NodeState};
9080

@@ -124,9 +114,6 @@ fn main() {
124114
.map_err(Into::into)
125115
.unwrap_or_else(|e: NodeSetupError| cmd.error(e.kind(), e).exit());
126116

127-
let (reload_handle, _agent) = setup_tracing(&node_state)
128-
.unwrap_or_else(|e: NodeSetupError| cmd.error(e.kind(), e).exit());
129-
130117
drop(cmd);
131118

132119
MONAD_NODE_VERSION.map(|v| info!("starting monad-bft with version {}", v));
@@ -149,70 +136,14 @@ fn main() {
149136
});
150137
}
151138

152-
if let Err(e) = runtime.block_on(run(node_state, reload_handle)) {
139+
if let Err(e) = runtime.block_on(run(node_state)) {
153140
tracing::error!("monad consensus node crashed: {:?}", e);
154141
}
155142
}
156143

157-
fn setup_tracing(
158-
node_state: &NodeState,
159-
) -> Result<(Box<dyn TracingReload>, Option<agent::Agent>), NodeSetupError> {
160-
if let Some(socket_path) = &node_state.manytrace_socket {
161-
let extension = std::sync::Arc::new(TracingExtension::new());
162-
let agent = AgentBuilder::new(socket_path.clone())
163-
.register_tracing(Box::new((*extension).clone()))
164-
.build()
165-
.map_err(|e| NodeSetupError::Custom {
166-
kind: clap::error::ErrorKind::Io,
167-
msg: format!("failed to build manytrace agent: {}", e),
168-
})?;
169-
let (filter, reload_handle) = tracing_subscriber::reload::Layer::new(
170-
tracing_subscriber::EnvFilter::from_default_env(),
171-
);
172-
let subscriber = tracing_subscriber::Registry::default()
173-
.with(ManytraceLayer::new(extension))
174-
.with(
175-
FmtLayer::default()
176-
.json()
177-
.with_span_events(FmtSpan::NONE)
178-
.with_current_span(false)
179-
.with_span_list(false)
180-
.with_writer(std::io::stdout)
181-
.with_ansi(false)
182-
.with_filter(filter),
183-
);
184-
185-
tracing::subscriber::set_global_default(subscriber)?;
186-
info!("manytrace tracing enabled");
187-
Ok((Box::new(reload_handle), Some(agent)))
188-
} else {
189-
let (filter, reload_handle) = tracing_subscriber::reload::Layer::new(
190-
tracing_subscriber::EnvFilter::from_default_env(),
191-
);
192-
193-
let subscriber = tracing_subscriber::Registry::default().with(filter).with(
194-
FmtLayer::default()
195-
.json()
196-
.with_span_events(FmtSpan::NONE)
197-
.with_current_span(false)
198-
.with_span_list(false)
199-
.with_writer(std::io::stdout)
200-
.with_ansi(false),
201-
);
202-
203-
tracing::subscriber::set_global_default(subscriber)?;
204-
Ok((Box::new(reload_handle), None))
205-
}
206-
}
207-
208-
async fn run(node_state: NodeState, reload_handle: Box<dyn TracingReload>) -> Result<(), ()> {
209-
let locked_epoch_validators = ValidatorsConfig::read_from_path(&node_state.validators_path)
210-
.unwrap_or_else(|err| {
211-
panic!(
212-
"failed to read/parse validators_path={:?}, err={:?}",
213-
&node_state.validators_path, err
214-
)
215-
})
144+
async fn run(node_state: NodeState) -> Result<(), ()> {
145+
let locked_epoch_validators = node_state
146+
.validators_config
216147
.get_locked_validator_sets(&node_state.forkpoint_config);
217148

218149
let current_epoch = node_state
@@ -341,7 +272,7 @@ async fn run(node_state: NodeState, reload_handle: Box<dyn TracingReload>) -> Re
341272
.expect("txpool ipc succeeds"),
342273
control_panel: ControlPanelIpcReceiver::new(
343274
node_state.control_panel_ipc_path,
344-
reload_handle,
275+
node_state.reload_handle,
345276
1000,
346277
)
347278
.expect("uds bind failed"),
@@ -397,8 +328,8 @@ async fn run(node_state: NodeState, reload_handle: Box<dyn TracingReload>) -> Re
397328
key: node_state.secp256k1_identity,
398329
certkey: node_state.bls12_381_identity,
399330
beneficiary: node_state.node_config.beneficiary.into(),
400-
locked_epoch_validators,
401331
forkpoint: node_state.forkpoint_config.into(),
332+
locked_epoch_validators,
402333
block_sync_override_peers,
403334
consensus_config: ConsensusConfig {
404335
execution_delay: SeqNum(EXECUTION_DELAY),

0 commit comments

Comments
 (0)