Simulations nodeid report (#272)

* Add node id to the node state report

* Update config with record settings example
This commit is contained in:
gusto 2023-07-25 17:17:26 +03:00 committed by GitHub
parent df97ea2543
commit ef0b0701f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 12 deletions

View File

@ -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
}
}

View File

@ -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<HashMap<String, bool>> = 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<O: Overlay> From<&Carnot<O>> for CarnotState {
fn from(value: &Carnot<O>) -> 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(),