Skip to content

Commit

Permalink
fix: api: return errors on failure to lookup an eth txn receipt (#11329)
Browse files Browse the repository at this point in the history
All these cases here are actually errors and returning `nil` makes this
hard to debug. We likely returned nil in the past to be "best effort"
but, as far as I can tell, we should only hit these error cases if
something is actually wrong.

part of #11325
  • Loading branch information
Stebalien committed Oct 24, 2023
1 parent 84b0751 commit 6e22c08
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,31 @@ func (a *EthModule) EthGetTransactionReceiptLimited(ctx context.Context, txHash
}

msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, c, limit, true)
if err != nil || msgLookup == nil {
if err != nil {
return nil, xerrors.Errorf("failed to lookup Eth Txn %s as %s: %w", txHash, c, err)
}
if msgLookup == nil {
// This is the best we can do. In theory, we could have just not indexed this
// transaction, but there's no way to check that here.
return nil, nil
}

tx, err := newEthTxFromMessageLookup(ctx, msgLookup, -1, a.Chain, a.StateAPI)
if err != nil {
return nil, nil
return nil, xerrors.Errorf("failed to convert %s into an Eth Txn: %w", txHash, err)
}

var events []types.Event
if rct := msgLookup.Receipt; rct.EventsRoot != nil {
events, err = a.ChainAPI.ChainGetEvents(ctx, *rct.EventsRoot)
if err != nil {
return nil, nil
return nil, xerrors.Errorf("failed get events for %s", txHash)
}
}

receipt, err := newEthTxReceipt(ctx, tx, msgLookup, events, a.Chain, a.StateAPI)
if err != nil {
return nil, nil
return nil, xerrors.Errorf("failed to convert %s into an Eth Receipt: %w", txHash, err)
}

return &receipt, nil
Expand Down

0 comments on commit 6e22c08

Please sign in to comment.