You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iterationError=errors.NewProcessingError("[Block Validation][checkOldBlockIDs][%s] blockIDs is empty for txID: %v", block.String(), txID)
1963
1980
returnfalse
1964
1981
}
1965
1982
1966
-
// check whether the blockIDs are in the current chain we just fetched
1983
+
// Check if any of the parent blocks exist in this block's ancestry
1984
+
foundInAncestry:=false
1967
1985
for_, blockID:=rangeblockIDs {
1968
-
if_, ok:=currentChainBlockIDsMap[blockID]; ok {
1969
-
// all good, continue
1970
-
returntrue
1971
-
}
1972
-
}
1973
-
1974
-
slices.Sort(blockIDs)
1975
-
1976
-
builder.Reset()
1977
-
1978
-
fori, id:=rangeblockIDs {
1979
-
ifi>0 {
1980
-
builder.WriteString(",") // Add a separator
1981
-
}
1982
-
1983
-
builder.WriteString(strconv.Itoa(int(id)))
1984
-
}
1985
-
1986
-
blockIDsString:=builder.String()
1987
-
1988
-
// check whether we already checked exactly the same blockIDs and can use a cache
1989
-
ifblocksPartOfCurrentChain, ok:=currentChainLookupCache[blockIDsString]; ok {
1990
-
if!blocksPartOfCurrentChain {
1991
-
iterationError=errors.NewBlockInvalidError("[Block Validation][checkOldBlockIDs][%s] block is not valid. Transaction's (%v) parent blocks (%v) are not from current chain using cache", block.String(), txID, blockIDs)
1992
-
returnfalse
1986
+
if_, ok:=blockAncestorIDsMap[blockID]; ok {
1987
+
foundInAncestry=true
1988
+
break
1993
1989
}
1994
-
1995
-
returntrue
1996
1990
}
1997
1991
1998
-
// Flag to check if the old blocks are part of the current chain
// if err is not nil, log the error and continue iterating for the next transaction
2001
-
iferr!=nil {
2002
-
iterationError=errors.NewProcessingError("[Block Validation][checkOldBlockIDs][%s] failed to check if old blocks are part of the current chain", block.String(), err)
// if the blocks are not part of the current chain, stop iteration, set the iterationError and return false
2010
-
if!blocksPartOfCurrentChain {
2011
-
iterationError=errors.NewBlockInvalidError("[Block Validation][checkOldBlockIDs][%s] block is not valid. Transaction's (%v) parent blocks (%v) are not from current chain", block.String(), txID, blockIDs)
1992
+
if!foundInAncestry {
1993
+
// CONSENSUS RULE VIOLATION: Transaction references blocks not in this block's ancestry.
1994
+
// This could mean:
1995
+
// 1. Parent blocks are on a competing fork (not in this chain's history)
1996
+
// 2. Parent blocks are >100K deep (extremely unlikely for valid transactions)
1997
+
// 3. Parent blocks don't exist at all (malformed transaction)
1998
+
slices.Sort(blockIDs)
1999
+
iterationError=errors.NewBlockInvalidError(
2000
+
"[Block Validation][checkOldBlockIDs][%s] block is invalid. Transaction %v references parent blocks %v that are not in this block's ancestry (checked %d ancestors)",
0 commit comments