x/consensus 模块允许治理在不进行软件升级的情况下,直接在运行中的链上更新 CometBFT 的 ABCI 共识参数。
共识参数
该模块管理以下 CometBFT 共识参数:区块参数
| 参数 | 说明 |
|---|---|
MaxBytes | 以字节为单位的最大区块大小 |
MaxGas | 每个区块允许的最大 gas(-1 表示无限制) |
证据参数
| 参数 | 说明 |
|---|---|
MaxAgeNumBlocks | 证据允许存在的最大区块年龄 |
MaxAgeDuration | 以时长表示的证据最大有效期 |
MaxBytes | 每个区块中证据总大小的最大字节数 |
验证者参数
| 参数 | 说明 |
|---|---|
PubKeyTypes | 验证者支持的公钥类型(例如 ed25519、secp256k1、bls12381) |
ABCI 参数
| 参数 | 说明 |
|---|---|
VoteExtensionsEnableHeight | 启用 vote extensions 的区块高度(0 表示禁用) |
消息
MsgUpdateParams
通过治理更新共识参数。必须同时提供block、evidence 和 validator。abci 为可选项。
AuthorityParams
可以通过x/consensus 模块结合 AuthorityParams 对权限进行集中化管理。ConsensusParams 中的 AuthorityParams 字段会在链上存储权限地址。设置后,它的优先级高于各 keeper 单独配置的 authority 参数。
Keeper 构造函数仍然接收 authority 参数。当共识参数中未配置 authority 时,会将其作为回退值使用。
工作方式
当模块校验 authority 时(例如在UpdateParams 中),会先检查共识参数。如果其中未设置 authority,则回退到 keeper 的 authority 字段:
x/consensus 模块 MsgUpdateParams 的治理提案,在共识参数中设置 AuthorityParams。
命令行
查询
params
查询当前共识参数:交易
update-params-proposal
提交用于更新共识参数的治理提案:gRPC
Params
查询当前共识参数:REST
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 ofblock, evidence, and validator must be provided. abci is optional.
AuthorityParams
Authority management can be centralized via thex/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., inUpdateParams), it checks consensus params first. If no authority is set there, it falls back to the keeper’s authority field:
AuthorityParams in consensus params via a governance proposal targeting the x/consensus module’s MsgUpdateParams.