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: make 09-localhost stateless #6683

Merged

Conversation

gjermundgaraba
Copy link
Contributor

Description

This PR makes the localhost light client stateless.
A couple of notes for reviwers:

  • I've removed the localhost migration code from the v7 upgrade, because the tests broke, and I assumed that if they are running the v9 code and coming from a ConsenusVersion that would trigger the v7 upgrades, we can safely ignore it as all the localhost state gets deleted on the final RunMigrations anyway.
  • I've tried to update the docs, but please have a look and see if you think it makes things clear and if something might be missing
  • As per the discussions in make localhost a stateless implementation #5959 the localhost client state is returned from queries, which added a couple of required checks in genesis export to make sure we don't accidentally export it.

closes: #5959


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/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@gjermundgaraba
Copy link
Contributor Author

Hmm, or would it somehow be better to keep a separate module account like the staking module does?

// GetBondedPool returns the bonded tokens pool's module account
func (k Keeper) GetBondedPool(ctx context.Context) (bondedPool sdk.ModuleAccountI) {
  return k.authKeeper.GetModuleAccount(ctx, types.BondedPoolName)
}

// GetNotBondedPool returns the not bonded tokens pool's module account
func (k Keeper) GetNotBondedPool(ctx context.Context) (notBondedPool sdk.ModuleAccountI) {
  return k.authKeeper.GetModuleAccount(ctx, types.NotBondedPoolName)
}

@colin-axner colin-axner self-assigned this Jul 1, 2024
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.

Looks great! Left various comments as I think we can simplify things even just a little more. I can push the changes when I get a moment

modules/light-clients/09-localhost/light_client_module.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/migrations.go Outdated Show resolved Hide resolved
modules/core/02-client/migrations/v9/store.go Outdated Show resolved Hide resolved
docs/docs/05-migrations/13-v8-to-v9.md Outdated Show resolved Hide resolved
@colin-axner colin-axner marked this pull request as draft July 3, 2024 09:34
req = &types.QueryClientStatesRequest{}
},
true,
},
{
"success, only localhost",
Copy link
Contributor

Choose a reason for hiding this comment

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

grpc should no longer return localhost in its query. There's no information to obtain, as it would just return back the height of the request

Copy link
Member

Choose a reason for hiding this comment

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

that makes sense!

@colin-axner
Copy link
Contributor

I am updating the code to remove the localhost client state entirely. The localhost module will now be a single file (really 2 functions) 🎉

@@ -486,21 +483,6 @@ func (suite *KeeperTestSuite) TestWasmSudo() {
},
types.ErrWasmAttributesNotAllowed,
},
{
"failure: invalid clientstate type",
Copy link
Contributor

Choose a reason for hiding this comment

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

this became a duplicate test case

clientState, found := getClientState(clientStore, cdc)
if !found {
return errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID)
// ensure the proof provided is the expected sentinel localhost client proof
Copy link
Contributor

Choose a reason for hiding this comment

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

moved over the impl from client state

@colin-axner colin-axner marked this pull request as ready for review July 3, 2024 11:00
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.

Looks great! Nice diffs 🔴 🔴

Thank you @gjermundgaraba and @colin-axner! 🙏🏻

docs/docs/05-migrations/13-v8-to-v9.md Outdated Show resolved Hide resolved
req = &types.QueryClientStatesRequest{}
},
true,
},
{
"success, only localhost",
Copy link
Member

Choose a reason for hiding this comment

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

that makes sense!

modules/core/02-client/keeper/migrations.go Outdated Show resolved Hide resolved
clientStore := l.storeProvider.ClientStore(ctx, exported.LocalhostClientID)
clientStore.Set(host.ClientStateKey(), clienttypes.MustMarshalClientState(l.cdc, &clientState))
return nil
func (LightClientModule) Initialize(ctx sdk.Context, clientID string, clientState, consensusStateBz []byte) error {
Copy link
Member

Choose a reason for hiding this comment

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

unsure if its necessary but could _ unused args, we had a linter complain at this at some point before (I'm not sure we still use it tho)

Copy link
Contributor

Choose a reason for hiding this comment

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

I will try and report back!

Copy link
Contributor

Choose a reason for hiding this comment

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

looks to be fine. Will update all args unused in the module to be discarded

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.

looks amazing! Great work both!

modules/core/02-client/keeper/migrations.go Outdated Show resolved Hide resolved
colin-axner and others added 4 commits July 3, 2024 15:36
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
…' of github.com:cosmos/ibc-go into gjermund/5959-make-localhost-a-stateless-implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

unsure if we want to delete this file, but left for now

@colin-axner colin-axner added this pull request to the merge queue Jul 3, 2024
Copy link

sonarcloud bot commented Jul 3, 2024

Merged via the queue into main with commit db955c4 Jul 3, 2024
91 of 97 checks passed
@colin-axner colin-axner deleted the gjermund/5959-make-localhost-a-stateless-implementation branch July 3, 2024 15:07
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.

make localhost a stateless implementation
5 participants