Skip to content

Commit

Permalink
feat(uniond): create v0.20.0 migration (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonPhang authored Feb 25, 2024
2 parents d65b68a + 66bfbac commit 2226c7a
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 36 deletions.
63 changes: 34 additions & 29 deletions e2e/upgrades.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
let
unionvisorBin = pkgs.lib.meta.getExe unionvisor;

# mkUpgradeProposal = version: height: pkgs.runCommand "upgrade-proposal" { } ''
# mkdir -p $out
# echo '{
# "messages": [
# {
# "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
# "authority": "union10d07y265gmmuvt4z0w9aw880jnsr700js4jdcz",
# "plan": {
# "name": "${version}",
# "height": "${toString height}",
# "info": "${version}"
# }
# }
# ],
# "deposit": "15000000stake",
# "title": "${version}",
# "summary": "Upgrade to ${version}"
# }' > proposal-${version}.json
# mv proposal-${version}.json $out
# '';
mkUpgradeProposal = version: height: pkgs.runCommand "upgrade-proposal" { } ''
mkdir -p $out
echo '{
"messages": [
{
"@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
"authority": "union10d07y265gmmuvt4z0w9aw880jnsr700js4jdcz",
"plan": {
"name": "${version}",
"height": "${toString height}",
"info": "${version}"
}
}
],
"deposit": "15000000stake",
"title": "${version}",
"summary": "Upgrade to ${version}"
}' > proposal-${version}.json
mv proposal-${version}.json $out
'';

forEachNode = f: ''
${f "0"}
Expand All @@ -30,20 +30,20 @@ let
${f "3"}
'';

# upgradeTo = version: height: ''
# union.succeed('docker cp ${mkUpgradeProposal version height}/proposal-${version}.json devnet-minimal-uniond-0-1:/proposal-${version}.json')
# print(union.succeed('docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} --root . call --bundle /bundle -- tx gov submit-proposal proposal-${version}.json --from val-0 --keyring-backend test --home ./home -y --gas 3000000000'))
upgradeTo = version: height: ''
union.succeed('docker cp ${mkUpgradeProposal version height}/proposal-${version}.json devnet-minimal-uniond-0-1:/proposal-${version}.json')
print(union.succeed('docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} --root . call --bundle /bundle -- tx gov submit-proposal proposal-${version}.json --from val-0 --keyring-backend test --home ./home -y --gas 3000000000'))
# time.sleep(6)
time.sleep(6)
# union.wait_until_succeeds("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query gov proposal ${toString (height / 10)} --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.status == \"PROPOSAL_STATUS_VOTING_PERIOD\"') == true ]]", timeout=30)
union.wait_until_succeeds("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query gov proposal ${toString (height / 10)} --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.status == \"PROPOSAL_STATUS_VOTING_PERIOD\"') == true ]]", timeout=30)
# ${forEachNode (id: "print(union.succeed('docker exec devnet-minimal-uniond-${id}-1 ${unionvisorBin} --root . call --bundle /bundle -- tx gov vote ${toString (height / 10)} yes --keyring-backend test --from val-${id} --home ./home -y'))")}
${forEachNode (id: "print(union.succeed('docker exec devnet-minimal-uniond-${id}-1 ${unionvisorBin} --root . call --bundle /bundle -- tx gov vote ${toString (height / 10)} yes --keyring-backend test --from val-${id} --home ./home -y'))")}
# union.wait_until_succeeds("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query gov proposal ${toString (height / 10)} --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.status == \"PROPOSAL_STATUS_PASSED\"') == true ]]", timeout=30)
union.wait_until_succeeds("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query gov proposal ${toString (height / 10)} --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.status == \"PROPOSAL_STATUS_PASSED\"') == true ]]", timeout=30)
# union.wait_until_succeeds('[[ $(curl "http://localhost:26660/block" --fail --silent | ${pkgs.lib.meta.getExe pkgs.jq} ".result.block.header.height | tonumber > ${toString height}") == "true" ]]')
# '';
union.wait_until_succeeds('[[ $(curl "http://localhost:26660/block" --fail --silent | ${pkgs.lib.meta.getExe pkgs.jq} ".result.block.header.height | tonumber > ${toString height}") == "true" ]]')
'';
in
{
upgrade-from-genesis = e2e.mkTest {
Expand All @@ -56,6 +56,8 @@ in
# Ensure the union network commits more than one block
union.wait_until_succeeds('[[ $(curl "http://localhost:26660/block" --fail --silent | ${pkgs.lib.meta.getExe pkgs.jq} ".result.block.header.height | tonumber > 1") == "true" ]]')
${upgradeTo "v0.20.0" 10}
'';

nodes = {
Expand All @@ -78,6 +80,9 @@ in
union.succeed("docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} --root . call --bundle /bundle -- tx tokenfactory create-denom bazinga --from val-0 --keyring-backend test --home ./home -y --gas 3000000000")
time.sleep(6)
union.succeed("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query tokenfactory denom-authority-metadata factory/union14fldwd959h7glh2e3k45veuqfszvgm69q07jhw/bazinga --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.authority_metadata.admin == \"union14fldwd959h7glh2e3k45veuqfszvgm69q07jhw\"') == true ]]")
${upgradeTo "v0.20.0" 10}
union.succeed("[[ $(docker exec devnet-minimal-uniond-0-1 ${unionvisorBin} -l off --root . call --bundle /bundle -- query tokenfactory denom-authority-metadata factory/union14fldwd959h7glh2e3k45veuqfszvgm69q07jhw/bazinga --home ./home --output json | ${pkgs.lib.meta.getExe pkgs.jq} '.authority_metadata.admin == \"union14fldwd959h7glh2e3k45veuqfszvgm69q07jhw\"') == true ]]")
'';

nodes = {
Expand Down
25 changes: 21 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
flake = false;
};
nix-filter.url = "github:numtide/nix-filter?rev=3449dc925982ad46246cfc36469baf66e1b64f17";
get-flake.url = "github:ursi/get-flake?rev=e0917b6f564aa5acefb1484b5baf76da21746c3c";
get-flake.url = "github:ursi/get-flake";
wasmvm = {
url = "github:CosmWasm/wasmvm/v1.5.2";
flake = false;
Expand Down Expand Up @@ -114,6 +114,10 @@
url = "github:unionlabs/union/release-v0.19.0";
flake = false;
};
v0_20_0 = {
url = "github:unionlabs/union/release-v0.20.0";
flake = false;
};
};
outputs =
inputs@{ self
Expand Down
14 changes: 14 additions & 0 deletions uniond/app/upgrades/v0_20_0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v0_20_0

import (
store "cosmossdk.io/store/types"
"union/app/upgrades"
)

const UpgradeName = "v0.20.0"

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

import (
"context"
"union/app/upgrades"

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

func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, keepers *upgrades.AppKeepers) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion unionvisor/unionvisor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
mkBundle {
name = "testnet-6";
versions = uniondBundleVersions.complete;
nextVersion = "v0.19.0";
nextVersion = "v0.20.0";
genesis = ../networks/genesis/union-testnet-6/genesis.json;
meta = {
binary_name = "uniond";
Expand Down
2 changes: 1 addition & 1 deletion versions/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"union-testnet-4": ["v0.14.0", "v0.15.0", "v0.16.0", "v0.17.0"],
"union-testnet-5": ["v0.18.0"],
"union-testnet-6": ["v0.19.0"]
"union-testnet-6": ["v0.19.0", "v0.20.0"]
}

0 comments on commit 2226c7a

Please sign in to comment.