iroha
iroha copied to clipboard
[suggestion] disallow conditional compilation of structures
Feature request
This structure in telemetry/src/config.rs
:
pub struct Configuration {
/// The node's name to be seen on the telemetry
#[config(serde_as_str)]
pub name: Option<String>,
/// The url of the telemetry, e.g., ws://127.0.0.1:8001/submit
#[config(serde_as_str)]
pub url: Option<Url>,
/// The minimum period of time in seconds to wait before reconnecting
#[serde(default = "default_min_retry_period")]
pub min_retry_period: u64,
/// The maximum exponent of 2 that is used for increasing delay between reconnections
#[serde(default = "default_max_retry_delay_exponent")]
pub max_retry_delay_exponent: u8,
/// The filepath that to write dev-telemetry to
#[cfg(feature = "dev-telemetry")]
#[config(serde_as_str)]
pub file: Option<PathBuf>,
}
contains feature flag dev-telemetry
on one of it's fields. Are we going to allow this?
related to #2111
Motivation
Conditionally compiled structs are a problem for users of Iroha. This structure isn't encoded/signed, so it may not be such a big problem.
Who can help?
No response
Sadly we can't check for this in IntoSchema
because cfg
directives are expanded before proc macros. What we can do is write a custom lint, and use clippy
.
https://blog.trailofbits.com/2021/11/09/write-rust-lints-without-forking-clippy/
We can implement a lint that checks for #[derive(IntoSchema)
and lints on #[cfg(feature)` inside fields.
Closing it as we decided that dynamic lints would introduce another level of complexity into an already unwieldy workflow.