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

feat: introduce enable public delegation upgrade #87

Merged
merged 5 commits into from
Jan 18, 2023
Merged
Changes from 1 commit
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
Next Next commit
introduce enable public delegation upgrade
Keefe Liu authored and yutianwu committed Jan 18, 2023
commit 6b78f1fead77c4ce844b5ddd564390d878f1b4e7
2 changes: 1 addition & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ func SetAppConfig(config serverconfig.Config) func(*BaseApp) {
return func(app *BaseApp) { app.setAppConfig(config) }
}

// SetAppConfig sets the chain id.
// SetChainID sets the chain id.
func SetChainID(chainID string) func(*BaseApp) {
return func(app *BaseApp) { app.setChainID(chainID) }
}
2 changes: 1 addition & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ type IntegrationTestSuite struct {

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
s.app = simapp.Setup(s.T(), false)
s.app = simapp.Setup(s.T(), false, true)
cfg := network.DefaultConfig()
cfg.NumValidators = 1
s.cfg = cfg
20 changes: 20 additions & 0 deletions simapp/app.go
Original file line number Diff line number Diff line change
@@ -356,6 +356,11 @@ func NewSimApp(
// app.Logger().Info("upgrade to ", plan.Name)
// return fromVM, nil
// },

upgradetypes.EnablePublicDelegationUpgrade: func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("upgrade to ", plan.Name)
return fromVM, nil
},
}

upgradeInitlizier := map[string]upgradetypes.UpgradeInitializer{
@@ -365,6 +370,11 @@ func NewSimApp(
// app.Logger().Info("Init BEP111")
// return nil
// },

upgradetypes.EnablePublicDelegationUpgrade: func() error {
app.Logger().Info("Init enable public delegation upgrade")
return nil
},
}

var err error
@@ -719,3 +729,13 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

return paramsKeeper
}

func InitUpgradeConfig() []config.UpgradeConfig {
return []config.UpgradeConfig{
{
Name: upgradetypes.EnablePublicDelegationUpgrade,
Height: 2,
Info: "Enable public delegation, after this fork, anyone can delegate and redelegate to any validator.",
},
}
}
20 changes: 13 additions & 7 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/simapp/params"
@@ -68,10 +69,15 @@ type SetupOptions struct {
AppOpts types.AppOptions
}

func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
func setup(withGenesis bool, invCheckPeriod uint, enableDefaultUpgrade bool) (*SimApp, GenesisState) {
appCfg := srvconfig.DefaultConfig()
if enableDefaultUpgrade {
appCfg.Upgrade = InitUpgradeConfig()
}

db := dbm.NewMemDB()
encCdc := MakeTestEncodingConfig()
app := NewSimApp(log.NewNopLogger(), db, nil, true, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{})
app := NewSimApp(log.NewNopLogger(), db, nil, true, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{}, bam.SetAppConfig(*appCfg))
if withGenesis {
return app, NewDefaultGenesisState(encCdc.Codec)
}
@@ -120,7 +126,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio
}

// Setup initializes a new SimApp. A Nop logger is set in SimApp.
func Setup(t *testing.T, isCheckTx bool) *SimApp {
func Setup(t *testing.T, isCheckTx bool, enableDefaultUpgrade bool) *SimApp {
t.Helper()

privVal := mock.NewPV()
@@ -139,7 +145,7 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp {
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}

app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance)
app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, enableDefaultUpgrade, balance)

return app
}
@@ -213,10 +219,10 @@ func genesisStateWithValSet(t *testing.T,
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, enableDefaultUpgrade bool, balances ...banktypes.Balance) *SimApp {
t.Helper()

app, genesisState := setup(true, 5)
app, genesisState := setup(true, 5, enableDefaultUpgrade)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
@@ -258,7 +264,7 @@ func SetupWithGenesisAccounts(t *testing.T, genAccs []authtypes.GenesisAccount,
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})

