From bb5cb19607113a5dfbaa218fc2c878dd1f75d15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 22 Dec 2022 11:47:46 +0000 Subject: [PATCH] fix: Eth JSON-RPC API: eth_getTransactionByHash should return nil when not found. --- node/impl/full/eth.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index 3dcc0d99e..069f8ac9d 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -237,19 +237,22 @@ func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtype // if not found, try to get it from the mempool pending, err := a.MpoolAPI.MpoolPending(ctx, types.EmptyTSK) if err != nil { - return nil, fmt.Errorf("cannot get pending txs from mpool: %v", err) + // inability to fetch mpool pending transactions is an internal node error + // that needs to be reported as-is + return nil, fmt.Errorf("cannot get pending txs from mpool: %s", err) } for _, p := range pending { if p.Cid() == cid { tx, err := newEthTxFromFilecoinMessage(ctx, p, a.StateAPI) if err != nil { - return nil, fmt.Errorf("cannot get parse message into tx: %v", err) + return nil, fmt.Errorf("could not convert Filecoin message into tx: %s", err) } return &tx, nil } } - return nil, fmt.Errorf("cannot find cid %v from the mpool", cid) + // Ethereum clients expect an empty response when the message was not found + return nil, nil } func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkParam string) (ethtypes.EthUint64, error) {