rpc: display block proposer address as the miner address (#290)
* rpc: display proser address as the miner address * use validator operator address
This commit is contained in:
parent
84febdddae
commit
5e87661e4c
@ -119,7 +119,7 @@ func (e *EVMBackend) GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.EthBlockFromTendermint(e.clientCtx, e.queryClient, resBlock.Block, fullTx)
|
res, err := e.EthBlockFromTendermint(resBlock.Block, fullTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Debug("EthBlockFromTendermint failed", "height", height, "error", err.Error())
|
e.logger.Debug("EthBlockFromTendermint failed", "height", height, "error", err.Error())
|
||||||
}
|
}
|
||||||
@ -140,13 +140,11 @@ func (e *EVMBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]i
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.EthBlockFromTendermint(e.clientCtx, e.queryClient, resBlock.Block, fullTx)
|
return e.EthBlockFromTendermint(resBlock.Block, fullTx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EthBlockFromTendermint returns a JSON-RPC compatible Ethereum block from a given Tendermint block.
|
// EthBlockFromTendermint returns a JSON-RPC compatible Ethereum block from a given Tendermint block.
|
||||||
func (e *EVMBackend) EthBlockFromTendermint(
|
func (e *EVMBackend) EthBlockFromTendermint(
|
||||||
clientCtx client.Context,
|
|
||||||
queryClient evmtypes.QueryClient,
|
|
||||||
block *tmtypes.Block,
|
block *tmtypes.Block,
|
||||||
fullTx bool,
|
fullTx bool,
|
||||||
) (map[string]interface{}, error) {
|
) (map[string]interface{}, error) {
|
||||||
@ -206,15 +204,32 @@ func (e *EVMBackend) EthBlockFromTendermint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockBloomResp, err := queryClient.BlockBloom(types.ContextWithHeight(block.Height), &evmtypes.QueryBlockBloomRequest{})
|
blockBloomResp, err := e.queryClient.BlockBloom(types.ContextWithHeight(block.Height), &evmtypes.QueryBlockBloomRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Debug("failed to query BlockBloom", "height", block.Height, "error", err.Error())
|
e.logger.Debug("failed to query BlockBloom", "height", block.Height, "error", err.Error())
|
||||||
|
|
||||||
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
|
blockBloomResp = &evmtypes.QueryBlockBloomResponse{Bloom: ethtypes.Bloom{}.Bytes()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req := &evmtypes.QueryValidatorAccountRequest{
|
||||||
|
ConsAddress: sdk.ConsAddress(block.Header.ProposerAddress).String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := e.queryClient.ValidatorAccount(e.ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
e.logger.Debug("failed to query validator operator address", "cons-address", req.ConsAddress, "error", err.Error())
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
addr, err := sdk.AccAddressFromBech32(res.AccountAddress)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
validatorAddr := common.BytesToAddress(addr)
|
||||||
|
|
||||||
bloom := ethtypes.BytesToBloom(blockBloomResp.Bloom)
|
bloom := ethtypes.BytesToBloom(blockBloomResp.Bloom)
|
||||||
formattedBlock := types.FormatBlock(block.Header, block.Size(), ethermint.DefaultRPCGasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom)
|
formattedBlock := types.FormatBlock(block.Header, block.Size(), ethermint.DefaultRPCGasLimit, new(big.Int).SetUint64(gasUsed), ethRPCTxs, bloom, validatorAddr)
|
||||||
return formattedBlock, nil
|
return formattedBlock, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Contex
|
|||||||
func FormatBlock(
|
func FormatBlock(
|
||||||
header tmtypes.Header, size int, gasLimit int64,
|
header tmtypes.Header, size int, gasLimit int64,
|
||||||
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
|
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
|
||||||
|
validatorAddr common.Address,
|
||||||
) map[string]interface{} {
|
) map[string]interface{} {
|
||||||
if len(header.DataHash) == 0 {
|
if len(header.DataHash) == 0 {
|
||||||
header.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())
|
header.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())
|
||||||
@ -164,7 +165,7 @@ func FormatBlock(
|
|||||||
"sha3Uncles": ethtypes.EmptyUncleHash, // No uncles in Tendermint
|
"sha3Uncles": ethtypes.EmptyUncleHash, // No uncles in Tendermint
|
||||||
"logsBloom": bloom,
|
"logsBloom": bloom,
|
||||||
"stateRoot": hexutil.Bytes(header.AppHash),
|
"stateRoot": hexutil.Bytes(header.AppHash),
|
||||||
"miner": common.Address{},
|
"miner": validatorAddr,
|
||||||
"mixHash": common.Hash{},
|
"mixHash": common.Hash{},
|
||||||
"difficulty": (*hexutil.Big)(big.NewInt(0)),
|
"difficulty": (*hexutil.Big)(big.NewInt(0)),
|
||||||
"extraData": "",
|
"extraData": "",
|
||||||
|
Loading…
Reference in New Issue
Block a user