From e0075264e9efdd4c8a32290c0d5643e7f48bfb14 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 01:48:57 +0000 Subject: federation: a checkpoint of 64 heads at most, a version of 96 parties No event is above more heads than it may name dependencies (64): a version naming more for its checkpoint is never written. A node voting by itself proposed one at whatever heads it held for a while, however many; it now proposes none past 64, as what is written merges them, and a party's client backs none such (`client::backable`). A version event names the votes passing a proposal, two thirds of its version's parties: past 96 parties, more than an event may name. A version names at most 96 now (`version::PARTIES`). --- src/federation/version.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/federation/version.rs') diff --git a/src/federation/version.rs b/src/federation/version.rs index d714a47..378e122 100644 --- a/src/federation/version.rs +++ b/src/federation/version.rs @@ -16,6 +16,11 @@ pub(crate) const KEYS: usize = 16; /// Nodes a node list may name. pub(crate) const NODES: usize = 64; +/// Parties a version may name: a version event names the votes passing a proposal, two +/// thirds of its version's parties, and an event names no more than 64 events +/// (`event::DEPENDENCIES`). +pub(crate) const PARTIES: usize = 96; + /// Segments a path may have, and bytes a segment. pub(crate) const SEGMENTS: usize = 32; pub(crate) const SEGMENT_BYTES: usize = 255; @@ -210,6 +215,12 @@ impl Version { if keys.names().is_empty() { return Err("no party".to_owned()); } + if keys.names().len() > PARTIES { + return Err(format!( + "{} parties, more than {PARTIES}", + keys.names().len() + )); + } let mut parties = BTreeMap::new(); let mut every_key = BTreeSet::new(); for name in keys.names() { @@ -534,6 +545,20 @@ mod tests { ); } + /// A version names no more parties than a version event may name the votes of two + /// thirds of. + #[test] + fn a_version_names_at_most_96_parties() { + use super::super::harness::{Party, Spec}; + let parties: Vec = (1..=PARTIES as u8 + 1) + .map(|n| Party::new(&format!("p{n}"), n)) + .collect(); + let named: Vec<&Party> = parties.iter().collect(); + assert!(Version::read(&Spec::first(&named[1..], &[]).json()).is_ok()); + let why = Version::read(&Spec::first(&named, &[]).json()).unwrap_err(); + assert_eq!(why, "97 parties, more than 96"); + } + #[test] fn a_version_changes_another_by_its_number_hash_and_sinces() { let first = Version::read(&first()).expect("a version"); -- cgit v1.3.1