diff --git a/ethclient/bor_ethclient.go b/ethclient/bor_ethclient.go index d40cdc6d8e..82fa3bb1e1 100644 --- a/ethclient/bor_ethclient.go +++ b/ethclient/bor_ethclient.go @@ -8,6 +8,10 @@ import ( "github.com/ethereum/go-ethereum/core/types" ) +const ( + zeroAddress = "0x0000000000000000000000000000000000000000" +) + // GetRootHash returns the merkle root of the block headers func (ec *Client) GetRootHash(ctx context.Context, startBlockNumber uint64, endBlockNumber uint64) (string, error) { var rootHash string diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 24356d0fd5..4c7ffe649d 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -163,7 +163,13 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface return nil, errors.New("server returned empty uncle list but block header indicates uncles") } if head.TxHash == types.EmptyTxsHash && len(body.Transactions) > 0 { - return nil, errors.New("server returned non-empty transaction list but block header indicates no transactions") + // If there is only one transaction in the block and the header's txHash is `EmptyTxsHash`, + // it indicates a state-sync transaction. No error handling is required in this case. + tx := body.Transactions[0] + if (tx.From != nil && *tx.From != common.HexToAddress(zeroAddress)) || + (tx.tx.To() != nil && *tx.tx.To() != common.HexToAddress(zeroAddress)) { + return nil, errors.New("server returned non-empty transaction list but block header indicates no transactions") + } } if head.TxHash != types.EmptyTxsHash && len(body.Transactions) == 0 { return nil, errors.New("server returned empty transaction list but block header indicates transactions")