Skip to content

Commit

Permalink
V1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelkulpa committed Sep 4, 2024
1 parent 025f9b0 commit 6269f35
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ open-memory-profiler-result:

PACKAGES_E2E=./tests/e2e
BUILDDIR ?= $(CURDIR)/build
E2E_UPGRADE_VERSION="v1.4.0"
E2E_UPGRADE_VERSION="v1.4.1"
E2E_SCRIPT_NAME=chain
C4E_E2E_SIGN_MODE = "direct"

Expand Down
12 changes: 11 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
wasmd "github.com/CosmWasm/wasmd/app"
v131 "github.com/chain4energy/c4e-chain/app/upgrades/v131"
v140 "github.com/chain4energy/c4e-chain/app/upgrades/v140"
v141 "github.com/chain4energy/c4e-chain/app/upgrades/v141"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7/types"

Expand Down Expand Up @@ -231,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}
Upgrades = []upgrades.Upgrade{v110.Upgrade, v120.Upgrade, v130.Upgrade, v131.Upgrade, v140.Upgrade, v141.Upgrade}
)

func init() {
Expand Down Expand Up @@ -307,6 +308,14 @@ type App struct {
sm *module.SimulationManager
}

// overrideWasmVariables overrides the wasm variables to:
// - allow for larger wasm files
func overrideWasmVariables() {
// Override Wasm size limitation from WASMD.
wasmtypes.MaxWasmSize = 3 * 1024 * 1024
wasmtypes.MaxProposalWasmSize = wasmtypes.MaxWasmSize
}

// New returns a reference to an initialized blockchain app
func New(
logger log.Logger,
Expand All @@ -321,6 +330,7 @@ func New(
wasmOpts []wasmkeeper.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
overrideWasmVariables()
appCodec := encodingConfig.Codec
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down
5 changes: 5 additions & 0 deletions app/app_keepers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"github.com/CosmWasm/wasmd/x/wasm"
cfeupgradetypes "github.com/chain4energy/c4e-chain/app/upgrades"
cfeclaimkeeper "github.com/chain4energy/c4e-chain/x/cfeclaim/keeper"
cfevestingkeeper "github.com/chain4energy/c4e-chain/x/cfevesting/keeper"
Expand Down Expand Up @@ -44,3 +45,7 @@ func (app *App) GetC4eParamsKeeper() *paramskeeper.Keeper {
func (app *App) GetC4eConsensusParamsKeeper() *consensusparamkeeper.Keeper {
return &app.ConsensusParamsKeeper
}

func (app *App) GetWasmKeeper() *wasm.Keeper {
return &app.WasmKeeper
}
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package upgrades

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
cfeclaimkeeper "github.com/chain4energy/c4e-chain/x/cfeclaim/keeper"
cfevestingkeeper "github.com/chain4energy/c4e-chain/x/cfevesting/keeper"
"github.com/cometbft/cometbft/proto/tendermint/types"
Expand All @@ -20,6 +21,7 @@ type AppKeepers interface {
GetBankKeeper() *bankkeeper.Keeper
GetParamKeeper() *paramsKeeper.Keeper
GetC4eVestingKeeper() *cfevestingkeeper.Keeper
GetWasmKeeper() *wasmkeeper.Keeper
GetC4eClaimKeeper() *cfeclaimkeeper.Keeper
GetC4eParamsKeeper() *paramsKeeper.Keeper
GetC4eConsensusParamsKeeper() *consensusparamkeeper.Keeper
Expand Down
28 changes: 28 additions & 0 deletions app/upgrades/v141/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v141

import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/chain4energy/c4e-chain/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7/types"
)

const UpgradeName = "v1.4.1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
consensusparamtypes.ModuleName,
crisistypes.ModuleName,
wasmtypes.StoreKey,
ibchookstypes.StoreKey,
},
Deleted: []string{
"cfesignature",
},
},
}
102 changes: 102 additions & 0 deletions app/upgrades/v141/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package v141

import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/chain4energy/c4e-chain/app/upgrades"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
)

func CreateUpgradeHandler(
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) {
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)
}
}

baseAppLegacySS := appKeepers.GetC4eParamsKeeper().Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, appKeepers.GetC4eConsensusParamsKeeper())
vmResult, err := mm.RunMigrations(ctx, configurator, vm)

// 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",
},
},
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
}
err = appKeepers.GetWasmKeeper().SetParams(ctx, wasmParams)
if err != nil {
return vmResult, err
}

return vmResult, nil
}
}

0 comments on commit 6269f35

Please sign in to comment.