Skip to content

Commit

Permalink
docs: including module errors codes in the module specs (#557)
Browse files Browse the repository at this point in the history
* including module errors codes in the module specs

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Signed-off-by: Spoorthi <[email protected]>
  • Loading branch information
spoo-bar authored Apr 10, 2024
1 parent 22e98b0 commit 74ce9d7
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 44 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ Contains all the PRs that improved the code without changing the behaviors.
- [#546](https://github.com/archway-network/archway/pull/546) - Adding x/cwerrors module
- [#549](https://github.com/archway-network/archway/pull/549) - Integrating x/cwerrors into x/cwica
- [#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
- [#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
- [#557](https://github.com/archway-network/archway/pull/557) - Updating the module specs to include module error codes

### Improvements

Expand Down
2 changes: 1 addition & 1 deletion x/callback/spec/03_end_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 14 additions & 0 deletions x/callback/spec/07_errors.md
Original file line number Diff line number Diff line change
@@ -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;
}
```
6 changes: 2 additions & 4 deletions x/callback/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
12 changes: 12 additions & 0 deletions x/cwerrors/spec/06_errors.md
Original file line number Diff line number Diff line change
@@ -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;
}
```
1 change: 1 addition & 0 deletions x/cwerrors/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
38 changes: 2 additions & 36 deletions x/cwica/spec/04_wasm_bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
14 changes: 14 additions & 0 deletions x/cwica/spec/05_errors.md
Original file line number Diff line number Diff line change
@@ -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;
}
```
3 changes: 2 additions & 1 deletion x/cwica/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4. [Wasm Bindings](./04_wasm_bindings.md)
5. [Module Errors](./05_errors.md)

0 comments on commit 74ce9d7

Please sign in to comment.