Skip to content

Conversation

MegaRedHand
Copy link
Collaborator

@MegaRedHand MegaRedHand commented Sep 23, 2025

Motivation

Hive tests are good for wide coverage, but having our own suite will let us iterate faster, adding our own regression tests or even fuzzing.

Description

This PR adds a new crate under tooling/reorgs with a reorgs testing framework. The README of the crate includes instructions on how to run:

First, compile the ethrex binary if you haven't already:

cargo build --workspace --bin ethrex

Then, run the reorg tests using:

cargo run

You can run a custom binary by specifying the path:

cargo run -- /path/to/your/binary

The package already includes a simple reorg test with two chains and a node going back and forth between the two, and another test similar to the reorg tests in Hive's "ethereum/engine" simulation, which does a reorg multiple blocks deep without sending all of the side-chain blocks to the node under test.

@MegaRedHand MegaRedHand changed the title test: add reorg testing framework test(l1): add reorg testing framework Sep 23, 2025
@github-actions github-actions bot added the L1 Ethereum client label Sep 23, 2025
Copy link

github-actions bot commented Sep 23, 2025

Lines of code report

Total lines added: 507
Total lines removed: 0
Total lines changed: 507

Detailed view
+----------------------------------------+-------+------+
| File                                   | Lines | Diff |
+----------------------------------------+-------+------+
| ethrex/tooling/reorgs/src/main.rs      | 148   | +148 |
+----------------------------------------+-------+------+
| ethrex/tooling/reorgs/src/simulator.rs | 359   | +359 |
+----------------------------------------+-------+------+

Comment on lines +240 to +254
name: Reorg Tests
runs-on: ubuntu-latest
if: ${{ github.event_name != 'merge_group' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Rust Environment
uses: ./.github/actions/setup-rust

- name: Compile ethrex binary
run: cargo build --bin ethrex

- name: Run reorg tests
run: cd tooling/reorgs && cargo run

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

To fix the problem, we should explicitly set a permissions block in the workflow to restrict the GITHUB_TOKEN permissions to the minimum needed. This can be set either at the workflow root or for individual jobs. As the workflow doesn't appear to require any write permissions (e.g., none of the steps push code, modify issues, or interact with pull requests), the safest minimal starting point is contents: read. This should be added at the top level of the workflow YAML file (immediately after the name and on sections, before jobs:), which will apply to all jobs that do not specify their own permissions block.

No additional imports, methods, or definitions are needed for this YAML change.

Suggested changeset 1
.github/workflows/pr-main_l1.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/pr-main_l1.yaml b/.github/workflows/pr-main_l1.yaml
--- a/.github/workflows/pr-main_l1.yaml
+++ b/.github/workflows/pr-main_l1.yaml
@@ -8,6 +8,9 @@
     paths-ignore:
       - "crates/l2/**" # Behind a feature flag not used in this workflow
 
+permissions:
+  contents: read
+
 concurrency:
   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
   cancel-in-progress: true
EOF
@@ -8,6 +8,9 @@
paths-ignore:
- "crates/l2/**" # Behind a feature flag not used in this workflow

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Copilot is powered by AI and may make mistakes. Always verify output.
@MegaRedHand MegaRedHand marked this pull request as ready for review September 23, 2025 22:11
@MegaRedHand MegaRedHand requested a review from a team as a code owner September 23, 2025 22:11
@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 22:11
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Sep 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a comprehensive reorg testing framework for the L1 chain, providing infrastructure to test chain reorganization scenarios. The implementation includes a simulator that can spawn multiple nodes, orchestrate blockchain operations, and verify reorg behavior.

Key changes:

  • Adds a complete reorg testing framework with node simulation capabilities
  • Implements chain manipulation tools for testing fork scenarios
  • Integrates reorg tests into the CI pipeline for automated testing

Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tooling/reorgs/src/simulator.rs Core simulator implementation with node management and chain utilities
tooling/reorgs/src/main.rs Main test runner with specific reorg test scenarios
tooling/reorgs/README.md Documentation for running the reorg tests
tooling/reorgs/Cargo.toml Package configuration and dependencies
crates/networking/rpc/types/payload.rs Adds PartialEq and Eq traits to PayloadValidationStatus
crates/networking/rpc/types/fork_choice.rs Adds Clone and Copy traits to ForkChoiceState
cmd/ethrex/cli.rs Adds Clone trait to Options struct
Cargo.toml Includes new reorgs package in workspace
.github/workflows/pr-main_l1.yaml Adds reorg tests to CI pipeline

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MegaRedHand MegaRedHand added this pull request to the merge queue Sep 26, 2025
Merged via the queue into main with commit 1c41473 Sep 26, 2025
39 checks passed
@MegaRedHand MegaRedHand deleted the add-reorg-framework branch September 26, 2025 16:32
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1 Ethereum client
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants