Dynamic Test Linking
dynamic_test_linking
is a configuration that speeds up project compilation (after first compile) by compiling only changed sources in the src/
directory and linking the test bytecode dynamically, hence avoid compilation of the solidify files in the test/
directory.
You can enable this feature by setting the dynamic_test_linking
configuration option to true
in your foundry.toml
file:
[profile.default]
...
dynamic_test_linking = true
OR by passing the --dynamic-test-linking
flag to the forge build
command:
forge build --dynamic-test-linking
We are looking into enabling this by default in the future.
Benchmarks from the PR show greater than 10x speedup in compilation time for large projects:
Project | Change | Files compiled (with / without, after initial compile) | Time to compile (with / without, after initial compile) |
---|---|---|---|
uniswap v4-core | add Lock.lock(); at PoolManager.sol#L107 | 1 / 19 | 2.25s / 165.13s |
spark-psm | change amountOut < minAmountOut at PSM3.sol#L125 | 3 / 28 | 2.14s / 16.15s |
morpho-blue-bundlers | change if (assets < 0) at MorphoBundler.sol#L106 | 11 / 36 | 16.39s / 251.05s |
morpho-blue | add require(assets != 0, ErrorsLib.ZERO_ASSETS) at Morpho.sol#L424 | 1 / 23 | 1.01s / 133.73s |
sablier lockup | change if (cliffTime < 0) at SablierLockup.sol#L480 | 1 / 104 | 781ms / 71.29s |
solady | add additional _setOwner(newOwner) at Ownable.sol#L182 | 9 / 14 | 6.17s / 6.34s |
euler evc | change SET_MAX_ELEMENTS to 11 at Set.sol#L7 | 28 / 30 | 9.17s / 9.40s |