Skip to content

Commit

Permalink
config: remove no-headers as it may leads to a dead peer not removing
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Jan 30, 2024
1 parent 5a43edc commit 7a10add
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
9 changes: 8 additions & 1 deletion eth/downloader/skeleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ var errTerminated = errors.New("terminated")
// with a new header, but it does not link up to the existing sync.
var errReorgDenied = errors.New("non-forced head reorg denied")

// maxBlockNumGapTolerance is the max gap tolerance by peer
var maxBlockNumGapTolerance = uint64(30)

func init() {
// Tuning parameters is nice, but the scratch space must be assignable in
// full to peers. It's a useless cornercase to support a dangling half-group.
Expand Down Expand Up @@ -793,7 +796,11 @@ func (s *skeleton) executeTask(peer *peerConnection, req *headerRequest) {
case headers[0].Number.Uint64() != req.head:
// Header batch anchored at non-requested number
peer.log.Debug("Invalid header response head", "have", headers[0].Number, "want", req.head)
res.Done <- etherror.ErrInvalidHeaderBatchAnchor
if req.head-headers[0].Number.Uint64() < maxBlockNumGapTolerance {
res.Done <- etherror.ErrHeaderBatchAnchorLow
} else {
res.Done <- etherror.ErrInvalidHeaderBatchAnchor
}
s.scheduleRevertRequest(req)

case req.head >= requestHeaders && len(headers) != requestHeaders:
Expand Down
1 change: 1 addition & 0 deletions eth/etherror/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ var (
ErrNotEnoughNonGenesisHeaders = errors.New("not enough non-genesis headers delivered")
ErrNotEnoughGenesisHeaders = errors.New("not enough genesis headers delivered")
ErrInvalidHashProgression = errors.New("invalid hash progression")
ErrHeaderBatchAnchorLow = errors.New("header batch anchor is lower than requested")
)
16 changes: 10 additions & 6 deletions eth/protocols/eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,16 @@ func Handle(backend Backend, peer *Peer) error {
for {
err := handleMessage(backend, peer)
switch {
case errors.Is(err, etherror.ErrInvalidHeaderBatchAnchor):
// ignore invalid header anchor
peer.Log().Warn("Message handling failed with invalid batch request anchor")
case errors.Is(err, etherror.ErrNoHeadersDelivered):
// ignore no headers delivered
peer.Log().Warn("Message handling failed with no headers")
// TODO: currently no headers not ignored as it may leads to a dead peer not removing as expected
/*
case errors.Is(err, etherror.ErrNoHeadersDelivered):
// ignore no headers delivered
peer.Log().Warn("Message handling failed with no headers")
*/
case errors.Is(err, etherror.ErrHeaderBatchAnchorLow):
// ignore lower header anchor within tolerance
peer.Log().Warn("Message handling failed with lower batch anchor")

case err != nil:
peer.Log().Debug("Message handling failed in `eth`", "err", err)
return err
Expand Down

0 comments on commit 7a10add

Please sign in to comment.