From ff5b5e15f17c5fc24b55c45ef426daa6d1b91195 Mon Sep 17 00:00:00 2001 From: gop Date: Fri, 8 Sep 2023 15:01:10 -0500 Subject: [PATCH] Added fetcher limit for block imports as a DDos prevention mechanism --- eth/fetcher/block_fetcher.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index f1cd195a81..f2d4e04f64 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -350,7 +350,12 @@ func (f *BlockFetcher) loop() { f.forgetBlock(hash) continue } - f.importBlocks(op.origin, op.block) + + // Only import blocks using the Fetcher if its within maxUncleDist + // This is done to prevent DDos on the append queue + if op != nil && op.block.NumberU64()+maxUncleDist > f.chainHeight() { + f.importBlocks(op.origin, op.block) + } } // Wait for an outside event to occur select {