Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ The public key currently supports three types:

- `ed25519`
- `secp256k1`
- `sr25519`
- `bls12381`

Structure `ValidatorUpdate` also contains an `ìnt64` field denoting the validator's new power.
Applications must ensure that
Expand Down
2 changes: 1 addition & 1 deletion cometbft/next/spec/core/genesis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The genesis file is the starting point of a chain. An application will populate
> Note: For evidence to be considered invalid, evidence must be older than both `max_age_num_blocks` and `max_age_duration`

- `validator`
- `pub_key_types`: Defines which curves are to be accepted as a valid validator consensus key. CometBFT supports ed25519, sr25519 and secp256k1.
- `pub_key_types`: Defines which curves are to be accepted as a valid validator consensus key. CometBFT supports ed25519, secp256k1, and bls12381.

- `version`
- `app_version`: The version of the application. This is set by the application and is used to identify which version of the app a user should be using in order to operate a node.
Expand Down
1 change: 0 additions & 1 deletion sdk/next/build/abci/checktx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,6 @@ Setting a custom `CheckTxHandler` is optional. It can be done from your app.go f
func NewSimApp(
logger log.Logger,
db corestore.KVStoreWithBatch,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
Expand Down
4 changes: 0 additions & 4 deletions sdk/next/build/building-apps/app-go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ import (

"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"cosmossdk.io/log"
Expand Down Expand Up @@ -519,7 +518,6 @@ DefaultNodeHome = filepath.Join(userHomeDir, ".simapp")
func NewSimApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
Expand Down Expand Up @@ -571,8 +569,6 @@ std.RegisterInterfaces(interfaceRegistry)
// baseAppOptions = append(baseAppOptions, prepareOpt)
bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...)

bApp.SetCommitMultiStoreTracer(traceStore)

bApp.SetVersion(version.Version)

bApp.SetInterfaceRegistry(interfaceRegistry)
Expand Down
4 changes: 2 additions & 2 deletions sdk/next/build/building-apps/app-testnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ Next we will add a newTestnetApp helper function:
```diff expandable
// newTestnetApp starts by running the normal newApp method. From there, the app interface returned is modified in order
// for a testnet to be created from the provided app.
func newTestnetApp(logger log.Logger, db cometbftdb.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
func newTestnetApp(logger log.Logger, db cometbftdb.DB, appOpts servertypes.AppOptions) servertypes.Application {
// Create an app and type cast to an SimApp
app := newApp(logger, db, traceStore, appOpts)
app := newApp(logger, db, appOpts)
simApp, ok := app.(*simapp.SimApp)
if !ok {
panic("app created from newApp is not of type simApp")
Expand Down
26 changes: 7 additions & 19 deletions sdk/next/build/building-apps/runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Cosmos SDK applications should embed the `*runtime.App` struct to leverage the r
package simapp

import (

"io"

dbm "github.com/cosmos/cosmos-db"

Expand Down Expand Up @@ -138,7 +136,6 @@ func init() {
func NewSimApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
Expand Down Expand Up @@ -278,7 +275,7 @@ voteExtHandler.SetHandlers(bApp)

baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution())

app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
app.App = appBuilder.Build(db, baseAppOptions...)

// register streaming services
if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil {
Expand Down Expand Up @@ -1636,9 +1633,8 @@ Additionally, runtime provides automatic registration of other essential (i.e.,
package runtime

import (

"encoding/json"
"io"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -1667,7 +1663,7 @@ map[string]json.RawMessage {
// Build builds an *App instance.
func (a *AppBuilder)

Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*baseapp.BaseApp)) *App {
Build(db dbm.DB, baseAppOptions ...func(*baseapp.BaseApp)) *App {
for _, option := range a.app.baseAppOptions {
baseAppOptions = append(baseAppOptions, option)
}
Expand All @@ -1685,8 +1681,6 @@ bApp.SetGRPCQueryRouter(a.app.grpcQueryRouter)
)
bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...)

bApp.SetCommitMultiStoreTracer(traceStore)

bApp.SetVersion(version.Version)

bApp.SetInterfaceRegistry(a.app.interfaceRegistry)
Expand All @@ -1711,9 +1705,8 @@ The `AppBuilder` type provides a structured way to build applications:
package runtime

import (

"encoding/json"
"io"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -1742,7 +1735,7 @@ map[string]json.RawMessage {
// Build builds an *App instance.
func (a *AppBuilder)

Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*baseapp.BaseApp)) *App {
Build(db dbm.DB, baseAppOptions ...func(*baseapp.BaseApp)) *App {
for _, option := range a.app.baseAppOptions {
baseAppOptions = append(baseAppOptions, option)
}
Expand All @@ -1760,8 +1753,6 @@ bApp.SetGRPCQueryRouter(a.app.grpcQueryRouter)
)
bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...)

bApp.SetCommitMultiStoreTracer(traceStore)

bApp.SetVersion(version.Version)

bApp.SetInterfaceRegistry(a.app.interfaceRegistry)
Expand Down Expand Up @@ -1792,9 +1783,8 @@ An application only needs to call `AppBuilder.Build` to create a fully configure
package runtime

import (

"encoding/json"
"io"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -1823,7 +1813,7 @@ map[string]json.RawMessage {
// Build builds an *App instance.
func (a *AppBuilder)

Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*baseapp.BaseApp)) *App {
Build(db dbm.DB, baseAppOptions ...func(*baseapp.BaseApp)) *App {
for _, option := range a.app.baseAppOptions {
baseAppOptions = append(baseAppOptions, option)
}
Expand All @@ -1841,8 +1831,6 @@ bApp.SetGRPCQueryRouter(a.app.grpcQueryRouter)
)
bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...)

bApp.SetCommitMultiStoreTracer(traceStore)

bApp.SetVersion(version.Version)

bApp.SetInterfaceRegistry(a.app.interfaceRegistry)
Expand Down
8 changes: 7 additions & 1 deletion sdk/next/build/building-modules/invariants.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ An invariant is a property of the application that should always be true. In the

## Implementing `Invariant`s

<Warning>
The `Invariant` type and related invariant checking infrastructure are deprecated as of Cosmos SDK next. The `x/crisis` module, which serves as the primary `InvariantRegistry` implementation, has been moved to `./contrib/x/crisis` and is no longer part of the core SDK. Module developers should be aware that this mechanism will be removed in a future release.
</Warning>

An `Invariant` is a function that checks for a particular invariant within a module. Module `Invariant`s must follow the `Invariant` type:

```go expandable
Expand Down Expand Up @@ -336,7 +340,9 @@ string {
}
```

Typically, this interface is implemented in the `keeper` of a specific module. The most used implementation of an `InvariantRegistry` can be found in the `crisis` module:
Typically, this interface is implemented in the `keeper` of a specific module. The most used implementation of an `InvariantRegistry` can be found in the `crisis` module. Note that `x/crisis` has been moved to `./contrib/x/crisis` in Cosmos SDK next and is no longer part of the core SDK.

See the [crisis module README](/sdk/next/build/modules/crisis) for the updated import path.

```go expandable
package keeper
Expand Down
2 changes: 1 addition & 1 deletion sdk/next/build/building-modules/msg-services.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ ctx.EventManager().EmitTypedEvent(
})
```

or the older `EmitEvent` function:
or the `EmitEvent` function:

```go
ctx.EventManager().EmitEvent(
Expand Down
4 changes: 4 additions & 0 deletions sdk/next/build/modules/circuit/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: 'x/circuit'
noindex: true
---

<Warning>
`x/circuit` has been moved to [`./contrib/x/circuit`](https://github.com/cosmos/cosmos-sdk/tree/main/contrib/x/circuit) and is no longer actively maintained as part of the core Cosmos SDK. It is still available for use but is not included in the SDK Bug Bounty program. It was moved because it was never widely adopted.
</Warning>

## Concepts

Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
Expand Down
173 changes: 172 additions & 1 deletion sdk/next/build/modules/consensus/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,175 @@ description: Functionality to modify CometBFT's ABCI consensus params.
noindex: true
---

Functionality to modify CometBFT's ABCI consensus params.
The `x/consensus` module allows governance to update CometBFT's ABCI consensus parameters on a live chain without a software upgrade.

## Consensus Parameters

The module manages the following CometBFT consensus parameters:

### Block Parameters

| Parameter | Description |
| --- | --- |
| `MaxBytes` | Maximum block size in bytes |
| `MaxGas` | Maximum gas per block (`-1` for unlimited) |

### Evidence Parameters

| Parameter | Description |
| --- | --- |
| `MaxAgeNumBlocks` | Maximum age of evidence in blocks |
| `MaxAgeDuration` | Maximum age of evidence as a duration |
| `MaxBytes` | Maximum total evidence size per block in bytes |

### Validator Parameters

| Parameter | Description |
| --- | --- |
| `PubKeyTypes` | Supported public key types for validators (e.g., `ed25519`, `secp256k1`, `bls12381`) |

### ABCI Parameters

| Parameter | Description |
| --- | --- |
| `VoteExtensionsEnableHeight` | Block height at which vote extensions are enabled (`0` to disable) |

## Messages

### MsgUpdateParams

Updates consensus parameters via governance. All of `block`, `evidence`, and `validator` must be provided. `abci` is optional.

```go
msg := &types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Block: &cmtproto.BlockParams{
MaxBytes: 200000,
MaxGas: 100000000,
},
Evidence: &cmtproto.EvidenceParams{
MaxAgeNumBlocks: 302400,
MaxAgeDuration: 504 * time.Hour,
MaxBytes: 10000,
},
Validator: &cmtproto.ValidatorParams{
PubKeyTypes: []string{"ed25519"},
},
Abci: &cmtproto.ABCIParams{
VoteExtensionsEnableHeight: 0,
},
}
```

## AuthorityParams

Authority management can be centralized via the `x/consensus` module using `AuthorityParams`. The `AuthorityParams` field in `ConsensusParams` stores the authority address on-chain. When set, it takes precedence over the per-keeper authority parameter.

Keeper constructors still accept the `authority` parameter. It is used as a fallback when no authority is configured in consensus params.

### How It Works

When a module validates authority (e.g., in `UpdateParams`), it checks consensus params first. If no authority is set there, it falls back to the keeper's `authority` field:

```go
authority := sdkCtx.Authority() // from consensus params
if authority == "" {
authority = k.authority // fallback to keeper field
}
if authority != msg.Authority {
return nil, errors.Wrapf(...)
}
```

To enable centralized authority, set the `AuthorityParams` in consensus params via a governance proposal targeting the `x/consensus` module's `MsgUpdateParams`.

## CLI

### Query

#### params

Query the current consensus parameters:

```shell
simd query consensus params
```

Example Output:

```yml
params:
abci:
vote_extensions_enable_height: "0"
block:
max_bytes: "200000"
max_gas: "-1"
evidence:
max_age_duration: 1814400s
max_age_num_blocks: "302400"
max_bytes: "10000"
validator:
pub_key_types:
- ed25519
```

### Transactions

#### update-params-proposal

Submit a governance proposal to update consensus parameters:

```shell
simd tx consensus update-params-proposal [block] [evidence] [validator] [abci] [flags]
```

Example:

```shell
simd tx consensus update-params-proposal \
'{"max_bytes":"200000","max_gas":"100000000"}' \
'{"max_age_num_blocks":"302400","max_age_duration":"1814400s","max_bytes":"10000"}' \
'{"pub_key_types":["ed25519"]}' \
'{"vote_extensions_enable_height":"0"}' \
--from mykey
```

## gRPC

### Params

Query the current consensus parameters:

```shell
grpcurl -plaintext localhost:9090 cosmos.consensus.v1.Query/Params
```

Example Output:

```json
{
"params": {
"block": {
"maxBytes": "200000",
"maxGas": "-1"
},
"evidence": {
"maxAgeNumBlocks": "302400",
"maxAgeDuration": "1814400s",
"maxBytes": "10000"
},
"validator": {
"pubKeyTypes": ["ed25519"]
},
"abci": {
"voteExtensionsEnableHeight": "0"
}
}
}
```

## REST

```
GET /cosmos/consensus/v1/params
```
Loading