mimblewimble / grin

Minimal implementation of the Mimblewimble protocol.
https://grin.mw/
Apache License 2.0
5.04k stars 991 forks source link

we can only fast sync against a full archival node #986

Closed antiochp closed 6 years ago

antiochp commented 6 years ago

Right now we fast sync by -

The third step requires us to request full blocks from peers. We currently ensure the peer has the full block by only running body_sync against full archival nodes (with more work than us) -

https://github.com/mimblewimble/grin/blob/f0cf903adc33cee56494099ebb2218c1a06c18ae/servers/src/grin/sync.rs#L207-L210

This feels wrong for a couple of reasons -

  1. We should be able to safely fast sync from a node that itself was fast sync'd
  2. Most nodes should have recent blocks, regardless of archival status

I wonder if the heuristic can be something along the lines of - "If requesting a block pre-horizon then only request from full archival peers, but if requesting a full block post-horizon then any peer (with more work) will do"?

The existing behavior also adds some further complication - we determine how many blocks to request during body_sync as a function of the number of peers we have. But we are then only requesting blocks from archival peers and there may only be a few archival nodes out there. These archival nodes are going to be overwhelmed if we have lots of connected peers and lots of peers attempting to sync.

ignopeverell commented 6 years ago

Your heuristic sounds good to me. We could also do "if requesting in fast-sync...." I think.