diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b0a16134260..1b2047d56ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/consensus) [#15553](https://github.com/cosmos/cosmos-sdk/pull/15553) Migrate consensus module to use collections * (x/bank) [#15764](https://github.com/cosmos/cosmos-sdk/pull/15764) Speedup x/bank InitGenesis * (x/auth) [#15867](https://github.com/cosmos/cosmos-sdk/pull/15867) Support better logging for signature verification failure. +* (types/query) [#16041](https://github.com/cosmos/cosmos-sdk/pull/16041) change pagination max limit to a variable in order to be modifed by application devs ### State Machine Breaking diff --git a/types/query/pagination.go b/types/query/pagination.go index 3eeb3a297aec..61e3c0679e50 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -19,9 +19,9 @@ const DefaultPage = 1 // if the `limit` is not supplied, paginate will use `DefaultLimit` const DefaultLimit = 100 -// MaxLimit is the maximum limit the paginate function can handle +// PaginationMaxLimit is the maximum limit the paginate function can handle // which equals the maximum value that can be stored in uint64 -const MaxLimit = math.MaxUint64 +var PaginationMaxLimit uint64 = math.MaxUint64 // ParsePagination validate PageRequest and returns page number & limit. func ParsePagination(pageReq *PageRequest) (page, limit int, err error) { diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go index eaee07c4843d..a74208b05b7d 100644 --- a/x/bank/keeper/genesis.go +++ b/x/bank/keeper/genesis.go @@ -53,7 +53,7 @@ func (k BaseKeeper) InitGenesis(ctx context.Context, genState *types.GenesisStat // ExportGenesis returns the bank module's genesis state. func (k BaseKeeper) ExportGenesis(ctx context.Context) *types.GenesisState { - totalSupply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) + totalSupply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.PaginationMaxLimit}) if err != nil { panic(fmt.Errorf("unable to fetch total supply %v", err)) } diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index ac04a6232c7a..251f0180ba99 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -16,7 +16,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { expectedBalances, expTotalSupply := suite.getTestBalancesAndSupply() // Adding genesis supply to the expTotalSupply - genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.PaginationMaxLimit}) suite.Require().NoError(err) expTotalSupply = expTotalSupply.Add(genesisSupply...) @@ -85,7 +85,7 @@ func (suite *KeeperTestSuite) TestTotalSupply() { } totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdkmath.NewInt(11)), sdk.NewCoin("barcoin", sdkmath.NewInt(21))) - genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.PaginationMaxLimit}) suite.Require().NoError(err) testcases := []struct { @@ -119,7 +119,7 @@ func (suite *KeeperTestSuite) TestTotalSupply() { suite.PanicsWithError(tc.expPanicMsg, func() { suite.bankKeeper.InitGenesis(suite.ctx, tc.genesis) }) } else { suite.bankKeeper.InitGenesis(suite.ctx, tc.genesis) - totalSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + totalSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.PaginationMaxLimit}) suite.Require().NoError(err) // adding genesis supply to expected supply diff --git a/x/bank/keeper/invariants.go b/x/bank/keeper/invariants.go index 5db22af69f81..72240a1ac387 100644 --- a/x/bank/keeper/invariants.go +++ b/x/bank/keeper/invariants.go @@ -51,7 +51,7 @@ func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant { func TotalSupply(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { expectedTotal := sdk.Coins{} - supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) + supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.PaginationMaxLimit}) if err != nil { return sdk.FormatInvariant(types.ModuleName, "query supply", fmt.Sprintf("error querying total supply %v", err)), false