From 473e09cd2d348ecb792ffe44f64cbea072759f0b Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Tue, 28 Jun 2022 21:03:36 +0530 Subject: [PATCH] removed check from consensus, handelling everything in api.go --- consensus/bor/bor.go | 4 ---- consensus/clique/clique.go | 4 ---- internal/ethapi/api.go | 17 +++++------------ 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index 37e5f87c13..2eb2645f18 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -288,10 +288,6 @@ func New( // Author implements consensus.Engine, returning the Ethereum address recovered // from the signature in the header's extra-data section. func (c *Bor) Author(header *types.Header) (common.Address, error) { - if header.Number.Uint64() == 0 { - add := common.HexToAddress("0x0000000000000000000000000000000000000000") - return add, nil - } return ecrecover(header, c.signatures, c.config) } diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index d63e0c37e3..685186817d 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -210,10 +210,6 @@ func New(config *params.CliqueConfig, db ethdb.Database) *Clique { // Author implements consensus.Engine, returning the Ethereum address recovered // from the signature in the header's extra-data section. func (c *Clique) Author(header *types.Header) (common.Address, error) { - if header.Number.Uint64() == 0 { - add := common.HexToAddress("0x0000000000000000000000000000000000000000") - return add, nil - } return ecrecover(header, c.signatures) } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9f57da33b9..2e22095460 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -815,17 +815,17 @@ func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.H } // getAuthor: returns the author of the Block -func (s *PublicBlockChainAPI) getAuthor(head *types.Header) (*common.Address, error) { +func (s *PublicBlockChainAPI) getAuthor(head *types.Header) *common.Address { // get author using Author() function from: /consensus/clique/clique.go // In Production: get author using Author() function from: /consensus/bor/bor.go author, err := s.b.Engine().Author(head) // make sure we don't send error to the user, return 0x0 instead if err != nil { add := common.HexToAddress("0x0000000000000000000000000000000000000000") - return &add, nil + return &add } // change the coinbase (0x0) with the miner address - return &author, nil + return &author } // GetBlockByNumber returns the requested canonical block. @@ -846,10 +846,7 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B } if err == nil && number != rpc.PendingBlockNumber { - author, err := s.getAuthor(block.Header()) - if err != nil { - return nil, err - } + author := s.getAuthor(block.Header()) response["miner"] = author } @@ -872,11 +869,7 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Ha response, err := s.rpcMarshalBlock(ctx, block, true, fullTx) // append marshalled bor transaction if err == nil && response != nil { - - author, err := s.getAuthor(block.Header()) - if err != nil { - return nil, err - } + author := s.getAuthor(block.Header()) response["miner"] = author