From ef0b0701f3470e6ed1ffe9a2e0367393ac2d9464 Mon Sep 17 00:00:00 2001 From: gusto Date: Tue, 25 Jul 2023 17:17:26 +0300 Subject: [PATCH] Simulations nodeid report (#272) * Add node id to the node state report * Update config with record settings example --- simulations/config/carnot.json | 41 +++++++++++++++++++++--------- simulations/src/node/carnot/mod.rs | 6 +++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/simulations/config/carnot.json b/simulations/config/carnot.json index 9231f25b..074f8009 100644 --- a/simulations/config/carnot.json +++ b/simulations/config/carnot.json @@ -1,14 +1,14 @@ { "network_settings": { "network_behaviors": { - "north america:north america": "10ms", - "north america:europe": "50ms", - "north america:asia": "500ms", - "europe:europe": "5ms", - "europe:asia": "300ms", - "europe:north america": "80ms", - "asia:north america": "480ms", - "asia:europe": "300ms", + "north america:north america": "50ms", + "north america:europe": "100ms", + "north america:asia": "120ms", + "europe:europe": "50ms", + "europe:asia": "100ms", + "europe:north america": "120ms", + "asia:north america": "100ms", + "asia:europe": "120ms", "asia:asia": "40ms" }, "regions": { @@ -23,13 +23,30 @@ "node_settings": { "timeout": "1000ms" }, - "step_time": "100ms", + "step_time": "10ms", "runner_settings": "Sync", "stream_settings": { - "type": "stdout" + "path": "test.json" }, - "node_count": 3, + "node_count": 3000, "views_count": 3, "leaders_count": 1, - "seed": 0 + "seed": 0, + "wards": [ + {"max_view": 1} + ], + "record_settings": { + "node_id": true, + "current_view": true, + "highest_voted_view": true, + "local_high_qc": true, + "safe_blocks": true, + "last_view_timeout_qc": true, + "latest_committed_block": true, + "latest_committed_view": true, + "root_committee": true, + "parent_committee": true, + "child_committees": true, + "committed_blocks": true + } } diff --git a/simulations/src/node/carnot/mod.rs b/simulations/src/node/carnot/mod.rs index d0f9e758..d6f64808 100644 --- a/simulations/src/node/carnot/mod.rs +++ b/simulations/src/node/carnot/mod.rs @@ -29,6 +29,7 @@ use nomos_consensus::{ network::messages::{NewViewMsg, TimeoutMsg, VoteMsg}, }; +const NODE_ID: &str = "node_id"; const CURRENT_VIEW: &str = "current_view"; const HIGHEST_VOTED_VIEW: &str = "highest_voted_view"; const LOCAL_HIGH_QC: &str = "local_high_qc"; @@ -42,6 +43,7 @@ const CHILD_COMMITTEES: &str = "child_committees"; const COMMITTED_BLOCKS: &str = "committed_blocks"; pub const CARNOT_RECORD_KEYS: &[&str] = &[ + NODE_ID, CURRENT_VIEW, HIGHEST_VOTED_VIEW, LOCAL_HIGH_QC, @@ -59,6 +61,7 @@ static RECORD_SETTINGS: std::sync::OnceLock> = std::sync:: #[derive(Debug)] pub struct CarnotState { + node_id: NodeId, current_view: View, highest_voted_view: View, local_high_qc: StandardQc, @@ -93,6 +96,7 @@ impl serde::Serialize for CarnotState { let mut ser = serializer.serialize_struct("CarnotState", keys.len())?; for k in keys { match k.trim() { + NODE_ID => ser.serialize_field(NODE_ID, &self.node_id)?, CURRENT_VIEW => ser.serialize_field(CURRENT_VIEW, &self.current_view)?, HIGHEST_VOTED_VIEW => { ser.serialize_field(HIGHEST_VOTED_VIEW, &self.highest_voted_view)? @@ -163,8 +167,10 @@ where impl From<&Carnot> for CarnotState { fn from(value: &Carnot) -> Self { + let node_id = value.id(); let current_view = value.current_view(); Self { + node_id, current_view, local_high_qc: value.high_qc(), parent_committe: value.parent_committee(),