From 3f4bf9c1f4d9985fdf1392bf9eee1d6e6715c889 Mon Sep 17 00:00:00 2001 From: "stefan.pingel@consensys.net" Date: Fri, 18 Oct 2024 15:09:03 +1000 Subject: [PATCH 1/2] add requests root to empty block check Signed-off-by: stefan.pingel@consensys.net --- .../besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index 524851af5f6..6b75f33dee0 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -108,6 +108,9 @@ private boolean hasEmptyBody(final BlockHeader header) { && header .getWithdrawalsRoot() .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) + .orElse(true) + && header.getRequestsRoot() + .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) .orElse(true); } From 2ab40e3f39a1ad812826c0da81738bbe1b981103 Mon Sep 17 00:00:00 2001 From: "stefan.pingel@consensys.net" Date: Fri, 18 Oct 2024 15:45:21 +1000 Subject: [PATCH 2/2] move to BlockHeader Signed-off-by: stefan.pingel@consensys.net --- .../besu/ethereum/core/BlockHeader.java | 13 +++++++++++++ .../eth/sync/tasks/CompleteBlocksTask.java | 15 +-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java index 42f99fafb69..7ff841280de 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java @@ -92,6 +92,19 @@ public BlockHeader( this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this)); } + public static boolean hasEmptyBlock(final BlockHeader blockHeader) { + return blockHeader.getOmmersHash().equals(Hash.EMPTY_LIST_HASH) + && blockHeader.getTransactionsRoot().equals(Hash.EMPTY_TRIE_HASH) + && blockHeader + .getWithdrawalsRoot() + .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) + .orElse(true) + && blockHeader + .getRequestsRoot() + .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) + .orElse(true); + } + /** * Returns the block mixed hash. * diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index 6b75f33dee0..ec679e53a14 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -19,7 +19,6 @@ import static java.util.concurrent.CompletableFuture.completedFuture; import static java.util.stream.Collectors.toMap; -import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -75,7 +74,7 @@ private CompleteBlocksTask( this.headers = headers; this.blocks = headers.stream() - .filter(this::hasEmptyBody) + .filter(BlockHeader::hasEmptyBlock) .collect( toMap( BlockHeader::getNumber, @@ -102,18 +101,6 @@ private boolean isWithdrawalsEnabled( return protocolSchedule.getByBlockHeader(header).getWithdrawalsProcessor().isPresent(); } - private boolean hasEmptyBody(final BlockHeader header) { - return header.getOmmersHash().equals(Hash.EMPTY_LIST_HASH) - && header.getTransactionsRoot().equals(Hash.EMPTY_TRIE_HASH) - && header - .getWithdrawalsRoot() - .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) - .orElse(true) - && header.getRequestsRoot() - .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) - .orElse(true); - } - public static CompleteBlocksTask forHeaders( final ProtocolSchedule protocolSchedule, final EthContext ethContext,