Skip to content

feat(p2p): fan out catch-up sync across all lagging peers concurrently - #131

Open
secretnamebasis wants to merge 3 commits into
DEROFDN:community-devfrom
secretnamebasis:feat/torrent_peer_conections
Open

feat(p2p): fan out catch-up sync across all lagging peers concurrently#131
secretnamebasis wants to merge 3 commits into
DEROFDN:community-devfrom
secretnamebasis:feat/torrent_peer_conections

Conversation

@secretnamebasis

Copy link
Copy Markdown

Description

trigger_sync's default catch-up path now fans out fetching missing blocks across every currently-eligible lagging peer concurrently, instead of fetching sequentially from a single peer one block at a time.

  • Block assignment is Pruned-aware per unit (a peer is only assigned a block it hasn't pruned away), not a blanket per-peer exclusion.
  • A fetch failure retries against a different eligible peer (up to 2 retries) before being treated as final.
  • Worker concurrency scales to real peer availability each tick, instead of a fixed pool size.
  • Blocks are committed in strict ascending order (required by Add_Complete_Block's parent-chain check), with panic recovery around the commit call so a bad block can't take down the daemon.
  • Falls back to the existing, unmodified single-peer sync_chain() when fan-out's own preconditions aren't met (fewer than 2 eligible peers, the chain-request call fails, or no missing blocks are found), so current behavior remains the safety net.
  • Fast-sync (--fastsync / bootstrap_chain) is a separate mechanism and is untouched.

Tested against real mainnet peers: multiple consecutive sync ticks each committed full batches with zero regressions, and peer diversity per tick scaled correctly with real peer availability once the concurrency fix landed.

Fixes # (issue)
No linked issue — this is a proactive sync-performance improvement, not a bug report.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted ?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc (documentation, comments, text...)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

License

Im am contributing & releasing the code under DERO Research License (which can be found here).

Let me know if you want me to actually open the PR (targeting dev on deroproject/derohe) with this, or if you'll paste it in yourself.

secretnamebasis and others added 3 commits August 25, 2026 22:09
trigger_sync's chain.Sync path now dispatches missing blocks across every
currently-eligible peer at once instead of fetching sequentially from a
single peer. Assignment is Pruned-aware per block, retries a different
peer on a fetch failure, and scales concurrency to real peer availability
each tick. Falls back to the original single-connection sync_chain() when
fewer than 2 eligible peers are available, so the existing path stays
intact as a safety net. Fast-sync (bootstrap_chain) is untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmRAFW3ZtNqNLHr3NZh4xH
Comments referenced internal planning cycle numbers ("kata cycle #N",
"test item N") and session-narrative framing ("caught live", "this
session") that don't belong in durable source comments. Rewritten to
keep the technical why, dropped the process narration. No behavior,
signature, or test-assertion changes - build, vet, and the full race
test suite are unaffected.
Same fix as on feat/torrent-and-pipeline-merge: bootstrap_chain()
writes topo-store placeholder entries with BLOCK_ID=zerohash but a
non-zero State_Version, which TopoRecord.IsClean() treats as
"not clean" - so while bootstrap is mid-write, Get_Top_ID() can return
the zero hash literally, and fill_common's ReadBlockSnapshotVersion
lookup on that hash panics (maps to a shard directory that
legitimately never exists). Treat a zero Get_Top_ID() as "chain not
ready yet" and skip the lookup instead of panicking. Same signature,
no call-site changes.
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.

1 participant