diff options
| author | tv <tv@krebsco.de> | 2026-11-25 15:20:37 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-25 15:20:37 +0000 |
| commit | 46fc2ab070b5f8d3cd6c8bd0d6bd15c624a061e5 (patch) | |
| tree | 880459c95224d1882ca847e0b607c8c78ef151b4 /src/config | |
| parent | 1656f73b41a3528048c33774457b0d68ed430934 (diff) | |
federation: a node votes false by no rule: --store-nay-beside is gone
A node following a party copies no false, so a followed key voting twice
finds nobody to end the first of its two checkpoints. With
--store-nay-beside its followers cast that false by rule: it showed each
checkpoint to some of them, voted false on one itself, had them end it
and move to the other, and passed the first with the rest. Two
checkpoint versions on one, by one key, in a federation of any size.
The rule was there for two checkpoints proposed at once, which a node's
wait before it proposes makes rare. Where they stay proposed, neither
with two thirds, their parties end one by hand: the checkpoints guide
says how (Two proposed at once). Row 59 says so, and its simulation has
the one two thirds back pass, with no false cast.
An option that is gone is named so, with what to do (config::GONE), on
the command line and in a configuration file, where "unknown option"
would leave an operator guessing.
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/file.rs | 12 | ||||
| -rw-r--r-- | src/config/mod.rs | 59 |
2 files changed, 57 insertions, 14 deletions
diff --git a/src/config/file.rs b/src/config/file.rs index ee71133..5984c10 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -79,6 +79,12 @@ fn load_inner( for name in unsets { if spec_in(options, &name).is_none() { + if let Some(why) = super::gone(&name) { + bail!( + "option {name:?} in unset, in {}, is gone: {why}", + canonical.display() + ); + } bail!( "unknown option {name:?} in unset, in {}", canonical.display() @@ -91,8 +97,10 @@ fn load_inner( let mut own = Vec::new(); flatten(&root, "", &dir, &mut own).with_context(|| format!("in {}", canonical.display()))?; for (name, value) in own { - let spec = spec_in(options, &name) - .ok_or_else(|| anyhow!("unknown option {name:?} in {}", canonical.display()))?; + let spec = spec_in(options, &name).ok_or_else(|| match super::gone(&name) { + Some(why) => anyhow!("option {name:?} in {} is gone: {why}", canonical.display()), + None => anyhow!("unknown option {name:?} in {}", canonical.display()), + })?; let (value, sources) = super::resolve_file_value(spec, value, &dir) .with_context(|| format!("option {name} in {}", canonical.display()))?; let entry = Entry { diff --git a/src/config/mod.rs b/src/config/mod.rs index f9663c1..cfc2c76 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -290,14 +290,6 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ ), #[cfg(feature = "federation")] option( - "store-nay-beside", - Kind::Flag, - "BOOL", - Some("false"), - "With store-vote-key: where it backs a proposal that can still pass, vote `false` on every other one on the current version that only moves to a checkpoint, so that, of two checkpoints proposed at once, the other dies and its backers are free.", - ), - #[cfg(feature = "federation")] - option( "store-propose-events", Kind::Integer, "COUNT", @@ -746,6 +738,39 @@ pub(super) fn spec_in(options: &'static [OptionSpec], name: &str) -> Option<&'st options.iter().find(|spec| spec.name == name) } +/// Options of earlier releases that are gone, each with what to do instead: a node given +/// one, in a configuration file or on its command line, says so and stops, where "unknown +/// option" would leave its operator guessing. +const GONE: &[(&str, &str)] = &[( + "store-nay-beside", + "a node votes `false` by no rule any more, as a party it follows could count on that \ + `false` to pass two checkpoints, voting twice: remove the option; where two checkpoints \ + stay proposed, their parties end one by hand (docs/guides/federation/checkpoints.md, \ + Two proposed at once)", +)]; + +/// Why `name` is no option any more, where it was one (`GONE`). +pub(super) fn gone(name: &str) -> Option<&'static str> { + GONE.iter() + .find(|(gone, _)| *gone == name) + .map(|(_, why)| *why) +} + +/// Stops on an argument naming an option that is gone, saying why, before the command +/// line is read: clap would call it unexpected. +fn refuse_gone(arguments: impl IntoIterator<Item = String>) -> Result<()> { + for argument in arguments { + let Some(name) = argument.strip_prefix("--") else { + continue; + }; + let name = name.split('=').next().unwrap_or(name); + if let Some(why) = gone(name) { + bail!("--{name} is gone: {why}"); + } + } + Ok(()) +} + /// The options of a party's client (`continuum-party`), set as the node's are: on the /// command line, or in configuration files of the same format (`with_options`, /// `merged`). @@ -849,9 +874,6 @@ pub(crate) struct Settings { #[serde(default)] pub(crate) store_follow_any: bool, #[cfg(feature = "federation")] - #[serde(default)] - pub(crate) store_nay_beside: bool, - #[cfg(feature = "federation")] pub(crate) store_propose_events: Option<usize>, #[cfg(feature = "federation")] #[serde( @@ -1401,7 +1423,6 @@ impl Settings { ("store-vote-record", self.store_vote_record.is_some()), ("store-follow", !self.store_follow.is_empty()), ("store-follow-any", self.store_follow_any), - ("store-nay-beside", self.store_nay_beside), ("store-propose-events", self.store_propose_events.is_some()), ("store-propose-every", self.store_propose_every.is_some()), ]; @@ -2173,6 +2194,7 @@ impl Loaded { /// Reads the command line and the configuration files it names. Exits on `--help`, /// `--version` and command-line syntax errors, like any command. pub(crate) fn load() -> Result<Loaded> { + refuse_gone(std::env::args().skip(1))?; let matches = command().get_matches(); let print_only = matches.get_flag(PRINT_CONFIG); let node_id = matches.subcommand_matches(NODE_ID).map(|sub| { @@ -2456,6 +2478,19 @@ mod tests { assert!(with("7h").is_ok()); } + /// An option that is gone is named so, with what to do, on the command line and in a + /// configuration file. + #[test] + fn an_option_that_is_gone_is_said_to_be() { + let why = refuse_gone(["--store-nay-beside".to_owned()]) + .unwrap_err() + .to_string(); + assert!(why.contains("is gone") && why.contains("by hand"), "{why}"); + assert!(refuse_gone(["--store-nay-beside=true".to_owned()]).is_err()); + assert!(refuse_gone(["--store-follow".to_owned(), "tv".to_owned()]).is_ok()); + assert!(gone("store-follow").is_none()); + } + #[test] fn options_and_settings_agree() { // Every option is a Settings field, and every field an option. |
