Skip to content

Commit

Permalink
Merge pull request #43 from chain4energy/v1.4.1
Browse files Browse the repository at this point in the history
V1.4.1 with testnet migration.
  • Loading branch information
pablokulpa authored Sep 10, 2024
2 parents e7c40d9 + 79907ca commit 6f5b1ed
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ var (
_ servertypes.Application = (*App)(nil)
_ runtime.AppI = (*App)(nil)

Upgrades = []upgrades.Upgrade{v110.Upgrade, v120.Upgrade, v130.Upgrade, v131.Upgrade, v140.Upgrade, v141.Upgrade}
Upgrades = []upgrades.Upgrade{v110.Upgrade, v120.Upgrade, v130.Upgrade, v131.Upgrade, v140.Upgrade, v141.Upgrade, v141.UpgradeTn}
)

func init() {
Expand Down
7 changes: 7 additions & 0 deletions app/upgrades/v141/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

const UpgradeName = "v1.4.1"
const UpgradeNameTn = "v1.4.1-tn"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
Expand All @@ -26,3 +27,9 @@ var Upgrade = upgrades.Upgrade{
},
},
}

var UpgradeTn = upgrades.Upgrade{
UpgradeName: UpgradeNameTn,
CreateUpgradeHandler: CreateUpgradeHandlerTn,
StoreUpgrades: store.StoreUpgrades{},
}
150 changes: 78 additions & 72 deletions app/upgrades/v141/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,86 +29,92 @@ func CreateUpgradeHandler(
appKeepers upgrades.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
if _, exists := vm[wasmtypes.ModuleName]; !exists {
ctx.Logger().Info("wasm not exist")
for _, subspace := range appKeepers.GetC4eParamsKeeper().GetSubspaces() {
subspace := subspace
ctx.Logger().Info("wasm not exist")
for _, subspace := range appKeepers.GetC4eParamsKeeper().GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
// ibc types
case ibctransfertypes.ModuleName:
keyTable = ibctransfertypes.ParamKeyTable()
case icahosttypes.SubModuleName:
keyTable = icahosttypes.ParamKeyTable()
case icacontrollertypes.SubModuleName:
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck
default:
continue
}

if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable()
case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
case slashingtypes.ModuleName:
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
case govtypes.ModuleName:
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
case crisistypes.ModuleName:
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
// ibc types
case ibctransfertypes.ModuleName:
keyTable = ibctransfertypes.ParamKeyTable()
case icahosttypes.SubModuleName:
keyTable = icahosttypes.ParamKeyTable()
case icacontrollertypes.SubModuleName:
keyTable = icacontrollertypes.ParamKeyTable()
// wasm
case wasmtypes.ModuleName:
keyTable = wasmtypes.ParamKeyTable() //nolint:staticcheck
default:
continue
}

baseAppLegacySS := appKeepers.GetC4eParamsKeeper().Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, appKeepers.GetC4eConsensusParamsKeeper())
vmResult, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vmResult, err
if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}

// Set permission for uploading new Wasm code with specific addresses
wasmParams := wasmtypes.Params{
CodeUploadAccess: wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeAnyOfAddresses,
Addresses: []string{
"c4e1r2ennr6ywv567lks3q5gujt4def726fe3t2tus",
"c4e1e0ddzmhw2ze2glszkgjk6tfvcfzv68cmnfrnaq",
"c4e19473sdmlkkvcdh6z3tqedtqsdqj4jjv7htsuaa",
"c4e1psaq0n2lzh84lzgh39kghuy0n256xltlcmea52",
"c4e1jr0ft7p2fgqxjrqxsakz9re0ae5499uz2cfmra",
"c4e1tw2crl23vluafhcvydhpnkejwth70y9knpsht7",
"c4e19x0fmrjnhqgze4c0c0st5jdpqgu3t4a2zn9t8r",
"c4e183f5fu67gagckux336kmjw75qw7dha5ycn5f6r",
"c4e10qfgech3v82uztzl20tl7uldsq8nk9gl92mm55",
"c4e16cwpandmj9np4huguzs32g0htm58p0cp9df8gj",
"c4e10ep2sxpf2kj6j26w7f4uuafedkuf9sf9xqq3sl",
"c4e16n7yweagu3fxfzvay6cz035hddda7z3ntdxq3l",
},
baseAppLegacySS := appKeepers.GetC4eParamsKeeper().Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, appKeepers.GetC4eConsensusParamsKeeper())
vmResult, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vmResult, err
}

// Set permission for uploading new Wasm code with specific addresses
wasmParams := wasmtypes.Params{
CodeUploadAccess: wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeAnyOfAddresses,
Addresses: []string{
"c4e1r2ennr6ywv567lks3q5gujt4def726fe3t2tus",
"c4e1e0ddzmhw2ze2glszkgjk6tfvcfzv68cmnfrnaq",
"c4e19473sdmlkkvcdh6z3tqedtqsdqj4jjv7htsuaa",
"c4e1psaq0n2lzh84lzgh39kghuy0n256xltlcmea52",
"c4e1jr0ft7p2fgqxjrqxsakz9re0ae5499uz2cfmra",
"c4e1tw2crl23vluafhcvydhpnkejwth70y9knpsht7",
"c4e19x0fmrjnhqgze4c0c0st5jdpqgu3t4a2zn9t8r",
"c4e183f5fu67gagckux336kmjw75qw7dha5ycn5f6r",
"c4e10qfgech3v82uztzl20tl7uldsq8nk9gl92mm55",
"c4e16cwpandmj9np4huguzs32g0htm58p0cp9df8gj",
"c4e10ep2sxpf2kj6j26w7f4uuafedkuf9sf9xqq3sl",
"c4e16n7yweagu3fxfzvay6cz035hddda7z3ntdxq3l",
},
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
}
},
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
}

err = appKeepers.GetWasmKeeper().SetParams(ctx, wasmParams)
if err != nil {
return vmResult, err
}
err = appKeepers.GetWasmKeeper().SetParams(ctx, wasmParams)
if err != nil {
return vmResult, err
}

return vmResult, nil
return vmResult, nil
}
}

} else {
return mm.RunMigrations(ctx, configurator, vm)
}
func CreateUpgradeHandlerTn(
mm *module.Manager,
configurator module.Configurator,
bpm upgrades.BaseAppParamManager,
appKeepers upgrades.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit 6f5b1ed

Please sign in to comment.