From c9eacbf3e0e6cb9e02277bfdaa7f63894dc9ccd4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 11 Oct 2023 13:05:18 -0700 Subject: [PATCH] fix: api: return errors on failure to lookup an eth txn receipt 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 --- node/impl/full/eth.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index a051b49b179..eb786d52dde 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -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