ZcashFoundation / zebra

Zcash - Financial Privacy in Rust 🦓
https://zfnd.org/zebra/
Apache License 2.0
404 stars 96 forks source link

feature: match zcashd RPC error codes #8782

Open conradoplg opened 3 weeks ago

conradoplg commented 3 weeks ago

Motivation

We currently return the error code 0 for most RPC errors.

We might want to return the same error codes that zcashd does. (However, we might want to investigate if people rely on them at all before spending time working on this)

Here are some specific instances which we might want to do right away to support specific use cases:

Specifications

The return codes are not documented. There is a list of them in bitcoin source; we would need to identify which error is returned when in the zcashd source (or do a best-effort of trying to assign the errors that make more sense in each case)

Complex Code or Requirements

No response

Testing

We might want to extend zcash-rpc-diff to test this

Related Work

No response

arya2 commented 3 weeks ago

However, we might want to investigate if people rely on them at all before spending time working on this

This should be a quick change that may not be worth investigating too deeply.

We might want to extend zcash-rpc-diff to test this

zcash-rpc-diff should support this already, we'll just need to run it with parameters or in circumstances where we expect the errors.

oxarbitrage commented 3 weeks ago

For a bit of more context here, @nuttycom tried to run some tests for the lightwalletd GetTransaction grpc method using zcashd and then zebrad as the backend.

~/work/lightwalletd on ᚠfix/get_transaction_notfound [$] via 🐹 v1.22.2 on ☁️   googleplay@z.cash(us-east1)
✗ grpcurl -d @ na-lax.zcashd.zec.rocks:443 cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction <<EOM
{"hash": "OVmYYbd17odbutVyi9YaHZqAbyBzixVG6q/wTdwgEFM="}
EOM
ERROR:
  Code: Unknown
  Message: -5: No such mempool or blockchain transaction. Use gettransaction for wallet transactions.

~/work/lightwalletd on ᚠfix/get_transaction_notfound [$] via 🐹 v1.22.2 on ☁️   googleplay@z.cash(us-east1)
✗ grpcurl -d @ zec.rocks:443 cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction <<EOM
{"hash": "OVmYYbd17odbutVyi9YaHZqAbyBzixVG6q/wTdwgEFM="}
EOM
ERROR:
  Code: Unknown
  Message: 0: Transaction not found

https://discordapp.com/channels/809218587167293450/809251029673312267/1275488658421448736