diff --git a/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go b/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go index 4515735c4..8bc717802 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go @@ -82,6 +82,15 @@ func (f *ForkChoice) ShouldOverrideFCU() (override bool) { return } + // Return early if we are checking before 10 seconds into the slot + secs, err := slots.SecondsSinceSlotStart(head.slot, f.store.genesisTime, uint64(time.Now().Unix())) + if err != nil { + log.WithError(err).Error("could not check current slot") + return true + } + if secs < ProcessAttestationsThreshold { + return true + } // Only orphan a block if the parent LMD vote is strong if parent.weight*100 < f.store.committeeWeight*params.BeaconConfig().ReorgParentWeightThreshold { return 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 dd5837606..dd6694aed 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 @@ -85,11 +85,19 @@ func TestForkChoice_ShouldOverrideFCU(t *testing.T) { require.Equal(t, false, f.ShouldOverrideFCU()) f.store.headNode.parent = saved }) - t.Run("parent is weak", func(t *testing.T) { + t.Run("parent is weak early call", func(t *testing.T) { saved := f.store.headNode.parent.weight f.store.headNode.parent.weight = 0 + require.Equal(t, true, f.ShouldOverrideFCU()) + f.store.headNode.parent.weight = saved + }) + t.Run("parent is weak late call", func(t *testing.T) { + saved := f.store.headNode.parent.weight + driftGenesisTime(f, 2, 11) + f.store.headNode.parent.weight = 0 require.Equal(t, false, f.ShouldOverrideFCU()) f.store.headNode.parent.weight = saved + driftGenesisTime(f, 2, orphanLateBlockFirstThreshold+1) }) t.Run("Head is strong", func(t *testing.T) { f.store.headNode.weight = f.store.committeeWeight