aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/event.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 03:52:49 +0000
committertv <tv@krebsco.de>2026-11-19 05:11:45 +0100
commit6c6f978189eafa15add0df865f713dc946dfc5cb (patch)
tree2b4c556ba96820aa6fd13c22d96cd5fe5af9e091 /src/federation/event.rs
parent54bcc0e4ee8e1e6a29e0e01369c2ba95b27abce8 (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/event.rs')
-rw-r--r--src/federation/event.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/federation/event.rs b/src/federation/event.rs
index 864bedb..ec4493f 100644
--- a/src/federation/event.rs
+++ b/src/federation/event.rs
@@ -81,6 +81,11 @@ pub(crate) fn vote(on: Id, proposal: Id, yes: bool) -> (&'static str, Json) {
("vote", does.expect("names once each"))
}
+/// What a node writing a merge event does: nothing but build on its dependencies.
+pub(crate) fn merge() -> (&'static str, Json) {
+ ("merge", Json::Bool(true))
+}
+
/// A version event, which nobody signs: its bytes.
pub(crate) fn version_event(deps: &[Id], version: Id) -> Vec<u8> {
Json::object(vec![
@@ -135,6 +140,9 @@ pub(crate) enum Does {
Proposal { hash: Id, version: Json },
/// A vote on a proposal (`proposal`) on a version (`on`).
Vote { on: Id, proposal: Id, yes: bool },
+ /// Nothing but building on its dependencies, signed by a node its party lists, with
+ /// its node key (`revision::Feature::MergeEvents`).
+ Merge,
}
impl Event {
@@ -166,7 +174,7 @@ impl Event {
let version = Id::from_hex(json.get("version")?.as_str()?)?;
return Some(Event::Version { deps, version });
}
- let does = ["write", "keys", "nodes", "proposal", "vote"]
+ let does = ["write", "keys", "nodes", "proposal", "vote", "merge"]
.into_iter()
.find(|name| names.contains(name))?;
let mut expected = vec!["deps", "key", "party", "sig", does];
@@ -213,6 +221,12 @@ impl Event {
hash: Id::of(&what.bytes()),
version: what.clone(),
},
+ "merge" => {
+ if what.as_bool() != Some(true) {
+ return None;
+ }
+ Does::Merge
+ }
_ => {
if what.names() != ["on", "proposal", "yes"] {
return None;