Skip to content

Commit d83aab2

Browse files
committed
data: add trace schema for haskell & rust
1 parent da6276d commit d83aab2

File tree

5 files changed

+711
-1
lines changed

5 files changed

+711
-1
lines changed

data/simulation/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
all: config.schema.json topology.schema.json
1+
all: config.schema.json topology.schema.json trace.haskell.schema.json trace.rust.schema.json
22

33
config.schema.json: config.d.ts
44
npx typescript-json-schema config.d.ts Config > config.schema.json
@@ -8,7 +8,17 @@ topology.schema.json: topology.d.ts
88
npx typescript-json-schema topology.d.ts Topology > topology.schema.json
99
npx prettier -w topology.schema.json
1010

11+
trace.haskell.schema.json: trace.haskell.d.ts
12+
npx typescript-json-schema trace.haskell.d.ts HaskellTraceEvent > trace.haskell.schema.json
13+
npx prettier -w trace.haskell.schema.json
14+
15+
trace.rust.schema.json: trace.rust.d.ts
16+
npx typescript-json-schema trace.rust.d.ts RustTraceEvent > trace.rust.schema.json
17+
npx prettier -w trace.rust.schema.json
18+
1119
.PHONY: validate
1220
validate:
1321
npx pajv -m schema.schema.json -s config.schema.json -d config.default.yaml
1422
npx pajv -m schema.schema.json -s topology.schema.json -d topology-dense-52.yaml
23+
npx pajv -m schema.schema.json -s trace.haskell.schema.json -d example.haskell.jsonl
24+
npx pajv -m schema.schema.json -s trace.rust.schema.json -d example.rust.jsonl

