Skip to content

Commit

Permalink
Add block delays on slot 31, and allow reorgs on epoch boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Apr 26, 2023
1 parent 9cc8783 commit 87bfb80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion consensus/proto_array/src/proto_array_fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ impl ProtoArrayForkChoice {
// Check shuffling stability.
let shuffling_stable = re_org_block_slot % E::slots_per_epoch() != 0;
if !shuffling_stable {
return Err(DoNotReOrg::ShufflingUnstable.into());
// [JC] Allow re-orgs to happen on epoch boundaries for testing.
// return Err(DoNotReOrg::ShufflingUnstable.into());
}

// Check FFG.
Expand Down
16 changes: 16 additions & 0 deletions validator_client/src/block_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
sleep(delay).await;
}

// Delay block production for slot 31 of every epoch.
if let Some(slot) = service.slot_clock.now() {
let slots_per_epoch = E::slots_per_epoch();
let slot_offset = slot % slots_per_epoch;
if slot_offset == (slots_per_epoch - 1) {
let delay = Duration::from_millis(4000);
debug!(
service.context.log(),
"Delaying block production by {}ms",
delay.as_millis();
"slot" => slot.as_u64(),
);
sleep(delay).await;
}
}

service.do_update(notif).await.ok();
}
debug!(log, "Block service shutting down");
Expand Down

0 comments on commit 87bfb80

Please sign in to comment.