From 2b43358c0a064b112b4cb8502e7c4615003e96dc Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:16:00 +0530 Subject: [PATCH 1/4] including module errors codes in the module specs --- x/callback/spec/03_end_block.md | 2 +- x/callback/spec/07_errors.md | 14 ++++++++++++ x/callback/spec/README.md | 6 ++--- x/cwerrors/spec/06_errors.md | 12 ++++++++++ x/cwerrors/spec/README.md | 1 + x/cwica/spec/04_wasm_bindings.md | 38 ++------------------------------ x/cwica/spec/05_errors.md | 14 ++++++++++++ x/cwica/spec/README.md | 3 ++- 8 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 x/callback/spec/07_errors.md create mode 100644 x/cwerrors/spec/06_errors.md create mode 100644 x/cwica/spec/05_errors.md diff --git a/x/callback/spec/03_end_block.md b/x/callback/spec/03_end_block.md index 76291a95..46ecb6ab 100644 --- a/x/callback/spec/03_end_block.md +++ b/x/callback/spec/03_end_block.md @@ -16,7 +16,7 @@ Every end block we iterate over all the callbacks registered at that height. For 3. Handle error - If there was any error during the execution of the callback, whether from the contract returning an error, or an out of gas error, throw a failure event with the detailed error message. + If there was any error during the execution of the callback, whether from the contract returning an error, or an out of gas error, set the error with the [x/cwerrors](../../cwerrors/spec/README.md) module with the appropriate error code. If the callback was successfull, throw a success event. diff --git a/x/callback/spec/07_errors.md b/x/callback/spec/07_errors.md new file mode 100644 index 00000000..61f67e74 --- /dev/null +++ b/x/callback/spec/07_errors.md @@ -0,0 +1,14 @@ +# Errors + +The module exposes the following error codes which are used with the x/cwerrors module in case of callback failures. + +```proto +enum ModuleErrors { + // ERR_UNKNOWN is the default error code + ERR_UNKNOWN = 0; + // ERR_OUT_OF_GAS is the error code when the contract callback exceeds the gas limit allowed by the module + ERR_OUT_OF_GAS = 1; + // ERR_CONTRACT_EXECUTION_FAILED is the error code when the contract callback execution fails + ERR_CONTRACT_EXECUTION_FAILED = 2; +} +``` \ No newline at end of file diff --git a/x/callback/spec/README.md b/x/callback/spec/README.md index 684c55e3..3f864a79 100644 --- a/x/callback/spec/README.md +++ b/x/callback/spec/README.md @@ -91,10 +91,7 @@ A sample contract which shows how the feature can be used can be found [here](.. ## Error Handling -As the contracts are executed during the protocol end blocker, it is not possible to return any execution errors to the user. -We highly recommend that user do not return any errors for the `SudoMsg::Callback` endpoint. Instead, handle it within the contract logic. - -However, any error encountered during the execution of the contract will be thrown as an explicit event. Users can subscribe to [CallbackExecutedFailedEvent](../../../proto/archway/callback/v1/events.proto#L45) to be notified of any issues with the callback. +As the contracts are executed during the protocol end blocker, it is not possible to return any execution errors to the user. However, the contract can use [x/cwerrors](../../cwerrors/spec/README.md) to get the errors when they happen. ## Contents @@ -104,6 +101,7 @@ However, any error encountered during the execution of the contract will be thro 4. [Events](./04_events.md) 5. [Client](./05_client.md) 6. [Wasm bindings](./06_wasm_bindings.md) +7. [Module Errors](./07_errors.md) ## References diff --git a/x/cwerrors/spec/06_errors.md b/x/cwerrors/spec/06_errors.md new file mode 100644 index 00000000..f6a4baf4 --- /dev/null +++ b/x/cwerrors/spec/06_errors.md @@ -0,0 +1,12 @@ +# Errors + +The module exposes the following error codes which are used with the x/cwerrors module in case of error callback failures. + +```proto +enum ModuleErrors { + // ERR_UNKNOWN is the default error code + ERR_UNKNOWN = 0; + // ERR_CALLBACK_EXECUTION_FAILED is the error code for when the error callback fails + ERR_CALLBACK_EXECUTION_FAILED = 1; +} +``` \ No newline at end of file diff --git a/x/cwerrors/spec/README.md b/x/cwerrors/spec/README.md index fb2fdc28..c07b02a3 100644 --- a/x/cwerrors/spec/README.md +++ b/x/cwerrors/spec/README.md @@ -38,6 +38,7 @@ The subscriptions are an opt-in feature where the contractadmin/owner has to sub 3. [End Block](./03_end_block.md) 4. [Events](./04_events.md) 5. [Client](./05_client.md) +6. [Module Errors](./06_errors.md) ## References diff --git a/x/cwica/spec/04_wasm_bindings.md b/x/cwica/spec/04_wasm_bindings.md index 43541918..dacc1fef 100644 --- a/x/cwica/spec/04_wasm_bindings.md +++ b/x/cwica/spec/04_wasm_bindings.md @@ -38,44 +38,10 @@ After successful interchain account transaction execution on the counterparty ch ## Transaction Execution - Failed -If the interachain account transaction failed on the counterparty chain, the sudo entrypoint will be called with the following json - -```jsonc -{ - "error": { - "module_name": "cwica", - "error_code": 2, // More details, look at archway/cwica/v1/errors.proto - "input_payload": "", // ibc packet info, serialized into a string - "error_message": "" // any relevant error message sent by the counterparty chain - } -} -``` +This is handeled by the [x/cwerrors](../../cwerrors/spec/README.md) module. ## Transaction Exectuion - Timeout -In case the ibc packet timed out ([more info on packet timeouts](https://ibc.cosmos.network/v7/ibc/overview?_highlight=timeout#receipts-and-timeouts)), the sudo entrypoint will be called with the following json - -```jsonc -{ - "error": { - "module_name": "cwica", - "error_code": 1, // More details, look at archway/cwica/v1/errors.proto - "input_payload": "", // ibc packet info, serialized into a string - "error_message": "IBC packet timeout" - } -} -``` +This is handeled by the [x/cwerrors](../../cwerrors/spec/README.md) module. Please note that packet timeouts cause the ibc channel to be closed. The channel can be reopened again by registering the ica account again using [MsgRegisterInterchainAccount](../../../proto/archway/cwica/v1/tx.proto) - -## Error Codes - -The error codes used by the module are - -```protobuf -enum ModuleErrors { - ERR_UNKNOWN = 0; - ERR_PACKET_TIMEOUT = 1; // When the ibc packet timesout - ERR_EXEC_FAILURE = 2; // When tx execution fails on counterparty chain -} -``` diff --git a/x/cwica/spec/05_errors.md b/x/cwica/spec/05_errors.md new file mode 100644 index 00000000..0ad6494f --- /dev/null +++ b/x/cwica/spec/05_errors.md @@ -0,0 +1,14 @@ +# Errors + +The module exposes the following error codes which are used with the x/cwerrors module in case of ica tx failures. + +```proto +enum ModuleErrors { + // ERR_UNKNOWN is the default error code + ERR_UNKNOWN = 0; + // ERR_PACKET_TIMEOUT is the error code for packet timeout + ERR_PACKET_TIMEOUT = 1; + // ERR_EXEC_FAILURE is the error code for tx execution failure + ERR_EXEC_FAILURE = 2; +} +``` \ No newline at end of file diff --git a/x/cwica/spec/README.md b/x/cwica/spec/README.md index 5aec50dd..8384336c 100644 --- a/x/cwica/spec/README.md +++ b/x/cwica/spec/README.md @@ -78,4 +78,5 @@ Once the txs have been submitted, the contract will receive a callback at the Su 1. [State](./01_state.md) 2. [Messages](./02_messages.md) 3. [Client](./03_client.md) -4. [Wasm Bindings](./04_wasm_bindings.md) \ No newline at end of file +4. [Wasm Bindings](./04_wasm_bindings.md) +5. [Module Errors](./05_errors.md) \ No newline at end of file From 8cb6177bb7ea2491f84a92f86ed29f8161891fc8 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:46:15 +0530 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bed11d7f..df069b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Contains all the PRs that improved the code without changing the behaviors. - [#550](https://github.com/archway-network/archway/pull/550) - Integrating x/cwerrors into x/callback module = [#551](https://github.com/archway-network/archway/pull/550) - Adding ADR-012 for x/cwerrors = [#554](https://github.com/archway-network/archway/pull/554) - Bumping ibc-go to v7.4.0 += [#555](https://github.com/archway-network/archway/pull/555) - Updating the module specs to include module error codes ### Improvements From 77f56e09f4c354d687664b73eaea11a0091cabbe Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:46:28 +0530 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df069b4a..53002a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ Contains all the PRs that improved the code without changing the behaviors. - [#550](https://github.com/archway-network/archway/pull/550) - Integrating x/cwerrors into x/callback module = [#551](https://github.com/archway-network/archway/pull/550) - Adding ADR-012 for x/cwerrors = [#554](https://github.com/archway-network/archway/pull/554) - Bumping ibc-go to v7.4.0 -= [#555](https://github.com/archway-network/archway/pull/555) - Updating the module specs to include module error codes +- [#555](https://github.com/archway-network/archway/pull/555) - Updating the module specs to include module error codes ### Improvements From ed1bd010a44366716f821ea4f5b81e32d26996c8 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:48:20 +0530 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2e4c17f..94cf9f79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ Contains all the PRs that improved the code without changing the behaviors. - [#551](https://github.com/archway-network/archway/pull/550) - Adding ADR-012 for x/cwerrors - [#554](https://github.com/archway-network/archway/pull/554) - Bumping ibc-go to v7.4.0 - [#553](https://github.com/archway-network/archway/pull/553) - Add explicit module licenses -- [#555](https://github.com/archway-network/archway/pull/555) - Updating the module specs to include module error codes +- [#557](https://github.com/archway-network/archway/pull/557) - Updating the module specs to include module error codes ### Improvements