Peer service: Announce and filter full vs pruned nodes for block catchup#49
Peer service: Announce and filter full vs pruned nodes for block catchup#49freemans13 wants to merge 5 commits into
Conversation
Decouple network block fetching from worker distribution using a two-goroutine pipeline. This keeps the network connection saturated even when validation is slower than fetch, improving overall catchup performance. Changes: - Add batchFetchWithPrefetch and distributeBatchesToWorkers functions - Introduce FetchPrefetchDepth setting (default: 5 batches ahead) - Add context cancellation check in subtree validation level processing The fetcher can now run up to prefetchDepth batches ahead of distribution, maximizing network throughput during block catchup operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
🤖 Claude Code Review Status: Complete Current Review:
Overall Assessment: The default value inconsistency should be fixed to avoid configuration confusion, but it's a minor issue that doesn't affect correctness when settings are properly configured. |
|
| largeBatchSize := 100 // Large batches for maximum HTTP efficiency (peer limit) | ||
| numWorkers := 16 // Number of worker goroutines for parallel processing | ||
| bufferSize := 500 // Buffer size for channels | ||
| prefetchDepth := 2 // Number of batches to prefetch ahead (default: 2) |
There was a problem hiding this comment.
The default value in the code (line 76) is 2, but the settings default (settings/settings.go) is 5. This inconsistency means the documented behavior does not match actual behavior when settings are not configured. Recommend changing line 76 to match the settings default of 5.
|
Closing - branch had extra commits. Creating clean PR. |
- Update config parameter names to include validator_ prefix - Reference validator_kafkaWorkers, validator_httpRateLimit, validator_verbose_debug - Add note that these are advanced settings not in default settings.conf - Link to comprehensive Validator Settings Reference documentation Addresses issue bsv-blockchain#49 from teranode-review - settings exist in code but not in default config file, which is expected for advanced options


Summary
Implement peer announcement and filtering for full vs pruned nodes to ensure reliable block catchup. Nodes now announce whether they have full block data (block persister running and caught up) or are pruned, and the sync-peer selection logic filters to only use full nodes for catchup by default.
Changes
Node Mode Determination
BlockPersisterHeightPeer Tracking
NodeModefield toPeerInfostruct to track peer capabilitiesUpdateNodeMode()method to peer registrySync-Peer Selection Filtering
PeerSelector.isEligible()to filter based on node modeConfiguration
Two new settings in
P2PSettings:Modes:
"pruned"(default): Strict - only sync from confirmed full nodes"full": Permissive - allow all peers (backward compatible)Test plan
Technical Details
Files modified:
services/p2p/Server.go- Node mode determination and announcement (services/p2p/Server.go:1261-1309)services/p2p/HandleWebsocket.go- Added NodeMode to WebSocket notificationsservices/p2p/peer_registry.go- Peer mode trackingservices/p2p/peer_selector.go- Node mode filtering in eligibility check (services/p2p/peer_selector.go:163-189)services/p2p/*_test.go- Updated test mockssettings/interface.go- Added configuration settings🤖 Generated with Claude Code