return SetupWithGenesisValSet(t, valSet, genAccs, balances...)
return SetupWithGenesisValSet(t, valSet, genAccs, true, balances...)
}

// GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts
2 changes: 2 additions & 0 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ func NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor {
simapp.EmptyAppOptions{},
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices),
baseapp.SetAppConfig(*val.AppConfig),
)
}
}
@@ -234,6 +235,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
// generate private keys, node IDs, and initial transactions
for i := 0; i < cfg.NumValidators; i++ {
appCfg := srvconfig.DefaultConfig()
appCfg.Upgrade = simapp.InitUpgradeConfig()
appCfg.Pruning = cfg.PruningStrategy
appCfg.MinGasPrices = cfg.MinGasPrices
appCfg.API.Enable = true
2 changes: 1 addition & 1 deletion types/query/pagination_test.go
Original file line number Diff line number Diff line change
@@ -337,7 +337,7 @@ func ExamplePaginate(t *testing.T) {
}

func setupTest(t *testing.T) (*simapp.SimApp, sdk.Context, codec.Codec) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1})
appCodec := app.AppCodec()

2 changes: 1 addition & 1 deletion x/auth/ante/testutil_test.go
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ type AnteTestSuite struct {

// returns context and app with params set on account keeper
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
app := simapp.Setup(t, isCheckTx, true)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())

2 changes: 1 addition & 1 deletion x/auth/keeper/integration_test.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import (

// returns context and app with params set on account keeper
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
app := simapp.Setup(t, isCheckTx, true)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())

2 changes: 1 addition & 1 deletion x/auth/migrations/v046/store_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (

// TestMigrateMapAccAddressToAccNumberKey test cases for state migration of map to accAddr to accNum
func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

// new base account
senderPrivKey := secp256k1.GenPrivKey()
2 changes: 1 addition & 1 deletion x/auth/signing/verify_test.go
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ func TestVerifySignature(t *testing.T) {

// returns context and app with params set on account keeper
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
app := simapp.Setup(t, isCheckTx, true)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, types.DefaultParams())

2 changes: 1 addition & 1 deletion x/auth/simulation/decoder_test.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ var (
)

func TestDecodeStore(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
cdc := simapp.MakeTestEncodingConfig().Codec
acc := types.NewBaseAccountWithAddress(delAddr1)
dec := simulation.NewDecodeStore(app.AccountKeeper)
2 changes: 1 addition & 1 deletion x/auth/types/account_test.go
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ func TestBaseSequence(t *testing.T) {
}

func TestBaseAccountMarshal(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
_, pub, addr := testdata.KeyEthSecp256k1TestPubAddr()
acc := types.NewBaseAccountWithAddress(addr)
seq := uint64(7)
2 changes: 1 addition & 1 deletion x/auth/vesting/types/vesting_account_test.go
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ type VestingAccountTestSuite struct {

func (s *VestingAccountTestSuite) SetupTest() {
checkTx := false
s.app = simapp.Setup(s.T(), checkTx)
s.app = simapp.Setup(s.T(), checkTx, true)

s.ctx = s.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1})
}
2 changes: 1 addition & 1 deletion x/authz/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ type GenesisTestSuite struct {

func (suite *GenesisTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)

suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1})
suite.keeper = app.AuthzKeeper
2 changes: 1 addition & 1 deletion x/authz/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ type TestSuite struct {
}

func (s *TestSuite) SetupTest() {
app := simapp.Setup(s.T(), false)
app := simapp.Setup(s.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
now := tmtime.Now()
ctx = ctx.WithBlockHeader(tmproto.Header{Time: now})
2 changes: 1 addition & 1 deletion x/authz/module/abci_test.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
)

func TestExpiredGrantsQueue(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, types.Header{})
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000))
granter := addrs[0]
2 changes: 1 addition & 1 deletion x/authz/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestRandomizedGenState(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

s := rand.NewSource(1)
r := rand.New(s)
2 changes: 1 addition & 1 deletion x/authz/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
}
2 changes: 1 addition & 1 deletion x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str
}

func (suite *IntegrationTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})

app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
2 changes: 1 addition & 1 deletion x/bank/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
}
2 changes: 1 addition & 1 deletion x/bank/types/send_authorization_test.go
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ var (
)

func TestSendAuthorization(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
authorization := types.NewSendAuthorization(coins1000)

2 changes: 1 addition & 1 deletion x/capability/capability_test.go
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ type CapabilityTestSuite struct {

func (suite *CapabilityTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
cdc := app.AppCodec()

// create new keeper so we can define custom scoping before init and seal
2 changes: 1 addition & 1 deletion x/capability/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ type KeeperTestSuite struct {

func (suite *KeeperTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
cdc := app.AppCodec()

// create new keeper so we can define custom scoping before init and seal
6 changes: 3 additions & 3 deletions x/crisis/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
)

func TestLogger(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

ctx := app.NewContext(true, tmproto.Header{})

@@ -23,7 +23,7 @@ func TestLogger(t *testing.T) {
}

func TestInvariants(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
app.Commit()
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}})

@@ -36,7 +36,7 @@ func TestInvariants(t *testing.T) {
}

func TestAssertInvariants(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
app.Commit()
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}})

2 changes: 1 addition & 1 deletion x/distribution/abci_test.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ type validator struct {

// Context in https://github.com/cosmos/cosmos-sdk/issues/9161
func TestVerifyProposerRewardAssignement(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrsIncremental(app, ctx, totalValidators, valTokens)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
6 changes: 3 additions & 3 deletions x/distribution/keeper/allocation_test.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import (
)

func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234))
@@ -46,7 +46,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
}

func TestAllocateTokensToManyValidators(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// reset fee pool
@@ -120,7 +120,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
}

func TestAllocateTokensTruncation(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// reset fee pool
37 changes: 25 additions & 12 deletions x/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/simapp"
@@ -12,10 +13,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
)

func TestCalculateRewardsBasic(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
@@ -72,7 +74,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
}

func TestCalculateRewardsAfterSlash(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000))
@@ -135,7 +137,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
}

func TestCalculateRewardsAfterManySlashes(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
@@ -210,7 +212,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
}

func TestCalculateRewardsMultiDelegator(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
@@ -225,7 +227,10 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
staking.EndBlocker(ctx, app.StakingKeeper)

// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 2)

// upgrade public delegation
upgrade.BeginBlocker(app.UpgradeKeeper, ctx, abci.RequestBeginBlock{})

// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
@@ -273,7 +278,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
}

func TestWithdrawDelegationRewardsBasic(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
@@ -346,7 +351,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
}

func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000))
@@ -414,7 +419,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
}

func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
@@ -430,7 +435,11 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
staking.EndBlocker(ctx, app.StakingKeeper)

// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 2)

// upgrade public delegation
upgrade.BeginBlocker(app.UpgradeKeeper, ctx, abci.RequestBeginBlock{})
tstaking.Ctx = ctx

// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
@@ -488,7 +497,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
}

func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)
@@ -513,7 +522,11 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
staking.EndBlocker(ctx, app.StakingKeeper)

// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 2)

// upgrade public delegation
upgrade.BeginBlocker(app.UpgradeKeeper, ctx, abci.RequestBeginBlock{})
tstaking.Ctx = ctx

// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
@@ -635,7 +648,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
}

