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

imp: use bytes in wasm contract api instead of wrapped types #5154

Merged
merged 15 commits into from
Nov 30, 2023

Conversation

crodriguezvega
Copy link
Contributor

@crodriguezvega crodriguezvega commented Nov 21, 2023

Description

Changes for:

  • VerifyClientMessageMsg
  • InstantiateMessage
  • VerifyUpgradeAndUpdateStateMsg
  • CheckForMisbehaviourMsg
  • UpdateStateMsg
  • UpdateStateOnMisbehaviourMsg

Contract changes here.

closes: #XXXX

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


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.
  • 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.

ConsensusState *ConsensusState `json:"consensus_state"`
ClientState []byte `json:"client_state"`
ConsensusState []byte `json:"consensus_state"`
Checksum []byte `json:"checksum"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left the checksum here for now.

Copy link
Member

Choose a reason for hiding this comment

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

What about latest height. Also, I don't see why contracts would need their own checksum. I think we should remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add it because the contract takes the latest height from the underlying client state (the bytes that we are passing here) and uses that to set the latest height of the 08-wasm wrapping type.

Happy to remove the checksum if you do me the favour to figure out how the contract can calculate that itself. I don't think I will have the time to investigate that. 🙏

Copy link
Member

Choose a reason for hiding this comment

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

Happy to keep. Contracts can only get this through a querier which we are passing nil. I think this was the only way to get it for standard contracts. I still don't see the reason why the contract should be aware of its own codehash.

Also it can get its own code hash during other executions from the clientStore right? Eitherway. Happy to keep.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should assume that the contract cannot get it's own codehash in instantiate if we remove this since we are not passing in a querier. But it can get it during other executions. I think the contract does not need it's own codeHash in instantiate and we could remove this. I'm in favour of removal but happy to hear what others think

ConsensusState *ConsensusState `json:"consensus_state"`
ClientState []byte `json:"client_state"`
ConsensusState []byte `json:"consensus_state"`
Checksum []byte `json:"checksum"`
Copy link
Member

Choose a reason for hiding this comment

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

What about latest height. Also, I don't see why contracts would need their own checksum. I think we should remove this.

@crodriguezvega crodriguezvega changed the title imp: use bytes in wasm contract api instead of wrapped types (WiP) imp: use bytes in wasm contract api instead of wrapped types Nov 24, 2023
@@ -101,7 +103,7 @@ func (suite *TypesTestSuite) TestVerifyClientMessage() {
clientState := endpoint.GetClientState()

clientMsg = &types.ClientMessage{
Data: []byte{1},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could have left this as it was, but I like using tests as some sort of documentation as well, and thus being explicit that we expect a header here it's more helpful for the reader, I think.

modules/light-clients/08-wasm/testing/values.go Outdated Show resolved Hide resolved
@@ -29,8 +29,11 @@ func (endpoint *WasmEndpoint) CreateClient() error {
checksum, err := types.CreateChecksum(Code)
require.NoError(endpoint.Chain.TB, err)

clientState := types.NewClientState(contractClientState, checksum, clienttypes.NewHeight(0, 1))
consensusState := types.NewConsensusState(contractConsensusState)
wrappedClientStateBz := clienttypes.MustMarshalClientState(endpoint.Chain.App.AppCodec(), CreateMockWrappedClientState(clienttypes.NewHeight(1, 5)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
wrappedClientStateBz := clienttypes.MustMarshalClientState(endpoint.Chain.App.AppCodec(), CreateMockWrappedClientState(clienttypes.NewHeight(1, 5)))
wrappedClientStateBz := clienttypes.MustMarshalClientState(endpoint.Chain.App.AppCodec(), MockWrappedClientState)

Would this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to use a different mock client state with a different height than MockWrappedClientState because there are some tests where the client state is updated with MockWrappedClientState and wanted to verify that the height actually changes.

@damiannolan
Copy link
Member

CI is now green 👍🏻

I didn't modify the migrate contract files migrate_success.wasm.gz and migrate_error.wasm.gz but the tests are now passing. Is this expected @srdtrk?

@crodriguezvega
Copy link
Contributor Author

I didn't modify the migrate contract files migrate_success.wasm.gz and migrate_error.wasm.gz but the tests are now passing. Is this expected @srdtrk?

Yes, that is expected, since we didn't change anything in the migration flow.

Thanks for getting CI green, @damiannolan @chatton! 🍾

@crodriguezvega crodriguezvega added the priority PRs that need prompt reviews label Nov 28, 2023
@crodriguezvega
Copy link
Contributor Author

Note for myself: I need to update the docs.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks everyone who contributed to this PR 🙏🏻

@github-actions github-actions bot added the docs Improvements or additions to documentation label Nov 29, 2023
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

ACK docs, thanks @crodriguezvega 🙏🏻

I left one suggestion for noting the base64 encoded byte strings

docs/docs/03-light-clients/04-wasm/07-contracts.md Outdated Show resolved Hide resolved
@crodriguezvega crodriguezvega merged commit f2cc21c into main Nov 30, 2023
75 checks passed
@crodriguezvega crodriguezvega deleted the serdar/carlos/contract-api-bytes branch November 30, 2023 13:04
mergify bot pushed a commit that referenced this pull request Nov 30, 2023
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
(cherry picked from commit f2cc21c)

# Conflicts:
#	docs/docs/03-light-clients/04-wasm/07-contracts.md
#	e2e/tests/wasm/contracts/ics10_grandpa_cw_expiry.wasm.gz
#	e2e/tests/wasm/grandpa_test.go
#	modules/light-clients/08-wasm/testing/values.go
#	modules/light-clients/08-wasm/testing/wasm_endpoint.go
#	modules/light-clients/08-wasm/types/client_state_test.go
#	modules/light-clients/08-wasm/types/misbehaviour_handle_test.go
#	modules/light-clients/08-wasm/types/proposal_handle_test.go
#	modules/light-clients/08-wasm/types/update_test.go
#	modules/light-clients/08-wasm/types/upgrade_test.go
mergify bot pushed a commit that referenced this pull request Nov 30, 2023
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
(cherry picked from commit f2cc21c)

# Conflicts:
#	e2e/tests/wasm/contracts/ics10_grandpa_cw_expiry.wasm.gz
#	e2e/tests/wasm/grandpa_test.go
#	modules/light-clients/08-wasm/testing/wasm_endpoint.go
#	modules/light-clients/08-wasm/types/client_state_test.go
#	modules/light-clients/08-wasm/types/update_test.go
DimitrisJim pushed a commit that referenced this pull request Nov 30, 2023
…#5154) (#5275)

* imp: use bytes in wasm contract api instead of wrapped types (#5154)

Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
(cherry picked from commit f2cc21c)

# Conflicts:
#	docs/docs/03-light-clients/04-wasm/07-contracts.md
#	e2e/tests/wasm/contracts/ics10_grandpa_cw_expiry.wasm.gz
#	e2e/tests/wasm/grandpa_test.go
#	modules/light-clients/08-wasm/testing/values.go
#	modules/light-clients/08-wasm/testing/wasm_endpoint.go
#	modules/light-clients/08-wasm/types/client_state_test.go
#	modules/light-clients/08-wasm/types/misbehaviour_handle_test.go
#	modules/light-clients/08-wasm/types/proposal_handle_test.go
#	modules/light-clients/08-wasm/types/update_test.go
#	modules/light-clients/08-wasm/types/upgrade_test.go

* fix conflicts

* delete e2e

* delete docs file

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
damiannolan added a commit that referenced this pull request Nov 30, 2023
…#5154) (#5276)

* imp: use bytes in wasm contract api instead of wrapped types (#5154)

Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
(cherry picked from commit f2cc21c)

# Conflicts:
#	e2e/tests/wasm/contracts/ics10_grandpa_cw_expiry.wasm.gz
#	e2e/tests/wasm/grandpa_test.go
#	modules/light-clients/08-wasm/testing/wasm_endpoint.go
#	modules/light-clients/08-wasm/types/client_state_test.go
#	modules/light-clients/08-wasm/types/update_test.go

* fix conflicts

* delete e2e

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
damiannolan added a commit that referenced this pull request Dec 5, 2023
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08-wasm docs Improvements or additions to documentation e2e priority PRs that need prompt reviews
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants