Skip to content

Commit

Permalink
Merge branch 'develop' into manav/miner-fix-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed Feb 7, 2025
2 parents 3336707 + 44775d8 commit 1f5efb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 2 additions & 3 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,8 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t

// Verify the validator list match the local contract
if IsSprintStart(number+1, c.config.CalculateSprint(number)) {
// Use parent block's hash to make the eth_call to fetch validators so that the state being
// used to make the call is of the same fork.
newValidators, err := c.spanner.GetCurrentValidatorsByBlockNrOrHash(context.Background(), rpc.BlockNumberOrHashWithHash(header.ParentHash, false), number+1)
newValidators, err := c.spanner.GetCurrentValidatorsByBlockNrOrHash(context.Background(), rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber), number+1)

if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions ethclient/bor_ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1f5efb2

Please sign in to comment.