Skip to content

Commit

Permalink
fix upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Mar 29, 2024
1 parent d152e7e commit 327db81
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 20 deletions.
4 changes: 4 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ante

import (
circuitante "cosmossdk.io/x/circuit/ante"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

Expand Down Expand Up @@ -28,13 +30,15 @@ func NewAnteHandler(
channelKeeper *ibckeeper.Keeper,
tfmwKeeper tfmwKeeper.Keeper,
txBoundaryKeeper txBoundaryKeeper.Keeper,
ck *circuitkeeper.Keeper,
codec codec.BinaryCodec,
) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // // outermost AnteDecorator. SetUpContext must be called first
ante.NewValidateBasicDecorator(),
ante.NewConsumeGasForTxSizeDecorator(ak),
ante.NewDeductFeeDecorator(ak, bk, feegrantKeeper, txFeeChecker),
circuitante.NewCircuitBreakerDecorator(ck),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(ak),
ante.NewConsumeGasForTxSizeDecorator(ak),
Expand Down
14 changes: 11 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"cosmossdk.io/x/circuit"
circuittypes "cosmossdk.io/x/circuit/types"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -203,6 +205,7 @@ var (
consensus.AppModuleBasic{},
stakingmiddleware.AppModuleBasic{},
ibctransfermiddleware.AppModuleBasic{},
circuit.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -384,6 +387,7 @@ func NewComposableApp(
txBoundaryModule,
icaModule,
ratelimitModule,
circuit.NewAppModule(appCodec, app.CircuitKeeper),
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -422,9 +426,10 @@ func NewComposableApp(
group.ModuleName,
paramstypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
Expand Down Expand Up @@ -457,9 +462,10 @@ func NewComposableApp(
ibctransfertypes.ModuleName,
icqtypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
)
Expand Down Expand Up @@ -496,9 +502,10 @@ func NewComposableApp(
feegrant.ModuleName,
group.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
Expand Down Expand Up @@ -555,6 +562,7 @@ func NewComposableApp(
app.IBCKeeper,
app.TransferMiddlewareKeeper,
app.TxBoundaryKeepper,
&app.CircuitKeeper,
appCodec,
))
app.SetEndBlocker(app.EndBlocker)
Expand Down
36 changes: 30 additions & 6 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package keepers

import (
circuitkeeper "cosmossdk.io/x/circuit/keeper"
circuittypes "cosmossdk.io/x/circuit/types"
"fmt"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
"path/filepath"
"strings"

Expand All @@ -12,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"

authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
Expand Down Expand Up @@ -67,7 +71,6 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
customibctransferkeeper "github.com/notional-labs/composable/v6/custom/ibc-transfer/keeper"

Expand Down Expand Up @@ -164,6 +167,8 @@ type AppKeepers struct {
RatelimitKeeper ratelimitmodulekeeper.Keeper
StakingMiddlewareKeeper stakingmiddleware.Keeper
IbcTransferMiddlewareKeeper ibctransfermiddleware.Keeper

CircuitKeeper circuitkeeper.Keeper
}

// InitNormalKeepers initializes all 'normal' keepers.
Expand Down Expand Up @@ -231,6 +236,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec, cdc, runtime.NewKVStoreService(appKeepers.keys[slashingtypes.StoreKey]), appKeepers.StakingKeeper, govModAddress,
)

appKeepers.CircuitKeeper = circuitkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[circuittypes.StoreKey]),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.AccountKeeper.AddressCodec(),
)
bApp.SetCircuitBreaker(&appKeepers.CircuitKeeper)

appKeepers.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, runtime.NewKVStoreService(appKeepers.keys[crisistypes.StoreKey]),
invCheckPeriod, appKeepers.BankKeeper, authtypes.FeeCollectorName, govModAddress, appKeepers.AccountKeeper.AddressCodec(),
)
Expand Down Expand Up @@ -262,7 +275,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers(

// Create IBC Keeper
appKeepers.IBCKeeper = ibckeeper.NewKeeper(
appCodec, appKeepers.keys[ibchost.StoreKey], appKeepers.GetSubspace(ibchost.ModuleName), appKeepers.StakingKeeper, appKeepers.UpgradeKeeper, appKeepers.ScopedIBCKeeper, govModAddress,
appCodec,
appKeepers.keys[ibcexported.StoreKey],
appKeepers.GetSubspace(ibcexported.ModuleName),
appKeepers.StakingKeeper,
appKeepers.UpgradeKeeper,
appKeepers.ScopedIBCKeeper,
govModAddress,
)

// ICA Host keeper
Expand Down Expand Up @@ -494,9 +513,9 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
bApp.SetParamStore(&appKeepers.ConsensusParamsKeeper.ParamsStore)

// grant capabilities for the ibc and ibc-transfer modules
appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
appKeepers.ScopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
appKeepers.ScopedRateLimitKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ratelimitmoduletypes.ModuleName)

Expand All @@ -507,6 +526,11 @@ func (appKeepers *AppKeepers) InitSpecialKeepers(
func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

// register the IBC key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{})
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)

paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
Expand All @@ -519,9 +543,9 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ratelimitmoduletypes.ModuleName)
paramsKeeper.Subspace(icqtypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(wasm08types.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(transfermiddlewaretypes.ModuleName)
paramsKeeper.Subspace(stakingmiddlewaretypes.ModuleName)
paramsKeeper.Subspace(ibctransfermiddlewaretypes.ModuleName)
Expand Down
16 changes: 13 additions & 3 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package keepers

import (
circuittypes "cosmossdk.io/x/circuit/types"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"

// bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand Down Expand Up @@ -38,7 +41,6 @@ import (

minttypes "github.com/notional-labs/composable/v6/x/mint/types"

"github.com/CosmWasm/wasmd/x/wasm"
wasm08types "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"

// customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types"
Expand All @@ -54,9 +56,17 @@ func (appKeepers *AppKeepers) GenerateKeys() {
appKeepers.keys = storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasm08types.StoreKey,
evidencetypes.StoreKey,
circuittypes.StoreKey,
ibctransfertypes.StoreKey,
icqtypes.StoreKey, capabilitytypes.StoreKey,
consensusparamtypes.StoreKey, wasm08types.StoreKey,
authzkeeper.StoreKey, stakingmiddleware.StoreKey, ibctransfermiddleware.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey,
group.StoreKey, minttypes.StoreKey, wasmtypes.StoreKey,
ibcexported.StoreKey,
ibchookstypes.StoreKey, icahosttypes.StoreKey,
ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
)

// Define transient store keys
Expand Down
5 changes: 4 additions & 1 deletion app/upgrades/v7_0_0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v7_0_0

import (
store "cosmossdk.io/store/types"
circuittypes "cosmossdk.io/x/circuit/types"
"github.com/notional-labs/composable/v6/app/upgrades"
)

Expand All @@ -14,7 +15,9 @@ var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Added: []string{
circuittypes.ModuleName,
},
Deleted: []string{"alliance"},
},
}
2 changes: 2 additions & 0 deletions app/upgrades/v7_0_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v7_0_0

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -19,6 +20,7 @@ func CreateUpgradeHandler(
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
fmt.Println("start v7.0.0 upgrade")
return mm.RunMigrations(ctx, configurator, vm)
}
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ replace (

github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.5

github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240328152744-0f9d4a916102
// github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240328152744-0f9d4a916102
github.com/cosmos/ibc-go/modules/light-clients/08-wasm => /Users/hoank/resource/notional/ibc-go/modules/light-clients/08-wasm

github.com/cosmos/ibc-go/v8 => /Users/hoank/resource/notional/ibc-go

// use cosmos-compatible protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,6 @@ github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 h1:nKP2+Rzlz2iyvTosY5mvP+
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0/go.mod h1:D3Q380FpWRFtmUQWLosPxachi6w24Og2t5u/Tww5wtY=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg=
github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
Expand Down Expand Up @@ -1401,8 +1399,6 @@ github.com/nishanths/exhaustive v0.9.5 h1:TzssWan6orBiLYVqewCG8faud9qlFntJE30ACp
github.com/nishanths/exhaustive v0.9.5/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA=
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240328152744-0f9d4a916102 h1:XKnqm3lM0mj7VYUpRrdbu4Pf01oz8spFr5rKEZIt4lk=
github.com/notional-labs/ibc-go/modules/light-clients/08-wasm v0.0.0-20240328152744-0f9d4a916102/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0=
github.com/nunnatsa/ginkgolinter v0.9.0 h1:Sm0zX5QfjJzkeCjEp+t6d3Ha0jwvoDjleP9XCsrEzOA=
github.com/nunnatsa/ginkgolinter v0.9.0/go.mod h1:FHaMLURXP7qImeH6bvxWJUpyH+2tuqe5j4rW1gxJRmI=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
4 changes: 2 additions & 2 deletions scripts/localnode.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ "$CONTINUE" == "true" ]; then
exit 0
fi

rm -rf mytestnet
rm -rf $HOME_DIR
pkill centaurid

# check DENOM is set. If not, set to upica
Expand All @@ -38,7 +38,7 @@ fi
# check BINARY is set. If not, build centaurid and set BINARY
if [ -z "$BINARY" ]; then
make build
BINARY=build/centaurid
BINARY=centaurid
fi

CHAIN_ID="localpica"
Expand Down

0 comments on commit 327db81

Please sign in to comment.