Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace Schema Changes #202

Merged
merged 10 commits into from
Feb 24, 2025
82 changes: 32 additions & 50 deletions data/simulation/trace.haskell.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,67 @@ export interface HaskellTraceEvent {
event: HaskellEvent;
}

type MessageKind = "IB" | "EB" | "RB" | "VT";
type BlockKind = "IB" | "EB" | "RB" | "VT";
type BlockAction = "Generated" | "EnteredState";

type HaskellEvent =
| HaskellCpuEvent
| HaskellGeneratedEvent
| HaskellSentEvent
| HaskellReceivedEvent
| HaskellStateEvent;
| HaskellBlockEvent // Unified block event type
| HaskellNetworkEvent; // Combine Sent/Received into network events

interface HaskellCpuEvent {
tag: "Cpu";
node: number;
node_name: string;
duration_s: number;
node: string;
cpu_time_s: number;
// CPU task types: Block validation (ValIB, ValEB, ValRB), Header validation (ValIH, ValRH), Vote validation (ValVote). Format: "<task_type>: <id>"
task_label: string; // e.g., "ValIB: 6-29" or "ValRH: 6253064077348247640"
}

type HaskellGeneratedEvent =
| HaskellGeneratedIBEvent
| HaskellGeneratedEBEvent
| HaskellGeneratedRBEvent
| HaskellGeneratedVTEvent;

interface HaskellGeneratedBaseEvent {
tag: "generated";
node: number;
node_name: string;
// Base block event interface
interface BaseBlockEvent {
type: `${BlockKind}${BlockAction}`;
node: string;
id: string;
size_bytes: number;
}

interface HaskellGeneratedIBEvent extends HaskellGeneratedBaseEvent {
interface InputBlockEvent extends BaseBlockEvent {
kind: "IB";
id: string;
slot: number;
payload_bytes: number;
rb_ref: string;
rb_ref: string; // Reference to ranking block
}

interface HaskellGeneratedEBEvent extends HaskellGeneratedBaseEvent {
interface EndorserBlockEvent extends BaseBlockEvent {
kind: "EB";
id: string;
input_blocks: string[];
slot: number;
input_blocks: string[]; // References to input blocks
}

interface HaskellGeneratedRBEvent extends HaskellGeneratedBaseEvent {
interface RankingBlockEvent extends BaseBlockEvent {
kind: "RB";
id: string;
slot: number;
}

interface HaskellGeneratedVTEvent extends HaskellGeneratedBaseEvent {
interface VoteEvent extends BaseBlockEvent {
kind: "VT";
id: string;
votes: number;
endorse_blocks: string[];
endorse_blocks: string[]; // References to endorser blocks
}

interface HaskellSentEvent {
tag: "Sent";
sender: number;
receipient: number;
type HaskellBlockEvent =
| InputBlockEvent
| EndorserBlockEvent
| RankingBlockEvent
| VoteEvent;

interface HaskellNetworkEvent {
type: "NetworkMessage";
action: "Sent" | "Received"; // Added to distinguish direction
sender: string;
recipient: string;
block_kind: BlockKind;
msg_size_bytes: number;
sending_s: number;
kind: MessageKind;
ids: string[];
}

interface HaskellReceivedEvent {
tag: "received";
kind: MessageKind;
id: string;
node: number;
node_name: string;
}

interface HaskellStateEvent {
tag: "enteredstate";
kind: MessageKind;
id: string;
node: number;
node_name: string;
}
16 changes: 9 additions & 7 deletions data/simulation/trace.rust.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Base types
interface RustBaseEvent {
time: number; // nanoseconds
time_s: number;
message: {
type: string;
[key: string]: any;
Expand All @@ -16,10 +16,10 @@ interface RustTaskInfo {

// CPU Events
type BlockOrTaskType =
| "PraosBlock"
| "EndorserBlock"
| "VoteBundle"
| "InputBlock"
| "RBBlock"
| "EBBlock"
| "VTBundle"
| "IBBlock"
| "Transaction";
type Action = "Validated" | "Generated";
type RustCpuTaskType = `${BlockOrTaskType}${Action}`;
Expand All @@ -35,6 +35,8 @@ interface RustCpuEvent extends Omit<RustBaseEvent, "message"> {
task_type?: RustCpuTaskType;
subtasks?: number;
subtask_id?: number;
duration_s?: number;
cpu_time_s?: number;
extra?: string;
};
}
Expand All @@ -48,9 +50,9 @@ interface RustBaseBlockEvent {
recipient?: string;
}

type BlockType = "Input" | "Endorser" | "Praos";
type BlockType = "IB" | "EB" | "RB";
type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated";
type RustBlockMessageType = `${BlockType}Block${BlockAction}`;
type RustBlockMessageType = `${BlockType}${BlockAction}`;

interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
message: RustBaseBlockEvent & {
Expand Down