From 03744437a5ffc36fbb5e973a0ddfd6b91945b212 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 01:48:57 +0000 Subject: federation: votes on the events proposing a checkpoint above its heads Anyone could propose a checkpoint's version again, by an event beside its heads. A node voting by itself, and a party's client, built a vote on every event proposing what it voted on, so every vote was beside the heads, and no version event written on them was taken: the checkpoint could never move the store. And the voters' rule refused it once that event was held for a while, as the heads left it out. They vote on the events proposing it that are above the heads it names (`State::proposing`), which `GET /events/counts` lists as `proposals`; where there are none, `none` says so, the node casts nothing and the client says why. The voters' rule leaves proposals and votes aside, as they lapse with the move. Row 70 is tested (`federation_attack_70`). --- src/api/events.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/api/events.rs') diff --git a/src/api/events.rs b/src/api/events.rs index 496a077..214882a 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -124,7 +124,8 @@ async fn event(State(state): State, Path(id): Path) -> Respons /// `GET /events/counts`: what counts, as the store reads now: the current version, each /// party's keys and nodes, the values at places, the members, and the proposals on the -/// current version, each with the events proposing it, the votes on it, the parties +/// current version, each with the events proposing it a vote may build on (`proposing`: +/// for a checkpoint, those above its heads), the votes on it, the parties /// voting `true` and `false`, whether it passed and whether it is dead, and why a party's /// client backs it not, where it is no version that can be written on the current one /// (`client::backable`). @@ -155,13 +156,21 @@ async fn counts(State(state): State) -> Response { .into_iter() .map(|(hash, ballot)| { let tally = read.tally(current, &hash); + let proposing = read.proposing(¤t.hash, &hash); let none = read .proposal(&hash) - .and_then(|proposed| client::backable(current, proposed).err()); + .and_then(|proposed| client::backable(current, proposed).err()) + .or_else(|| { + (proposing.is_empty() && !ballot.proposals.is_empty()).then(|| { + "no event proposing it is above the heads it names: no version \ + event is written on a vote on it" + .to_owned() + }) + }); ( hash.to_string(), json!({ - "proposals": ids(ballot.proposals), + "proposals": ids(proposing), "votes": ids(ballot.votes), "yes": tally.yes, "no": tally.no, -- cgit v1.3.1