consensus

package
v0.55.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 23 Imported by: 865

README


sidebar_position: 1

x/consensus

The consensus module provides functionality to modify CometBFT's ABCI consensus parameters on-chain through governance proposals.

Overview

This module allows authorized entities (typically governance) to update critical consensus parameters that affect blockchain performance and security without requiring a hard fork.

Key Features

  • Parameter Updates: Modify consensus parameters through governance proposals
  • Authority Control: Only authorized addresses can update parameters
  • Validation: Comprehensive parameter validation before updates
  • ABCI Integration: Direct integration with CometBFT consensus engine

Consensus Parameters

The module manages the following CometBFT consensus parameters:

Block Parameters

  • MaxBytes: Maximum block size in bytes
  • MaxGas: Maximum gas per block

Evidence Parameters

  • MaxAgeNumBlocks: Maximum age of evidence in blocks
  • MaxAgeDuration: Maximum age of evidence in time
  • MaxBytes: Maximum evidence size in bytes

Validator Parameters

  • PubKeyTypes: Supported public key types for validators

ABCI Parameters

  • VoteExtensionsEnableHeight: Height at which vote extensions are enabled

Usage

Governance Proposal

To update consensus parameters, submit a governance proposal with MsgUpdateParams:

import (
    "time"
    govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
    authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

msg := &types.MsgUpdateParams{
    Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), // governance authority
    Block: &types.BlockParams{
        MaxBytes: 22020096,
        MaxGas:   10000000,
    },
    Evidence: &types.EvidenceParams{
        MaxAgeNumBlocks: 100000,
        MaxAgeDuration:  48 * time.Hour,
        MaxBytes:        1048576,
    },
    Validator: &types.ValidatorParams{
        PubKeyTypes: []string{"ed25519"},
    },
    Abci: &types.ABCIParams{
        VoteExtensionsEnableHeight: 0,
    },
}

Query Parameters

Retrieve current consensus parameters:

<appd> q consensus params

Architecture

  • Keeper: Manages parameter storage and validation
  • Types: Defines message types and parameter structures
  • Module: Integrates with the Cosmos SDK application lifecycle

Security

  • Only the designated authority can update parameters
  • All parameter changes are validated before application
  • Updates are subject to governance approval process

Documentation

Index

Constants

View Source
const ConsensusVersion = 1

ConsensusVersion defines the current x/consensus module consensus version.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements an application module

func NewAppModule

func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) AutoCLIOptions added in v0.50.0

func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions

AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) IsAppModule

func (am AppModule) IsAppModule()

IsAppModule implements the appmodule.AppModule interface.

func (AppModule) IsOnePerModuleType

func (am AppModule) IsOnePerModuleType()

IsOnePerModuleType implements the depinject.OnePerModuleType interface.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error

RegisterServices registers module services.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

AppModuleBasic defines the basic application module used by the consensus module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the consensus module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes

func (AppModuleBasic) RegisterInterfaces

func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers interfaces and implementations of the consensus module.

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the consensus module's types on the LegacyAmino codec.

type ModuleInputs added in v0.50.0

type ModuleInputs struct {
	depinject.In

	Config       *modulev1.Module
	Cdc          codec.Codec
	StoreService storetypes.KVStoreService
	EventManager event.Service
}

type ModuleOutputs added in v0.50.0

type ModuleOutputs struct {
	depinject.Out

	Keeper        keeper.Keeper
	Module        appmodule.AppModule
	BaseAppOption runtime.BaseAppOption
}

func ProvideModule

func ProvideModule(in ModuleInputs) ModuleOutputs

Directories

Path Synopsis
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL