-
Notifications
You must be signed in to change notification settings - Fork 226
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
feat(rpc): Re-organize RPC errors #2038
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doitian
changed the title
feat(rpc): Organize RPC errors
feat(rpc): Re-organize RPC errors
Apr 30, 2020
doitian
added
b:rpc
Break RPC interface
breaking change
The feature breaks consensus, database, message schema or RPC interface.
labels
Apr 30, 2020
doitian
requested review from
a team,
yangby-cryptape and
quake
and removed request for
a team
April 30, 2020 02:12
yangby-cryptape
previously approved these changes
May 1, 2020
Will fix the CI error today |
doitian
added
the
s:waiting-on-author
Status: The marked PR is awaiting some action (such as code changes) from the PR author.
label
May 6, 2020
@quake @yangby-cryptape fixed clippy, please review again. |
quake
previously approved these changes
May 26, 2020
bors try |
Rebased, please review. |
quake
previously approved these changes
Jun 22, 2020
CKB - Pull Requests
automation
moved this from ✅ Reviewer approved
to 👀 Awaiting review
Jun 29, 2020
quake
previously approved these changes
Jun 29, 2020
CKB - Pull Requests
automation
moved this from 👀 Awaiting review
to ✅ Reviewer approved
Jun 29, 2020
zhangsoledad
previously approved these changes
Jun 29, 2020
bors r=quake,zhangsoledad |
bors bot
added a commit
that referenced
this pull request
Jun 30, 2020
2038: feat(rpc): Re-organize RPC errors r=quake,zhangsoledad a=doitian This PR reworks on the RPC errors: * Use JSONRPC error code to differentiate different errors. Also prefix the error code in the message to be search engine friendly. * Make error message simple and easy to understand. The dump of the error is added as the data instead. * Avoid reusing the same error message for different reasons. ## Breaking Changes * The error object `date` field is always absent before, now it can be a string which contains the detailed error information. * The `code` in error object is always -3 for all the CKB internal errors, now it can have different values to differentiate different errors. Check the file `rpc/src/error.rs`. * The error messages have been updated to improve readability. ## JSON-RPC Errors See [JSON-RPC spec](https://www.jsonrpc.org/specification#error_object). ## General Errors ┌ `CKBInternalError (-1)` Errors in this category are considered to never happen or only happen when the system resources are exhausted. ┌ `RPCModuleIsDisabled (-4)` Not all RPC modules are enabled by default. Please edit `rpc.modules` in the configuration file `ckb.toml`. ## Alert ### `send_alert` ┌ `AlertFailedToVerifySignatures (-1000)` Some signatures are invalid. ┌ `P2PFailedToBroadcast (-101)` Alert is saved locally but has failed to broadcast to the P2P network. ┌ `InvalidParams (-32602)` * Expected `params[0].notice_until` in the future. ## Chain ### `get_block_by_number` ┌ `ChainIndexIsInconsistent (-201)` The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database. ┌ `DatabaseIsCorrupt (-202)` The data read from database is dirty. Please report it as a bug. ### `get_header_by_number` ┌ `ChainIndexIsInconsistent (-201)` The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database. ### `get_cells_by_lock_hash` ┌ `InvalidParams (-32602)` * Expected `from <= to` in `params[0]`. * Expected `to - from <= 100`. ┌ `ChainIndexIsInconsistent (-201)` The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database. ## Experiment ### `dry_run_transaction` ┌ `TransactionFailedToResolve (-301)` Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies. ┌ `TransactionFailedToVerify (-302)` Failed to verify the transaction. ### `calculate_dao_maximum_withdraw` ┌ `DAOError (-5)` The given out point is not a valid cell for DAO computation. ┌ `CKBInternalError (-1)` Mathematics overflow. ## Network ### `set_ban` ┌ `InvalidParams (-32602)` * Expected `params[0]` to be a valid IP address. * Expected `params[1]` to be in the list [insert, delete]. ## Pool ### `send_transaction` ┌ `PoolRejectedTransactionByOutputsValidator (-1102)` The transaction is rejected by the validator specified by `params[1]`. If you really want to send transactions with advanced scripts, please set `params[1]` to "passthrough". ┌ `PoolRejectedTransactionByIllTransactionChecker (-1103)` Pool rejects some transactions which seem contain invalid VM instructions. See the issue link in the error message for details. ┌ `PoolRejectedTransactionByMinFeeRate (-1104)` The transaction fee rate must >= `tx_pool.min_fee_rate` in `ckb.toml`. ┌ `PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)` The ancestors count must <= `tx_pool.max_ancestors_count` in `ckb.toml`. ┌ `PoolIsFull (-1106)` Pool is full. ┌ `PoolRejectedDuplicatedTransaction (-1107)` The transaction is already in the pool. ┌ TransactionFailedToResolve (-301) Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies. ┌ TransactionFailedToVerify (-302) Failed to verify the transaction. Co-authored-by: ian <ian@nervos.org>
Build failed:
|
The error is renamed in 0a8bf97
CKB - Pull Requests
automation
moved this from ✅ Reviewer approved
to 👀 Awaiting review
Jun 30, 2020
quake
approved these changes
Jun 30, 2020
bors try |
tryBuild succeeded:
|
CKB - Pull Requests
automation
moved this from 👀 Awaiting review
to ✅ Reviewer approved
Jul 15, 2020
yangby-cryptape
approved these changes
Jul 15, 2020
bors r=quake,yangby-cryptape |
Build succeeded: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
b:rpc
Break RPC interface
breaking change
The feature breaks consensus, database, message schema or RPC interface.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks on the RPC errors:
Breaking Changes
date
field is always absent before, now it can be a string which contains the detailed error information.code
in error object is always -3 for all the CKB internal errors, now it can have different values to differentiate different errors. Check the filerpc/src/error.rs
.JSON-RPC Errors
See JSON-RPC spec.
General Errors
┌
CKBInternalError (-1)
Errors in this category are considered to never happen or only happen when the system resources are exhausted.
┌
RPCModuleIsDisabled (-4)
Not all RPC modules are enabled by default. Please edit
rpc.modules
in the configuration fileckb.toml
.Alert
send_alert
┌
AlertFailedToVerifySignatures (-1000)
Some signatures are invalid.
┌
P2PFailedToBroadcast (-101)
Alert is saved locally but has failed to broadcast to the P2P network.
┌
InvalidParams (-32602)
params[0].notice_until
in the future.Chain
get_block_by_number
┌
ChainIndexIsInconsistent (-201)
The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database.
┌
DatabaseIsCorrupt (-202)
The data read from database is dirty. Please report it as a bug.
get_header_by_number
┌
ChainIndexIsInconsistent (-201)
The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database.
get_cells_by_lock_hash
┌
InvalidParams (-32602)
from <= to
inparams[0]
.to - from <= 100
.┌
ChainIndexIsInconsistent (-201)
The index is inconsistent. It says a block hash is in the main chain, but cannot read it from database.
Experiment
dry_run_transaction
┌
TransactionFailedToResolve (-301)
Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.
┌
TransactionFailedToVerify (-302)
Failed to verify the transaction.
calculate_dao_maximum_withdraw
┌
DAOError (-5)
The given out point is not a valid cell for DAO computation.
┌
CKBInternalError (-1)
Mathematics overflow.
Network
set_ban
┌
InvalidParams (-32602)
params[0]
to be a valid IP address.params[1]
to be in the list [insert, delete].Pool
send_transaction
┌
PoolRejectedTransactionByOutputsValidator (-1102)
The transaction is rejected by the validator specified by
params[1]
. If you really want to send transactions with advanced scripts, please setparams[1]
to "passthrough".┌
PoolRejectedTransactionByIllTransactionChecker (-1103)
Pool rejects some transactions which seem contain invalid VM instructions. See the issue link in the error message for details.
┌
PoolRejectedTransactionByMinFeeRate (-1104)
The transaction fee rate must >=
tx_pool.min_fee_rate
inckb.toml
.┌
PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)
The ancestors count must <=
tx_pool.max_ancestors_count
inckb.toml
.┌
PoolIsFull (-1106)
Pool is full.
┌
PoolRejectedDuplicatedTransaction (-1107)
The transaction is already in the pool.
┌ TransactionFailedToResolve (-301)
Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.
┌ TransactionFailedToVerify (-302)
Failed to verify the transaction.