@@ -222,45 +222,74 @@ jobs:
222222 exit 1
223223 fi
224224
225- echo "== Check B: scenarios installed the local EDR build =="
225+ echo "== Check B: each scenario's hardhat resolves the local EDR build =="
226226 found=0
227227 fail=0
228228 for d in "$E2E_CLONE_DIR"/*/; do
229229 [ -d "$d" ] || continue
230- while IFS= read -r pj; do
231- found=1
232- name=$(jq -r .name "$pj")
233- version=$(jq -r .version "$pj")
234- if [ "$version" != "$EDR_VER" ]; then
235- echo "::error::$name in $pj is $version, expected $EDR_VER"
236- fail=1
237- else
238- echo "OK: $name@$version ($pj)"
239- fi
240- done < <(find "$d" \
241- \( -path '*/node_modules/@nomicfoundation/edr/package.json' \
242- -o -path '*/node_modules/@nomicfoundation/edr-linux-x64-gnu/package.json' \) \
243- 2>/dev/null)
244-
245- # yarn Plug'n'Play scenarios have no node_modules; fall back to the lockfile.
246- if [ -f "$d/.pnp.cjs" ] || [ -f "$d/.pnp.loader.mjs" ]; then
247- if grep -rqs -- "$EDR_VER" "$d/yarn.lock"; then
230+ id=$(basename "$d")
231+
232+ # Resolve the EDR that THIS scenario's hardhat loads. Works across
233+ # npm/pnpm/yarn node_modules layouts (Node realpaths pnpm symlinks).
234+ # Nested EDR copies pulled by other dependents (e.g. @1inch/solidity-utils,
235+ # hardhat-network-helpers) are intentionally ignored — only hardhat's
236+ # EDR (the build under test) matters for the benchmark.
237+ read -r hh_ver edr_ver < <(node -e '
238+ const fs = require("node:fs");
239+ const path = require("node:path");
240+ const dir = process.argv[1];
241+ // Resolve a package via its "." export (defined), then walk up to
242+ // its package.json. require.resolve("<pkg>/package.json") is blocked
243+ // by EDR/Hardhat exports maps, so we cannot ask for it directly.
244+ function pkgJsonPath(name, fromDir) {
245+ const main = require.resolve(name, { paths: [fromDir] });
246+ let d = path.dirname(main);
247+ for (;;) {
248+ const cand = path.join(d, "package.json");
249+ if (fs.existsSync(cand)) {
250+ try { if (JSON.parse(fs.readFileSync(cand, "utf8")).name === name) return cand; } catch {}
251+ }
252+ const parent = path.dirname(d);
253+ if (parent === d) throw new Error("package.json for " + name + " not found above " + main);
254+ d = parent;
255+ }
256+ }
257+ try {
258+ const hhPkg = pkgJsonPath("hardhat", dir);
259+ const edrPkg = pkgJsonPath("@nomicfoundation/edr", path.dirname(hhPkg));
260+ const ver = (p) => JSON.parse(fs.readFileSync(p, "utf8")).version;
261+ process.stdout.write(ver(hhPkg) + " " + ver(edrPkg));
262+ } catch (e) { process.stderr.write(String(e.message || e)); }
263+ ' "$d" 2>/tmp/edr-resolve-err) || true
264+
265+ if [ -z "${edr_ver:-}" ]; then
266+ # yarn Plug'n'Play scenarios have no node_modules to resolve through.
267+ if { [ -f "$d/.pnp.cjs" ] || [ -f "$d/.pnp.loader.mjs" ]; } \
268+ && grep -rqs -- "$EDR_VER" "$d/yarn.lock"; then
248269 found=1
249- echo "OK (PnP lockfile): $d"
250- else
251- echo "::warning::PnP scenario $d: $EDR_VER not found in yarn.lock"
270+ echo "OK (PnP lockfile): $id"
271+ continue
252272 fi
273+ echo "::error::$id: could not resolve hardhat's @nomicfoundation/edr ($(cat /tmp/edr-resolve-err))"
274+ fail=1
275+ continue
276+ fi
277+
278+ found=1
279+ if [ "$edr_ver" != "$EDR_VER" ]; then
280+ echo "::error::$id: hardhat@$hh_ver resolves @nomicfoundation/edr@$edr_ver, expected $EDR_VER"
281+ fail=1
282+ else
283+ echo "OK: $id -> hardhat@$hh_ver, @nomicfoundation/edr@$edr_ver"
253284 fi
254285 done
255286
256287 if [ "$found" -eq 0 ]; then
257- echo "::error::No installed @nomicfoundation/edr found in any scenario clone — local EDR was NOT used"
258- exit 1
259- fi
260- if [ "$fail" -ne 0 ]; then
288+ echo "::error::No scenario resolved @nomicfoundation/edr via hardhat — local EDR was NOT used"
261289 exit 1
262290 fi
263- echo "All inspected scenarios use the local EDR build ($EDR_VER)."
291+ [ "$fail" -eq 0 ] || exit 1
292+ echo "All scenarios resolve the local EDR build ($EDR_VER) through hardhat."
264293
265294 # Persist the (possibly partial) benchmark output in the job log so it
266295 # survives the runner's temp-dir cleanup and is available for debugging.
0 commit comments