diff options
| author | tv <tv@krebsco.de> | 2026-11-19 01:48:57 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 03:19:12 +0100 |
| commit | e0075264e9efdd4c8a32290c0d5643e7f48bfb14 (patch) | |
| tree | 646f0ab7fb2dd61e93bc1b8cce6f6a13a5ff0b8b /src/federation/version.rs | |
| parent | 31d41eb1c902c907a5c6e5608510f96c4b1bc864 (diff) | |
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`).
Diffstat (limited to 'src/federation/version.rs')
| -rw-r--r-- | src/federation/version.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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<Party> = (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"); |
