From ca271b18243fd20206ffe76067363285bcce3a18 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 6 Oct 2023 08:43:34 +0100 Subject: [PATCH] Fix bor receipts (#8391) --- turbo/jsonrpc/eth_receipts.go | 26 +++++++++----------------- turbo/jsonrpc/eth_txs.go | 2 -- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/turbo/jsonrpc/eth_receipts.go b/turbo/jsonrpc/eth_receipts.go index 1d623605a..0e582d0c7 100644 --- a/turbo/jsonrpc/eth_receipts.go +++ b/turbo/jsonrpc/eth_receipts.go @@ -626,23 +626,16 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Ha if err != nil { return nil, err } - - if !ok && cc.Bor == nil { - return nil, nil - } - - // if not ok and cc.Bor != nil then we might have a bor transaction. - // Note that Private API returns 0 if transaction is not found. - if !ok || blockNum == 0 { - blockNumPtr, err := rawdb.ReadBorTxLookupEntry(tx, txnHash) + // Private API returns 0 if transaction is not found. + if blockNum == 0 && cc.Bor != nil { + blockNum, ok, err = api._blockReader.EventLookup(ctx, tx, txnHash) if err != nil { return nil, err } - if blockNumPtr == nil { - return nil, nil - } + } - blockNum = *blockNumPtr + if !ok { + return nil, nil } block, err := api.blockByNumberWithSenders(tx, blockNum) @@ -664,19 +657,18 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Ha } var borTx types.Transaction - if txn == nil { + if txn == nil && cc.Bor != nil { borTx = rawdb.ReadBorTransactionForBlock(tx, blockNum) if borTx == nil { - return nil, nil + borTx = types.NewBorTransaction() } } - receipts, err := api.getReceipts(ctx, tx, cc, block, block.Body().SendersFromTxs()) if err != nil { return nil, fmt.Errorf("getReceipts error: %w", err) } - if txn == nil { + if txn == nil && cc.Bor != nil { borReceipt, err := rawdb.ReadBorReceipt(tx, block.Hash(), blockNum, receipts) if err != nil { return nil, err diff --git a/turbo/jsonrpc/eth_txs.go b/turbo/jsonrpc/eth_txs.go index d2086c1b3..c6fbe8377 100644 --- a/turbo/jsonrpc/eth_txs.go +++ b/turbo/jsonrpc/eth_txs.go @@ -3,7 +3,6 @@ package jsonrpc import ( "bytes" "context" - "fmt" "math/big" "github.com/ledgerwatch/erigon-lib/common" @@ -42,7 +41,6 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash common.Has if err != nil { return nil, err } - fmt.Printf("Found block num %d, ok %t\n", blockNum, ok) } if ok { block, err := api.blockByNumberWithSenders(tx, blockNum)