Skip to content

Commit 87bfb80

Browse files
committed
Add block delays on slot 31, and allow reorgs on epoch boundary
1 parent 9cc8783 commit 87bfb80

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

consensus/proto_array/src/proto_array_fork_choice.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ impl ProtoArrayForkChoice {
542542
// Check shuffling stability.
543543
let shuffling_stable = re_org_block_slot % E::slots_per_epoch() != 0;
544544
if !shuffling_stable {
545-
return Err(DoNotReOrg::ShufflingUnstable.into());
545+
// [JC] Allow re-orgs to happen on epoch boundaries for testing.
546+
// return Err(DoNotReOrg::ShufflingUnstable.into());
546547
}
547548

548549
// Check FFG.

validator_client/src/block_service.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
185185
sleep(delay).await;
186186
}
187187

188+
// Delay block production for slot 31 of every epoch.
189+
if let Some(slot) = service.slot_clock.now() {
190+
let slots_per_epoch = E::slots_per_epoch();
191+
let slot_offset = slot % slots_per_epoch;
192+
if slot_offset == (slots_per_epoch - 1) {
193+
let delay = Duration::from_millis(4000);
194+
debug!(
195+
service.context.log(),
196+
"Delaying block production by {}ms",
197+
delay.as_millis();
198+
"slot" => slot.as_u64(),
199+
);
200+
sleep(delay).await;
201+
}
202+
}
203+
188204
service.do_update(notif).await.ok();
189205
}
190206
debug!(log, "Block service shutting down");

0 commit comments

Comments
 (0)