-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: Add MigrationModuleManager to handle migration of upgrade module before other modules #16583
Conversation
types/module/module.go
Outdated
errorsmod "cosmossdk.io/errors" | ||
|
||
storetypes "cosmossdk.io/store/types" | ||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tac0turtle is there any harm on depending on cometbft
types in types/module
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we dont do this, this seems like a bandaid that we will have to clean up later on. i think we should identify how to fix this problem without allowing modules to override consensus params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must be doing this within BeginBlock
of Manager
since the consensus params is accessed by other modules right after migration within the same block execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I guess there's no way around it it seems :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could perhaps return an any
instead and then type cast where needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if get params by consensusKeeper is better, but we need add module one by one (not to mention module outside sdk)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tac0turtle May I ask if you have any better idea beside these two approaches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the core issue here is the migration is "system" level functionalities, probably shouldn't happen in a module in the first place, it should be executed before all the module logics. is it possible to move the migration logic into baseapp somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for delay, the dependency is fine. agree with @yihuang. Maybe for this version of baseapp this is fine but for later on we can change it. Im not sure we have a clean alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree 👍
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
types/module/module.go
Outdated
@@ -261,6 +262,11 @@ func (GenesisOnlyAppModule) EndBlock(sdk.Context) ([]abci.ValidatorUpdate, error | |||
return []abci.ValidatorUpdate{}, nil | |||
} | |||
|
|||
// ConsensusParamsGetter is an interface to retrieve consensus parameters for a given context. | |||
type ConsensusParamsGetter interface { | |||
GetConsensusParams(ctx sdk.Context) tmproto.ConsensusParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we just return an any
here and then type cast? Then we can avoid the CometBFT dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since need use as cp := getter.GetConsensusParams(ctx).(tmproto.ConsensusParams)
, we can't use any for WithConsensusParams
, or can we add a separate package to avoid import cometbft type directly
@@ -0,0 +1,12 @@ | |||
package interfaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK @tac0turtle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why creating a new package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's to avoid directly import cometbft type, sth like allow B get A without import X:
A import X
B import A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used anymore right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Thanks for adding the godoc and tests!
Possibly as well here cosmos-sdk/docs/docs/core/00-baseapp.md Line 447 in dd49f98
|
Co-authored-by: Julien Robert <[email protected]>
… before other modules (#16583) Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 0c1f6fc)
… before other modules (#16583) Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 0c1f6fc) # Conflicts: # CHANGELOG.md # UPGRADING.md # baseapp/baseapp.go # docs/docs/building-modules/01-module-manager.md # docs/docs/core/00-baseapp.md # testutil/mock/types_mock_appmodule.go # types/module/module.go # types/module/module_test.go
… before other modules (cosmos#16583) Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 0c1f6fc)
… before other modules (cosmos#16583) Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Julien Robert <[email protected]> (cherry picked from commit 0c1f6fc) # Conflicts: # CHANGELOG.md # UPGRADING.md # baseapp/baseapp.go # docs/docs/building-modules/01-module-manager.md # docs/docs/core/00-baseapp.md # testutil/mock/types_mock_appmodule.go # types/module/module.go # types/module/module_test.go
Description
Closes: #16494
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change