diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..d308228d379 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,209 @@ +version: 2.1 + +# Runs this fork's validation workflows through pinned act because GitHub Actions is disabled. +# Pull requests and branch pushes run the PR checks; merge queues add stage.yml. Event metadata is +# generated once per CircleCI revision and shared by all shards. +# +# The read-only GitHub token is exposed to PR code, so its CircleCI context must remain +# restricted to trusted contributors. Keep CircleCI auto-cancellation enabled. +# +# The act binary, checksum, and runner image are pinned. Compiler caches are no-ops because +# act's local cache is not reusable across these machines; Pages plumbing is skipped after the +# validation build. Lint and unit jobs are distributed; other workflows run up to four jobs. +# +# Excluded: pr-title.yml, label-pr.yml, and the privileged cyclops-audit.yml integration. + +jobs: + prepare-act-event: + machine: + image: ubuntu-2404:2025.09.1 + resource_class: medium + steps: + - checkout + - run: + name: Snapshot GitHub event + command: | + mkdir -p /tmp/act-event + if ! .circleci/prepare-act-event.sh; then + echo "GitHub event preparation failed; act shards will report the failure" | + tee /tmp/act-event/failed + fi + - persist_to_workspace: + root: /tmp/act-event + paths: + - . + + act: + parameters: + wf: + type: string + job: + type: string + default: "" + concurrent_jobs: + type: integer + default: 4 + machine: + image: ubuntu-2404:2025.09.1 + resource_class: xlarge + steps: + - checkout + - attach_workspace: + at: /tmp/act-event + - run: + name: Check event snapshot + command: | + if [ -f /tmp/act-event/failed ]; then + cat /tmp/act-event/failed >&2 + exit 1 + fi + - run: + name: Install pinned act + command: | + set -euo pipefail + readonly ACT_VERSION="0.2.89-action-cache-fix.1" + readonly ACT_RELEASE="v0.2.89-action-cache-fix.4" + readonly ACT_BINARY="act_Linux_x86_64" + readonly ACT_SHA256="28bfcf1502f59a834b14f2fb23c39e5b253c2234d875592b5aa0a175f9674dce" + curl --fail --silent --show-error --location \ + "https://github.com/ethereum-optimism/act/releases/download/${ACT_RELEASE}/${ACT_BINARY}" \ + --output "/tmp/${ACT_BINARY}" + echo "${ACT_SHA256} /tmp/${ACT_BINARY}" | sha256sum --check + sudo install -m 0755 "/tmp/${ACT_BINARY}" /usr/local/bin/act + test "$(act --version)" = "act version ${ACT_VERSION}" + - run: + name: Stub unsupported non-check actions + command: | + mkdir -p /tmp/noop-action + printf '%s\n' \ + 'name: noop' \ + 'description: disabled service plumbing under act' \ + 'inputs:' \ + ' cache-on-failure: {required: false}' \ + ' cache-targets: {required: false}' \ + 'runs:' \ + ' using: composite' \ + ' steps:' \ + ' - run: echo "Service plumbing disabled under act"' \ + ' shell: bash' \ + > /tmp/noop-action/action.yml + - run: + name: Run << parameters.wf >> via act + no_output_timeout: 45m + command: | + set -euo pipefail + event_path=/tmp/act-event/github-event.json + event_name="$(jq -er 'if .pull_request then "pull_request" elif .merge_group then "merge_group" elif .ref and .after then "push" else error("unsupported event") end' "$event_path")" + base_ref="$(jq -r '(.pull_request.base.ref // .merge_group.base_ref // "") | sub("^refs/heads/"; "")' "$event_path")" + target_job="<< parameters.job >>" + # Validate documentation without entering Pages deployment on branch pushes. + if [ "<< parameters.wf >>" = "book.yml" ]; then + target_job=build + fi + act_job=() + if [ -n "$target_job" ]; then + case "$target_job" in + crate-checks-*) + partition="${target_job#crate-checks-}" + if [[ ! "$partition" =~ ^[1-9][0-9]*$ ]]; then + echo "invalid crate-checks partition: $partition" >&2 + exit 1 + fi + act_job=(-j crate-checks --matrix "partition:${partition}") + ;; + *) + act_job=(-j "$target_job") + ;; + esac + fi + + act_env=(--env "RUSTC_WRAPPER=" --env "GITHUB_BASE_REF=${base_ref}") + if [ "<< parameters.wf >>" = "unit.yml" ] && [ "$target_job" = "state" ]; then + # EF tests use Rayon internally, so unrestricted nextest processes multiply + # runnable threads and starve valid_blocks past its upstream timeout. + act_env+=(--env "NEXTEST_TEST_THREADS=2") + fi + if [ "$event_name" != "pull_request" ]; then + act_env+=( + --env "GITHUB_REF=refs/heads/${CIRCLE_BRANCH}" + --env "GITHUB_SHA=${CIRCLE_SHA1}" + ) + fi + + act "$event_name" -W ".github/workflows/<< parameters.wf >>" \ + "${act_job[@]}" \ + --eventpath "$event_path" \ + -P "ubuntu-latest=catthehacker/ubuntu@sha256:b839c14c4410998529ec18f951262bdf87a2b23bc1467304d07b491b9455e074" \ + --concurrent-jobs << parameters.concurrent_jobs >> \ + "${act_env[@]}" \ + -s GITHUB_TOKEN="${MISE_GITHUB_TOKEN:?missing restricted read-only GitHub token}" \ + --local-repository "mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696=/tmp/noop-action" \ + --local-repository "Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4=/tmp/noop-action" \ + --local-repository "actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d=/tmp/noop-action" \ + --local-repository "actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9=/tmp/noop-action" + +workflows: + reth-act: + jobs: + - prepare-act-event: + context: + - circleci-repo-readonly-authenticated-github-token + - act: + context: + - circleci-repo-readonly-authenticated-github-token + name: "act-<< matrix.wf >>" + requires: + - prepare-act-event + matrix: + parameters: + wf: + - book.yml + - compact.yml + - e2e.yml + - grafana.yml + - integration.yml + - lint-actions.yml + - stage.yml + - act: + wf: lint.yml + concurrent_jobs: 1 + context: + - circleci-repo-readonly-authenticated-github-token + name: "act-lint-<< matrix.job >>" + requires: + - prepare-act-event + matrix: + parameters: + job: + - clippy-binaries + - clippy + - wasm + - riscv + - crate-checks-1 + - crate-checks-2 + - crate-checks-3 + - msrv + - docs + - fmt + - udeps + - book + - typos + - check-toml + - grafana + - no-test-deps + - feature-propagation + - deny + - act: + wf: unit.yml + concurrent_jobs: 1 + context: + - circleci-repo-readonly-authenticated-github-token + name: "act-unit-<< matrix.job >>" + requires: + - prepare-act-event + matrix: + parameters: + job: + - test + - state + - doc diff --git a/.circleci/prepare-act-event.sh b/.circleci/prepare-act-event.sh new file mode 100755 index 00000000000..99cccb27f3c --- /dev/null +++ b/.circleci/prepare-act-event.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +set -euo pipefail + +readonly OUTPUT_DIR="${ACT_EVENT_OUTPUT_DIR:-/tmp/act-event}" +readonly EVENT_PATH="${OUTPUT_DIR}/github-event.json" + +mkdir -p "$OUTPUT_DIR" +rm -f "$EVENT_PATH" + +: "${CIRCLE_SHA1:?missing CircleCI revision}" +: "${CIRCLE_PROJECT_USERNAME:?missing CircleCI project owner}" +: "${CIRCLE_PROJECT_REPONAME:?missing CircleCI project repository}" + +repository="${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" + +if [[ "${CIRCLE_BRANCH:-}" == gh-readonly-queue/* ]]; then + event_name="merge_group" +elif [[ -n "${CIRCLE_PULL_REQUEST:-}" ]]; then + event_name="pull_request" +else + event_name="push" +fi + +case "$event_name" in + pull_request) + : "${CIRCLE_PULL_REQUEST:?pull-request trigger must provide CIRCLE_PULL_REQUEST}" + pr_number="${CIRCLE_PULL_REQUEST##*/}" + if [[ ! "$pr_number" =~ ^[1-9][0-9]*$ ]]; then + echo "invalid pull-request URL: ${CIRCLE_PULL_REQUEST}" >&2 + exit 1 + fi + + pull_request_path="${OUTPUT_DIR}/pull-request.json" + curl --fail --silent --show-error --location \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${MISE_GITHUB_TOKEN:?missing restricted read-only GitHub token}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${repository}/pulls/${pr_number}" > "$pull_request_path" + + event_head_sha="$(jq -er '.head.sha' "$pull_request_path")" + if [[ "$event_head_sha" != "$CIRCLE_SHA1" ]]; then + echo "PR head does not match CircleCI revision: ${CIRCLE_SHA1} != ${event_head_sha}" >&2 + exit 1 + fi + + jq '{ + action: "synchronize", + number: .number, + pull_request: ., + repository: .base.repo, + sender: .user + }' "$pull_request_path" > "$EVENT_PATH" + base_ref="$(jq -er '.base.ref | select(length > 0)' "$pull_request_path")" + head_ref="$(jq -er '.head.ref | select(length > 0)' "$pull_request_path")" + echo "act event: pull_request #${pr_number}, ${head_ref} -> ${base_ref}" + ;; + push) + : "${CIRCLE_BRANCH:?push trigger must provide CIRCLE_BRANCH}" + jq -n \ + --arg ref "refs/heads/${CIRCLE_BRANCH}" \ + --arg after "$CIRCLE_SHA1" \ + '{ref: $ref, after: $after}' > "$EVENT_PATH" + echo "act event: push ${CIRCLE_BRANCH} at ${CIRCLE_SHA1}" + ;; + merge_group) + : "${CIRCLE_BRANCH:?merge-queue trigger must provide CIRCLE_BRANCH}" + if [[ ! "$CIRCLE_BRANCH" =~ ^gh-readonly-queue/(.+)/pr-([1-9][0-9]*)-[^/]+$ ]]; then + echo "merge_group requires a gh-readonly-queue//pr-- branch, got: ${CIRCLE_BRANCH}" >&2 + exit 1 + fi + base_ref="${BASH_REMATCH[1]}" + + if ! base_sha="$(git rev-parse "${CIRCLE_SHA1}^1" 2>/dev/null)"; then + git fetch --no-tags --depth=2 origin "$CIRCLE_SHA1" + base_sha="$(git rev-parse "${CIRCLE_SHA1}^1")" + fi + + jq -n \ + --arg head_sha "$CIRCLE_SHA1" \ + --arg head_ref "refs/heads/${CIRCLE_BRANCH}" \ + --arg base_sha "$base_sha" \ + --arg base_ref "refs/heads/${base_ref}" \ + --arg repository "$repository" \ + --arg repository_name "$CIRCLE_PROJECT_REPONAME" \ + --arg repository_owner "$CIRCLE_PROJECT_USERNAME" \ + '{ + action: "checks_requested", + merge_group: { + head_sha: $head_sha, + head_ref: $head_ref, + base_sha: $base_sha, + base_ref: $base_ref + }, + repository: { + full_name: $repository, + name: $repository_name, + owner: {login: $repository_owner} + } + }' > "$EVENT_PATH" + echo "act event: merge_group ${CIRCLE_BRANCH} -> ${base_ref} at ${base_sha}" + ;; +esac diff --git a/.github/scripts/check_rv32imac.sh b/.github/scripts/check_rv32imac.sh index 4e477cdbed1..988a95a3309 100755 --- a/.github/scripts/check_rv32imac.sh +++ b/.github/scripts/check_rv32imac.sh @@ -32,7 +32,7 @@ trap 'rm -rf -- "$tmpdir"' EXIT INT TERM for crate in "${crates_to_check[@]}"; do outfile="$tmpdir/$crate.log" - if cargo +stable build -p "$crate" --target riscv32imac-unknown-none-elf --no-default-features --color never >"$outfile" 2>&1; then + if cargo build -p "$crate" --target riscv32imac-unknown-none-elf --no-default-features --color never >"$outfile" 2>&1; then echo "✅ $crate" else echo "❌ $crate" diff --git a/.github/scripts/check_wasm.sh b/.github/scripts/check_wasm.sh index 13bea47cfea..376b1fac7cf 100755 --- a/.github/scripts/check_wasm.sh +++ b/.github/scripts/check_wasm.sh @@ -109,7 +109,7 @@ for crate in "${crates[@]}"; do fi outfile="$tmpdir/$crate.log" - if cargo +stable build -p "$crate" --target wasm32-wasip1 --no-default-features --color never >"$outfile" 2>&1; then + if cargo build -p "$crate" --target wasm32-wasip1 --no-default-features --color never >"$outfile" 2>&1; then echo "✅ $crate" else echo "❌ $crate" diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index c8cea3e8832..707ff64874e 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -40,6 +40,8 @@ jobs: - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2026-07-14 - name: Build docs run: cd docs/vocs && bash scripts/build-cargo-docs.sh diff --git a/.github/workflows/compact.yml b/.github/workflows/compact.yml index 86f2592881a..80014d3793b 100644 --- a/.github/workflows/compact.yml +++ b/.github/workflows/compact.yml @@ -1,6 +1,6 @@ # Ensures that `Compact` codec changes are backwards compatible. # -# 1) checkout `main` +# 1) checkout the PR base, or the selected release for maintenance-branch pushes # 2) randomly generate and serialize to disk many different type vectors with `Compact` (eg. Header, Transaction, etc) # 3) checkout `pr` # 4) deserialize previously generated test vectors @@ -35,6 +35,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: @@ -42,9 +44,11 @@ jobs: - name: Checkout base uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ github.base_ref || 'main' }} + # Use v2.5.2's commit: the fork carries its history but does not mirror upstream tags. + # The maintenance branch must decode its release's data, not unreleased main formats. + ref: ${{ github.base_ref || (github.ref == 'refs/heads/optimism' && '5a6940e351fed80458fe6c9da8581cbe4b8bd036' || 'main') }} persist-credentials: false - # On `main` branch, generates test vectors and serializes them to disk using `Compact`. + # On the comparison base, generate test vectors and serialize them to disk using `Compact`. - name: Generate compact vectors run: | ${{ matrix.bin }} -- test-vectors compact --write diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1abce78da42..bb1ca111517 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -35,6 +35,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: @@ -70,6 +72,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 591bc31304e..9dde9163659 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -42,6 +42,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - name: Install Geth run: .github/scripts/install_geth.sh - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 @@ -85,6 +87,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: tool: nextest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 562185f766b..59626fb4442 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,6 +33,7 @@ jobs: - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@clippy with: + toolchain: nightly-2026-07-14 components: clippy - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 @@ -61,6 +62,7 @@ jobs: - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@nightly with: + toolchain: nightly-2026-07-14 components: clippy - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 @@ -80,8 +82,10 @@ jobs: with: persist-credentials: false - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable with: + toolchain: "1.97.0" target: wasm32-wasip1 - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: @@ -93,7 +97,7 @@ jobs: - uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1 - name: Run Wasm checks run: | - sudo apt update && sudo apt install gcc-multilib + sudo apt update && sudo apt install --yes gcc-multilib .github/scripts/check_wasm.sh riscv: @@ -108,6 +112,7 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - uses: dtolnay/rust-toolchain@stable with: + toolchain: "1.97.0" target: riscv32imac-unknown-none-elf - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: @@ -137,6 +142,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: tool: cargo-hack @@ -182,6 +189,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2026-07-14 - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: @@ -205,6 +214,7 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - uses: dtolnay/rust-toolchain@nightly with: + toolchain: nightly-2026-07-14 components: rustfmt - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - name: Run fmt @@ -223,6 +233,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2026-07-14 - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: @@ -245,6 +257,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2026-07-14 - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: @@ -307,6 +321,8 @@ jobs: persist-credentials: false - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - name: Ensure no arbitrary or proptest dependency on default build run: cargo tree --package reth -e=features,no-dev | grep -Eq "arbitrary|proptest" && exit 1 || exit 0 @@ -322,6 +338,8 @@ jobs: persist-credentials: false - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7 diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 8d0e2bf9d04..5b5d5d9eddf 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -39,6 +39,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 74986cbb3b9..465747462c3 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -42,6 +42,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: @@ -97,6 +99,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2.85.2 with: tool: nextest @@ -121,6 +125,8 @@ jobs: - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - run: .github/scripts/install_llvm.sh ubuntu - uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.97.0" - uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: diff --git a/Cargo.lock b/Cargo.lock index b33be037034..f33ed1c6760 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1573,9 +1573,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "aws-lc-rs" -version = "1.16.3" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec6fb3fe69024a75fa7e1bfb48aa6cf59706a101658ea01bfd33b2b248a038f" +checksum = "b281d307588d634de920874890732659e2e7672f72b5e10e81badc1a8a83621e" dependencies = [ "aws-lc-sys", "untrusted 0.7.1", @@ -1584,14 +1584,15 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.40.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50037ee5e1e41e7b8f9d161680a725bd1626cb6f8c7e901f91f942850852fe7" +checksum = "9bff6c3b54fad79a2e60b8102caf565819711497c1f5f092f49508e2f5c31b27" dependencies = [ "cc", "cmake", "dunce", "fs_extra", + "pkg-config", ] [[package]] @@ -3269,7 +3270,7 @@ dependencies = [ [[package]] name = "ef-test-runner" -version = "2.4.1" +version = "2.5.2" dependencies = [ "clap", "ef-tests", @@ -3277,7 +3278,7 @@ dependencies = [ [[package]] name = "ef-tests" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -3730,7 +3731,7 @@ dependencies = [ [[package]] name = "example-full-contract-state" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "eyre", @@ -3848,7 +3849,7 @@ dependencies = [ [[package]] name = "exex-subscription" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "clap", @@ -4373,9 +4374,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.14" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" +checksum = "a9f37a958b41b3b19ee2707c06439c0e9e547e847223eb791ecb0cb821c65e27" dependencies = [ "atomic-waker", "bytes", @@ -7661,7 +7662,7 @@ checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7" [[package]] name = "reth" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-node-bindings", "alloy-primitives", @@ -7711,7 +7712,7 @@ dependencies = [ [[package]] name = "reth-basic-payload-builder" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7737,7 +7738,7 @@ dependencies = [ [[package]] name = "reth-bb" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7784,7 +7785,7 @@ dependencies = [ [[package]] name = "reth-chain-state" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7815,7 +7816,7 @@ dependencies = [ [[package]] name = "reth-chainspec" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-consensus", @@ -7835,7 +7836,7 @@ dependencies = [ [[package]] name = "reth-cli" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-genesis", "clap", @@ -7847,7 +7848,7 @@ dependencies = [ [[package]] name = "reth-cli-commands" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-consensus", @@ -7937,7 +7938,7 @@ dependencies = [ [[package]] name = "reth-cli-runner" -version = "2.4.1" +version = "2.5.2" dependencies = [ "reth-tasks", "tokio", @@ -7946,7 +7947,7 @@ dependencies = [ [[package]] name = "reth-cli-util" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8000,7 +8001,7 @@ dependencies = [ [[package]] name = "reth-config" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "eyre", @@ -8018,7 +8019,7 @@ dependencies = [ [[package]] name = "reth-consensus" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -8031,7 +8032,7 @@ dependencies = [ [[package]] name = "reth-consensus-common" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8045,7 +8046,7 @@ dependencies = [ [[package]] name = "reth-consensus-debug-client" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8069,7 +8070,7 @@ dependencies = [ [[package]] name = "reth-db" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8105,7 +8106,7 @@ dependencies = [ [[package]] name = "reth-db-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8133,7 +8134,7 @@ dependencies = [ [[package]] name = "reth-db-common" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-genesis", @@ -8164,7 +8165,7 @@ dependencies = [ [[package]] name = "reth-db-models" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8180,7 +8181,7 @@ dependencies = [ [[package]] name = "reth-discv4" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -8206,7 +8207,7 @@ dependencies = [ [[package]] name = "reth-discv5" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -8231,7 +8232,7 @@ dependencies = [ [[package]] name = "reth-dns-discovery" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-primitives", @@ -8259,7 +8260,7 @@ dependencies = [ [[package]] name = "reth-downloaders" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8297,7 +8298,7 @@ dependencies = [ [[package]] name = "reth-e2e-test-utils" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8353,7 +8354,7 @@ dependencies = [ [[package]] name = "reth-ecies" -version = "2.4.1" +version = "2.5.2" dependencies = [ "aes", "alloy-primitives", @@ -8379,7 +8380,7 @@ dependencies = [ [[package]] name = "reth-engine-local" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8401,7 +8402,7 @@ dependencies = [ [[package]] name = "reth-engine-primitives" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8427,7 +8428,7 @@ dependencies = [ [[package]] name = "reth-engine-tree" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -8497,7 +8498,7 @@ dependencies = [ [[package]] name = "reth-engine-util" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8526,7 +8527,7 @@ dependencies = [ [[package]] name = "reth-era" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8551,7 +8552,7 @@ dependencies = [ [[package]] name = "reth-era-downloader" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "bytes", @@ -8569,7 +8570,7 @@ dependencies = [ [[package]] name = "reth-era-utils" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -8600,7 +8601,7 @@ dependencies = [ [[package]] name = "reth-errors" -version = "2.4.1" +version = "2.5.2" dependencies = [ "reth-consensus", "reth-execution-errors", @@ -8610,7 +8611,7 @@ dependencies = [ [[package]] name = "reth-eth-wire" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-consensus", @@ -8648,7 +8649,7 @@ dependencies = [ [[package]] name = "reth-eth-wire-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-consensus", @@ -8676,7 +8677,7 @@ dependencies = [ [[package]] name = "reth-ethereum" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-rpc-types-engine", "alloy-rpc-types-eth", @@ -8716,7 +8717,7 @@ dependencies = [ [[package]] name = "reth-ethereum-cli" -version = "2.4.1" +version = "2.5.2" dependencies = [ "clap", "eyre", @@ -8739,7 +8740,7 @@ dependencies = [ [[package]] name = "reth-ethereum-consensus" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8755,7 +8756,7 @@ dependencies = [ [[package]] name = "reth-ethereum-engine-primitives" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8771,7 +8772,7 @@ dependencies = [ [[package]] name = "reth-ethereum-forks" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eip2124", "alloy-hardforks 0.4.7", @@ -8784,7 +8785,7 @@ dependencies = [ [[package]] name = "reth-ethereum-payload-builder" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8813,7 +8814,7 @@ dependencies = [ [[package]] name = "reth-ethereum-primitives" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8834,7 +8835,7 @@ dependencies = [ [[package]] name = "reth-etl" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "rayon", @@ -8844,7 +8845,7 @@ dependencies = [ [[package]] name = "reth-evm" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -8870,7 +8871,7 @@ dependencies = [ [[package]] name = "reth-evm-ethereum" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8895,7 +8896,7 @@ dependencies = [ [[package]] name = "reth-execution-cache" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "fixed-cache", @@ -8913,7 +8914,7 @@ dependencies = [ [[package]] name = "reth-execution-errors" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-evm", "alloy-primitives", @@ -8925,7 +8926,7 @@ dependencies = [ [[package]] name = "reth-execution-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8946,7 +8947,7 @@ dependencies = [ [[package]] name = "reth-exex" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -8991,7 +8992,7 @@ dependencies = [ [[package]] name = "reth-exex-test-utils" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "eyre", @@ -9022,7 +9023,7 @@ dependencies = [ [[package]] name = "reth-exex-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -9039,7 +9040,7 @@ dependencies = [ [[package]] name = "reth-fs-util" -version = "2.4.1" +version = "2.5.2" dependencies = [ "serde", "serde_json", @@ -9048,7 +9049,7 @@ dependencies = [ [[package]] name = "reth-invalid-block-hooks" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9079,7 +9080,7 @@ dependencies = [ [[package]] name = "reth-ipc" -version = "2.4.1" +version = "2.5.2" dependencies = [ "bytes", "futures", @@ -9101,7 +9102,7 @@ dependencies = [ [[package]] name = "reth-libmdbx" -version = "2.4.1" +version = "2.5.2" dependencies = [ "bitflags 2.13.0", "byteorder", @@ -9118,7 +9119,7 @@ dependencies = [ [[package]] name = "reth-mdbx-sys" -version = "2.4.1" +version = "2.5.2" dependencies = [ "bindgen", "cc", @@ -9126,7 +9127,7 @@ dependencies = [ [[package]] name = "reth-metrics" -version = "2.4.1" +version = "2.5.2" dependencies = [ "futures", "libc", @@ -9139,7 +9140,7 @@ dependencies = [ [[package]] name = "reth-net-banlist" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "ipnet", @@ -9147,7 +9148,7 @@ dependencies = [ [[package]] name = "reth-net-nat" -version = "2.4.1" +version = "2.5.2" dependencies = [ "futures-util", "if-addrs", @@ -9161,7 +9162,7 @@ dependencies = [ [[package]] name = "reth-network" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -9230,7 +9231,7 @@ dependencies = [ [[package]] name = "reth-network-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9254,7 +9255,7 @@ dependencies = [ [[package]] name = "reth-network-p2p" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -9278,7 +9279,7 @@ dependencies = [ [[package]] name = "reth-network-peers" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -9295,7 +9296,7 @@ dependencies = [ [[package]] name = "reth-network-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eip2124", "humantime-serde", @@ -9308,7 +9309,7 @@ dependencies = [ [[package]] name = "reth-nippy-jar" -version = "2.4.1" +version = "2.5.2" dependencies = [ "anyhow", "bincode", @@ -9326,7 +9327,7 @@ dependencies = [ [[package]] name = "reth-node-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-rpc-types-engine", "eyre", @@ -9349,7 +9350,7 @@ dependencies = [ [[package]] name = "reth-node-builder" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9420,7 +9421,7 @@ dependencies = [ [[package]] name = "reth-node-core" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9476,7 +9477,7 @@ dependencies = [ [[package]] name = "reth-node-ethereum" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-contract", @@ -9545,7 +9546,7 @@ dependencies = [ [[package]] name = "reth-node-ethstats" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9568,7 +9569,7 @@ dependencies = [ [[package]] name = "reth-node-events" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9591,7 +9592,7 @@ dependencies = [ [[package]] name = "reth-node-metrics" -version = "2.4.1" +version = "2.5.2" dependencies = [ "bytes", "eyre", @@ -9620,7 +9621,7 @@ dependencies = [ [[package]] name = "reth-node-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "reth-chainspec", "reth-db-api", @@ -9631,7 +9632,7 @@ dependencies = [ [[package]] name = "reth-payload-builder" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9654,7 +9655,7 @@ dependencies = [ [[package]] name = "reth-payload-builder-primitives" -version = "2.4.1" +version = "2.5.2" dependencies = [ "pin-project", "reth-payload-primitives", @@ -9665,7 +9666,7 @@ dependencies = [ [[package]] name = "reth-payload-primitives" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -9689,7 +9690,7 @@ dependencies = [ [[package]] name = "reth-payload-util" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9698,7 +9699,7 @@ dependencies = [ [[package]] name = "reth-payload-validator" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-rpc-types-engine", @@ -9740,7 +9741,7 @@ dependencies = [ [[package]] name = "reth-provider" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -9751,6 +9752,7 @@ dependencies = [ "assert_matches", "eyre", "itertools 0.14.0", + "libc", "metrics", "notify", "parking_lot", @@ -9794,7 +9796,7 @@ dependencies = [ [[package]] name = "reth-prune" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9825,7 +9827,7 @@ dependencies = [ [[package]] name = "reth-prune-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "arbitrary", @@ -9845,7 +9847,7 @@ dependencies = [ [[package]] name = "reth-revm" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -9861,7 +9863,7 @@ dependencies = [ [[package]] name = "reth-rpc" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -9941,7 +9943,7 @@ dependencies = [ [[package]] name = "reth-rpc-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-genesis", @@ -9971,7 +9973,7 @@ dependencies = [ [[package]] name = "reth-rpc-builder" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-network", @@ -10029,7 +10031,7 @@ dependencies = [ [[package]] name = "reth-rpc-convert" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-evm", @@ -10049,7 +10051,7 @@ dependencies = [ [[package]] name = "reth-rpc-e2e-tests" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-genesis", "alloy-rpc-types-engine", @@ -10069,7 +10071,7 @@ dependencies = [ [[package]] name = "reth-rpc-engine-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10105,7 +10107,7 @@ dependencies = [ [[package]] name = "reth-rpc-eth-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -10151,7 +10153,7 @@ dependencies = [ [[package]] name = "reth-rpc-eth-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-chains", "alloy-consensus", @@ -10203,7 +10205,7 @@ dependencies = [ [[package]] name = "reth-rpc-layer" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-rpc-types-engine", "http", @@ -10220,7 +10222,7 @@ dependencies = [ [[package]] name = "reth-rpc-server-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10250,7 +10252,7 @@ dependencies = [ [[package]] name = "reth-stages" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10312,7 +10314,7 @@ dependencies = [ [[package]] name = "reth-stages-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10346,7 +10348,7 @@ dependencies = [ [[package]] name = "reth-stages-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "arbitrary", @@ -10362,7 +10364,7 @@ dependencies = [ [[package]] name = "reth-static-file" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "assert_matches", @@ -10385,7 +10387,7 @@ dependencies = [ [[package]] name = "reth-static-file-types" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "clap", @@ -10403,7 +10405,7 @@ dependencies = [ [[package]] name = "reth-storage-api" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eip7928", @@ -10430,7 +10432,7 @@ dependencies = [ [[package]] name = "reth-storage-errors" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-eips", "alloy-primitives", @@ -10446,7 +10448,7 @@ dependencies = [ [[package]] name = "reth-storage-overlay" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10475,7 +10477,7 @@ dependencies = [ [[package]] name = "reth-storage-rpc-provider" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10504,7 +10506,7 @@ dependencies = [ [[package]] name = "reth-tasks" -version = "2.4.1" +version = "2.5.2" dependencies = [ "crossbeam-utils", "dashmap", @@ -10524,7 +10526,7 @@ dependencies = [ [[package]] name = "reth-testing-utils" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10540,7 +10542,7 @@ dependencies = [ [[package]] name = "reth-tokio-util" -version = "2.4.1" +version = "2.5.2" dependencies = [ "tokio", "tokio-stream", @@ -10549,7 +10551,7 @@ dependencies = [ [[package]] name = "reth-tracing" -version = "2.4.1" +version = "2.5.2" dependencies = [ "clap", "eyre", @@ -10568,7 +10570,7 @@ dependencies = [ [[package]] name = "reth-tracing-otlp" -version = "2.4.1" +version = "2.5.2" dependencies = [ "base64 0.22.1", "clap", @@ -10586,7 +10588,7 @@ dependencies = [ [[package]] name = "reth-transaction-pool" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10637,7 +10639,7 @@ dependencies = [ [[package]] name = "reth-trie" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10669,7 +10671,7 @@ dependencies = [ [[package]] name = "reth-trie-common" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -10701,7 +10703,7 @@ dependencies = [ [[package]] name = "reth-trie-db" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -10728,7 +10730,7 @@ dependencies = [ [[package]] name = "reth-trie-parallel" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-evm", "alloy-primitives", @@ -10756,7 +10758,7 @@ dependencies = [ [[package]] name = "reth-trie-sparse" -version = "2.4.1" +version = "2.5.2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -11376,9 +11378,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.38" +version = "0.23.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f9466fb2c14ea04357e91413efb882e2a6d4a406e625449bc0a5d360d53a21" +checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" dependencies = [ "aws-lc-rs", "log", @@ -11462,9 +11464,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.103.13" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "aws-lc-rs", "ring", diff --git a/Cargo.toml b/Cargo.toml index b23f6556a63..d6d61f1b3e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "2.4.1" +version = "2.5.2" edition = "2024" rust-version = "1.95" license = "MIT OR Apache-2.0" diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index f0bb957fb3f..2995071a77e 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -710,17 +710,24 @@ where /// Blocks until the next event that can safely be processed is ready. /// - /// A pending persisted handoff only accepts the notification that all active payload builds - /// have finished. This keeps queued engine messages from starting replacement payload jobs - /// before the handoff can reclaim the in-memory overlay. Otherwise, uses biased selection to - /// prioritize persistence completion to update in-memory state and unblock further writes. + /// A pending persisted handoff keeps processing engine messages while prioritizing the + /// notification that all active payload builds have finished. This keeps the engine responsive + /// without reclaiming the in-memory overlay while a payload job may still access it. Otherwise, + /// uses biased selection to prioritize persistence completion to update in-memory state and + /// unblock further writes. fn wait_for_event(&mut self) -> LoopEvent { if self.pending_persisted_handoff.is_some() { self.metrics.engine.backpressure_active.set(0.0); - return match self.payload_build_finished.recv() { - Ok(()) => LoopEvent::PayloadBuildFinished, - Err(_) => LoopEvent::Disconnected, - }; + return crossbeam_channel::select_biased! { + recv(self.payload_build_finished) -> result => match result { + Ok(()) => LoopEvent::PayloadBuildFinished, + Err(_) => LoopEvent::Disconnected, + }, + recv(self.incoming) -> msg => match msg { + Ok(m) => LoopEvent::EngineMessage(m), + Err(_) => LoopEvent::Disconnected, + }, + } } // Take ownership of persistence rx if present diff --git a/crates/engine/tree/src/tree/precompile_cache.rs b/crates/engine/tree/src/tree/precompile_cache.rs index e868cca8485..23146ca3914 100644 --- a/crates/engine/tree/src/tree/precompile_cache.rs +++ b/crates/engine/tree/src/tree/precompile_cache.rs @@ -14,6 +14,9 @@ use tracing::error; /// Default max cache size for [`PrecompileCache`] const MAX_CACHE_SIZE: u32 = 1024 * 1024; +/// Maximum calldata size to cache for a precompile. +const MAX_PRECOMPILE_CACHE_INPUT_SIZE: usize = 2 * 1024; + /// Stores caches for each precompile. #[derive(Debug, Clone, Default)] pub struct PrecompileCacheMap(Arc, FbBuildHasher<20>>>) @@ -179,7 +182,9 @@ where } fn call(&self, input: PrecompileInput<'_>) -> PrecompileResult { - if let Some(entry) = &self.cache.get(input.data, self.spec_id.clone()) && + let cacheable_input = input.data.len() <= MAX_PRECOMPILE_CACHE_INPUT_SIZE; + if cacheable_input && + let Some(entry) = &self.cache.get(input.data, self.spec_id.clone()) && input.gas >= entry.gas_used() { self.increment_by_one_precompile_cache_hits(); @@ -193,7 +198,7 @@ where match &result { // Only successful outputs are cacheable. Non-success statuses and errors must execute // again instead of poisoning the cache for subsequent calls. - Ok(output) if output.is_success() => { + Ok(output) if cacheable_input && output.is_success() => { // Sanity-check precompile output to ensure that it does not affect state gas in any // way. // diff --git a/crates/engine/tree/src/tree/tests.rs b/crates/engine/tree/src/tree/tests.rs index 53cbf1d4e5f..c2e517db218 100644 --- a/crates/engine/tree/src/tree/tests.rs +++ b/crates/engine/tree/src/tree/tests.rs @@ -709,7 +709,7 @@ fn persistence_handoff_waits_for_active_payload_jobs() { } #[test] -fn pending_persisted_handoff_blocks_engine_messages_until_payload_build_finishes() { +fn pending_persisted_handoff_keeps_engine_messages_responsive() { let blocks: Vec<_> = TestBlockBuilder::eth().get_executed_blocks(1..4).collect(); let mut test_harness = TestHarness::with_config( MAINNET.clone(), @@ -732,34 +732,23 @@ fn pending_persisted_handoff_blocks_engine_messages_until_payload_build_finishes .unwrap(); assert!(test_harness.tree.pending_persisted_handoff.is_some()); - // Forkchoice updates received while the handoff is pending could start replacement payload - // builds and keep the final completion notification from reaching the tree. Queue a generic - // engine message to prove the gate leaves every message upstream until then. + // Engine messages remain processable while the handoff waits for the active payload build. test_harness.to_tree_tx.send(FromEngine::Event(FromOrchestrator::BackfillSyncStarted)).unwrap(); + assert_matches!( + test_harness.tree.wait_for_event(), + super::LoopEvent::EngineMessage(FromEngine::Event(FromOrchestrator::BackfillSyncStarted)) + ); + assert!(test_harness.tree.pending_persisted_handoff.is_some()); + assert!(test_harness.tree.state.tree_state.contains_hash(&persisted.hash)); - let (started_tx, started_rx) = std::sync::mpsc::sync_channel(0); - let (event_tx, event_rx) = std::sync::mpsc::sync_channel(1); - std::thread::scope(|scope| { - let tree = &mut test_harness.tree; - scope.spawn(move || { - started_tx.send(()).unwrap(); - event_tx - .send(matches!(tree.wait_for_event(), super::LoopEvent::PayloadBuildFinished)) - .unwrap(); - }); - - started_rx.recv().unwrap(); - assert!( - event_rx.recv_timeout(Duration::from_millis(100)).is_err(), - "a pending handoff must prevent queued engine messages from being processed" - ); - - drop(payload_build); - assert_eq!(event_rx.recv_timeout(Duration::from_secs(1)), Ok(true)); - }); - + // Once the final lease drops, its completion is prioritized over queued engine messages so the + // handoff gets the first opportunity to reclaim the overlay. + test_harness.to_tree_tx.send(FromEngine::Event(FromOrchestrator::BackfillSyncStarted)).unwrap(); + drop(payload_build); + assert_matches!(test_harness.tree.wait_for_event(), super::LoopEvent::PayloadBuildFinished); test_harness.tree.on_payload_build_finished().unwrap(); assert!(test_harness.tree.pending_persisted_handoff.is_none()); + assert!(!test_harness.tree.state.tree_state.contains_hash(&persisted.hash)); assert_matches!( test_harness.tree.wait_for_event(), super::LoopEvent::EngineMessage(FromEngine::Event(FromOrchestrator::BackfillSyncStarted)) diff --git a/crates/exex/exex/src/wal/mod.rs b/crates/exex/exex/src/wal/mod.rs index 0836e15b55a..e96d8b6cd3e 100644 --- a/crates/exex/exex/src/wal/mod.rs +++ b/crates/exex/exex/src/wal/mod.rs @@ -113,13 +113,14 @@ where /// Fills the block cache with the notifications from the storage. #[instrument(skip(self))] fn fill_block_cache(&self) -> WalResult<()> { - let Some(files_range) = self.storage.files_range()? else { return Ok(()) }; - self.next_file_id.store(files_range.end() + 1, Ordering::Relaxed); + let file_ids = self.storage.file_ids()?; + let Some(last_file_id) = file_ids.last() else { return Ok(()) }; + self.next_file_id.store(last_file_id + 1, Ordering::Relaxed); let mut block_cache = self.block_cache.write(); let mut notifications_size = 0; - for entry in self.storage.iter_notifications(files_range) { + for entry in self.storage.iter_notifications(file_ids) { let (file_id, size, notification) = entry?; notifications_size += size; @@ -198,11 +199,9 @@ where fn iter_notifications( &self, ) -> WalResult>> + '_>> { - let Some(range) = self.storage.files_range()? else { - return Ok(Box::new(std::iter::empty())) - }; - - Ok(Box::new(self.storage.iter_notifications(range).map(|entry| Ok(entry?.2)))) + Ok(Box::new( + self.storage.iter_notifications(self.storage.file_ids()?).map(|entry| Ok(entry?.2)), + )) } } @@ -238,6 +237,7 @@ mod tests { use crate::wal::{cache::CachedBlock, error::WalResult, Wal}; use alloy_primitives::B256; use itertools::Itertools; + use reth_ethereum_primitives::EthPrimitives; use reth_exex_types::ExExNotification; use reth_provider::Chain; use reth_testing_utils::generators::{ @@ -246,13 +246,11 @@ mod tests { use std::{collections::BTreeMap, sync::Arc}; fn read_notifications(wal: &Wal) -> WalResult> { - wal.inner.storage.files_range()?.map_or(Ok(Vec::new()), |range| { - wal.inner - .storage - .iter_notifications(range) - .map(|entry| entry.map(|(_, _, n)| n)) - .collect() - }) + wal.inner + .storage + .iter_notifications(wal.inner.storage.file_ids()?) + .map(|entry| entry.map(|(_, _, n)| n)) + .collect() } fn sort_committed_blocks( @@ -522,4 +520,44 @@ mod tests { Ok(()) } + + #[test] + fn test_finalize_with_sparse_file_ids() -> eyre::Result<()> { + let mut rng = generators::rng(); + + let temp_dir = tempfile::tempdir()?; + let wal = Wal::::new(&temp_dir)?; + + let blocks = random_block_range(&mut rng, 0..=5, BlockRangeParams::default()) + .into_iter() + .map(|block| block.try_recover()) + .collect::, _>>()?; + let chain = |range: std::ops::RangeInclusive| { + Arc::new(Chain::new(blocks[range].to_vec(), Default::default(), BTreeMap::new())) + }; + + let commit_to_four = ExExNotification::ChainCommitted { new: chain(1..=4) }; + let revert_to_two = ExExNotification::ChainReverted { old: chain(2..=4) }; + let commit_two = ExExNotification::ChainCommitted { new: chain(2..=2) }; + let commit_to_five = ExExNotification::ChainCommitted { new: chain(3..=5) }; + + wal.commit(&commit_to_four)?; + wal.commit(&revert_to_two)?; + wal.commit(&commit_two)?; + wal.commit(&commit_to_five)?; + assert_eq!(wal.inner.storage.file_ids()?, vec![0, 1, 2, 3]); + + // File 2 has a lower maximum block than the surrounding notifications, so finalizing it + // leaves a gap in the file ID sequence. + wal.finalize((blocks[2].number, blocks[2].hash()).into())?; + assert_eq!(wal.inner.storage.file_ids()?, vec![0, 1, 3]); + + let wal = Wal::::new(&temp_dir)?; + assert_eq!(read_notifications(&wal)?, vec![commit_to_four, revert_to_two, commit_to_five]); + + wal.commit(&commit_two)?; + assert_eq!(wal.inner.storage.file_ids()?, vec![0, 1, 3, 4]); + + Ok(()) + } } diff --git a/crates/exex/exex/src/wal/storage.rs b/crates/exex/exex/src/wal/storage.rs index 8c36e3f624d..45363130c23 100644 --- a/crates/exex/exex/src/wal/storage.rs +++ b/crates/exex/exex/src/wal/storage.rs @@ -1,6 +1,5 @@ use std::{ fs::File, - ops::RangeInclusive, path::{Path, PathBuf}, }; @@ -69,12 +68,9 @@ where } } - /// Returns the range of file IDs in the storage. - /// - /// If there are no files in the storage, returns `None`. - pub(super) fn files_range(&self) -> WalResult>> { - let mut min_id = None; - let mut max_id = None; + /// Returns the file IDs in the storage in ascending order. + pub(super) fn file_ids(&self) -> WalResult> { + let mut file_ids = Vec::new(); for entry in reth_fs_util::read_dir(&self.path)? { let entry = entry.map_err(|err| WalError::DirEntry(self.path.clone(), err))?; @@ -82,13 +78,12 @@ where if entry.path().extension() == Some(FILE_EXTENSION.as_ref()) { let file_name = entry.file_name(); let file_id = Self::parse_filename(&file_name.to_string_lossy())?; - - min_id = min_id.map_or(Some(file_id), |min_id: u32| Some(min_id.min(file_id))); - max_id = max_id.map_or(Some(file_id), |max_id: u32| Some(max_id.max(file_id))); + file_ids.push(file_id); } } - Ok(min_id.zip(max_id).map(|(min_id, max_id)| min_id..=max_id)) + file_ids.sort_unstable(); + Ok(file_ids) } /// Removes notifications from the storage according to the given list of file IDs. @@ -113,11 +108,11 @@ where Ok((deleted_total, deleted_size)) } - pub(super) fn iter_notifications( - &self, - range: RangeInclusive, - ) -> impl Iterator)>> + '_ { - range.map(move |id| { + pub(super) fn iter_notifications<'a>( + &'a self, + file_ids: impl IntoIterator + 'a, + ) -> impl Iterator)>> + 'a { + file_ids.into_iter().map(move |id| { let (notification, size) = self.read_notification(id)?.ok_or(WalError::FileNotFound(id))?; @@ -316,21 +311,20 @@ mod tests { } #[test] - fn test_files_range() -> eyre::Result<()> { + fn test_file_ids() -> eyre::Result<()> { let temp_dir = tempfile::tempdir()?; let storage: Storage = Storage::new(&temp_dir)?; // Create WAL files File::create(storage.file_path(1))?; - File::create(storage.file_path(2))?; File::create(storage.file_path(3))?; // Create non-WAL files that should be ignored File::create(temp_dir.path().join("0.tmp"))?; File::create(temp_dir.path().join("4.tmp"))?; - // Check files range - assert_eq!(storage.files_range()?, Some(1..=3)); + // Check existing file IDs are returned in order without filling the gap + assert_eq!(storage.file_ids()?, vec![1, 3]); Ok(()) } diff --git a/crates/net/network/src/manager.rs b/crates/net/network/src/manager.rs index 515b27d690b..63255c41daa 100644 --- a/crates/net/network/src/manager.rs +++ b/crates/net/network/src/manager.rs @@ -776,6 +776,10 @@ impl NetworkManager { self.swarm.state_mut().update_fork_id(transition.current); } } + NetworkHandleMessage::SetForkFilter { fork_filter } => { + let fork_id = self.swarm.sessions_mut().set_fork_filter(fork_filter); + self.swarm.state_mut().update_fork_id(fork_id); + } NetworkHandleMessage::GetPeerInfos(tx) => { let _ = tx.send(self.get_peer_infos()); } diff --git a/crates/net/network/src/network.rs b/crates/net/network/src/network.rs index 18f381b3cbf..0ad5356bfee 100644 --- a/crates/net/network/src/network.rs +++ b/crates/net/network/src/network.rs @@ -12,7 +12,7 @@ use reth_eth_wire::{ BlockRangeUpdate, BroadcastPoolTransactions, DisconnectReason, EthNetworkPrimitives, NetworkPrimitives, NewPooledTransactionHashes, SharedTransactions, }; -use reth_ethereum_forks::Head; +use reth_ethereum_forks::{ForkFilter, Head}; use reth_network_api::{ events::{NetworkPeersEvents, PeerEvent, PeerEventStream}, test_utils::{PeersHandle, PeersHandleProvider}, @@ -112,6 +112,18 @@ impl NetworkHandle { self.send_message(NetworkHandleMessage::StatusUpdate { head }); } + /// Replaces the network's active [`ForkFilter`] with `fork_filter`, re-deriving the advertised + /// [`ForkId`](reth_ethereum_forks::ForkId) for future handshakes and updating the discovery + /// ENR entry. + /// + /// This lets a running node adopt a fork schedule that changed at runtime (e.g. an + /// L1-signalled upgrade) without a restart. The caller must build `fork_filter` from the + /// updated chain spec advanced to the node's current head, and should do so before the fork's + /// activation timestamp so the node announces the upcoming fork ahead of time. + pub fn set_fork_filter(&self, fork_filter: ForkFilter) { + self.send_message(NetworkHandleMessage::SetForkFilter { fork_filter }); + } + /// Announce a block over devp2p /// /// Caution: in `PoS` this is a noop because new blocks are no longer announced over devp2p. @@ -497,6 +509,11 @@ impl NetworkSyncUpdater for NetworkHandle { fn update_block_range(&self, update: reth_eth_wire::BlockRangeUpdate) { self.send_message(NetworkHandleMessage::InternalBlockRangeUpdate(update)); } + + /// Replaces the active fork filter to adopt a runtime fork-schedule change. + fn set_fork_filter(&self, fork_filter: ForkFilter) { + self.send_message(NetworkHandleMessage::SetForkFilter { fork_filter }); + } } impl BlockDownloaderProvider for NetworkHandle { @@ -614,6 +631,11 @@ pub(crate) enum NetworkHandleMessage), /// Gets `PeerInfo` for the specified peer IDs. diff --git a/crates/net/network/src/session/mod.rs b/crates/net/network/src/session/mod.rs index db95a71d984..a70a72742f4 100644 --- a/crates/net/network/src/session/mod.rs +++ b/crates/net/network/src/session/mod.rs @@ -263,6 +263,23 @@ impl SessionManager { transition } + /// Replaces the active [`ForkFilter`] with a newly derived one and returns the resulting + /// [`ForkId`]. + /// + /// This is used to adopt a fork schedule that changed at runtime (e.g. an L1-signalled + /// upgrade) without restarting the node. The caller is expected to build `fork_filter` from + /// the updated chain spec already advanced to the node's current head, so that + /// [`ForkFilter::current`] reflects the correct [`ForkId`] immediately. + /// + /// Every subsequent handshake clones this filter and advertises the returned [`ForkId`], so + /// the node's advertised fork identity stays aligned with the rules it now enforces. Existing + /// active sessions are not revalidated here; see [`SessionManager::active_sessions`]. + pub(crate) fn set_fork_filter(&mut self, fork_filter: ForkFilter) -> ForkId { + self.fork_filter = fork_filter; + self.status.forkid = self.fork_filter.current(); + self.status.forkid + } + /// An incoming TCP connection was received. This starts the authentication process to turn this /// stream into an active peer session. /// diff --git a/crates/net/p2p/src/sync.rs b/crates/net/p2p/src/sync.rs index 77b97116d19..6770c5d12a2 100644 --- a/crates/net/p2p/src/sync.rs +++ b/crates/net/p2p/src/sync.rs @@ -1,6 +1,6 @@ //! Traits used when interacting with the sync status of the network. -use alloy_eips::eip2124::Head; +use alloy_eips::eip2124::{ForkFilter, Head}; use reth_eth_wire_types::BlockRangeUpdate; /// A type that provides information about whether the node is currently syncing and the network is @@ -31,6 +31,17 @@ pub trait NetworkSyncUpdater: std::fmt::Debug + Send + Sync + 'static { /// Updates the advertised block range. fn update_block_range(&self, update: BlockRangeUpdate); + + /// Replaces the node's active [`ForkFilter`] to adopt a fork schedule that changed at runtime + /// (e.g. an L1-signalled upgrade) without a restart. + /// + /// The caller must build `fork_filter` from the updated chain spec advanced to the node's + /// current head, and should do so before the fork's activation timestamp so the node + /// announces the upcoming fork ahead of time. Defaults to a no-op for updaters that do not + /// track a fork filter. + fn set_fork_filter(&self, fork_filter: ForkFilter) { + let _ = fork_filter; + } } /// The state the network is currently in when it comes to synchronization. diff --git a/crates/payload/basic/src/lib.rs b/crates/payload/basic/src/lib.rs index f9c18dfc00d..fb67012927f 100644 --- a/crates/payload/basic/src/lib.rs +++ b/crates/payload/basic/src/lib.rs @@ -416,7 +416,7 @@ where trace!(target: "payload_builder", id = %self.config.payload_id(), "spawn new payload build task"); let (tx, rx) = oneshot::channel(); let cancel = CancelOnDrop::default(); - let _cancel = cancel.clone(); + let pending_cancel = cancel.clone(); let guard = self.payload_task_guard.clone(); let payload_config = self.config.clone(); let best_payload = self.best_payload.payload().cloned(); @@ -446,7 +446,7 @@ where }); }); - self.pending_block = Some(PendingPayload { _cancel, payload: rx }); + self.pending_block = Some(PendingPayload { cancel: pending_cancel, payload: rx }); } } @@ -567,6 +567,10 @@ where let mut empty_payload = None; if best_payload.is_none() { + if let Some(pending) = maybe_better.as_ref() { + pending.cancel.request_finalization(); + } + debug!(target: "payload_builder", id=%self.config.payload_id(), "no best payload yet to resolve, building empty payload"); let args = BuildArguments { @@ -734,8 +738,8 @@ where /// A future that resolves to the result of the block building job. #[derive(Debug)] pub struct PendingPayload

