Skip to content

Commit e7d3c85

Browse files
authored
Merge branch 'main' into fix/issue-25543
2 parents 2840052 + cab47d3 commit e7d3c85

File tree

9 files changed

+134
-54
lines changed

9 files changed

+134
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4040

4141
### Breaking Changes
4242

43+
* (x/staking) [#25724](https://github.com/cosmos/cosmos-sdk/issues/25724) Validate `BondDenom` in `MsgUpdateParams` to prevent setting non-existent or zero-supply denoms.
4344
* [#25778](https://github.com/cosmos/cosmos-sdk/pull/25778) Update `log` to log v2.
4445
* [#25090](https://github.com/cosmos/cosmos-sdk/pull/25090) Moved deprecated modules to `./contrib`. These modules are still available but will no longer be actively maintained or supported in the Cosmos SDK Bug Bounty program.
4546
* `x/group`

collections/README.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ package collections
4343

4444
import (
4545
"cosmossdk.io/collections"
46-
storetypes "cosmossdk.io/store/types"
47-
sdk "github.com/cosmos/cosmos-sdk/types"
46+
"cosmossdk.io/core/store"
4847
)
4948

5049
var AllowListPrefix = collections.NewPrefix(0)
@@ -54,8 +53,8 @@ type Keeper struct {
5453
AllowList collections.KeySet[string]
5554
}
5655

57-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
58-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
56+
func NewKeeper(storeService store.KVStoreService) Keeper {
57+
sb := collections.NewSchemaBuilder(storeService)
5958

6059
return Keeper{
6160
AllowList: collections.NewKeySet(sb, AllowListPrefix, "allow_list", collections.StringKey),
@@ -168,8 +167,7 @@ package collections
168167

169168
import (
170169
"cosmossdk.io/collections"
171-
storetypes "cosmossdk.io/store/types"
172-
sdk "github.com/cosmos/cosmos-sdk/types"
170+
"cosmossdk.io/core/store"
173171
)
174172

175173
var IDsPrefix = collections.NewPrefix(0)
@@ -179,8 +177,8 @@ type Keeper struct {
179177
IDs collections.Map[string, uint64]
180178
}
181179

182-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
183-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
180+
func NewKeeper(storeService store.KVStoreService) Keeper {
181+
sb := collections.NewSchemaBuilder(storeService)
184182

185183
return Keeper{
186184
IDs: collections.NewMap(sb, IDsPrefix, "ids", collections.StringKey, collections.Uint64Value),
@@ -205,7 +203,7 @@ package collections
205203

206204
import (
207205
"cosmossdk.io/collections"
208-
storetypes "cosmossdk.io/store/types"
206+
"cosmossdk.io/core/store"
209207
"github.com/cosmos/cosmos-sdk/codec"
210208
sdk "github.com/cosmos/cosmos-sdk/types"
211209
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -218,8 +216,8 @@ type Keeper struct {
218216
Accounts collections.Map[sdk.AccAddress, authtypes.BaseAccount]
219217
}
220218

221-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
222-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
219+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
220+
sb := collections.NewSchemaBuilder(storeService)
223221
return Keeper{
224222
Accounts: collections.NewMap(sb, AccountsPrefix, "accounts",
225223
sdk.AccAddressKey, codec.CollValue[authtypes.BaseAccount](cdc)),
@@ -253,7 +251,7 @@ package collections
253251

254252
import (
255253
"cosmossdk.io/collections"
256-
storetypes "cosmossdk.io/store/types"
254+
"cosmossdk.io/core/store"
257255
"fmt"
258256
"github.com/cosmos/cosmos-sdk/codec"
259257
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -267,8 +265,8 @@ type Keeper struct {
267265
Accounts collections.Map[sdk.AccAddress, authtypes.BaseAccount]
268266
}
269267

270-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
271-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
268+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
269+
sb := collections.NewSchemaBuilder(storeService)
272270
return Keeper{
273271
Accounts: collections.NewMap(sb, AccountsPrefix, "accounts",
274272
sdk.AccAddressKey, codec.CollValue[authtypes.BaseAccount](cdc)),
@@ -352,7 +350,7 @@ package collections
352350

353351
import (
354352
"cosmossdk.io/collections"
355-
storetypes "cosmossdk.io/store/types"
353+
"cosmossdk.io/core/store"
356354
"fmt"
357355
sdk "github.com/cosmos/cosmos-sdk/types"
358356
)
@@ -364,8 +362,8 @@ type Keeper struct {
364362
ValidatorsSet collections.KeySet[sdk.ValAddress]
365363
}
366364

367-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
368-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
365+
func NewKeeper(storeService store.KVStoreService) Keeper {
366+
sb := collections.NewSchemaBuilder(storeService)
369367
return Keeper{
370368
ValidatorsSet: collections.NewKeySet(sb, ValidatorsSetPrefix, "validators_set", sdk.ValAddressKey),
371369
}
@@ -435,7 +433,7 @@ package collections
435433

436434
import (
437435
"cosmossdk.io/collections"
438-
storetypes "cosmossdk.io/store/types"
436+
"cosmossdk.io/core/store"
439437
"github.com/cosmos/cosmos-sdk/codec"
440438
sdk "github.com/cosmos/cosmos-sdk/types"
441439
stakingtypes "cosmossdk.io/x/staking/types"
@@ -448,8 +446,8 @@ type Keeper struct {
448446
Params collections.Item[stakingtypes.Params]
449447
}
450448

451-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
452-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
449+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
450+
sb := collections.NewSchemaBuilder(storeService)
453451
return Keeper{
454452
Params: collections.NewItem(sb, ParamsPrefix, "params", codec.CollValue[stakingtypes.Params](cdc)),
455453
}
@@ -505,7 +503,7 @@ package collections
505503

506504
import (
507505
"cosmossdk.io/collections"
508-
storetypes "cosmossdk.io/store/types"
506+
"cosmossdk.io/core/store"
509507
"github.com/cosmos/cosmos-sdk/codec"
510508
sdk "github.com/cosmos/cosmos-sdk/types"
511509
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -518,8 +516,8 @@ type Keeper struct {
518516
Accounts collections.Map[uint64, authtypes.BaseAccount]
519517
}
520518

521-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
522-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
519+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
520+
sb := collections.NewSchemaBuilder(storeService)
523521
return Keeper{
524522
Accounts: collections.NewMap(sb, AccountsPrefix, "accounts", collections.Uint64Key, codec.CollValue[authtypes.BaseAccount](cdc)),
525523
}
@@ -659,7 +657,7 @@ package collections
659657
import (
660658
"cosmossdk.io/collections"
661659
"cosmossdk.io/math"
662-
storetypes "cosmossdk.io/store/types"
660+
"cosmossdk.io/core/store"
663661
sdk "github.com/cosmos/cosmos-sdk/types"
664662
)
665663

@@ -671,8 +669,8 @@ type Keeper struct {
671669
Balances collections.Map[collections.Pair[sdk.AccAddress, string], math.Int]
672670
}
673671

674-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
675-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
672+
func NewKeeper(storeService store.KVStoreService) Keeper {
673+
sb := collections.NewSchemaBuilder(storeService)
676674
return Keeper{
677675
Balances: collections.NewMap(
678676
sb, BalancesPrefix, "balances",
@@ -714,8 +712,8 @@ type Keeper struct {
714712
Balances collections.Map[collections.Pair[sdk.AccAddress, string], math.Int]
715713
}
716714

717-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
718-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
715+
func NewKeeper(storeService store.KVStoreService) Keeper {
716+
sb := collections.NewSchemaBuilder(storeService)
719717
return Keeper{
720718
Balances: collections.NewMap(
721719
sb, BalancesPrefix, "balances",
@@ -901,8 +899,8 @@ type Keeper struct {
901899
Accounts *collections.IndexedMap[sdk.AccAddress, authtypes.BaseAccount, AccountsIndexes]
902900
}
903901

904-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
905-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
902+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
903+
sb := collections.NewSchemaBuilder(storeService)
906904
return Keeper{
907905
Accounts: collections.NewIndexedMap(
908906
sb, AccountsPrefix, "accounts",
@@ -927,7 +925,7 @@ package docs
927925
import (
928926
"cosmossdk.io/collections"
929927
"cosmossdk.io/collections/indexes"
930-
storetypes "cosmossdk.io/store/types"
928+
"cosmossdk.io/core/store"
931929
"github.com/cosmos/cosmos-sdk/codec"
932930
sdk "github.com/cosmos/cosmos-sdk/types"
933931
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -962,8 +960,8 @@ type Keeper struct {
962960
Accounts *collections.IndexedMap[sdk.AccAddress, authtypes.BaseAccount, AccountsIndexes]
963961
}
964962

965-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
966-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
963+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
964+
sb := collections.NewSchemaBuilder(storeService)
967965
return Keeper{
968966
Accounts: collections.NewIndexedMap(
969967
sb, AccountsPrefix, "accounts",
@@ -986,7 +984,7 @@ package docs
986984
import (
987985
"cosmossdk.io/collections"
988986
"cosmossdk.io/collections/indexes"
989-
storetypes "cosmossdk.io/store/types"
987+
"cosmossdk.io/core/store"
990988
"github.com/cosmos/cosmos-sdk/codec"
991989
sdk "github.com/cosmos/cosmos-sdk/types"
992990
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -1021,8 +1019,8 @@ type Keeper struct {
10211019
Accounts *collections.IndexedMap[sdk.AccAddress, authtypes.BaseAccount, AccountsIndexes]
10221020
}
10231021

1024-
func NewKeeper(storeKey *storetypes.KVStoreKey, cdc codec.BinaryCodec) Keeper {
1025-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
1022+
func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec) Keeper {
1023+
sb := collections.NewSchemaBuilder(storeService)
10261024
return Keeper{
10271025
Accounts: collections.NewIndexedMap(
10281026
sb, AccountsPrefix, "accounts",
@@ -1094,7 +1092,7 @@ package example
10941092

10951093
import (
10961094
"cosmossdk.io/collections"
1097-
storetypes "cosmossdk.io/store/types"
1095+
"cosmossdk.io/core/store"
10981096
"github.com/cosmos/cosmos-sdk/codec"
10991097
sdk "github.com/cosmos/cosmos-sdk/types"
11001098
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -1107,8 +1105,8 @@ type Keeper struct {
11071105
Accounts *collections.Map[sdk.AccAddress, sdk.AccountI]
11081106
}
11091107

1110-
func NewKeeper(cdc codec.BinaryCodec, storeKey *storetypes.KVStoreKey) Keeper {
1111-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
1108+
func NewKeeper(cdc codec.BinaryCodec, storeService store.KVStoreService) Keeper {
1109+
sb := collections.NewSchemaBuilder(storeService)
11121110
return Keeper{
11131111
Accounts: collections.NewMap(
11141112
sb, AccountsPrefix, "accounts",
@@ -1143,8 +1141,7 @@ import (
11431141
"context"
11441142

11451143
"cosmossdk.io/collections"
1146-
storetypes "cosmossdk.io/store/types"
1147-
"github.com/cosmos/cosmos-sdk/codec"
1144+
"cosmossdk.io/core/store"
11481145
)
11491146

11501147
type AccAddress = string
@@ -1156,8 +1153,8 @@ type Keeper struct {
11561153
Redelegations collections.KeySet[collections.Triple[AccAddress, ValAddress, ValAddress]]
11571154
}
11581155

1159-
func NewKeeper(storeKey *storetypes.KVStoreKey) Keeper {
1160-
sb := collections.NewSchemaBuilder(sdk.OpenKVStore(storeKey))
1156+
func NewKeeper(storeService store.KVStoreService) Keeper {
1157+
sb := collections.NewSchemaBuilder(storeService)
11611158
return Keeper{
11621159
Redelegations: collections.NewKeySet(sb, collections.NewPrefix(0), "redelegations", collections.TripleKeyCodec(collections.StringKey, collections.StringKey, collections.StringKey)
11631160
}

docs/docs/learn/advanced/00-baseapp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ Each CometBFT `query` comes with a `path`, which is a `string` which denotes wha
526526

527527
* Application-related queries like querying the application's version, which are served via the `handleQueryApp` method.
528528
* Direct queries to the multistore, which are served by the `handlerQueryStore` method. These direct queries are different from custom queries which go through `app.queryRouter`, and are mainly used by third-party service provider like block explorers.
529-
* P2P queries, which are served via the `handleQueryP2P` method. These queries return either `app.addrPeerFilter` or `app.ipPeerFilter` that contain the list of peers filtered by address or IP respectively. These lists are first initialized via `options` in `BaseApp`'s [constructor](#constructor).
529+
* P2P queries, which are served via the `handleQueryP2P` method. These queries return either `app.addrPeerFilter` or `app.idPeerFilter` that contain the list of peers filtered by address or node ID respectively. These lists are first initialized via `options` in `BaseApp`'s [constructor](#constructor).
530530

531531
### ExtendVote
532532

x/epochs/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,28 @@ The `epochs` module emits the following events:
6464

6565
## Keepers
6666

67-
### Keeper functions
67+
### Keeper Functions
6868

69-
Epochs keeper module provides utility functions to manage epochs.
69+
The epochs keeper provides the following functions to manage epochs:
70+
71+
```go
72+
// GetEpochInfo returns epoch info by identifier.
73+
func (k *Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, error)
74+
75+
// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation,
76+
// or re-uses an existing identifier. This method also sets the start time if left unset,
77+
// and sets the epoch start height.
78+
func (k *Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error
79+
80+
// AllEpochInfos iterate through epochs to return all epochs info.
81+
func (k *Keeper) AllEpochInfos(ctx sdk.Context) ([]types.EpochInfo, error)
82+
83+
// NumBlocksSinceEpochStart returns the number of blocks since the epoch started.
84+
// If the epoch started on block N, then calling this during block N (after BeforeEpochStart)
85+
// would return 0. Calling it any point in block N+1 (assuming the epoch doesn't increment)
86+
// would return 1.
87+
func (k *Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (int64, error)
88+
```
7089

7190
## Hooks
7291

x/gov/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,25 @@ Developers can now build systems with:
200200
```go
201201
func myCustomVotingFunction(
202202
ctx context.Context,
203-
k Keeper,
203+
k keeper.Keeper,
204204
proposal v1.Proposal,
205-
validators map[string]v1.ValidatorGovInfo,
206-
) (totalVoterPower math.LegacyDec, results map[v1.VoteOption]math.LegacyDec, err error) {
205+
) (totalVoterPower math.LegacyDec, totalValPower math.Int, results map[v1.VoteOption]math.LegacyDec, err error) {
207206
// ... tally logic
207+
// totalVoterPower is the sum of voting power that actually voted
208+
// totalValPower is the sum of all active validator power (for quorum calculation)
209+
return totalVoterPower, totalValPower, results, nil
208210
}
209211

210212
govKeeper := govkeeper.NewKeeper(
211213
appCodec,
212214
runtime.NewKVStoreService(keys[govtypes.StoreKey]),
213215
app.AccountKeeper,
214216
app.BankKeeper,
215-
app.StakingKeeper,
216217
app.DistrKeeper,
217218
app.MsgServiceRouter(),
218219
govConfig,
219220
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
220-
govkeeper.WithCustomCalculateVoteResultsAndVotingPowerFn(myCustomVotingFunction),
221+
govkeeper.NewDefaultCalculateVoteResultsAndVotingPower(app.StakingKeeper),
221222
)
222223
```
223224

x/protocolpool/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@ CancelContinuousFund is a message used to cancel an existing continuous fund pro
7373
rpc CancelContinuousFund(MsgCancelContinuousFund) returns (MsgCancelContinuousFundResponse);
7474
```
7575

76+
## Keepers
77+
78+
### Keeper Functions
79+
80+
The `x/protocolpool` keeper provides the following functions for managing the community pool:
81+
82+
```go
83+
// GetCommunityPool gets the community pool balance.
84+
func (k Keeper) GetCommunityPool(ctx sdk.Context) (sdk.Coins, error)
85+
86+
// FundCommunityPool allows an account to directly fund the community pool.
87+
func (k Keeper) FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
88+
89+
// DistributeFromCommunityPool distributes funds from the protocolpool module account
90+
// to a receiver address.
91+
func (k Keeper) DistributeFromCommunityPool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error
92+
93+
// DistributeFunds distributes funds from the ProtocolPoolEscrow account.
94+
// For each continuous fund, it distributes according to percentage, removes expired funds,
95+
// and sends remaining funds to the community pool. Called in BeginBlocker.
96+
func (k Keeper) DistributeFunds(ctx sdk.Context) error
97+
98+
// GetAllContinuousFunds returns all continuous funds in the store.
99+
func (k Keeper) GetAllContinuousFunds(ctx sdk.Context) ([]types.ContinuousFund, error)
100+
```
101+
76102
## Messages
77103

78104
### MsgFundCommunityPool

x/staking/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,9 @@ The staking module contains the following parameters:
941941
| Key | Type | Example |
942942
|-------------------|------------------|------------------------|
943943
| UnbondingTime | string (time ns) | "259200000000000" |
944-
| MaxValidators | uint16 | 100 |
945-
| KeyMaxEntries | uint16 | 7 |
946-
| HistoricalEntries | uint16 | 3 |
944+
| MaxValidators | uint32 | 100 |
945+
| MaxEntries | uint32 | 7 |
946+
| HistoricalEntries | uint32 | 10000 |
947947
| BondDenom | string | "stake" |
948948
| MinCommissionRate | string | "0.000000000000000000" |
949949

0 commit comments

Comments
 (0)