func Test100PercentCommissionReward(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
2 changes: 1 addition & 1 deletion x/distribution/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ type KeeperTestSuite struct {
}

func (suite *KeeperTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
8 changes: 4 additions & 4 deletions x/distribution/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestSetWithdrawAddr(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000))
@@ -36,7 +36,7 @@ func TestSetWithdrawAddr(t *testing.T) {
}

func TestWithdrawValidatorCommission(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valCommission := sdk.DecCoins{
@@ -88,7 +88,7 @@ func TestWithdrawValidatorCommission(t *testing.T) {
}

func TestGetTotalRewards(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valCommission := sdk.DecCoins{
@@ -109,7 +109,7 @@ func TestGetTotalRewards(t *testing.T) {
}

func TestFundCommunityPool(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// reset fee pool
2 changes: 1 addition & 1 deletion x/distribution/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
genesisVals := app.StakingKeeper.GetAllValidators(suite.ctx)
2 changes: 1 addition & 1 deletion x/distribution/simulation/proposals_test.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
)

func TestProposalContents(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// initialize parameters
2 changes: 1 addition & 1 deletion x/evidence/genesis_test.go
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ type GenesisTestSuite struct {

func (suite *GenesisTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)

suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1})
suite.keeper = app.EvidenceKeeper
2 changes: 1 addition & 1 deletion x/evidence/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ type KeeperTestSuite struct {

func (suite *KeeperTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)

// recreate keeper in order to use custom testing types
evidenceKeeper := keeper.NewKeeper(
2 changes: 1 addition & 1 deletion x/evidence/simulation/decoder_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestDecodeStore(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
dec := simulation.NewDecodeStore(app.EvidenceKeeper)

delPk1 := ed25519.GenPrivKey().PubKey()
2 changes: 1 addition & 1 deletion x/feegrant/basic_fee_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestBasicFeeValidAllow(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

ctx := app.BaseApp.NewContext(false, tmproto.Header{})
badTime := ctx.BlockTime().AddDate(0, 0, -1)
2 changes: 1 addition & 1 deletion x/feegrant/filtered_fee_test.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
)

func TestFilteredFeeValidAllow(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

ctx := app.BaseApp.NewContext(false, ocproto.Header{
Time: time.Now(),
2 changes: 1 addition & 1 deletion x/feegrant/grant_test.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
)

func TestGrant(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
addr, err := sdk.AccAddressFromHexUnsafe("0x058b15d64f210480217ab50093b7373a41a86c33")
require.NoError(t, err)
addr2, err := sdk.AccAddressFromHexUnsafe("0x09417afda96ea6f066fc943bfadbc87e63eb67e5")
2 changes: 1 addition & 1 deletion x/feegrant/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ type GenesisTestSuite struct {

func (suite *GenesisTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1})
suite.keeper = app.FeeGrantKeeper
}
2 changes: 1 addition & 1 deletion x/feegrant/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

suite.app = app
2 changes: 1 addition & 1 deletion x/feegrant/module/abci_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestFeegrantPruning(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 4, sdk.NewInt(1000))
2 changes: 1 addition & 1 deletion x/feegrant/periodic_fee_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestPeriodicFeeValidAllow(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{
Time: time.Now(),
})
2 changes: 1 addition & 1 deletion x/feegrant/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestRandomizedGenState(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

s := rand.NewSource(1)
r := rand.New(s)
2 changes: 1 addition & 1 deletion x/feegrant/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{
Time: time.Now(),
2 changes: 1 addition & 1 deletion x/gashub/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ type IntegrationTestSuite struct {
}

func (suite *IntegrationTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})

app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
2 changes: 1 addition & 1 deletion x/genutil/gentx_test.go
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ type GenTxTestSuite struct {

func (suite *GenTxTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{ChainID: simapp.DefaultChainId})
suite.app = app
suite.encodingConfig = simapp.MakeTestEncodingConfig()
12 changes: 6 additions & 6 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ import (
)

func TestTickExpiredDepositPeriod(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens)

@@ -75,7 +75,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
}

func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens)

@@ -154,7 +154,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
}

func TestTickPassedDepositPeriod(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens)

@@ -208,7 +208,7 @@ func TestTickPassedDepositPeriod(t *testing.T) {
}

func TestTickPassedVotingPeriod(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens)

@@ -274,7 +274,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
}

func TestProposalPassedEndblocker(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens)

@@ -327,7 +327,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
}

func TestEndBlockerProposalHandlerFailed(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 1, valTokens)

4 changes: 2 additions & 2 deletions x/gov/genesis_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ import (
)

func TestImportExportQueues(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens)

@@ -117,7 +117,7 @@ func TestImportExportQueues(t *testing.T) {
}

func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
require.Panics(t, func() {
gov.InitGenesis(ctx, app.AccountKeeper, app.BankKeeper, app.GovKeeper, &v1.GenesisState{
2 changes: 1 addition & 1 deletion x/gov/keeper/deposit_test.go
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import (
)

func TestDeposits(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000))
2 changes: 1 addition & 1 deletion x/gov/keeper/hooks_test.go
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ func (h *MockGovHooksReceiver) AfterProposalVotingPeriodEnded(ctx sdk.Context, p
}

func TestHooks(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

minDeposit := app.GovKeeper.GetDepositParams(ctx).MinDeposit
6 changes: 3 additions & 3 deletions x/gov/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ type KeeperTestSuite struct {
}

func (suite *KeeperTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// Populate the gov account with some coins, as the TestProposal we have
@@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) SetupTest() {
}

func TestIncrementProposalNumber(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tp := TestProposal
@@ -81,7 +81,7 @@ func TestIncrementProposalNumber(t *testing.T) {
}

func TestProposalQueues(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// create test proposals
4 changes: 2 additions & 2 deletions x/gov/keeper/querier_test.go
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, quer
}

func TestQueries(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
legacyQuerierCdc := app.LegacyAmino()
querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc)
@@ -305,7 +305,7 @@ func TestQueries(t *testing.T) {
}

func TestPaginatedVotesQuery(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
legacyQuerierCdc := app.LegacyAmino()

30 changes: 15 additions & 15 deletions x/gov/keeper/tally_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestTallyNoOneVotes(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

createValidators(t, ctx, app, []int64{5, 5, 5})
@@ -36,7 +36,7 @@ func TestTallyNoOneVotes(t *testing.T) {
}

func TestTallyNoQuorum(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

createValidators(t, ctx, app, []int64{2, 5, 0})
@@ -61,7 +61,7 @@ func TestTallyNoQuorum(t *testing.T) {
}

func TestTallyOnlyValidatorsAllYes(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, _ := createValidators(t, ctx, app, []int64{5, 5, 5})
@@ -87,7 +87,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
}

func TestTallyOnlyValidators51No(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0})
@@ -111,7 +111,7 @@ func TestTallyOnlyValidators51No(t *testing.T) {
}

func TestTallyOnlyValidators51Yes(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0})
@@ -136,7 +136,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
}

func TestTallyOnlyValidatorsVetoed(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})
@@ -162,7 +162,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
}

func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})
@@ -188,7 +188,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
}

func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})
@@ -214,7 +214,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
}

func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 7})
@@ -240,7 +240,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
}

func TestTallyDelgatorOverride(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, valAddrs := createValidators(t, ctx, app, []int64{5, 6, 7})
@@ -276,7 +276,7 @@ func TestTallyDelgatorOverride(t *testing.T) {
}

func TestTallyDelgatorInherit(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, vals := createValidators(t, ctx, app, []int64{5, 6, 7})
@@ -311,7 +311,7 @@ func TestTallyDelgatorInherit(t *testing.T) {
}

func TestTallyDelgatorMultipleOverride(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, vals := createValidators(t, ctx, app, []int64{5, 6, 7})
@@ -351,7 +351,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
}

func TestTallyDelgatorMultipleInherit(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

createValidators(t, ctx, app, []int64{25, 6, 7})
@@ -392,7 +392,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
}

func TestTallyJailedValidator(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, valAddrs := createValidators(t, ctx, app, []int64{25, 6, 7})
@@ -435,7 +435,7 @@ func TestTallyJailedValidator(t *testing.T) {
}

func TestTallyValidatorMultipleDelegations(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs, valAddrs := createValidators(t, ctx, app, []int64{10, 10, 10})
2 changes: 1 addition & 1 deletion x/gov/keeper/vote_test.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import (
)

func TestVotes(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000))
2 changes: 1 addition & 1 deletion x/gov/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) {

// returns context and an app with updated mint keeper
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
app := simapp.Setup(t, isCheckTx, true)

ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.MintKeeper.SetParams(ctx, minttypes.DefaultParams())
2 changes: 1 addition & 1 deletion x/group/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
)

func TestQueryGroupsByMember(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
group.RegisterQueryServer(queryHelper, app.GroupKeeper)
2 changes: 1 addition & 1 deletion x/group/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ type TestSuite struct {
}

func (s *TestSuite) SetupTest() {
app := simapp.Setup(s.T(), false)
app := simapp.Setup(s.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

s.blockTime = tmtime.Now()
4 changes: 2 additions & 2 deletions x/group/module/abci_test.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import (
)

func TestEndBlockerPruning(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(30000000))
addr1 := addrs[0]
@@ -318,7 +318,7 @@ func TestEndBlockerPruning(t *testing.T) {
}

func TestEndBlockerTallying(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000))
2 changes: 1 addition & 1 deletion x/group/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestRandomizedGenState(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

s := rand.NewSource(1)
r := rand.New(s)
2 changes: 1 addition & 1 deletion x/group/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
}
2 changes: 1 addition & 1 deletion x/mint/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ type MintTestSuite struct {
}

func (suite *MintTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
2 changes: 1 addition & 1 deletion x/mint/keeper/querier_test.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ type MintKeeperTestSuite struct {
}

func (suite *MintKeeperTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), true)
app := simapp.Setup(suite.T(), true, true)
ctx := app.BaseApp.NewContext(true, tmproto.Header{})

app.MintKeeper.SetParams(ctx, types.DefaultParams())
2 changes: 1 addition & 1 deletion x/nft/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ type TestSuite struct {
}

func (s *TestSuite) SetupTest() {
app := simapp.Setup(s.T(), false)
app := simapp.Setup(s.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
ctx = ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()})
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
2 changes: 1 addition & 1 deletion x/nft/simulation/genesis_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestRandomizedGenState(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)

s := rand.NewSource(1)
r := rand.New(s)
2 changes: 1 addition & 1 deletion x/nft/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ type SimTestSuite struct {

func (suite *SimTestSuite) SetupTest() {
checkTx := false
app := simapp.Setup(suite.T(), checkTx)
app := simapp.Setup(suite.T(), checkTx, true)
suite.app = app
suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{})
}
2 changes: 1 addition & 1 deletion x/params/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type KeeperTestSuite struct {
}

func (suite *KeeperTestSuite) SetupTest() {
suite.app = simapp.Setup(suite.T(), false)
suite.app = simapp.Setup(suite.T(), false, true)
suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{})

queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
2 changes: 1 addition & 1 deletion x/params/proposal_handler_test.go
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ type HandlerTestSuite struct {
}

func (suite *HandlerTestSuite) SetupTest() {
suite.app = simapp.Setup(suite.T(), false)
suite.app = simapp.Setup(suite.T(), false, true)
suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{})
suite.govHandler = params.NewParamChangeProposalHandler(suite.app.ParamsKeeper)
}
2 changes: 1 addition & 1 deletion x/slashing/abci_test.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import (
)

func TestBeginBlocker(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

pks := simapp.CreateTestPubKeys(1)
2 changes: 1 addition & 1 deletion x/slashing/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

func TestExportAndInitGenesis(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())
2 changes: 1 addition & 1 deletion x/slashing/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ type SlashingTestSuite struct {
}

func (suite *SlashingTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
13 changes: 9 additions & 4 deletions x/slashing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/simapp"
@@ -13,10 +14,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
)

func TestUnJailNotBonded(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

p := app.StakingKeeper.GetParams(ctx)
@@ -82,7 +84,7 @@ func TestUnJailNotBonded(t *testing.T) {
// Ensure that SigningInfo.StartHeight is set correctly
// and that they are not immediately jailed
func TestHandleNewValidator(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))
@@ -128,7 +130,7 @@ func TestHandleNewValidator(t *testing.T) {
// Ensure that they're only slashed once
func TestHandleAlreadyJailed(t *testing.T) {
// initial setup
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))
@@ -181,7 +183,7 @@ func TestHandleAlreadyJailed(t *testing.T) {
func TestValidatorDippingInAndOut(t *testing.T) {
// initial setup
// TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())

@@ -207,6 +209,8 @@ func TestValidatorDippingInAndOut(t *testing.T) {
height := int64(0)
for ; height < int64(100); height++ {
ctx = ctx.WithBlockHeight(height)
// upgrade public delegation
upgrade.BeginBlocker(app.UpgradeKeeper, ctx, abci.RequestBeginBlock{})
app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, true)
}

@@ -222,6 +226,7 @@ func TestValidatorDippingInAndOut(t *testing.T) {
ctx = ctx.WithBlockHeight(height)

// validator added back in
tstaking.Ctx = ctx
tstaking.DelegateWithPower(sdk.AccAddress(pks[2].Address()), valAddr, 50)

validatorUpdates = staking.EndBlocker(ctx, app.StakingKeeper)
4 changes: 2 additions & 2 deletions x/slashing/keeper/querier_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
)

func TestNewQuerier(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())
legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino())
@@ -34,7 +34,7 @@ func TestNewQuerier(t *testing.T) {
func TestQueryParams(t *testing.T) {
cdc := codec.NewLegacyAmino()
legacyQuerierCdc := codec.NewAminoCodec(cdc)
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())

8 changes: 4 additions & 4 deletions x/slashing/keeper/signing_info_test.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
)

func TestGetSetValidatorSigningInfo(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))

@@ -37,7 +37,7 @@ func TestGetSetValidatorSigningInfo(t *testing.T) {
}

func TestGetSetValidatorMissedBlockBitArray(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))

@@ -49,7 +49,7 @@ func TestGetSetValidatorMissedBlockBitArray(t *testing.T) {
}

func TestTombstoned(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))

@@ -73,7 +73,7 @@ func TestTombstoned(t *testing.T) {
}

func TestJailUntil(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200))

2 changes: 1 addition & 1 deletion x/slashing/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}

app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance)
app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, true, balance)

ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
initAmt := app.StakingKeeper.TokensFromConsensusPower(ctx, 200)
2 changes: 1 addition & 1 deletion x/staking/common_test.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ var (
// getBaseSimappWithCustomKeeper Returns a simapp with custom StakingKeeper
// to avoid messing with the hooks.
func getBaseSimappWithCustomKeeper(t *testing.T) (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

appCodec := app.AppCodec()
2 changes: 1 addition & 1 deletion x/staking/keeper/common_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ func init() {
// createTestInput Returns a simapp with custom StakingKeeper
// to avoid messing with the hooks.
func createTestInput(t *testing.T) (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.StakingKeeper = keeper.NewKeeper(
4 changes: 2 additions & 2 deletions x/staking/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import (
)

func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrDels, _ := generateAddresses(app, ctx, numAddrs)
@@ -113,7 +113,7 @@ func TestInitGenesis(t *testing.T) {
}

func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.NewContext(false, tmproto.Header{})

consPub, err := codectypes.NewAnyWithValue(PKs[0])
4 changes: 2 additions & 2 deletions x/staking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ type KeeperTestSuite struct {
}

func (suite *KeeperTestSuite) SetupTest() {
app := simapp.Setup(suite.T(), false)
app := simapp.Setup(suite.T(), false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

querier := keeper.Querier{Keeper: app.StakingKeeper}
@@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) SetupTest() {
}

func TestParams(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

expParams := types.DefaultParams()
14 changes: 11 additions & 3 deletions x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

type msgServer struct {
@@ -317,7 +318,12 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
return nil, err
}

// TODO: And a hard fork to allow all delegations, before that fork, only self delegation allowed.
if !ctx.IsUpgraded(upgrade.EnablePublicDelegationUpgrade) {
selfDelAddress := validator.GetSelfDelegator()
if delegatorAddress.String() != selfDelAddress.String() {
return nil, types.ErrDelegationNotAllowed
}
}

bondDenom := k.BondDenom(ctx)
if msg.Amount.Denom != bondDenom {
@@ -363,6 +369,10 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
// BeginRedelegate defines a method for performing a redelegation of coins from a delegator and source validator to a destination validator
func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
if !ctx.IsUpgraded(upgrade.EnablePublicDelegationUpgrade) {
return nil, types.ErrRedelegationNotAllowed
}

valSrcAddr, err := sdk.AccAddressFromHexUnsafe(msg.ValidatorSrcAddress)
if err != nil {
return nil, err
@@ -378,8 +388,6 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed
return nil, err
}

// TODO: And a hard fork to allow all redelegations

bondDenom := k.BondDenom(ctx)
if msg.Amount.Denom != bondDenom {
return nil, sdkerrors.Wrapf(
2 changes: 1 addition & 1 deletion x/staking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (

func TestCancelUnbondingDelegation(t *testing.T) {
// setup the app
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
msgServer := keeper.NewMsgServerImpl(app.StakingKeeper)
bondDenom := app.StakingKeeper.BondDenom(ctx)
2 changes: 1 addition & 1 deletion x/staking/simulation/operations_test.go
Original file line number Diff line number Diff line change
@@ -313,7 +313,7 @@ func createTestApp(t *testing.T, isCheckTx bool, r *rand.Rand, n int) (*simapp.S
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}

app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance)
app := simapp.SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, true, balance)

ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{ChainID: simapp.DefaultChainId})
app.MintKeeper.SetParams(ctx, minttypes.DefaultParams())
2 changes: 1 addition & 1 deletion x/staking/types/authz_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ var (
)

func TestAuthzAuthorizations(t *testing.T) {
app := simapp.Setup(t, false)
app := simapp.Setup(t, false, true)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

// verify ValidateBasic returns error for the AUTHORIZATION_TYPE_UNSPECIFIED authorization type
2 changes: 1 addition & 1 deletion x/upgrade/client/testutil/suite.go
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ type IntegrationTestSuite struct {

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
app := simapp.Setup(s.T(), false)
app := simapp.Setup(s.T(), false, true)
s.app = app
s.ctx = app.BaseApp.NewContext(false, tmproto.Header{})

2 changes: 1 addition & 1 deletion x/upgrade/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ type UpgradeTestSuite struct {
}

func (suite *UpgradeTestSuite) SetupTest() {
suite.app = simapp.Setup(suite.T(), false)
suite.app = simapp.Setup(suite.T(), false, false)
suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{})

queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
2 changes: 1 addition & 1 deletion x/upgrade/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ type KeeperTestSuite struct {

func (s *KeeperTestSuite) SetupTest() {
var err error
app := simapp.Setup(s.T(), false)
app := simapp.Setup(s.T(), false, true)
homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test")
app.UpgradeKeeper, err = keeper.NewKeeper( // recreate keeper in order to use a custom home Path
app.GetKey(types.StoreKey), app.AppCodec(), homeDir,
4 changes: 4 additions & 0 deletions x/upgrade/types/upgrade_config.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ import (
// BEP111 = "BEP111"
// )

const (
EnablePublicDelegationUpgrade = "EnablePublicDelegationUpgrade"
)

var (
MainnetChainID = "inscription_9000-1"
MainnetConfig = NewUpgradeConfig()