Skip to content

Commit

Permalink
fix: begin blocker order
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Mar 28, 2024
1 parent 3e21b5e commit 3364248
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 44 deletions.
22 changes: 20 additions & 2 deletions app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ var (
beginBlockers = []string{
// cosmos sdk modules
minttypes.ModuleName,
// NOTE: x/team must be run before x/distribution and after x/mint.
teamtypes.ModuleName,
// NOTE: x/bundles must be run before x/distribution and after x/team.
bundlestypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
Expand All @@ -139,13 +143,11 @@ var (
ibcfeetypes.ModuleName,

// KYVE modules
bundlestypes.ModuleName,
delegationtypes.ModuleName,
globaltypes.ModuleName,
pooltypes.ModuleName,
querytypes.ModuleName,
stakerstypes.ModuleName,
teamtypes.ModuleName,
funderstypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
}
Expand Down Expand Up @@ -191,6 +193,8 @@ var (
{Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, authtypes.Staking}},
{Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, authtypes.Staking}},
{Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},

// IBC
{Account: ibctransfertypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
Expand All @@ -212,6 +216,20 @@ var (
minttypes.ModuleName,
stakingtypes.BondedPoolName,
stakingtypes.NotBondedPoolName,

// IBC
ibctransfertypes.ModuleName,
ibcfeetypes.ModuleName,
icatypes.ModuleName,

// KYVE
bundlestypes.ModuleName,
delegationtypes.ModuleName,
pooltypes.ModuleName,
stakerstypes.ModuleName,
teamtypes.ModuleName,
funderstypes.ModuleName,

// We allow the following module accounts to receive funds:
// govtypes.ModuleName
}
Expand Down
7 changes: 3 additions & 4 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,10 @@ func (suite *KeeperTestSuite) VerifyBundlesGenesisImportExport() {
// ========================

func (suite *KeeperTestSuite) VerifyDelegationQueries() {
goCtx := sdk.WrapSDKContext(suite.Ctx())
for _, delegator := range suite.App().DelegationKeeper.GetAllDelegators(suite.Ctx()) {

// Query: delegator/{staker}/{delegator}
resD, errD := suite.App().QueryKeeper.Delegator(goCtx, &querytypes.QueryDelegatorRequest{
resD, errD := suite.App().QueryKeeper.Delegator(suite.Ctx(), &querytypes.QueryDelegatorRequest{
Staker: delegator.Staker,
Delegator: delegator.Delegator,
})
Expand All @@ -332,7 +331,7 @@ func (suite *KeeperTestSuite) VerifyDelegationQueries() {
Expect(resD.Delegator.CurrentReward).To(Equal(suite.App().DelegationKeeper.GetOutstandingRewards(suite.Ctx(), delegator.Staker, delegator.Delegator)))

// Query: stakers_by_delegator/{delegator}
resSbD, errSbD := suite.App().QueryKeeper.StakersByDelegator(goCtx, &querytypes.QueryStakersByDelegatorRequest{
resSbD, errSbD := suite.App().QueryKeeper.StakersByDelegator(suite.Ctx(), &querytypes.QueryStakersByDelegatorRequest{
Pagination: nil,
Delegator: delegator.Delegator,
})
Expand All @@ -355,7 +354,7 @@ func (suite *KeeperTestSuite) VerifyDelegationQueries() {

for _, staker := range suite.App().StakersKeeper.GetAllStakers(suite.Ctx()) {
// Query: delegators_by_staker/{staker}
resDbS, errDbS := suite.App().QueryKeeper.DelegatorsByStaker(goCtx, &querytypes.QueryDelegatorsByStakerRequest{
resDbS, errDbS := suite.App().QueryKeeper.DelegatorsByStaker(suite.Ctx(), &querytypes.QueryDelegatorsByStakerRequest{
Pagination: nil,
Staker: staker.Address,
})
Expand Down
3 changes: 1 addition & 2 deletions x/delegation/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper"
stakersKeeper "github.com/KYVENetwork/chain/x/stakers/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
distributionKeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -195,7 +194,7 @@ type ModuleInputs struct {
Logger log.Logger

AccountKeeper types.AccountKeeper
BankKeeper bankKeeper.Keeper
BankKeeper util.BankKeeper
DistributionKeeper distributionKeeper.Keeper
UpgradeKeeper util.UpgradeKeeper
PoolKeeper *poolKeeper.Keeper
Expand Down
3 changes: 1 addition & 2 deletions x/funders/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/KYVENetwork/chain/util"
poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

// this line is used by starport scaffolding # 1
Expand Down Expand Up @@ -191,7 +190,7 @@ type ModuleInputs struct {
Logger log.Logger

AccountKeeper util.AccountKeeper
BankKeeper bankKeeper.Keeper
BankKeeper util.BankKeeper
UpgradeKeeper util.UpgradeKeeper
PoolKeeper *poolKeeper.Keeper
}
Expand Down
12 changes: 6 additions & 6 deletions x/stakers/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type (

authority string

accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
distrkeeper types.DistrKeeper
accountKeeper util.AccountKeeper
bankKeeper util.BankKeeper
distrkeeper util.DistributionKeeper
poolKeeper types.PoolKeeper
upgradeKeeper util.UpgradeKeeper
delegationKeeper delegationKeeper.Keeper
Expand All @@ -37,9 +37,9 @@ func NewKeeper(

authority string,

accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
distrkeeper types.DistrKeeper,
accountKeeper util.AccountKeeper,
bankKeeper util.BankKeeper,
distrkeeper util.DistributionKeeper,
poolKeeper types.PoolKeeper,
upgradeKeeper util.UpgradeKeeper,
) *Keeper {
Expand Down
13 changes: 6 additions & 7 deletions x/stakers/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
delegationKeeper "github.com/KYVENetwork/chain/x/delegation/keeper"
poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
distributionKeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
// this line is used by starport scaffolding # 1
Expand Down Expand Up @@ -109,15 +108,15 @@ type AppModule struct {
AppModuleBasic

keeper *keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
accountKeeper util.AccountKeeper
bankKeeper util.BankKeeper
}

func NewAppModule(
cdc codec.Codec,
keeper *keeper.Keeper,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
accountKeeper util.AccountKeeper,
bankKeeper util.BankKeeper,
) AppModule {
return AppModule{
AppModuleBasic: NewAppModuleBasic(cdc),
Expand Down Expand Up @@ -197,8 +196,8 @@ type ModuleInputs struct {
MemService store.MemoryStoreService
Logger log.Logger

AccountKeeper types.AccountKeeper
BankKeeper bankKeeper.Keeper
AccountKeeper util.AccountKeeper
BankKeeper util.BankKeeper
DistributionKeeper distributionKeeper.Keeper
UpgradeKeeper util.UpgradeKeeper
PoolKeeper *poolKeeper.Keeper
Expand Down
18 changes: 0 additions & 18 deletions x/stakers/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
package types

import (
"context"
poolTypes "github.com/KYVENetwork/chain/x/pool/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// AccountKeeper defines the expected account keeper used for simulations (noalias)
type AccountKeeper interface {
GetModuleAddress(moduleName string) sdk.AccAddress
}

type DistrKeeper interface {
FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error
}

// BankKeeper defines the expected interface needed to retrieve account balances.
type BankKeeper interface {
SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

type PoolKeeper interface {
AssertPoolExists(ctx sdk.Context, poolId uint64) error
GetPoolWithError(ctx sdk.Context, poolId uint64) (poolTypes.Pool, error)
Expand Down
4 changes: 1 addition & 3 deletions x/team/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package team
import (
"cosmossdk.io/math"
"fmt"
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/KYVENetwork/chain/util"
sdk "github.com/cosmos/cosmos-sdk/types"

// Auth
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"

// Team
"github.com/KYVENetwork/chain/x/team/keeper"
"github.com/KYVENetwork/chain/x/team/types"
Expand Down

0 comments on commit 3364248

Please sign in to comment.