Skip to content

Commit

Permalink
rpc: move receipts length check after bor logic (erigontech#6731)
Browse files Browse the repository at this point in the history
Fixing issue erigontech#6730
  • Loading branch information
madumas authored Jan 28, 2023
1 parent 00390a9 commit 407cfef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/rpcdaemon/commands/eth_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,6 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Ha
if err != nil {
return nil, fmt.Errorf("getReceipts error: %w", err)
}
if len(receipts) <= int(txnIndex) {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), int(txnIndex), blockNum)
}

if txn == nil {
borReceipt, err := rawdb.ReadBorReceipt(tx, block.Hash(), blockNum, receipts)
Expand All @@ -713,6 +710,10 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Ha
return marshalReceipt(borReceipt, borTx, cc, block.HeaderNoCopy(), txnHash, false), nil
}

if len(receipts) <= int(txnIndex) {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), int(txnIndex), blockNum)
}

return marshalReceipt(receipts[txnIndex], block.Transactions()[txnIndex], cc, block.HeaderNoCopy(), txnHash, true), nil
}

Expand Down

0 comments on commit 407cfef

Please sign in to comment.