Skip to content

test: auto-detect live precompiles so base-forge test just works; rename fork->live precompile testing#167

Merged
amiecorso merged 3 commits into
mainfrom
corso/live-precompile-testing
Jun 12, 2026
Merged

test: auto-detect live precompiles so base-forge test just works; rename fork->live precompile testing#167
amiecorso merged 3 commits into
mainfrom
corso/live-precompile-testing

Conversation

@amiecorso

Copy link
Copy Markdown
Collaborator

What

base-forge test against base-std previously failed every setUp with vm.etch: cannot use precompile ... as an argument: base-forge makes the real precompiles present, but BaseTest still etched the Solidity mocks over them unless LIVE_PRECOMPILES=true was set by hand.

This makes the suite detect its world and adapt:

  • Reference mode (stock forge test): precompiles absent -> etch the Solidity mocks -> testing the reference implementation.
  • Live precompile mode (base-forge test, or forge test --fork-url <base-anvil node>): precompiles present -> skip the etch -> checking base/base against the reference (conformance).

Detection is a behavioral probe (STATICCALL ActivationRegistry.admin() before any etch), not extcodesize (native precompiles report zero code). setUp logs which world ran; LIVE_PRECOMPILES=true remains a force-live override.

Result

  • base-forge test -> 616 passed, 0 failed, 13 skipped (was 145 failing), no env var, no node.
  • forge test -> 625 passed, 0 failed, 4 skipped (reference world unchanged).

Also

  • Rename FORK_TESTING.md -> LIVE_PRECOMPILE_TESTING.md, reframed to lead with base-forge test; the Python node-runner stays documented as the against-a-real-node / CI path. "fork mode" -> "live precompile mode" terminology swept. Functional names (make fork-tests, script/fork/, the workflow) left intact to avoid breaking CI.

Test plan

Ran the full suite both ways on macOS arm64 against the v1.1.0 base-anvil build; both green (counts above).

BaseTest probes for the live precompiles (STATICCALL ActivationRegistry.admin()
before any etch) instead of requiring LIVE_PRECOMPILES, and records the result
in livePrecompiles. Stock forge test runs the Solidity mocks (reference mode);
base-forge test (or forge --fork-url a base-anvil node) uses the live
precompiles (conformance) and skips the mock etch. setUp logs which mode ran.
LIVE_PRECOMPILES=true remains as a force-live override.

Fixes the 'vm.etch: cannot use precompile ... as an argument' failures when
running base-forge test without LIVE_PRECOMPILES.
…round base-forge

Lead the docs with the auto-detected base-forge test path (reference vs live
precompile worlds), keep the python node-runner as the against-a-real-node /
CI path, and sweep 'fork mode' -> 'live precompile mode' terminology. Functional
names (make fork-tests, script/fork, the workflow) left intact.
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Interface Coverage

✅ All interface functions have test coverage.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

📊 Forge Coverage (src/lib/)

🟡 ≥95% across all metrics — some metrics below 99%.

File Lines Stmts Branches Funcs
🟢 B20FactoryLib.sol 100.00% 100.00% 100.00% 100.00%
🔴 test/lib/ForceFeeder.sol 0.00% 0.00% 100.00% 0.00%
🔴 test/lib/PrecompileProbe.sol 0.00% 0.00% 0.00% 0.00%
🟢 MockActivationRegistry.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockActivationRegistryStorage.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockB20.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockB20Asset.sol 100.00% 100.00% 100.00% 100.00%
🟡 MockB20Factory.sol 98.96% 99.10% 100.00% 100.00%
🟢 MockB20Stablecoin.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockB20Storage.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockPolicyRegistry.sol 100.00% 100.00% 100.00% 100.00%
🟢 MockPolicyRegistryStorage.sol 100.00% 100.00% 100.00% 100.00%
Total 96.69% 97.23% 98.39% 96.89%

Full report: download artifact. To browse locally: make coverage (runs forge coverage + genhtml + opens the HTML report).

…testing)

Add a Quick start that uses base-foundryup-installed base-forge/base-anvil
instead of a from-source build: base-forge test for the no-node path, and the
Python runner pointed at $HOME/.foundry/versions/base-nightly for genuine
node fork testing. Note that a base-anvil node starts with features inactive
(only forge in-process seeds them), so the runner activates them. Demote the
cargo build to a contributors section.
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

✅ Fork tests: all 616 passed

base/base is fully in sync with the base-std spec.

@amiecorso amiecorso force-pushed the corso/live-precompile-testing branch from 4b1558f to d58d907 Compare June 12, 2026 15:45
@amiecorso amiecorso merged commit e25553d into main Jun 12, 2026
15 of 16 checks passed
@amiecorso amiecorso deleted the corso/live-precompile-testing branch June 12, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant