Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of EndBlock #221

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import (
ibcprovider "github.com/cosmos/interchain-security/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/x/ccv/provider/client"
ibcproviderkeeper "github.com/cosmos/interchain-security/x/ccv/provider/keeper"
ibcprovidertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"

"github.com/tendermint/spm/cosmoscmd"

Expand Down Expand Up @@ -288,7 +288,7 @@ func New(
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, liquiditytypes.StoreKey, ibctransfertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey,
ibcprovidertypes.StoreKey,
providertypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, stakingtypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -325,7 +325,7 @@ func New(
)
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedIBCProviderKeeper := app.CapabilityKeeper.ScopeToModule(ibcprovidertypes.ModuleName)
scopedIBCProviderKeeper := app.CapabilityKeeper.ScopeToModule(providertypes.ModuleName)
app.CapabilityKeeper.Seal()

// add keepers
Expand Down Expand Up @@ -437,8 +437,8 @@ func New(

app.ProviderKeeper = ibcproviderkeeper.NewKeeper(
appCodec,
keys[ibcprovidertypes.StoreKey],
app.GetSubspace(ibcprovidertypes.ModuleName),
keys[providertypes.StoreKey],
app.GetSubspace(providertypes.ModuleName),
scopedIBCProviderKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
Expand All @@ -460,7 +460,7 @@ func New(
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(ibcprovidertypes.RouterKey, ibcprovider.NewConsumerChainProposalHandler(app.ProviderKeeper)).
AddRoute(providertypes.RouterKey, ibcprovider.NewConsumerChainProposalHandler(app.ProviderKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

app.GovKeeper = govkeeper.NewKeeper(
Expand Down Expand Up @@ -490,7 +490,7 @@ func New(
// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, ibcmodule)
ibcRouter.AddRoute(ibcprovidertypes.ModuleName, providerModule)
ibcRouter.AddRoute(providertypes.ModuleName, providerModule)
app.IBCKeeper.SetRouter(ibcRouter)

// create evidence keeper with router
Expand Down Expand Up @@ -561,8 +561,14 @@ func New(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
ibcprovidertypes.ModuleName,
providertypes.ModuleName,
)
// Interchain Security requirements
// - provider.EndBlock gets validator updates from the staking module;
// thus, staking.EndBlock must be executed before provider.EndBlock;
// - creating a new consumer chain requires the following order,
// CreateChildClient(), staking.EndBlock, provider.EndBlock;
// thus, gov.EndBlock must be executed before staking.EndBlock
app.MM.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
Expand All @@ -583,7 +589,7 @@ func New(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibcprovidertypes.ModuleName,
providertypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -612,7 +618,7 @@ func New(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibcprovidertypes.ModuleName,
providertypes.ModuleName,
)

app.MM.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -902,7 +908,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(liquiditytypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(ibcprovidertypes.ModuleName)
paramsKeeper.Subspace(providertypes.ModuleName)

return paramsKeeper
}