Skip to content

Commit d9af90d

Browse files
committed
sim-rs: track vote bundle sizes
1 parent 9495c51 commit d9af90d

File tree

9 files changed

+18
-10
lines changed

9 files changed

+18
-10
lines changed

data/simulation/config.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ export interface Config {
8383
"vote-generation-cpu-time-ms-per-ib": number;
8484
"vote-validation-cpu-time-ms": number;
8585
"vote-threshold": bigint;
86-
/** Only supported by Haskell simulation. */
8786
"vote-bundle-size-bytes-constant": bigint;
88-
/** Only supported by Haskell simulation. */
8987
"vote-bundle-size-bytes-per-eb": bigint;
9088
/** Only supported by Haskell simulation. */
9189
"vote-diffusion-strategy": DiffusionStrategy;

data/simulation/config.schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,11 @@
281281
},
282282
"vote-bundle-size-bytes-constant": {
283283
"additionalProperties": false,
284-
"description": "Only supported by Haskell simulation.",
285284
"properties": {},
286285
"type": "number"
287286
},
288287
"vote-bundle-size-bytes-per-eb": {
289288
"additionalProperties": false,
290-
"description": "Only supported by Haskell simulation.",
291289
"properties": {},
292290
"type": "number"
293291
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl EventMonitor {
307307
eb_messages.received += 1;
308308
}
309309
Event::VoteLotteryWon { .. } => {}
310-
Event::VotesGenerated { id, votes } => {
310+
Event::VotesGenerated { id, votes, .. } => {
311311
for (eb, count) in votes.0 {
312312
total_votes += count as u64;
313313
*votes_per_bundle.entry(id.clone()).or_default() += count as f64;

sim-rs/sim-core/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ pub struct RawParameters {
9898
pub vote_generation_cpu_time_ms_per_ib: f64,
9999
pub vote_validation_cpu_time_ms: f64,
100100
pub vote_threshold: u64,
101-
// pub vote_size_bytes_constant: u64,
102-
// pub vote_size_bytes_per_node: u64,
101+
pub vote_bundle_size_bytes_constant: u64,
102+
pub vote_bundle_size_bytes_per_eb: u64,
103103

104104
// Certificate configuration
105105
pub cert_generation_cpu_time_ms_constant: f64,
@@ -311,6 +311,8 @@ pub(crate) struct BlockSizeConfig {
311311
pub ib_header: u64,
312312
eb_constant: u64,
313313
eb_per_ib: u64,
314+
vote_constant: u64,
315+
vote_per_eb: u64,
314316
}
315317

316318
impl BlockSizeConfig {
@@ -322,6 +324,8 @@ impl BlockSizeConfig {
322324
ib_header: params.ib_head_size_bytes,
323325
eb_constant: params.eb_size_bytes_constant,
324326
eb_per_ib: params.eb_size_bytes_per_ib,
327+
vote_constant: params.vote_bundle_size_bytes_constant,
328+
vote_per_eb: params.vote_bundle_size_bytes_per_eb,
325329
}
326330
}
327331

@@ -332,6 +336,10 @@ impl BlockSizeConfig {
332336
pub fn eb(&self, ibs: usize) -> u64 {
333337
self.eb_constant + self.eb_per_ib * ibs as u64
334338
}
339+
340+
pub fn vote_bundle(&self, ebs: usize) -> u64 {
341+
self.vote_constant + self.vote_per_eb * ebs as u64
342+
}
335343
}
336344

337345
#[derive(Debug, Clone)]

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ pub enum Event {
163163
VotesGenerated {
164164
#[serde(flatten)]
165165
id: VoteBundleId<Node>,
166+
bytes: u64,
166167
votes: Votes<Node>,
167168
},
168169
NoVote {
@@ -389,6 +390,7 @@ impl EventTracker {
389390
pub fn track_votes_generated(&self, votes: &VoteBundle) {
390391
self.send(Event::VotesGenerated {
391392
id: self.to_vote_bundle(votes.id),
393+
bytes: votes.bytes,
392394
votes: Votes(
393395
votes
394396
.ebs

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ impl<Node: Display + Serialize> Serialize for VoteBundleId<Node> {
189189
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
190190
pub struct VoteBundle {
191191
pub id: VoteBundleId,
192+
pub bytes: u64,
192193
pub ebs: BTreeMap<EndorserBlockId, usize>,
193194
}
194195

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,13 @@ impl Node {
622622
}
623623
// For every VRF lottery you won, you can vote for every EB
624624
let votes_allowed = vote_count * ebs.len();
625-
let eb_counts = ebs.into_iter().map(|eb| (eb, votes_allowed)).collect();
626625
let votes = VoteBundle {
627626
id: VoteBundleId {
628627
slot,
629628
producer: self.id,
630629
},
631-
ebs: eb_counts,
630+
bytes: self.sim_config.sizes.vote_bundle(ebs.len()),
631+
ebs: ebs.into_iter().map(|eb| (eb, votes_allowed)).collect(),
632632
};
633633
if !votes.ebs.is_empty() {
634634
self.schedule_cpu_task(CpuTask::VoteBundleGenerated(votes));

ui/src/app/api/messages/batch/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const processMessage = (
202202
message.producer.toString(),
203203
"votesGenerated",
204204
);
205-
// TODO: track vote bundle size
205+
intermediate.bytes.set(`votes-${message.id}`, message.bytes);
206206
} else if (message.type === EMessageType.VotesSent) {
207207
incrementNodeAggregationData(
208208
aggregatedData,

ui/src/components/Sim/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export interface IVotesGenerated {
191191
id: string;
192192
slot: number;
193193
producer: string;
194+
bytes: number;
194195
votes: any[] // @todo
195196
}
196197

0 commit comments

Comments
 (0)