diff --git a/examples/basic.rs b/examples/basic.rs index 0bf67ba7..0e634a13 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -107,7 +107,12 @@ impl Peer { fn from_genesis(our_id: PeerId, genesis_group: &BTreeSet) -> Self { Self { id: our_id.clone(), - parsec: Parsec::from_genesis(our_id, genesis_group, ConsensusMode::Supermajority), + parsec: Parsec::from_genesis( + our_id, + genesis_group, + vec![], + ConsensusMode::Supermajority, + ), observations: vec![], blocks: vec![], } diff --git a/input_graphs/benches/minimal.dot b/input_graphs/benches/minimal.dot index 0a44ddb3..f91ae5a0 100644 --- a/input_graphs/benches/minimal.dot +++ b/input_graphs/benches/minimal.dot @@ -914,7 +914,7 @@ digraph GossipGraph { /// ===== meta-elections ===== /// consensus_history: -/// a137c1b54c5895b13a1e204869f650636920286bd5b903e0576a9a15a2f58c2c +/// d98f8abc4ba966aadc391bb857a6879a122602074766f19fadf22ce59dd0410e /// c93ff2cda7e9dd6a49b12c4fccdbaa0fe1b25b1e92421f288b06bfe53122be0f /// interesting_events: { diff --git a/input_graphs/dev_utils_record_tests_smoke_other_peer_names/annie.dot b/input_graphs/dev_utils_record_tests_smoke_other_peer_names/annie.dot index 542d36c7..338af5c1 100644 --- a/input_graphs/dev_utils_record_tests_smoke_other_peer_names/annie.dot +++ b/input_graphs/dev_utils_record_tests_smoke_other_peer_names/annie.dot @@ -5,6 +5,7 @@ /// Carol: PeerState(VOTE|SEND|RECV) /// Claire: PeerState(VOTE|SEND|RECV) /// } +/// consensus_mode: Supermajority digraph GossipGraph { splines=false rankdir=BT @@ -1163,7 +1164,7 @@ digraph GossipGraph { /// ===== meta-elections ===== /// consensus_history: -/// ece3eaf86a7f7396aed2e4bdd0c67cf7b67df5aabbd5eced04924b154d0f3841 +/// 5d1bc22c2cce50873bffc1ba00ecbecce52085dc3bd15e8b43f5167bf72962cd /// interesting_events: { /// Annie -> ["An_19"] @@ -1174,10 +1175,6 @@ digraph GossipGraph { /// all_voters: {Annie, B, Carol, Claire} /// unconsensused_events: {"An_13", "B_9", "Ca_6", "Cl_10"} /// meta_events: { -/// An_13 -> { -/// observees: {} -/// interesting_content: [] -/// } /// An_14 -> { /// observees: {} /// interesting_content: [] @@ -1219,10 +1216,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// An_24 -> { @@ -1230,10 +1227,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// An_25 -> { @@ -1241,10 +1238,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// An_26 -> { @@ -1252,10 +1249,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f f f - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// An_27 -> { @@ -1263,10 +1260,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_28 -> { @@ -1274,11 +1271,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_29 -> { @@ -1286,11 +1283,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_30 -> { @@ -1298,11 +1295,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_31 -> { @@ -1310,11 +1307,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_32 -> { @@ -1322,11 +1319,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// An_33 -> { @@ -1334,11 +1331,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// B_6 -> { @@ -1353,10 +1350,6 @@ digraph GossipGraph { /// observees: {} /// interesting_content: [] /// } -/// B_9 -> { -/// observees: {} -/// interesting_content: [] -/// } /// B_10 -> { /// observees: {} /// interesting_content: [] @@ -1394,10 +1387,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 t - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 t - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// B_19 -> { @@ -1405,10 +1398,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 t - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 t - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// B_20 -> { @@ -1416,10 +1409,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 t - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 t - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// B_21 -> { @@ -1427,10 +1420,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 b f f - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 b f f - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// B_22 -> { @@ -1438,10 +1431,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 b f f - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 b f f - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// B_23 -> { @@ -1449,10 +1442,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 b f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 b f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// B_24 -> { @@ -1460,17 +1453,13 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 b f f - -/// 0/1 f f f f -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 b f f - +/// 0/1 f f f f +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } -/// Ca_6 -> { -/// observees: {} -/// interesting_content: [] -/// } /// Ca_7 -> { /// observees: {} /// interesting_content: [] @@ -1508,10 +1497,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Ca_16 -> { @@ -1519,10 +1508,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Ca_17 -> { @@ -1530,10 +1519,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Ca_18 -> { @@ -1541,10 +1530,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Ca_19 -> { @@ -1552,10 +1541,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Ca_20 -> { @@ -1563,10 +1552,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Ca_21 -> { @@ -1574,10 +1563,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Ca_22 -> { @@ -1585,11 +1574,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Ca_23 -> { @@ -1597,11 +1586,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Ca_24 -> { @@ -1609,21 +1598,17 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f f f - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f f f - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_9 -> { /// observees: {} /// interesting_content: [] /// } -/// Cl_10 -> { -/// observees: {} -/// interesting_content: [] -/// } /// Cl_11 -> { /// observees: {} /// interesting_content: [] @@ -1661,10 +1646,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Cl_20 -> { @@ -1672,10 +1657,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Cl_21 -> { @@ -1683,10 +1668,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Cl_22 -> { @@ -1694,10 +1679,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t - - - -/// Ca: 0/0 t - - - -/// Cl: 0/0 t - - - +/// An: 0/0 f - - - +/// B: 0/0 t - - - +/// Ca: 0/0 t - - - +/// Cl: 0/0 t - - - /// } /// } /// Cl_23 -> { @@ -1705,10 +1690,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_24 -> { @@ -1716,10 +1701,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_25 -> { @@ -1727,10 +1712,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_26 -> { @@ -1738,10 +1723,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_27 -> { @@ -1749,10 +1734,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_28 -> { @@ -1760,10 +1745,10 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f - - - -/// B: 0/0 t t t - -/// Ca: 0/0 t t t - -/// Cl: 0/0 t t t - +/// An: 0/0 f - - - +/// B: 0/0 t t t - +/// Ca: 0/0 t t t - +/// Cl: 0/0 t t t - /// } /// } /// Cl_29 -> { @@ -1771,11 +1756,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_30 -> { @@ -1783,11 +1768,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_31 -> { @@ -1795,11 +1780,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_32 -> { @@ -1807,11 +1792,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_33 -> { @@ -1819,11 +1804,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_34 -> { @@ -1831,11 +1816,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// Cl_35 -> { @@ -1843,11 +1828,11 @@ digraph GossipGraph { /// interesting_content: [] /// meta_votes: { /// stage est bin aux dec -/// An: 0/0 f f f - -/// 0/1 f - - - -/// B: 0/0 t t t t -/// Ca: 0/0 t t t t -/// Cl: 0/0 t t t t +/// An: 0/0 f f f - +/// 0/1 f - - - +/// B: 0/0 t t t t +/// Ca: 0/0 t t t t +/// Cl: 0/0 t t t t /// } /// } /// } diff --git a/input_graphs/functional_tests_unpolled_observations/alice.dot b/input_graphs/functional_tests_unpolled_observations/alice.dot index a5c52525..1cf5edac 100644 --- a/input_graphs/functional_tests_unpolled_observations/alice.dot +++ b/input_graphs/functional_tests_unpolled_observations/alice.dot @@ -827,7 +827,7 @@ digraph GossipGraph { /// ===== meta-elections ===== /// consensus_history: -/// a137c1b54c5895b13a1e204869f650636920286bd5b903e0576a9a15a2f58c2c +/// d98f8abc4ba966aadc391bb857a6879a122602074766f19fadf22ce59dd0410e /// interesting_events: { /// Alice -> ["A_14"] diff --git a/src/dev_utils/dot_parser.rs b/src/dev_utils/dot_parser.rs index a1056755..caae4adc 100644 --- a/src/dev_utils/dot_parser.rs +++ b/src/dev_utils/dot_parser.rs @@ -526,7 +526,10 @@ fn parse_invalid() -> Parser { } fn parse_genesis() -> Parser> { - (seq(b"Genesis(") * parse_peers() - seq(b")")).map(Observation::Genesis) + (seq(b"Genesis(") * parse_peers() - seq(b")")).map(|group| Observation::Genesis { + group, + related_info: vec![], + }) } fn parse_add() -> Parser> { diff --git a/src/dev_utils/network.rs b/src/dev_utils/network.rs index a874a813..696b9176 100644 --- a/src/dev_utils/network.rs +++ b/src/dev_utils/network.rs @@ -425,8 +425,8 @@ impl Network { for block_group in block_groups { for block in block_group { - if let ParsecObservation::Genesis(ref g) = *block.payload() { - valid_voters = g.clone(); + if let ParsecObservation::Genesis { ref group, .. } = *block.payload() { + valid_voters = group.clone(); } self.check_block_signatories(block, &valid_voters)?; @@ -434,7 +434,7 @@ impl Network { for block in block_group { match *block.payload() { - ParsecObservation::Genesis(_) => (), + ParsecObservation::Genesis { .. } => (), ParsecObservation::Add { ref peer_id, .. } => { let _ = valid_voters.insert(peer_id.clone()); } diff --git a/src/dev_utils/peer.rs b/src/dev_utils/peer.rs index 6344f097..d22c7632 100644 --- a/src/dev_utils/peer.rs +++ b/src/dev_utils/peer.rs @@ -248,6 +248,7 @@ impl Peer { Self::new(WrappedParsec::Good(Parsec::from_genesis( id, genesis_group, + vec![], consensus_mode, ))) } diff --git a/src/dev_utils/record.rs b/src/dev_utils/record.rs index 1cef6534..1b646980 100644 --- a/src/dev_utils/record.rs +++ b/src/dev_utils/record.rs @@ -41,8 +41,12 @@ impl Record { } pub fn play(self) -> Parsec { - let mut parsec = - Parsec::from_genesis(self.our_id, &self.genesis_group, self.consensus_mode); + let mut parsec = Parsec::from_genesis( + self.our_id, + &self.genesis_group, + vec![], + self.consensus_mode, + ); for action in self.actions { action.run(&mut parsec) @@ -213,8 +217,8 @@ fn extract_genesis_group<'a>( .and_then(|key| observations.get(key)) .map(|info| &info.observation) .and_then(|observation| { - if let Observation::Genesis(ref genesis_group) = *observation { - Some(genesis_group) + if let Observation::Genesis { ref group, .. } = *observation { + Some(group) } else { None } diff --git a/src/dump_graph.rs b/src/dump_graph.rs index 75c9476b..e83812c8 100644 --- a/src/dump_graph.rs +++ b/src/dump_graph.rs @@ -979,7 +979,7 @@ mod detail { short_peer_ids: &PeerIndexMap, ) -> Self { let value = match observation { - Observation::Genesis(group) => format!( + Observation::Genesis { group, .. } => format!( "Genesis({:?})", group.iter().map(sanitise_peer_id).collect::>() ), diff --git a/src/functional_tests.rs b/src/functional_tests.rs index 8b3d95cc..db1933b0 100644 --- a/src/functional_tests.rs +++ b/src/functional_tests.rs @@ -161,7 +161,13 @@ fn from_genesis() { assert_eq!(*parsec.event_creator_id(&genesis_observation), our_id); match parsec.event_payload(&genesis_observation) { Some(payload) => { - assert_eq!(*payload, Observation::Genesis(peers)); + assert_eq!( + *payload, + Observation::Genesis { + group: peers, + related_info: vec![] + } + ); } None => panic!("Expected observation, but event carried no vote"), } @@ -341,6 +347,7 @@ fn unpolled_observations() { peer_id: PeerId::new("Eric"), related_info: vec![], }; + assert_eq!(alice.our_unpolled_observations().count(), 1); assert_eq!(*unwrap!(alice.our_unpolled_observations().next()), add_eric); @@ -389,7 +396,7 @@ fn our_unpolled_observations_with_consensus_mode_single() { let mut alice = Record::from(parse_test_dot_file("alice.dot")).play(); let block = unwrap!(alice.poll()); - if let Observation::Genesis(_) = block.payload() { + if let Observation::Genesis { .. } = block.payload() { } else { panic!(); } @@ -587,9 +594,13 @@ mod handle_malice { )); let d_1_index = dave_contents.add_event(d_1); - let d_2 = unwrap!( - dave_contents.new_event_from_observation(d_1_index, Observation::Genesis(genesis),) - ); + let d_2 = unwrap!(dave_contents.new_event_from_observation( + d_1_index, + Observation::Genesis { + group: genesis, + related_info: vec![] + } + )); let d_2_hash = *d_2.hash(); let _ = dave_contents.add_event(d_2); @@ -642,9 +653,13 @@ mod handle_malice { let e_0 = Event::new_initial(eric_contents.event_context()); let e_0_index = eric_contents.add_event(e_0); - let e_1 = unwrap!( - eric_contents.new_event_from_observation(e_0_index, Observation::Genesis(genesis),) - ); + let e_1 = unwrap!(eric_contents.new_event_from_observation( + e_0_index, + Observation::Genesis { + group: genesis, + related_info: vec![] + }, + )); let e_1_hash = *e_1.hash(); let _ = eric_contents.add_event(e_1); @@ -703,7 +718,7 @@ mod handle_malice { // Pop Alice's last event, which is her genesis vote. let (_, genesis_event) = unwrap!(alice.remove_last_event()); match unwrap!(alice.event_payload(&genesis_event)) { - Observation::Genesis(_) => (), + Observation::Genesis { .. } => (), _ => panic!("This should be Alice's genesis vote."), } @@ -735,7 +750,10 @@ mod handle_malice { bob.our_pub_id().clone(), PeerId::new("Derp") ]; - unwrap!(alice.vote_for(Observation::Genesis(invalid_genesis))); + unwrap!(alice.vote_for(Observation::Genesis { + group: invalid_genesis, + related_info: vec![] + })); // Create request from Alice to Carol. let request = unwrap!(alice.create_gossip(carol.our_pub_id())); diff --git a/src/observation.rs b/src/observation.rs index 1a054aca..9f7e0395 100644 --- a/src/observation.rs +++ b/src/observation.rs @@ -27,7 +27,12 @@ use std::{ #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub enum Observation { /// Genesis group - Genesis(BTreeSet

), + Genesis { + /// Members of the genesis group. + group: BTreeSet

, + /// Extra arbitrary information for use by the client. + related_info: Vec, + }, /// Vote to add the indicated peer to the network. Add { /// Public id of the peer to be added @@ -67,7 +72,7 @@ impl Observation { impl Debug for Observation { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { match self { - Observation::Genesis(group) => write!(formatter, "Genesis({:?})", group), + Observation::Genesis { group, .. } => write!(formatter, "Genesis({:?})", group), Observation::Add { peer_id, .. } => write!(formatter, "Add({:?})", peer_id), Observation::Remove { peer_id, .. } => write!(formatter, "Remove({:?})", peer_id), Observation::Accusation { offender, malice } => { diff --git a/src/parsec.rs b/src/parsec.rs index 06304b93..4cfc890c 100644 --- a/src/parsec.rs +++ b/src/parsec.rs @@ -116,11 +116,13 @@ impl Parsec { /// * `our_id` is the value that will identify the owning peer in the network. /// * `genesis_group` is the set of public IDs of the peers that are present at the network /// startup. + /// * `genesis_info` extra arbitrary opaque data attached to the genesis event. /// * `consensus_mode` determines how many votes are needed for an observation to become a /// candidate for consensus. For more details, see [ConsensusMode](enum.ConsensusMode.html) pub fn from_genesis( our_id: S, genesis_group: &BTreeSet, + genesis_info: Vec, consensus_mode: ConsensusMode, ) -> Self { if !genesis_group.contains(our_id.public_id()) { @@ -147,7 +149,10 @@ impl Parsec { parsec.add_initial_event(); // Add event carrying genesis observation. - let genesis_observation = Observation::Genesis(genesis_group.clone()); + let genesis_observation = Observation::Genesis { + group: genesis_group.clone(), + related_info: genesis_info, + }; let event = parsec.our_last_event_index().and_then(|self_parent| { parsec.new_event_from_observation(self_parent, genesis_observation) }); @@ -821,7 +826,7 @@ impl Parsec { self.handle_remove_peer(event_index, offender) } - Some(Observation::Genesis(_)) | Some(Observation::OpaquePayload(_)) => None, + Some(Observation::Genesis { .. }) | Some(Observation::OpaquePayload(_)) => None, None => { log_or_panic!("Failed to get observation from hash."); None @@ -1589,7 +1594,7 @@ impl Parsec { // Detect if the event carries an `Observation::Genesis` that doesn't match what we'd expect. fn detect_incorrect_genesis(&mut self, event: &Event) -> Result<()> { - if let Some(Observation::Genesis(ref group)) = self.event_payload(event) { + if let Some(Observation::Genesis { ref group, .. }) = self.event_payload(event) { if self.genesis_group() == group.iter().collect() { return Ok(()); } @@ -1667,7 +1672,7 @@ impl Parsec { return; }; - let genesis_group = if let Observation::Genesis(ref group) = *payload { + let genesis_group = if let Observation::Genesis { ref group, .. } = *payload { group } else { return; @@ -1699,7 +1704,7 @@ impl Parsec { return; } - if let Some(&Observation::Genesis(_)) = self.event_payload(event) { + if let Some(&Observation::Genesis { .. }) = self.event_payload(event) { return; } @@ -1966,9 +1971,9 @@ impl Parsec { }; let starting_index = self.peer_list.accomplice_event_checkpoint_by(creator); - for (_, malice) in - self.detect_accomplice_for_our_accusations(event_index, starting_index)? - { + let accusations = + self.detect_accomplice_for_our_accusations(event_index, starting_index)?; + for (_, malice) in accusations { self.accuse(creator, Malice::Accomplice(event_hash, Box::new(malice))); } @@ -2026,8 +2031,8 @@ impl Parsec { .iter() .filter_map(|event| { let observation = self.event_payload(&*event)?; - if let Observation::Genesis(ref gen) = *observation { - Some(gen.iter().collect()) + if let Observation::Genesis { ref group, .. } = *observation { + Some(group.iter().collect()) } else { None } @@ -2157,7 +2162,12 @@ impl TestParsec { genesis_group: &BTreeSet, consensus_mode: ConsensusMode, ) -> Self { - TestParsec(Parsec::from_genesis(our_id, genesis_group, consensus_mode)) + TestParsec(Parsec::from_genesis( + our_id, + genesis_group, + vec![], + consensus_mode, + )) } pub fn from_existing(