Skip to content

Commit

Permalink
Merge pull request #9932 from filecoin-project/raulk/eth-jsonrpc-api-…
Browse files Browse the repository at this point in the history
…fixes-1

fix: Eth JSON-RPC API: eth_getTransactionByHash should return nil when not found
  • Loading branch information
arajasek authored Dec 22, 2022
2 parents e7aa7cb + bb5cb19 commit 6faa901
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6faa901

Please sign in to comment.