Skip to content

Commit

Permalink
Cherry Pick for Testnet v0.5.0 (#159)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Zampolin <[email protected]>
Co-authored-by: Andrew Gouin <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2023
1 parent d3e0a66 commit e0d0952
Show file tree
Hide file tree
Showing 7 changed files with 463 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish-and-E2E.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
- name: checkout chain
uses: actions/checkout@v2

- run: make ictest-paramauthorityChainUpgrade
- run: make ictest-chain-upgrade
env:
BRANCH_CI: ${{needs.build-and-push-image.outputs.branchTag}}

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ictest-packet-forward:
ictest-paramauthority:
cd interchaintest && go test -race -v -run ^TestNobleParamAuthority$$ .

ictest-paramauthorityChainUpgrade:
ictest-chain-upgrade:
cd interchaintest && go test -race -v -run ^TestNobleChainUpgrade$$ .

ictest-globalFee:
Expand Down
18 changes: 17 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,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"
"github.com/strangelove-ventures/noble/app/upgrades/neon"
neon "github.com/strangelove-ventures/noble/app/upgrades/neon"
radon "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 @@ -843,6 +845,16 @@ func (app *App) setupUpgradeHandlers() {
app.BankKeeper,
app.AccountKeeper))

// radon upgrade
app.UpgradeKeeper.SetUpgradeHandler(
radon.UpgradeName,
radon.CreateRadonUpgradeHandler(
app.mm,
app.configurator,
app.ParamsKeeper,
app.FiatTokenFactoryKeeper,
))

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
Expand All @@ -858,6 +870,10 @@ func (app *App) setupUpgradeHandlers() {
stroreUpgrades = &storetypes.StoreUpgrades{
Added: []string{fiattokenfactorymoduletypes.StoreKey},
}
case radon.UpgradeName:
stroreUpgrades = &storetypes.StoreUpgrades{
Added: []string{globalfeetypes.ModuleName, tarifftypes.ModuleName},
}
}

if stroreUpgrades != nil {
Expand Down
8 changes: 8 additions & 0 deletions app/upgrades/radon/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package radon

const (
// UpgradeName is the shared upgrade plan name for mainnet
UpgradeName = "radon"
// UpgradeInfo defines the binaries that will be used for the upgrade
UpgradeInfo = "Noble Radon Upgrade"
)
65 changes: 65 additions & 0 deletions app/upgrades/radon/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package radon

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

paramauthoritykeeper "github.com/strangelove-ventures/paramauthority/x/params/keeper"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
fiattokenfactorykeeper "github.com/strangelove-ventures/noble/x/fiattokenfactory/keeper"
globalfeetypes "github.com/strangelove-ventures/noble/x/globalfee/types"

tarifftypes "github.com/strangelove-ventures/noble/x/tariff/types"
)

func CreateRadonUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
paramauthoritykeeper paramauthoritykeeper.Keeper,
fiatTFKeeper *fiattokenfactorykeeper.Keeper,

) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

// New modules run AFTER the migrations, so to set the correct params after the default
// becasuse RunMigrations runs `InitGenesis` on new modules`.
versionMap, err := mm.RunMigrations(ctx, cfg, vm)

// -- globalfee params --
minGasPrices := sdk.DecCoins{
sdk.NewDecCoinFromDec("udrachma", sdk.NewDecWithPrec(1, 2)),
}
globlaFeeParamsSubspace, ok := paramauthoritykeeper.GetSubspace(globalfeetypes.ModuleName)
if !ok {
panic("global fee params subspace not found")
}
globlaFeeParamsSubspace.Set(ctx, globalfeetypes.ParamStoreKeyMinGasPrices, minGasPrices)
// -- --

// -- tariff params --
tariffParamsSubspace, ok := paramauthoritykeeper.GetSubspace(tarifftypes.ModuleName)
if !ok {
panic("tariff params subspace not found")
}
paramAuth := paramauthoritykeeper.GetAuthority(ctx)
distributionEntities := []tarifftypes.DistributionEntity{
{
Address: paramAuth,
Share: sdk.NewDec(1),
},
}
feeDenom := fiatTFKeeper.GetMintingDenom(ctx)
tariffParams := tarifftypes.Params{
Share: sdk.NewDecWithPrec(8, 1),
DistributionEntities: distributionEntities,
TransferFeeBps: sdk.OneInt(),
TransferFeeMax: sdk.NewInt(5000000),
TransferFeeDenom: feeDenom.Denom,
}
tariffParamsSubspace.SetParamSet(ctx, &tariffParams)
// -- --

return versionMap, err
}
}
Loading

0 comments on commit e0d0952

Please sign in to comment.