Fix bor receipts (#8391)

This commit is contained in:
ledgerwatch 2023-10-06 08:43:34 +01:00 committed by GitHub
parent bdc9d5577b
commit ca271b1824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 19 deletions

View File

@ -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

View File

@ -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)