My App

Resonance Consensus

Understanding the Resonance DPoS consensus mechanism powering Living Mission

Resonance Consensus Engine

Resonance is Living Mission's custom Delegated Proof-of-Stake (DPoS) consensus engine, built on top of go-ethereum (geth). It combines the security of Proof-of-Authority with the decentralization benefits of stake-based validator selection.

Overview

Resonance is designed to provide:

  • Fast Finality - ~1 second block times
  • High Throughput - Efficient block production
  • Decentralization - Up to 101 active validators
  • Economic Security - Stake-based validator selection

Resonance is similar to consensus mechanisms used by BNB Chain (Parlia), Cosmos (Tendermint), and Polygon (Bor).

How It Works

Validator Selection

  1. Registration - Validators register with metadata and stake minimum 10,000 LGM
  2. Activation - At each epoch (200 blocks), eligible validators are activated
  3. Block Production - Active validators take turns producing blocks
  4. Rewards - Block rewards are distributed proportionally to stake

Epoch System

An epoch is a period of 200 blocks (~3.3 minutes at 1s block time).

At each epoch boundary:

  1. updateValidatorCandidates() - Activates new validators (STAKED → VALIDATED)
  2. distributeBlockReward() - Distributes accumulated rewards
Block 0    Block 200    Block 400    Block 600
   |          |            |            |
   └──Epoch 0─┴──Epoch 1───┴──Epoch 2───┴──...

Consensus Parameters

ParameterValueDescription
MAX_VALIDATORS101Maximum active validators
BLOCK_EPOCH200Blocks per epoch
Period1 secondTarget block time
MIN_VA_STAKE10,000 LGMMinimum validator stake
VA_LOCK_PERIOD50,000 blocksValidator unstake lock

Block Production

In-Turn vs Out-of-Turn

Validators are ordered by their position in the active set. Each validator has designated slots:

// Difficulty indicates in-turn status
DIFF_INTURN = 2  // Block produced by in-turn validator
  • In-Turn: Validator produces block at their designated slot
  • Out-of-Turn: Backup validator produces if in-turn misses

Block Header Structure

type Header struct {
    // Standard fields
    ParentHash  common.Hash
    Coinbase    common.Address  // Block producer (validator)
    Root        common.Hash     // State root
    TxHash      common.Hash     // Transactions root
    Number      *big.Int        // Block number
    Time        uint64          // Timestamp

    // Resonance-specific
    Extra       []byte          // Vanity (32) + Signature (65)
    Difficulty  *big.Int        // 2 = in-turn
}

System Transactions

At epoch blocks (block % 200 == 0), the consensus engine injects system transactions:

1. Update Validator Candidates

function updateValidatorCandidates() external returns (address[] memory)
  • Called first at epoch boundary
  • Activates STAKED validators to VALIDATED status
  • Returns updated active validator set

2. Distribute Block Reward

function distributeBlockReward(uint256 epochReward) external payable returns (bool)
  • Called second at epoch boundary
  • Distributes accumulated fees to validators
  • Updates reward accumulators for delegators

Fee Distribution

Block fees flow through the system:

┌─────────────────────────────────────────────────────────┐
│                    Block Fees                            │
│                        │                                 │
│                        ▼                                 │
│              ┌─────────────────┐                        │
│              │  FeeRecorder    │                        │
│              │  (accumulates)  │                        │
│              └────────┬────────┘                        │
│                       │ At Epoch                        │
│                       ▼                                 │
│              ┌─────────────────┐                        │
│              │ ResonanceSystem │                        │
│              │ (distributes)   │                        │
│              └────────┬────────┘                        │
│           ┌───────────┼───────────┐                     │
│           ▼           ▼           ▼                     │
│     ┌──────────┐ ┌──────────┐ ┌──────────┐             │
│     │Validator │ │Validator │ │Validator │             │
│     │    1     │ │    2     │ │   ...    │             │
│     └──────────┘ └──────────┘ └──────────┘             │
└─────────────────────────────────────────────────────────┘

Security Features

Signature Verification

Every block must be signed by an authorized validator:

// Block signature in extra-data
extraVanity = 32  // Vanity prefix
extraSeal   = 65  // ECDSA signature (r, s, v)

// Verify block producer
func ecrecover(header *Header) (common.Address, error) {
    signature := header.Extra[extraVanity:]
    pubkey := crypto.Ecrecover(sigHash, signature)
    return crypto.PubkeyToAddress(pubkey)
}

Snapshot System

Resonance maintains snapshots of the validator set for efficient verification:

type Snapshot struct {
    Number     uint64                      // Block number
    Hash       common.Hash                 // Block hash
    Validators map[common.Address]struct{} // Active validators
}

Genesis Configuration

Resonance is configured in the genesis file:

{
  "config": {
    "chainId": 5881,
    "resonance": {
      "period": 1,
      "epoch": 200
    }
  }
}

Comparison with Other Consensus

FeatureResonanceParlia (BNB)TendermintClique
TypeDPoSDPoSBFTPoA
Max Validators10121100+Unlimited
Block Time1s3s6s15s
FinalityProbabilisticProbabilisticInstantProbabilistic
DelegationYesYesYesNo