Merge pull request #9932 from filecoin-project/raulk/eth-jsonrpc-api-fixes-1

fix: Eth JSON-RPC API: eth_getTransactionByHash should return nil when not found
This commit is contained in:
Aayush Rajasekaran 2022-12-22 10:22:46 -05:00 committed by GitHub
commit 6faa901914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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