Skip to content

Commit eb8b987

Browse files
committed
data: simplify haskell trace schema
1 parent c5944d7 commit eb8b987

File tree

2 files changed

+138
-31
lines changed

2 files changed

+138
-31
lines changed

data/simulation/trace.haskell.d.ts

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export interface HaskellTraceEvent {
44
event: HaskellEvent;
55
}
66

7+
type MessageKind = "IB" | "EB" | "RB" | "VT";
8+
79
type HaskellEvent =
810
| HaskellCpuEvent
911
| HaskellGeneratedEvent
@@ -20,22 +22,43 @@ interface HaskellCpuEvent {
2022
task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640"
2123
}
2224

23-
interface HaskellGeneratedEvent {
25+
type HaskellGeneratedEvent =
26+
| HaskellGeneratedIBEvent
27+
| HaskellGeneratedEBEvent
28+
| HaskellGeneratedRBEvent
29+
| HaskellGeneratedVTEvent;
30+
31+
interface HaskellGeneratedBaseEvent {
2432
tag: "generated";
25-
kind: "IB" | "EB" | "RB" | "VT";
26-
id: string;
2733
node: number;
2834
node_name: string;
2935
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[];
36+
}
37+
38+
interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent {
39+
kind: Extract<MessageKind, "IB">;
40+
id: string;
41+
slot: number;
42+
payload_bytes: number;
43+
rb_ref: string;
44+
}
45+
46+
interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent {
47+
kind: Extract<MessageKind, "EB">;
48+
id: string;
49+
input_blocks: string[];
50+
}
51+
52+
interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent {
53+
kind: Extract<MessageKind, "RB">;
54+
id: string;
55+
}
56+
57+
interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent {
58+
kind: Extract<MessageKind, "VT">;
59+
id: string;
60+
votes: number;
61+
endorse_blocks: string[];
3962
}
4063

4164
interface HaskellSentEvent {
@@ -44,21 +67,21 @@ interface HaskellSentEvent {
4467
receipient: number;
4568
msg_size_bytes: number;
4669
sending_s: number;
47-
kind: "IB" | "EB" | "RB" | "VT";
70+
kind: MessageKind;
4871
ids: string[];
4972
}
5073

5174
interface HaskellReceivedEvent {
5275
tag: "received";
53-
kind: "IB" | "EB" | "RB" | "VT";
76+
kind: MessageKind;
5477
id: string;
5578
node: number;
5679
node_name: string;
5780
}
5881

5982
interface HaskellStateEvent {
6083
tag: "enteredstate";
61-
kind: "IB" | "EB" | "RB" | "VT";
84+
kind: MessageKind;
6285
id: string;
6386
node: number;
6487
node_name: string;

data/simulation/trace.haskell.schema.json

Lines changed: 100 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"type": "string"
1818
},
1919
"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>\"",
2120
"type": "string"
2221
}
2322
},
@@ -29,7 +28,16 @@
2928
"$ref": "#/definitions/HaskellCpuEvent"
3029
},
3130
{
32-
"$ref": "#/definitions/HaskellGeneratedEvent"
31+
"$ref": "#/definitions/HaskellGeneratedIBEvent"
32+
},
33+
{
34+
"$ref": "#/definitions/HaskellGeneratedEBEvent"
35+
},
36+
{
37+
"$ref": "#/definitions/HaskellGeneratedRBEvent"
38+
},
39+
{
40+
"$ref": "#/definitions/HaskellGeneratedVTEvent"
3341
},
3442
{
3543
"$ref": "#/definitions/HaskellSentEvent"
@@ -42,14 +50,8 @@
4250
}
4351
]
4452
},
45-
"HaskellGeneratedEvent": {
53+
"HaskellGeneratedEBEvent": {
4654
"properties": {
47-
"endorse_blocks": {
48-
"items": {
49-
"type": "string"
50-
},
51-
"type": "array"
52-
},
5355
"id": {
5456
"type": "string"
5557
},
@@ -60,7 +62,32 @@
6062
"type": "array"
6163
},
6264
"kind": {
63-
"enum": ["EB", "IB", "RB", "VT"],
65+
"const": "EB",
66+
"type": "string"
67+
},
68+
"node": {
69+
"type": "number"
70+
},
71+
"node_name": {
72+
"type": "string"
73+
},
74+
"size_bytes": {
75+
"type": "number"
76+
},
77+
"tag": {
78+
"const": "generated",
79+
"type": "string"
80+
}
81+
},
82+
"type": "object"
83+
},
84+
"HaskellGeneratedIBEvent": {
85+
"properties": {
86+
"id": {
87+
"type": "string"
88+
},
89+
"kind": {
90+
"const": "IB",
6491
"type": "string"
6592
},
6693
"node": {
@@ -81,6 +108,62 @@
81108
"slot": {
82109
"type": "number"
83110
},
111+
"tag": {
112+
"const": "generated",
113+
"type": "string"
114+
}
115+
},
116+
"type": "object"
117+
},
118+
"HaskellGeneratedRBEvent": {
119+
"properties": {
120+
"id": {
121+
"type": "string"
122+
},
123+
"kind": {
124+
"const": "RB",
125+
"type": "string"
126+
},
127+
"node": {
128+
"type": "number"
129+
},
130+
"node_name": {
131+
"type": "string"
132+
},
133+
"size_bytes": {
134+
"type": "number"
135+
},
136+
"tag": {
137+
"const": "generated",
138+
"type": "string"
139+
}
140+
},
141+
"type": "object"
142+
},
143+
"HaskellGeneratedVTEvent": {
144+
"properties": {
145+
"endorse_blocks": {
146+
"items": {
147+
"type": "string"
148+
},
149+
"type": "array"
150+
},
151+
"id": {
152+
"type": "string"
153+
},
154+
"kind": {
155+
"const": "VT",
156+
"type": "string"
157+
},
158+
"node": {
159+
"type": "number"
160+
},
161+
"node_name": {
162+
"type": "string"
163+
},
164+
"size_bytes": {
165+
"type": "number"
166+
},
84167
"tag": {
85168
"const": "generated",
86169
"type": "string"
@@ -97,8 +180,7 @@
97180
"type": "string"
98181
},
99182
"kind": {
100-
"enum": ["EB", "IB", "RB", "VT"],
101-
"type": "string"
183+
"$ref": "#/definitions/MessageKind"
102184
},
103185
"node": {
104186
"type": "number"
@@ -122,8 +204,7 @@
122204
"type": "array"
123205
},
124206
"kind": {
125-
"enum": ["EB", "IB", "RB", "VT"],
126-
"type": "string"
207+
"$ref": "#/definitions/MessageKind"
127208
},
128209
"msg_size_bytes": {
129210
"type": "number"
@@ -150,8 +231,7 @@
150231
"type": "string"
151232
},
152233
"kind": {
153-
"enum": ["EB", "IB", "RB", "VT"],
154-
"type": "string"
234+
"$ref": "#/definitions/MessageKind"
155235
},
156236
"node": {
157237
"type": "number"
@@ -165,6 +245,10 @@
165245
}
166246
},
167247
"type": "object"
248+
},
249+
"MessageKind": {
250+
"enum": ["EB", "IB", "RB", "VT"],
251+
"type": "string"
168252
}
169253
},
170254
"description": "Haskell simulation trace format",

0 commit comments

Comments
 (0)