From 065e21eae82e87690b4dbea5a50cef0cabe01888 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Fri, 27 Oct 2023 14:50:23 -0400 Subject: [PATCH 1/2] rm pending block for now --- eth/polar/api_backend.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/eth/polar/api_backend.go b/eth/polar/api_backend.go index b810b98d7..92353a955 100644 --- a/eth/polar/api_backend.go +++ b/eth/polar/api_backend.go @@ -243,8 +243,10 @@ func (b *backend) BlockByNumber(_ context.Context, number rpc.BlockNumber) (*typ // Pending block is only known by the miner switch number { case rpc.PendingBlockNumber: - block := b.polar.miner.PendingBlock() - return block, nil + header := b.polar.blockchain.CurrentBlock() + return b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil + // block := b.polar.miner.PendingBlock() + // return block, nil // Otherwise resolve and return the block case rpc.LatestBlockNumber: header := b.polar.blockchain.CurrentBlock() @@ -307,16 +309,24 @@ func (b *backend) StateAndHeaderByNumber( ctx context.Context, number rpc.BlockNumber, ) (state.StateDB, *types.Header, error) { + var header *types.Header // Pending state is only known by the miner if number == rpc.PendingBlockNumber { - block, state := b.polar.miner.Pending() - return state, block.Header(), nil - } - // Otherwise resolve the block number and return its state - header, err := b.HeaderByNumber(ctx, number) - if err != nil { - return nil, nil, err + header = b.polar.blockchain.CurrentBlock() + // The above code is returning a block from the blockchain based on the given header hash and block + // number. + // return b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil + // block, state := b.polar.miner.Pending() + // return state, block.Header(), nil + } else { + // Otherwise resolve the block number and return its state + var err error + header, err = b.HeaderByNumber(ctx, number) + if err != nil { + return nil, nil, err + } } + if header == nil { // to match Geth return nil, nil, core.ErrBlockNotFound From c267b46537f13e7474a0cd75814c0c19d9d0ba6c Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Fri, 27 Oct 2023 15:05:40 -0400 Subject: [PATCH 2/2] linter --- eth/polar/api_backend.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eth/polar/api_backend.go b/eth/polar/api_backend.go index 92353a955..22f86b435 100644 --- a/eth/polar/api_backend.go +++ b/eth/polar/api_backend.go @@ -313,7 +313,8 @@ func (b *backend) StateAndHeaderByNumber( // Pending state is only known by the miner if number == rpc.PendingBlockNumber { header = b.polar.blockchain.CurrentBlock() - // The above code is returning a block from the blockchain based on the given header hash and block + // The above code is returning a block from the blockchain based on the given header + // hash and block // number. // return b.polar.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil // block, state := b.polar.miner.Pending()