From d83aab23839b196c9f7f9488ed9ae5022307b318 Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 11:17:04 +0000 Subject: [PATCH 1/7] data: add trace schema for haskell & rust --- data/simulation/Makefile | 12 +- data/simulation/trace.haskell.d.ts | 65 +++++ data/simulation/trace.haskell.schema.json | 180 ++++++++++++ data/simulation/trace.rust.d.ts | 134 +++++++++ data/simulation/trace.rust.schema.json | 321 ++++++++++++++++++++++ 5 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 data/simulation/trace.haskell.d.ts create mode 100644 data/simulation/trace.haskell.schema.json create mode 100644 data/simulation/trace.rust.d.ts create mode 100644 data/simulation/trace.rust.schema.json diff --git a/data/simulation/Makefile b/data/simulation/Makefile index 337a02132..5a50f1ca9 100644 --- a/data/simulation/Makefile +++ b/data/simulation/Makefile @@ -1,4 +1,4 @@ -all: config.schema.json topology.schema.json +all: config.schema.json topology.schema.json trace.haskell.schema.json trace.rust.schema.json config.schema.json: config.d.ts npx typescript-json-schema config.d.ts Config > config.schema.json @@ -8,7 +8,17 @@ topology.schema.json: topology.d.ts npx typescript-json-schema topology.d.ts Topology > topology.schema.json npx prettier -w topology.schema.json +trace.haskell.schema.json: trace.haskell.d.ts + npx typescript-json-schema trace.haskell.d.ts HaskellTraceEvent > trace.haskell.schema.json + npx prettier -w trace.haskell.schema.json + +trace.rust.schema.json: trace.rust.d.ts + npx typescript-json-schema trace.rust.d.ts RustTraceEvent > trace.rust.schema.json + npx prettier -w trace.rust.schema.json + .PHONY: validate validate: npx pajv -m schema.schema.json -s config.schema.json -d config.default.yaml npx pajv -m schema.schema.json -s topology.schema.json -d topology-dense-52.yaml + npx pajv -m schema.schema.json -s trace.haskell.schema.json -d example.haskell.jsonl + npx pajv -m schema.schema.json -s trace.rust.schema.json -d example.rust.jsonl diff --git a/data/simulation/trace.haskell.d.ts b/data/simulation/trace.haskell.d.ts new file mode 100644 index 000000000..831927348 --- /dev/null +++ b/data/simulation/trace.haskell.d.ts @@ -0,0 +1,65 @@ +/** Haskell simulation trace format */ +export interface HaskellTraceEvent { + time_s: number; + event: HaskellEvent; +} + +type HaskellEvent = + | HaskellCpuEvent + | HaskellGeneratedEvent + | HaskellSentEvent + | HaskellReceivedEvent + | HaskellStateEvent; + +interface HaskellCpuEvent { + tag: "Cpu"; + node: number; + node_name: string; + duration_s: number; + // CPU task types: Block validation (ValIB, ValEB, ValRB), Header validation (ValIH, ValRH), Vote validation (ValVote). Format: ": " + task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640" +} + +interface HaskellGeneratedEvent { + tag: "generated"; + kind: "IB" | "EB" | "RB" | "VT"; + id: string; + node: number; + node_name: string; + size_bytes: number; + // Required for IB + slot?: number; + payload_bytes?: number; + rb_ref?: string; + // Required for EB + input_blocks?: string[]; + // Required for VT + votes?: number; + endorse_blocks?: string[]; +} + +interface HaskellSentEvent { + tag: "Sent"; + sender: number; + receipient: number; + msg_size_bytes: number; + sending_s: number; + kind: "IB" | "EB" | "RB" | "VT"; + ids: string[]; +} + +interface HaskellReceivedEvent { + tag: "received"; + kind: "IB" | "EB" | "RB" | "VT"; + id: string; + node: number; + node_name: string; +} + +interface HaskellStateEvent { + tag: "enteredstate"; + kind: "IB" | "EB" | "RB" | "VT"; + id: string; + node: number; + node_name: string; +} diff --git a/data/simulation/trace.haskell.schema.json b/data/simulation/trace.haskell.schema.json new file mode 100644 index 000000000..43d5f8c86 --- /dev/null +++ b/data/simulation/trace.haskell.schema.json @@ -0,0 +1,180 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "HaskellCpuEvent": { + "properties": { + "duration_s": { + "type": "number" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "tag": { + "const": "Cpu", + "type": "string" + }, + "task_label": { + "description": "CPU task types:\n- Block validation: ValIB, ValEB, ValRB\n- Header validation: ValIH, ValRH\n- Vote validation: ValVote\nFormat: \": \"", + "type": "string" + } + }, + "type": "object" + }, + "HaskellEvent": { + "anyOf": [ + { + "$ref": "#/definitions/HaskellCpuEvent" + }, + { + "$ref": "#/definitions/HaskellGeneratedEvent" + }, + { + "$ref": "#/definitions/HaskellSentEvent" + }, + { + "$ref": "#/definitions/HaskellReceivedEvent" + }, + { + "$ref": "#/definitions/HaskellStateEvent" + } + ] + }, + "HaskellGeneratedEvent": { + "properties": { + "endorse_blocks": { + "items": { + "type": "string" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "input_blocks": { + "items": { + "type": "string" + }, + "type": "array" + }, + "kind": { + "enum": ["EB", "IB", "RB", "VT"], + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "payload_bytes": { + "type": "number" + }, + "rb_ref": { + "type": "string" + }, + "size_bytes": { + "type": "number" + }, + "slot": { + "type": "number" + }, + "tag": { + "const": "generated", + "type": "string" + }, + "votes": { + "type": "number" + } + }, + "type": "object" + }, + "HaskellReceivedEvent": { + "properties": { + "id": { + "type": "string" + }, + "kind": { + "enum": ["EB", "IB", "RB", "VT"], + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "tag": { + "const": "received", + "type": "string" + } + }, + "type": "object" + }, + "HaskellSentEvent": { + "properties": { + "ids": { + "items": { + "type": "string" + }, + "type": "array" + }, + "kind": { + "enum": ["EB", "IB", "RB", "VT"], + "type": "string" + }, + "msg_size_bytes": { + "type": "number" + }, + "receipient": { + "type": "number" + }, + "sender": { + "type": "number" + }, + "sending_s": { + "type": "number" + }, + "tag": { + "const": "Sent", + "type": "string" + } + }, + "type": "object" + }, + "HaskellStateEvent": { + "properties": { + "id": { + "type": "string" + }, + "kind": { + "enum": ["EB", "IB", "RB", "VT"], + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "tag": { + "const": "enteredstate", + "type": "string" + } + }, + "type": "object" + } + }, + "description": "Haskell simulation trace format", + "properties": { + "event": { + "$ref": "#/definitions/HaskellEvent" + }, + "time_s": { + "type": "number" + } + }, + "type": "object" +} diff --git a/data/simulation/trace.rust.d.ts b/data/simulation/trace.rust.d.ts new file mode 100644 index 000000000..6e86dc7e4 --- /dev/null +++ b/data/simulation/trace.rust.d.ts @@ -0,0 +1,134 @@ +/** Rust simulation trace format */ + +// Base types +interface BaseEvent { + time: number; // nanoseconds +} + +interface TaskInfo { + node: string; + index: number; +} + +// CPU Events +type CpuTaskType = + | "PraosBlockValidated" + | "EndorserBlockValidated" + | "VoteBundleValidated" + | "EndorserBlockGenerated" + | "VoteBundleGenerated" + | "InputBlockValidated" + | "InputBlockGenerated" + | "TransactionValidated" + | "PraosBlockGenerated"; + +interface CpuEvent extends BaseEvent { + message: { + type: + | "CpuTaskScheduled" + | "CpuTaskFinished" + | "CpuSubtaskStarted" + | "CpuSubtaskFinished"; + task: TaskInfo; + task_type?: CpuTaskType; + subtasks?: number; + subtask_id?: number; + extra?: string; + }; +} + +// Block Events +interface BaseBlockEvent { + id?: string; + slot: number; + producer: string; + sender?: string; + recipient?: string; +} + +interface InputBlockEvent extends BaseEvent { + message: BaseBlockEvent & { + type: + | "InputBlockSent" + | "InputBlockReceived" + | "InputBlockLotteryWon" + | "InputBlockGenerated"; + index: number; + header_bytes?: number; + transactions?: string[]; + }; +} + +interface EndorserBlockEvent extends BaseEvent { + message: BaseBlockEvent & { + type: + | "EndorserBlockSent" + | "EndorserBlockReceived" + | "EndorserBlockLotteryWon" + | "EndorserBlockGenerated"; + }; +} + +interface PraosBlockEvent extends BaseEvent { + message: BaseBlockEvent & { + type: + | "PraosBlockSent" + | "PraosBlockReceived" + | "PraosBlockLotteryWon" + | "PraosBlockGenerated"; + header_bytes?: number; + transactions?: string[]; + vrf?: number; + endorsement?: any; + }; +} + +// Transaction Events +interface TransactionEvent extends BaseEvent { + message: { + type: + | "TransactionSent" + | "TransactionReceived" + | "TransactionGenerated"; + id: string; + sender?: string; + recipient?: string; + publisher?: string; + bytes?: number; + }; +} + +// Vote Events +interface VoteEvent extends BaseEvent { + message: { + type: + | "VotesReceived" + | "VotesSent" + | "VotesGenerated" + | "VoteLotteryWon"; + id: string; + slot: number; + producer: string; + sender?: string; + recipient?: string; + votes?: Record; + }; +} + +// Slot Event +interface SlotEvent extends BaseEvent { + message: { + type: "Slot"; + number: number; + }; +} + +// Combined type +export type RustTraceEvent = + | CpuEvent + | InputBlockEvent + | EndorserBlockEvent + | PraosBlockEvent + | TransactionEvent + | VoteEvent + | SlotEvent; diff --git a/data/simulation/trace.rust.schema.json b/data/simulation/trace.rust.schema.json new file mode 100644 index 000000000..f20bc758e --- /dev/null +++ b/data/simulation/trace.rust.schema.json @@ -0,0 +1,321 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "anyOf": [ + { + "$ref": "#/definitions/CpuEvent" + }, + { + "$ref": "#/definitions/InputBlockEvent" + }, + { + "$ref": "#/definitions/EndorserBlockEvent" + }, + { + "$ref": "#/definitions/PraosBlockEvent" + }, + { + "$ref": "#/definitions/TransactionEvent" + }, + { + "$ref": "#/definitions/VoteEvent" + }, + { + "$ref": "#/definitions/SlotEvent" + } + ], + "definitions": { + "BaseBlockEvent": { + "properties": { + "id": { + "type": "string" + }, + "producer": { + "type": "string" + }, + "recipient": { + "type": "string" + }, + "sender": { + "type": "string" + }, + "slot": { + "type": "number" + } + }, + "type": "object" + }, + "CpuEvent": { + "properties": { + "message": { + "properties": { + "extra": { + "type": "string" + }, + "subtask_id": { + "type": "number" + }, + "subtasks": { + "type": "number" + }, + "task": { + "$ref": "#/definitions/TaskInfo" + }, + "task_type": { + "$ref": "#/definitions/CpuTaskType" + }, + "type": { + "enum": [ + "CpuSubtaskFinished", + "CpuSubtaskStarted", + "CpuTaskFinished", + "CpuTaskScheduled" + ], + "type": "string" + } + }, + "type": "object" + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "CpuTaskType": { + "enum": [ + "EndorserBlockGenerated", + "EndorserBlockValidated", + "InputBlockGenerated", + "InputBlockValidated", + "PraosBlockGenerated", + "PraosBlockValidated", + "TransactionValidated", + "VoteBundleGenerated", + "VoteBundleValidated" + ], + "type": "string" + }, + "EndorserBlockEvent": { + "properties": { + "message": { + "allOf": [ + { + "$ref": "#/definitions/BaseBlockEvent" + }, + { + "properties": { + "type": { + "enum": [ + "EndorserBlockGenerated", + "EndorserBlockLotteryWon", + "EndorserBlockReceived", + "EndorserBlockSent" + ], + "type": "string" + } + }, + "type": "object" + } + ] + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "InputBlockEvent": { + "properties": { + "message": { + "allOf": [ + { + "$ref": "#/definitions/BaseBlockEvent" + }, + { + "properties": { + "header_bytes": { + "type": "number" + }, + "index": { + "type": "number" + }, + "transactions": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "enum": [ + "InputBlockGenerated", + "InputBlockLotteryWon", + "InputBlockReceived", + "InputBlockSent" + ], + "type": "string" + } + }, + "type": "object" + } + ] + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "PraosBlockEvent": { + "properties": { + "message": { + "allOf": [ + { + "$ref": "#/definitions/BaseBlockEvent" + }, + { + "properties": { + "endorsement": {}, + "header_bytes": { + "type": "number" + }, + "transactions": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "enum": [ + "PraosBlockGenerated", + "PraosBlockLotteryWon", + "PraosBlockReceived", + "PraosBlockSent" + ], + "type": "string" + }, + "vrf": { + "type": "number" + } + }, + "type": "object" + } + ] + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "Record": { + "type": "object" + }, + "SlotEvent": { + "properties": { + "message": { + "properties": { + "number": { + "type": "number" + }, + "type": { + "const": "Slot", + "type": "string" + } + }, + "type": "object" + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "TaskInfo": { + "properties": { + "index": { + "type": "number" + }, + "node": { + "type": "string" + } + }, + "type": "object" + }, + "TransactionEvent": { + "properties": { + "message": { + "properties": { + "bytes": { + "type": "number" + }, + "id": { + "type": "string" + }, + "publisher": { + "type": "string" + }, + "recipient": { + "type": "string" + }, + "sender": { + "type": "string" + }, + "type": { + "enum": [ + "TransactionGenerated", + "TransactionReceived", + "TransactionSent" + ], + "type": "string" + } + }, + "type": "object" + }, + "time": { + "type": "number" + } + }, + "type": "object" + }, + "VoteEvent": { + "properties": { + "message": { + "properties": { + "id": { + "type": "string" + }, + "producer": { + "type": "string" + }, + "recipient": { + "type": "string" + }, + "sender": { + "type": "string" + }, + "slot": { + "type": "number" + }, + "type": { + "enum": [ + "VoteLotteryWon", + "VotesGenerated", + "VotesReceived", + "VotesSent" + ], + "type": "string" + }, + "votes": { + "$ref": "#/definitions/Record" + } + }, + "type": "object" + }, + "time": { + "type": "number" + } + }, + "type": "object" + } + } +} From c5944d72029595ce8f3b8ab5e3397dbd721bb10b Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 11:37:09 +0000 Subject: [PATCH 2/7] data: add example logs for all events for make validate --- data/simulation/Makefile | 35 ++++++++++++++++++++++++--- data/simulation/example.haskell.jsonl | 22 +++++++++++++++++ data/simulation/example.rust.jsonl | 32 ++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 data/simulation/example.haskell.jsonl create mode 100644 data/simulation/example.rust.jsonl diff --git a/data/simulation/Makefile b/data/simulation/Makefile index 5a50f1ca9..f47dfe14c 100644 --- a/data/simulation/Makefile +++ b/data/simulation/Makefile @@ -18,7 +18,34 @@ trace.rust.schema.json: trace.rust.d.ts .PHONY: validate validate: - npx pajv -m schema.schema.json -s config.schema.json -d config.default.yaml - npx pajv -m schema.schema.json -s topology.schema.json -d topology-dense-52.yaml - npx pajv -m schema.schema.json -s trace.haskell.schema.json -d example.haskell.jsonl - npx pajv -m schema.schema.json -s trace.rust.schema.json -d example.rust.jsonl + @echo "Validating config..." + @npx pajv -m schema.schema.json -s config.schema.json -d config.default.yaml > /dev/null && echo "config.default.yaml valid" || exit 1 + @echo "Validating topology..." + @npx pajv -m schema.schema.json -s topology.schema.json -d topology-dense-52.yaml > /dev/null && echo "topology-dense-52.yaml valid" || exit 1 + @echo "Validating Haskell trace events..." + @line_num=0; \ + while IFS= read -r line; do \ + line_num=$$((line_num + 1)); \ + echo "$$line" > temp.json; \ + if ! npx ajv-cli validate -s trace.haskell.schema.json -d temp.json 2>/dev/null >/dev/null; then \ + echo "Error in example.haskell.jsonl at line $$line_num:"; \ + echo "$$line"; \ + npx ajv-cli validate -s trace.haskell.schema.json -d temp.json; \ + rm -f temp.json; \ + exit 1; \ + fi; \ + done < example.haskell.jsonl && echo "example.haskell.jsonl valid" + @echo "Validating Rust trace events..." + @line_num=0; \ + while IFS= read -r line; do \ + line_num=$$((line_num + 1)); \ + echo "$$line" > temp.json; \ + if ! npx ajv-cli validate -s trace.rust.schema.json -d temp.json 2>/dev/null >/dev/null; then \ + echo "Error in example.rust.jsonl at line $$line_num:"; \ + echo "$$line"; \ + npx ajv-cli validate -s trace.rust.schema.json -d temp.json; \ + rm -f temp.json; \ + exit 1; \ + fi; \ + done < example.rust.jsonl && echo "example.rust.jsonl valid" + @rm -f temp.json diff --git a/data/simulation/example.haskell.jsonl b/data/simulation/example.haskell.jsonl new file mode 100644 index 000000000..439e2db06 --- /dev/null +++ b/data/simulation/example.haskell.jsonl @@ -0,0 +1,22 @@ +{"time_s": 1.0, "event": {"tag": "Cpu", "node": 1, "node_name": "node1", "duration_s": 0.1, "task_label": "ValIB: 6-29"}} +{"time_s": 1.2, "event": {"tag": "Cpu", "node": 1, "node_name": "node1", "duration_s": 0.05, "task_label": "ValIH: 6253064077348247640"}} +{"time_s": 1.5, "event": {"tag": "Cpu", "node": 2, "node_name": "node2", "duration_s": 0.15, "task_label": "ValEB: 7-30"}} +{"time_s": 1.8, "event": {"tag": "Cpu", "node": 2, "node_name": "node2", "duration_s": 0.08, "task_label": "ValRH: 7253064077348247641"}} +{"time_s": 2.0, "event": {"tag": "Cpu", "node": 3, "node_name": "node3", "duration_s": 0.12, "task_label": "ValRB: 8-31"}} +{"time_s": 2.3, "event": {"tag": "Cpu", "node": 3, "node_name": "node3", "duration_s": 0.03, "task_label": "ValVote: vote123"}} +{"time_s": 3.0, "event": {"tag": "generated", "kind": "IB", "id": "block1", "node": 1, "node_name": "node1", "size_bytes": 1000, "slot": 1, "payload_bytes": 800, "rb_ref": "rb123"}} +{"time_s": 3.1, "event": {"tag": "Sent", "sender": 1, "receipient": 2, "msg_size_bytes": 1000, "sending_s": 0.01, "kind": "IB", "ids": ["block1"]}} +{"time_s": 3.2, "event": {"tag": "received", "kind": "IB", "id": "block1", "node": 2, "node_name": "node2"}} +{"time_s": 3.3, "event": {"tag": "enteredstate", "kind": "IB", "id": "block1", "node": 2, "node_name": "node2"}} +{"time_s": 4.0, "event": {"tag": "generated", "kind": "EB", "id": "eb1", "node": 2, "node_name": "node2", "size_bytes": 500, "input_blocks": ["block1"]}} +{"time_s": 4.1, "event": {"tag": "Sent", "sender": 2, "receipient": 3, "msg_size_bytes": 500, "sending_s": 0.01, "kind": "EB", "ids": ["eb1"]}} +{"time_s": 4.2, "event": {"tag": "received", "kind": "EB", "id": "eb1", "node": 3, "node_name": "node3"}} +{"time_s": 4.3, "event": {"tag": "enteredstate", "kind": "EB", "id": "eb1", "node": 3, "node_name": "node3"}} +{"time_s": 5.0, "event": {"tag": "generated", "kind": "RB", "id": "rb1", "node": 3, "node_name": "node3", "size_bytes": 300}} +{"time_s": 5.1, "event": {"tag": "Sent", "sender": 3, "receipient": 1, "msg_size_bytes": 300, "sending_s": 0.01, "kind": "RB", "ids": ["rb1"]}} +{"time_s": 5.2, "event": {"tag": "received", "kind": "RB", "id": "rb1", "node": 1, "node_name": "node1"}} +{"time_s": 5.3, "event": {"tag": "enteredstate", "kind": "RB", "id": "rb1", "node": 1, "node_name": "node1"}} +{"time_s": 6.0, "event": {"tag": "generated", "kind": "VT", "id": "vote1", "node": 1, "node_name": "node1", "size_bytes": 200, "votes": 1, "endorse_blocks": ["eb1"]}} +{"time_s": 6.1, "event": {"tag": "Sent", "sender": 1, "receipient": 2, "msg_size_bytes": 200, "sending_s": 0.01, "kind": "VT", "ids": ["vote1"]}} +{"time_s": 6.2, "event": {"tag": "received", "kind": "VT", "id": "vote1", "node": 2, "node_name": "node2"}} +{"time_s": 6.3, "event": {"tag": "enteredstate", "kind": "VT", "id": "vote1", "node": 2, "node_name": "node2"}} \ No newline at end of file diff --git a/data/simulation/example.rust.jsonl b/data/simulation/example.rust.jsonl new file mode 100644 index 000000000..d2be42712 --- /dev/null +++ b/data/simulation/example.rust.jsonl @@ -0,0 +1,32 @@ +{"time": 1000, "message": {"type": "Slot", "number": 1}} +{"time": 2000, "message": {"type": "CpuTaskScheduled", "task": {"node": "node1", "index": 0}, "task_type": "PraosBlockValidated"}} +{"time": 2100, "message": {"type": "CpuTaskFinished", "task": {"node": "node1", "index": 0}, "task_type": "PraosBlockValidated"}} +{"time": 2200, "message": {"type": "CpuTaskScheduled", "task": {"node": "node1", "index": 1}, "task_type": "EndorserBlockValidated"}} +{"time": 2300, "message": {"type": "CpuTaskFinished", "task": {"node": "node1", "index": 1}, "task_type": "EndorserBlockValidated"}} +{"time": 2400, "message": {"type": "CpuTaskScheduled", "task": {"node": "node1", "index": 2}, "task_type": "VoteBundleValidated"}} +{"time": 2500, "message": {"type": "CpuTaskFinished", "task": {"node": "node1", "index": 2}, "task_type": "VoteBundleValidated"}} +{"time": 2600, "message": {"type": "CpuTaskScheduled", "task": {"node": "node1", "index": 3}, "task_type": "InputBlockValidated"}} +{"time": 2700, "message": {"type": "CpuTaskFinished", "task": {"node": "node1", "index": 3}, "task_type": "InputBlockValidated"}} +{"time": 2800, "message": {"type": "CpuTaskScheduled", "task": {"node": "node1", "index": 4}, "task_type": "TransactionValidated"}} +{"time": 2900, "message": {"type": "CpuTaskFinished", "task": {"node": "node1", "index": 4}, "task_type": "TransactionValidated"}} +{"time": 3000, "message": {"type": "CpuSubtaskStarted", "task": {"node": "node1", "index": 5}, "task_type": "VoteBundleValidated", "subtask_id": 0, "subtasks": 2}} +{"time": 3100, "message": {"type": "CpuSubtaskFinished", "task": {"node": "node1", "index": 5}, "task_type": "VoteBundleValidated", "subtask_id": 0, "subtasks": 2}} +{"time": 3200, "message": {"type": "CpuSubtaskStarted", "task": {"node": "node1", "index": 5}, "task_type": "VoteBundleValidated", "subtask_id": 1, "subtasks": 2}} +{"time": 3300, "message": {"type": "CpuSubtaskFinished", "task": {"node": "node1", "index": 5}, "task_type": "VoteBundleValidated", "subtask_id": 1, "subtasks": 2}} +{"time": 4000, "message": {"type": "InputBlockGenerated", "slot": 1, "producer": "node1", "index": 0, "header_bytes": 100, "transactions": ["tx1", "tx2"]}} +{"time": 4100, "message": {"type": "InputBlockSent", "slot": 1, "producer": "node1", "sender": "node1", "recipient": "node2", "index": 0, "header_bytes": 100, "transactions": ["tx1", "tx2"]}} +{"time": 4200, "message": {"type": "InputBlockReceived", "slot": 1, "producer": "node1", "sender": "node1", "recipient": "node2", "index": 0, "header_bytes": 100, "transactions": ["tx1", "tx2"]}} +{"time": 4300, "message": {"type": "InputBlockLotteryWon", "slot": 1, "producer": "node1", "index": 0}} +{"time": 5000, "message": {"type": "EndorserBlockGenerated", "slot": 1, "producer": "node2"}} +{"time": 5100, "message": {"type": "EndorserBlockSent", "slot": 1, "producer": "node2", "sender": "node2", "recipient": "node3"}} +{"time": 5200, "message": {"type": "EndorserBlockReceived", "slot": 1, "producer": "node2", "sender": "node2", "recipient": "node3"}} +{"time": 5300, "message": {"type": "EndorserBlockLotteryWon", "slot": 1, "producer": "node2"}} +{"time": 6000, "message": {"type": "PraosBlockGenerated", "slot": 1, "producer": "node3", "header_bytes": 200, "transactions": ["tx1", "tx2"], "vrf": 584785879898000}} +{"time": 6100, "message": {"type": "PraosBlockSent", "slot": 1, "producer": "node3", "sender": "node3", "recipient": "node1", "header_bytes": 200, "transactions": ["tx1", "tx2"], "vrf": 584785879898836}} +{"time": 6200, "message": {"type": "PraosBlockReceived", "slot": 1, "producer": "node3", "sender": "node3", "recipient": "node1", "header_bytes": 200, "transactions": ["tx1", "tx2"], "vrf": 584785870008836}} +{"time": 6300, "message": {"type": "PraosBlockLotteryWon", "slot": 1, "producer": "node3", "vrf": 384785879898000}} +{"time": 7000, "message": {"type": "TransactionSent", "id": "tx1", "sender": "node1", "recipient": "node2", "publisher": "node1", "bytes": 50}} +{"time": 8000, "message": {"type": "VotesGenerated", "id": "vote1", "slot": 1, "producer": "node1", "votes": {"node1": 1}}} +{"time": 8100, "message": {"type": "VotesSent", "id": "vote1", "slot": 1, "producer": "node1", "sender": "node1", "recipient": "node2", "votes": {"node1": 1}}} +{"time": 8200, "message": {"type": "VotesReceived", "id": "vote1", "slot": 1, "producer": "node1", "sender": "node1", "recipient": "node2", "votes": {"node1": 1}}} +{"time": 8300, "message": {"type": "VoteLotteryWon", "id": "vote1", "slot": 1, "producer": "node1"}} \ No newline at end of file From eb8b9879ddada60fb36499000defa3b33ad986d2 Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 11:46:48 +0000 Subject: [PATCH 3/7] data: simplify haskell trace schema --- data/simulation/trace.haskell.d.ts | 53 +++++++--- data/simulation/trace.haskell.schema.json | 116 +++++++++++++++++++--- 2 files changed, 138 insertions(+), 31 deletions(-) diff --git a/data/simulation/trace.haskell.d.ts b/data/simulation/trace.haskell.d.ts index 831927348..f0ece70d4 100644 --- a/data/simulation/trace.haskell.d.ts +++ b/data/simulation/trace.haskell.d.ts @@ -4,6 +4,8 @@ export interface HaskellTraceEvent { event: HaskellEvent; } +type MessageKind = "IB" | "EB" | "RB" | "VT"; + type HaskellEvent = | HaskellCpuEvent | HaskellGeneratedEvent @@ -20,22 +22,43 @@ interface HaskellCpuEvent { task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640" } -interface HaskellGeneratedEvent { +type HaskellGeneratedEvent = + | HaskellGeneratedIBEvent + | HaskellGeneratedEBEvent + | HaskellGeneratedRBEvent + | HaskellGeneratedVTEvent; + +interface HaskellGeneratedBaseEvent { tag: "generated"; - kind: "IB" | "EB" | "RB" | "VT"; - id: string; node: number; node_name: string; size_bytes: number; - // Required for IB - slot?: number; - payload_bytes?: number; - rb_ref?: string; - // Required for EB - input_blocks?: string[]; - // Required for VT - votes?: number; - endorse_blocks?: string[]; +} + +interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent { + kind: Extract; + id: string; + slot: number; + payload_bytes: number; + rb_ref: string; +} + +interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent { + kind: Extract; + id: string; + input_blocks: string[]; +} + +interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent { + kind: Extract; + id: string; +} + +interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent { + kind: Extract; + id: string; + votes: number; + endorse_blocks: string[]; } interface HaskellSentEvent { @@ -44,13 +67,13 @@ interface HaskellSentEvent { receipient: number; msg_size_bytes: number; sending_s: number; - kind: "IB" | "EB" | "RB" | "VT"; + kind: MessageKind; ids: string[]; } interface HaskellReceivedEvent { tag: "received"; - kind: "IB" | "EB" | "RB" | "VT"; + kind: MessageKind; id: string; node: number; node_name: string; @@ -58,7 +81,7 @@ interface HaskellReceivedEvent { interface HaskellStateEvent { tag: "enteredstate"; - kind: "IB" | "EB" | "RB" | "VT"; + kind: MessageKind; id: string; node: number; node_name: string; diff --git a/data/simulation/trace.haskell.schema.json b/data/simulation/trace.haskell.schema.json index 43d5f8c86..650a0af84 100644 --- a/data/simulation/trace.haskell.schema.json +++ b/data/simulation/trace.haskell.schema.json @@ -17,7 +17,6 @@ "type": "string" }, "task_label": { - "description": "CPU task types:\n- Block validation: ValIB, ValEB, ValRB\n- Header validation: ValIH, ValRH\n- Vote validation: ValVote\nFormat: \": \"", "type": "string" } }, @@ -29,7 +28,16 @@ "$ref": "#/definitions/HaskellCpuEvent" }, { - "$ref": "#/definitions/HaskellGeneratedEvent" + "$ref": "#/definitions/HaskellGeneratedIBEvent" + }, + { + "$ref": "#/definitions/HaskellGeneratedEBEvent" + }, + { + "$ref": "#/definitions/HaskellGeneratedRBEvent" + }, + { + "$ref": "#/definitions/HaskellGeneratedVTEvent" }, { "$ref": "#/definitions/HaskellSentEvent" @@ -42,14 +50,8 @@ } ] }, - "HaskellGeneratedEvent": { + "HaskellGeneratedEBEvent": { "properties": { - "endorse_blocks": { - "items": { - "type": "string" - }, - "type": "array" - }, "id": { "type": "string" }, @@ -60,7 +62,32 @@ "type": "array" }, "kind": { - "enum": ["EB", "IB", "RB", "VT"], + "const": "EB", + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "size_bytes": { + "type": "number" + }, + "tag": { + "const": "generated", + "type": "string" + } + }, + "type": "object" + }, + "HaskellGeneratedIBEvent": { + "properties": { + "id": { + "type": "string" + }, + "kind": { + "const": "IB", "type": "string" }, "node": { @@ -81,6 +108,62 @@ "slot": { "type": "number" }, + "tag": { + "const": "generated", + "type": "string" + } + }, + "type": "object" + }, + "HaskellGeneratedRBEvent": { + "properties": { + "id": { + "type": "string" + }, + "kind": { + "const": "RB", + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "size_bytes": { + "type": "number" + }, + "tag": { + "const": "generated", + "type": "string" + } + }, + "type": "object" + }, + "HaskellGeneratedVTEvent": { + "properties": { + "endorse_blocks": { + "items": { + "type": "string" + }, + "type": "array" + }, + "id": { + "type": "string" + }, + "kind": { + "const": "VT", + "type": "string" + }, + "node": { + "type": "number" + }, + "node_name": { + "type": "string" + }, + "size_bytes": { + "type": "number" + }, "tag": { "const": "generated", "type": "string" @@ -97,8 +180,7 @@ "type": "string" }, "kind": { - "enum": ["EB", "IB", "RB", "VT"], - "type": "string" + "$ref": "#/definitions/MessageKind" }, "node": { "type": "number" @@ -122,8 +204,7 @@ "type": "array" }, "kind": { - "enum": ["EB", "IB", "RB", "VT"], - "type": "string" + "$ref": "#/definitions/MessageKind" }, "msg_size_bytes": { "type": "number" @@ -150,8 +231,7 @@ "type": "string" }, "kind": { - "enum": ["EB", "IB", "RB", "VT"], - "type": "string" + "$ref": "#/definitions/MessageKind" }, "node": { "type": "number" @@ -165,6 +245,10 @@ } }, "type": "object" + }, + "MessageKind": { + "enum": ["EB", "IB", "RB", "VT"], + "type": "string" } }, "description": "Haskell simulation trace format", From 1b86f959c1229d698f07d5b1135264b9184e0ab6 Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 11:48:34 +0000 Subject: [PATCH 4/7] data: remove verbose extract of message kind --- data/simulation/trace.haskell.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/simulation/trace.haskell.d.ts b/data/simulation/trace.haskell.d.ts index f0ece70d4..7154d0a6f 100644 --- a/data/simulation/trace.haskell.d.ts +++ b/data/simulation/trace.haskell.d.ts @@ -36,7 +36,7 @@ interface HaskellGeneratedBaseEvent { } interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent { - kind: Extract; + kind: "IB"; id: string; slot: number; payload_bytes: number; @@ -44,18 +44,18 @@ interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent { } interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent { - kind: Extract; + kind: "EB"; id: string; input_blocks: string[]; } interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent { - kind: Extract; + kind: "RB"; id: string; } interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent { - kind: Extract; + kind: "VT"; id: string; votes: number; endorse_blocks: string[]; From 84d7bd122566d8d394466368f1d423f1ac36b561 Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 12:01:01 +0000 Subject: [PATCH 5/7] data: updated rust schema --- data/simulation/trace.rust.d.ts | 120 +++++++++++--------- data/simulation/trace.rust.schema.json | 148 ++++++++++++++----------- 2 files changed, 151 insertions(+), 117 deletions(-) diff --git a/data/simulation/trace.rust.d.ts b/data/simulation/trace.rust.d.ts index 6e86dc7e4..b030abd5a 100644 --- a/data/simulation/trace.rust.d.ts +++ b/data/simulation/trace.rust.d.ts @@ -1,17 +1,21 @@ /** Rust simulation trace format */ // Base types -interface BaseEvent { +interface RustBaseEvent { time: number; // nanoseconds + message: { + type: string; + [key: string]: any; + }; } -interface TaskInfo { +interface RustTaskInfo { node: string; index: number; } // CPU Events -type CpuTaskType = +type RustCpuTaskType = | "PraosBlockValidated" | "EndorserBlockValidated" | "VoteBundleValidated" @@ -22,15 +26,17 @@ type CpuTaskType = | "TransactionValidated" | "PraosBlockGenerated"; -interface CpuEvent extends BaseEvent { +type RustCpuMessageType = + | "CpuTaskScheduled" + | "CpuTaskFinished" + | "CpuSubtaskStarted" + | "CpuSubtaskFinished"; + +interface RustCpuEvent extends Omit { message: { - type: - | "CpuTaskScheduled" - | "CpuTaskFinished" - | "CpuSubtaskStarted" - | "CpuSubtaskFinished"; - task: TaskInfo; - task_type?: CpuTaskType; + type: RustCpuMessageType; + task: RustTaskInfo; + task_type?: RustCpuTaskType; subtasks?: number; subtask_id?: number; extra?: string; @@ -38,7 +44,7 @@ interface CpuEvent extends BaseEvent { } // Block Events -interface BaseBlockEvent { +interface RustBaseBlockEvent { id?: string; slot: number; producer: string; @@ -46,36 +52,42 @@ interface BaseBlockEvent { recipient?: string; } -interface InputBlockEvent extends BaseEvent { - message: BaseBlockEvent & { - type: - | "InputBlockSent" - | "InputBlockReceived" - | "InputBlockLotteryWon" - | "InputBlockGenerated"; +type RustInputBlockMessageType = + | "InputBlockSent" + | "InputBlockReceived" + | "InputBlockLotteryWon" + | "InputBlockGenerated"; + +interface RustInputBlockEvent extends Omit { + message: RustBaseBlockEvent & { + type: RustInputBlockMessageType; index: number; header_bytes?: number; transactions?: string[]; }; } -interface EndorserBlockEvent extends BaseEvent { - message: BaseBlockEvent & { - type: - | "EndorserBlockSent" - | "EndorserBlockReceived" - | "EndorserBlockLotteryWon" - | "EndorserBlockGenerated"; +type RustEndorserBlockMessageType = + | "EndorserBlockSent" + | "EndorserBlockReceived" + | "EndorserBlockLotteryWon" + | "EndorserBlockGenerated"; + +interface RustEndorserBlockEvent extends Omit { + message: RustBaseBlockEvent & { + type: RustEndorserBlockMessageType; }; } -interface PraosBlockEvent extends BaseEvent { - message: BaseBlockEvent & { - type: - | "PraosBlockSent" - | "PraosBlockReceived" - | "PraosBlockLotteryWon" - | "PraosBlockGenerated"; +type RustPraosBlockMessageType = + | "PraosBlockSent" + | "PraosBlockReceived" + | "PraosBlockLotteryWon" + | "PraosBlockGenerated"; + +interface RustPraosBlockEvent extends Omit { + message: RustBaseBlockEvent & { + type: RustPraosBlockMessageType; header_bytes?: number; transactions?: string[]; vrf?: number; @@ -84,12 +96,14 @@ interface PraosBlockEvent extends BaseEvent { } // Transaction Events -interface TransactionEvent extends BaseEvent { +type RustTransactionMessageType = + | "TransactionSent" + | "TransactionReceived" + | "TransactionGenerated"; + +interface RustTransactionEvent extends Omit { message: { - type: - | "TransactionSent" - | "TransactionReceived" - | "TransactionGenerated"; + type: RustTransactionMessageType; id: string; sender?: string; recipient?: string; @@ -99,13 +113,15 @@ interface TransactionEvent extends BaseEvent { } // Vote Events -interface VoteEvent extends BaseEvent { +type RustVoteMessageType = + | "VotesReceived" + | "VotesSent" + | "VotesGenerated" + | "VoteLotteryWon"; + +interface RustVoteEvent extends Omit { message: { - type: - | "VotesReceived" - | "VotesSent" - | "VotesGenerated" - | "VoteLotteryWon"; + type: RustVoteMessageType; id: string; slot: number; producer: string; @@ -116,7 +132,7 @@ interface VoteEvent extends BaseEvent { } // Slot Event -interface SlotEvent extends BaseEvent { +interface RustSlotEvent extends Omit { message: { type: "Slot"; number: number; @@ -125,10 +141,10 @@ interface SlotEvent extends BaseEvent { // Combined type export type RustTraceEvent = - | CpuEvent - | InputBlockEvent - | EndorserBlockEvent - | PraosBlockEvent - | TransactionEvent - | VoteEvent - | SlotEvent; + | RustCpuEvent + | RustInputBlockEvent + | RustEndorserBlockEvent + | RustPraosBlockEvent + | RustTransactionEvent + | RustVoteEvent + | RustSlotEvent; diff --git a/data/simulation/trace.rust.schema.json b/data/simulation/trace.rust.schema.json index f20bc758e..1999cbf39 100644 --- a/data/simulation/trace.rust.schema.json +++ b/data/simulation/trace.rust.schema.json @@ -2,29 +2,32 @@ "$schema": "http://json-schema.org/draft-07/schema#", "anyOf": [ { - "$ref": "#/definitions/CpuEvent" + "$ref": "#/definitions/RustCpuEvent" }, { - "$ref": "#/definitions/InputBlockEvent" + "$ref": "#/definitions/RustInputBlockEvent" }, { - "$ref": "#/definitions/EndorserBlockEvent" + "$ref": "#/definitions/RustEndorserBlockEvent" }, { - "$ref": "#/definitions/PraosBlockEvent" + "$ref": "#/definitions/RustPraosBlockEvent" }, { - "$ref": "#/definitions/TransactionEvent" + "$ref": "#/definitions/RustTransactionEvent" }, { - "$ref": "#/definitions/VoteEvent" + "$ref": "#/definitions/RustVoteEvent" }, { - "$ref": "#/definitions/SlotEvent" + "$ref": "#/definitions/RustSlotEvent" } ], "definitions": { - "BaseBlockEvent": { + "Record": { + "type": "object" + }, + "RustBaseBlockEvent": { "properties": { "id": { "type": "string" @@ -44,7 +47,7 @@ }, "type": "object" }, - "CpuEvent": { + "RustCpuEvent": { "properties": { "message": { "properties": { @@ -58,19 +61,13 @@ "type": "number" }, "task": { - "$ref": "#/definitions/TaskInfo" + "$ref": "#/definitions/RustTaskInfo" }, "task_type": { - "$ref": "#/definitions/CpuTaskType" + "$ref": "#/definitions/RustCpuTaskType" }, "type": { - "enum": [ - "CpuSubtaskFinished", - "CpuSubtaskStarted", - "CpuTaskFinished", - "CpuTaskScheduled" - ], - "type": "string" + "$ref": "#/definitions/RustCpuMessageType" } }, "type": "object" @@ -81,7 +78,16 @@ }, "type": "object" }, - "CpuTaskType": { + "RustCpuMessageType": { + "enum": [ + "CpuSubtaskFinished", + "CpuSubtaskStarted", + "CpuTaskFinished", + "CpuTaskScheduled" + ], + "type": "string" + }, + "RustCpuTaskType": { "enum": [ "EndorserBlockGenerated", "EndorserBlockValidated", @@ -95,23 +101,17 @@ ], "type": "string" }, - "EndorserBlockEvent": { + "RustEndorserBlockEvent": { "properties": { "message": { "allOf": [ { - "$ref": "#/definitions/BaseBlockEvent" + "$ref": "#/definitions/RustBaseBlockEvent" }, { "properties": { "type": { - "enum": [ - "EndorserBlockGenerated", - "EndorserBlockLotteryWon", - "EndorserBlockReceived", - "EndorserBlockSent" - ], - "type": "string" + "$ref": "#/definitions/RustEndorserBlockMessageType" } }, "type": "object" @@ -124,12 +124,21 @@ }, "type": "object" }, - "InputBlockEvent": { + "RustEndorserBlockMessageType": { + "enum": [ + "EndorserBlockGenerated", + "EndorserBlockLotteryWon", + "EndorserBlockReceived", + "EndorserBlockSent" + ], + "type": "string" + }, + "RustInputBlockEvent": { "properties": { "message": { "allOf": [ { - "$ref": "#/definitions/BaseBlockEvent" + "$ref": "#/definitions/RustBaseBlockEvent" }, { "properties": { @@ -146,13 +155,7 @@ "type": "array" }, "type": { - "enum": [ - "InputBlockGenerated", - "InputBlockLotteryWon", - "InputBlockReceived", - "InputBlockSent" - ], - "type": "string" + "$ref": "#/definitions/RustInputBlockMessageType" } }, "type": "object" @@ -165,12 +168,21 @@ }, "type": "object" }, - "PraosBlockEvent": { + "RustInputBlockMessageType": { + "enum": [ + "InputBlockGenerated", + "InputBlockLotteryWon", + "InputBlockReceived", + "InputBlockSent" + ], + "type": "string" + }, + "RustPraosBlockEvent": { "properties": { "message": { "allOf": [ { - "$ref": "#/definitions/BaseBlockEvent" + "$ref": "#/definitions/RustBaseBlockEvent" }, { "properties": { @@ -185,13 +197,7 @@ "type": "array" }, "type": { - "enum": [ - "PraosBlockGenerated", - "PraosBlockLotteryWon", - "PraosBlockReceived", - "PraosBlockSent" - ], - "type": "string" + "$ref": "#/definitions/RustPraosBlockMessageType" }, "vrf": { "type": "number" @@ -207,10 +213,16 @@ }, "type": "object" }, - "Record": { - "type": "object" + "RustPraosBlockMessageType": { + "enum": [ + "PraosBlockGenerated", + "PraosBlockLotteryWon", + "PraosBlockReceived", + "PraosBlockSent" + ], + "type": "string" }, - "SlotEvent": { + "RustSlotEvent": { "properties": { "message": { "properties": { @@ -230,7 +242,7 @@ }, "type": "object" }, - "TaskInfo": { + "RustTaskInfo": { "properties": { "index": { "type": "number" @@ -241,7 +253,7 @@ }, "type": "object" }, - "TransactionEvent": { + "RustTransactionEvent": { "properties": { "message": { "properties": { @@ -261,12 +273,7 @@ "type": "string" }, "type": { - "enum": [ - "TransactionGenerated", - "TransactionReceived", - "TransactionSent" - ], - "type": "string" + "$ref": "#/definitions/RustTransactionMessageType" } }, "type": "object" @@ -277,7 +284,15 @@ }, "type": "object" }, - "VoteEvent": { + "RustTransactionMessageType": { + "enum": [ + "TransactionGenerated", + "TransactionReceived", + "TransactionSent" + ], + "type": "string" + }, + "RustVoteEvent": { "properties": { "message": { "properties": { @@ -297,13 +312,7 @@ "type": "number" }, "type": { - "enum": [ - "VoteLotteryWon", - "VotesGenerated", - "VotesReceived", - "VotesSent" - ], - "type": "string" + "$ref": "#/definitions/RustVoteMessageType" }, "votes": { "$ref": "#/definitions/Record" @@ -316,6 +325,15 @@ } }, "type": "object" + }, + "RustVoteMessageType": { + "enum": [ + "VoteLotteryWon", + "VotesGenerated", + "VotesReceived", + "VotesSent" + ], + "type": "string" } } } From aed2c2c93d4722c02f24ce30353b31498d534063 Mon Sep 17 00:00:00 2001 From: William Wolff Date: Fri, 14 Feb 2025 12:12:03 +0000 Subject: [PATCH 6/7] data: composed rust message & action types --- data/simulation/trace.rust.d.ts | 85 +++-------- data/simulation/trace.rust.schema.json | 186 ++++++++----------------- 2 files changed, 82 insertions(+), 189 deletions(-) diff --git a/data/simulation/trace.rust.d.ts b/data/simulation/trace.rust.d.ts index b030abd5a..95e0aaab6 100644 --- a/data/simulation/trace.rust.d.ts +++ b/data/simulation/trace.rust.d.ts @@ -15,22 +15,18 @@ interface RustTaskInfo { } // CPU Events -type RustCpuTaskType = - | "PraosBlockValidated" - | "EndorserBlockValidated" - | "VoteBundleValidated" - | "EndorserBlockGenerated" - | "VoteBundleGenerated" - | "InputBlockValidated" - | "InputBlockGenerated" - | "TransactionValidated" - | "PraosBlockGenerated"; - -type RustCpuMessageType = - | "CpuTaskScheduled" - | "CpuTaskFinished" - | "CpuSubtaskStarted" - | "CpuSubtaskFinished"; +type BlockOrTaskType = + | "PraosBlock" + | "EndorserBlock" + | "VoteBundle" + | "InputBlock" + | "Transaction"; +type Action = "Validated" | "Generated"; +type RustCpuTaskType = `${BlockOrTaskType}${Action}`; + +type CpuTaskPrefix = "CpuTask" | "CpuSubtask"; +type CpuTaskAction = "Scheduled" | "Started" | "Finished"; +type RustCpuMessageType = `${CpuTaskPrefix}${CpuTaskAction}`; interface RustCpuEvent extends Omit { message: { @@ -52,42 +48,14 @@ interface RustBaseBlockEvent { recipient?: string; } -type RustInputBlockMessageType = - | "InputBlockSent" - | "InputBlockReceived" - | "InputBlockLotteryWon" - | "InputBlockGenerated"; - -interface RustInputBlockEvent extends Omit { - message: RustBaseBlockEvent & { - type: RustInputBlockMessageType; - index: number; - header_bytes?: number; - transactions?: string[]; - }; -} - -type RustEndorserBlockMessageType = - | "EndorserBlockSent" - | "EndorserBlockReceived" - | "EndorserBlockLotteryWon" - | "EndorserBlockGenerated"; - -interface RustEndorserBlockEvent extends Omit { - message: RustBaseBlockEvent & { - type: RustEndorserBlockMessageType; - }; -} - -type RustPraosBlockMessageType = - | "PraosBlockSent" - | "PraosBlockReceived" - | "PraosBlockLotteryWon" - | "PraosBlockGenerated"; +type BlockType = "Input" | "Endorser" | "Praos"; +type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated"; +type RustBlockMessageType = `${BlockType}Block${BlockAction}`; -interface RustPraosBlockEvent extends Omit { +interface RustBlockEvent extends Omit { message: RustBaseBlockEvent & { - type: RustPraosBlockMessageType; + type: RustBlockMessageType; + index?: number; header_bytes?: number; transactions?: string[]; vrf?: number; @@ -96,10 +64,8 @@ interface RustPraosBlockEvent extends Omit { } // Transaction Events -type RustTransactionMessageType = - | "TransactionSent" - | "TransactionReceived" - | "TransactionGenerated"; +type TransactionAction = "Sent" | "Received" | "Generated"; +type RustTransactionMessageType = `Transaction${TransactionAction}`; interface RustTransactionEvent extends Omit { message: { @@ -113,11 +79,8 @@ interface RustTransactionEvent extends Omit { } // Vote Events -type RustVoteMessageType = - | "VotesReceived" - | "VotesSent" - | "VotesGenerated" - | "VoteLotteryWon"; +type VoteAction = "Received" | "Sent" | "Generated" | "LotteryWon"; +type RustVoteMessageType = `Votes${VoteAction}`; interface RustVoteEvent extends Omit { message: { @@ -142,9 +105,7 @@ interface RustSlotEvent extends Omit { // Combined type export type RustTraceEvent = | RustCpuEvent - | RustInputBlockEvent - | RustEndorserBlockEvent - | RustPraosBlockEvent + | RustBlockEvent | RustTransactionEvent | RustVoteEvent | RustSlotEvent; diff --git a/data/simulation/trace.rust.schema.json b/data/simulation/trace.rust.schema.json index 1999cbf39..f346bf364 100644 --- a/data/simulation/trace.rust.schema.json +++ b/data/simulation/trace.rust.schema.json @@ -5,13 +5,7 @@ "$ref": "#/definitions/RustCpuEvent" }, { - "$ref": "#/definitions/RustInputBlockEvent" - }, - { - "$ref": "#/definitions/RustEndorserBlockEvent" - }, - { - "$ref": "#/definitions/RustPraosBlockEvent" + "$ref": "#/definitions/RustBlockEvent" }, { "$ref": "#/definitions/RustTransactionEvent" @@ -47,93 +41,7 @@ }, "type": "object" }, - "RustCpuEvent": { - "properties": { - "message": { - "properties": { - "extra": { - "type": "string" - }, - "subtask_id": { - "type": "number" - }, - "subtasks": { - "type": "number" - }, - "task": { - "$ref": "#/definitions/RustTaskInfo" - }, - "task_type": { - "$ref": "#/definitions/RustCpuTaskType" - }, - "type": { - "$ref": "#/definitions/RustCpuMessageType" - } - }, - "type": "object" - }, - "time": { - "type": "number" - } - }, - "type": "object" - }, - "RustCpuMessageType": { - "enum": [ - "CpuSubtaskFinished", - "CpuSubtaskStarted", - "CpuTaskFinished", - "CpuTaskScheduled" - ], - "type": "string" - }, - "RustCpuTaskType": { - "enum": [ - "EndorserBlockGenerated", - "EndorserBlockValidated", - "InputBlockGenerated", - "InputBlockValidated", - "PraosBlockGenerated", - "PraosBlockValidated", - "TransactionValidated", - "VoteBundleGenerated", - "VoteBundleValidated" - ], - "type": "string" - }, - "RustEndorserBlockEvent": { - "properties": { - "message": { - "allOf": [ - { - "$ref": "#/definitions/RustBaseBlockEvent" - }, - { - "properties": { - "type": { - "$ref": "#/definitions/RustEndorserBlockMessageType" - } - }, - "type": "object" - } - ] - }, - "time": { - "type": "number" - } - }, - "type": "object" - }, - "RustEndorserBlockMessageType": { - "enum": [ - "EndorserBlockGenerated", - "EndorserBlockLotteryWon", - "EndorserBlockReceived", - "EndorserBlockSent" - ], - "type": "string" - }, - "RustInputBlockEvent": { + "RustBlockEvent": { "properties": { "message": { "allOf": [ @@ -142,6 +50,7 @@ }, { "properties": { + "endorsement": {}, "header_bytes": { "type": "number" }, @@ -155,7 +64,10 @@ "type": "array" }, "type": { - "$ref": "#/definitions/RustInputBlockMessageType" + "$ref": "#/definitions/RustBlockMessageType" + }, + "vrf": { + "type": "number" } }, "type": "object" @@ -168,44 +80,47 @@ }, "type": "object" }, - "RustInputBlockMessageType": { + "RustBlockMessageType": { "enum": [ + "EndorserBlockGenerated", + "EndorserBlockLotteryWon", + "EndorserBlockReceived", + "EndorserBlockSent", "InputBlockGenerated", "InputBlockLotteryWon", "InputBlockReceived", - "InputBlockSent" + "InputBlockSent", + "PraosBlockGenerated", + "PraosBlockLotteryWon", + "PraosBlockReceived", + "PraosBlockSent" ], "type": "string" }, - "RustPraosBlockEvent": { + "RustCpuEvent": { "properties": { "message": { - "allOf": [ - { - "$ref": "#/definitions/RustBaseBlockEvent" + "properties": { + "extra": { + "type": "string" }, - { - "properties": { - "endorsement": {}, - "header_bytes": { - "type": "number" - }, - "transactions": { - "items": { - "type": "string" - }, - "type": "array" - }, - "type": { - "$ref": "#/definitions/RustPraosBlockMessageType" - }, - "vrf": { - "type": "number" - } - }, - "type": "object" + "subtask_id": { + "type": "number" + }, + "subtasks": { + "type": "number" + }, + "task": { + "$ref": "#/definitions/RustTaskInfo" + }, + "task_type": { + "$ref": "#/definitions/RustCpuTaskType" + }, + "type": { + "$ref": "#/definitions/RustCpuMessageType" } - ] + }, + "type": "object" }, "time": { "type": "number" @@ -213,12 +128,29 @@ }, "type": "object" }, - "RustPraosBlockMessageType": { + "RustCpuMessageType": { + "enum": [ + "CpuSubtaskFinished", + "CpuSubtaskScheduled", + "CpuSubtaskStarted", + "CpuTaskFinished", + "CpuTaskScheduled", + "CpuTaskStarted" + ], + "type": "string" + }, + "RustCpuTaskType": { "enum": [ + "EndorserBlockGenerated", + "EndorserBlockValidated", + "InputBlockGenerated", + "InputBlockValidated", "PraosBlockGenerated", - "PraosBlockLotteryWon", - "PraosBlockReceived", - "PraosBlockSent" + "PraosBlockValidated", + "TransactionGenerated", + "TransactionValidated", + "VoteBundleGenerated", + "VoteBundleValidated" ], "type": "string" }, @@ -328,8 +260,8 @@ }, "RustVoteMessageType": { "enum": [ - "VoteLotteryWon", "VotesGenerated", + "VotesLotteryWon", "VotesReceived", "VotesSent" ], From 9a64c9cfbf75e41ea9a3fe3cf2488b1f600234a2 Mon Sep 17 00:00:00 2001 From: William <9065638+will-break-it@users.noreply.github.com> Date: Mon, 24 Feb 2025 09:29:07 +0000 Subject: [PATCH 7/7] Trace Schema Changes (#202) * fix: add cpu_time_s field to track total CPU time across cores * fix: consistent naming of RBs across both simulations * refactor: naming of block variants * - refactor(hs) - separate block lifecycle actions from network actions - use shorter block type names (IB/EB/RB/VT) * fix(hs): remove node_name * fix: remove duration_s * fix: remove redundant block kind; tag -> type * fix(hs-schema): add endorse_blocks; payload_bytes * fix(hs-schema): add slot number to base block evnet * fix(hs-schema): remove duplicate payload_bytes for sent & receive events --- data/simulation/trace.haskell.d.ts | 90 +++++++++++++----------------- data/simulation/trace.rust.d.ts | 16 +++--- 2 files changed, 47 insertions(+), 59 deletions(-) diff --git a/data/simulation/trace.haskell.d.ts b/data/simulation/trace.haskell.d.ts index 7154d0a6f..a64b12d22 100644 --- a/data/simulation/trace.haskell.d.ts +++ b/data/simulation/trace.haskell.d.ts @@ -4,85 +4,71 @@ export interface HaskellTraceEvent { event: HaskellEvent; } -type MessageKind = "IB" | "EB" | "RB" | "VT"; +type BlockKind = "IB" | "EB" | "RB" | "VT"; +type BlockAction = "Generated" | "EnteredState"; type HaskellEvent = | HaskellCpuEvent - | HaskellGeneratedEvent - | HaskellSentEvent - | HaskellReceivedEvent - | HaskellStateEvent; + | HaskellBlockEvent // Unified block event type + | HaskellNetworkEvent; // Combine Sent/Received into network events interface HaskellCpuEvent { - tag: "Cpu"; - node: number; - node_name: string; - duration_s: number; + type: "Cpu"; + node: string; + cpu_time_s: number; // CPU task types: Block validation (ValIB, ValEB, ValRB), Header validation (ValIH, ValRH), Vote validation (ValVote). Format: ": " task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640" } -type HaskellGeneratedEvent = - | HaskellGeneratedIBEvent - | HaskellGeneratedEBEvent - | HaskellGeneratedRBEvent - | HaskellGeneratedVTEvent; +// Base block event interface with just identification info +interface BaseBlockEvent { + type: `${BlockKind}${BlockAction}`; + node: string; + id: string; + slot: number; +} -interface HaskellGeneratedBaseEvent { - tag: "generated"; - node: number; - node_name: string; +// Additional fields for Generated events +interface GeneratedBlockEvent extends BaseBlockEvent { size_bytes: number; } -interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent { - kind: "IB"; - id: string; - slot: number; +interface GeneratedInputBlock extends GeneratedBlockEvent { payload_bytes: number; rb_ref: string; } -interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent { - kind: "EB"; - id: string; +interface GeneratedEndorserBlock extends GeneratedBlockEvent { input_blocks: string[]; } -interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent { - kind: "RB"; - id: string; +interface GeneratedRankingBlock extends GeneratedBlockEvent { + endorse_blocks: string[]; + payload_bytes: number; } -interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent { - kind: "VT"; - id: string; +interface GeneratedVote extends GeneratedBlockEvent { votes: number; endorse_blocks: string[]; } -interface HaskellSentEvent { - tag: "Sent"; - sender: number; - receipient: number; +// EnteredState events only need the base identification info +type EnteredStateBlock = BaseBlockEvent; + +type HaskellBlockEvent = + | GeneratedInputBlock + | GeneratedEndorserBlock + | GeneratedRankingBlock + | GeneratedVote + | EnteredStateBlock; + +interface HaskellNetworkEvent { + type: "NetworkMessage"; + action: "Sent" | "Received"; // Added to distinguish direction + sender: string; + recipient: string; + block_kind: BlockKind; msg_size_bytes: number; sending_s: number; - kind: MessageKind; ids: string[]; } - -interface HaskellReceivedEvent { - tag: "received"; - kind: MessageKind; - id: string; - node: number; - node_name: string; -} - -interface HaskellStateEvent { - tag: "enteredstate"; - kind: MessageKind; - id: string; - node: number; - node_name: string; -} diff --git a/data/simulation/trace.rust.d.ts b/data/simulation/trace.rust.d.ts index 95e0aaab6..5814480f4 100644 --- a/data/simulation/trace.rust.d.ts +++ b/data/simulation/trace.rust.d.ts @@ -2,7 +2,7 @@ // Base types interface RustBaseEvent { - time: number; // nanoseconds + time_s: number; message: { type: string; [key: string]: any; @@ -16,10 +16,10 @@ interface RustTaskInfo { // CPU Events type BlockOrTaskType = - | "PraosBlock" - | "EndorserBlock" - | "VoteBundle" - | "InputBlock" + | "RBBlock" + | "EBBlock" + | "VTBundle" + | "IBBlock" | "Transaction"; type Action = "Validated" | "Generated"; type RustCpuTaskType = `${BlockOrTaskType}${Action}`; @@ -35,6 +35,8 @@ interface RustCpuEvent extends Omit { task_type?: RustCpuTaskType; subtasks?: number; subtask_id?: number; + duration_s?: number; + cpu_time_s?: number; extra?: string; }; } @@ -48,9 +50,9 @@ interface RustBaseBlockEvent { recipient?: string; } -type BlockType = "Input" | "Endorser" | "Praos"; +type BlockType = "IB" | "EB" | "RB"; type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated"; -type RustBlockMessageType = `${BlockType}Block${BlockAction}`; +type RustBlockMessageType = `${BlockType}${BlockAction}`; interface RustBlockEvent extends Omit { message: RustBaseBlockEvent & {