From cf17704d31521716d5cf6e93cc00e786b67a28b0 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 2 Apr 2024 09:56:45 +0200 Subject: [PATCH] Remove `telemetry` and `rest-server` feature flags (#3878) * Enable telemetry unconditionally and remove `telemetry` feature flag * Formatting * Add changelog entry * Remove `rest-server` feature flag * Update changelog entry --------- Signed-off-by: Romain Ruetschi --- .../3878-remove-telemetry-flag.md | 3 ++ crates/relayer-cli/Cargo.toml | 11 ++------ crates/relayer-cli/src/commands/start.rs | 28 ------------------- crates/relayer/Cargo.toml | 3 +- crates/relayer/src/chain/cosmos/estimate.rs | 1 - crates/relayer/src/link/relay_path.rs | 4 --- crates/relayer/src/supervisor.rs | 1 - crates/relayer/src/telemetry.rs | 11 -------- crates/relayer/src/worker/map.rs | 1 - crates/relayer/src/worker/packet.rs | 5 ---- 10 files changed, 6 insertions(+), 62 deletions(-) create mode 100644 .changelog/unreleased/breaking-changes/ibc-telemetry/3878-remove-telemetry-flag.md diff --git a/.changelog/unreleased/breaking-changes/ibc-telemetry/3878-remove-telemetry-flag.md b/.changelog/unreleased/breaking-changes/ibc-telemetry/3878-remove-telemetry-flag.md new file mode 100644 index 0000000000..4f0d3f5646 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/ibc-telemetry/3878-remove-telemetry-flag.md @@ -0,0 +1,3 @@ +- Remove the `telemetry` and `rest-server` feature flags, ensuring Hermes is always built with telemetry and REST support. + Both servers can still be disabled in the configuration file, by setting `telemtry.enabled = false` and `rest.enabled = false`, respectively. + ([\#3878](https://github.com/informalsystems/hermes/pull/3878)) diff --git a/crates/relayer-cli/Cargo.toml b/crates/relayer-cli/Cargo.toml index da9deeb9f1..ebc2941fa2 100644 --- a/crates/relayer-cli/Cargo.toml +++ b/crates/relayer-cli/Cargo.toml @@ -17,18 +17,11 @@ default-run = "hermes" [[bin]] name = "hermes" -[features] -default = ["telemetry", "rest-server", "std", "eyre_tracer"] -std = ["flex-error/std"] -eyre_tracer = ["flex-error/eyre_tracer"] -telemetry = ["ibc-relayer/telemetry", "ibc-telemetry"] -rest-server = ["ibc-relayer-rest"] - [dependencies] ibc-relayer-types = { workspace = true } ibc-relayer = { workspace = true } -ibc-telemetry = { workspace = true, optional = true } -ibc-relayer-rest = { workspace = true, optional = true } +ibc-telemetry = { workspace = true } +ibc-relayer-rest = { workspace = true } ibc-chain-registry = { workspace = true } abscissa_core = { workspace = true, features = ["options"] } diff --git a/crates/relayer-cli/src/commands/start.rs b/crates/relayer-cli/src/commands/start.rs index a102e66c0c..cc9c9193f7 100644 --- a/crates/relayer-cli/src/commands/start.rs +++ b/crates/relayer-cli/src/commands/start.rs @@ -131,7 +131,6 @@ fn register_signals(tx_cmd: Sender) -> Result<(), io::Error> { Ok(()) } -#[cfg(feature = "rest-server")] fn spawn_rest_server(config: &Config) -> Option { use ibc_relayer::util::spawn_blocking; @@ -169,23 +168,6 @@ fn spawn_rest_server(config: &Config) -> Option { Some(rx) } -#[cfg(not(feature = "rest-server"))] -fn spawn_rest_server(config: &Config) -> Option { - let rest = config.rest.clone(); - - if rest.enabled { - warn!( - "REST server enabled in the config but Hermes was built without REST support, \ - build Hermes with --features=rest-server to enable REST support." - ); - - None - } else { - None - } -} - -#[cfg(feature = "telemetry")] fn spawn_telemetry_server(config: &Config) { use ibc_relayer::util::spawn_blocking; @@ -220,16 +202,6 @@ fn spawn_telemetry_server(config: &Config) { }); } -#[cfg(not(feature = "telemetry"))] -fn spawn_telemetry_server(config: &Config) { - if config.telemetry.enabled { - warn!( - "telemetry enabled in the config but Hermes was built without telemetry support, \ - build Hermes with --features=telemetry to enable telemetry support." - ); - } -} - fn make_supervisor( config: Config, options: SupervisorOptions, diff --git a/crates/relayer/Cargo.toml b/crates/relayer/Cargo.toml index 1bc3c3564a..f338761093 100644 --- a/crates/relayer/Cargo.toml +++ b/crates/relayer/Cargo.toml @@ -17,11 +17,10 @@ all-features = true [features] default = ["flex-error/std", "flex-error/eyre_tracer"] -telemetry = ["ibc-telemetry"] [dependencies] ibc-proto = { workspace = true, features = ["serde"] } -ibc-telemetry = { workspace = true, optional = true } +ibc-telemetry = { workspace = true } ibc-relayer-types = { workspace = true, features = ["clock"] } anyhow = { workspace = true } diff --git a/crates/relayer/src/chain/cosmos/estimate.rs b/crates/relayer/src/chain/cosmos/estimate.rs index dff1a5cdff..e68ea86b2b 100644 --- a/crates/relayer/src/chain/cosmos/estimate.rs +++ b/crates/relayer/src/chain/cosmos/estimate.rs @@ -212,7 +212,6 @@ fn can_recover_from_simulation_failure(e: &Error) -> bool { } } -#[cfg(feature = "telemetry")] fn get_error_text(e: &Error) -> String { use crate::error::ErrorDetail::*; diff --git a/crates/relayer/src/link/relay_path.rs b/crates/relayer/src/link/relay_path.rs index a1372b8bbf..511ecc383b 100644 --- a/crates/relayer/src/link/relay_path.rs +++ b/crates/relayer/src/link/relay_path.rs @@ -1845,7 +1845,6 @@ impl RelayPath { } // we need fully qualified ChainId to avoid unneeded imports warnings - #[cfg(feature = "telemetry")] fn target_info( &self, target: OperationalDataTarget, @@ -1871,7 +1870,6 @@ impl RelayPath { } } - #[cfg(feature = "telemetry")] fn backlog_update(&self, event: &IbcEvent) { match event { IbcEvent::SendPacket(send_packet_ev) => { @@ -1905,7 +1903,6 @@ impl RelayPath { } } - #[cfg(feature = "telemetry")] fn record_cleared_send_packet(&self, event_with_height: &IbcEventWithHeight) { if let IbcEvent::SendPacket(send_packet_ev) = &event_with_height.event { ibc_telemetry::global().send_packet_events( @@ -1927,7 +1924,6 @@ impl RelayPath { } } - #[cfg(feature = "telemetry")] fn record_cleared_acknowledgments<'a>( &self, events_with_heights: impl Iterator, diff --git a/crates/relayer/src/supervisor.rs b/crates/relayer/src/supervisor.rs index cab6f55c82..53661e7007 100644 --- a/crates/relayer/src/supervisor.rs +++ b/crates/relayer/src/supervisor.rs @@ -848,7 +848,6 @@ fn process_batch( /// So successfully sending a packet from chain A to chain B will result in first a SendPacket /// event with `chain_id = A` and `counterparty_chain_id = B` and then a WriteAcknowlegment /// event with `chain_id = B` and `counterparty_chain_id = A`. -#[cfg(feature = "telemetry")] fn send_telemetry( src: &Src, dst: &Dst, diff --git a/crates/relayer/src/telemetry.rs b/crates/relayer/src/telemetry.rs index 0734ee454b..bc8bc77ae6 100644 --- a/crates/relayer/src/telemetry.rs +++ b/crates/relayer/src/telemetry.rs @@ -1,15 +1,6 @@ // If the `telemetry` feature is enabled, re-export the `ibc-telemetry` state. -#[cfg(feature = "telemetry")] pub type Telemetry = alloc::sync::Arc; -// Otherwise, define and export a dummy type. -#[cfg(not(feature = "telemetry"))] -#[derive(Clone, Debug)] -pub struct TelemetryDisabled; - -#[cfg(not(feature = "telemetry"))] -pub type Telemetry = TelemetryDisabled; - /// A macro to send metric updates via a telemetry handle, /// only if the `telemetry` feature is enabled. /// Otherwise, it compiles to a no-op. @@ -32,7 +23,6 @@ pub type Telemetry = TelemetryDisabled; #[macro_export] macro_rules! telemetry { ($id:ident, $($args:expr),* $(,)*) => { - #[cfg(feature = "telemetry")] #[allow(unused_imports, unused_variables)] { use ::ibc_telemetry::state::WorkerType; @@ -42,7 +32,6 @@ macro_rules! telemetry { }; ($e:expr) => { - #[cfg(feature = "telemetry")] #[allow(unused_imports, unused_variables)] { use ::ibc_telemetry::state::WorkerType; diff --git a/crates/relayer/src/worker/map.rs b/crates/relayer/src/worker/map.rs index c5305f52cb..eb498c8f69 100644 --- a/crates/relayer/src/worker/map.rs +++ b/crates/relayer/src/worker/map.rs @@ -252,7 +252,6 @@ impl Drop for WorkerMap { } } -#[cfg(feature = "telemetry")] fn metric_type(o: &Object) -> ibc_telemetry::state::WorkerType { use ibc_telemetry::state::WorkerType; diff --git a/crates/relayer/src/worker/packet.rs b/crates/relayer/src/worker/packet.rs index 841b6ada98..98fe15c3e3 100644 --- a/crates/relayer/src/worker/packet.rs +++ b/crates/relayer/src/worker/packet.rs @@ -484,10 +484,8 @@ fn lowest_sequence(events: &[IbcEventWithHeight]) -> Option { .min() } -#[cfg(feature = "telemetry")] use crate::link::RelaySummary; -#[cfg(feature = "telemetry")] fn packet_metrics( path: &Packet, summary: &RelaySummary, @@ -499,7 +497,6 @@ fn packet_metrics( timeout_metrics(path, summary, dst_channel, dst_port); } -#[cfg(feature = "telemetry")] fn receive_packet_metrics( path: &Packet, summary: &RelaySummary, @@ -526,7 +523,6 @@ fn receive_packet_metrics( ); } -#[cfg(feature = "telemetry")] fn acknowledgment_metrics( path: &Packet, summary: &RelaySummary, @@ -553,7 +549,6 @@ fn acknowledgment_metrics( ); } -#[cfg(feature = "telemetry")] fn timeout_metrics( path: &Packet, summary: &RelaySummary,