Skip to content

Commit

Permalink
feat: wip replicated security
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed Aug 18, 2023
1 parent 4a5f303 commit d0c1166
Show file tree
Hide file tree
Showing 6 changed files with 354 additions and 8 deletions.
10 changes: 8 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import (
// Consensus
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusKeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
// Consumer
"github.com/cosmos/interchain-security/v3/x/ccv/consumer"
consumerKeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
// Crisis
"github.com/cosmos/cosmos-sdk/x/crisis"
crisisKeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
Expand Down Expand Up @@ -126,6 +129,7 @@ var (
upgrade.AppModuleBasic{},
vesting.AppModuleBasic{},

consumer.AppModuleBasic{},
ibc.AppModuleBasic{},
ibcClientSolomachine.AppModuleBasic{},
ibcClientTendermint.AppModuleBasic{},
Expand Down Expand Up @@ -172,6 +176,7 @@ type NobleApp struct {
UpgradeKeeper *upgradeKeeper.Keeper

// IBC Keepers
ConsumerKeeper consumerKeeper.Keeper
IBCKeeper *ibcKeeper.Keeper
IBCFeeKeeper ibcFeeKeeper.Keeper
IBCTransferKeeper ibcTransferKeeper.Keeper
Expand All @@ -187,6 +192,7 @@ type NobleApp struct {
TokenFactoryKeeper *tokenFactoryKeeper.Keeper

// Scoped Keepers (for IBC)
ScopedConsumerKeeper capabilityKeeper.ScopedKeeper
ScopedIBCKeeper capabilityKeeper.ScopedKeeper
ScopedIBCTransferKeeper capabilityKeeper.ScopedKeeper
ScopedICAControllerKeeper capabilityKeeper.ScopedKeeper
Expand Down Expand Up @@ -254,9 +260,9 @@ func NewNobleApp(
app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)

// Registers all modules that don't use App Wiring (e.g. IBC).
// app.RegisterLegacyModules()
app.RegisterLegacyModules()
// Registers all proposals handlers that are using v1beta1 governance.
// app.RegisterLegacyRouter()
app.RegisterLegacyRouter()

if err := app.Load(loadLatest); err != nil {
panic(err)
Expand Down
5 changes: 5 additions & 0 deletions app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
// Consensus
consensus "cosmossdk.io/api/cosmos/consensus/module/v1"
consensusTypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
// Consumer
consumerTypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
// Crisis
crisis "cosmossdk.io/api/cosmos/crisis/module/v1"
crisisTypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand Down Expand Up @@ -102,6 +104,7 @@ var AppConfig = appconfig.Compose(&app.Config{
authTypes.ModuleName,
bankTypes.ModuleName,
crisisTypes.ModuleName,
consumerTypes.ModuleName, // ICS
ibcTransferTypes.ModuleName, // IBC
ibcTypes.ModuleName, // IBC
icaTypes.ModuleName, // IBC
Expand All @@ -123,6 +126,7 @@ var AppConfig = appconfig.Compose(&app.Config{
EndBlockers: []string{
crisisTypes.ModuleName,
stakingTypes.ModuleName,
consumerTypes.ModuleName, // ICS
ibcTransferTypes.ModuleName, // IBC
ibcTypes.ModuleName, // IBC
icaTypes.ModuleName, // IBC
Expand Down Expand Up @@ -174,6 +178,7 @@ var AppConfig = appconfig.Compose(&app.Config{
vestingTypes.ModuleName,
consensusTypes.ModuleName,

consumerTypes.ModuleName,
ibcTransferTypes.ModuleName,
ibcTypes.ModuleName,
icaTypes.ModuleName,
Expand Down
35 changes: 31 additions & 4 deletions app/legacy_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

// Auth
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"
// BlockIBC
blockIBC "github.com/strangelove-ventures/noble/x/blockibc"
// Consumer
consumerKeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
consumerTypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
// IBC Client
ibcClientSolomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibcClientTendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
Expand Down Expand Up @@ -40,15 +45,17 @@ import (

var (
keys = sdk.NewKVStoreKeys(
ibcTypes.StoreKey, ibcFeeTypes.StoreKey, ibcTransferTypes.StoreKey,
icaControllerTypes.StoreKey, icaHostTypes.StoreKey, pfmTypes.StoreKey,
consumerTypes.StoreKey, ibcTypes.StoreKey, ibcFeeTypes.StoreKey,
ibcTransferTypes.StoreKey, icaControllerTypes.StoreKey,
icaHostTypes.StoreKey, pfmTypes.StoreKey,
)

memKeys = sdk.NewMemoryStoreKeys()

subspaces = []string{
ibcTypes.ModuleName, ibcFeeTypes.ModuleName, ibcTransferTypes.ModuleName,
icaControllerTypes.SubModuleName, icaHostTypes.SubModuleName, pfmTypes.ModuleName,
consumerTypes.ModuleName, ibcTypes.ModuleName, ibcFeeTypes.ModuleName,
ibcTransferTypes.ModuleName, icaControllerTypes.SubModuleName,
icaHostTypes.SubModuleName, pfmTypes.ModuleName,
}
)

Expand Down Expand Up @@ -119,6 +126,26 @@ func (app *NobleApp) RegisterLegacyModules() {
app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper
app.PFMKeeper.SetTransferKeeper(app.IBCTransferKeeper)

// Keeper: Consumer
scopedConsumerKeeper := app.CapabilityKeeper.ScopeToModule(consumerTypes.ModuleName)
app.ConsumerKeeper = consumerKeeper.NewKeeper(
app.appCodec,
keys[consumerTypes.StoreKey],
app.GetSubspace(consumerTypes.ModuleName),

scopedConsumerKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ClientKeeper,
app.SlashingKeeper,
app.BankKeeper,
app.AccountKeeper,
app.IBCTransferKeeper,
app.IBCKeeper,
authTypes.FeeCollectorName,
)

// Keeper: ICA Controller
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icaControllerTypes.SubModuleName)
app.ICAControllerKeeper = icaControllerKeeper.NewKeeper(
Expand Down
Loading

0 comments on commit d0c1166

Please sign in to comment.