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
- Registration - Validators register with metadata and stake minimum 10,000 LGM
- Activation - At each epoch (200 blocks), eligible validators are activated
- Block Production - Active validators take turns producing blocks
- 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:
updateValidatorCandidates()- Activates new validators (STAKED → VALIDATED)distributeBlockReward()- Distributes accumulated rewards
Block 0 Block 200 Block 400 Block 600
| | | |
└──Epoch 0─┴──Epoch 1───┴──Epoch 2───┴──...Consensus Parameters
| Parameter | Value | Description |
|---|---|---|
MAX_VALIDATORS | 101 | Maximum active validators |
BLOCK_EPOCH | 200 | Blocks per epoch |
Period | 1 second | Target block time |
MIN_VA_STAKE | 10,000 LGM | Minimum validator stake |
VA_LOCK_PERIOD | 50,000 blocks | Validator 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
| Feature | Resonance | Parlia (BNB) | Tendermint | Clique |
|---|---|---|---|---|
| Type | DPoS | DPoS | BFT | PoA |
| Max Validators | 101 | 21 | 100+ | Unlimited |
| Block Time | 1s | 3s | 6s | 15s |
| Finality | Probabilistic | Probabilistic | Instant | Probabilistic |
| Delegation | Yes | Yes | Yes | No |
Related Topics
- Validators - How to become a validator
- Delegators - How to delegate stake
- Smart Contracts - System contract details