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(client): migrate client params #3640

Merged
merged 13 commits into from
May 30, 2023

Conversation

DimitrisJim
Copy link
Contributor

@DimitrisJim DimitrisJim commented May 24, 2023

Description

closes: #3500

Commit Message / Changelog Entry

feat(client)!: migrate client parameters to be self managed

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.

@DimitrisJim DimitrisJim linked an issue May 24, 2023 that may be closed by this pull request
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil {
panic("ibc client params are not set in store")

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
Copy link
Member

Choose a reason for hiding this comment

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

This is called in BeginBlocker when updating the localhost client. Personally I'd rather avoid panics entirely in these situations.

Copy link
Contributor Author

@DimitrisJim DimitrisJim May 24, 2023

Choose a reason for hiding this comment

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

Gotcha, will switch to empty params mirroring what the sdk does.

Copy link
Member

Choose a reason for hiding this comment

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

Is empty params what the sdk does? I know @colin-axner mentioned briefly that he had a minor preference for panicking, but it would be nice if we could avoid it imo.

For context, panicking in the BeginBlocker abci call is not caught by sdk's baseapp. Panicking in msg server handlers is "fine" because its caught by the grpc recovery interceptor, but doing so in BeginBlocker would crash nodes and ultimately halt a chain

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, good point, @damiannolan! I believe the SDK does not panic.

Copy link
Contributor Author

@DimitrisJim DimitrisJim May 25, 2023

Choose a reason for hiding this comment

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

That seems to be the case for x/bank, x/mint, x/staking and x/slashing. I'm sure others that migrated should follow that same pattern.

I'll hunt down Colin's comment real quick since I might of missed it, it's probably something along the lines of it doesn't make sense to return empty params if none are there.

Copy link
Contributor

Choose a reason for hiding this comment

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

My view is that unset params are a sign of a misconfigured chain which should be halted. It seems unsafe to process any transactions if certain parameters on chain haven't been decided on. My recommendation would be defense in depth, as we may choose to add params in the future which might not have a similar sane default value as allowed clients

@DimitrisJim DimitrisJim marked this pull request as ready for review May 24, 2023 09:55
Copy link
Member

@srdtrk srdtrk 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 a few nits, I think you'll need to modify app.go. And a docs entry is needed in docs/migrations/ just a reference to this issue mentioning how app.go needs to be modified.

modules/core/02-client/exported/exported.go Outdated Show resolved Hide resolved
modules/core/02-client/types/params_legacy.go Show resolved Hide resolved
modules/core/02-client/types/params_test.go Outdated Show resolved Hide resolved
modules/core/02-client/genesis.go Outdated Show resolved Hide resolved
modules/core/02-client/types/keys.go Show resolved Hide resolved
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.

Nice work! Left some comments/suggestions. Looks pretty clean so far!

modules/core/02-client/exported/exported.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/migrations.go Show resolved Hide resolved
modules/core/module.go Show resolved Hide resolved
proto/ibc/core/client/v1/tx.proto Show resolved Hide resolved
proto/ibc/core/client/v1/tx.proto Outdated Show resolved Hide resolved
modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
modules/core/keeper/keeper.go Outdated Show resolved Hide resolved
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil {
panic("ibc client params are not set in store")
Copy link
Member

Choose a reason for hiding this comment

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

This is called in BeginBlocker when updating the localhost client. Personally I'd rather avoid panics entirely in these situations.

@DimitrisJim
Copy link
Contributor Author

DimitrisJim commented May 24, 2023

re: And a docs entry is needed in docs/migrations/ just a reference to this issue mentioning how app.go needs to be modified.

I saw that mentioned by Colin and was wondering if just adding a single note for all modules that params have been migrated and an example of what needs to change would suffice. All keepers defined in ibc go now need to accept an additional authority argument, etc.

Seems like having a diff for all 5(?) modules would be a lot of duplication. Thoughts?

@DimitrisJim DimitrisJim force-pushed the jim/3500-migrate-02-client-params-to-be-self-managed branch from 6e931d1 to 64e0a1e Compare May 24, 2023 16:41
@codecov-commenter
Copy link

codecov-commenter commented May 25, 2023

Codecov Report

Merging #3640 (9070b49) into main (25de1c4) will decrease coverage by 0.04%.
The diff coverage is 73.33%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3640      +/-   ##
==========================================
- Coverage   78.78%   78.74%   -0.04%     
==========================================
  Files         186      186              
  Lines       12769    12816      +47     
==========================================
+ Hits        10060    10092      +32     
- Misses       2278     2291      +13     
- Partials      431      433       +2     
Impacted Files Coverage Δ
modules/core/02-client/genesis.go 20.93% <0.00%> (-1.03%) ⬇️
modules/core/02-client/types/keys.go 75.00% <ø> (ø)
modules/core/module.go 47.29% <33.33%> (-1.32%) ⬇️
modules/core/02-client/types/params_legacy.go 50.00% <50.00%> (ø)
modules/core/02-client/keeper/migrations.go 53.33% <66.66%> (+20.00%) ⬆️
modules/core/02-client/types/msgs.go 75.00% <66.66%> (-0.74%) ⬇️
modules/core/02-client/keeper/keeper.go 83.58% <90.47%> (+0.85%) ⬆️
modules/core/02-client/types/codec.go 79.79% <100.00%> (+0.20%) ⬆️
modules/core/02-client/types/params.go 100.00% <100.00%> (+10.00%) ⬆️
modules/core/keeper/keeper.go 91.66% <100.00%> (+0.55%) ⬆️
... and 1 more

// UpdateClientParams defines a rpc handler method for MsgUpdateClientParams.
func (k Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateClientParams) (*clienttypes.MsgUpdateClientParamsResponse, error) {
ck := k.ClientKeeper
if ck.GetAuthority() != msg.Authority {
Copy link
Member

Choose a reason for hiding this comment

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

since the entrypoint(s) to the msg server for ibc core submodules is in the core keeper, it might make sense for GetAuthority to just exist at the level of the core ibc keeper rather than passing the authority along to each nested keeper (client, connection).

I don't see a world right now in which client would have authority x and connection would have authority y.

Thoughts? cc. @colin-axner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's seems like a good point to me. I'll wait for Colin's thoughts on this before making changes.

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've made this change. Code definitely looks better. Will revert if required.

modules/core/02-client/keeper/params.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/params.go Outdated Show resolved Hide resolved
@DimitrisJim DimitrisJim force-pushed the jim/3500-migrate-02-client-params-to-be-self-managed branch 2 times, most recently from b8e432f to 5fc3686 Compare May 30, 2023 10:30
@DimitrisJim DimitrisJim force-pushed the jim/3500-migrate-02-client-params-to-be-self-managed branch from 5fc3686 to e483b3b Compare May 30, 2023 10:33
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.

Awesome work, thanks @DimitrisJim 🚀

I think we should go ahead and add the migration doc entry in this PR.

modules/core/02-client/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/keeper/keeper.go Outdated Show resolved Hide resolved
Copy link
Member

@srdtrk srdtrk left a comment

Choose a reason for hiding this comment

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

Great, lgtm

modules/core/keeper/msg_server_test.go Show resolved Hide resolved
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM nice job!

@DimitrisJim DimitrisJim merged commit d61886d into main May 30, 2023
@DimitrisJim DimitrisJim deleted the jim/3500-migrate-02-client-params-to-be-self-managed branch May 30, 2023 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate 02-client params to be self managed
7 participants