Skip to content

Commit aed2c2c

Browse files
committed
data: composed rust message & action types
1 parent 84d7bd1 commit aed2c2c

File tree

2 files changed

+82
-189
lines changed

2 files changed

+82
-189
lines changed

data/simulation/trace.rust.d.ts

Lines changed: 23 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ interface RustTaskInfo {
1515
}
1616

1717
// CPU Events
18-
type RustCpuTaskType =
19-
| "PraosBlockValidated"
20-
| "EndorserBlockValidated"
21-
| "VoteBundleValidated"
22-
| "EndorserBlockGenerated"
23-
| "VoteBundleGenerated"
24-
| "InputBlockValidated"
25-
| "InputBlockGenerated"
26-
| "TransactionValidated"
27-
| "PraosBlockGenerated";
28-
29-
type RustCpuMessageType =
30-
| "CpuTaskScheduled"
31-
| "CpuTaskFinished"
32-
| "CpuSubtaskStarted"
33-
| "CpuSubtaskFinished";
18+
type BlockOrTaskType =
19+
| "PraosBlock"
20+
| "EndorserBlock"
21+
| "VoteBundle"
22+
| "InputBlock"
23+
| "Transaction";
24+
type Action = "Validated" | "Generated";
25+
type RustCpuTaskType = `${BlockOrTaskType}${Action}`;
26+
27+
type CpuTaskPrefix = "CpuTask" | "CpuSubtask";
28+
type CpuTaskAction = "Scheduled" | "Started" | "Finished";
29+
type RustCpuMessageType = `${CpuTaskPrefix}${CpuTaskAction}`;
3430

