diff --git a/beacon-chain/forkchoice/doubly-linked-tree/node.go b/beacon-chain/forkchoice/doubly-linked-tree/node.go index 2e7695efe7..dd8b1bd2ef 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/node.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/node.go @@ -11,10 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/time/slots" ) -// orphanLateBlockFirstThreshold is the number of seconds after which we -// consider a block to be late, and thus a candidate to being reorged. -const orphanLateBlockFirstThreshold = 4 - // ProcessAttestationsThreshold is the number of seconds after which we // process attestations for the current slot const ProcessAttestationsThreshold = 10 @@ -137,7 +133,8 @@ func (n *Node) setNodeAndParentValidated(ctx context.Context) error { // slot will have secs = 3 below. func (n *Node) arrivedEarly(genesisTime uint64) (bool, error) { secs, err := slots.SecondsSinceSlotStart(n.slot, genesisTime, n.timestamp) - return secs < orphanLateBlockFirstThreshold, err + votingWindow := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot + return secs < votingWindow, err } // arrivedAfterOrphanCheck returns whether this block was inserted after the diff --git a/beacon-chain/forkchoice/doubly-linked-tree/node_test.go b/beacon-chain/forkchoice/doubly-linked-tree/node_test.go index 822c7e6948..60f86af067 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/node_test.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/node_test.go @@ -277,6 +277,7 @@ func TestNode_TimeStampsChecks(t *testing.T) { require.NoError(t, err) require.Equal(t, false, late) + orphanLateBlockFirstThreshold := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot // late block driftGenesisTime(f, 2, orphanLateBlockFirstThreshold+1) root = [32]byte{'b'} diff --git a/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks_test.go b/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks_test.go index 8485021a18..f38aa6019e 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks_test.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks_test.go @@ -28,6 +28,7 @@ func TestForkChoice_ShouldOverrideFCU(t *testing.T) { } f.ProcessAttestation(ctx, attesters, root, 0) + orphanLateBlockFirstThreshold := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot driftGenesisTime(f, 2, orphanLateBlockFirstThreshold+1) st, root, err = prepareForkchoiceState(ctx, 2, [32]byte{'b'}, [32]byte{'a'}, [32]byte{'B'}, 0, 0) require.NoError(t, err) @@ -125,6 +126,7 @@ func TestForkChoice_GetProposerHead(t *testing.T) { headRoot, err := f.Head(ctx) require.NoError(t, err) require.Equal(t, root, headRoot) + orphanLateBlockFirstThreshold := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot f.store.headNode.timestamp -= params.BeaconConfig().SecondsPerSlot - orphanLateBlockFirstThreshold t.Run("head is weak", func(t *testing.T) { require.Equal(t, parentRoot, f.GetProposerHead())