Skip to content

Commit a88f978

Browse files
author
Alex | Interchain Labs
authored
Merge branch 'main' into thomas/block-stm
2 parents e75b65a + ccd37e1 commit a88f978

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+731
-155
lines changed

.github/issue_labeler.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
6060
* x/distribution can now utilize an externally managed community pool. NOTE: this will make the message handlers for FundCommunityPool and CommunityPoolSpend error, as well as the query handler for CommunityPool.
6161
* (client) [#18101](https://github.com/cosmos/cosmos-sdk/pull/18101) Add a `keyring-default-keyname` in `client.toml` for specifying a default key name, and skip the need to use the `--from` flag when signing transactions.
6262
* (x/gov) [#24355](https://github.com/cosmos/cosmos-sdk/pull/24355) Allow users to set a custom CalculateVoteResultsAndVotingPower function to be used in govkeeper.Tally.
63+
* (x/mint) [#24436](https://github.com/cosmos/cosmos-sdk/pull/24436) Allow users to set a custom minting function used in the `x/mint` begin blocker.
64+
* The `InflationCalculationFn` argument to `mint.NewAppModule()` is now ignored and must be nil. To set a custom `InflationCalculationFn` on the default minter, use `mintkeeper.WithMintFn(mintkeeper.DefaultMintFn(customInflationFn))`.
6365
* (api) [#24428](https://github.com/cosmos/cosmos-sdk/pull/24428) Add block height to response headers
6466
* (baseapp) [#24458](https://github.com/cosmos/cosmos-sdk/pull/24458) Add `Executor` to support custom execution logic and incarnation cache for performance optimisation
6567

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The Cosmos SDK is a framework for building blockchain applications. [CometBFT (B
3434

3535
## Quick Start
3636

37-
To learn how the Cosmos SDK works from a high-level perspective, see the Cosmos SDK [High-Level Intro](https://docs.cosmos.network/main/intro/overview.html).
37+
To learn how the Cosmos SDK works from a high-level perspective, see the Cosmos SDK [High-Level Intro](https://docs.cosmos.network/main/intro/overview).
3838

3939
If you want to get started quickly and learn how to build on top of Cosmos SDK, visit [Cosmos SDK Tutorials](https://tutorials.cosmos.network). You can also fork the tutorial's repository to get started building your own Cosmos SDK application.
4040

UPGRADING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,62 @@ Required wiring:
139139
- entry in SetGenesisModuleOrder
140140
- entry in SetExportModuleOrder **before `x/bank`**
141141

142+
## Custom Minting Function in `x/mint`
143+
144+
This release introduces the ability to configure a custom mint function in `x/mint`. The minting logic is now abstracted as a `MintFn` with a default implementation that can be overridden.
145+
146+
### What’s New
147+
148+
- **Configurable Mint Function:**
149+
A new `MintFn` abstraction is introduced. By default, the module uses `DefaultMintFn`, but you can supply your own implementation.
150+
151+
- **Deprecated InflationCalculationFn Parameter:**
152+
The `InflationCalculationFn` argument previously provided to `mint.NewAppModule()` is now ignored and must be `nil`. To customize the default minter’s inflation behavior, wrap your custom function with `mintkeeper.DefaultMintFn` and pass it via the `WithMintFn` option:
153+
154+
```go
155+
mintkeeper.WithMintFn(mintkeeper.DefaultMintFn(customInflationFn))
156+
```
157+
158+
### How to Upgrade
159+
160+
1. **Using the Default Minting Function**
161+
162+
No action is needed if you’re happy with the default behavior. Make sure your application wiring initializes the MintKeeper like this:
163+
164+
```go
165+
mintKeeper := mintkeeper.NewKeeper(
166+
appCodec,
167+
storeService,
168+
stakingKeeper,
169+
accountKeeper,
170+
bankKeeper,
171+
authtypes.FeeCollectorName,
172+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
173+
)
174+
```
175+
176+
2. **Using a Custom Minting Function**
177+
178+
To use a custom minting function, define it as follows and pass it you your mintKeeper when constructing it:
179+
180+
```go
181+
func myCustomMintFunc(ctx sdk.Context, k *mintkeeper.Keeper) {
182+
// do minting...
183+
}
184+
185+
// ...
186+
mintKeeper := mintkeeper.NewKeeper(
187+
appCodec,
188+
storeService,
189+
stakingKeeper,
190+
accountKeeper,
191+
bankKeeper,
192+
authtypes.FeeCollectorName,
193+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
194+
mintkeeper.WithMintFn(myCustomMintFunc), // Use custom minting function
195+
)
196+
```
197+
142198
### Misc Changes
143199

144200
#### Testnet's init-files Command

docs/docs/learn/advanced/01-transactions.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ Every message in a transaction must be signed by the addresses specified by its
4343
The most used implementation of the `Tx` interface is the Protobuf `Tx` message, which is used in `SIGN_MODE_DIRECT`:
4444

4545
```protobuf reference
46-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L13-L26
46+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/proto/cosmos/tx/v1beta1/tx.proto#L15-L28
4747
```
4848

4949
Because Protobuf serialization is not deterministic, the Cosmos SDK uses an additional `TxRaw` type to denote the pinned bytes over which a transaction is signed. Any user can generate a valid `body` and `auth_info` for a transaction, and serialize these two messages using Protobuf. `TxRaw` then pins the user's exact binary representation of `body` and `auth_info`, called respectively `body_bytes` and `auth_info_bytes`. The document that is signed by all signers of the transaction is `SignDoc` (deterministically serialized using [ADR-027](../../build/architecture/adr-027-deterministic-protobuf-serialization.md)):
5050

5151
```protobuf reference
52-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L48-L65
52+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/proto/cosmos/tx/v1beta1/tx.proto#L50-L67
5353
```
5454

5555
Once signed by all signers, the `body_bytes`, `auth_info_bytes` and `signatures` are gathered into `TxRaw`, whose serialized bytes are broadcasted over the network.
@@ -59,13 +59,13 @@ Once signed by all signers, the `body_bytes`, `auth_info_bytes` and `signatures`
5959
The legacy implementation of the `Tx` interface is the `StdTx` struct from `x/auth`:
6060

6161
```go reference
62-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdtx.go#L83-L90
62+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/x/auth/migrations/legacytx/stdtx.go#L82-L89
6363
```
6464

6565
The document signed by all signers is `StdSignDoc`:
6666

6767
```go reference
68-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdsign.go#L31-L45
68+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/x/auth/migrations/legacytx/stdsign.go#L30-L43
6969
```
7070

7171
which is encoded into bytes using Amino JSON. Once all signatures are gathered into `StdTx`, `StdTx` is serialized using Amino JSON, and these bytes are broadcasted over the network.
@@ -80,7 +80,7 @@ The Cosmos SDK also provides a couple of other sign modes for particular use cas
8080
need to sign over the fees:
8181

8282
```protobuf reference
83-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L67-L98
83+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/proto/cosmos/tx/v1beta1/tx.proto#L68-L93
8484
```
8585

8686
The use case is a multi-signer transaction, where one of the signers is appointed to gather all signatures, broadcast the signature and pay for fees, and the others only care about the transaction body. This generally allows for a better multi-signing UX. If Alice, Bob and Charlie are part of a 3-signer transaction, then Alice and Bob can both use `SIGN_MODE_DIRECT_AUX` to sign over the `TxBody` and their own signer info (no need an additional step to gather other signers' ones, like in `SIGN_MODE_DIRECT`), without specifying a fee in their SignDoc. Charlie can then gather both signatures from Alice and Bob, and
@@ -99,7 +99,7 @@ If you wish to learn more, please refer to [ADR-050](../../build/architecture/ad
9999

100100
#### Custom Sign modes
101101

102-
There is the opportunity to add your own custom sign mode to the Cosmos-SDK. While we can not accept the implementation of the sign mode to the repository, we can accept a pull request to add the custom signmode to the SignMode enum located [here](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/signing/v1beta1/signing.proto#L17)
102+
There is the opportunity to add your own custom sign mode to the Cosmos-SDK. While we can not accept the implementation of the sign mode to the repository, we can accept a pull request to add the custom signmode to the SignMode enum located [here](https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/proto/cosmos/tx/signing/v1beta1/signing.proto#L17)
103103

104104
## Transaction Process
105105

@@ -145,8 +145,8 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/client/tx_config.go#L39-L
145145

146146
As there are currently two sign modes for signing transactions, there are also two implementations of `TxBuilder`:
147147

148-
* [wrapper](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/tx/builder.go#L26-L43) for creating transactions for `SIGN_MODE_DIRECT`,
149-
* [StdTxBuilder](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdtx_builder.go#L14-L17) for `SIGN_MODE_LEGACY_AMINO_JSON`.
148+
* [wrapper](https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/x/auth/tx/builder.go#L27-L44) for creating transactions for `SIGN_MODE_DIRECT`,
149+
* [StdTxBuilder](https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/x/auth/migrations/legacytx/stdtx_builder.go#L14-L17) for `SIGN_MODE_LEGACY_AMINO_JSON`.
150150

151151
However, the two implementations of `TxBuilder` should be hidden away from end-users, as they should prefer using the overarching `TxConfig` interface:
152152

@@ -185,7 +185,7 @@ simd tx send $MY_VALIDATOR_ADDRESS $RECIPIENT 1000stake
185185
[gRPC](https://grpc.io) is the main component for the Cosmos SDK's RPC layer. Its principal usage is in the context of modules' [`Query` services](../../build/building-modules/04-query-services.md). However, the Cosmos SDK also exposes a few other module-agnostic gRPC services, one of them being the `Tx` service:
186186

187187
```go reference
188-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/service.proto
188+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/proto/cosmos/tx/v1beta1/service.proto
189189
```
190190

191191
The `Tx` service exposes a handful of utility functions, such as simulating a transaction or querying a transaction, and also one method to broadcast transactions.

docs/docs/learn/advanced/02-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `context` is a data structure intended to be passed from function to functio
2020
The Cosmos SDK `Context` is a custom data structure that contains Go's stdlib [`context`](https://pkg.go.dev/context) as its base, and has many additional types within its definition that are specific to the Cosmos SDK. The `Context` is integral to transaction processing in that it allows modules to easily access their respective [store](./04-store.md#base-layer-kvstores) in the [`multistore`](./04-store.md#multistore) and retrieve transactional context such as the block header and gas meter.
2121

2222
```go reference
23-
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L41-L67
23+
https://github.com/cosmos/cosmos-sdk/blob/v0.53.0-rc.2/types/context.go#L40-L67
2424
```
2525

2626
* **Base Context:** The base type is a Go [Context](https://pkg.go.dev/context), which is explained further in the [Go Context Package](#go-context-package) section below.

simapp/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ func NewSimApp(
349349
app.BankKeeper,
350350
authtypes.FeeCollectorName,
351351
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
352+
// mintkeeper.WithMintFn(mintkeeper.DefaultMintFn(minttypes.DefaultInflationCalculationFn)), custom mintFn can be added here
352353
)
353354

354355
app.ProtocolPoolKeeper = protocolpoolkeeper.NewKeeper(

simapp/app_di.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func NewSimApp(
156156
//
157157

158158
// For providing a custom inflation function for x/mint add here your
159-
// custom function that implements the minttypes.InflationCalculationFn
159+
// custom minting function that implements the mintkeeper.MintFn
160160
// interface.
161161
),
162162
)

simapp/sim_bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"github.com/cosmos/cosmos-sdk/baseapp"
1515
"github.com/cosmos/cosmos-sdk/client/flags"
16-
"github.com/cosmos/cosmos-sdk/simsx"
1716
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
17+
"github.com/cosmos/cosmos-sdk/testutil/simsx"
1818
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
1919
"github.com/cosmos/cosmos-sdk/x/simulation"
2020
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"

simapp/sim_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525

2626
"github.com/cosmos/cosmos-sdk/baseapp"
2727
servertypes "github.com/cosmos/cosmos-sdk/server/types"
28-
sims "github.com/cosmos/cosmos-sdk/simsx"
2928
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
29+
sims "github.com/cosmos/cosmos-sdk/testutil/simsx"
3030
sdk "github.com/cosmos/cosmos-sdk/types"
3131
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
3232
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"

0 commit comments

Comments
 (0)