Skip to content

feat: make 09-localhost stateless#6683

Merged
colin-axner merged 26 commits intomainfrom
gjermund/5959-make-localhost-a-stateless-implementation
Jul 3, 2024
Merged

feat: make 09-localhost stateless#6683
colin-axner merged 26 commits intomainfrom
gjermund/5959-make-localhost-a-stateless-implementation

Conversation

@gjermundgaraba
Copy link
Copy Markdown
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 gjermundgaraba linked an issue Jun 24, 2024 that may be closed by this pull request
@crodriguezvega crodriguezvega added the priority PRs that need prompt reviews label Jun 24, 2024
@gjermundgaraba
Copy link
Copy Markdown
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
Copy Markdown
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

@colin-axner colin-axner marked this pull request as draft July 3, 2024 09:34
true,
},
{
"success, only localhost",
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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) 🎉

types.ErrWasmAttributesNotAllowed,
},
{
"failure: invalid clientstate type",
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@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! 🙏🏻

true,
},
{
"success, only localhost",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that makes sense!

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

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
Copy Markdown
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
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jul 3, 2024

Merged via the queue into main with commit db955c4 Jul 3, 2024
@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