Skip to content

Commit

Permalink
feat(uniond): added v0.12.0 migration (#694)
Browse files Browse the repository at this point in the history
* feat(uniond): added v0.12.0 migration

* feat(unionvisor): added mkNextBundle and bundle-testnet-next
  • Loading branch information
PoisonPhang authored Sep 13, 2023
1 parent 1bc0497 commit 09a7285
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(lib.flip withSystem ({ e2e, networks, pkgs, nixpkgs, crane, self', ... }:
let
epoch-staking = import ./epoch-staking.nix { inherit e2e pkgs; };
upgrades = import ./upgrades.nix { inherit e2e pkgs; unionvisor = self'.packages.unionvisor; bundle = self'.packages.bundle-testnet; };
upgrades = import ./upgrades.nix { inherit e2e pkgs; unionvisor = self'.packages.unionvisor; bundle = self'.packages.bundle-testnet-next; };
in
{
ensure-blocks = import ./ensure-blocks/ensure-blocks.nix { inherit e2e networks pkgs nixpkgs crane; };
Expand Down
1 change: 1 addition & 0 deletions e2e/upgrades.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ in
${upgradeTo "v0.9.0" 10}
${upgradeTo "v0.10.0" 20}
${upgradeTo "v0.11.0" 30}
${upgradeTo "v0.12.0" 40}
'';

nodes = {
Expand Down
3 changes: 2 additions & 1 deletion uniond/app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"union/app/upgrades"
"union/app/upgrades/v0_10_0"
"union/app/upgrades/v0_11_0"
"union/app/upgrades/v0_12_0"
"union/app/upgrades/v0_9_0"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

var Upgrades = []upgrades.Upgrade{v0_9_0.Upgrade, v0_10_0.Upgrade, v0_11_0.Upgrade}
var Upgrades = []upgrades.Upgrade{v0_9_0.Upgrade, v0_10_0.Upgrade, v0_11_0.Upgrade, v0_12_0.Upgrade}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
func (app *UnionApp) setupUpgradeStoreLoaders() {
Expand Down
14 changes: 14 additions & 0 deletions uniond/app/upgrades/v0_12_0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v0_12_0

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"union/app/upgrades"
)

const UpgradeName = "v0.12.0"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{Added: []string{}},
}
15 changes: 15 additions & 0 deletions uniond/app/upgrades/v0_12_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v0_12_0

import (
"union/app/upgrades"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, keepers *upgrades.AppKeepers) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
27 changes: 27 additions & 0 deletions unionvisor/unionvisor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@
path = pkgs.lib.getExe (get-flake "${inputs."${swapDotsWithUnderscores version}"}").packages.${system}.uniond;
})
versions);
mkNextBundle = name: versions: nextVersion: meta:
pkgs.linkFarm "union-bundle-${name}" ([
{
name = "meta.json";
path = pkgs.writeText "meta.json" (builtins.toJSON meta);
}
{
name = "unionvisor";
path = "${unionvisorAll.packages.unionvisor}/bin/unionvisor";
}
{
name = "${meta.versions_directory}/${nextVersion}/${meta.binary_name}";
path = pkgs.lib.getExe self'.packages.uniond;
}
] ++ map
(version: {
name =
"${meta.versions_directory}/${version}/${meta.binary_name}";
path = pkgs.lib.getExe (get-flake "${inputs."${swapDotsWithUnderscores version}"}").packages.${system}.uniond;
})
versions);
in
{
inherit (unionvisorAll) checks;
Expand All @@ -52,6 +73,12 @@
versions_directory = "versions";
fallback_version = "v0.8.0";
};
bundle-testnet-next =
mkNextBundle "testnet" [ "v0.8.0" "v0.9.0" "v0.10.0" "v0.11.0" ] "v0.12.0" {
binary_name = "uniond";
versions_directory = "versions";
fallback_version = "v0.8.0";
};
};
};

Expand Down

0 comments on commit 09a7285

Please sign in to comment.