-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set upgrade handler for v0.2.1 with migrations for intrechain mo…
…dules
- Loading branch information
Showing
6 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Nolus Upgrades | ||
|
||
This folder contains sub-folders for every nolus upgrade. (Both state | ||
migrations, and hard forks) It also defines upgrade & hard fork structs, | ||
that each upgrade implements. These then get included in the application | ||
app.go to run the upgrade. | ||
|
||
## Version History | ||
|
||
|
||
## Upgrade types | ||
|
||
Currently in Nolus we support only one upgrade type, `Upgrade`. | ||
If we need to support more upgrade types, like `Fork`, we can add them. | ||
An `Upgrade` defines an upgrade that is to be acted upon by state migrations from the | ||
SDK `x/upgrade` module. | ||
|
||
<!-- A `Fork` defines a hard fork that changes some | ||
logic at a block height. If the goal is to have a new binary be | ||
compatible with the old binary prior to the upgrade height, as is the | ||
case for all osmosis `Fork`s, then all logic changes must be | ||
height-gated or in the `BeginForkLogic` code. --> | ||
|
||
```go | ||
type Upgrade struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v7` | ||
UpgradeName string | ||
// Function that creates an upgrade handler | ||
CreateUpgradeHandler func(mm *module.Manager, configurator module.Configurator, keepers *keepers.AppKeepers) upgradetypes.UpgradeHandler | ||
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. | ||
StoreUpgrades store.StoreUpgrades | ||
} | ||
|
||
// type Fork struct { | ||
// // Upgrade version name, for the upgrade handler, e.g. `v7` | ||
// UpgradeName string | ||
// // height the upgrade occurs at | ||
// UpgradeHeight int64 | ||
|
||
// // Function that runs some custom state transition code at the beginning of a fork. | ||
// BeginForkLogic func(ctx sdk.Context, keepers *keepers.AppKeepers) | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package upgrades | ||
|
||
import ( | ||
"github.com/Nolus-Protocol/nolus-core/app/keepers" | ||
|
||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal | ||
// must have written, in order for the state migration to go smoothly. | ||
// An upgrade must implement this struct, and then set it in the app.go. | ||
// The app.go will then define the handler. | ||
type Upgrade struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v7` | ||
UpgradeName string | ||
|
||
// CreateUpgradeHandler defines the function that creates an upgrade handler | ||
CreateUpgradeHandler func(*module.Manager, module.Configurator, *keepers.AppKeepers) upgradetypes.UpgradeHandler | ||
|
||
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. | ||
StoreUpgrades store.StoreUpgrades | ||
} | ||
|
||
// // Fork defines a struct containing the requisite fields for a non-software upgrade proposal | ||
// // Hard Fork at a given height to implement. | ||
// // There is one time code that can be added for the start of the Fork, in `BeginForkLogic`. | ||
// // Any other change in the code should be height-gated, if the goal is to have old and new binaries | ||
// // to be compatible prior to the upgrade height. | ||
// type Fork struct { | ||
// // Upgrade version name, for the upgrade handler, e.g. `v7` | ||
// UpgradeName string | ||
// // height the upgrade occurs at | ||
// UpgradeHeight int64 | ||
|
||
// // Function that runs some custom state transition code at the beginning of a fork. | ||
// BeginForkLogic func(ctx sdk.Context, keepers *keepers.AppKeepers) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package v0 | ||
|
||
import ( | ||
"github.com/Nolus-Protocol/nolus-core/app/upgrades" | ||
|
||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
interchainqueries "github.com/neutron-org/neutron/x/interchainqueries/types" | ||
interchaintxs "github.com/neutron-org/neutron/x/interchaintxs/types" | ||
) | ||
|
||
// TODO Start using this method to upgrade the app after export app state is fixed. | ||
const ( | ||
// UpgradeName defines the on-chain upgrade name. | ||
UpgradeName = "v0.2.1" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
interchainqueries.ModuleName, | ||
interchaintxs.ModuleName, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v0 | ||
|
||
import ( | ||
"github.com/Nolus-Protocol/nolus-core/app/keepers" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// TODO Start using this method to upgrade the app after export app state is fixed. | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |