Skip to content

Commit 03ceefc

Browse files
committed
sim-rs: only generate EBs/Votes for useful pipelines
1 parent d14e7e1 commit 03ceefc

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ impl EventMonitor {
452452
Some(block_time - tx.generated)
453453
})
454454
.collect();
455-
let ib_expiration_cutoff = last_timestamp - Duration::from_secs(self.maximum_ib_age);
455+
let ib_expiration_cutoff = last_timestamp.checked_sub_duration(Duration::from_secs(self.maximum_ib_age)).unwrap_or_default();
456456
let expired_ibs = ibs.values().filter(|ib| ib.included_in_eb.is_none() && ib.generated < ib_expiration_cutoff).count();
457-
let eb_expiration_cutoff = last_timestamp - Duration::from_secs(self.maximum_eb_age);
457+
let eb_expiration_cutoff = last_timestamp.checked_sub_duration(Duration::from_secs(self.maximum_eb_age)).unwrap_or_default();
458458
let expired_ebs = ebs.values().filter(|eb| eb.included_in_eb.is_none() && eb.included_in_block.is_none() && eb.generated < eb_expiration_cutoff).count();
459459
let empty_ebs = ebs.values().filter(|eb| eb.is_empty()).count();
460460
let bundle_count = votes_per_bundle.len();

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,13 @@ impl Node {
587587
}
588588

589589
fn generate_endorser_blocks(&mut self, slot: u64) {
590+
let pipeline = self.slot_to_pipeline(slot) + 1;
591+
if pipeline < 4 {
592+
// The first pipeline with IBs in it is pipeline 4.
593+
// Don't generate EBs before that pipeline, because they would just be empty.
594+
}
590595
for next_p in vrf_probabilities(self.sim_config.eb_generation_probability) {
591596
if self.run_vrf(next_p).is_some() {
592-
let pipeline = self.slot_to_pipeline(slot) + 1;
593597
self.tracker.track_eb_lottery_won(EndorserBlockId {
594598
slot,
595599
pipeline,
@@ -619,6 +623,12 @@ impl Node {
619623
}
620624

621625
fn schedule_endorser_block_votes(&mut self, slot: u64) {
626+
let pipeline = self.slot_to_pipeline(slot);
627+
if pipeline < 4 {
628+
// The first pipeline with IBs in it is pipeline 4.
629+
// Don't run the VT lottery before that pipeline, because there's nothing to vote on.
630+
return;
631+
}
622632
let vrf_wins = vrf_probabilities(self.sim_config.vote_probability)
623633
.filter_map(|f| self.run_vrf(f))
624634
.count();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:a5b65b452312578f3a710024f04c912647fcce4e63224c3471d50921eac9c091
3-
size 14783528
2+
oid sha256:1340952829906e650306286981c459c31265edd42d0db840d309b77e4db8a531
3+
size 14451878
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:8c73e766768276d9f707eeee0f2b60511c5f99acd0764461d84cd6238eca432f
3-
size 12670009
2+
oid sha256:4c4b0d8f1f18aee8a68467211be4e34cd519c65ef130b8977f25ee31993d5483
3+
size 12135481
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:f32692bef181c2c22d57a9f63c97651a1ac67fa5af6c579a72395dab08105e95
3-
size 8635280
2+
oid sha256:33b4bbb5760bcfa2d1e4726d81642cf48c8832cca0586d1e85b0d16aa6ec965b
3+
size 8351576

0 commit comments

Comments
 (0)