From 4bd261e60551c746d84875d5af365efd51c8d1f6 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 22 Sep 2023 11:22:05 +0200 Subject: [PATCH 1/4] WIP --- docs/docs/dev_docs/contracts/common_errors.md | 43 ++++++++++++++++--- docs/sidebars.js | 1 + 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index ce96e27ed09..53d3665b1aa 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -1,9 +1,42 @@ -# Errors - -List common errors. +# Common Errors There are two kinds of errors: errors in an Aztec.nr contract, and errors spat out by an Aztec Sandbox node! +This section will provide an overview of the errors you might encounter, and how to fix them. + +### Assertion Error + +This error is thrown when a condition is not met. + +This is what the error typically looks like: +``` +Simulation error: Assertion failed: Balance too low 'sum == amount' +``` + +To address the error find the line in the contract that is throwing the error, and investigate why the condition is not met. + +### Unknown Contract Error +This error occurs when you are trying to interact with a smart contract via an Aztec RPC Server that does not have the necessary information to execute a transaction. + +This is what the error typically looks like: +``` + Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to Aztec RPC server by calling server.addContracts(...) +``` + +To execute a transaction, the Aztec RPC Server needs to know the complete address of a contract, portal address (if portal is used) and contract artifacts. + +To address the error, add the contract to the Aztec RPC Server by calling `server.addContracts(...)`. + +### Unknown Complete Address Error +This error occurs when your contract is trying to get a public key via the `get_public_key` oracle call, but the Aztec RPC Server does not have the Complete Address (Complete Address contains the public key). + +This is what the error typically looks like: +``` +Simulation error: Unknown complete address for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Add the information to Aztec RPC server by calling server.registerRecipient(...) or server.registerAccount(...) +``` -Maybe even auto-generate error docs, based on error codes in our codebase. +Your contract typically needs a public key when it wants to send a note to a recipient because the public key is used to encrypt notes. -Make sure descriptions of errors relate to the end user experience. An error like 'SegFault' is useless to a contract developer! \ No newline at end of file +:::info +Manually adding the recipient to the Aztec RPC Server should not be required in case the recipient contract has already been deployed and the Aztec RPC Server is fully synced. +This is because this information is submitted on-chain when the recipient contract is deployed. +::: \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 7bc4f2b58b3..454eec4d8e3 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -271,6 +271,7 @@ const sidebars = { "dev_docs/contracts/portals/outbox", ], }, + "dev_docs/contracts/common_errors", // { // label: "Resources", // type: "category", From 12ac3adbe361edfcd28e99bb63c121ca4245337e Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 22 Sep 2023 11:30:25 +0200 Subject: [PATCH 2/4] WIP --- docs/docs/dev_docs/contracts/common_errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index 53d3665b1aa..c247a6e8b54 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -19,7 +19,7 @@ This error occurs when you are trying to interact with a smart contract via an A This is what the error typically looks like: ``` - Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to Aztec RPC server by calling server.addContracts(...) +Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to Aztec RPC server by calling server.addContracts(...) ``` To execute a transaction, the Aztec RPC Server needs to know the complete address of a contract, portal address (if portal is used) and contract artifacts. From c6a0ce6e153d85070af1daaafaeffec1b7962866 Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 22 Sep 2023 13:21:24 +0200 Subject: [PATCH 3/4] WIP --- docs/docs/dev_docs/contracts/common_errors.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index c247a6e8b54..51d2c26f3bb 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -39,4 +39,15 @@ Your contract typically needs a public key when it wants to send a note to a rec :::info Manually adding the recipient to the Aztec RPC Server should not be required in case the recipient contract has already been deployed and the Aztec RPC Server is fully synced. This is because this information is submitted on-chain when the recipient contract is deployed. -::: \ No newline at end of file +::: + +### Unknown account +This error occurs when your contract is trying to get a secret via the `get_secret` oracle call, but the Aztec RPC Server does not have the secret for the public key. + +This is what the error typically looks like: +``` +Could not process note because of "Error: Unknown account.". Skipping note... +``` + +This error might occurr when you register an account only as a recipient and not as an account. +To address the error, register the account by calling `server.registerAccount(...)`. \ No newline at end of file From a100dfd69262021aa3d58862e5f6b50c52904048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Fri, 22 Sep 2023 15:30:18 +0200 Subject: [PATCH 4/4] Update docs/docs/dev_docs/contracts/common_errors.md Co-authored-by: spypsy --- docs/docs/dev_docs/contracts/common_errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index 51d2c26f3bb..cefaa8535fb 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -12,7 +12,7 @@ This is what the error typically looks like: Simulation error: Assertion failed: Balance too low 'sum == amount' ``` -To address the error find the line in the contract that is throwing the error, and investigate why the condition is not met. +To address the error. find the line in the contract that is throwing the error and investigate why the condition is not met. ### Unknown Contract Error This error occurs when you are trying to interact with a smart contract via an Aztec RPC Server that does not have the necessary information to execute a transaction.