diff options
| author | tv <tv@krebsco.de> | 2026-11-19 03:52:49 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 05:11:45 +0100 |
| commit | 6c6f978189eafa15add0df865f713dc946dfc5cb (patch) | |
| tree | 2b4c556ba96820aa6fd13c22d96cd5fe5af9e091 /src/federation/vote.rs | |
| parent | 54bcc0e4ee8e1e6a29e0e01369c2ba95b27abce8 (diff) | |
federation: merge events, the first revision
What builds on many heads merges them, but only an event a party writes: in a quiet
federation, heads beside each other stay so, and past 64 no event is above them all.
Revision 1 (`merge-events`) adds merge events: `{"merge": true}`, signed with a node's
own key, the `key` its Ed25519 key, for the party whose node list names it. One counts for
nothing, and only gathers what it builds on into the history of what builds on it. Under
the base revision, signed by a node its party doesn't list, or by a party's key, it is
refused; the model alike. Generated federations begin at either revision, and their nodes
merge.
A node voting by itself backs no version changing the revision, on any version neither:
its party's operators vote on that one, once their nodes run a continuum that knows it.
`federation.md` lists the revisions, says what a merge event is, and row 71 is tested
(`federation_attack_71`).
Diffstat (limited to 'src/federation/vote.rs')
| -rw-r--r-- | src/federation/vote.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/federation/vote.rs b/src/federation/vote.rs index 2e5ce15..c274849 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -5,7 +5,8 @@ //! * **Following**: it votes `true` on a proposal on the current version where a party it //! follows voted `true`, never `false`; by default only on a version that only moves to a //! checkpoint (`Version::only_moves_on`), and then only where no proposal that changes -//! more holds it back (`holds_back`), as such a version lapses it. +//! more holds it back (`holds_back`), as such a version lapses it; never on one changing +//! the revision. //! * **Proposing a checkpoint**: once so many events are held beyond its checkpoint, so //! many versions were written since, or so long after it moved there by its own clock, it //! proposes a version that only moves to a checkpoint, at the heads of what it held for a @@ -268,6 +269,15 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act if !own_one && !rules.follow_any && !moves_on { continue; } + // A revision its operators move to by hand: its party's nodes run a continuum + // that knows it first. + let revised = proposed + .version + .as_ref() + .is_some_and(|version| version.revision != current.revision); + if !own_one && revised { + continue; + } // A checkpoint lapses what else is proposed: the party it follows may not end so // a proposal that changes more. let lapses = all.iter().any(|other| { @@ -622,6 +632,31 @@ mod tests { )); } + /// A party the node follows backs a version moving to a later revision: a node + /// following on any version backs it not, as its operators move to a revision by hand. + #[test] + fn a_follower_backs_no_change_of_the_revision() { + let (tv, _, _, first, mut store) = three(); + let root = store.id(); + let mut revised = first.after(first.hash()); + revised.revision = crate::federation::revision::Feature::MergeEvents.revision(); + let proposal = taken(&mut store, tv.propose(&[root], &revised.json())); + taken( + &mut store, + tv.vote(&[proposal], first.hash(), revised.hash(), true), + ); + let any = Rules { + follow: vec!["tv".to_owned()], + follow_any: true, + ..Rules::default() + }; + let long = |_: &Id| Some(Duration::from_secs(3600)); + let record = record(&store, "makefu"); + assert!(decide(&seen(&store, &long), &any, &record).is_empty()); + // By hand, it does. + assert!(by_hand(&seen(&store, &long), &any, &record, revised.hash(), true).is_ok()); + } + /// A party the node follows backs a checkpoint while a proposal that changes more, /// which another party backs, can still pass: the node backs it not, as it would lapse /// that one; while nobody but its proposer backs that one, it does. |
