Skip to content

Commit 4bb36d5

Browse files
committed
leios-trace-hs: updated LeiosEvent to trace.shared.d.ts schema.
1 parent bbb47d3 commit 4bb36d5

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

leios-trace-hs/src/LeiosEvents.hs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import GHC.Generics
2828

2929
type Bytes = Word64
3030
type SlotNo = Word64
31+
type PipelineNo = Word64
3132
type Time = Micro
3233

3334
data NetworkAction = Sent | Received
@@ -44,11 +45,34 @@ data Endorsement = Endorsement {eb :: BlockRef}
4445
data BlockRef = BlockRef {id :: Text}
4546
deriving (Eq, Show, Generic, ToJSON, FromJSON)
4647

48+
newtype Nullable a = Nullable (Maybe a)
49+
deriving (Eq, Show)
50+
51+
instance ToJSON a => ToJSON (Nullable a) where
52+
omitField _ = False
53+
toJSON (Nullable x) = toJSON x
54+
toEncoding (Nullable x) = toEncoding x
55+
instance FromJSON a => FromJSON (Nullable a) where
56+
parseJSON v = Nullable <$> parseJSON v
57+
4758
data Event where
59+
Slot ::
60+
{ node :: !Text
61+
, slot :: !SlotNo
62+
} ->
63+
Event
4864
Cpu ::
4965
{ node :: !Text
5066
, cpu_time_s :: !Time
51-
, task_label :: !Text
67+
, task_type :: !Text
68+
, block_id :: !Text
69+
} ->
70+
Event
71+
NoIBGenerated
72+
, NoEBGenerated
73+
, NoVTBundleGenerated ::
74+
{ node :: !Text
75+
, slot :: !SlotNo
5276
} ->
5377
Event
5478
IBSent
@@ -64,7 +88,7 @@ data Event where
6488
, recipient :: !Node
6589
, msg_size_bytes :: !(Maybe Bytes)
6690
, sending_s :: !(Maybe Time)
67-
, block_id :: !(Maybe Text)
91+
, block_id :: !Text
6892
, block_ids :: !(Maybe [Text])
6993
-- ^ used by Haskell when sending more blocks in one message.
7094
} ->
@@ -82,35 +106,37 @@ data Event where
82106
{ producer :: !Text
83107
, id :: !Text
84108
, slot :: !SlotNo
85-
, size_bytes :: !(Maybe Bytes)
86-
, payload_bytes :: !(Maybe Bytes)
109+
, pipeline :: !PipelineNo
110+
, size_bytes :: !Bytes
111+
, payload_bytes :: !Bytes
87112
, rb_ref :: !(Maybe Text)
88113
} ->
89114
Event
90115
EBGenerated ::
91116
{ producer :: !Text
92117
, id :: !Text
93118
, slot :: !Word64
119+
, pipeline :: !PipelineNo
94120
, bytes :: !Word64
95121
, input_blocks :: ![BlockRef]
96122
} ->
97123
Event
98124
RBGenerated ::
99125
{ producer :: !Text
100-
, block_id :: !(Maybe Text)
101-
, vrf :: !(Maybe Int)
126+
, block_id :: !Text
102127
, slot :: !Word64
103-
, size_bytes :: !(Maybe Word64)
104-
, endorsement :: !(Maybe Endorsement)
128+
, size_bytes :: !Word64
129+
, endorsement :: !(Nullable Endorsement)
105130
, endorsements :: !(Maybe [Endorsement])
106-
, payload_bytes :: !(Maybe Word64)
107-
, parent :: !(Maybe BlockRef)
131+
, payload_bytes :: !Word64
132+
, parent :: !(Nullable BlockRef)
108133
} ->
109134
Event
110135
VTBundleGenerated ::
111136
{ producer :: !Text
112137
, id :: !Text
113138
, slot :: !Word64
139+
, pipeline :: !PipelineNo
114140
, bytes :: !Word64
115141
, votes :: !(Map Text Word64)
116142
} ->
@@ -124,7 +150,10 @@ $( deriveJSON
124150
, fieldLabelModifier = \fl -> case fl of
125151
('b' : 'l' : 'o' : 'c' : 'k' : '_' : xs) -> xs
126152
"bytes" -> "size_bytes"
153+
"payload_bytes" -> "tx_payload_bytes"
127154
xs -> xs
155+
, allowOmittedFields = True
156+
, omitNothingFields = True
128157
}
129158
''Event
130159
)

0 commit comments

Comments
 (0)