Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for creating and updating ICS 08 WASM clients wrapping an ICS 07 Tendermint client #3943

Merged
merged 40 commits into from
Apr 22, 2024

Conversation

romac
Copy link
Member

@romac romac commented Apr 11, 2024

Part of: #3951

Depends on: #3942

Manual testing instructions

1. Get simd with Wasm client support

From the root of the hermes repository, on this branch, run:

❯ nix shell '.#ibc-go-v7-wasm-simapp'
❯ which simd
/nix/store/3pp59wi249yd30dmr7hb49wbm9s19zci-simd-v7.3.0-wasm/bin/simd

Or build simd on this branch of ibc-go: https://github.com/cosmos/ibc-go/tree/08-wasm/release/v0.1.x%2Bibc-go-v7.3.x-wasmvm-v1.5.x

2. Setup two simd chains with Wasm support

Put this into ./gm.toml, update gaiad_binary to point to the simd binary we installed above, and update the path to the hermes binary:

[global]
home_dir             = "$HOME/.gm"
gaiad_binary         = "/nix/store/3pp59wi249yd30dmr7hb49wbm9s19zci-simd-v7.3.0-wasm/bin/simd"
extra_wallets        = 1
auto_maintain_config = true
add_to_hermes        = true

[global.hermes]
binary            = "$HOME/Informal/Code/hermes/target/debug/hermes"
config            = "$HOME/.hermes/config.toml"
log_level         = "debug"
telemetry_enabled = false
telemetry_host    = "127.0.0.1"
telemetry_port    = 3001

[ibc0-wasm]
ports_start_at = 27000

[ibc1-wasm]
ports_start_at = 28000

3. Create the chains and update their config

Create, then stop and re-initialize the chains:

❯ GM_TOML=./gm.toml gm start
❯ GM_TOML=./gm.toml gm stop
❯ GM_TOML=./gm.toml gm nuke

Update the config of the chain ibc0-wasm:

  • Fetch the scripts from this Gist: https://gist.github.com/romac/80eddfd304ec03562badf23d9b43f892

  • Run enable-was.py:

    $ p3 enable-wasm.py ~/.gm/ibc0-wasm/
  • Or do it manually:

    • In ~/.gm/ibc0-wasm/config/config.toml, change max_body_bytes to 10001048576
    • In ~/.gm/ibc0-wasm/config/genesis.json, change:
      • max_deposit_period to 10s
      • voting_period to 10s
      • Add 08-wasm to the list of alloed clients in allowed_clients
@@ -246,8 +246,8 @@
             "amount": "10000000"
           }
         ],
-        "max_deposit_period": "172800s",
-        "voting_period": "172800s",
+        "max_deposit_period": "10s",
+        "voting_period": "10s",
         "quorum": "0.334000000000000000",
         "threshold": "0.500000000000000000",
         "veto_threshold": "0.334000000000000000",
@@ -276,6 +276,7 @@
           "allowed_clients": [
             "06-solomachine",
             "07-tendermint",
+            "08-wasm",
             "09-localhost"
           ]
         },

4. Start the chains

❯ GM_TOML=./gm.toml hermes config
❯ GM_TOML=./gm.toml hermes keys
❯ GM_TOML=./gm.toml gm start

5. Install the contract on chain

  • Get a wallet address of the validator account for ibc0-wasm
❯ GM_TOML=./gm.toml gm keys ibc0-wasm
- address: cosmos15culynpgfdcfupl3f2yrzmav4t8hhpfalc2eu6
  name: validator
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A4qOppP8gT3fF/671w7qKBFllT0DTlzwawwZ9b2dx926"}'
  • Run the install script from the Gist:
❯ python3 ./install-wasm.py ibc0-wasm tcp://localhost:27000 cosmos15culynpgfdcfupl3f2yrzmav4t8hhpfalc2eu6 tools/integration-test/fixtures/wasm/ibc_client_tendermint_cw.wasm

6. Create a Wasm client using Hermes