{ - /// The marker to cancel the job on drop - _cancel: CancelOnDrop, + /// Cancels the job on drop and carries cooperative control signals. + cancel: CancelOnDrop, /// The channel to send the result to. payload: oneshot::Receiver, PayloadBuilderError>>, } @@ -746,7 +750,7 @@ impl

PendingPayload

{ cancel: CancelOnDrop, payload: oneshot::Receiver, PayloadBuilderError>>, ) -> Self { - Self { _cancel: cancel, payload } + Self { cancel, payload } } } diff --git a/crates/revm/src/cancelled.rs b/crates/revm/src/cancelled.rs index e535882355c..591cd3d376d 100644 --- a/crates/revm/src/cancelled.rs +++ b/crates/revm/src/cancelled.rs @@ -1,26 +1,53 @@ use alloc::sync::Arc; -use core::sync::atomic::AtomicBool; +use core::sync::atomic::{AtomicBool, AtomicU8, Ordering}; -/// A marker that can be used to cancel execution. +/// Payload building is still in progress. +const RUNNING: u8 = 0; +/// Payload building should stop accepting transactions and seal the accumulated work. +const FINALIZATION_REQUESTED: u8 = 1; +/// Payload building should stop and discard the accumulated work. +const CANCELLED: u8 = 2; + +/// Cancels execution on drop and supports cooperative finalization. /// /// If dropped, it will set the `cancelled` flag to true. /// /// This is most useful when a payload job needs to be cancelled. #[derive(Default, Clone, Debug)] -pub struct CancelOnDrop(Arc); +pub struct CancelOnDrop(Arc); // === impl CancelOnDrop === impl CancelOnDrop { + /// Returns true if the current work should be interrupted. + pub fn is_interrupted(&self) -> bool { + self.0.load(Ordering::Relaxed) != RUNNING + } + /// Returns true if the job was cancelled. pub fn is_cancelled(&self) -> bool { - self.0.load(core::sync::atomic::Ordering::Relaxed) + self.0.load(Ordering::Relaxed) == CANCELLED + } + + /// Requests that the current work be finalized without cancelling it. + pub fn request_finalization(&self) { + let _ = self.0.compare_exchange( + RUNNING, + FINALIZATION_REQUESTED, + Ordering::Relaxed, + Ordering::Relaxed, + ); + } + + /// Returns true if finalization was requested. + pub fn is_finalization_requested(&self) -> bool { + self.0.load(Ordering::Relaxed) == FINALIZATION_REQUESTED } } impl Drop for CancelOnDrop { fn drop(&mut self) { - self.0.store(true, core::sync::atomic::Ordering::Relaxed); + self.0.store(CANCELLED, Ordering::Relaxed); } } @@ -55,6 +82,7 @@ mod tests { #[test] fn test_default_cancelled() { let c = CancelOnDrop::default(); + assert!(!c.is_interrupted()); assert!(!c.is_cancelled()); } @@ -122,6 +150,7 @@ mod tests { drop(cancel); // The cloned instance should now see the cancelled flag as true + assert!(cloned_cancel.is_interrupted()); assert!(cloned_cancel.is_cancelled()); } @@ -140,8 +169,31 @@ mod tests { // Drop one clone - this should cancel all instances drop(clone1); + assert!(cancel.is_interrupted()); assert!(cancel.is_cancelled()); assert!(clone2.is_cancelled()); assert!(clone3.is_cancelled()); } + + #[test] + fn test_cancel_on_drop_finalization_request() { + let cancel = CancelOnDrop::default(); + let clone = cancel.clone(); + + cancel.request_finalization(); + + assert!(clone.is_interrupted()); + assert!(clone.is_finalization_requested()); + assert!(!clone.is_cancelled()); + + drop(cancel); + + assert!(clone.is_cancelled()); + assert!(!clone.is_finalization_requested()); + + clone.request_finalization(); + + assert!(clone.is_cancelled()); + assert!(!clone.is_finalization_requested()); + } } diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 060d2365298..5b4842ce303 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -21,8 +21,10 @@ use futures::Future; use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks}; use reth_errors::{ProviderError, RethError}; use reth_evm::{ - block::BlockExecutor, env::BlockEnvironment, execute::BlockBuilder, ConfigureEvm, Evm, - EvmEnvFor, EvmFor, HaltReasonFor, InspectorFor, TransactionEnvMut, TxEnvFor, + block::{BlockExecutor, TxResult}, + env::BlockEnvironment, + execute::BlockBuilder, + ConfigureEvm, Evm, EvmEnvFor, EvmFor, HaltReasonFor, InspectorFor, TransactionEnvMut, TxEnvFor, }; use reth_node_api::BlockBody; use reth_primitives_traits::Recovered; @@ -717,9 +719,10 @@ pub trait Call: executor.execute_transaction(block_tx).map_err(Self::Error::from_eth_err)?; } - let tx_env = RpcNodeCore::evm_config(&this).tx_env(tx); - - let res = executor.evm_mut().transact(tx_env).map_err(Self::Error::from_evm_err)?; + let res = executor + .execute_transaction_without_commit(tx) + .map_err(Self::Error::from_eth_err)? + .into_result(); drop(executor); f(tx_info, res, db) }) @@ -732,8 +735,11 @@ pub trait Call: /// /// This executes on a caller provided EVM, so the target transaction can then be run on the /// same EVM, keeping any block-scoped EVM state intact. The EVM's inspector configuration is - /// left untouched; see - /// [`Trace::inspect_transaction_in_block`] to replay without inspection and trace the target. + /// left untouched. + /// + /// This bypasses the block executor, so it misses any chain-specific per-transaction + /// settlement the executor applies. To replay a block's own transactions, use + /// [`Trace::replay_block_until`] or [`Trace::inspect_transaction_in_block`] instead. /// /// If the target index is greater than or equal to the iterator length, all transactions are /// replayed. diff --git a/crates/rpc/rpc-eth-api/src/helpers/trace.rs b/crates/rpc/rpc-eth-api/src/helpers/trace.rs index a2662147624..08fc7d3328a 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/trace.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/trace.rs @@ -8,13 +8,17 @@ use alloy_rpc_types_eth::{BlockId, TransactionInfo}; use futures::Future; use reth_errors::RethError; use reth_evm::{ - block::BlockExecutor, evm::EvmFactoryExt, tracing::TracingCtx, ConfigureEvm, Evm, EvmEnvFor, - EvmFor, HaltReasonFor, InspectorFor, IntoTxEnv, TxEnvFor, + block::{BlockExecutor, BlockExecutorFor, TxResult}, + ConfigureEvm, Evm, EvmEnvFor, EvmFor, HaltReasonFor, InspectorFor, IntoTxEnv, TxEnvFor, }; use reth_primitives_traits::{BlockBody, BlockTy, Recovered, RecoveredBlock}; -use reth_rpc_eth_types::cache::db::StateCacheDb; +use reth_rpc_eth_types::{cache::db::StateCacheDb, EthApiError}; use reth_storage_api::{ProviderBlock, ProviderTx}; -use revm::{context::Block, context_interface::result::ResultAndState}; +use revm::{ + context::Block, + context_interface::result::{ExecutionResult, ResultAndState}, + state::EvmState, +}; use revm_inspectors::tracing::{TracingInspector, TracingInspectorConfig}; use std::sync::Arc; @@ -98,7 +102,7 @@ pub trait Trace: LoadState> + Call { None => return Ok(None), Some(res) => res, }; - let (tx, tx_info) = transaction.split(); + let (_, tx_info) = transaction.split(); // we need to get the state of the parent block because we're essentially replaying the // block the transaction is included in @@ -113,7 +117,6 @@ pub trait Trace: LoadState> + Call { // returns transactions included in a block tx_info.index.expect("transaction_and_block only returns block transactions") as usize, - tx, )?; f(tx_info, inspector, res, db) }) @@ -124,8 +127,9 @@ pub trait Trace: LoadState> + Call { /// Replays all transactions before the target transaction index. /// - /// All transactions before the target transaction are executed and their changes are written to - /// the _runtime_ db ([`StateCacheDb`]). + /// The block's pre-execution changes and all transactions before the target transaction are + /// executed through the block executor, and their changes are written to the _runtime_ db + /// ([`StateCacheDb`]). /// /// If the target index is greater than or equal to the block's transaction count, all /// transactions are replayed. @@ -135,19 +139,25 @@ pub trait Trace: LoadState> + Call { block: &RecoveredBlock>, target_tx_index: usize, ) -> Result<(), Self::Error> { - self.apply_pre_execution_changes(block, db)?; + let mut executor = self + .evm_config() + .executor_for_block(db, block.sealed_block()) + .map_err(RethError::other) + .map_err(Self::Error::from_eth_err)?; + executor.apply_pre_execution_changes().map_err(Self::Error::from_eth_err)?; - let evm_env = self.evm_env_for_header(block.sealed_block().sealed_header())?; - let mut evm = self.evm_config().evm_with_env(db, evm_env); - self.replay_transactions_until_with_evm( - &mut evm, - block.transactions_recovered(), - target_tx_index, - ) + for tx in block.transactions_recovered().take(target_tx_index) { + executor.execute_transaction(tx).map_err(Self::Error::from_eth_err)?; + } + Ok(()) } /// Replays all transactions before the target transaction without inspection, then executes - /// the target transaction with the configured inspector, all on the given EVM. + /// the block's transaction at the target index with the configured inspector, all through the + /// same block executor. + /// + /// The returned [`ResultAndState`] is the executor's, so it includes any chain-specific + /// per-transaction settlement. It is not committed to `db`. #[expect(clippy::type_complexity)] fn inspect_transaction_in_block<'a>( &self, @@ -155,26 +165,68 @@ pub trait Trace: LoadState> + Call { db: &'a mut StateCacheDb, inspector: impl InspectorFor, target_tx_index: usize, - target_tx_env: impl IntoTxEnv>, ) -> Result<(ResultAndState>, EvmEnvFor), Self::Error> { - let block_txs = block.transactions_recovered(); - - self.apply_pre_execution_changes(block, db)?; - let evm_env = self.evm_env_for_header(block.sealed_block().sealed_header())?; - let mut evm = self.evm_config().evm_with_env_and_inspector(db, evm_env, inspector); - - evm.disable_inspector(); - self.replay_transactions_until_with_evm(&mut evm, block_txs, target_tx_index)?; - evm.enable_inspector(); + let mut executor = self.inspected_block_executor(block, db, evm_env.clone(), inspector)?; - let res = evm.transact(target_tx_env).map_err(Self::Error::from_evm_err)?; + let mut block_txs = block.transactions_recovered(); + for tx in block_txs.by_ref().take(target_tx_index) { + executor.execute_transaction(tx).map_err(Self::Error::from_eth_err)?; + } + let target_tx = block_txs.next().ok_or_else(|| { + Self::Error::from_eth_err(EthApiError::InvalidParams(format!( + "tx_index {target_tx_index} out of bounds for block with {} transactions", + block.transaction_count() + ))) + })?; - let (_, evm_env) = evm.finish(); + executor.evm_mut().enable_inspector(); + let res = executor + .execute_transaction_without_commit(target_tx) + .map_err(Self::Error::from_eth_err)? + .into_result(); Ok((res, evm_env)) } + /// Creates a block executor for `block` whose EVM runs the given inspector, and applies the + /// block's pre-execution changes. The inspector is left disabled. + /// + /// Block transactions must be replayed through the executor rather than its EVM: the executor + /// tracks the transaction's position in the block and applies chain-specific per-transaction + /// settlement, such as OP Stack SDM refunds, that a bare EVM replay misses. + #[expect(clippy::type_complexity)] + fn inspected_block_executor<'a, 'db, I>( + &'a self, + block: &'a RecoveredBlock>, + db: &'db mut StateCacheDb, + evm_env: EvmEnvFor, + inspector: I, + ) -> Result< + BlockExecutorFor< + 'a, + ::BlockExecutorFactory, + &'db mut StateCacheDb, + I, + >, + Self::Error, + > + where + I: InspectorFor, + { + let evm_config = self.evm_config(); + let ctx = evm_config + .context_for_block(block.sealed_block()) + .map_err(RethError::other) + .map_err(Self::Error::from_eth_err)?; + let mut evm = evm_config.evm_with_env_and_inspector(db, evm_env, inspector); + evm.disable_inspector(); + + let mut executor = evm_config.create_executor_with_state(evm, ctx); + executor.apply_pre_execution_changes().map_err(Self::Error::from_eth_err)?; + Ok(executor) + } + /// Executes all transactions of a block up to a given index. /// /// If a `highest_index` is given, this will only execute the first `highest_index` @@ -268,38 +320,64 @@ pub trait Trace: LoadState> + Call { let block_timestamp = evm_env.block_env.timestamp().saturating_to(); let base_fee = evm_env.block_env.basefee(); - this.apply_pre_execution_changes(&block, &mut db)?; - // prepare transactions, we do everything upfront to reduce time spent with open // state - let max_transactions = highest_index.map_or_else( - || block.body().transaction_count(), - |highest| { - // we need + 1 because the index is 0-based - highest as usize + 1 - }, - ); + let max_transactions = highest_index + .map_or_else( + || block.body().transaction_count(), + |highest| { + // we need + 1 because the index is 0-based + (highest as usize).saturating_add(1) + }, + ) + .min(block.body().transaction_count()); - let mut idx = 0; + let inspector = inspector_setup(); + let fused_inspector = inspector.clone(); + let mut executor = + this.inspected_block_executor(&block, &mut db, evm_env, inspector)?; + executor.evm_mut().enable_inspector(); - let results = this - .evm_config() - .evm_factory() - .create_tracer(&mut db, evm_env, inspector_setup()) - .try_trace_many(block.transactions_recovered().take(max_transactions), |ctx| { - let tx_info = TransactionInfo { - hash: Some(*ctx.tx.tx_hash()), - index: Some(idx), - block_hash: Some(block_hash), - block_number: Some(block_number), - block_timestamp: Some(block_timestamp), - base_fee: Some(base_fee), - }; - idx += 1; + let mut results = Vec::with_capacity(max_transactions); + let mut transactions = + block.transactions_recovered().take(max_transactions).enumerate().peekable(); + while let Some((idx, tx)) = transactions.next() { + let output = executor + .execute_transaction_without_commit(tx) + .map_err(Self::Error::from_eth_err)?; + let ResultAndState { result, state } = output.result(); - f(tx_info, ctx) - }) - .collect::>()?; + let tx_info = TransactionInfo { + hash: Some(*tx.tx_hash()), + index: Some(idx as u64), + block_hash: Some(block_hash), + block_number: Some(block_number), + block_timestamp: Some(block_timestamp), + base_fee: Some(base_fee), + }; + let mut was_fused = false; + let (db, inspector, _) = executor.evm_mut().components_mut(); + results.push(f( + tx_info, + TracingCtx { + tx, + result: result.clone(), + state, + inspector, + db, + fused_inspector: &fused_inspector, + was_fused: &mut was_fused, + }, + )?); + if !was_fused { + *executor.evm_mut().inspector_mut() = fused_inspector.clone(); + } + + // the state of the last traced transaction is not needed + if transactions.peek().is_some() { + executor.commit_transaction(output); + } + } Ok(Some(results)) }) @@ -404,3 +482,30 @@ pub trait Trace: LoadState> + Call { Ok(()) } } + +/// Context for one transaction of a block traced by [`Trace::trace_block_until_with_inspector`]. +#[derive(Debug)] +pub struct TracingCtx<'a, T, E: Evm> { + /// The transaction that was just executed. + pub tx: T, + /// Result of transaction execution. + pub result: ExecutionResult, + /// State changes after transaction. + pub state: &'a EvmState, + /// Inspector state after transaction. + pub inspector: &'a mut E::Inspector, + /// Database used when executing the transaction, _before_ committing the state changes. + pub db: &'a mut E::DB, + /// Inspector state before any transaction was executed. + fused_inspector: &'a E::Inspector, + /// Whether the inspector was already reset by [`TracingCtx::take_inspector`]. + was_fused: &'a mut bool, +} + +impl> TracingCtx<'_, T, E> { + /// Returns the inspector state of this transaction, resetting the inspector for the next one. + pub fn take_inspector(&mut self) -> E::Inspector { + *self.was_fused = true; + core::mem::replace(self.inspector, self.fused_inspector.clone()) + } +} diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 9860eae2fc7..ff01b500508 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -19,7 +19,11 @@ use parking_lot::RwLock; use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks}; use reth_engine_primitives::ConsensusEngineEvent; use reth_errors::RethError; -use reth_evm::{block::BlockExecutor, execute::Executor, ConfigureEvm, EvmEnvFor}; +use reth_evm::{ + block::{BlockExecutor, TxResult}, + execute::Executor, + ConfigureEvm, EvmEnvFor, +}; use reth_primitives_traits::{ Block as BlockTrait, BlockBody, BlockTy, ReceiptWithBloom, RecoveredBlock, }; @@ -28,7 +32,7 @@ use reth_rpc_api::DebugApiServer; use reth_rpc_convert::RpcTxReq; use reth_rpc_eth_api::{ helpers::{EthTransactions, TraceExt}, - FromEthApiError, FromEvmError, RpcConvert, RpcNodeCore, + FromEthApiError, RpcConvert, RpcNodeCore, }; use reth_rpc_eth_types::{EthApiError, StateCacheDb}; use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult}; @@ -122,20 +126,22 @@ where .spawn_with_state_at_block(block.parent_hash(), move |eth_api, mut db| { let mut results = Vec::with_capacity(block.body().transactions().len()); - eth_api.apply_pre_execution_changes(&block, &mut db)?; - let block_env = evm_env.block_env.clone(); - let mut transactions = block.transactions_recovered().enumerate().peekable(); let inspector = DebugInspector::new(opts).map_err(Eth::Error::from_eth_err)?; - let mut evm = - eth_api.evm_config().evm_with_env_and_inspector(&mut db, evm_env, inspector); + let mut executor = + eth_api.inspected_block_executor(&block, &mut db, evm_env, inspector)?; + executor.evm_mut().enable_inspector(); + + let mut transactions = block.transactions_recovered().enumerate().peekable(); while let Some((index, tx)) = transactions.next() { let tx_env = eth_api.evm_config().tx_env(tx); - let res = evm.transact(tx_env.clone()).map_err(Eth::Error::from_evm_err)?; + let output = executor + .execute_transaction_without_commit(tx) + .map_err(Eth::Error::from_eth_err)?; - let (db, inspector, _) = evm.components_mut(); + let (db, inspector, _) = executor.evm_mut().components_mut(); let result = inspector .get_result( Some(TransactionContext { @@ -145,7 +151,7 @@ where }), &tx_env, &block_env, - &res, + output.result(), db, ) .map_err(Eth::Error::from_eth_err)?; @@ -155,7 +161,7 @@ where inspector.fuse().map_err(Eth::Error::from_eth_err)?; // need to apply the state changes of this transaction before executing the // next transaction - db.commit(res.state) + executor.commit_transaction(output); } } @@ -243,13 +249,8 @@ where let mut inspector = DebugInspector::new(opts).map_err(Eth::Error::from_eth_err)?; let tx_env = eth_api.evm_config().tx_env(&tx); - let (res, evm_env) = eth_api.inspect_transaction_in_block( - &block, - &mut db, - &mut inspector, - index, - tx_env.clone(), - )?; + let (res, evm_env) = + eth_api.inspect_transaction_in_block(&block, &mut db, &mut inspector, index)?; let trace = inspector .get_result( @@ -704,22 +705,24 @@ where .recovered_block(block_hash.into()) .await? .ok_or(EthApiError::HeaderNotFound(block_hash.into()))?; - let evm_env = self.eth_api().evm_env_for_header(block.sealed_block().sealed_header())?; self.eth_api() .spawn_with_state_at_block(block.parent_hash(), move |eth_api, mut db| { // Enable transition tracking so that merge_transitions works db.transition_state = Some(Default::default()); - eth_api.apply_pre_execution_changes(&block, &mut db)?; + let mut executor = eth_api + .evm_config() + .executor_for_block(&mut db, block.sealed_block()) + .map_err(RethError::other) + .map_err(Eth::Error::from_eth_err)?; + executor.apply_pre_execution_changes().map_err(Eth::Error::from_eth_err)?; let mut roots = Vec::with_capacity(block.body().transactions().len()); - let mut evm = eth_api.evm_config().evm_with_env(&mut db, evm_env); for tx in block.transactions_recovered() { - let tx_env = eth_api.evm_config().tx_env(tx); - evm.transact_commit(tx_env).map_err(Eth::Error::from_evm_err)?; + executor.execute_transaction(tx).map_err(Eth::Error::from_eth_err)?; - let state = evm.db_mut(); + let state = executor.evm_mut().db_mut(); // Merge transitions into cumulative bundle_state state.merge_transitions(BundleRetention::PlainState); // Compute state root from the accumulated state changes diff --git a/crates/stages/api/src/pipeline/mod.rs b/crates/stages/api/src/pipeline/mod.rs index 0c2f3b668d6..36a8a6f3c3d 100644 --- a/crates/stages/api/src/pipeline/mod.rs +++ b/crates/stages/api/src/pipeline/mod.rs @@ -585,6 +585,7 @@ impl Pipeline { target: "sync::pipeline", stage = %stage_id, bad_block = %block.block.number, + bad_block_hash = %block.block.hash, "Stage encountered a validation error: {validation_error}" ); @@ -609,6 +610,7 @@ impl Pipeline { target: "sync::pipeline", stage = %stage_id, bad_block = %block.block.number, + bad_block_hash = %block.block.hash, "Stage encountered an execution error: {execution_error}" ); } diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 1ff298889c1..17db3b470e5 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -69,6 +69,9 @@ rayon.workspace = true rocksdb.workspace = true +[target.'cfg(unix)'.dependencies] +libc.workspace = true + [dev-dependencies] reth-db = { workspace = true, features = ["test-utils"] } reth-primitives-traits = { workspace = true, features = ["arbitrary", "test-utils"] } diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index f29f84a5327..df23ce5fda3 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -798,7 +798,25 @@ impl DatabaseProvider>(); - let merged_trie = TrieUpdatesSorted::disjointed_merge_batch(&batch, &mask); + // Sparse-trie streaming emits node updates, while the serial state-root path, + // including fallback, can emit a whole storage-trie wipe. `disjointed_merge_batch` + // rejects wipes, so use the ordered merge. Persisting updates shadowed by the + // masking suffix is redundant but safe: the in-memory overlay still takes + // precedence. + // + // With a revm release containing bluealloy/revm#3863, post-Cancun selfdestructs + // will no longer result in `storage.is_deleted` in serial trie updates. The flag + // remains valid `save_blocks` input when processing pre-Cancun historical data. + let contains_storage_wipe = batch.iter().chain(&mask).any(|updates| { + updates.storage_tries_ref().values().any(|storage| storage.is_deleted) + }); + let merged_trie = if contains_storage_wipe { + TrieUpdatesSorted::merge_batch( + state_trie_blocks.iter().rev().map(|block| block.trie_updates()), + ) + } else { + Arc::new(TrieUpdatesSorted::disjointed_merge_batch(&batch, &mask)) + }; if !merged_trie.is_empty() { self.write_trie_updates_sorted(&merged_trie)?; } @@ -4858,6 +4876,123 @@ mod tests { assert_eq!(masked_entries[0].1.nibbles.0, masked_storage_node); } + #[cfg(feature = "partial-persistence")] + #[test] + fn test_save_blocks_merges_storage_wipe_in_multi_block_batch() { + use reth_trie::{ + updates::{StorageTrieUpdatesSorted, TrieUpdatesSorted}, + BranchNodeCompact, HashedPostStateSorted, + }; + + let factory = create_test_provider_factory(); + factory.set_storage_settings_cache(StorageSettings::v2()); + + let mut test_block_builder = TestBlockBuilder::eth().with_state(); + let genesis = test_block_builder.get_executed_blocks(0..1).next().unwrap(); + let mut blocks: Vec<_> = test_block_builder.get_executed_blocks(1..4).collect(); + let address = B256::with_last_byte(1); + let storage_path = Nibbles::from_nibbles([0x1, 0x2]); + + let provider_rw = factory.provider_rw().unwrap(); + save_genesis(&provider_rw, &genesis).unwrap(); + provider_rw + .write_trie_updates_sorted(&TrieUpdatesSorted::new( + vec![], + B256Map::from_iter([( + address, + StorageTrieUpdatesSorted { + is_deleted: false, + storage_nodes: vec![(storage_path, Some(BranchNodeCompact::default()))], + }, + )]), + )) + .unwrap(); + provider_rw.commit().unwrap(); + + let wipe = TrieUpdatesSorted::new( + vec![], + B256Map::from_iter([( + address, + StorageTrieUpdatesSorted { is_deleted: true, storage_nodes: vec![] }, + )]), + ); + let wipe_block = &blocks[2]; + blocks[2] = ExecutedBlock::new( + Arc::clone(&wipe_block.recovered_block), + Arc::clone(&wipe_block.execution_output), + ComputedTrieData::new(Arc::new(HashedPostStateSorted::default()), Arc::new(wipe)), + ); + + let provider_rw = factory.provider_rw().unwrap(); + let input = SaveBlocksInput::new(blocks, 0, 0, 3, 3); + provider_rw.save_blocks(&input).unwrap(); + provider_rw.commit().unwrap(); + + let provider = factory.provider().unwrap(); + let checkpoint = provider.get_stage_checkpoint(StageId::Finish).unwrap().unwrap(); + assert_eq!(checkpoint.block_number, 3); + let storage_entries = provider + .tx_ref() + .cursor_dup_read::() + .unwrap() + .walk_dup(Some(address), None) + .unwrap() + .collect::, _>>() + .unwrap(); + assert!(storage_entries.is_empty()); + } + + #[cfg(feature = "partial-persistence")] + #[test] + fn test_save_blocks_batches_transient_storage_wipe() { + use alloy_primitives::map::B256Set; + use reth_trie::{updates::TrieUpdates, HashBuilder, HashedPostStateSorted}; + + let factory = create_test_provider_factory(); + factory.set_storage_settings_cache(StorageSettings::v2()); + + let mut test_block_builder = TestBlockBuilder::eth().with_state(); + let genesis = test_block_builder.get_executed_blocks(0..1).next().unwrap(); + let blocks: Vec<_> = test_block_builder.get_executed_blocks(1..4).collect(); + + let provider_rw = factory.provider_rw().unwrap(); + save_genesis(&provider_rw, &genesis).unwrap(); + provider_rw.commit().unwrap(); + + // A contract created and self-destructed in the same transaction leaves an empty whole- + // storage wipe in the trie updates, even though the account never reaches persisted state. + let ephemeral_account = B256::with_last_byte(0x57); + let hashed_state = HashedPostStateSorted::default(); + let mut trie_updates = TrieUpdates::default(); + trie_updates.finalize( + HashBuilder::default(), + Default::default(), + B256Set::from_iter([ephemeral_account]), + ); + let trie_updates = trie_updates.into_sorted(); + assert!(trie_updates.storage_tries_ref()[&ephemeral_account].is_deleted); + let selfdestruct_block = ExecutedBlock::new( + Arc::clone(&blocks[2].recovered_block), + Arc::clone(&blocks[2].execution_output), + ComputedTrieData::new(Arc::new(hashed_state), Arc::new(trie_updates)), + ); + + let provider_rw = factory.provider_rw().unwrap(); + let input = SaveBlocksInput::new( + vec![blocks[0].clone(), blocks[1].clone(), selfdestruct_block], + 0, + 0, + 3, + 3, + ); + provider_rw.save_blocks(&input).unwrap(); + provider_rw.commit().unwrap(); + + let checkpoint = + factory.provider().unwrap().get_stage_checkpoint(StageId::Finish).unwrap().unwrap(); + assert_eq!(checkpoint.block_number, 3); + } + #[cfg(feature = "partial-persistence")] #[test] fn test_save_blocks_partial_cycles_do_not_duplicate_static_file_writes() { diff --git a/crates/storage/provider/src/providers/rocksdb/provider.rs b/crates/storage/provider/src/providers/rocksdb/provider.rs index d7198e7c74a..9fae9514ebd 100644 --- a/crates/storage/provider/src/providers/rocksdb/provider.rs +++ b/crates/storage/provider/src/providers/rocksdb/provider.rs @@ -115,14 +115,22 @@ const DEFAULT_BLOCK_SIZE: usize = 16 * 1024; /// Default max background jobs for `RocksDB` compaction and flushing. const DEFAULT_MAX_BACKGROUND_JOBS: i32 = 6; -/// Default max open file descriptors for `RocksDB`. +/// Max open file descriptors for `RocksDB` when the process limit is low. /// /// Caps the number of SST file handles `RocksDB` keeps open simultaneously. /// Set to 512 to stay within the common default OS `ulimit -n` of 1024, /// leaving headroom for MDBX, static files, and other I/O. -/// `RocksDB` uses an internal table cache and re-opens files on demand, -/// so this has negligible performance impact on read-heavy workloads. -const DEFAULT_MAX_OPEN_FILES: i32 = 512; +const LIMITED_MAX_OPEN_FILES: i32 = 512; + +/// Keeps all `RocksDB` files open and avoids table cache lookups. +const KEEP_ALL_FILES_OPEN: i32 = -1; + +/// Minimum process file descriptor limit for keeping all `RocksDB` files open. +/// +/// Mature archive databases can use tens of thousands of file descriptors. This threshold keeps +/// unlimited mode for hosts configured for that workload while retaining a bounded table cache on +/// systems with low limits. +const HIGH_FILE_DESCRIPTOR_LIMIT: u64 = 128 * 1024; /// Default bytes per sync for `RocksDB` WAL writes (1 MB). const DEFAULT_BYTES_PER_SYNC: u64 = 1_048_576; @@ -234,7 +242,7 @@ impl RocksDBBuilder { options.set_log_level(log_level); - options.set_max_open_files(DEFAULT_MAX_OPEN_FILES); + options.set_max_open_files(select_max_open_files()); // Delete obsolete WAL files immediately after all column families have flushed. // Both set to 0 means "delete ASAP, no archival". @@ -415,7 +423,7 @@ impl RocksDBBuilder { // Open as secondary instance for catch-up capability. // Secondary needs max_open_files = -1 to keep all FDs open. let mut options = options; - options.set_max_open_files(-1); + options.set_max_open_files(KEEP_ALL_FILES_OPEN); let secondary_path = self .path @@ -2879,6 +2887,60 @@ const fn convert_log_level(level: LogLevel) -> rocksdb::LogLevel { } } +/// Selects the `RocksDB` `max_open_files` setting from the current file descriptor limit +/// balancing performance vs. compatibility. +/// +/// A mature database can use tens of thousands of file descriptors. With a +/// finite `max_open_files` value, `RocksDB` performs additional table-cache checks +/// even when enough capacity is available. The value `-1` keeps all table files +/// open and avoids this overhead. +/// +/// During normal startup, Reth raises the soft file descriptor limit to the +/// system hard limit before it opens `RocksDB`. Therefore, we expect the current +/// limit to be the hard limit. A survey of modern Linux distributions shows +/// common default limits of `1024:524288`. +/// +/// We use `-1` only when the current limit is above a conservative threshold. +/// This keeps enough file descriptors for other parts of the process. When the +/// limit is lower or cannot be read, we use a stricter fixed limit. +fn select_max_open_files() -> i32 { + let file_descriptor_limit = current_file_descriptor_limit(); + let max_open_files = max_open_files_for_limit(file_descriptor_limit); + + if max_open_files == LIMITED_MAX_OPEN_FILES { + tracing::warn!( + target: "providers::rocksdb", + ?file_descriptor_limit, + threshold = HIGH_FILE_DESCRIPTOR_LIMIT, + max_open_files, + "RocksDB will not keep all files open; performance may be reduced" + ); + } + + max_open_files +} + +const fn max_open_files_for_limit(file_descriptor_limit: Option) -> i32 { + match file_descriptor_limit { + Some(limit) if limit >= HIGH_FILE_DESCRIPTOR_LIMIT => KEEP_ALL_FILES_OPEN, + _ => LIMITED_MAX_OPEN_FILES, + } +} + +#[cfg(unix)] +#[allow(clippy::useless_conversion)] +fn current_file_descriptor_limit() -> Option { + let mut limit = libc::rlimit { rlim_cur: 0, rlim_max: 0 }; + // SAFETY: `limit` points to initialized writable memory for the kernel to populate. + let result = unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &raw mut limit) }; + (result == 0).then(|| limit.rlim_cur.into()) +} + +#[cfg(not(unix))] +const fn current_file_descriptor_limit() -> Option { + None +} + #[cfg(test)] mod tests { use super::*; @@ -2895,6 +2957,16 @@ mod tests { }; use tempfile::TempDir; + #[test] + fn max_open_files_adapts_to_file_descriptor_limit() { + assert_eq!(max_open_files_for_limit(Some(HIGH_FILE_DESCRIPTOR_LIMIT)), KEEP_ALL_FILES_OPEN); + assert_eq!( + max_open_files_for_limit(Some(HIGH_FILE_DESCRIPTOR_LIMIT - 1)), + LIMITED_MAX_OPEN_FILES + ); + assert_eq!(max_open_files_for_limit(None), LIMITED_MAX_OPEN_FILES); + } + #[test] fn test_with_default_tables_registers_required_column_families() { let temp_dir = TempDir::new().unwrap(); diff --git a/docs/vocs/vocs.config.ts b/docs/vocs/vocs.config.ts index bb8a8fba54b..6aa891ac973 100644 --- a/docs/vocs/vocs.config.ts +++ b/docs/vocs/vocs.config.ts @@ -23,7 +23,7 @@ export default defineConfig({ { text: 'Rustdocs', link: '/docs' }, { text: 'GitHub', link: 'https://github.com/paradigmxyz/reth' }, { - text: 'v2.4.1', + text: 'v2.5.2', items: [ { text: 'Releases',