Skip to content

Commit 57feabe

Browse files
authored
eth, internal/ethapi: make RPC block miner field show block sealer correctly (ethereum#23312)
Makes the RPC block return the POA sealer for clique blocks on the 'miner' field (was previously zeroes)
1 parent 16ecdd5 commit 57feabe

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

eth/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs,
342342
} else {
343343
blockRlp = fmt.Sprintf("0x%x", rlpBytes)
344344
}
345-
if blockJSON, err = ethapi.RPCMarshalBlock(block, true, true); err != nil {
345+
if blockJSON, err = ethapi.RPCMarshalBlock(block, true, true, api.eth.engine); err != nil {
346346
blockJSON = map[string]interface{}{"error": err.Error()}
347347
}
348348
results = append(results, &BadBlockArgs{

internal/ethapi/api.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/ethereum/go-ethereum/common"
3333
"github.com/ethereum/go-ethereum/common/hexutil"
3434
"github.com/ethereum/go-ethereum/common/math"
35+
"github.com/ethereum/go-ethereum/consensus"
3536
"github.com/ethereum/go-ethereum/consensus/clique"
3637
"github.com/ethereum/go-ethereum/consensus/ethash"
3738
"github.com/ethereum/go-ethereum/consensus/misc"
@@ -1175,7 +1176,8 @@ func FormatLogs(logs []vm.StructLog) []StructLogRes {
11751176
}
11761177

11771178
// RPCMarshalHeader converts the given header to the RPC output .
1178-
func RPCMarshalHeader(head *types.Header) map[string]interface{} {
1179+
func RPCMarshalHeader(head *types.Header, engine consensus.Engine) map[string]interface{} {
1180+
miner, _ := engine.Author(head)
11791181
result := map[string]interface{}{
11801182
"number": (*hexutil.Big)(head.Number),
11811183
"hash": head.Hash(),
@@ -1185,7 +1187,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
11851187
"sha3Uncles": head.UncleHash,
11861188
"logsBloom": head.Bloom,
11871189
"stateRoot": head.Root,
1188-
"miner": head.Coinbase,
1190+
"miner": miner,
11891191
"difficulty": (*hexutil.Big)(head.Difficulty),
11901192
"extraData": hexutil.Bytes(head.Extra),
11911193
"size": hexutil.Uint64(head.Size()),
@@ -1206,8 +1208,8 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
12061208
// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
12071209
// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
12081210
// transaction hashes.
1209-
func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
1210-
fields := RPCMarshalHeader(block.Header())
1211+
func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, engine consensus.Engine) (map[string]interface{}, error) {
1212+
fields := RPCMarshalHeader(block.Header(), engine)
12111213
fields["size"] = hexutil.Uint64(block.Size())
12121214

12131215
if inclTx {
@@ -1242,15 +1244,15 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]i
12421244
// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires
12431245
// a `PublicBlockchainAPI`.
12441246
func (s *PublicBlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} {
1245-
fields := RPCMarshalHeader(header)
1247+
fields := RPCMarshalHeader(header, s.b.Engine())
12461248
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, header.Hash()))
12471249
return fields
12481250
}
12491251

12501252
// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires
12511253
// a `PublicBlockchainAPI`.
12521254
func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
1253-
fields, err := RPCMarshalBlock(b, inclTx, fullTx)
1255+
fields, err := RPCMarshalBlock(b, inclTx, fullTx, s.b.Engine())
12541256
if err != nil {
12551257
return nil, err
12561258
}

0 commit comments

Comments
 (0)