-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 migrations for app.toml
#9692
Comments
Good idea, ACK. |
ProposalA new command called func PreUpgradeCmd(modules []module.AppModule) *cobra.Command {
cmd := &cobra.Command{
Use: "pre-upgrade [target-version]",
Short: "",
Long: ""
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
for _, module := module range modules {
module.PreUpgrade(clientCtx)
}
return nil
},
}
return cmd
} This command accepts a list of modules and target-version to carry out the pre-upgrade. Each module would implement its own Since each module can modify the settings as desired, it is possible that the settings could end up in an undesirable state. The developers implementing the Further Discussion neededCurrently for the migration of the modules, the versioning is handled through the value |
@AmauryM @aaronc @robert-zaremba do you have some feedback on what @spoo-bar described? Thanks. |
A few things:
|
I think we cannot make it configurable if we gonna do it via |
I don't follow? Why can't this be done via |
@alexanderbez The current upgrade module is used to update app modules, so any config changes which are part of an upgrade, I assumed, would be relevant to some module's upgrade. |
The pre-upgrade hook should be unrelated to modules. I am not yet seeing a case yet where it would apply. As far as I know this pre-upgrade command should live in apps, not the SDK and we just need a convention for how cosmovisor will interact with it. Will it be some script specified in the upgrade info cosmovisor receives? Will it be a convention? Probably the former makes sense because we need to have well defined failure/retry behavior. Each app will need to define pre-upgrade hooks for each upgrade. I think it is pre-mature to assume we can generalize any more than that. |
This is not true, at least not what my intuition tells me. The upgrade handler upgrades module state. Configurations and other misc. items are non-state related, so they don't happen as part of the upgrade handler.
Essentially this is what we need to do. The simplest approach is to just provide an additional flag, e.g. |
What about the case where the cosmos sdk adds a new field in the app.toml? For example, I have a running application and I want to upgrade. The new SDK upgrade adds a new field into app.toml but I need to define the pre upgrade hook. Do I need to put the updates coming from the SDK by hand into the hook? Isn't there any other way to make it automatic so I only need to take care of the changes that I need for my app? |
I was thinking about something |
The script updates the
cosmovisor wouldn't not do this -- this isn't what I'm proposing. What I'm proposing is a pre-upgrade-hook script that can do whatever you need before the binary starts, e.g. Tendermint key migration, updating app.toml, etc..., and I'm proposing cosmivisor to automatically call this script. |
Update on the ProposalThis would handle any migration changes required by the SDK as wells as the application
type PreUpgradeHooks interface {
Run(clientCtx client.Context)
} func PreUpgradeCmd(customHooks []PreUpgradeHooks) *cobra.Command {
cmd := &cobra.Command{
Use: "pre-upgrade [target-version]",
Short: "",
Long: ""
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
sdkUpgradeHooks := []PreUpgradeHooks {
sdk.Migration1,
sdk.Migration2,
// ...
// ...
}
preUpgradeHooks = merge(sdkUpgradeHooks, customHooks)
for _, hook := hook range preUpgradeHooks {
hook.Run(clientCtx)
}
return nil
},
}
return cmd
} Cosmovisor can call this command before performing the upgrade. |
@spoo-bar what does this buy you over making a simple script? Also, there is no relationship between target version of SDK updates in your example. |
@alexanderbez In the solution which involves passing a script.sh to cosmovisor to be executed before the upgrade, it is not recommended to pass any cmd line args to cosmovisor. As all args received by cosmovisor are passed to the application. |
Additionally, this would mean the script would also need to include all the migrations which are SDK specific which application dev need to be aware of and missing something could cause failure. |
Yes, correct. The proposal is we add a flag to
Well, the migrations are agonistic. They can application or Tendermint or something completely else. We can't make any assumptions about what migrations are happening. |
This all started from @anilcse, they updated the SDK in their application and when they run it it panicked because some field was not updated on the app.toml related to the cosmos SDK. In the script approach looks like the developer needs to be aware that he needs to add this field, what @spoo-bar tries to solve is that the developer does not care if there is something updated from the SDK, that happens automatic and he can add more things (whatever it is) on top of it. If we just want to execute something arbitrary before the upgrade then the script is enough, but does not solve the problem @anilcse faced. |
@aaronc or @robert-zaremba do you have any thoughts here? |
So I spoke with @aaronc and I see where there is some miscommunication. @spoo-bar we're not doing any state migrations and we're not touching or dealing with modules of any kind. We're just doing off-chain pre-upgrade "general" logic. To summarize, we will have convention where cosmovisor executes a
This work is small scope and belongs 100% in cosmovisor (cc @robert-zaremba) |
Agree with what @alexanderbez said. I would also add that pre-upgrade handler should basically look like what we're doing now for "pre-upgrades" of the multi-store: https://github.com/cosmos/gaia/blob/main/app/app.go#L428-L439. It would check for an upgrade name and skip-heights. So the Also, it's an open question whether I think we should document how to do this in the SDK and provide any known migrations needed for things like app.toml in the SDK, but I don't think we can really generalized this pre-upgrade command. Apps will need to implement it for the upgrades they have planned. |
Thanks for the clarification! |
Broke the Cosmovisor piece out into its own issue: #9973 |
Closing in favor of #9973 |
Summary
Now with
x/upgrade
, upgrades became seemless and less burden for app developers and node operators. One thing that is missing from automatic upgrades is updatingapp.toml
when there are new/updated configs.app.toml
changes require manual update.cosmovisor
Proposal
Add migrations for
app.toml
changes. It should basically cover the following cases:For Admin Use
The text was updated successfully, but these errors were encountered: