From 733fcbbc65bca69e28480f624e2aeb170c97cb3e Mon Sep 17 00:00:00 2001 From: Martin HS Date: Wed, 21 Aug 2024 09:22:33 +0200 Subject: [PATCH] eth/protocols/eth: handle zero-count header requests (#30305) Proper fix for handling `count=0` get header requests. https://en.wikipedia.org/wiki/Count_Zero --- eth/protocols/eth/handlers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index bdc630a9f4..b3886270f3 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -42,6 +42,9 @@ func handleGetBlockHeaders(backend Backend, msg Decoder, peer *Peer) error { // ServiceGetBlockHeadersQuery assembles the response to a header query. It is // exposed to allow external packages to test protocol behavior. func ServiceGetBlockHeadersQuery(chain *core.BlockChain, query *GetBlockHeadersRequest, peer *Peer) []rlp.RawValue { + if query.Amount == 0 { + return nil + } if query.Skip == 0 { // The fast path: when the request is for a contiguous segment of headers. return serviceContiguousBlockHeaderQuery(chain, query)