3531
interface RustCpuEvent extends Omit<RustBaseEvent, "message"> {
3632
message: {
@@ -52,42 +48,14 @@ interface RustBaseBlockEvent {
5248
recipient?: string;
5349
}
5450

55-
type RustInputBlockMessageType =
56-
| "InputBlockSent"
57-
| "InputBlockReceived"
58-
| "InputBlockLotteryWon"
59-
| "InputBlockGenerated";
60-
61-
interface RustInputBlockEvent extends Omit<RustBaseEvent, "message"> {
62-
message: RustBaseBlockEvent & {
63-
type: RustInputBlockMessageType;
64-
index: number;
65-
header_bytes?: number;
66-
transactions?: string[];
67-
};
68-
}
69-
70-
type RustEndorserBlockMessageType =
71-
| "EndorserBlockSent"
72-
| "EndorserBlockReceived"
73-
| "EndorserBlockLotteryWon"
74-
| "EndorserBlockGenerated";
75-
76-
interface RustEndorserBlockEvent extends Omit<RustBaseEvent, "message"> {
77-
message: RustBaseBlockEvent & {
78-
type: RustEndorserBlockMessageType;
79-
};
80-
}
81-
82-
type RustPraosBlockMessageType =
83-
| "PraosBlockSent"
84-
| "PraosBlockReceived"
85-
| "PraosBlockLotteryWon"
86-
| "PraosBlockGenerated";
51+
type BlockType = "Input" | "Endorser" | "Praos";
52+
type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated";
53+
type RustBlockMessageType = `${BlockType}Block${BlockAction}`;
8754

88-
interface RustPraosBlockEvent extends Omit<RustBaseEvent, "message"> {
55+
interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
8956
message: RustBaseBlockEvent & {
90-
type: RustPraosBlockMessageType;
57+
type: RustBlockMessageType;
58+
index?: number;
9159
header_bytes?: number;
9260
transactions?: string[];
9361
vrf?: number;
@@ -96,10 +64,8 @@ interface RustPraosBlockEvent extends Omit<RustBaseEvent, "message"> {
9664
}
9765

9866
// Transaction Events
99-
type RustTransactionMessageType =
100-
| "TransactionSent"
101-
| "TransactionReceived"
102-
| "TransactionGenerated";
67+
type TransactionAction = "Sent" | "Received" | "Generated";
68+
type RustTransactionMessageType = `Transaction${TransactionAction}`;
10369

10470
interface RustTransactionEvent extends Omit<RustBaseEvent, "message"> {
10571
message: {
@@ -113,11 +79,8 @@ interface RustTransactionEvent extends Omit<RustBaseEvent, "message"> {
11379
}
11480

11581
// Vote Events
116-
type RustVoteMessageType =
117-
| "VotesReceived"
118-
| "VotesSent"
119-
| "VotesGenerated"
120-
| "VoteLotteryWon";
82+
type VoteAction = "Received" | "Sent" | "Generated" | "LotteryWon";
83+
type RustVoteMessageType = `Votes${VoteAction}`;
12184

12285
interface RustVoteEvent extends Omit<RustBaseEvent, "message"> {
12386
message: {
@@ -142,9 +105,7 @@ interface RustSlotEvent extends Omit<RustBaseEvent, "message"> {
142105
// Combined type
143106
export type RustTraceEvent =
144107
| RustCpuEvent
145-
| RustInputBlockEvent
146-
| RustEndorserBlockEvent
147-
| RustPraosBlockEvent
108+
| RustBlockEvent
148109
| RustTransactionEvent
149110
| RustVoteEvent
150111
| RustSlotEvent;

data/simulation/trace.rust.schema.json

Lines changed: 59 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
"$ref": "#/definitions/RustCpuEvent"
66
},
77
{
8-
"$ref": "#/definitions/RustInputBlockEvent"
9-
},
10-
{
11-
"$ref": "#/definitions/RustEndorserBlockEvent"
12-
},
13-
{
14-
"$ref": "#/definitions/RustPraosBlockEvent"
8+
"$ref": "#/definitions/RustBlockEvent"
159
},
1610
{
1711
"$ref": "#/definitions/RustTransactionEvent"
@@ -47,93 +41,7 @@
4741
},
4842
"type": "object"
4943
},
50-
"RustCpuEvent": {
51-
"properties": {
52-
"message": {
53-
"properties": {
54-
"extra": {
55-
"type": "string"
56-
},
57-
"subtask_id": {
58-
"type": "number"
59-
},
60-
"subtasks": {
61-
"type": "number"
62-
},
63-
"task": {
64-
"$ref": "#/definitions/RustTaskInfo"
65-
},
66-
"task_type": {
67-
"$ref": "#/definitions/RustCpuTaskType"
68-
},
69-
"type": {
70-
"$ref": "#/definitions/RustCpuMessageType"
71-
}
72-
},
73-
"type": "object"
74-
},
75-
"time": {
76-
"type": "number"
77-
}
78-
},
79-
"type": "object"
80-
},
81-
"RustCpuMessageType": {
82-
"enum": [
83-
"CpuSubtaskFinished",
84-
"CpuSubtaskStarted",
85-
"CpuTaskFinished",
86-
"CpuTaskScheduled"
87-
],
88-
"type": "string"
89-
},
90-
"RustCpuTaskType": {
91-
"enum": [
92-
"EndorserBlockGenerated",
93-
"EndorserBlockValidated",
94-
"InputBlockGenerated",
95-
"InputBlockValidated",
96-
"PraosBlockGenerated",
97-
"PraosBlockValidated",
98-
"TransactionValidated",
99-
"VoteBundleGenerated",
100-
"VoteBundleValidated"
101-
],
102-
"type": "string"
103-
},
104-
"RustEndorserBlockEvent": {
105-
"properties": {
106-
"message": {
107-
"allOf": [
108-
{
109-
"$ref": "#/definitions/RustBaseBlockEvent"
110-
},
111-
{
112-
"properties": {
113-
"type": {
114-
"$ref": "#/definitions/RustEndorserBlockMessageType"
115-
}
116-
},
117-
"type": "object"
118-
}
119-
]
120-
},
121-
"time": {
122-
"type": "number"
123-
}
124-
},
125-
"type": "object"
126-
},
127-
"RustEndorserBlockMessageType": {
128-
"enum": [
129-
"EndorserBlockGenerated",
130-
"EndorserBlockLotteryWon",
131-
"EndorserBlockReceived",
132-
"EndorserBlockSent"
133-
],
134-
"type": "string"
135-
},
136-
"RustInputBlockEvent": {
44+
"RustBlockEvent": {
13745
"properties": {
13846
"message": {
13947
"allOf": [
@@ -142,6 +50,7 @@
14250
},
14351
{
14452
"properties": {
53+
"endorsement": {},
14554
"header_bytes": {
14655
"type": "number"
14756
},
@@ -155,7 +64,10 @@
15564
"type": "array"
15665
},
15766
"type": {
158-
"$ref": "#/definitions/RustInputBlockMessageType"
67+
"$ref": "#/definitions/RustBlockMessageType"
68+
},
69+
"vrf": {
70+
"type": "number"
15971
}
16072
},
16173
"type": "object"
@@ -168,57 +80,77 @@
16880
},
16981
"type": "object"
17082
},
171-
"RustInputBlockMessageType": {
83+
"RustBlockMessageType": {
17284
"enum": [
85+
"EndorserBlockGenerated",
86+
"EndorserBlockLotteryWon",
87+
"EndorserBlockReceived",
88+
"EndorserBlockSent",
17389
"InputBlockGenerated",
17490
"InputBlockLotteryWon",
17591
"InputBlockReceived",
176-
"InputBlockSent"
92+
"InputBlockSent",
93+
"PraosBlockGenerated",
94+
"PraosBlockLotteryWon",
95+
"PraosBlockReceived",
96+
"PraosBlockSent"
17797
],
17898
"type": "string"
17999
},
180-
"RustPraosBlockEvent": {
100+
"RustCpuEvent": {
181101
"properties": {
182102
"message": {
183-
"allOf": [
184-
{
185-
"$ref": "#/definitions/RustBaseBlockEvent"
103+
"properties": {
104+
"extra": {
105+
"type": "string"
186106
},
187-
{
188-
"properties": {
189-
"endorsement": {},
190-
"header_bytes": {
191-
"type": "number"
192-
},
193-
"transactions": {
194-
"items": {
195-
"type": "string"
196-
},
197-
"type": "array"
198-
},
199-
"type": {
200-
"$ref": "#/definitions/RustPraosBlockMessageType"
201-
},
202-
"vrf": {
203-
"type": "number"
204-
}
205-
},
206-
"type": "object"
107+
"subtask_id": {
108+
"type": "number"
109+
},
110+
"subtasks": {
111+
"type": "number"
112+
},
113+
"task": {
114+
"$ref": "#/definitions/RustTaskInfo"
115+
},
116+
"task_type": {
117+
"$ref": "#/definitions/RustCpuTaskType"
118+
},
119+
"type": {
120+
"$ref": "#/definitions/RustCpuMessageType"
207121
}
208-
]
122+
},
123+
"type": "object"
209124
},
210125
"time": {
211126
"type": "number"
212127
}
213128
},
214129
"type": "object"
215130
},
216-
"RustPraosBlockMessageType": {
131+
"RustCpuMessageType": {
132+
"enum": [
133+
"CpuSubtaskFinished",
134+
"CpuSubtaskScheduled",
135+
"CpuSubtaskStarted",
136+
"CpuTaskFinished",
137+
"CpuTaskScheduled",
138+
"CpuTaskStarted"
139+
],
140+
"type": "string"
141+
},
142+
"RustCpuTaskType": {
217143
"enum": [
144+
"EndorserBlockGenerated",
145+
"EndorserBlockValidated",
146+
"InputBlockGenerated",
147+
"InputBlockValidated",
218148
"PraosBlockGenerated",
219-
"PraosBlockLotteryWon",
220-
"PraosBlockReceived",
221-
"PraosBlockSent"
149+
"PraosBlockValidated",
150+
"TransactionGenerated",
151+
"TransactionValidated",
152+
"VoteBundleGenerated",
153+
"VoteBundleValidated"
222154
],
223155
"type": "string"
224156
},
@@ -328,8 +260,8 @@
328260
},
329261
"RustVoteMessageType": {
330262
"enum": [
331-
"VoteLotteryWon",
332263
"VotesGenerated",
264+
"VotesLotteryWon",
333265
"VotesReceived",
334266
"VotesSent"
335267
],

0 commit comments

Comments
 (0)