rpc: fix empty root and uncle hash (#45)
* rpc: fix empty root and uncle hash * changelog
This commit is contained in:
parent
6c1e7fec01
commit
956b18f45e
@ -46,6 +46,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
* (evm) [tharsis#24](https://github.com/tharsis/ethermint/pull/24)Implement metrics for `MsgEthereumTx`, state transtitions, `BeginBlock` and `EndBlock`.
|
* (evm) [tharsis#24](https://github.com/tharsis/ethermint/pull/24)Implement metrics for `MsgEthereumTx`, state transtitions, `BeginBlock` and `EndBlock`.
|
||||||
* (deps) [\#602](https://github.com/cosmos/ethermint/pull/856) Bump tendermint version to [v0.39.3](https://github.com/tendermint/tendermint/releases/tag/v0.39.3)
|
* (deps) [\#602](https://github.com/cosmos/ethermint/pull/856) Bump tendermint version to [v0.39.3](https://github.com/tendermint/tendermint/releases/tag/v0.39.3)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* (rpc) [tharsis#45](https://github.com/tharsis/ethermint/pull/45) Use `EmptyUncleHash` and `EmptyRootHash` for empty ethereum `Header` fields.
|
||||||
|
|
||||||
## [v0.4.1] - 2021-03-01
|
## [v0.4.1] - 2021-03-01
|
||||||
|
|
||||||
### API Breaking
|
### API Breaking
|
||||||
|
@ -108,15 +108,22 @@ func NewTransaction(tx *ethtypes.Transaction, blockHash common.Hash, blockNumber
|
|||||||
// EthHeaderFromTendermint is an util function that returns an Ethereum Header
|
// EthHeaderFromTendermint is an util function that returns an Ethereum Header
|
||||||
// from a tendermint Header.
|
// from a tendermint Header.
|
||||||
func EthHeaderFromTendermint(header tmtypes.Header) *ethtypes.Header {
|
func EthHeaderFromTendermint(header tmtypes.Header) *ethtypes.Header {
|
||||||
|
txHash := ethtypes.EmptyRootHash
|
||||||
|
if len(header.DataHash) == 0 {
|
||||||
|
txHash = common.BytesToHash(header.DataHash)
|
||||||
|
}
|
||||||
return ðtypes.Header{
|
return ðtypes.Header{
|
||||||
ParentHash: common.BytesToHash(header.LastBlockID.Hash.Bytes()),
|
ParentHash: common.BytesToHash(header.LastBlockID.Hash.Bytes()),
|
||||||
UncleHash: common.Hash{},
|
UncleHash: ethtypes.EmptyUncleHash,
|
||||||
Coinbase: common.Address{},
|
Coinbase: common.Address{},
|
||||||
Root: common.BytesToHash(header.AppHash),
|
Root: common.BytesToHash(header.AppHash),
|
||||||
TxHash: common.BytesToHash(header.DataHash),
|
TxHash: txHash,
|
||||||
ReceiptHash: common.Hash{},
|
ReceiptHash: ethtypes.EmptyRootHash,
|
||||||
Difficulty: nil,
|
Bloom: ethtypes.Bloom{},
|
||||||
|
Difficulty: big.NewInt(0),
|
||||||
Number: big.NewInt(header.Height),
|
Number: big.NewInt(header.Height),
|
||||||
|
GasLimit: 0,
|
||||||
|
GasUsed: 0,
|
||||||
Time: uint64(header.Time.Unix()),
|
Time: uint64(header.Time.Unix()),
|
||||||
Extra: nil,
|
Extra: nil,
|
||||||
MixDigest: common.Hash{},
|
MixDigest: common.Hash{},
|
||||||
@ -177,22 +184,23 @@ func FormatBlock(
|
|||||||
"hash": hexutil.Bytes(header.Hash()),
|
"hash": hexutil.Bytes(header.Hash()),
|
||||||
"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": ethtypes.EmptyUncleHash, // No uncles in Tendermint
|
||||||
"logsBloom": bloom,
|
"logsBloom": bloom,
|
||||||
"transactionsRoot": hexutil.Bytes(header.DataHash),
|
|
||||||
"stateRoot": hexutil.Bytes(header.AppHash),
|
"stateRoot": hexutil.Bytes(header.AppHash),
|
||||||
"miner": common.Address{},
|
"miner": common.Address{},
|
||||||
"mixHash": common.Hash{},
|
"mixHash": common.Hash{},
|
||||||
"difficulty": 0,
|
"difficulty": (*hexutil.Big)(big.NewInt(0)),
|
||||||
"totalDifficulty": 0,
|
|
||||||
"extraData": hexutil.Uint64(0),
|
"extraData": hexutil.Uint64(0),
|
||||||
"size": hexutil.Uint64(size),
|
"size": hexutil.Uint64(size),
|
||||||
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
|
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
|
||||||
"gasUsed": (*hexutil.Big)(gasUsed),
|
"gasUsed": (*hexutil.Big)(gasUsed),
|
||||||
"timestamp": hexutil.Uint64(header.Time.Unix()),
|
"timestamp": hexutil.Uint64(header.Time.Unix()),
|
||||||
|
"transactionsRoot": hexutil.Bytes(header.DataHash),
|
||||||
|
"receiptsRoot": ethtypes.EmptyRootHash,
|
||||||
|
|
||||||
|
"uncles": []common.Hash{},
|
||||||
"transactions": transactions.([]common.Hash),
|
"transactions": transactions.([]common.Hash),
|
||||||
"uncles": []string{},
|
"totalDifficulty": (*hexutil.Big)(big.NewInt(0)),
|
||||||
"receiptsRoot": common.Hash{},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +316,10 @@ func NewTransactionFromData(
|
|||||||
to = &recipient
|
to = &recipient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if txHash == (common.Hash{}) {
|
||||||
|
txHash = ethtypes.EmptyRootHash
|
||||||
|
}
|
||||||
|
|
||||||
rpcTx := &RPCTransaction{
|
rpcTx := &RPCTransaction{
|
||||||
From: from,
|
From: from,
|
||||||
Gas: hexutil.Uint64(txData.GasLimit),
|
Gas: hexutil.Uint64(txData.GasLimit),
|
||||||
|
Loading…
Reference in New Issue
Block a user