aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 01:48:57 +0000
committertv <tv@krebsco.de>2026-11-19 03:18:49 +0100
commit03744437a5ffc36fbb5e973a0ddfd6b91945b212 (patch)
tree227eb42b4e7cac546b857cfacb79ab890e8bb137 /src/api
parentf24063e90d02ef76d87401d6e74cf8c9f489ff7d (diff)
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`).
Diffstat (limited to 'src/api')
-rw-r--r--src/api/events.rs15
1 files changed, 12 insertions, 3 deletions
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<AppState>, Path(id): Path<String>) -> 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<AppState>) -> Response {
.into_iter()
.map(|(hash, ballot)| {
let tally = read.tally(current, &hash);
+ let proposing = read.proposing(&current.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,