Skip to content

feat(bench): add replay-reorg command for benchmarking reorgs#23055

Open
decofe wants to merge 2 commits intomainfrom
dcline/replay-reorg-bench
Open

feat(bench): add replay-reorg command for benchmarking reorgs#23055
decofe wants to merge 2 commits intomainfrom
dcline/replay-reorg-bench

Conversation

@decofe
Copy link
Member

@decofe decofe commented Mar 16, 2026

Adds a new reth-bench replay-reorg subcommand that replays a reorg between two existing block hashes.

How it works

Given two competing chain tips (--tip-a and --tip-b), the command:

  1. Walks both tips back to find their common ancestor (number-aligned for efficiency)
  2. Builds fork A as canonical by sending newPayload + forkchoiceUpdated
  3. Imports fork B blocks as side-chain (newPayload only)
  4. Triggers the reorg via a single forkchoiceUpdated switching head to fork B

Reports per-phase and per-call latency, with the reorg FCU latency called out separately.

Flags

  • --tip-a / --tip-b: the two competing chain tip hashes
  • --order a-then-b|b-then-a: which fork to build canonical first (default: a-then-b)
  • --fcu-mode tip-only|per-block: FCU after every block vs only at the tip during canonical build (default: tip-only)
  • --max-depth: cap on ancestor search depth (default: 4096)
  • --reth-new-payload: use reth_newPayload endpoint for server-side timing

Example

reth-bench replay-reorg \\
  --rpc-url http://localhost:8545 \\
  --engine-rpc-url http://localhost:8551 \\
  --jwt-secret ~/.local/share/reth/mainnet/jwt.hex \\
  --tip-a 0xaaa... --tip-b 0xbbb...

Co-Authored-By: Dan Cline 6798349+Rjected@users.noreply.github.com

Prompted by: Dan

Co-Authored-By: Dan Cline <6798349+Rjected@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
reth-bench: minor
---

Added `replay-reorg` subcommand to `reth-bench` for benchmarking chain reorgs. The command discovers the common ancestor of two competing chain tips, builds one fork as canonical via the Engine API, imports the competing fork, then triggers a reorg via `forkchoiceUpdated`. Supports fetching blocks from EL RPC, pre-downloaded JSON files, or a Dora beacon explorer.

Add changelog to commit this to your branch.

Adds --payload-a-file, --payload-b-file for pre-downloaded block JSON,
and --dora-url with --beacon-root-a/b for fetching orphaned blocks from
a Dora beacon explorer. Supports both RPC block and beacon block JSON
formats with automatic detection and beacon→engine format conversion.

Co-Authored-By: Derek Cofausper <256792747+decofe@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019cf80b-6b8b-770a-ad10-e21675226297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants