From a8696bd825db4c61973f456ed8718721aee7f767 Mon Sep 17 00:00:00 2001 From: gop Date: Fri, 26 Apr 2024 11:09:08 -0500 Subject: [PATCH] bugfix: Stop the etx collection if the slice was not created yet --- core/slice.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/slice.go b/core/slice.go index 7156f33221..b4a21db455 100644 --- a/core/slice.go +++ b/core/slice.go @@ -772,6 +772,20 @@ func (sl *Slice) CollectNewlyConfirmedEtxs(block *types.WorkObject, location com return newlyConfirmedEtxs, subRollup, nil } + // Terminate the search if the slice to which the given block belongs was + // not activated yet, expansion number is validated on prime block, so only + // terminate on prime block, It is possible to make this check more + // optimized but this is performant enough and in some cases might have to + // go through few more region blocks than necessary + _, order, err := sl.Engine().CalcOrder(ancestor) + if err != nil { + return nil, nil, err + } + regions, zones := common.GetHierarchySizeForExpansionNumber(ancestor.ExpansionNumber()) + if order == common.PRIME_CTX && (location.Region() > int(regions) || location.Zone() > int(zones)) { + return newlyConfirmedEtxs, subRollup, nil + } + // Terminate the search when we find a block produced by the same sub if ancestor.Location().SubIndex(nodeLocation) == location.SubIndex(nodeLocation) { return newlyConfirmedEtxs, subRollup, nil