Skip to content

Commit 816abfe

Browse files
committed
sim-rs: give every Generated message a size_bytes
1 parent 124888d commit 816abfe

File tree

7 files changed

+144
-142
lines changed

7 files changed

+144
-142
lines changed

data/simulation/example.rust.jsonl

Lines changed: 123 additions & 123 deletions
Large diffs are not rendered by default.

data/simulation/trace.rust.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
6262
type: RustBlockMessageType;
6363
index?: number;
6464
header_bytes?: number;
65-
total_bytes?: number;
65+
size_bytes?: number;
6666
transactions?: string[];
6767
vrf?: number;
6868
endorsement?: any;

data/simulation/trace.rust.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
},
7575
"type": "object"
7676
},
77-
"total_bytes": {
77+
"size_bytes": {
7878
"type": "number"
7979
},
8080
"transactions": {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ impl EventMonitor {
177177
Event::CpuTaskScheduled { .. } => {}
178178
Event::CpuTaskFinished { .. } => {}
179179
Event::CpuSubtaskStarted { .. } => {}
180-
Event::TransactionGenerated { id, bytes, .. } => {
181-
txs.insert(id, Transaction::new(bytes, time));
180+
Event::TransactionGenerated { id, size_bytes, .. } => {
181+
txs.insert(id, Transaction::new(size_bytes, time));
182182
pending_txs.insert(id);
183183
}
184184
Event::TransactionSent { .. } => {
@@ -256,7 +256,7 @@ impl EventMonitor {
256256
Event::IBGenerated {
257257
id,
258258
header_bytes,
259-
total_bytes,
259+
size_bytes,
260260
transactions,
261261
..
262262
} => {
@@ -266,7 +266,7 @@ impl EventMonitor {
266266
}
267267
pending_ibs.insert(id.clone());
268268
ib_txs.insert(id.clone(), transactions.clone());
269-
bytes_in_ib.insert(id.clone(), total_bytes as f64);
269+
bytes_in_ib.insert(id.clone(), size_bytes as f64);
270270
let mut tx_bytes = header_bytes;
271271
for tx_id in &transactions {
272272
*txs_in_ib.entry(id.clone()).or_default() += 1.;

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub enum Event {
8282
TransactionGenerated {
8383
id: TransactionId,
8484
publisher: Node,
85-
bytes: u64,
85+
size_bytes: u64,
8686
},
8787
TransactionSent {
8888
id: TransactionId,
@@ -106,6 +106,7 @@ pub enum Event {
106106
vrf: u64,
107107
parent: Option<BlockId<Node>>,
108108
header_bytes: u64,
109+
size_bytes: u64,
109110
endorsement: Option<Endorsement<Node>>,
110111
transactions: Vec<TransactionId>,
111112
},
@@ -137,7 +138,7 @@ pub enum Event {
137138
producer: Node,
138139
index: u64,
139140
header_bytes: u64,
140-
total_bytes: u64,
141+
size_bytes: u64,
141142
transactions: Vec<TransactionId>,
142143
},
143144
IBSent {
@@ -169,7 +170,7 @@ pub enum Event {
169170
slot: u64,
170171
pipeline: u64,
171172
producer: Node,
172-
bytes: u64,
173+
size_bytes: u64,
173174
input_blocks: Vec<InputBlockId<Node>>,
174175
endorser_blocks: Vec<EndorserBlockId<Node>>,
175176
},
@@ -200,7 +201,7 @@ pub enum Event {
200201
slot: u64,
201202
pipeline: u64,
202203
producer: Node,
203-
bytes: u64,
204+
size_bytes: u64,
204205
votes: Votes<Node>,
205206
},
206207
VTBundleNotGenerated {
@@ -322,9 +323,10 @@ impl EventTracker {
322323
vrf: block.vrf,
323324
parent: block.parent.map(|id| self.to_block(id)),
324325
header_bytes: block.header_bytes,
326+
size_bytes: block.bytes(),
325327
endorsement: block.endorsement.as_ref().map(|e| Endorsement {
326328
eb: self.to_endorser_block(e.eb),
327-
bytes: e.bytes,
329+
size_bytes: e.size_bytes,
328330
votes: e
329331
.votes
330332
.iter()
@@ -359,7 +361,7 @@ impl EventTracker {
359361
self.send(Event::TransactionGenerated {
360362
id: transaction.id,
361363
publisher: self.to_node(publisher),
362-
bytes: transaction.bytes,
364+
size_bytes: transaction.bytes,
363365
});
364366
}
365367

@@ -397,7 +399,7 @@ impl EventTracker {
397399
producer: self.to_node(block.header.id.producer),
398400
index: block.header.id.index,
399401
header_bytes: block.header.bytes,
400-
total_bytes: block.header.bytes
402+
size_bytes: block.header.bytes
401403
+ block.transactions.iter().map(|tx| tx.bytes).sum::<u64>(),
402404
transactions: block.transactions.iter().map(|tx| tx.id).collect(),
403405
});
@@ -442,7 +444,7 @@ impl EventTracker {
442444
slot: block.slot,
443445
pipeline: block.pipeline,
444446
producer: self.to_node(block.producer),
445-
bytes: block.bytes,
447+
size_bytes: block.bytes,
446448
input_blocks: block
447449
.ibs
448450
.iter()
@@ -493,7 +495,7 @@ impl EventTracker {
493495
slot: votes.id.slot,
494496
pipeline: votes.id.pipeline,
495497
producer: self.to_node(votes.id.producer),
496-
bytes: votes.bytes,
498+
size_bytes: votes.bytes,
497499
votes: Votes(
498500
votes
499501
.ebs

sim-rs/sim-core/src/model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Block {
7878
+ self
7979
.endorsement
8080
.as_ref()
81-
.map(|e| e.bytes)
81+
.map(|e| e.size_bytes)
8282
.unwrap_or_default()
8383
+ self.transactions.iter().map(|t| t.bytes).sum::<u64>()
8484
}
@@ -219,6 +219,6 @@ pub enum NoVoteReason {
219219
#[derive(Clone, Debug, Serialize)]
220220
pub struct Endorsement<Node: Display = NodeId> {
221221
pub eb: EndorserBlockId<Node>,
222-
pub bytes: u64,
222+
pub size_bytes: u64,
223223
pub votes: BTreeMap<Node, usize>,
224224
}

sim-rs/sim-core/src/sim/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,11 @@ impl Node {
789789
};
790790

791791
let votes = self.leios.votes_by_eb.get(&block)?.clone();
792-
let bytes = self.sim_config.sizes.cert(votes.len());
792+
let size_bytes = self.sim_config.sizes.cert(votes.len());
793793

794794
Some(Endorsement {
795795
eb: block,
796-
bytes,
796+
size_bytes,
797797
votes,
798798
})
799799
}

0 commit comments

Comments
 (0)