From ed9a4df60b0c224d1d75de3e8ec7769e4fdf07c9 Mon Sep 17 00:00:00 2001 From: piersy Date: Thu, 19 Sep 2024 12:05:32 +0100 Subject: [PATCH] Allow ethclient to fetch blocks with empty uncles (#228) The first blocks of the celo chain (till gingerbread) lacked the uncles field, so to support retrieving them with the ethclient.Client this modification is required. --- ethclient/ethclient.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 8a15483021..1680ec1092 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -150,7 +150,10 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 { return nil, errors.New("server returned non-empty uncle list but block header indicates no uncles") } - if head.UncleHash != types.EmptyUncleHash && len(body.UncleHashes) == 0 { + // In celo before the ginerbread hardfork, blocks had no uncles hash and no + // uncles, so in those cases it is legitimate to have an empty uncles hash. + var emptyHash common.Hash + if head.UncleHash != emptyHash && head.UncleHash != types.EmptyUncleHash && len(body.UncleHashes) == 0 { return nil, errors.New("server returned empty uncle list but block header indicates uncles") } if head.TxHash == types.EmptyTxsHash && len(body.Transactions) > 0 {