-
Notifications
You must be signed in to change notification settings - Fork 22
Error codes
ian edited this page Apr 28, 2023
·
3 revisions
Notice: Error codes here are only used in system scripts. For scripts developer, please submit the error codes document to https://github.com/nervosnetwork/ckb-script-error-codes
Due to the design of CKB's VM execution model, the only thing a script running on CKB can communicate with the outside world, is a 8-bit integer value. 0
is treated as success, anything else is treated as execution failure. As a result, we can only use different return code to denote different script execution failure. Here, we document all the error codes that can occur in CKB's system scripts.
Error Code | Reason |
---|---|
1 | Requesting index is out of boundary. This typically happens when a transaction has 3 inputs, but you are requesting for the 4th one. |
2 | Item missing. When requesting certain optional elements this can happen. For example, some cell might not have type scripts. If the script requires a type script but the prepared transaction doesn't have one, this will be returned. |
-101 | Secp256k1 data loading error. Right now secp256k1's code and data sections are separated in different cells, if a transaction doesn't include the cell dep used to reference secp256k1's data section, this would be returned. |
-102 | Secp256k1 encounters an illegal state. Ideally this should not happen, otherwise please fill a bug report. |
-103 | Secp256k1 encounters an error state. Ideally this should not happen, otherwise please fill a bug report. |
-1 | Argument length error. If the script receives an invalid length of arguments, this would be returned. Typically this means the lock/type script structure constructed has a problem, or a signature has an incorrect length. |
-2 | Encoding error. Typically happens when the data fail molecule's parsing checks, or the data passed in surpasses the script's maximum allowed limit. |
-3 | Syscall error. Happens when a syscall fails to load the requested data. When this happens, it's best to re-check the transaction to make sure it follows the enclosing scripts requirements, typical reasons include invalid cell data length/format, missing type scripts, missing required witnesses, etc. |
-11 | Secp256k1 fails to recover a public key, please recheck the signature used. |
-14 | Secp256k1 fails to parse the signature, please recheck to make sure a valid compact signature is used. |
-15 | Secp256k1 fails to serialize the public key, please also check the signature here. |
-21 | Script too long. The system script has a fixed upper bound on the accepted serialized script size(32K right now). If your script is too big(for example, an attacker includes too much script arg data), this would be returned. |
-22 | Witness too long. The system script has a fixed upper bound on the accepted witness size(32K right now). If your witness is too big(for example, an attacker includes too much witness data), this would be returned. |
-23 | Incorrect since flags. CKB supports multiple since types, if 2 since types are used in comparison, this error would be returned. Note for some use cases, it might be possible to convert a since value to a different type, but the system scripts choose to opt for the safe side and do no conversions. |
-24 | An incorrect since value is used. |
-31 | The public key hash calculated from the signature does not match public key hash requested in the script. Note due to the way recoverable signature works, an invalid signature can actual signal this error. |
-41 | An invalid reserved field value is used in the multisig script. |
-42 | No public key hash is provided in the multisig script, at least one public key is needed. |
-43 | Threshold value is bigger than provided public key hash in the multisig script, or 0 is used as threshold value. Threshold should always be a number between 1 and the number of provided public key hash. |
-44 | Required public key hash number is bigger than threshold. |
-51 | P2SH failure in multisig script, meaning the provided data do not match hash included in the multisig script args. |
-52 | Multisig verification failure, meaning one of the following conditions are not met: 1. The number of valid signatures is less than the threshold. Note the user could provide enough signatures, but some signature might not match any of requested public key hash. 2. The required public key hashes are not all provided. |