Consensus Module (x/consensus)
Overview
Thex/consensus module provides functionality to modify CometBFT’s ABCI consensus parameters on-chain through governance proposals, eliminating the need for hard forks when updating critical consensus settings.
Purpose: Enable dynamic updates to blockchain consensus parameters through governance without requiring chain restarts or hard forks.
Key Features
- On-Chain Parameter Updates: Modify consensus parameters through governance
- Authority Control: Restrict parameter updates to authorized addresses
- Comprehensive Validation: Ensure parameter changes are safe before application
- ABCI Integration: Direct integration with CometBFT consensus engine
- No Hard Forks Required: Update consensus rules seamlessly
Consensus Parameters
The module manages four categories of CometBFT consensus parameters:Block Parameters
Control block size and gas limits:| Parameter | Type | Description |
|---|---|---|
| MaxBytes | int64 | Maximum block size in bytes (e.g., 22020096 = ~21MB) |
| MaxGas | int64 | Maximum gas per block (e.g., 10000000) |
Evidence Parameters
Control how evidence of misbehavior is handled:| Parameter | Type | Description |
|---|---|---|
| MaxAgeNumBlocks | int64 | Maximum age of evidence in blocks |
| MaxAgeDuration | time.Duration | Maximum age of evidence in time |
| MaxBytes | int64 | Maximum evidence size in bytes |
Validator Parameters
Define supported validator key types:| Parameter | Type | Description |
|---|---|---|
| PubKeyTypes | []string | Supported public key algorithms for validators |
ed25519- Primary key type for CometBFT validatorssecp256k1- Alternative key type
ABCI Parameters
Control advanced ABCI features:| Parameter | Type | Description |
|---|---|---|
| VoteExtensionsEnableHeight | int64 | Block height to enable vote extensions (0 = disabled) |
Messages
MsgUpdateParams
Update consensus parameters through governance:- Signer must be the designated authority (typically governance module)
- Block parameters must be positive and within safe limits
- Evidence age parameters must be positive
- Validator key types must be supported by the chain
Queries
Query Current Parameters
Retrieve the current consensus parameters:Governance Proposal
Create Parameter Update Proposal
Submit a governance proposal to update consensus parameters:Submit via CLI
gRPC Endpoints
Query Params
Code Examples
Query Current Parameters
Update Parameters (via Handler)
Validate Parameters
Security Considerations
Authority Control
Only the designated authority can update parameters:Parameter Limits
Recommended safe ranges:- MaxBytes: 1MB - 100MB (too small = low throughput, too large = network issues)
- MaxGas: -1 (unlimited) or 1M - 100M
- MaxAgeNumBlocks: 10,000 - 1,000,000 blocks
- MaxAgeDuration: 24 hours - 21 days
Best Practices
- Test Changes: Thoroughly test parameter changes on testnets before mainnet
- Gradual Increases: Increase block size gradually to monitor network performance
- Monitor Impact: Track block times, network bandwidth, and validator performance
- Community Consensus: Gather community feedback before major parameter changes
- Emergency Plans: Have rollback plans for problematic parameter changes
Integration Guide
CLI Commands Reference
| Command | Description |
|---|---|
simd query consensus params | Query current consensus parameters |
simd tx gov submit-proposal | Submit parameter update proposal |