Skip to content

Commit

Permalink
chore: prepare argon (#196)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Kanefsky <56059752+boojamya@users.noreply.github.com>
(cherry picked from commit 4cc95ae)
  • Loading branch information
johnletey authored and mergify[bot] committed Jul 14, 2023
1 parent ca1fa22 commit 8f72bb2
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ ictest-paramauthority:
cd interchaintest && go test -race -v -run ^TestNobleParamAuthority$$ .

ictest-chain-upgrade-grand-1:
cd interchaintest && go test -race -v -run ^TestGrand1ChainUpgrade$$ .
cd interchaintest && go test -race -v -timeout 15m -run ^TestGrand1ChainUpgrade$$ .

ictest-chain-upgrade-noble-1:
cd interchaintest && go test -race -v -run ^TestNoble1ChainUpgrade$$ .
cd interchaintest && go test -race -v -timeout 15m -run ^TestNoble1ChainUpgrade$$ .

ictest-globalFee:
cd interchaintest && go test -race -v -run ^TestGlobalFee$$ .
Expand Down
31 changes: 19 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
neon "github.com/strangelove-ventures/noble/app/upgrades/neon"
radon "github.com/strangelove-ventures/noble/app/upgrades/radon"
"github.com/strangelove-ventures/noble/app/upgrades/argon"
"github.com/strangelove-ventures/noble/app/upgrades/neon"
"github.com/strangelove-ventures/noble/app/upgrades/radon"
"github.com/strangelove-ventures/noble/cmd"
"github.com/strangelove-ventures/noble/docs"
"github.com/strangelove-ventures/noble/x/blockibc"
fiattokenfactorymodule "github.com/strangelove-ventures/noble/x/fiattokenfactory"
fiattokenfactorymodulekeeper "github.com/strangelove-ventures/noble/x/fiattokenfactory/keeper"
fiattokenfactorymoduletypes "github.com/strangelove-ventures/noble/x/fiattokenfactory/types"
"github.com/strangelove-ventures/noble/x/globalfee"
globalfeetypes "github.com/strangelove-ventures/noble/x/globalfee/types"
tariff "github.com/strangelove-ventures/noble/x/tariff"
tariffkeeper "github.com/strangelove-ventures/noble/x/tariff/keeper"
tarifftypes "github.com/strangelove-ventures/noble/x/tariff/types"
Expand Down Expand Up @@ -866,6 +866,15 @@ func (app *App) setupUpgradeHandlers() {
app.FiatTokenFactoryKeeper,
))

// argon upgrade
app.UpgradeKeeper.SetUpgradeHandler(
argon.UpgradeName,
argon.CreateUpgradeHandler(
app.mm,
app.configurator,
),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
Expand All @@ -874,22 +883,20 @@ func (app *App) setupUpgradeHandlers() {
return
}

var stroreUpgrades *storetypes.StoreUpgrades
var storeLoader baseapp.StoreLoader

switch upgradeInfo.Name {
case neon.UpgradeName:
stroreUpgrades = &storetypes.StoreUpgrades{
Added: []string{fiattokenfactorymoduletypes.StoreKey},
}
storeLoader = neon.CreateStoreLoader(upgradeInfo.Height)
case radon.UpgradeName:
stroreUpgrades = &storetypes.StoreUpgrades{
Added: []string{globalfeetypes.ModuleName, tarifftypes.ModuleName},
}
storeLoader = radon.CreateStoreLoader(upgradeInfo.Height)
case argon.UpgradeName:
storeLoader = argon.CreateStoreLoader(upgradeInfo.Height)
}

if stroreUpgrades != nil {
if storeLoader != nil {
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, stroreUpgrades))
app.SetStoreLoader(storeLoader)
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/upgrades/argon/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package argon

// UpgradeName is the name of this specific software upgrade used on-chain.
const UpgradeName = "argon"

// TestnetChainID is the Chain ID of the Noble testnet (Grand).
const TestnetChainID = "grand-1"

// MainnetChainID is the Chain ID of the Noble mainnet.
const MainnetChainID = "noble-1"
13 changes: 13 additions & 0 deletions app/upgrades/argon/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package argon

import (
"github.com/cosmos/cosmos-sdk/baseapp"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
storeUpgrades := storeTypes.StoreUpgrades{}

return upgradeTypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
}
16 changes: 16 additions & 0 deletions app/upgrades/argon/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package argon

import (
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,
) upgradeTypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
21 changes: 21 additions & 0 deletions app/upgrades/neon/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package neon

import (
"github.com/cosmos/cosmos-sdk/baseapp"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"

// FiatTokenFactory
fiatTokenFactoryTypes "github.com/strangelove-ventures/noble/x/fiattokenfactory/types"
// Upgrade
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
storeUpgrades := storeTypes.StoreUpgrades{
Added: []string{
fiatTokenFactoryTypes.ModuleName,
},
}

return upgradeTypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
}
23 changes: 23 additions & 0 deletions app/upgrades/radon/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package radon

import (
"github.com/cosmos/cosmos-sdk/baseapp"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"

// GlobalFee
globalFeeTypes "github.com/strangelove-ventures/noble/x/globalfee/types"
// Tariff
tariffTypes "github.com/strangelove-ventures/noble/x/tariff/types"
// Upgrade
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
storeUpgrades := storeTypes.StoreUpgrades{
Added: []string{
globalFeeTypes.ModuleName, tariffTypes.ModuleName,
},
}

return upgradeTypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
}
10 changes: 9 additions & 1 deletion interchaintest/upgrade_grand-1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ func TestGrand1ChainUpgrade(t *testing.T) {
},
{
// post radon patch upgrade (will be applied as rolling upgrade due to lack of upgradeName)
image: nobleImageInfo[0],
image: ibc.DockerImage{
Repository: "ghcr.io/strangelove-ventures/noble",
Version: "v3.0.0",
UidGid: containerUidGid,
},
},
{
upgradeName: "argon",
image: nobleImageInfo[0],
},
}

Expand Down
10 changes: 9 additions & 1 deletion interchaintest/upgrade_noble-1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ func TestNoble1ChainUpgrade(t *testing.T) {
},
{
upgradeName: "radon",
image: nobleImageInfo[0],
image: ibc.DockerImage{
Repository: "ghcr.io/strangelove-ventures/noble",
Version: "v3.0.0",
UidGid: containerUidGid,
},
postUpgrade: testPostRadonUpgrade,
},
{
upgradeName: "argon",
image: nobleImageInfo[0],
},
}

testNobleChainUpgrade(t, noble1ChainID, noble1Genesis, denomMetadataFrienzies, numVals, numFullNodes, noble1Upgrades)
Expand Down

0 comments on commit 8f72bb2

Please sign in to comment.