forked from cerc-io/laconicd-deprecated
rpc: fix method to calculate block hash and fix mismatch block hash in eth.getBlock response (#755)
This commit is contained in:
parent
e1349e46a3
commit
6d11e23326
@ -43,7 +43,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
* (evm) [\#670](https://github.com/cosmos/ethermint/pull/670) Migrate types to the ones defined by the protobuf messages, which are required for the stargate release.
|
* (evm) [\#670](https://github.com/cosmos/ethermint/pull/670) Migrate types to the ones defined by the protobuf messages, which are required for the stargate release.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
* (evm) [\#751](https://github.com/cosmos/ethermint/issues/751) Fix misused method to calculate block hash in evm related function.
|
||||||
|
* (evm) [\#721](https://github.com/cosmos/ethermint/issues/721) Fix mismatch block hash in rpc response when use eht.getBlock.
|
||||||
* (evm) [\#730](https://github.com/cosmos/ethermint/issues/730) Fix 'EIP2028' not open when Istanbul version has been enabled.
|
* (evm) [\#730](https://github.com/cosmos/ethermint/issues/730) Fix 'EIP2028' not open when Istanbul version has been enabled.
|
||||||
* (evm) [\#749](https://github.com/cosmos/ethermint/issues/749) Fix panic in `AnteHandler` when gas price larger than 100000
|
* (evm) [\#749](https://github.com/cosmos/ethermint/issues/749) Fix panic in `AnteHandler` when gas price larger than 100000
|
||||||
* (evm) [\#747](https://github.com/cosmos/ethermint/issues/747) Fix format errors in String() of QueryETHLogs
|
* (evm) [\#747](https://github.com/cosmos/ethermint/issues/747) Fix format errors in String() of QueryETHLogs
|
||||||
|
@ -689,10 +689,11 @@ func (api *PublicEthereumAPI) GetBlockByNumber(blockNum rpctypes.BlockNumber, fu
|
|||||||
ChainID: api.clientCtx.ChainID,
|
ChainID: api.clientCtx.ChainID,
|
||||||
Height: height + 1,
|
Height: height + 1,
|
||||||
Time: time.Unix(0, 0),
|
Time: time.Unix(0, 0),
|
||||||
LastBlockID: latestBlock.BlockID,
|
LastBlockID: latestBlock.Block.LastBlockID,
|
||||||
ValidatorsHash: latestBlock.Block.NextValidatorsHash,
|
ValidatorsHash: latestBlock.Block.NextValidatorsHash,
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
|
latestBlock.Block.Hash(),
|
||||||
0,
|
0,
|
||||||
gasUsed,
|
gasUsed,
|
||||||
pendingTxs,
|
pendingTxs,
|
||||||
@ -731,7 +732,7 @@ func (api *PublicEthereumAPI) GetTransactionByHash(hash common.Hash) (*rpctypes.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
blockHash := common.BytesToHash(block.Block.Header.Hash())
|
blockHash := common.BytesToHash(block.Block.Hash())
|
||||||
|
|
||||||
ethTx, err := rpctypes.RawTxToEthTx(api.clientCtx, tx.Tx)
|
ethTx, err := rpctypes.RawTxToEthTx(api.clientCtx, tx.Tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -817,7 +818,7 @@ func (api *PublicEthereumAPI) getTransactionByBlockAndIndex(block *tmtypes.Block
|
|||||||
|
|
||||||
height := uint64(block.Height)
|
height := uint64(block.Height)
|
||||||
txHash := common.BytesToHash(block.Txs[idx].Hash())
|
txHash := common.BytesToHash(block.Txs[idx].Hash())
|
||||||
blockHash := common.BytesToHash(block.Header.Hash())
|
blockHash := common.BytesToHash(block.Hash())
|
||||||
return rpctypes.NewTransaction(ethTx, txHash, blockHash, height, uint64(idx))
|
return rpctypes.NewTransaction(ethTx, txHash, blockHash, height, uint64(idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +837,7 @@ func (api *PublicEthereumAPI) GetTransactionReceipt(hash common.Hash) (map[strin
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
blockHash := common.BytesToHash(block.Block.Header.Hash())
|
blockHash := common.BytesToHash(block.Block.Hash())
|
||||||
|
|
||||||
// Convert tx bytes to eth transaction
|
// Convert tx bytes to eth transaction
|
||||||
ethTx, err := rpctypes.RawTxToEthTx(api.clientCtx, tx.Tx)
|
ethTx, err := rpctypes.RawTxToEthTx(api.clientCtx, tx.Tx)
|
||||||
|
@ -90,7 +90,7 @@ func EthBlockFromTendermint(clientCtx clientcontext.CLIContext, block *tmtypes.B
|
|||||||
|
|
||||||
bloom := bloomRes.Bloom
|
bloom := bloomRes.Bloom
|
||||||
|
|
||||||
return FormatBlock(block.Header, block.Size(), gasLimit, gasUsed, transactions, bloom), nil
|
return FormatBlock(block.Header, block.Size(), block.Hash(), gasLimit, gasUsed, transactions, bloom), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EthHeaderFromTendermint is an util function that returns an Ethereum Header
|
// EthHeaderFromTendermint is an util function that returns an Ethereum Header
|
||||||
@ -153,7 +153,7 @@ func BlockMaxGasFromConsensusParams(_ context.Context, clientCtx clientcontext.C
|
|||||||
// FormatBlock creates an ethereum block from a tendermint header and ethereum-formatted
|
// FormatBlock creates an ethereum block from a tendermint header and ethereum-formatted
|
||||||
// transactions.
|
// transactions.
|
||||||
func FormatBlock(
|
func FormatBlock(
|
||||||
header tmtypes.Header, size int, gasLimit int64,
|
header tmtypes.Header, size int, curBlockHash tmbytes.HexBytes, gasLimit int64,
|
||||||
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
|
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
|
||||||
) map[string]interface{} {
|
) map[string]interface{} {
|
||||||
if len(header.DataHash) == 0 {
|
if len(header.DataHash) == 0 {
|
||||||
@ -162,7 +162,7 @@ func FormatBlock(
|
|||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"number": hexutil.Uint64(header.Height),
|
"number": hexutil.Uint64(header.Height),
|
||||||
"hash": hexutil.Bytes(header.Hash()),
|
"hash": hexutil.Bytes(curBlockHash),
|
||||||
"parentHash": hexutil.Bytes(header.LastBlockID.Hash),
|
"parentHash": hexutil.Bytes(header.LastBlockID.Hash),
|
||||||
"nonce": hexutil.Uint64(0), // PoW specific
|
"nonce": hexutil.Uint64(0), // PoW specific
|
||||||
"sha3Uncles": common.Hash{}, // No uncles in Tendermint
|
"sha3Uncles": common.Hash{}, // No uncles in Tendermint
|
||||||
|
@ -82,7 +82,7 @@ func getEthTransactionByHash(cliCtx context.CLIContext, hashHex string) ([]byte,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
blockHash := common.BytesToHash(block.Block.Header.Hash())
|
blockHash := common.BytesToHash(block.Block.Hash())
|
||||||
|
|
||||||
ethTx, err := rpctypes.RawTxToEthTx(cliCtx, tx.Tx)
|
ethTx, err := rpctypes.RawTxToEthTx(cliCtx, tx.Tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user