AbstractSDK / cw-orchestrator

All-in-one Rust-based CosmWasm testing, scripting, and deployment tool.
https://orchestrator.abstract.money
GNU General Public License v3.0
75 stars 17 forks source link

Modify cw-orch-interchain API + Doc updates #435

Closed Kayanski closed 1 month ago

Kayanski commented 1 month ago

This PR aims at making the cw-orch-interchain API AND docs better. The names of functions are still up for discussion, so here are the components that are used regularly :

Checklist

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 51.30435% with 56 lines in your changes missing coverage. Please review.

Project coverage is 54.9%. Comparing base (59451dd) to head (2cd8a4e).

Additional details and impacted files | [Files](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK) | Coverage Δ | | |---|---|---| | [packages/clone-testing/src/contract\_instance.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Fclone-testing%2Fsrc%2Fcontract_instance.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY2xvbmUtdGVzdGluZy9zcmMvY29udHJhY3RfaW5zdGFuY2UucnM=) | `100.0% <100.0%> (ø)` | | | [packages/clone-testing/src/core.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Fclone-testing%2Fsrc%2Fcore.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY2xvbmUtdGVzdGluZy9zcmMvY29yZS5ycw==) | `83.4% <100.0%> (+0.8%)` | :arrow_up: | | [packages/clone-testing/src/lib.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Fclone-testing%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvY2xvbmUtdGVzdGluZy9zcmMvbGliLnJz) | `68.0% <ø> (ø)` | | | [packages/interchain/interchain-core/src/types.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Finterchain-core%2Fsrc%2Ftypes.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9pbnRlcmNoYWluLWNvcmUvc3JjL3R5cGVzLnJz) | `4.0% <ø> (+0.2%)` | :arrow_up: | | [...nterchain/interchain-daemon/src/channel\_creator.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Finterchain-daemon%2Fsrc%2Fchannel_creator.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9pbnRlcmNoYWluLWRhZW1vbi9zcmMvY2hhbm5lbF9jcmVhdG9yLnJz) | `0.0% <0.0%> (ø)` | | | [packages/interchain/proto/src/tokenfactory.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Fproto%2Fsrc%2Ftokenfactory.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9wcm90by9zcmMvdG9rZW5mYWN0b3J5LnJz) | `0.0% <0.0%> (ø)` | | | [packages/interchain/proto/src/ics20.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Fproto%2Fsrc%2Fics20.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9wcm90by9zcmMvaWNzMjAucnM=) | `0.0% <0.0%> (ø)` | | | [...kages/interchain/interchain-mock/src/interchain.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Finterchain-mock%2Fsrc%2Finterchain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9pbnRlcmNoYWluLW1vY2svc3JjL2ludGVyY2hhaW4ucnM=) | `84.3% <66.6%> (-1.5%)` | :arrow_down: | | [packages/interchain/starship/src/lib.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Fstarship%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9zdGFyc2hpcC9zcmMvbGliLnJz) | `0.0% <0.0%> (ø)` | | | [...kages/interchain/interchain-core/src/ack\_parser.rs](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree&filepath=packages%2Finterchain%2Finterchain-core%2Fsrc%2Fack_parser.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK#diff-cGFja2FnZXMvaW50ZXJjaGFpbi9pbnRlcmNoYWluLWNvcmUvc3JjL2Fja19wYXJzZXIucnM=) | `20.8% <0.0%> (+4.8%)` | :arrow_up: | | ... and [2 more](https://app.codecov.io/gh/AbstractSDK/cw-orchestrator/pull/435?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AbstractSDK) | |
cloudflare-pages[bot] commented 1 month ago

Deploying cw-orchestrator with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2cd8a4e
Status:🚫  Build failed.

View logs

CyberHoward commented 1 month ago

Since we're working with the "interchain" I think get_chain is fine!

follow_packets -> await_packets? follow_and check_packets -> await_packets_res? follow_packets_from_txhash -> await_packets_for_tx?

Think it's nice to use await here as it indicates that the execution will wait for the packets to propagate (which isn't entirely clear for "follow").

Buckram123 commented 1 month ago

This PR aims at making the cw-orch-interchain API AND docs better. The names of functions are still up for discussion, so here are the components that are used regularly :

* `get_chain(chain_id)` to get the chain (Mock, Daemon) associated with the chain id

  * This was renamed from `chain` to avoid conflicts with `Iterator::Chain` (that pops up inside rust-analyzer for some reason)
  * This could be renamed `environment`, as it's the method used inside contracts to get the execution environment

Have you considered just get? I guess we can have similar API to std::collections::HashMap since InterchainEnv is just collection of chains. Also regarding iterators, is it possible to imlpement Iterator of (ChainId, Chain) for InterchainEnv ?

* `follow_packets(tx_response)` that checks wether there are some packets inside a transaction result and follows the execution of all the packet sent during the transaction across remote chains. It also picks up other packets sent during the packet lifecycle (Receive, Ack, Timeout) and follows their execution. This returns when the packets have completed their cycle. (or it took too long and `cw-orch times-out)

I like follow_packets, could also be track_packets

* `follow_and check_packets(tx_response)`. This follows packets and **THEN** makes sure that:

  * There was no timeout
  * The resulting acknowledgments are successful. This last step is not possible for every packet type as there is no enforced standard for packet ack formats.

ensure_packets?

* `follow_packets_from_txhash(txhash: String)`. This queries the transaction response associated with the hash and then executes `follow_packets` on this transaction

follow_packets_txhash, track_packets_txhash

Kayanski commented 1 month ago

Have you considered just get? I guess we can have similar API to std::collections::HashMap since InterchainEnv is just collection of chains. Also regarding iterators, is it possible to imlpement Iterator of (ChainId, Chain) for InterchainEnv ?

The underlying objects are accessible on the env that we have, and devs can use it. I don't think it should be assumed that the underlying object is a HashMap though, because it doesn't have to be

Thanks for the other feedback