Skip to content

refactor(pseudo-peer): direct trusted peer + DB hash resolution#122

Merged
sprites0 merged 3 commits intonode-builderfrom
fix/pseudo-peer-remove-panics
Mar 14, 2026
Merged

refactor(pseudo-peer): direct trusted peer + DB hash resolution#122
sprites0 merged 3 commits intonode-builderfrom
fix/pseudo-peer-remove-panics

Conversation

@sprites0
Copy link
Collaborator

@sprites0 sprites0 commented Mar 4, 2026

Summary

1. style: cargo fmt and clippy fixes

Formatting and collapsible_if lint fixes, no functional changes.

2. refactor: use direct trusted peer instead of boot node discovery

  • Remove boot nodes and discovery (discv4/DNS) — the pseudo-peer always connects to a known local node, so discovery is unnecessary
  • Use add_trusted_peer instead of add_peer so the peer auto-reconnects on disconnect and is never evicted after backoff failures
  • Set max_inbound(0) since only one outbound connection is needed

3. refactor: resolve hash→number via node DB instead of backfill scanning

  • Pass a DbBlockNumberFn closure from build_network into the pseudo-peer for direct hash→number lookups against the node's header DB
  • Remove ~200 lines of backfill/cache-warming code (backfill_cache_for_hash, warm_cache_around_blocks, try_block_range_for_hash, get_cached_block_hashes, fallback_to_official_rpc, watermarks, retry loop)
  • LRU cache (1M entries) remains as a fast-path to avoid DB roundtrips

This resolves #109

Test plan

  • Full sync completes without hash resolution errors
  • Pseudo-peer reconnects after main node disconnect

🤖 Generated with Claude Code

@sprites0 sprites0 changed the title fix(pseudo-peer): replace panics in hash_to_block_number with Result refactor+fix(pseudo-peer): cache watermark strategy and remove panics Mar 4, 2026
@sprites0 sprites0 changed the title refactor+fix(pseudo-peer): cache watermark strategy and remove panics Improve pseudo-peer cache strategy and error handling Mar 4, 2026
@sprites0 sprites0 changed the title Improve pseudo-peer cache strategy and error handling Resolve hash→number via node DB instead of backfill scanning Mar 14, 2026
@sprites0 sprites0 force-pushed the fix/pseudo-peer-remove-panics branch 2 times, most recently from a8cdb97 to 98a03cc Compare March 14, 2026 07:28
@sprites0 sprites0 changed the title Resolve hash→number via node DB instead of backfill scanning Simplify pseudo-peer: DB-based hash resolution + direct trusted peer connection Mar 14, 2026
@sprites0 sprites0 changed the title Simplify pseudo-peer: DB-based hash resolution + direct trusted peer connection refactor(pseudo-peer): use DB for hash resolution and direct trusted peer connection Mar 14, 2026
@sprites0 sprites0 force-pushed the fix/pseudo-peer-remove-panics branch 2 times, most recently from d82bde9 to 80d08d2 Compare March 14, 2026 07:37
@sprites0 sprites0 changed the title refactor(pseudo-peer): use DB for hash resolution and direct trusted peer connection refactor(pseudo-peer): DB hash resolution + direct trusted peer Mar 14, 2026
sprites0 and others added 3 commits March 14, 2026 07:46
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…iscovery

Remove boot nodes and discovery (discv4/DNS) since the pseudo-peer
always connects to a known local node. Use add_trusted_peer so the
peer auto-reconnects and is never evicted after backoff failures.
Set max_inbound to 0 since only one outbound connection is needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…kfill scanning

Pass a DbBlockNumberFn closure from build_network into the pseudo-peer
for direct hash→number lookups against the node's header DB. Remove
~200 lines of backfill/cache-warming code. The LRU cache remains as a
fast-path to avoid DB roundtrips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sprites0 sprites0 force-pushed the fix/pseudo-peer-remove-panics branch from bfa0728 to adc5606 Compare March 14, 2026 07:47
@sprites0 sprites0 changed the title refactor(pseudo-peer): DB hash resolution + direct trusted peer refactor(pseudo-peer): direct trusted peer + DB hash resolution Mar 14, 2026
@sprites0 sprites0 marked this pull request as ready for review March 14, 2026 07:51
@sprites0
Copy link
Collaborator Author

Finally!

@sprites0 sprites0 merged commit 74ec5cd into node-builder Mar 14, 2026
4 checks passed
@sprites0 sprites0 deleted the fix/pseudo-peer-remove-panics branch March 14, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For initial sync + Bodies stage, --local-ingest-dir reads excessive amount of file repeatedly

1 participant