Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): Make RPC "incorrect parameters" error code match zcashd #6066

Merged
merged 6 commits into from
Feb 1, 2023

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Feb 1, 2023

Motivation

Some miners expect specific RPC error codes.

Closes #6054

Solution

  • return error code -1 when the parameters are incorrect

I checked the error strings and they already seem to match.

Related changes:

  • log all RPC errors at info level (we can turn this off or skip some errors if it gets noisy)
  • simplify RPC error logging implementation

Review

This is on the critical path, so I guess it's a high priority?

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

Follow Up Work

The only other error codes I could find are in the payment code, which Zebra doesn't support because it doesn't have a wallet:
https://github.com/s-nomp/s-nomp/blob/8567a4c649ab6f5ea37ac3c3901f2d9c2597199a/libs/paymentProcessor.js#L750

@teor2345 teor2345 added C-bug Category: This is a bug P-High 🔥 A-rpc Area: Remote Procedure Call interfaces A-compatibility Area: Compatibility with other nodes or wallets, or standard rules labels Feb 1, 2023
@teor2345 teor2345 requested a review from a team as a code owner February 1, 2023 00:03
@teor2345 teor2345 self-assigned this Feb 1, 2023
@teor2345 teor2345 requested review from oxarbitrage and removed request for a team February 1, 2023 00:03
@teor2345
Copy link
Contributor Author

teor2345 commented Feb 1, 2023

I manually tested this with equihash-solomining and the RPC stubs in #6067.

It got past the stage where it called the initial RPCs, so it seems to work:

$ npm start                                                                                                                                                               
                                                                                                                                                                                                           
> equihash-solomining@0.0.1 start /home/dev/equihash-solomining                                                                                                                                            
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/node_modules/stratum-pool/node_modules/equihashverify/build/Release/:$PWD/node_modules/equihashverify/build/Release/ node init.js                                  
                                                                                                                                                                                                           
POSIX Connection Limit (Safe to ignore) POSIX module not installed and resource (connection) limit was not raised                                                                                          
CLI: CLI listening on port undefined                                                                                                                                                                       
[Website][Thread 0][2023/02/01 09:58:22] Example app listening at http://0.0.0.0:8080                                                                                                                      
[Init][Thread 0][2023/02/01 09:58:22] Spawned proxy on 1 threads(s)                                                                                                                                        
[PoolWorker][Thread 0][2023/02/01 09:58:22] Daemon is still syncing with network (download blockchain) - server will be started once synced                                                                
[PoolWorker][Thread 0][2023/02/01 09:58:22] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:27] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:32] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:37] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:42] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:47] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:52] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:58:57] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:02] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:07] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:12] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:17] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:22] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:27] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:32] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:37] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:42] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:47] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
[PoolWorker][Thread 0][2023/02/01 09:59:52] Downloaded NaN% of blockchain from 6 peers                                                                                                                     
/home/dev/equihash-solomining/node_modules/bitcoinjs-lib/src/address.js:10                                                                                                                                 
  if (payload.length > 21) throw new TypeError(address + ' is too long')

mergify bot added a commit that referenced this pull request Feb 1, 2023
@mergify mergify bot merged commit 9d97919 into main Feb 1, 2023
@mergify mergify bot deleted the rpc-incorrect-params branch February 1, 2023 18:20
teor2345 added a commit that referenced this pull request Feb 6, 2023
…6066) - manually delete getblocktemplate-rpcs

* Move RPC method constants into their own module

* Rename RPC compatibility modules to avoid confusion

* Rename RPC middleware to include its new functionality

* Use FutureExt::inspect() for logging, and only format on failure

* Log all RPC errors at info level

* Make "invalid parameters" RPC error code match `zcashd`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compatibility Area: Compatibility with other nodes or wallets, or standard rules A-rpc Area: Remote Procedure Call interfaces C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use error code -1 for incorrect RPC parameters
2 participants