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!: connect app version with consensus params in end block #16244

Merged
merged 36 commits into from
Aug 29, 2023

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented May 22, 2023

Description

Closes: #16243

This PR wires up the upgrade module to the app version delivered through the ConsensusParams in EndBlock (thus removing the previous appVersion field in BaseApp). x/upgrade no longer keeps its own copy of the app version but uses the baseapp's canonical app version

NOTE: this touches both baseapp and x/upgrade. As they are different go modules, I can also split them into separate PRs


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@cmwaters cmwaters requested a review from a team as a code owner May 22, 2023 08:26
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

there will need to be a store migration to migrate the existing version to consensus params

@cmwaters
Copy link
Contributor Author

there will need to be a store migration to migrate the existing version to consensus params

This is a migration of the upgrade module right? So it would read in the old key and then set the app version in baseapp

@tac0turtle
Copy link
Member

there will need to be a store migration to migrate the existing version to consensus params

This is a migration of the upgrade module right? So it would read in the old key and then set the app version in baseapp

yes

@cmwaters
Copy link
Contributor Author

Does that mean I need to bump the consensus version from 2 to 3?

@tac0turtle
Copy link
Member

Does that mean I need to bump the consensus version from 2 to 3?

yea, since its consensus breaking

@@ -199,8 +196,19 @@ func (app *BaseApp) Name() string {
}

// AppVersion returns the application's protocol version.
func (app *BaseApp) AppVersion() uint64 {
return app.appVersion
func (app *BaseApp) AppVersion(ctx context.Context) uint64 {
Copy link
Contributor

@alexanderbez alexanderbez May 22, 2023

Choose a reason for hiding this comment

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

Can we have this return an error? In the ABCI++ branch, all the ABCI methods return an error so I would prefer this not to panic.

For now, we can panic in Info which we'll adjust once we update the ABCI++ branch.

Comment on lines 26 to 28
// LegacyProtocolVersionByte was the prefix to look up Protocol Version (AppVersion)
LegacyProtocolVersionByte = 0x3

Copy link
Contributor

Choose a reason for hiding this comment

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

I would delete this and then define it in the migration file.

@cmwaters
Copy link
Contributor Author

I've come across something of a deadlock here. We don't set state and the consensus params until InitChain which makes sense as CometBFT is providing the consensus params (which contain the app version). However Info is called before InitChain and requires the app version (which isn't set, i.e. Info has no access to state).

Best solution I can think of is to deprecate the app version in the Info call. CometBFT can pull it from their latest state. SDK can panic if InitChain returns an app version that the application doesn't support

baseapp/abci.go Fixed Show fixed Hide fixed
baseapp/abci.go Outdated Show resolved Hide resolved
baseapp/abci.go Outdated Show resolved Hide resolved
x/upgrade/keeper/migrations.go Outdated Show resolved Hide resolved
x/upgrade/keeper/migrations.go Show resolved Hide resolved
x/upgrade/keeper/keeper.go Show resolved Hide resolved
CHANGELOG.md Outdated
Copy link
Member

Choose a reason for hiding this comment

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

can we get those changelog entries under unreleased?

Copy link
Member

Choose a reason for hiding this comment

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

gentle ping @cmwaters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I left this PR. Have tried to update it and move the changelog entries under unreleased

baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/options.go Outdated Show resolved Hide resolved
tac0turtle and others added 5 commits August 18, 2023 16:36
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
baseapp/abci.go Outdated Show resolved Hide resolved
@tac0turtle tac0turtle added this pull request to the merge queue Aug 29, 2023
Merged via the queue into cosmos:main with commit 79cc75b Aug 29, 2023
44 of 45 checks passed
@@ -441,6 +402,7 @@ func (k Keeper) GetUpgradePlan(ctx context.Context) (plan types.Plan, err error)
func (k Keeper) setDone(ctx context.Context, name string) error {
store := k.storeService.OpenKVStore(ctx)
sdkCtx := sdk.UnwrapSDKContext(ctx)
fmt.Println("setting done", "height", sdkCtx.HeaderInfo().Height, "name", name)
Copy link
Member

Choose a reason for hiding this comment

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

This should have been using the logger

Copy link
Member

Choose a reason for hiding this comment

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

I can remove in a follow up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support app version changes through EndBlock
5 participants