data/simulation/trace.haskell.d.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/** Haskell simulation trace format */
2+
export interface HaskellTraceEvent {
3+
time_s: number;
4+
event: HaskellEvent;
5+
}
6+
7+
type HaskellEvent =
8+
| HaskellCpuEvent
9+
| HaskellGeneratedEvent
10+
| HaskellSentEvent
11+
| HaskellReceivedEvent
12+
| HaskellStateEvent;
13+
14+
interface HaskellCpuEvent {
15+
tag: "Cpu";
16+
node: number;
17+
node_name: string;
18+
duration_s: number;
19+
// CPU task types: Block validation (ValIB, ValEB, ValRB), Header validation (ValIH, ValRH), Vote validation (ValVote). Format: "<task_type>: <id>"
20+
task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640"
21+
}
22+
23+
interface HaskellGeneratedEvent {
24+
tag: "generated";
25+
kind: "IB" | "EB" | "RB" | "VT";
26+
id: string;
27+
node: number;
28+
node_name: string;
29+
size_bytes: number;
30+
// Required for IB
31+
slot?: number;
32+
payload_bytes?: number;
33+
rb_ref?: string;
34+
// Required for EB
35+
input_blocks?: string[];
36+
// Required for VT
37+
votes?: number;
38+
endorse_blocks?: string[];
39+
}
40+
41+
interface HaskellSentEvent {
42+
tag: "Sent";
43+
sender: number;
44+
receipient: number;
45+
msg_size_bytes: number;
46+
sending_s: number;
47+
kind: "IB" | "EB" | "RB" | "VT";
48+
ids: string[];
49+
}
50+
51+
interface HaskellReceivedEvent {
52+
tag: "received";
53+
kind: "IB" | "EB" | "RB" | "VT";
54+
id: string;
55+
node: number;
56+
node_name: string;
57+
}
58+
59+
interface HaskellStateEvent {
60+
tag: "enteredstate";
61+
kind: "IB" | "EB" | "RB" | "VT";
62+
id: string;
63+
node: number;
64+
node_name: string;
65+
}
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"definitions": {
4+
"HaskellCpuEvent": {
5+
"properties": {
6+
"duration_s": {
7+
"type": "number"
8+
},
9+
"node": {
10+
"type": "number"
11+
},
12+
"node_name": {
13+
"type": "string"
14+
},
15+
"tag": {
16+
"const": "Cpu",
17+
"type": "string"
18+
},
19+
"task_label": {
20+
"description": "CPU task types:\n- Block validation: ValIB, ValEB, ValRB\n- Header validation: ValIH, ValRH\n- Vote validation: ValVote\nFormat: \"<task_type>: <id>\"",
21+
"type": "string"
22+
}
23+
},
24+
"type": "object"
25+
},
26+
"HaskellEvent": {
27+
"anyOf": [
28+
{
29+
"$ref": "#/definitions/HaskellCpuEvent"
30+
},
31+
{
32+
"$ref": "#/definitions/HaskellGeneratedEvent"
33+
},
34+
{
35+
"$ref": "#/definitions/HaskellSentEvent"
36+
},
37+
{
38+
"$ref": "#/definitions/HaskellReceivedEvent"
39+
},
40+
{
41+
"$ref": "#/definitions/HaskellStateEvent"
42+
}
43+
]
44+
},
45+
"HaskellGeneratedEvent": {
46+
"properties": {
47+
"endorse_blocks": {
48+
"items": {
49+
"type": "string"
50+
},
51+
"type": "array"
52+
},
53+
"id": {
54+
"type": "string"
55+
},
56+
"input_blocks": {
57+
"items": {
58+
"type": "string"
59+
},
60+
"type": "array"
61+
},
62+
"kind": {
63+
"enum": ["EB", "IB", "RB", "VT"],
64+
"type": "string"
65+
},
66+
"node": {
67+
"type": "number"
68+
},
69+
"node_name": {
70+
"type": "string"
71+
},
72+
"payload_bytes": {
73+
"type": "number"
74+
},
75+
"rb_ref": {
76+
"type": "string"
77+
},
78+
"size_bytes": {
79+
"type": "number"
80+
},
81+
"slot": {
82+
"type": "number"
83+
},
84+
"tag": {
85+
"const": "generated",
86+
"type": "string"
87+
},
88+
"votes": {
89+
"type": "number"
90+
}
91+
},
92+
"type": "object"
93+
},
94+
"HaskellReceivedEvent": {
95+
"properties": {
96+
"id": {
97+
"type": "string"
98+
},
99+
"kind": {
100+
"enum": ["EB", "IB", "RB", "VT"],
101+
"type": "string"
102+
},
103+
"node": {
104+
"type": "number"
105+
},
106+
"node_name": {
107+
"type": "string"
108+
},
109+
"tag": {
110+
"const": "received",
111+
"type": "string"
112+
}
113+
},
114+
"type": "object"
115+
},
116+
"HaskellSentEvent": {
117+
"properties": {
118+
"ids": {
119+
"items": {
120+
"type": "string"
121+
},
122+
"type": "array"
123+
},
124+
"kind": {
125+
"enum": ["EB", "IB", "RB", "VT"],
126+
"type": "string"
127+
},
128+
"msg_size_bytes": {
129+
"type": "number"
130+
},
131+
"receipient": {
132+
"type": "number"
133+
},
134+
"sender": {
135+
"type": "number"
136+
},
137+
"sending_s": {
138+
"type": "number"
139+
},
140+
"tag": {
141+
"const": "Sent",
142+
"type": "string"
143+
}
144+
},
145+
"type": "object"
146+
},
147+
"HaskellStateEvent": {
148+
"properties": {
149+
"id": {
150+
"type": "string"
151+
},
152+
"kind": {
153+
"enum": ["EB", "IB", "RB", "VT"],
154+
"type": "string"
155+
},
156+
"node": {
157+
"type": "number"
158+
},
159+
"node_name": {
160+
"type": "string"
161+
},
162+
"tag": {
163+
"const": "enteredstate",
164+
"type": "string"
165+
}
166+
},
167+
"type": "object"
168+
}
169+
},
170+
"description": "Haskell simulation trace format",
171+
"properties": {
172+
"event": {
173+
"$ref": "#/definitions/HaskellEvent"
174+
},
175+
"time_s": {
176+
"type": "number"
177+
}
178+
},
179+
"type": "object"
180+
}

0 commit comments

Comments
 (0)