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

add protos, msgs, keeper handler to upgrade clients using v1 governance proposals #4436

Conversation

charleenfei
Copy link
Contributor

Description

closes a portion of #3673.

This PR contains just the protos, msgs, keeper function and correlating tests.

the msg_server impl will come in a following pr

Commit Message / Changelog Entry

feat: add protos, msgs, keeper handler to upgrade clients using v1 governance proposals

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.

@charleenfei

This comment was marked as outdated.

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.

should fix linter errors I think, I haven't reviewed anything else properly yet! Looks good tho!

modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
modules/core/keeper/msg_server_test.go Outdated 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.

Looks great! Left a couple of suggestions, mostly minor stuff!

Main concern is around sdkerrors and ibcerrors being used together

var (
upgradedClientState *ibctm.ClientState
oldPlan, plan upgradetypes.Plan
expError error
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to expError on the testcase struct instead?

modules/core/02-client/keeper/keeper_test.go Outdated Show resolved Hide resolved
bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)

suite.chainA.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz) //nolint:errcheck
Copy link
Member

Choose a reason for hiding this comment

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

may as well check the error instead of having the nolint directive, if you always expect it to succeed just use suite.Require().NoError(err) on it directly underneath

}

// check that client state was not set
_, found = suite.chainA.GetSimApp().UpgradeKeeper.GetUpgradedClient(suite.chainA.GetContext(), plan.Height)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I have a preference for not discarding args as much as possible. We can do an assert empty or assert default struct of this value I think, right?

modules/core/02-client/types/msgs_test.go Outdated Show resolved Hide resolved
Name: "upgrade IBC clients",
Height: 1000,
}
_, err := types.NewMsgScheduleIBCClientUpgrade(
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 we could not discard this and make some assertions on expected value in expPass conditional

proto/ibc/core/client/v1/tx.proto Outdated Show resolved Hide resolved
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.

LGTM, see comments

modules/core/02-client/types/msgs_test.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/02-client/keeper/keeper_test.go Outdated Show resolved Hide resolved
Comment on lines +547 to +558
// set the old plan if it is not empty
if oldPlan.Height != 0 {
// set upgrade plan in the upgrade store
store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(upgradetypes.StoreKey))
bz := suite.chainA.App.AppCodec().MustMarshal(&oldPlan)
store.Set(upgradetypes.PlanKey(), bz)

bz, err := types.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClientState)
suite.Require().NoError(err)

suite.Require().NoError(suite.chainA.GetSimApp().UpgradeKeeper.SetUpgradedClient(suite.chainA.GetContext(), oldPlan.Height, bz))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's probably some code magic we could do here by adding the logic to setting an old plan and checking the expected result only in the test cases that use it. Maybe we can open as a followup issue (I know this comes from the existing code). I'd expect only the test cases needing an existing plan to execute that logic (maybe by calling ibcSoftwareUpgrade with an older plan height and then having some assertion to check that the old plan exists. Happy as is though

}

// ValidateBasic performs basic checks on a MsgIBCSoftwareUpgrade.
func (msg *MsgIBCSoftwareUpgrade) ValidateBasic() error {
Copy link
Member

Choose a reason for hiding this comment

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

Considering that for the time being we're implicitly on a tendermint chain when using ibc-go should we add a check on the provided client state that ClientType() returns exported.Tendermint

cc. @colin-axner

Copy link
Contributor

Choose a reason for hiding this comment

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

Fine by me

@charleenfei charleenfei added the v8 label Aug 25, 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.

Great work, @charleenfei! Just left one comment based on what we decided yesterday to rename authority to signer in the MsgUpdateParams.

proto/ibc/core/client/v1/tx.proto Outdated Show resolved Hide resolved
…handler-to-upgrade-clients-using-v1-governance-proposals
@charleenfei charleenfei force-pushed the charly/issue#3673-add-message-and-rpc-handler-to-upgrade-clients-using-v1-governance-proposals branch from 3d627a9 to dbbf6b9 Compare August 29, 2023 12:35
}

// emitting an event for handling client upgrade proposal
emitUpgradeClientProposalEvent(ctx, plan.Name, plan.Height)
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 want a separate event for this?

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 would lean towards not for this function, as this function calls the upgradeKeeper to schedule a client upgrade so i think the event should remain the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

potentially could be different for recover client tho

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we should, opened #4507

