Skip to content

Mock consensus layer (Engine-API driver) for frozen-milestone snap-sync + replay#36

Merged
dmitriy-b merged 1 commit into
feat/add-locust-frameworkfrom
feat/mock-cl-engine-driver
Jun 16, 2026
Merged

Mock consensus layer (Engine-API driver) for frozen-milestone snap-sync + replay#36
dmitriy-b merged 1 commit into
feat/add-locust-frameworkfrom
feat/mock-cl-engine-driver

Conversation

@AnkushinDaniil

Copy link
Copy Markdown
Collaborator

Stacked on top of #34 (base: feat/add-locust-framework).

Why

Post-merge EL clients (Geth, Besu, Reth, Erigon, Nethermind) only snap-sync or execute blocks when a consensus client drives their Engine API. The benchmark framework in #34 starts a real lighthouse-<client> CL for that — but the frozen milestone snapshots this project benchmarks (#21: x1, 1.5×…10× bloated states) have no live chain, so a real CL can't drive them. This adds a minimal Engine-API mock CL that provides the two CL roles #21 needs, generalizing the throwaway geth_*_fcu.py / replay scripts into a tested, version-controlled module.

What

src/mock_cl/ — stdlib + requests only (hand-rolled HS256 JWT, no new deps):

  • PivotDriver (snap-sync mode) — repeatedly sends engine_forkchoiceUpdatedV3 with head=safe=finalized set to a fixed frozen pivot hash, so the target EL snap-syncs to that milestone state. Optional status polling stops the loop once the target reports synced.
  • ReplayDriver (execution mode) — feeds recorded payloads through engine_newPayloadV{1..4} + engine_forkchoiceUpdated, advancing the head and recording per-block latency (newPayload/FCU ms, p50/p95) to CSV.
  • EngineClient — JWT-authed Engine-API client; auto-selects newPayload/FCU versions across Paris→Prague from payload shape.
  • __main__ CLI: pivot, replay, record subcommands.

#21 metric coverage

Mode Unlocks
pivot snap-sync wall time, peak/sustained bandwidth, disk IOPS/throughput, peak/steady RSS, final DB size
replay block-processing time p50/p95/p99, gas/s, CPU%, RSS growth under live head

Orchestrator integration (backward compatible)

  • New nodes.consensus_mode: lighthouse | mock | none (+ a mock_cl: config block). If unset it falls back to the legacy consensus: boolean (true→lighthouse, false→none), so existing configs are unchanged. CONSENSUS_MODE in env/.env overrides.
  • In mock mode the runner launches the pivot driver in the background for the sync phase and tears it down on stop. build_mock_cl_command() is a pure, unit-tested helper.

Nethermind note

NM targets can use --Sync.StaticSnapPivot (NethermindEth/nethermind#11943) as the native pivot alternative (no external driver) — set consensus_mode: none in that case. Documented in the README.

Limitation

record (pulling payloads from eth_getBlockByNumber) is best-effort and cannot recover blob versioned-hashes or parentBeaconBlockRoot, so Cancun+ replay needs a true CL-recorded payload source. Pre-Cancun (V1/V2) replay works directly from record output. Logged + documented.

Tests

uv run pytest -m 'not integration'62 passed (+21 new mock_cl tests; all existing runner/aggregator tests still green). Covers JWT structure/signature, secret loading, version auto-pick, FCU/newPayload param shapes, JSONL payload parsing, ReplayDriver ordering + mid-INVALID raise + CSV, PivotDriver FCU shape, and build_mock_cl_command.

…nap-sync + replay

Post-merge EL clients only snap-sync or execute blocks when a CL drives their
Engine API. Frozen milestone snapshots (the bloated states in #21) have no live
CL, so lighthouse can't drive them. This adds a minimal Engine-API mock CL with
the two CL roles #21 needs:

- PivotDriver: repeated engine_forkchoiceUpdatedV3 to a fixed frozen pivot hash
  -> the EL snap-syncs to that milestone state (snap-sync metrics).
- ReplayDriver: engine_newPayloadV{1..4} + engine_forkchoiceUpdated over
  recorded payloads -> drives execution under live head + per-block latency
  (block-processing p50/p95/p99, gas/s metrics).

EngineClient hand-rolls HS256 JWT (no new deps) and auto-picks newPayload/FCU
versions across Paris..Prague. Wired into the orchestrator via consensus_mode:
lighthouse|mock|none (back-compat: legacy consensus bool still works). Generalizes
the throwaway geth FCU/replay scripts. Nethermind targets can use
--Sync.StaticSnapPivot (nethermind#11943) as the native pivot alternative.
@dmitriy-b dmitriy-b merged commit 7b4aa1f into feat/add-locust-framework Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants