Skip to content

Commit

Permalink
Allow ethclient to fetch blocks with empty uncles (#228)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
piersy committed Oct 15, 2024
1 parent 67e1a40 commit ed9a4df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ed9a4df

Please sign in to comment.