diff --git a/core/chains/evm/headtracker/heap.go b/core/chains/evm/headtracker/heap.go index f377f82cd71..572ed541dfa 100644 --- a/core/chains/evm/headtracker/heap.go +++ b/core/chains/evm/headtracker/heap.go @@ -19,8 +19,10 @@ func (h *headsHeap) Less(i, j int) bool { } func (h *headsHeap) Pop() any { - old := h.values[len(h.values)-1] - h.values = h.values[:len(h.values)-1] + n := len(h.values) - 1 + old := h.values[n] + h.values[n] = nil + h.values = h.values[:n] return old } diff --git a/core/chains/evm/types/models.go b/core/chains/evm/types/models.go index fb95026eb2c..1da8754cec4 100644 --- a/core/chains/evm/types/models.go +++ b/core/chains/evm/types/models.go @@ -136,9 +136,6 @@ func (h *Head) HeadAtHeight(blockNum int64) (commontypes.Head[common.Hash], erro // ChainLength returns the length of the chain followed by recursively looking up parents func (h *Head) ChainLength() uint32 { - if h == nil { - return 0 - } l := uint32(0) for cur := h; cur != nil; cur = cur.Parent.Load() { l++