fix(validator): require BlockIDs+!Conflicting+!Locked before ErrTxNotFound shortcut#770
Open
ordishs wants to merge 1 commit intobsv-blockchain:mainfrom
Open
fix(validator): require BlockIDs+!Conflicting+!Locked before ErrTxNotFound shortcut#770ordishs wants to merge 1 commit intobsv-blockchain:mainfrom
ordishs wants to merge 1 commit intobsv-blockchain:mainfrom
Conversation
…Found shortcut (refs #4568)
Contributor
|
🤖 Claude Code Review Status: Complete No issues found. The fix properly gates the ErrTxNotFound shortcut with three conditions that collectively confirm prior full validation. The logic is sound, test coverage is comprehensive (5 scenarios), and the mock fix correctly handles error returns. The implementation addresses the security concern described in #4568 where a tx could be accepted based on its mere existence rather than verified validation state. |
Contributor
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-04-28 18:12 UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4568.
Summary
When
spendUtxosreturnsErrTxNotFound(parent missing), the validator looked up the current tx in the UTXO store and, if found, returned(meta, nil)with a warning "assuming already blessed" — without checking whether the metadata actually confirmed prior validation. During a reorg or DAH-eviction window, a tx lookup can succeed while its parent is temporarily absent; the shortcut would silently accept the tx on the basis of its own existence rather than a verified prior validation.Fix
Gate the shortcut on three conditions that together imply prior full validation:
len(BlockIDs) > 0— tx has been included in at least one block.!Conflicting— tx is not flagged as conflicting.!Locked— tx is not locked (e.g., from a conflict aftermath).If any condition fails, surface the original
ErrTxNotFound. Use a localmetaErrso the outererr(stillErrTxNotFound) survives the metadata lookup for the fall-through error path.Also tightened
MockUtxostore.GetMetasoReturn(error)now correctly surfaces a lookup failure instead of panicking on a*meta.Datacast.Test plan
go test -race ./services/validator/...passes.go test -race ./stores/utxo/...passes.