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

Update wasm light client unit tests and tendermint/grandpa cw contract #4306

Merged
merged 9 commits into from
Sep 15, 2023
Merged

Update wasm light client unit tests and tendermint/grandpa cw contract #4306

merged 9 commits into from
Sep 15, 2023

Conversation

misko9
Copy link
Member

@misko9 misko9 commented Aug 7, 2023

update grandpa testing, update TestInitializeTendermint(), remove unnecessary test from TestConsensusStateValidateBasic(), change the update state result's height type.

Description

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.

TestInitializeTendermint(), remove unnecessary test from
TestConsensusStateValidateBasic(), change the update state result's
height type.
@@ -120,5 +120,5 @@ type checkForMisbehaviourResult struct {

type updateStateResult struct {
contractResult
Heights []exported.Height `json:"heights"`
Heights []clienttypes.Height `json:"heights"`
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I think this is right, I guess we could keep it as an interface and define structs for each different response type we could have and define a custom unmarshaller. It's not entirely clear to me if that would be needed though.

Also noting that Status can also be directly set to string instead of exported.Status.

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 better to use the concrete types when serialising json across the vm with std lib.
Not sure how well encoding/json plays with interfaces in general, its not quite like the proto3 json and the interface support with sdk codec

ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
)

func (suite *TypesTestSuite) TestExportGenesisGrandpa() {
/*func (suite *TypesTestSuite) TestExportGenesisGrandpa() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: We're waiting for the contract update for Grandpa, right? I'm guessing this is a temp commenting out for that eventuality.

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, we need updates for grandpa contract and hyperspace supporting the new wasm client changes. Then interchaintest support for any hyperspace cli/config changes (I'm pretty sure there are some). And then, finally, run interchaintest using compatible polkadot and parachain images. Once the e2e test is successful, we can harvest the test data for the wasm client's grandpa tests for the tests that require new test data.

@misko9 misko9 changed the title Update wasm light client unit tests and tendermint cw contract Update wasm light client unit tests and tendermint/grandpa cw contract Sep 1, 2023
@crodriguezvega crodriguezvega self-assigned this Sep 4, 2023
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 you very much for this PR, @misko9. I had a quick look and left just one question for now. Will review more later.

@@ -365,7 +384,7 @@ func (suite *TypesTestSuite) TestVerifyMembershipGrandpa() {
ConnectionId: connectionID,
Prefix: suite.chainA.GetPrefix(),
},
DelayPeriod: 0,
DelayPeriod: 1000000000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious: why this needed to be changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the last test data was generated, a requirement was added to Hyperspace for a non-zero delay in seconds. For generating the new test data using the e2e test, I used 1 second, 1_000_000_000, for that input to fulfill that requirement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, @misko9. I will add a comment in a follow-up PR, so that we don't lose this information.

@crodriguezvega crodriguezvega added this to the 08-wasm/v1.0.0 milestone Sep 4, 2023
@DimitrisJim DimitrisJim mentioned this pull request Sep 7, 2023
9 tasks
@@ -0,0 +1,59 @@
How to regenerate grandpa test data
Copy link
Contributor

Choose a reason for hiding this comment

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

tysm for the README, haven't tried to run these atm but really great idea you decided to add this

Copy link
Member

Choose a reason for hiding this comment

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

+1 thanks for this doc

@crodriguezvega crodriguezvega mentioned this pull request Sep 10, 2023
9 tasks
@faddat faddat mentioned this pull request Sep 11, 2023
9 tasks
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.

Great work, @misko9. Thanks a lot for regenerating the test data and updating the tests.

I am happy to work on my comments in a follow-up PR. I will also open an issue to track the work for fixing the misbehaviour tests.

@@ -173,17 +173,17 @@ func (suite *TypesTestSuite) TestValidate() {
}{
{
name: "valid client",
clientState: types.NewClientState([]byte{0}, []byte{0}, clienttypes.ZeroHeight()),
clientState: types.NewClientState([]byte{0}, []byte("01234567012345670123456701234567"), clienttypes.ZeroHeight()),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can make this magic 01234567012345670123456701234567 string a constant somewhere. I am happy to do it in a follow-up PR to speed up merging this one.

Copy link
Member

Choose a reason for hiding this comment

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

where does this magic string come from?

Would be nice to move away from hardcoded values in testing in the long term, but I think we can also work on that post-release.

Copy link
Member Author

Choose a reason for hiding this comment

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

This magic string just needs to be any 32 bytes to pass ClientState's Validate() function.

Copy link
Member

Choose a reason for hiding this comment

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

Aha, makes sense, thanks @misko9

@@ -365,7 +384,7 @@ func (suite *TypesTestSuite) TestVerifyMembershipGrandpa() {
ConnectionId: connectionID,
Prefix: suite.chainA.GetPrefix(),
},
DelayPeriod: 0,
DelayPeriod: 1000000000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, @misko9. I will add a comment in a follow-up PR, so that we don't lose this information.

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.

Thank you @misko9! Much appreciated.

@@ -0,0 +1,59 @@
How to regenerate grandpa test data
Copy link
Member

Choose a reason for hiding this comment

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

+1 thanks for this doc

@@ -120,5 +120,5 @@ type checkForMisbehaviourResult struct {

type updateStateResult struct {
contractResult
Heights []exported.Height `json:"heights"`
Heights []clienttypes.Height `json:"heights"`
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 better to use the concrete types when serialising json across the vm with std lib.
Not sure how well encoding/json plays with interfaces in general, its not quite like the proto3 json and the interface support with sdk codec

Copy link
Member

Choose a reason for hiding this comment

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

Should we create an issue for these commented out tests?

@@ -173,17 +173,17 @@ func (suite *TypesTestSuite) TestValidate() {
}{
{
name: "valid client",
clientState: types.NewClientState([]byte{0}, []byte{0}, clienttypes.ZeroHeight()),
clientState: types.NewClientState([]byte{0}, []byte("01234567012345670123456701234567"), clienttypes.ZeroHeight()),
Copy link
Member

Choose a reason for hiding this comment

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

where does this magic string come from?

Would be nice to move away from hardcoded values in testing in the long term, but I think we can also work on that post-release.

@crodriguezvega crodriguezvega merged commit 1bc5845 into cosmos:feat/wasm-clients Sep 15, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants