diff --git a/.circleci/continue/rust-ci.yml b/.circleci/continue/rust-ci.yml
index 23205fe5f79..73d28092315 100644
--- a/.circleci/continue/rust-ci.yml
+++ b/.circleci/continue/rust-ci.yml
@@ -163,6 +163,20 @@ jobs:
command: typos
# No cache save: downloads no crates.
+ # Fails while the reth fork is pinned by anything but an op-- tag. Its own job,
+ # so a PR pinned on a fork PR's commit still runs every other check and is red only here.
+ rust-reth-pin:
+ docker:
+ - image: <>
+ resource_class: small.gen2
+ steps:
+ - checkout-with-mise:
+ checkout-method: blobless
+ - run:
+ name: Check the reth fork is pinned by tag
+ working_directory: rust
+ command: just check-reth-pin
+
# Shared no_std compatibility check job
rust-ci-check-no-std:
parameters:
@@ -1018,6 +1032,10 @@ workflows:
directory: rust
context: *rust-ci-context
+ - rust-reth-pin:
+ context:
+ - circleci-repo-readonly-authenticated-github-token
+
- rust-ci-cargo-tests:
name: rust-tests
directory: rust
@@ -1131,6 +1149,7 @@ workflows:
- rust-deny: terminal
- rust-typos: terminal
- rust-zepter: terminal
+ - rust-reth-pin: terminal
- rust-tests: terminal
- interop-deposits-diff: terminal
- rust-doctest: terminal
diff --git a/rust/UPDATING-RETH.md b/rust/UPDATING-RETH.md
index 0c157a1a68a..dd27683deca 100644
--- a/rust/UPDATING-RETH.md
+++ b/rust/UPDATING-RETH.md
@@ -477,6 +477,12 @@ PR's head commit with `rev = ""` meanwhile. Once the fork PR merges, tag
its merged commit and switch the monorepo PR to the tag before it merges, so
a fork pin on `develop` is always a tag.
+CI enforces this: the required `rust-reth-pin` job (`just check-reth-pin` in
+`rust/`) fails while any crate from the fork resolves through anything but an
+`op--` tag. It runs apart from the other jobs, so a PR on a `rev` pin
+still gets the full CI result and is red only on this check. Keep that PR in
+draft until the switch to the tag.
+
## After the monorepo PR merges
Repin the premium PR's monorepo dependency to the merge commit on `develop`
diff --git a/rust/justfile b/rust/justfile
index 5b22c03ddea..297ac6cf4a5 100644
--- a/rust/justfile
+++ b/rust/justfile
@@ -265,6 +265,33 @@ check-sp1-guest-lock:
exit 1
fi
+# Fail unless every crate from the ethereum-optimism/reth fork resolves through an
+# `op--` tag. A `rev` pin on an open fork PR is fine while both PRs are in
+# development, but not on develop. CI runs this as its own required job, so such a PR
+# still runs every other check. Reads the lockfiles, which `--locked` CI jobs keep in
+# sync with the manifests, so a transitive fork dependency is caught too.
+[script('bash')]
+check-reth-pin:
+ set -euo pipefail
+ # Fail closed: a git or grep error must not read as "no untagged sources".
+ files=$(git ls-files -- '*Cargo.lock')
+ locks=()
+ while IFS= read -r f; do [ -n "$f" ] && locks+=("$f"); done <<< "$files"
+ [ "${#locks[@]}" -gt 0 ] || { echo "error: no Cargo.lock found" >&2; exit 1; }
+ rc=0
+ sources=$(grep -hoE '"git\+https://github\.com/ethereum-optimism/reth(\.git)?[?#][^"]*"' "${locks[@]}") || rc=$?
+ [ "$rc" -le 1 ] || exit "$rc"
+ # `` may contain hyphens, e.g. an upstream pre-release `v2.8.0-rc.1`.
+ untagged=$(printf '%s\n' "$sources" | grep -vE '^$|\?tag=op-[0-9A-Za-z.-]+-[0-9]+#[0-9a-f]{40}"$' | sort -u) || true
+ if [ -n "$untagged" ]; then
+ echo "error: the reth fork is pinned by something other than an op-- tag:" >&2
+ echo "$untagged" | sed 's/^/ /' >&2
+ echo " Before merging: merge the ethereum-optimism/reth PRs this pin points at," >&2
+ echo " tag the merged commit, and pin \`tag = \"op--\"\` in rust/Cargo.toml." >&2
+ echo " See rust/UPDATING-RETH.md, \"Pinning a fork change\"." >&2
+ exit 1
+ fi
+
# Cargo only warns when a [patch.crates-io] entry is unused. Assert that every
# crypto crate used by each guest program resolves exclusively to its SP1 fork.
[script('bash')]