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

feat: add wasm light client module to feat/wasm-clients branch #3486

Merged
merged 124 commits into from
Jul 6, 2023
Merged

feat: add wasm light client module to feat/wasm-clients branch #3486

merged 124 commits into from
Jul 6, 2023

Conversation

misko9
Copy link
Member

@misko9 misko9 commented Apr 18, 2023

Description

Wasm light client module

This PR adds a new light client to support wasm light client contracts. A chain that would like to use a wasm light client contract would add this module to their app.go. An existing chain will need to add 08-wasm to the allowed clients list. The module will create a wasm vm to run the wasm contracts. New contracts will be submitted through a governance proposal. Once approved, the contract can be used to create any number of clients. Gas consumption for the wasm vm is based off of wasmd's implementation. The bulk of the light client logic is executed in the contract with the module providing the interface and management of the contracts.

IBC spec: https://github.com/cosmos/ibc/tree/main/spec/client/ics-008-wasm-client

Commit Message / Changelog Entry

feat: adding 08-wasm light client module

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests. Unit tests have been written providing code coverage of the interface to a contract and the management of contracts. Currently, a version of the grandpa light client contract is being used with a couple methods stubbed out as they are still in development, but the interface is still fully exercised.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

jackzampolin and others added 30 commits September 14, 2022 12:18
return consensusState, nil
}

// ValidateSelfClient validates the client parameters for a client of the running chain
// This function is only used to validate the client state the counterparty stores for this chain
// Client must be in same revision as the executing chain
func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error {
if clientState.ClientType() == exported.Wasm {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the tendermint client state to be in data instead of directly passing tendermint client state as the state?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the client type is 08-wasm, then the tendermint client state is already in data. We are unmarshaling the tendermint client state from the wasm client state in order to validate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Won't any other non-tendermint wasm client states just fail here on line 306, which would bubble up the error to connOpenTry?
Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but this is a self client state validation. So prior to 08-wasm, only 07-tendermint self validation was supported as tendermint consensus was expected with ibc-go. This expands support to include 08-wasm using tendermint consensus for counterparty chains that need to or want to use 08-wasm + a 07-tendermint light client cosmwasm contract.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ayy, indeed! Makes sense. We'll definitely need future improvements to ValidateSelfClient in a world where sdk supports various consensus engines.

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thank so much for the fantastic work implementing this new light client module, @misko9. 🙏 Thank you also, @damiannolan and @DimitrisJim for the review of the PR and the rest of the team for spending hours also reviewing the code during our internal walkthrough. I will merge now this PR and we will continue with the remaining work on follow-up PRs.

@crodriguezvega crodriguezvega merged commit 01e8548 into cosmos:feat/wasm-clients Jul 6, 2023
@faddat faddat mentioned this pull request Sep 10, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.