About Epochs

Introduction

Epochs are the fundamental time unit in OP_NET's consensus mechanism. They function as the heartbeat of the system, providing regular intervals that group transactions, finalize state, and create immutable checkpoints of everything that occurred during each period.

Unlike traditional blockchains that create new blocks through mining, OP_NET uses Bitcoin's existing blocks and organizes them into epochs. This architectural choice enables OP_NET to operate directly on Bitcoin Layer 1 without requiring any modifications to Bitcoin's protocol.

What Are Epochs and Why Do They Matter?

An epoch consists of exactly five consecutive Bitcoin blocks, taking approximately 50 minutes to complete. This serves as the fundamental time unit in OP_NET's consensus mechanism. Every transaction confirmed in Bitcoin during those five blocks becomes part of that epoch's state and is processed and finalized together.

The following example presents a high level overview of epochs:
Epoch 184450 Overview Epoch Number: 184450 Duration: ~50 minutes (5 blocks × ~10 min/block) Block Range: 922250 - 922254 Block Range Calculation Start Block = Epoch × 5 184450 × 5 → 922250 End Block = (Epoch × 5) + 4 (184450 × 5) + 4 → 922254 5 Bitcoin Blocks Included Block 922250 Block 922251 Block 922252 Block 922253 Block 922254 START END What Happens During This Epoch Transaction Processing All OP_NET transactions in these 5 blocks are collected and processed deterministically by all nodes in the network. State Changes Contract executions, token transfers, and storage updates accumulate throughout the epoch duration. Deterministic Ordering Transactions are sorted by dependency groups and fees, ensuring identical execution on all nodes. Epoch Finalization At block 922254, the epoch ends and the checksum root is generated for the SHA-1 mining competition.

Why Epochs Are Critical

Epochs serve a critical architectural purpose beyond simple time division. They address fundamental challenges required to make OP_NET possible:

Enable Smart Contracts on Bitcoin

By grouping transactions into epochs and creating checkpoints, OP_NET can maintain complex state on top of Bitcoin without modifying Bitcoin's protocol. The epoch system provides the temporal structure needed for Turing complete computation.

Achieve Mathematical Consensus

Epochs enable deterministic consensus through mathematical proofs rather than social agreement or voting. Every node independently processes the same epochs and arrives at provably identical results.

Make Forks Mathematically Impossible

The epoch structure, combined with time delayed attestations, makes forks impossible. All decisions reference immutable Bitcoin history (21+ blocks deep) that all nodes must agree on.

Create Sustainable Economic Incentives

Epoch mining provides a decentralized way to incentivize network operation without requiring a separate token. Miners earn future Bitcoin transaction fees, aligning incentives with long-term network health.

Detailed Epoch Flow

The epoch process spans from transaction processing through mining competition, winner selection, and reward distribution, demonstrating how OP_NET achieves deterministic consensus.

The diagram below shows the complete lifecycle for Epoch 184450:
Epoch 184450 Detailed Flow Epoch 184446 Blocks 922230-922234 Attestation Target ~21 blocks ago, referenced in solutions Epoch 184450 Blocks 922250-922254 STEP 1: Transaction Processing Block 922250 Block 922251 Block 922252 Block 922253 Block 922254 Deterministic ordering: Gas, Priority, TxID STEP 2: State Finalization Checksum Root Generated SHA256(all states + transactions + balances) Epoch state finalized Epoch 184451 Blocks 922255-922259 STEP 3: SHA-1 Mining A B C✓ D E Finding SHA-1(checksum + pubkey + salt) Most matching bits wins STEP 4: Submit Solution Attests to Epoch 184446 Bitcoin Transaction: SHA-1 Proof + PubKey + Salt Submit within epoch window Epoch 184453 Blocks 922265-922269 STEP 5: Winner Selection Tiebreaker Cascade: 1. Most SHA-1 matching bits 2. Lowest public key value 3. Last 20 bytes match, Salt, TxID STEP 6: Reward Distribution Winner receives gas fees ~150 min delay prevents manipulation Incentivizes long-term network health
Key Observation
The winning miner for an epoch must attest to the state from five epochs prior. By the time anyone can submit a solution, that referenced epoch is already 21 or more blocks deep in Bitcoin's history, a depth where Bitcoin never reorganizes under normal circumstances. This time delay is what makes forks mathematically impossible.

Five Bitcoin Blocks

The selection of five Bitcoin blocks per epoch balances several competing factors:

Transaction Batching

Five blocks provides enough time to accumulate meaningful transaction volume while keeping finalization intervals reasonable. Too few blocks would create overhead; too many would delay finality.

Finality Timing

~50 minutes gives users predictable finalization windows. Combined with the attestation delay, transactions achieve practical irreversibility within 3.5 hours (~21 blocks).

Mining Economics

The interval provides sufficient time for miners to compute SHA-1 collisions while ensuring regular reward opportunities. This creates a competitive mining market without excessive computational waste.

State Management

Five blocks allows for manageable state checkpoints. Each epoch's state root represents a reasonable amount of state changes without creating excessively large Merkle trees.

Transaction Ordering

Transaction ordering within each epoch follows a deterministic algorithm rather than simple Bitcoin block sequence. Transactions are grouped by dependencies and sorted to guarantee identical processing order across all nodes.

The following diagram shows the transaction ordering flow:
Transaction Ordering Algorithm Flow Step 1: Input TX A TX B TX C TX D Block reward (coinbase) shown in red Step 2: Group by UTXO Group 1 TX C (coinbase) No dependencies Group 2 TX A → TX B B spends A's output Must maintain order Group 3 TX D Independent Step 3: Rank by Fees rank = (gas × PENALTY) - priority Group 1: rank = -∞ Block rewards always first Group 2: rank = 5000 (10000 gas × 2) - 15000 priority Group 3: rank = 8000 (5000 gas × 2) - 2000 priority Step 4: Final Order 1. TX C (coinbase) 2. TX A → TX B 3. TX D If ranks equal: compare hashes All nodes get identical order
  • Dependency Grouping
    Transactions spending the same UTXOs stay together, maintaining topological order (parent before child).
  • Fee-Based Ranking
    Groups compete based on economic incentives. Higher priority fees and lower gas usage = better rank = earlier execution.
  • Mathematical Tiebreakers
    When ranks are equal, concatenated transaction hashes provide deterministic ordering. No ambiguity, no voting.
  • Coinbase Priority
    Block rewards process first because they have no dependencies, ensuring they're always available for subsequent transactions.
Why Order Matters

In smart contracts, especially DeFi applications, execution order can dramatically affect outcomes. If one DEX swap executes before another, prices shift. If a lending protocol processes a liquidation before a repayment, the result changes. OP_NET's deterministic ordering ensures all nodes experience the same sequence of events and arrive at identical final states.

State Finalization at Epoch End

When the last block of an epoch is mined, several critical things happen:

  1. Transaction Processing Completes
    All transactions from blocks of this epoch have been executed through OP_VM in deterministic order.
  2. State Root Generation
    The system generates a checksum root; a cryptographic hash (SHA-256) of the entire state after all transactions have executed. This includes:
    • All contract storage values.
    • All token balances.
    • All contract variables.
    • The complete transaction set and their results.
  3. Mining Competition Begins
    Miners can now compete to create the winning solution for the epoch, which involves finding a SHA-1 near-collision with this checksum root.
Checksum Root Properties
The checksum root is extremely sensitive; changing even a single bit in the state produces a completely different hash. This means if two nodes calculated different states (perhaps one had a bug), their checksum roots would be entirely different, making the disagreement immediately detectable.

Mining and Submission Window

After an epoch ends, miners have the duration of the next epoch to submit their solutions.

OP_NET uses SHA-1 for epoch mining instead of SHA-256. While this might seem surprising, it's a deliberate choice that provides Bitcoin compatibility, decentralization benefits, and secure proof-of-work for state finalization.

Learn More About Mining
For a detailed explanation on how the mining process works, see Mining Process.

Finality Stages

OP_NET transactions progress through several stages of finality, each providing stronger guarantees than the previous.

After Stage 4, transactions are protected not by probabilistic security but by mathematical impossibility. Reversal would require reorganizing 21 or more Bitcoin blocks, which becomes economically irrational after a few hours and physically impossible after a few days.

The following diagram illustrates the multiple finality stages:
Understanding Finality Stages 1. Bitcoin Inclusion When: Bitcoin block mined Transaction is permanently recorded in Bitcoin's blockchain Finality: Bitcoin-level Protected by Bitcoin's PoW Reversed only by Bitcoin reorg 2. Epoch Processing When: Epoch ends (~50 min) All nodes execute transaction deterministically. State root generated Finality: Computational State changes calculated Mining competition begins 3. Epoch Checkpointed When: Winner selected Winning miner's solution submitted State root checkpointed in Bitcoin Finality: Cryptographic Reversal requires attacking Bitcoin itself 4. Deep Confirmation When: 21+ blocks deep Attestations reference this state Deeply buried in Bitcoin Finality: Absolute Reversal economically impossible Protected by millions in PoW

Epochs vs Bitcoin Blocks

Epochs are fundamentally different from Bitcoin blocks, even though they are built on top of them.

Bitcoin Blocks vs OP_NET Epochs:
Aspect Bitcoin Blocks OP_NET Epochs
Creation Method SHA256 Proof-of-Work mining Grouping of 5 Bitcoin blocks
Average Duration ~10 minutes ~50 minutes (5 blocks)
Purpose Record Bitcoin transactions Finalize smart contract state
Can Fork? Yes (temporarily) No (mathematically impossible)
Transaction Ordering Miner's choice Deterministic (dependency groups by fees)
Finality Probabilistic (~6 blocks) Deterministic (21+ blocks)