Skip to content

Commit 9a64c9c

Browse files
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
1 parent aed2c2c commit 9a64c9c

File tree

2 files changed

+47
-59
lines changed

2 files changed

+47
-59
lines changed

data/simulation/trace.haskell.d.ts

+38-52
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,71 @@ export interface HaskellTraceEvent {
44
event: HaskellEvent;
55
}
66

7-
type MessageKind = "IB" | "EB" | "RB" | "VT";
7+
type BlockKind = "IB" | "EB" | "RB" | "VT";
8+
type BlockAction = "Generated" | "EnteredState";
89

910
type HaskellEvent =
1011
| HaskellCpuEvent
11-
| HaskellGeneratedEvent
12-
| HaskellSentEvent
13-
| HaskellReceivedEvent
14-
| HaskellStateEvent;
12+
| HaskellBlockEvent // Unified block event type
13+
| HaskellNetworkEvent; // Combine Sent/Received into network events
1514

1615
interface HaskellCpuEvent {
17-
tag: "Cpu";
18-
node: number;
19-
node_name: string;
20-
duration_s: number;
16+
type: "Cpu";
17+
node: string;
18+
cpu_time_s: number;
2119
// CPU task types: Block validation (ValIB, ValEB, ValRB), Header validation (ValIH, ValRH), Vote validation (ValVote). Format: "<task_type>: <id>"
2220
task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640"
2321
}
2422

25-
type HaskellGeneratedEvent =
26-
| HaskellGeneratedIBEvent
27-
| HaskellGeneratedEBEvent
28-
| HaskellGeneratedRBEvent
29-
| HaskellGeneratedVTEvent;
23+
// Base block event interface with just identification info
24+
interface BaseBlockEvent {
25+
type: `${BlockKind}${BlockAction}`;
26+
node: string;
27+
id: string;
28+
slot: number;
29+
}
3030

31-
interface HaskellGeneratedBaseEvent {
32-
tag: "generated";
33-
node: number;
34-
node_name: string;
31+
// Additional fields for Generated events
32+
interface GeneratedBlockEvent extends BaseBlockEvent {
3533
size_bytes: number;
3634
}
3735

38-
interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent {
39-
kind: "IB";
40-
id: string;
41-
slot: number;
36+
interface GeneratedInputBlock extends GeneratedBlockEvent {
4237
payload_bytes: number;
4338
rb_ref: string;
4439
}
4540

46-
interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent {
47-
kind: "EB";
48-
id: string;
41+
interface GeneratedEndorserBlock extends GeneratedBlockEvent {
4942
input_blocks: string[];
5043
}
5144

52-
interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent {
53-
kind: "RB";
54-
id: string;
45+
interface GeneratedRankingBlock extends GeneratedBlockEvent {
46+
endorse_blocks: string[];
47+
payload_bytes: number;
5548
}
5649

57-
interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent {
58-
kind: "VT";
59-
id: string;
50+
interface GeneratedVote extends GeneratedBlockEvent {
6051
votes: number;
6152
endorse_blocks: string[];
6253
}
6354

64-
interface HaskellSentEvent {
65-
tag: "Sent";
66-
sender: number;
67-
receipient: number;
55+
// EnteredState events only need the base identification info
56+
type EnteredStateBlock = BaseBlockEvent;
57+
58+
type HaskellBlockEvent =
59+
| GeneratedInputBlock
60+
| GeneratedEndorserBlock
61+
| GeneratedRankingBlock
62+
| GeneratedVote
63+
| EnteredStateBlock;
64+
65+
interface HaskellNetworkEvent {
66+
type: "NetworkMessage";
67+
action: "Sent" | "Received"; // Added to distinguish direction
68+
sender: string;
69+
recipient: string;
70+
block_kind: BlockKind;
6871
msg_size_bytes: number;
6972
sending_s: number;
70-
kind: MessageKind;
7173
ids: string[];
7274
}
73-
74-
interface HaskellReceivedEvent {
75-
tag: "received";
76-
kind: MessageKind;
77-
id: string;
78-
node: number;
79-
node_name: string;
80-
}
81-
82-
interface HaskellStateEvent {
83-
tag: "enteredstate";
84-
kind: MessageKind;
85-
id: string;
86-
node: number;
87-
node_name: string;
88-
}

data/simulation/trace.rust.d.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Base types
44
interface RustBaseEvent {
5-
time: number; // nanoseconds
5+
time_s: number;
66
message: {
77
type: string;
88
[key: string]: any;
@@ -16,10 +16,10 @@ interface RustTaskInfo {
1616

1717
// CPU Events
1818
type BlockOrTaskType =
19-
| "PraosBlock"
20-
| "EndorserBlock"
21-
| "VoteBundle"
22-
| "InputBlock"
19+
| "RBBlock"
20+
| "EBBlock"
21+
| "VTBundle"
22+
| "IBBlock"
2323
| "Transaction";
2424
type Action = "Validated" | "Generated";
2525
type RustCpuTaskType = `${BlockOrTaskType}${Action}`;
@@ -35,6 +35,8 @@ interface RustCpuEvent extends Omit<RustBaseEvent, "message"> {
3535
task_type?: RustCpuTaskType;
3636
subtasks?: number;
3737
subtask_id?: number;
38+
duration_s?: number;
39+
cpu_time_s?: number;
3840
extra?: string;
3941
};
4042
}
@@ -48,9 +50,9 @@ interface RustBaseBlockEvent {
4850
recipient?: string;
4951
}
5052

51-
type BlockType = "Input" | "Endorser" | "Praos";
53+
type BlockType = "IB" | "EB" | "RB";
5254
type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated";
53-
type RustBlockMessageType = `${BlockType}Block${BlockAction}`;
55+
type RustBlockMessageType = `${BlockType}${BlockAction}`;
5456

5557
interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
5658
message: RustBaseBlockEvent & {

0 commit comments

Comments
 (0)