11/** Rust simulation trace format */
22
33// Base types
4- interface BaseEvent {
4+ interface RustBaseEvent {
55 time : number ; // nanoseconds
6+ message : {
7+ type : string ;
8+ [ key : string ] : any ;
9+ } ;
610}
711
8- interface TaskInfo {
12+ interface RustTaskInfo {
913 node : string ;
1014 index : number ;
1115}
1216
1317// CPU Events
14- type CpuTaskType =
18+ type RustCpuTaskType =
1519 | "PraosBlockValidated"
1620 | "EndorserBlockValidated"
1721 | "VoteBundleValidated"
@@ -22,60 +26,68 @@ type CpuTaskType =
2226 | "TransactionValidated"
2327 | "PraosBlockGenerated" ;
2428
25- interface CpuEvent extends BaseEvent {
29+ type RustCpuMessageType =
30+ | "CpuTaskScheduled"
31+ | "CpuTaskFinished"
32+ | "CpuSubtaskStarted"
33+ | "CpuSubtaskFinished" ;
34+
35+ interface RustCpuEvent extends Omit < RustBaseEvent , "message" > {
2636 message : {
27- type :
28- | "CpuTaskScheduled"
29- | "CpuTaskFinished"
30- | "CpuSubtaskStarted"
31- | "CpuSubtaskFinished" ;
32- task : TaskInfo ;
33- task_type ?: CpuTaskType ;
37+ type : RustCpuMessageType ;
38+ task : RustTaskInfo ;
39+ task_type ?: RustCpuTaskType ;
3440 subtasks ?: number ;
3541 subtask_id ?: number ;
3642 extra ?: string ;
3743 } ;
3844}
3945
4046// Block Events
41- interface BaseBlockEvent {
47+ interface RustBaseBlockEvent {
4248 id ?: string ;
4349 slot : number ;
4450 producer : string ;
4551 sender ?: string ;
4652 recipient ?: string ;
4753}
4854
49- interface InputBlockEvent extends BaseEvent {
50- message : BaseBlockEvent & {
51- type :
52- | "InputBlockSent"
53- | "InputBlockReceived"
54- | "InputBlockLotteryWon"
55- | "InputBlockGenerated" ;
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 ;
5664 index : number ;
5765 header_bytes ?: number ;
5866 transactions ?: string [ ] ;
5967 } ;
6068}
6169
62- interface EndorserBlockEvent extends BaseEvent {
63- message : BaseBlockEvent & {
64- type :
65- | "EndorserBlockSent"
66- | "EndorserBlockReceived"
67- | "EndorserBlockLotteryWon"
68- | "EndorserBlockGenerated" ;
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 ;
6979 } ;
7080}
7181
72- interface PraosBlockEvent extends BaseEvent {
73- message : BaseBlockEvent & {
74- type :
75- | "PraosBlockSent"
76- | "PraosBlockReceived"
77- | "PraosBlockLotteryWon"
78- | "PraosBlockGenerated" ;
82+ type RustPraosBlockMessageType =
83+ | "PraosBlockSent"
84+ | "PraosBlockReceived"
85+ | "PraosBlockLotteryWon"
86+ | "PraosBlockGenerated" ;
87+
88+ interface RustPraosBlockEvent extends Omit < RustBaseEvent , "message" > {
89+ message : RustBaseBlockEvent & {
90+ type : RustPraosBlockMessageType ;
7991 header_bytes ?: number ;
8092 transactions ?: string [ ] ;
8193 vrf ?: number ;
@@ -84,12 +96,14 @@ interface PraosBlockEvent extends BaseEvent {
8496}
8597
8698// Transaction Events
87- interface TransactionEvent extends BaseEvent {
99+ type RustTransactionMessageType =
100+ | "TransactionSent"
101+ | "TransactionReceived"
102+ | "TransactionGenerated" ;
103+
104+ interface RustTransactionEvent extends Omit < RustBaseEvent , "message" > {
88105 message : {
89- type :
90- | "TransactionSent"
91- | "TransactionReceived"
92- | "TransactionGenerated" ;
106+ type : RustTransactionMessageType ;
93107 id : string ;
94108 sender ?: string ;
95109 recipient ?: string ;
@@ -99,13 +113,15 @@ interface TransactionEvent extends BaseEvent {
99113}
100114
101115// Vote Events
102- interface VoteEvent extends BaseEvent {
116+ type RustVoteMessageType =
117+ | "VotesReceived"
118+ | "VotesSent"
119+ | "VotesGenerated"
120+ | "VoteLotteryWon" ;
121+
122+ interface RustVoteEvent extends Omit < RustBaseEvent , "message" > {
103123 message : {
104- type :
105- | "VotesReceived"
106- | "VotesSent"
107- | "VotesGenerated"
108- | "VoteLotteryWon" ;
124+ type : RustVoteMessageType ;
109125 id : string ;
110126 slot : number ;
111127 producer : string ;
@@ -116,7 +132,7 @@ interface VoteEvent extends BaseEvent {
116132}
117133
118134// Slot Event
119- interface SlotEvent extends BaseEvent {
135+ interface RustSlotEvent extends Omit < RustBaseEvent , "message" > {
120136 message : {
121137 type : "Slot" ;
122138 number : number ;
@@ -125,10 +141,10 @@ interface SlotEvent extends BaseEvent {
125141
126142// Combined type
127143export type RustTraceEvent =
128- | CpuEvent
129- | InputBlockEvent
130- | EndorserBlockEvent
131- | PraosBlockEvent
132- | TransactionEvent
133- | VoteEvent
134- | SlotEvent ;
144+ | RustCpuEvent
145+ | RustInputBlockEvent
146+ | RustEndorserBlockEvent
147+ | RustPraosBlockEvent
148+ | RustTransactionEvent
149+ | RustVoteEvent
150+ | RustSlotEvent ;
0 commit comments