mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 16:02:38 +00:00
interfaces: fix findAncestorByHash returning true for unknown block #36490
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36490
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-findancestor-unknown"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #36472.
When
findAncestorByHash(block_hash, ancestor_hash, ...)is called with an unknown or nullblock_hash,LookupBlockIndex(block_hash)returnsnullptr. The preceding checkif (block && ancestor && block->GetAncestor(...) != ancestor) ancestor = nullptr;evaluates to false whenblockis null, leavingancestoruntouched. Ifancestor_hashexists,FillBlock(ancestor, ...)evaluates to true, falsely reporting that an unknown descendant descends from a known block.This patch updates the guard in
src/node/interfaces.cppto ensureancestoris reset to null whenever!block || !ancestor || block->GetAncestor(ancestor->nHeight) != ancestor.Unit test coverage is added in
src/test/interfaces_tests.cppasserting thatfindAncestorByHashreturns false whenblock_hashis null, preservesheight = -1in the output struct, returns false whenancestor_hashis null, returns false when both are null, and correctly returns true for identical blocks.Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Base:
4bacf21a13c2ed25ef9362ca38f26bf0a67d22c9Head:
3cae888dc80124123d9c14c46fe0445feeda1c4eI found no actionable issues in this static review.
Full review report
Another duplicate of https://github.com/bitcoin/bitcoin/pull/36473#issuecomment-6060602624