Skip to content

Commit

Permalink
Merge branch 'main' into nguyen/ic-for-ibc-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
expertdicer authored Jul 26, 2023
2 parents 6423daa + 6283944 commit c0ff186
Show file tree
Hide file tree
Showing 124 changed files with 12,175 additions and 556 deletions.
2 changes: 1 addition & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
tfmwKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
tfmwKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

// Link to default ante handler used by cosmos sdk:
Expand Down
2 changes: 1 addition & 1 deletion app/ante/ibc_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/authz"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
tfmwKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
tfmwKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

type IBCPermissionDecorator struct {
Expand Down
96 changes: 81 additions & 15 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/bank"
bech32stakingmigration "github.com/notional-labs/centauri/v3/bech32-migration/staking"
bech32stakingmigration "github.com/notional-labs/centauri/v4/bech32-migration/staking"

"github.com/notional-labs/centauri/v4/app/keepers"
v4 "github.com/notional-labs/centauri/v4/app/upgrades/v4"

"github.com/notional-labs/centauri/v3/app/keepers"
// bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/capability"
Expand Down Expand Up @@ -71,6 +73,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand All @@ -82,31 +86,35 @@ import (
icq "github.com/strangelove-ventures/async-icq/v7"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

reward "github.com/notional-labs/centauri/v3/app/upgrade/reward"
custombankmodule "github.com/notional-labs/centauri/v3/custom/bank"
custombankmodule "github.com/notional-labs/centauri/v4/custom/bank"
"github.com/strangelove-ventures/packet-forward-middleware/v7/router"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types"
alliancemodule "github.com/terra-money/alliance/x/alliance"
alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

"github.com/notional-labs/centauri/v3/app/ante"
transfermiddleware "github.com/notional-labs/centauri/v3/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
"github.com/notional-labs/centauri/v4/app/ante"
transfermiddleware "github.com/notional-labs/centauri/v4/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"

ratelimitmodule "github.com/notional-labs/centauri/v4/x/ratelimit"
ratelimitmoduletypes "github.com/notional-labs/centauri/v4/x/ratelimit/types"

consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

"github.com/notional-labs/centauri/v3/x/mint"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
"github.com/notional-labs/centauri/v4/x/mint"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"

ibc_hooks "github.com/notional-labs/centauri/v3/x/ibc-hooks"
ibchookstypes "github.com/notional-labs/centauri/v3/x/ibc-hooks/types"
ibc_hooks "github.com/notional-labs/centauri/v4/x/ibc-hooks"
ibchookstypes "github.com/notional-labs/centauri/v4/x/ibc-hooks/types"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

upgrades "github.com/notional-labs/centauri/v4/app/upgrades"
)

const (
Expand All @@ -123,6 +131,8 @@ var (
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v4.Upgrade}
)

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
Expand Down Expand Up @@ -194,8 +204,10 @@ var (
wasm08.AppModuleBasic{},
wasm.AppModuleBasic{},
router.AppModuleBasic{},
ica.AppModuleBasic{},
ibc_hooks.AppModuleBasic{},
transfermiddleware.AppModuleBasic{},
ratelimitmodule.AppModuleBasic{},
consensus.AppModuleBasic{},
alliancemodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
Expand All @@ -214,6 +226,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.RewardsPoolName: nil,
icatypes.ModuleName: nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -291,7 +304,7 @@ func NewCentauriApp(
skipUpgradeHeights,
homePath,
)

app.setupUpgradeStoreLoaders()
app.InitNormalKeepers(
appCodec,
cdc,
Expand All @@ -308,8 +321,10 @@ func NewCentauriApp(
transferModule := transfer.NewAppModule(app.TransferKeeper)
routerModule := router.NewAppModule(app.RouterKeeper)
transfermiddlewareModule := transfermiddleware.NewAppModule(&app.TransferMiddlewareKeeper)
ratelimitModule := ratelimitmodule.NewAppModule(&app.RatelimitKeeper)
icqModule := icq.NewAppModule(app.ICQKeeper)
ibcHooksModule := ibc_hooks.NewAppModule()
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) // Only ICA Host
/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -348,6 +363,8 @@ func NewCentauriApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
routerModule,
transfermiddlewareModule,
icaModule,
ratelimitModule,
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// this line is used by starport scaffolding # stargate/app/appModule
)
Expand All @@ -369,6 +386,7 @@ func NewCentauriApp(
ibctransfertypes.ModuleName,
routertypes.ModuleName,
transfermiddlewaretypes.ModuleName,
ratelimitmoduletypes.ModuleName,
ibchookstypes.ModuleName,
icqtypes.ModuleName,
authtypes.ModuleName,
Expand All @@ -381,6 +399,7 @@ func NewCentauriApp(
paramstypes.ModuleName,
consensusparamtypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
Expand All @@ -406,11 +425,13 @@ func NewCentauriApp(
ibchost.ModuleName,
routertypes.ModuleName,
transfermiddlewaretypes.ModuleName,
ratelimitmoduletypes.ModuleName,
ibchookstypes.ModuleName,
ibctransfertypes.ModuleName,
icqtypes.ModuleName,
consensusparamtypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
)
Expand Down Expand Up @@ -440,11 +461,13 @@ func NewCentauriApp(
icqtypes.ModuleName,
routertypes.ModuleName,
transfermiddlewaretypes.ModuleName,
ratelimitmoduletypes.ModuleName,
ibchookstypes.ModuleName,
feegrant.ModuleName,
group.ModuleName,
consensusparamtypes.ModuleName,
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
Expand All @@ -454,6 +477,8 @@ func NewCentauriApp(
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

app.setupUpgradeHandlers()

// create the simulation manager and define the order of the modules for deterministic simulations
// app.sm = module.NewSimulationManager(
// auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
Expand Down Expand Up @@ -514,9 +539,6 @@ func NewCentauriApp(
}
}

// app.ScopedMonitoringKeeper = scopedMonitoringKeeper
app.UpgradeKeeper.SetUpgradeHandler(reward.UpgradeName, reward.CreateUpgradeHandler(app.mm, app.configurator, app.TransferMiddlewareKeeper, app.MintKeeper))

return app
}

Expand Down Expand Up @@ -655,3 +677,47 @@ func GetMaccPerms() map[string][]string {
func (app *CentauriApp) SimulationManager() *module.SimulationManager {
return app.sm
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
func (app *CentauriApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

currentHeight := app.CommitMultiStore().LastCommitID().Version

if upgradeInfo.Height == currentHeight+1 {
app.customPreUpgradeHandler(upgradeInfo)
}

for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
}
}
}

func (app *CentauriApp) customPreUpgradeHandler(upgradeInfo upgradetypes.Plan) {
switch upgradeInfo.Name {
default:
}
}

func (app *CentauriApp) setupUpgradeHandlers() {
for _, upgrade := range Upgrades {
app.UpgradeKeeper.SetUpgradeHandler(
upgrade.UpgradeName,
upgrade.CreateUpgradeHandler(
app.mm,
app.configurator,
app.BaseApp,
&app.AppKeepers,
),
)
}
}
2 changes: 1 addition & 1 deletion app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/ibc-go/v7/testing/mock"
centauri "github.com/notional-labs/centauri/v3/app"
centauri "github.com/notional-labs/centauri/v4/app"
"github.com/stretchr/testify/require"
)

Expand Down
14 changes: 10 additions & 4 deletions app/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"testing"
"time"

ratelimitmodulekeeper "github.com/notional-labs/centauri/v4/x/ratelimit/keeper"

"cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
Expand Down Expand Up @@ -49,9 +51,9 @@ import (
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/cosmos/ibc-go/v7/testing/mock"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
centauri "github.com/notional-labs/centauri/v3/app"
"github.com/notional-labs/centauri/v3/app/ibctesting/simapp"
routerKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
centauri "github.com/notional-labs/centauri/v4/app"
"github.com/notional-labs/centauri/v4/app/ibctesting/simapp"
routerKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -122,7 +124,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *TestChain {
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)),
}

app := NewTestingAppDecorator(t, centauri.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance))
app := NewTestingAppDecorator(t, centauri.SetupWithGenesisValSet(t, coord.CurrentTime.UTC(), valSet, []authtypes.GenesisAccount{acc}, balance))

// create current header and call begin block
header := tmproto.Header{
Expand Down Expand Up @@ -616,6 +618,10 @@ func (chain *TestChain) TransferMiddleware() routerKeeper.Keeper {
return chain.GetTestSupport().TransferMiddleware()
}

func (chain *TestChain) RateLimit() ratelimitmodulekeeper.Keeper {
return chain.GetTestSupport().RateLimit()
}

func (chain *TestChain) Balance(acc sdk.AccAddress, denom string) sdk.Coin {
return chain.GetTestSupport().BankKeeper().GetBalance(chain.GetContext(), acc, denom)
}
Expand Down
21 changes: 11 additions & 10 deletions app/ibctesting/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ import (
"github.com/gorilla/mux"

// TODO: mint module not complete yet,
"github.com/notional-labs/centauri/v3/x/mint"
mintkeeper "github.com/notional-labs/centauri/v3/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
"github.com/notional-labs/centauri/v4/x/mint"
mintkeeper "github.com/notional-labs/centauri/v4/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -123,13 +123,13 @@ import (
wasm08 "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
simappparams "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/params"
simappupgrades "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades"
v6 "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades/v6"
v7 "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades/v7"
transfermiddleware "github.com/notional-labs/centauri/v3/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
simappparams "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/params"
simappupgrades "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades"
v6 "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades/v6"
v7 "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades/v7"
transfermiddleware "github.com/notional-labs/centauri/v4/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"
)

const appName = "SimApp"
Expand Down Expand Up @@ -379,6 +379,7 @@ func NewSimApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.TransferMiddlewarekeeper = transfermiddlewarekeeper.NewKeeper(
keys[transfermiddlewaretypes.StoreKey],
app.GetSubspace(transfermiddlewaretypes.ModuleName),
appCodec,
app.IBCKeeper.ChannelKeeper,
app.TransferKeeper,
Expand Down
2 changes: 1 addition & 1 deletion app/ibctesting/simapp/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package simapp
import (
"github.com/cosmos/cosmos-sdk/std"

simappparams "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/params"
simappparams "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/params"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
Expand Down
2 changes: 1 addition & 1 deletion app/ibctesting/simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/simulation"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"
"github.com/stretchr/testify/require"

ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand Down
Loading

0 comments on commit c0ff186

Please sign in to comment.