Skip to content

ci: run Lean Hive simulators in CI #1182

ci: run Lean Hive simulators in CI

ci: run Lean Hive simulators in CI #1182

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: ["**"]
workflow_dispatch:
# Cancel in-progress runs when a new commit is pushed to the same PR or branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_NET_RETRY: "10"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.92.0"
components: rustfmt, clippy
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Cargo check
run: cargo check --workspace --all-targets
- name: Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Read the pinned leanSpec commit from the Makefile (single source of truth)
- name: Get leanSpec pinned commit
id: lean-spec
run: echo "commit=$(sed -n 's/^LEAN_SPEC_COMMIT_HASH:= *//p' Makefile)" >> $GITHUB_OUTPUT
- name: Restore test fixtures cache
id: cache-fixtures
uses: actions/cache/restore@v5
with:
path: leanSpec/fixtures
key: leanspec-fixtures-${{ steps.lean-spec.outputs.commit }}
# All fixture generation steps are skipped when the cache hits
- name: Checkout leanSpec at pinned commit
if: steps.cache-fixtures.outputs.cache-hit != 'true'
uses: actions/checkout@v6
with:
repository: leanEthereum/leanSpec
ref: ${{ steps.lean-spec.outputs.commit }}
path: leanSpec
- name: Install uv and Python 3.14
if: steps.cache-fixtures.outputs.cache-hit != 'true'
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "leanSpec/pyproject.toml"
python-version: "3.14"
- name: Sync leanSpec dependencies
if: steps.cache-fixtures.outputs.cache-hit != 'true'
working-directory: leanSpec
run: uv sync --no-progress
- name: Get production keys URL hash
if: steps.cache-fixtures.outputs.cache-hit != 'true'
id: prod-keys-url
working-directory: leanSpec
run: |
URL=$(uv run python -c "from consensus_testing.keys import KEY_DOWNLOAD_URLS; print(KEY_DOWNLOAD_URLS['prod'])")
HASH=$(echo -n "$URL" | sha256sum | awk '{print $1}')
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Restore production keys cache
if: steps.cache-fixtures.outputs.cache-hit != 'true'
id: cache-prod-keys
uses: actions/cache/restore@v5
with:
path: leanSpec/packages/testing/src/consensus_testing/test_keys/prod_scheme
key: prod-keys-${{ steps.prod-keys-url.outputs.hash }}
- name: Download production keys
if: steps.cache-fixtures.outputs.cache-hit != 'true' && steps.cache-prod-keys.outputs.cache-hit != 'true'
working-directory: leanSpec
run: uv run python -m consensus_testing.keys --download --scheme prod
# Save production keys even if a later step fails, so a re-run does
# not have to re-download. See: https://github.com/actions/cache/tree/main/save#always-save-cache
#
# `cache-hit == 'false'` (rather than `!= 'true'`) only matches when
# the restore step actually ran and missed: when fixtures were already
# cached, the restore was skipped and `cache-hit` is empty, so save
# is skipped too.
- name: Save production keys cache
if: always() && steps.cache-prod-keys.outputs.cache-hit == 'false'
uses: actions/cache/save@v5
with:
path: leanSpec/packages/testing/src/consensus_testing/test_keys/prod_scheme
key: ${{ steps.cache-prod-keys.outputs.cache-primary-key }}
- name: Generate test fixtures
if: steps.cache-fixtures.outputs.cache-hit != 'true'
working-directory: leanSpec
run: uv run fill --fork=Devnet --scheme prod -o fixtures -n auto
# Save fixtures even if a later step fails, so a re-run does not
# have to regenerate them. See: https://github.com/actions/cache/tree/main/save#always-save-cache
- name: Save test fixtures cache
if: always() && steps.cache-fixtures.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: leanSpec/fixtures
key: ${{ steps.cache-fixtures.outputs.cache-primary-key }}
# Ensure make sees fixtures as up-to-date (its timestamp must be
# newer than leanSpec/, which intermediate steps may have modified).
- name: Mark fixtures as up-to-date
run: touch leanSpec/fixtures
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.92.0"
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Run tests
run: make test
docker_build:
name: Build Docker
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ethlambda Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
GIT_COMMIT=${{ github.sha }}
GIT_BRANCH=${{ github.ref_name }}
push: false
tags: |
ghcr.io/lambdaclass/ethlambda:devnet3
ghcr.io/lambdaclass/ethlambda:devnet4
outputs: type=docker,dest=/tmp/ethlambda_image.tar
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload image artifacts
uses: actions/upload-artifact@v6
with:
name: ethlambda_image
path: /tmp/ethlambda_image.tar
run-hive:
name: Hive - ${{ matrix.name }}
runs-on: ubuntu-latest
permissions:
contents: read
needs: docker_build
strategy:
fail-fast: false
matrix:
include:
- name: "Lean RPC Compat"
limit: "rpc-compat"
artifact_prefix: lean_rpc_compat
- name: "Lean Sync"
limit: "sync"
artifact_prefix: lean_sync
- name: "Lean Client Interop"
limit: "client-interop"
artifact_prefix: lean_client_interop
- name: "Lean Validation"
limit: "validation"
artifact_prefix: lean_validation
- name: "Lean Gossip"
limit: "gossip"
artifact_prefix: lean_gossip
- name: "Lean ReqResp"
limit: "reqresp"
artifact_prefix: lean_reqresp
- name: "Lean Fork Choice Spec Tests"
limit: "lean-spec-tests-fork-choice"
artifact_prefix: lean_spec_fork_choice
- name: "Lean State Transition Spec Tests"
limit: "lean-spec-tests-state-transition"
artifact_prefix: lean_spec_state_transition
- name: "Lean Verify Signatures Spec Tests"
limit: "lean-spec-tests-verify-signatures"
artifact_prefix: lean_spec_verify_signatures
steps:
- uses: actions/checkout@v6
- name: Download ethlambda image artifact
uses: actions/download-artifact@v6
with:
name: ethlambda_image
path: /tmp
- name: Load image
run: docker load --input /tmp/ethlambda_image.tar
- name: Load hive client config
id: client-config
shell: bash
run: |
{
echo "config<<EOF"
cat .github/config/hive/clients.yaml
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Determine hive flags
id: hive-flags
shell: bash
env:
SIM_LIMIT: ${{ matrix.limit }}
run: |
FLAGS="--sim.parallelism 4 --sim.loglevel 3"
if [[ -n "$SIM_LIMIT" ]]; then
escaped_limit=${SIM_LIMIT//\'/\'\\\'\'}
FLAGS+=" --sim.limit '$escaped_limit'"
fi
echo "flags=$FLAGS" >> "$GITHUB_OUTPUT"
- name: Run Hive Simulation
uses: ethpandaops/hive-github-action@1aa8d73dad34de13afbb3113ab16c1a462d2fbc3 # v0.5.0
with:
hive_repository: ethereum/hive
hive_version: 6f704d0cd8fb4dfd3f635abcc5a3ea6cd395e61b
simulator: lean
client: ethlambda
client_config: ${{ steps.client-config.outputs.config }}
extra_flags: ${{ steps.hive-flags.outputs.flags }}
- name: Check Hive Results For Failures
id: verify-hive-results
if: ${{ success() }}
shell: bash
run: bash ./.github/scripts/check-hive-results.sh src/results
- name: Upload Hive Failure Logs
if: ${{ failure() && steps.verify-hive-results.conclusion == 'failure' }}
uses: actions/upload-artifact@v6
with:
name: hive_failed_logs_${{ matrix.artifact_prefix }}
path: src/results/failed_logs
if-no-files-found: warn