> For the complete documentation index, see [llms.txt](https://docs.engma.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.engma.io/ravid/epochs.md).

# Epochs

**How Synchronized Motion Works**

Several times per minute, Ethereum produces a new block with an unpredictable hash. All RAVID nodes observe the same hash at the same time. From this shared randomness, every node independently computes the same "motion plan" which routes to use, where workloads go, how storage redistributes.

No central coordinator tells anyone what to do. The math is deterministic: same input → same output. Everyone moves together because everyone computes the same answer.<br>

```
EPOCH CYCLE:

  Ethereum Block    All Nodes See      Each Node Computes    System Moves
  ─────────────     ─────────────      ──────────────────    ────────────
  Block #N ──────►  Same blockhash ──► Same motion plan ──►  Synchronized
                    (public)           (deterministic)        motion

  Block #N+B ────►  New blockhash ───► New motion plan ────► Next epoch
  
```

### Technical: DETSA Mathematical Framework

**DETSA** = Deterministic Execution with Time-Domain Security Amplification

{% code overflow="wrap" %}

```angular-ts
EPOCH INDEX
e = ⌊(blockNumber - b₀) / B⌋ where: blockNumber = current block height b₀ = genesis block for RAVID B = blocks per epoch (tunable)
```

{% endcode %}

{% code overflow="wrap" %}

```angular-ts
EPOCH ENTROPY (Critical Formula)
Rand_e = H(blockhash(boundary(e)) ‖ PolCommit_e ‖ e) where: blockhash = unpredictable until mined, immutable after PolCommit_e = commitment to current policy state H = cryptographic hash (BLAKE2B)
```

{% endcode %}

{% code overflow="wrap" %}

```angular-ts
MOTION PLAN DERIVATION
π_e = F(Σ_e, Rand_e) // Network motion ω_e = G(Ω_e, Rand_e) // Storage motion RAVID_e = (π_e, ω_e) // Complete motion plan
```

{% endcode %}

{% code overflow="wrap" %}

```angular-ts
// EPOCH TRANSITION PSEUDOCODE

function computeEpochMotion(blockNumber, currentState):
    // Calculate epoch index
    epoch = floor((blockNumber - GENESIS_BLOCK) / BLOCKS_PER_EPOCH)

    // Get entropy from blockchain
    boundaryBlock = GENESIS_BLOCK + (epoch * BLOCKS_PER_EPOCH)
    blockhash = ethereum.getBlockHash(boundaryBlock)

    // Derive epoch randomness
    policyCommit = hash(currentState.policies)
    epochEntropy = BLAKE2B(blockhash || policyCommit || epoch)

    // Compute motion plans (deterministic!)
    networkMotion = deriveNetworkRoutes(currentState.network, epochEntropy)
    storageMotion = deriveShardPlacements(currentState.storage, epochEntropy)

    return {
        epoch: epoch,
        entropy: epochEntropy,
        networkPlan: networkMotion,
        storagePlan: storageMotion
    }

// Security Property: All honest nodes compute identical plans
// because they see same blockhash and have same state
```

{% endcode %}

> **Security Amplification Theorem**\
> \
> After k epochs: Pr\[successful attack] ≤ (1/2²⁵⁶)ᵏ\
> \
> Attack difficulty grows EXPONENTIALLY because each epoch requires a new attack vector. Previous reconnaissance becomes stale.
