diff --git a/changelog.md b/changelog.md index da4d082c95..1d85c97f86 100644 --- a/changelog.md +++ b/changelog.md @@ -59,6 +59,7 @@ * [2909](https://github.com/zeta-chain/node/pull/2909) - add legacy messages back to codec for querier backward compatibility * [3018](https://github.com/zeta-chain/node/pull/3018) - support `DepositAndCall` and `WithdrawAndCall` with empty payload * [3030](https://github.com/zeta-chain/node/pull/3030) - Avoid storing invalid Solana gateway address in the `SetGatewayAddress` +* [3047](https://github.com/zeta-chain/node/pull/3047) - wrong block hash in subscribe new heads ## v20.0.0 diff --git a/rpc/backend/blocks_test.go b/rpc/backend/blocks_test.go index 0b2be17809..8fdea01533 100644 --- a/rpc/backend/blocks_test.go +++ b/rpc/backend/blocks_test.go @@ -1292,7 +1292,12 @@ func (suite *BackendTestSuite) TestHeaderByNumber() { header, err := suite.backend.HeaderByNumber(tc.blockNumber) if tc.expPass { - expHeader := ethrpc.EthHeaderFromTendermint(expResultBlock.Block.Header, ethtypes.Bloom{}, tc.baseFee, validator) + expHeader := ethrpc.EthHeaderFromTendermint( + expResultBlock.Block.Header, + ethtypes.Bloom{}, + tc.baseFee, + validator, + ) suite.Require().NoError(err) suite.Require().Equal(expHeader, header) } else { @@ -1406,7 +1411,12 @@ func (suite *BackendTestSuite) TestHeaderByHash() { header, err := suite.backend.HeaderByHash(tc.hash) if tc.expPass { - expHeader := ethrpc.EthHeaderFromTendermint(expResultBlock.Block.Header, ethtypes.Bloom{}, tc.baseFee, validator) + expHeader := ethrpc.EthHeaderFromTendermint( + expResultBlock.Block.Header, + ethtypes.Bloom{}, + tc.baseFee, + validator, + ) suite.Require().NoError(err) suite.Require().Equal(expHeader, header) } else { diff --git a/rpc/backend/utils.go b/rpc/backend/utils.go index d68884c499..e297053fef 100644 --- a/rpc/backend/utils.go +++ b/rpc/backend/utils.go @@ -26,6 +26,7 @@ import ( "github.com/cometbft/cometbft/libs/log" "github.com/cometbft/cometbft/proto/tendermint/crypto" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" + tmtypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -36,7 +37,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - tmtypes "github.com/cometbft/cometbft/types" "github.com/zeta-chain/node/rpc/types" ) diff --git a/rpc/types/block.go b/rpc/types/block.go index ded8a0d607..808cd522d1 100644 --- a/rpc/types/block.go +++ b/rpc/types/block.go @@ -230,8 +230,8 @@ type Header struct { Extra hexutil.Bytes `json:"extraData" gencodec:"required"` MixDigest common.Hash `json:"mixHash"` Nonce ethtypes.BlockNonce `json:"nonce"` - BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` - WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` + BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` + WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` // overwrite rlpHash Hash common.Hash `json:"hash"` } diff --git a/rpc/types/utils.go b/rpc/types/utils.go index cbc25026df..67ee50133a 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -62,7 +62,12 @@ func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) ([]*evmtypes.MsgEth // EthHeaderFromTendermint is an util function that returns an Ethereum Header // from a tendermint Header. -func EthHeaderFromTendermint(header tmtypes.Header, bloom ethtypes.Bloom, baseFee *big.Int, miner sdk.AccAddress) *ethtypes.Header { +func EthHeaderFromTendermint( + header tmtypes.Header, + bloom ethtypes.Bloom, + baseFee *big.Int, + miner sdk.AccAddress, +) *ethtypes.Header { txHash := ethtypes.EmptyRootHash if len(header.DataHash) == 0 { txHash = common.BytesToHash(header.DataHash)