Skip to content

Commit 9311538

Browse files
committed
Run per-slot fork choice at a further distance from the head (#3487)
## Issue Addressed NA ## Proposed Changes Run fork choice when the head is 256 slots from the wall-clock slot, rather than 4. The reason we don't *always* run FC is so that it doesn't slow us down during sync. As the comments state, setting the value to 256 means that we'd only have one interrupting fork-choice call if we were syncing at 20 slots/sec. ## Additional Info NA
1 parent df358b8 commit 9311538

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ const PREPARE_PROPOSER_HISTORIC_EPOCHS: u64 = 4;
131131
/// run the per-slot tasks (primarily fork choice).
132132
///
133133
/// This prevents unnecessary work during sync.
134-
const MAX_PER_SLOT_FORK_CHOICE_DISTANCE: u64 = 4;
134+
///
135+
/// The value is set to 256 since this would be just over one slot (12.8s) when syncing at
136+
/// 20 slots/second. Having a single fork-choice run interrupt syncing would have very little
137+
/// impact whilst having 8 epochs without a block is a comfortable grace period.
138+
const MAX_PER_SLOT_FORK_CHOICE_DISTANCE: u64 = 256;
135139

136140
/// Reported to the user when the justified block has an invalid execution payload.
137141
pub const INVALID_JUSTIFIED_PAYLOAD_SHUTDOWN_REASON: &str =

beacon_node/beacon_chain/src/state_advance_timer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ use types::{AttestationShufflingId, EthSpec, Hash256, RelativeEpoch, Slot};
3838
const MAX_ADVANCE_DISTANCE: u64 = 4;
3939

4040
/// Similarly for fork choice: avoid the fork choice lookahead during sync.
41-
const MAX_FORK_CHOICE_DISTANCE: u64 = 4;
41+
///
42+
/// The value is set to 256 since this would be just over one slot (12.8s) when syncing at
43+
/// 20 slots/second. Having a single fork-choice run interrupt syncing would have very little
44+
/// impact whilst having 8 epochs without a block is a comfortable grace period.
45+
const MAX_FORK_CHOICE_DISTANCE: u64 = 256;
4246

4347
#[derive(Debug)]
4448
enum Error {

0 commit comments

Comments
 (0)