❯ cargo run -- create client --host-chain ibc0-wasm --reference-chain ibc1-wasm --wasm-checksum 08eb0025bc235c3114946ab5124ade365061c4529068dcae180357e819a7cb07
SUCCESS CreateClient(
    CreateClient(
        Attributes {
            client_id: ClientId(
                "08-wasm-0",
            ),
            client_type: Wasm,
            consensus_height: Height {
                revision: 0,
                height: 220,
            },
        },
    ),
)

7. Update the Wasm client using Hermes

❯ cargo run -- update client --host-chain ibc0-wasm --client 08-wasm-0
SUCCESS [
    UpdateClient(
        UpdateClient {
            common: Attributes {
                client_id: ClientId(
                    "08-wasm-0",
                ),
                client_type: Wasm,
                consensus_height: Height {
                    revision: 0,
                    height: 232,
                },
            },
            header: None,
        },
    ),
]

PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@romac romac force-pushed the romac/wasm-tendermint-client branch from b476dcf to 3fbeba7 Compare April 11, 2024 10:16
@romac romac force-pushed the romac/wasm-tendermint-client branch from 3fbeba7 to 0bf4c1e Compare April 11, 2024 10:17
@romac romac force-pushed the romac/wasm-tendermint-client branch from ec57792 to c070f89 Compare April 12, 2024 13:31
@romac romac force-pushed the romac/wasm-tendermint-client branch from 544478d to 291acf5 Compare April 16, 2024 09:27
@romac romac force-pushed the romac/wasm-tendermint-client branch from 5b6ae05 to 3af6d9a Compare April 17, 2024 08:57
@romac romac changed the title WIP: Support for ICS 08 WASM clients wrapping an ICS 07 Tendermint client WIP: Support for creating and updating ICS 08 WASM clients wrapping an ICS 07 Tendermint client Apr 17, 2024
@romac romac force-pushed the romac/wasm-tendermint-client branch from 084ea13 to 7ced2f7 Compare April 17, 2024 15:57
@romac romac changed the title WIP: Support for creating and updating ICS 08 WASM clients wrapping an ICS 07 Tendermint client Support for creating and updating ICS 08 WASM clients wrapping an ICS 07 Tendermint client Apr 17, 2024
@romac romac force-pushed the romac/wasm-tendermint-client branch from 417ce18 to c6ec09a Compare April 18, 2024 10:10
@romac
Copy link
Member Author

romac commented Apr 18, 2024

CI consistently fails with

Client refresh failed: error raised while updating client on chain ibc1: failed sending message to dst chain
Caused by:
gRPC call send_tx_simulate failed with status: status: Unknown, message: "recovered: IBC validation/execution context error: ICS02 Client error: other error: cannot convert into a Height type from string \0\0\0\0\0\0\0-: wasm contract call failed [cosmos/ibc-go/modules/light-clients/08-wasm/types/vm.go:156]

whereas the test goes through successfully locally on macOS.

I was able to reproduce the failure, though not consistently, by tweaking the trusting_period of the clients. I wonder if there is a race condition where the client expires after we have sent the UpdateClient message, which ends up triggering the error above within the Wasm contract? That said, in the test the clients are refreshed way before their trusting period, so this shouldn't come into play.

Interestingly, it's only the second client (B -> A) which fails to refresh, never the first one.

@romac
Copy link
Member Author

romac commented Apr 18, 2024

Alright, increasing the trusting period on CI fixed it, no idea why though…

@romac romac changed the base branch from master to romac/wasm-client April 18, 2024 15:00
@romac romac marked this pull request as ready for review April 18, 2024 15:02
@romac romac requested review from ljoss17 and ancazamfir April 18, 2024 15:02
Copy link
Contributor

@ljoss17 ljoss17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for this!!
I left a few nits and questions

Copy link
Contributor

@ljoss17 ljoss17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@romac romac merged commit 018e2f1 into romac/wasm-client Apr 22, 2024
38 checks passed
@romac romac deleted the romac/wasm-tendermint-client branch April 22, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants