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

fix(08-wasm/test): register mockVm querier callbacks against TimestampAtHeightMsg to avoid recursive loops #5878

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

damiannolan
Copy link
Member

Description

Register querier callbacks in mockVM against TimestampAtHeightMsg instead of StatusMsg.
This avoids recursive loops introduced by yours truly in #5870, adding the client status check to the rpc handler of VerifyMembership.

If anyone would rather a different approach to fixing this issue, we could additional create an entirely separate test func for success: verify membership query and only use TimestampAtHeightMsg for that one, but it makes no difference to me.


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

clientState.Status(suite.chainA.GetContext(), clientStore, suite.chainA.App.AppCodec())

// NOTE: we register query callbacks against: types.TimestampAtHeightMsg{}
// in practise, this can against any client state msg, however registering against types.StatusMsg{} introduces recursive loops
Copy link
Contributor

Choose a reason for hiding this comment

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

due to Status being used in the VerifyMembership grpc implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to protect against this somehow? Or are avoiding recursive loops up to contract developers?

Copy link
Member Author

Choose a reason for hiding this comment

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

due to Status being used in the VerifyMembership grpc implementation?

Yes, exactly!

do we need to protect against this somehow? Or are avoiding recursive loops up to contract developers?

I feel like there is only a certain amount we can do to protect against this tbh. Any wasm client devs should be testing their code before anything like this can ever happen. I think it should be extremely rare to occur. The recursive loop scenario here imo is more due to how we use the mockVM and the fact that we are making callback into the same client state which has invoked the call.

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

swift fix 💪, these tests can get spaghetti-ish at certain points.

we also need to bp this, correct?

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

ACK, quick fix!

clientState.Status(suite.chainA.GetContext(), clientStore, suite.chainA.App.AppCodec())

// NOTE: we register query callbacks against: types.TimestampAtHeightMsg{}
// in practise, this can against any client state msg, however registering against types.StatusMsg{} introduces recursive loops
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to protect against this somehow? Or are avoiding recursive loops up to contract developers?

@colin-axner
Copy link
Contributor

should VerifyMembership conditional queries only be allowed on 08-wasm verify membership contract api? Feels like we should disable in other scenarios? But if the contract specifies its own clientID, it would be recursive regardless?

@damiannolan
Copy link
Member Author

should VerifyMembership conditional queries only be allowed on 08-wasm verify membership contract api? Feels like we should disable in other scenarios? But if the contract specifies its own clientID, it would be recursive regardless?

Yeah, its down to the implementation of the contract right? and which one its calling. But specifying its own clientID seems like something that shouldn't ever need to happen - we can probably add a defensive check here. Happy to chat about this in eng call next week.

@damiannolan damiannolan merged commit fb7b6b5 into main Feb 21, 2024
79 of 80 checks passed
@damiannolan damiannolan deleted the damian/fix-wasm-rescurive-loop-test branch February 21, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants