Download missing subtree files before block revalidation#454
Open
freemans13 wants to merge 2 commits intobsv-blockchain:mainfrom
Open
Download missing subtree files before block revalidation#454freemans13 wants to merge 2 commits intobsv-blockchain:mainfrom
freemans13 wants to merge 2 commits intobsv-blockchain:mainfrom
Conversation
Contributor
|
🤖 Claude Code Review Status: Complete Current Review: The PR adds subtree data fetching before block revalidation, which correctly addresses the pruning issue. However, there is one existing concern:
The core logic is sound and the PR description accurately explains the problem and solution. |
services/blockvalidation/Server.go
Outdated
| // This handles the case where pruner has removed subtree data for old invalid blocks. | ||
| if u.p2pClient != nil { | ||
| var baseURL string | ||
| if peer, err := u.p2pClient.GetPeer(ctx, blockHeaderMeta.PeerID); err == nil && peer != nil { |
Contributor
There was a problem hiding this comment.
The error from GetPeer is silently ignored. If GetPeer fails, baseURL will be empty, causing fetchSubtreeDataForBlock to construct an invalid URL. While there is fallback logic, this causes unnecessary HTTP failures and warning logs. Consider logging the GetPeer error or handling it explicitly, similar to catchup_get_block_headers.go:438
|
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.


Problem
When revalidating old invalid blocks via the
RevalidateBlockRPC endpoint, the pruner may have already removed the subtree files (FileTypeSubtreeToCheckandFileTypeSubtreeData). This causes revalidation to fail because the validation logic cannot access the required data.Solution
Call
fetchSubtreeDataForBlock()at the start ofRevalidateBlock()to download any missing subtree files before proceeding with validation. This method:GetPeersAtMaxHeight()if the primary peer failsThe fetch is only attempted when
p2pClientis available, since peer communication is required to download the files.Changes
services/blockvalidation/Server.go: Added subtree fetch logic inRevalidateBlock()before callingValidateBlockWithOptions()Testing
go build ./services/blockvalidation/...🤖 Generated with Claude Code