Skip to content

Commit e6d30fa

Browse files
committed
sim-rs: log total bytes contained in an IB
1 parent a7d98ba commit e6d30fa

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

data/simulation/trace.rust.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
6060
type: RustBlockMessageType;
6161
index?: number;
6262
header_bytes?: number;
63+
total_bytes?: number;
6364
transactions?: string[];
6465
vrf?: number;
6566
endorsement?: any;

data/simulation/trace.rust.schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
},
7272
"type": "object"
7373
},
74+
"total_bytes": {
75+
"type": "number"
76+
},
7477
"transactions": {
7578
"items": {
7679
"type": "string"

sim-rs/sim-cli/src/events.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ impl EventMonitor {
252252
Event::IBGenerated {
253253
id,
254254
header_bytes,
255+
total_bytes,
255256
transactions,
256257
} => {
257258
generated_ibs += 1;
@@ -260,13 +261,13 @@ impl EventMonitor {
260261
}
261262
pending_ibs.insert(id.clone());
262263
ib_txs.insert(id.clone(), transactions.clone());
263-
let mut ib_bytes = header_bytes;
264+
bytes_in_ib.insert(id.clone(), total_bytes as f64);
265+
let mut tx_bytes = header_bytes;
264266
for tx_id in &transactions {
265267
*txs_in_ib.entry(id.clone()).or_default() += 1.;
266268
*ibs_containing_tx.entry(*tx_id).or_default() += 1.;
267269
let tx = txs.get_mut(tx_id).unwrap();
268-
ib_bytes += tx.bytes;
269-
*bytes_in_ib.entry(id.clone()).or_default() += tx.bytes as f64;
270+
tx_bytes += tx.bytes;
270271
if tx.included_in_ib.is_none() {
271272
tx.included_in_ib = Some(time);
272273
}
@@ -277,7 +278,7 @@ impl EventMonitor {
277278
id.producer,
278279
transactions.len(),
279280
id.slot,
280-
pretty_bytes(ib_bytes, pbo.clone()),
281+
pretty_bytes(tx_bytes, pbo.clone()),
281282
)
282283
}
283284
Event::IBSent { .. } => {

sim-rs/sim-core/src/events.rs

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub enum Event {
125125
#[serde(flatten)]
126126
id: InputBlockId<Node>,
127127
header_bytes: u64,
128+
total_bytes: u64,
128129
transactions: Vec<TransactionId>,
129130
},
130131
IBSent {
@@ -342,6 +343,8 @@ impl EventTracker {
342343
self.send(Event::IBGenerated {
343344
id: self.to_input_block(block.header.id),
344345
header_bytes: block.header.bytes,
346+
total_bytes: block.header.bytes
347+
+ block.transactions.iter().map(|tx| tx.bytes).sum::<u64>(),
345348
transactions: block.transactions.iter().map(|tx| tx.id).collect(),
346349
});
347350
}

0 commit comments

Comments
 (0)