@charleenfei charleenfei merged commit 35909f6 into feat/govv1 Aug 29, 2023
49 checks passed
@charleenfei charleenfei deleted the charly/issue#3673-add-message-and-rpc-handler-to-upgrade-clients-using-v1-governance-proposals branch August 29, 2023 14:07
colin-axner added a commit that referenced this pull request Sep 13, 2023
…and `MsgIBCSoftwareUpgrade`. The legacy proposal types `ClientUpdateProposal` and `UpgradeClientProposal` have been removed. (#4620)

* Add proto message, implement sdk.Msg for Recover Client. (#4494)

* Add proto message for Recover client, implement sdk.Message interface.

* Update modules/core/02-client/types/msgs.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Apply suggestions from code review

Co-authored-by: Charly <charly@interchain.io>

* Remove gogoproto false for cmp, lint, move ibctesting address inline.

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: Charly <charly@interchain.io>

* add protos, msgs, keeper handler to upgrade clients using v1 governance proposals (#4436)

* add protos and keeper function placeholder

* add keeper functions/tests, msgs and tests

* update to 0.47.5 release branch

* Move signer as last proto field. (#4510)

* msg server function and tests for MsgScheduleIBCClientUpgrade (#4442)

* Add 02-client implementation for Recover client. (#4499)

* Add 02-client implementation for Recover client.

* Partially address feedback.

* Docu RecoverClient, add label, re-use error.

* Add implementation for recover client on message server. (#4503)

* Add message server handler for recovering a client

* Don't assign to deprecated attrs, clean up unused fields.

* Further clean-up, remove declaration of unmutated vars.

* Add cmd for submitting a recover client prop. (#4522)

* Add cmd for submitting a recover client prop.

* Bump cosmossdk in e2e.

* Use govtypes.ModuleName, rename old govtypes to govv1beta1

* Update modules/core/02-client/client/cli/tx.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Add auth flag.

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* rename command

* docs: fixed broken links (#4571)

* Add e2e test for recovering a client. (#4543)

Co-authored-by: Colin Axnér <25233464+colin-axner@users.noreply.github.com>

* feat: add unpacket inerfaces message assertion (#4588)

* add cli for MsgIBCSoftwareUpgrade (#4558)

* docs: use MsgRecoverClient in docs (#4580)

* docs: recover client update

* Update docs/ibc/proposals.md

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* refactor: remove legacy client update proposal (#4581)

* refactor: remove legacy client update proposal

* e2e: swap from ClientUpdateProposal e2e to RecoverClient

* refactor: remove unused events

* feat: add proposal simulator interface function and tests (#4466)

Co-authored-by: colin axner <25233464+colin-axner@users.noreply.github.com>

* refactor!: remove UpgradeProposal type (#4602)

* create separate event emission for ibc software upgrades vs an upgraded client (#4594)

* add new event type

* update event name

* fix build

* remove: legacy event emissions

* remove: unnecessary assignments, apply suggestion from code review

* e2e: schedule IBC software upgrade (#4585)

* wip e2e test

* query proposal

* update upgrade height in plan

* rm unnecessary wait/authority

* rm test artifact from merge

* add checks for scheduled plan

* hook up upgrade query client

* plan height

* pr fixes

* update test

* import space

* update newchainID value

* update clientID upgrade

* linter

* gci

* rm unnecessary event

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Sishir Giri <sis1001@berkeley.edu>
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: Cian Hatton <cian@interchain.io>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
Co-authored-by: sontrinh16 <trinhleson2000@gmail.com>
Co-authored-by: catShaark <gundamaster5@gmail.com>
Co-authored-by: khanh-notional <50263489+catShaark@users.noreply.github.com>

* chore: docs for MsgIBCSoftwareUpgrade (#4601)

* chore: update docs for UpgradeProposal -> MsgIBCSoftwareUpgrade

* chore: anticipate link change

* fix event docs

* refactor: s.Assert -> s.Require

* Apply suggestions from code review

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* make proto-all

* chore: update compiler assertion

* refactor: ordering, order as follows: create, update, upgrade, misbheaviour, recover, ibcsoftwareupgrade, update params

* refactor: simplify ibc software upgrade emitted event

* lint lint lint

* Apply suggestions from code review

Co-authored-by: Charly <charly@interchain.io>

* review of feat/govv1

* pr nits

* fix tests for error wrapping

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: Charly <charly@interchain.io>
Co-authored-by: Charly <charly@interchain.berlin>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sishir Giri <sis1001@berkeley.edu>
Co-authored-by: Cian Hatton <cian@interchain.io>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: sontrinh16 <trinhleson2000@gmail.com>
Co-authored-by: catShaark <gundamaster5@gmail.com>
Co-authored-by: khanh-notional <50263489+catShaark@users.noreply.github.com>
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.

5 participants