Skip to content

Commit

Permalink
Merge branch 'release/v2.7' into feat/ibc/hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 authored Nov 1, 2023
2 parents fb899b0 + 0043608 commit dc0cf53
Show file tree
Hide file tree
Showing 54 changed files with 858 additions and 166 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh

gen-swagger:
proto-swagger:
bash scripts/protoc-swagger-gen.sh

update-swagger-docs: statik
Expand All @@ -266,9 +266,7 @@ update-swagger-docs: statik
echo "Swagger docs are in sync!";\
fi

apply-swagger: gen-swagger update-swagger-docs

proto-all: proto-gen gen-swagger update-swagger-docs apply-swagger
proto-all: proto-gen proto-swagger update-swagger-docs

.PHONY: proto-gen gen-swagger update-swagger-docs apply-swagger proto-all

Expand Down
13 changes: 7 additions & 6 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package ante

import (
"github.com/cosmos/cosmos-sdk/client"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/skip-mev/pob/mempool"
Expand All @@ -15,6 +9,13 @@ import (
feeshareante "github.com/terra-money/core/v2/x/feeshare/ante"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"

"github.com/cosmos/cosmos-sdk/client"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
Expand Down
50 changes: 47 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"

icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
Expand Down Expand Up @@ -168,6 +172,7 @@ import (
v2_4 "github.com/terra-money/core/v2/app/upgrades/v2.4"
v2_5 "github.com/terra-money/core/v2/app/upgrades/v2.5"
v2_6 "github.com/terra-money/core/v2/app/upgrades/v2.6"
v2_7 "github.com/terra-money/core/v2/app/upgrades/v2.7"

// unnamed import of statik for swagger UI support
_ "github.com/terra-money/core/v2/client/docs/statik"
Expand Down Expand Up @@ -239,6 +244,7 @@ var (
alliance.AppModuleBasic{},
feeshare.AppModuleBasic{},
pob.AppModuleBasic{},
icq.AppModuleBasic{},
)

// module account permissions
Expand All @@ -252,6 +258,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icqtypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Burner, authtypes.Minter},
alliancetypes.ModuleName: {authtypes.Burner, authtypes.Minter},
Expand Down Expand Up @@ -315,6 +322,7 @@ type TerraApp struct {
TokenFactoryKeeper tokenfactorykeeper.Keeper
AllianceKeeper alliancekeeper.Keeper
FeeShareKeeper feesharekeeper.Keeper
ICQKeeper icqkeeper.Keeper

// IBC hooks
IBCHooksKeeper *ibchookskeeper.Keeper
Expand All @@ -327,6 +335,7 @@ type TerraApp struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICQKeeper capabilitykeeper.ScopedKeeper

WasmKeeper wasmkeeper.Keeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -388,7 +397,7 @@ func NewTerraApp(
icahosttypes.StoreKey, icacontrollertypes.StoreKey, routertypes.StoreKey,
consensusparamtypes.StoreKey, tokenfactorytypes.StoreKey, wasmtypes.StoreKey,
ibcfeetypes.StoreKey, ibchookstypes.StoreKey, crisistypes.StoreKey,
alliancetypes.StoreKey, feesharetypes.StoreKey, pobtype.StoreKey,
alliancetypes.StoreKey, feesharetypes.StoreKey, pobtype.StoreKey, icqtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -421,6 +430,7 @@ func NewTerraApp(
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)

scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)

Expand Down Expand Up @@ -587,9 +597,20 @@ func NewTerraApp(
app.IBCKeeper.ChannelKeeper,
)
pmfTransferStack := router.NewIBCMiddleware(hooksTransferStack, &app.RouterKeeper, 5, routerkeeper.DefaultForwardTransferPacketTimeoutTimestamp, routerkeeper.DefaultRefundTransferPacketTimeoutTimestamp)

app.TransferStack = &pmfTransferStack

// ICQ Keeper
app.ICQKeeper = icqkeeper.NewKeeper(
appCodec,
app.keys[icqtypes.StoreKey],
app.GetSubspace(icqtypes.ModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedICQKeeper,
bApp.GRPCQueryRouter(),
)

app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
Expand Down Expand Up @@ -670,12 +691,14 @@ func NewTerraApp(
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper)

icqModule := icq.NewIBCModule(app.ICQKeeper)
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter().
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(ibctransfertypes.ModuleName, pmfTransferStack).
AddRoute(wasmtypes.ModuleName, wasmStack)
AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(icqtypes.ModuleName, icqModule)

app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -754,6 +777,7 @@ func NewTerraApp(
alliance.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancetypes.ModuleName)),
feeshare.NewAppModule(app.FeeShareKeeper, app.AccountKeeper, app.GetSubspace(feesharetypes.ModuleName)),
pob.NewAppModule(appCodec, app.BuilderKeeper),
icq.NewAppModule(app.ICQKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -789,6 +813,7 @@ func NewTerraApp(
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
icqtypes.ModuleName,
pobtype.ModuleName,
)

Expand Down Expand Up @@ -821,6 +846,7 @@ func NewTerraApp(
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
icqtypes.ModuleName,
pobtype.ModuleName,
)

Expand Down Expand Up @@ -857,6 +883,7 @@ func NewTerraApp(
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
icqtypes.ModuleName,
pobtype.ModuleName,
)

Expand Down Expand Up @@ -966,6 +993,13 @@ func NewTerraApp(
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
} else if upgradeInfo.Name == terraappconfig.Upgrade2_7 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
icqtypes.StoreKey,
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if loadLatest {
Expand All @@ -988,6 +1022,7 @@ func NewTerraApp(
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.scopedWasmKeeper = scopedWasmKeeper
app.ScopedICQKeeper = scopedICQKeeper

return app
}
Expand Down Expand Up @@ -1171,6 +1206,14 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.FeeShareKeeper,
),
)
app.UpgradeKeeper.SetUpgradeHandler(
terraappconfig.Upgrade2_7,
v2_7.CreateUpgradeHandler(app.mm,
app.configurator,
app.appCodec,
app.ICQKeeper,
),
)
}

// RegisterSwaggerAPI registers swagger route with API Server
Expand Down Expand Up @@ -1213,6 +1256,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(alliancetypes.ModuleName).WithKeyTable(alliancetypes.ParamKeyTable())
paramsKeeper.Subspace(feesharetypes.ModuleName).WithKeyTable(feesharetypes.ParamKeyTable())
paramsKeeper.Subspace(icqtypes.ModuleName)

paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())

Expand Down
19 changes: 12 additions & 7 deletions app/app_test/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
mocktestutils "github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
Expand All @@ -19,7 +17,17 @@ import (
"github.com/terra-money/core/v2/x/feeshare"
"github.com/terra-money/core/v2/x/tokenfactory"

mocktestutils "github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"

tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -44,11 +52,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/upgrade"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"

"github.com/CosmWasm/wasmd/x/wasm"
terra_app "github.com/terra-money/core/v2/app"
Expand Down Expand Up @@ -156,6 +159,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"genutil": genutil.AppModule{}.ConsensusVersion(),
"gov": gov.AppModule{}.ConsensusVersion(),
"ibc": ibc.AppModule{}.ConsensusVersion(),
"interchainquery": icq.AppModule{}.ConsensusVersion(),
"ibchooks": ibchooks.AppModule{}.ConsensusVersion(),
"interchainaccounts": ica.AppModule{}.ConsensusVersion(),
"mint": mint.AppModule{}.ConsensusVersion(),
Expand Down Expand Up @@ -190,6 +194,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"ibc": 4,
"ibchooks": 1,
"interchainaccounts": 2,
"interchainquery": 1,
"mint": 2,
"mock": 0,
"packetfowardmiddleware": 1,
Expand Down
19 changes: 9 additions & 10 deletions app/app_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import (
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/suite"
"github.com/terra-money/core/v2/app"
terra_app "github.com/terra-money/core/v2/app"
appparams "github.com/terra-money/core/v2/app/params"
"github.com/terra-money/core/v2/app/wasmconfig"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"

"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
Expand All @@ -23,14 +31,6 @@ import (
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/suite"
"github.com/terra-money/core/v2/app"
terra_app "github.com/terra-money/core/v2/app"
"github.com/terra-money/core/v2/app/config"
appparams "github.com/terra-money/core/v2/app/params"
"github.com/terra-money/core/v2/app/wasmconfig"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"
)

type AppTestSuite struct {
Expand All @@ -47,8 +47,7 @@ func (s *AppTestSuite) Setup() {
appparams.RegisterAddressesConfig()
encCfg := terra_app.MakeEncodingConfig()
genesisState := app.NewDefaultGenesisState(encCfg.Marshaler)
genesisState.ConfigureBondDenom(encCfg.Marshaler, config.BondDenom)
genesisState.ConfigureICA(encCfg.Marshaler)
genesisState.SetDefaultTerraConfig(encCfg.Marshaler)

db := dbm.NewMemDB()
s.App = terra_app.NewTerraApp(
Expand Down
Loading

0 comments on commit dc0cf53

Please sign in to comment.