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 | |
| 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.
| -rw-r--r-- | CHANGELOG.md | 7 | ||||
| -rw-r--r-- | docs/example.toml | 1 | ||||
| -rw-r--r-- | docs/federation.md | 8 | ||||
| -rw-r--r-- | docs/guides/federation/checkpoints.md | 33 | ||||
| -rw-r--r-- | docs/guides/federation/voting-by-itself.md | 9 | ||||
| -rw-r--r-- | src/config/file.rs | 12 | ||||
| -rw-r--r-- | src/config/mod.rs | 59 | ||||
| -rw-r--r-- | src/federation/vote.rs | 137 | ||||
| -rw-r--r-- | src/lib.rs | 1 | ||||
| -rw-r--r-- | src/simtest/holding.rs | 25 |
10 files changed, 114 insertions, 178 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b82eff..0a26c42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ it from the release before ([`docs/operations.md`](docs/operations.md), ## Unreleased +* `--store-nay-beside` is gone: a node votes `false` by no rule. A party it follows could + count on that `false`, and voting twice have its followers pass two checkpoints, in a + federation of any size. A node given the option says so and stops: remove it. Where two + checkpoints stay proposed, their parties end one by hand + ([`docs/guides/federation/checkpoints.md`](docs/guides/federation/checkpoints.md), + [Two proposed at once](docs/guides/federation/checkpoints.md#two-proposed-at-once)). + * A node merges heads from before the version naming the revision with merge events: a new event builds on a head holding the current version too. On the earliest heads alone, its merge event was written under the version before and refused, so the diff --git a/docs/example.toml b/docs/example.toml index cdf942a..6423f95 100644 --- a/docs/example.toml +++ b/docs/example.toml @@ -167,7 +167,6 @@ htpasswd = "/etc/continuum/htpasswd" # store-vote-record = "/var/lib/continuum/party-record.json" # store-follow = ["lass"] # store-follow-any = false -# store-nay-beside = false # store-propose-events = 10000 # store-propose-every = "7d" # store-propose-versions = 1 diff --git a/docs/federation.md b/docs/federation.md index 79921d6..4aefffc 100644 --- a/docs/federation.md +++ b/docs/federation.md @@ -610,8 +610,10 @@ each voting by itself can vote twice; none for a proposal that is no version; an rule for checkpoints, none for a version that changes more than its number, what it changes and its checkpoint, which it checks against the current one, nor for one whose heads leave out what it held for a while ([Checkpoints](#checkpoints)). Where two -checkpoints are proposed at once, the votes split, as any do; a rule may vote `false` on -the one it doesn't back, so that one dies and its backers are free. It backs, and +checkpoints are proposed at once, the votes split, as any do: one two thirds back passes, +and the other lapses with the move; where neither does, their parties end one by hand. A +node votes `false` by no rule, as a party it follows could count on that `false`, and +voting twice have its followers pass two checkpoints. It backs, and proposes, a checkpoint only once its store held its checkpoint, or ran, for a while, by its own clock: so the parties it follows move the store at most once that long, and a node just started backs none. What it held when it started, it takes as held for a @@ -821,7 +823,7 @@ yet*: what would answer it better, which isn't built. | 56 | Two versions changing one, naming different checkpoints | As 12: each node keeps the one it took, and moves to its checkpoint | unit | | 57 | A key added back, or a place given back, after a checkpoint | Brings back nothing signed before the checkpoint that counted no more there | unit | | 58 | A party a node follows backs, or votes `false` on, a version that changes more than its checkpoint | By default the node follows neither; one following on any version backs the one, as its operator chose, and copies no `false` | unit | -| 59 | Two checkpoints proposed at once, by nodes voting by themselves | The votes split; nays from the nodes backing one make the other dead, and its backers are free | sim | +| 59 | Two checkpoints proposed at once, by nodes voting by themselves | The votes split: one two thirds back passes, and the other lapses with the move. Where neither does, each party's `true` stays on its own until nays by hand from more than a third end one; a node votes `false` by no rule, which a party it follows could count on | sim | | 60 | Two nodes of one party, each voting by itself | They can vote twice, answered as any party voting twice: a party has one node vote by itself | — | | 61 | A key a version names, kept on a node that votes by itself, stolen with it | As 23: it counts while that version is current | unit | | 62 | A party's event spelled anew by another: its `sig` or `key` encoded otherwise, its signature's S not canonical (of ECDSA, the order less `s`, or `r` or `s` with zeros more in front), its blob naming another key | None: `key` and `sig` read back to themselves, the signature is checked strictly (of ECDSA, `s` low and `r` and `s` each its shortest), and the blob's key is `key` | unit | diff --git a/docs/guides/federation/checkpoints.md b/docs/guides/federation/checkpoints.md index f6340b0..072fc80 100644 --- a/docs/guides/federation/checkpoints.md +++ b/docs/guides/federation/checkpoints.md @@ -69,9 +69,36 @@ again. [Its rules](voting-by-itself.md#its-rules)). * `--store-back-after` (ten minutes unless set) has it back none before its store held its checkpoint, or ran, that long. -* `--store-nay-beside` has it vote `false` on every other version only moving to a - checkpoint, where it backs one that can still pass: of two checkpoints proposed at once, - the other dies, and its backers are free. + +## Two proposed at once + +Nodes voting by themselves each propose a random wait after a checkpoint is due, so that +the first proposal reaches the others before they make one of their own. Two can still +come at once: in a cut, or where a party proposes one beside another on purpose. Each +party's one `true` is then on the one its node proposed, or follows. + +Where two thirds back one of them, it passes, every node moves there, and the other +lapses with the move: nothing to do. Where neither gets two thirds, both stay proposed +and their backers stay bound, as a `true` holds its party until its proposal is dead, and +no node votes `false` by a rule: a `false` cast so is one a party it follows could count +on, to pass two checkpoints voting twice. Then the parties end one by hand: + +1. See both, and who backs which: `continuum-party proposals`, or `status`. +2. Agree which one to end. Either moves the store to heads its backers held; `beside` of + each in `GET /events/counts` says what moving there refuses. +3. More than a third of the parties vote `false` on it, none of them a party that backs it, + as none votes `true` and `false` on one proposal: + + ```sh + continuum-party vote 8d02… no # by its client + continuum-party vote 8d02… no --through # a party whose node votes for it + ``` + +4. It is dead. Its backers are free: their nodes back the other by themselves where they + follow one of its backers, and a party votes `true` on it by hand otherwise. + +A party that backed one may vote `false` on the other, so the backers of one, where they +are more than a third of the parties, end the other by themselves. ## After a move diff --git a/docs/guides/federation/voting-by-itself.md b/docs/guides/federation/voting-by-itself.md index 175081c..a94a084 100644 --- a/docs/guides/federation/voting-by-itself.md +++ b/docs/guides/federation/voting-by-itself.md @@ -10,7 +10,7 @@ proposal. The rules are the design's ([`federation.md`](../../federation.md), ```sh continuum --store-id 6d1e… --store-party tv … \ --store-vote-key tv.key --store-vote-record tv.record \ - --store-follow lass,makefu --store-nay-beside --store-propose-events 1000 + --store-follow lass,makefu --store-propose-events 1000 ``` * `--store-vote-key`: a key the party's version names, an OpenSSH private key file @@ -70,9 +70,10 @@ or `POST /admin/events/vote` with `{"proposal": "8d02…", "yes": true}`. close vote, one key voting twice can pass a rival version at a history from before it, any time later, which nodes lagging behind or joining from the root may take; a checkpoint above that version ends that. -* **`false` beside** (`--store-nay-beside`): where it backs a proposal that can still - pass, it votes `false` on every other version only moving to a checkpoint, so that of - two checkpoints proposed at once the other dies, and its backers are free. +* **No `false` by a rule**: where two checkpoints are proposed at once and neither gets two + thirds, their parties end one by hand ([`checkpoints.md`](checkpoints.md), + [Two proposed at once](checkpoints.md#two-proposed-at-once)). A `false` a node cast by + a rule is one a party it follows could count on, to pass two checkpoints voting twice. ## What it keeps to 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. diff --git a/src/federation/vote.rs b/src/federation/vote.rs index baf8dd0..0bad500 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -55,8 +55,6 @@ pub(crate) struct Rules { /// How long it holds an event before it holds it for a while: the voters' rule, and how /// long a new proposal holds back a checkpoint. pub(crate) held_for: Duration, - /// Voting `false` on a checkpoint proposed beside one it backs. - pub(crate) nay_beside: bool, /// How long its store holds its checkpoint, or runs, before it backs or proposes a /// later one. pub(crate) back_after: Duration, @@ -382,9 +380,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act }); } } - if rules.nay_beside { - acts.extend(beside(¤t, &all, &acts, record, &nays)); - } if !backed && let Some(version) = checkpoint(seen, rules, ¤t, &all) { let hash = Id::of(&version.bytes()); if record @@ -397,64 +392,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act acts } -/// The votes `false` a node casts beside what it backs: where its party backs a proposal on -/// `current` that can still pass, by its `record` or by `acts`, on every other proposal -/// that only moves to a checkpoint and can still pass, but where it votes already. -fn beside( - current: &Version, - all: &[Proposed], - acts: &[Act], - record: &Record, - nays: &[Vec<u8>], -) -> Vec<Act> { - let voting: BTreeSet<Id> = acts - .iter() - .filter_map(|act| match act { - Act::Vote { proposal, .. } => Some(*proposal), - Act::Propose(_) => None, - }) - .collect(); - let backs: BTreeSet<Id> = record - .backs(¤t.hash) - .into_iter() - .chain(acts.iter().filter_map(|act| match act { - Act::Vote { - proposal, - yes: true, - .. - } => Some(*proposal), - _ => None, - })) - .collect(); - let backing = all - .iter() - .any(|proposed| backs.contains(&proposed.hash) && alive(current, proposed)); - if !backing { - return Vec::new(); - } - all.iter() - .filter(|proposed| { - !backs.contains(&proposed.hash) - && !voting.contains(&proposed.hash) - && alive(current, proposed) - && proposed - .version - .as_ref() - .is_some_and(|version| version.only_moves_on(current)) - }) - .filter(|proposed| { - record - .may_vote(current, proposed.hash, &proposed.json, false, nays) - .is_ok() - }) - .map(|proposed| Act::Vote { - proposal: proposed.hash, - yes: false, - nays: Vec::new(), - }) - .collect() -} - /// A vote by hand, cast through the node that votes for its party, which keeps its /// party's one record: `yes` on the proposal of hash `proposal` on the current version, by /// the record, and with a `true` by the voters' rule; or why not. @@ -1180,78 +1117,4 @@ mod tests { let record = super::tests::record(&apart, "tv"); assert!(decide(&seen(&apart, &held), &rules, &record).is_empty()); } - - /// Two checkpoints proposed at once: a node backing one votes `false` on the other by - /// its rule, and on nothing else; without the rule, on nothing. - #[test] - fn a_node_votes_false_on_a_checkpoint_beside_the_one_it_backs() { - let (tv, lass, _, first, mut store) = three(); - let root = store.id(); - let on = first.hash(); - let here = taken( - &mut store, - tv.write(&[root], "home/tv/a", harness::str("1")), - ); - let there = taken( - &mut store, - lass.write(&[root], "home/lass/b", harness::str("1")), - ); - let (mut one, mut two) = (first.after(on), first.after(on)); - one.checkpoint = Some(vec![here]); - two.checkpoint = Some(vec![there]); - let mut other = first.after(on); - other.rules.push(("names/x".to_owned(), harness::str("tv"))); - let proposing = tv.propose(&[here], &one.json()); - let mut record = record(&store, "tv"); - record.signed(&proposing); - let proposal = taken(&mut store, proposing); - let by_lass = [ - taken(&mut store, lass.propose(&[there], &two.json())), - taken(&mut store, lass.propose(&[root], &other.json())), - ]; - // lass's, held since its proposals came, after tv proposed. - let long = |id: &Id| { - Some(if *id == there || by_lass.contains(id) { - Duration::from_secs(60) - } else { - Duration::from_secs(3600) - }) - }; - let rules = Rules { - nay_beside: true, - ..Rules::default() - }; - // Backing its own, this round: `false` on the other checkpoint, not on the version - // that changes more. - let acts = decide(&seen(&store, &long), &rules, &record); - assert_eq!(acts.len(), 2, "{acts:?}"); - assert!(acts.contains(&Act::Vote { - proposal: one.hash(), - yes: true, - nays: Vec::new() - })); - assert!(acts.contains(&Act::Vote { - proposal: two.hash(), - yes: false, - nays: Vec::new() - })); - let quiet = Rules::default(); - assert_eq!(decide(&seen(&store, &long), &quiet, &record).len(), 1); - // Its `true` recorded and taken: `false` on the other, once. - let yes = tv.vote(&[proposal], on, one.hash(), true); - record.cast(store.state().current(), &yes, Vec::new()); - taken(&mut store, yes); - let acts = decide(&seen(&store, &long), &rules, &record); - assert_eq!( - acts, - vec![Act::Vote { - proposal: two.hash(), - yes: false, - nays: Vec::new() - }] - ); - let no = tv.vote(&[proposal], on, two.hash(), false); - record.cast(store.state().current(), &no, Vec::new()); - assert!(decide(&seen(&store, &long), &rules, &record).is_empty()); - } } @@ -67,7 +67,6 @@ fn voter(args: &config::Settings) -> Result<Option<federation::held::Voter>> { rules: federation::vote::Rules { follow: args.store_follow.clone(), follow_any: args.store_follow_any, - nay_beside: args.store_nay_beside, propose_events: args.store_propose_events, propose_every: args.store_propose_every, propose_versions: (args.store_propose_versions > 0) diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs index 12dac23..16158b1 100644 --- a/src/simtest/holding.rs +++ b/src/simtest/holding.rs @@ -774,10 +774,9 @@ async fn store_attack_10() { /// Two checkpoints proposed at once, by nodes voting by themselves: a for tv and b for /// lass, apart, each propose one once their stores took six events, and back it; c votes -/// for makefu, following tv; each votes `false` on a checkpoint beside the one it backs. -/// a and b, together, vote `false` on each other's: the votes split. With c, tv's passes -/// and every node moves there; lass's is dead by the nays of tv and makefu, which their -/// records hold. +/// for makefu, following tv. a and b, together, hold both, each party's `true` on its own: +/// the votes split, and no node votes `false` by a rule. With c, tv's passes by two +/// thirds and every node moves there; lass's lapses with the move. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn federation_attack_59() { let sim = Sim::with_identity(89); @@ -786,12 +785,10 @@ async fn federation_attack_59() { let dir = crate::files::scratch_dir("sim-attack-59"); let proposing = Rules { propose_events: Some(6), - nay_beside: true, ..Rules::default() }; let following = Rules { follow: vec!["tv".to_owned()], - nay_beside: true, held_for: Duration::from_secs(3600), ..Rules::default() }; @@ -831,20 +828,18 @@ async fn federation_attack_59() { sim.net.bring_up("a"); sim.net.bring_up("b"); sim.wait_until( - "a and b vote `false` on each other's", + "a and b hold both, each party's `true` on its own", LONG, move || async move { all[..2].iter().all(|node| { - ballot(node, "tv") - .is_some_and(|(_, yes, no)| yes == set(&["tv"]) && no == set(&["lass"])) + ballot(node, "tv").is_some_and(|(_, yes, no)| yes == set(&["tv"]) && no.is_empty()) && ballot(node, "lass") - .is_some_and(|(_, yes, no)| yes == set(&["lass"]) && no == set(&["tv"])) + .is_some_and(|(_, yes, no)| yes == set(&["lass"]) && no.is_empty()) }) }, ) .await; let (passing, _, _) = ballot(&nodes[0], "tv").expect("tv's"); - let (other, _, _) = ballot(&nodes[0], "lass").expect("lass's"); sim.net.bring_up("c"); sim.wait_until( "every node moves to tv's checkpoint", @@ -852,18 +847,18 @@ async fn federation_attack_59() { move || async move { all.iter().all(|node| current(node) == Some(passing)) }, ) .await; - for party in ["tv", "makefu"] { + for party in ["tv", "lass", "makefu"] { let record = Record::load(&dir.join(format!("{party}.json"))).expect("its record"); let nay = record.votes.iter().any(|vote| { matches!( Event::read_taken(vote.as_bytes()), Some(Event::Signed(Signed { - does: Does::Vote { proposal, yes: false, .. }, + does: Does::Vote { yes: false, .. }, .. - })) if proposal == other + })) ) }); - assert!(nay, "{party} voted no `false` on lass's checkpoint"); + assert!(!nay, "{party}'s node voted `false`, by no rule of its"); } } |
