What changed, and why it matters
This commit only adds a new error code constant and its string mapping in the blockchain package. It does not change any validation logic, network behavior, or how blocks are accepted or rejected. By itself, it cannot introduce or fix a security issue.
No security action needed. Review follow-up commits that actually emit ErrKnownInvalidBlock to determine whether the intended behavioral change has security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds ErrKnownInvalidBlock to the ErrorCode iota block in blockchain/error.go and registers its string representation in errorCodeStrings, plus a matching test case in error_test.go. No call sites use this new error code, and no consensus or validation code is modified. It is purely a preparatory/error-typing change.
Changed components
blockchain/error.goblockchain/error_test.goInspect captured patch +7 / −0
diff --git a/blockchain/error.go b/blockchain/error.go
index 8a7d4a7..6104e7a 100644
--- a/blockchain/error.go
+++ b/blockchain/error.go
@@ -224,6 +224,11 @@ const (
// ErrTimewarpAttack indicates a timewarp attack i.e.
// when block's timestamp is too early on diff adjustment block.
ErrTimewarpAttack
+
+ // ErrKnownInvalidBlock indicates that the block itself has previously
+ // been found to violate a consensus rule, as opposed to having an
+ // invalid ancestor.
+ ErrKnownInvalidBlock
)
// Map of ErrorCode values back to their constant names for pretty printing.
@@ -271,6 +276,7 @@ var errorCodeStrings = map[ErrorCode]string{
ErrPreviousBlockUnknown: "ErrPreviousBlockUnknown",
ErrInvalidAncestorBlock: "ErrInvalidAncestorBlock",
ErrPrevBlockNotBest: "ErrPrevBlockNotBest",
+ ErrKnownInvalidBlock: "ErrKnownInvalidBlock",
}
// String returns the ErrorCode as a human-readable name.
diff --git a/blockchain/error_test.go b/blockchain/error_test.go
index c0e56ab..94b5daf 100644
--- a/blockchain/error_test.go
+++ b/blockchain/error_test.go
@@ -58,6 +58,7 @@ func TestErrorCodeStringer(t *testing.T) {
{ErrPreviousBlockUnknown, "ErrPreviousBlockUnknown"},
{ErrInvalidAncestorBlock, "ErrInvalidAncestorBlock"},
{ErrPrevBlockNotBest, "ErrPrevBlockNotBest"},
+ {ErrKnownInvalidBlock, "ErrKnownInvalidBlock"},
{0xffff, "Unknown ErrorCode (65535)"},
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.