network

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

Network Module

Introduction

The network module provides the framework for an off-chain consensus mechanism driven by a dynamic set of participants called Attesters. This module allows for blocks to be confirmed much faster than the underlying consensus engine's finality by gathering votes from attesters. When enough votes are collected for a specific block, it is considered "soft confirmed."

This module is responsible for:

  • Managing the set of active attesters.
  • Collecting and recording attestations (votes) for blocks.
  • Determining when a block has reached a quorum of votes.
  • Emitting events that other off-chain components can use to reason about the state of the network.

Core Concepts

Attesters

Attesters are validators who have explicitly opted-in to participate in the off-chain attestation process. They are responsible for validating blocks and submitting signed votes to the network module.

Soft Confirmation

A soft confirmation is a signal that a block has been validated by a sufficient number of attesters. It is achieved when a quorum of votes is reached for a specific block height. This provides a faster, off-chain layer of consensus that can be used by light clients and other services that require quick confirmation, without waiting for the finality of the underlying L1.

Epochs

An epoch is a defined period of blocks. At the end of each epoch, the module can perform accounting tasks, such as updating the attester set based on who has joined or left.

Workflow

  1. Joining: A validator operator submits a MsgJoinAttesterSet transaction to add their validator to the active attester set.
  2. Attesting: For each relevant block, an attester's off-chain process signs a vote and submits it to the chain via a MsgAttest transaction.
  3. Recording: The network module receives the attestation, records the vote, and updates a bitmap for that block height to track which attesters have voted.
  4. Confirmation: At the end of every block, the module's EndBlocker checks if the total voting power of the attesters for any recent block has passed the quorum threshold.
  5. Notification: If quorum is reached, the module emits a checkpoint event containing the block hash and other details. Downstream services listen for this event to act on the soft-confirmed block.

Messages

Interaction with the network module is done through the following messages:

MsgJoinAttesterSet

Allows a validator to opt-in to the attester set. The transaction must be signed by the authority account, but the consensus_address specifies which validator is being added.

Example:

{
  "messages": [
    {
      "@type": "/evabci.network.v1.MsgJoinAttesterSet",
      "authority": "cosmos1...",
      "consensus_address": "cosmosvalcons1...",
      "pubkey": {
        "@type": "/cosmos.crypto.ed25519.PubKey",
        "key": "VALIDATOR_CONSENSUS_PUBKEY_BASE64"
      }
    }
  ],
  ...
}
MsgLeaveAttesterSet

Allows a validator to opt-out of the attester set.

Example:

{
  "messages": [
    {
      "@type": "/evabci.network.v1.MsgLeaveAttesterSet",
      "authority": "cosmos1...",
      "consensus_address": "cosmosvalcons1..."
    }
  ],
  ...
}
MsgAttest

Submits a signed vote for a specific block height. This is the primary transaction used by active attesters.

  • authority: The account submitting the transaction and paying the fee.
  • consensus_address: The consensus address of the validator that is attesting.
  • height: The block height being voted on.
  • vote: The base64-encoded vote payload.

Example:

{
  "messages": [
    {
      "@type": "/evabci.network.v1.MsgAttest",
      "authority": "cosmos1...",
      "consensus_address": "cosmosvalcons1...",
      "height": "12345",
      "vote": "BASE64_ENCODED_VOTE_BYTES"
    }
  ],
  ...
}
MsgUpdateParams

Allows a governance proposal to update the parameters of the network module.

Example:

{
  "messages": [
    {
      "@type": "/evabci.network.v1.MsgUpdateParams",
      "authority": "cosmos10d07y265gmmuvt4z0w9aw880j2r6426u005ev2",
      "params": {
        "epoch_length": "100",
        "min_attester_stake_amount": "1000000"
      }
    }
  ],
  ...
}

EndBlocker Logic

The module's EndBlocker is executed at the end of every block and performs the following critical functions:

  1. Quorum Evaluation: It iterates through recent blocks that have received attestations and checks if the cumulative voting power of the attesters has reached the required quorum.
  2. Checkpoint Emission: If quorum is met for a block, it emits an EventSoftCheckpoint with the height, block_hash, a bitmap of the participating attesters, and the total voting power.
  3. Epoch Processing: It checks if the current block is the end of an epoch. If it is, it performs accounting tasks, such as updating the attester index map for the next epoch.

Genesis and Queries

The module supports standard genesis import/export, allowing the attester set, parameters, and historical attestation data to be included in a chain's genesis file.

The state can be inspected via gRPC queries, which allow you to query for the current attester set, module parameters, and the attestation status of specific blocks.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

ExportGenesis returns the network module's exported genesis.

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) error

InitGenesis initializes the network module's state from a provided genesis state.

Types

type AppModule

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

func NewAppModule

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

NewAppModule creates a new AppModule object

func (AppModule) AutoCLIOptions

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

AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.

func (AppModule) EndBlock

func (am AppModule) EndBlock(ctx context.Context) error

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage)

InitGenesis performs genesis initialization for the staking module.

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(cfg module.Configurator)

RegisterServices registers module services.

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for supply module's types

type AppModuleBasic

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

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns default genesis state as raw bytes.

func (AppModuleBasic) Name

func (am AppModuleBasic) Name() string

Name returns the network module's name

func (AppModuleBasic) RegisterGRPCGatewayRoutes

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

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the network module.

func (AppModuleBasic) RegisterInterfaces

func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

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

RegisterLegacyAminoCodec registers the network module's types on the given LegacyAmino codec.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the network module.

type ModuleInputs

type ModuleInputs struct {
	depinject.In

	Config        *modulev1.Module
	Cdc           codec.Codec
	StoreService  store.KVStoreService
	StakingKeeper types.StakingKeeper
	AccountKeeper types.AccountKeeper
	BankKeeper    types.BankKeeper
}

type ModuleOutputs

type ModuleOutputs struct {
	depinject.Out

	NetworkKeeper keeper.Keeper
	Module        appmodule.AppModule
}

func ProvideModule

func ProvideModule(in ModuleInputs) ModuleOutputs

Directories

Path Synopsis
client
cli
module
v1
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