Frak Labs

Solar vs solc: A 19x Faster Solidity Dev Loop, and One Regression

I benchmarked Paradigm's Rust Solidity compiler against solc on Frak's contracts. Builds drop under a second and 217 tests pass, but the P-256 signature verifier costs 22% more gas, so Solar stays in the dev loop.

By 16 min readUpdated
SolarsolcFoundrySolidityRustBenchmarkingGas Optimization

On my M1 Pro, forge build --force on Frak’s contracts repo takes 10.11 s with solc 0.8.23. With Solar it takes 0.53 s. After I append a comment to RewarderHub.sol and rebuild, solc needs 6.17 s and Solar 0.38 s. I measured this on 2 November 2026, with five clean builds per compiler, and the numbers barely move between runs.

Solar is Paradigm’s Solidity compiler written in Rust. Version 0.3 is the first release that generates bytecode, and Foundry 1.9.0 ships it next to forge. The contracts repo (frak-id/contracts-v2) has a solar profile on an unmerged branch: FOUNDRY_PROFILE=solar forge test. Deployments, forge script and verification stay on solc. The profile exists for the loop where I edit, compile and run tests many times an hour, and nothing else.

The benchmark lives in bench/solar/ on branch chore/solar-bench. At the time of writing there is no pull request and nothing is merged into main.

I wrote earlier about moving Frak’s Solidity tests from Hardhat to Foundry, which cut a test run of 13 seconds down to 102 milliseconds. On this repo the slow step of the loop is now compilation, and compilation is the part Solar changes.

What Is Being Compared

Three variants, all driven by bench/solar/run.ts on the same forge binary (forge Version: 1.9.0) and the same foundry.toml:

VariantCompilerRuns per measurement
solc0.8.23, legacy pipeline, optimizer on, optimizer_runs = 100_000, EVM shanghai5
Solarsolar 0.3.0-dev+commit.a2b44354, the build bundled with Foundry 1.9.05
solc --via-irsame solc, IR pipeline1

The legacy pipeline compiles Solidity straight to EVM assembly. Via-IR goes through Yul (solc’s intermediate language) first, which optimizes better in some cases and compiles much slower. I included it because Paradigm’s own headline numbers compare against it.

The Solar version needs a footnote. Foundry 1.9.0 bundles a Solar one release-tooling commit before the v0.3.0 tag. It writes its full version string into the CBOR metadata, 23 bytes more per contract than the standalone v0.3.0 binary. Per the README that is the whole size difference between the two (runtime size −41% with the bundled binary, −43% with the standalone one), and codegen is the same. I did not diff the two binaries’ output myself.

Keeping the Comparison Fair

The harness gives each variant its own out/ and cache/ directories under bench/solar/.work/, and pins the environment:

// bench/solar/run.ts
const FORGE_ENV = {
    ...process.env,
    // Every variant starts from the default profile, a stray FOUNDRY_PROFILE=solar would turn the baseline into Solar
    FOUNDRY_PROFILE: "default",
    FOUNDRY_DISABLE_NIGHTLY_WARNING: "1",
    // Lint-on-build runs Solar's linter after every build, it would add the same noise to every variant
    FOUNDRY_LINT_ON_BUILD: "false",
    NO_COLOR: "1",
};

const variants: Variant[] = [
    { id: "solc", label: "solc (project settings)", args: [], runs: RUNS },
    { id: "solar", label: "Solar", args: ["--use", SOLAR], runs: RUNS },
];

I added the FOUNDRY_PROFILE: "default" line when I re-ran on Foundry 1.9.0. Without it, a shell with FOUNDRY_PROFILE=solar exported would have made the baseline a Solar build. The Solar variant uses --use <binary> on the same forge. Only the compiler differs.

There are two timing scenarios. A cold one: forge build --force on the whole project (114 files: src/, test/, script/ and dependencies), five runs, with wall clock, the compiler time forge prints, and peak RSS (resident memory) read from /usr/bin/time -l. And a warm one: build once, then for each run append a different trailing comment to src/reward/RewarderHub.sol so the content hash changes, and rebuild on the warm cache. Thirteen files depend on it and get recompiled. Reported numbers are medians.

// bench/solar/run.ts, benchIncremental()
for (let i = 0; i < v.runs; i++) {
    // A different comment every run, so each build sees new content
    writeFileSync(path, `${original}\n// solar-bench incremental edit ${i}\n`);
    const res = run([FORGE, "build", ...v.args, "--out", out, "--cache-path", cache]);
    // ...
}

The spread is small. Clean solc builds ran 9.99 to 10.23 s, clean Solar builds 513 to 532 ms. Rebuilds ran 6.12 to 6.19 s for solc and 370 to 389 ms for Solar. The via-IR figures (87.14 s clean, 49.75 s rebuild) come from one run each, because 87 seconds times five was more than I wanted to wait. Treat those two as indicative.

Build Speed and Memory

solc 0.8.23SolarRatio
Clean build, wall (median)10.11 s530 ms19.1×
Clean build, compiler time forge reports9.89 s243 ms
Rebuild after edit, wall (13 files)6.17 s382 ms16.1×
Peak RSS, clean build (median)459 MiB132 MiB
forge test, cached build, wall (one run)4.58 s3.21 s

Against solc --via-ir the clean build is 164× faster (87.14 s against 530 ms). The compiler alone drops from 9.89 s to 243 ms. The other 290 ms of Solar’s wall time is forge: reading the project, writing artifacts, process start. That is why the wall-clock ratio (19×) is smaller than the compiler-only ratio (about 41×) and why I quote the wall-clock one.

My first run on the same day gave 22.8× (10.24 s → 449 ms) and a 200× gap to via-IR. It used a forge 1.8.8-nightly and a standalone Solar 0.3.0 binary, and the report from that run is still in git history at a06d976. The re-run on the Foundry 1.9.0 release, which is what anyone installing Foundry gets, produced 19.1×.

The last row of the table is the one to read carefully. A cached forge test spends most of its time executing tests in the EVM, which Solar does not touch, and it ran once per variant. The 1.4 s difference could be the smaller bytecode executing faster, noise, or both. The README says the suite “takes about the same time with every compiler”, and I would not claim more than that.

What the Bytecode Looks Like

On the seven concrete src/ contracts (libraries are left out, because with internal functions only they compile to a stub that is never deployed):

Metric (geomean, src/)Solar vs solcsolc --via-ir vs solc
Runtime size−41.2%+1.5%
Init code size−39.0%+0.4%
Deployment gas−38.6%−3.1%
Function gas (40 medians)−12.7%+4.0%

For function gas, 39 of 40 functions are cheaper under Solar. The size of the gain tracks how much of the call is storage, at least in this data:

That is the extent of the explanation I can support. A cold SSTORE costs the same whichever compiler emitted the opcode, so a function that is mostly storage has little left to save, and a function that is mostly dispatch and stack shuffling has a lot. I did not read Solar’s output opcode by opcode, so I cannot say which of its optimizations produce the savings on the small functions.

Three caveats from the README belong next to these numbers. Solar implements Solidity 0.8.38 and warns (code 5333) on every pragma solidity 0.8.23, then compiles anyway, so the comparison pits a 0.8.38-level frontend against solc 0.8.23. A newer solc could not be used without changing pinned pragmas. Fuzz tests do not feed identical inputs, because forge seeds the fuzz dictionary with constants found in the bytecode, so a few gas-report rows show different call counts. And the timings come from one machine. Solar is multi-threaded and solc is not, so I expect the gap to grow with core count, but I have only the M1 Pro.

The report’s per-test gas geomean, which includes test-contract code compiled by the same compiler, is a more modest −4.3%.

Solar’s output was also stable. Two builds gave identical bytecode across 119 artifacts, and building only src/ gave the same src/ bytecode as a whole-project build.

Two Failing Tests, Both My Tests

In the first run, 217 tests passed under solc and 215 under Solar. Under solc --via-ir the same two failed, the same way, and that coincidence made me suspect the tests before the compiler. Both turned out to lean on an accident of the legacy pipeline.

A Timestamp Read Across a Warp

// test/reward/RewarderHub.freeze.t.sol (as it was before b69926e)
function test_getFreezeInfo_canRecover() public {
    uint256 freezeTime = block.timestamp;

    vm.prank(compliance);
    hub.freezeUser(user1);

    vm.warp(block.timestamp + hub.FREEZE_DURATION());

    (uint256 frozenAt, bool canRecover) = hub.getFreezeInfo(user1);
    assertEq(frozenAt, freezeTime);
    assertTrue(canRecover);
}

The failure under Solar read assertion failed: 1 != 5184001. The freeze happened at timestamp 1, the contract recorded 1, and the test’s local freezeTime held 5,184,001, which is 1 plus FREEZE_DURATION (60 days, 5,184,000 s). The local had been re-read after the vm.warp cheatcode (a Foundry call that sets the block timestamp).

Within a real transaction block.timestamp cannot change, so a compiler is free to treat TIMESTAMP as a constant and re-emit the opcode where it needs the value instead of holding it in a stack slot or memory. vm.warp breaks that assumption, because it changes the timestamp in the middle of a test function. solc’s legacy pipeline kept the value; Solar and via-IR did not. I did not disassemble the test bytecode to confirm that is what happened. It is the explanation that fits both compilers failing with the same numbers, and per the README forge lint flags this pattern as environment-read-across-mutation. The fix is the one the linter suggests:

// test/reward/RewarderHub.freeze.t.sol
// Not `block.timestamp`: it is constant within a tx, so optimizing compilers (via-IR, Solar) may re-read it
// after the `vm.warp` below
uint256 freezeTime = vm.getBlockTimestamp();

This test was wrong under any compiler. It had never failed because the legacy optimizer never exercised the freedom the EVM gives it.

An Assertion Sitting on the Mean

// test/utils/BetaDistribution.t.sol (before b69926e)
// Generate 10_000 points and ensure that the average match the mean of the alpha distrib: alpha=2 beta=2.1
function test_wadBetaPoint_average_beta2() public view {
    uint256 betaWad = 2.1e18;
    // ...
    uint256 average = total / runs;

    assertGt(average, 0.49e18, "Average should be greater than 0.49");
    assertLt(average, 0.51e18, "Average should be lower than 0.51");
}

The contract interpolates between Beta(2,2), mean 0.5, and Beta(2,3), mean 0.4. For β = 2.1 that gives 0.9 × 0.5 + 0.1 × 0.4 = 0.49, exactly the lower bound. The average of 10,000 samples lands on either side of the mean with roughly equal probability, so the assertion passed or failed depending on the random stream.

The stream is not fixed. The library seeds its PRNG from gas(), prevrandao() and the caller:

// src/utils/BetaDistribution.sol
function _initPrngSeed() internal view returns (LibPRNG.PRNG memory) {
    uint256 seed;
    assembly {
        let freeMemPtr := mload(0x40)
        mstore(0, gas())
        // ...
        seed := keccak256(0, 0x60)
        mstore(0x40, freeMemPtr)
    }
    // ...
}

Different bytecode burns a different amount of gas before reaching that point, so any compiler change reshuffles the samples. The failure messages show it. Solar’s average was 0.48948 and via-IR’s 0.48927, both just under 0.49. The solc legacy build passed the original test, by landing above 0.49 on a stream I did not record. The test now asserts between 0.48 and 0.50, centered on the mean.

The fix turns a coin flip into a band around the mean. One Beta(2,2) sample has a standard deviation of about 0.224, so the mean of 10,000 samples has σ ≈ 0.002, and the ±0.01 band is roughly 4.5σ wide. Solar’s 0.48948 sits about 0.0005 under the mean, well inside it. That is back-of-envelope arithmetic on Beta(2,2), not a measurement of this sampler, and the seed still depends on gas(). The README also reports a probe test, not committed to the repo, in which Solar’s samples were all distinct and averaged 0.4991 for β = 2 and 0.4023 for β = 3. Those are close to the exact means 0.5 and 0.4, which is why I trust the sampler and distrust the old assertion.

After b69926e, all three variants report 217 passed and 0 failed (7 tests skipped everywhere), and no test changes status between solc and Solar. That is a parity result over this suite, not a proof about Solar’s codegen: 217 tests exercise the paths I wrote tests for.

The One Regression

P256VerifierWrapper is the only function in the gas report that got more expensive under Solar:

P256VerifierWrapper.fallback()Gas (median of 143 calls)vs solc
solc legacy212,299
Solar259,725+22.3%
solc --via-ir301,882+42.2%

Its runtime bytecode is 27.8% smaller under Solar (5,966 → 4,305 bytes) and it costs 22% more per call. Size and gas moved in opposite directions, so the saved bytes are probably outside the hot loop.

The contract wraps FreshCryptoLib’s P256 verification for the case where the chain has no native verifier:

// src/kernel/utils/P256VerifierWrapper.sol
contract P256VerifierWrapper {
    // ...
    fallback(bytes calldata input) external returns (bytes memory) {
        if (input.length != 160) {
            return abi.encodePacked(uint256(0));
        }
        // ...
        uint256 ret = FCL_ecdsa.ecdsa_verify(hash, r, s, x, y) ? 1 : 0;
        return abi.encodePacked(ret);
    }
}

The calldata layout mimics the RIP-7212 precompile (a proposed secp256r1 verification precompile at address 0x100), so the same call works against a precompile or against this contract. ecdsa_verify calls into FCL_Elliptic_ZZ (ecZZ_mulmuladd_S_asm and friends) in FreshCryptoLib’s FCL_elliptic.sol, which has 10 inline assembly blocks. Solar’s README entry says it does not beat solc’s legacy optimizer on assembly-heavy code yet. That is my working explanation. I have not reduced it to one function or compared opcode counts.

This contract matters more than its place in a geomean suggests. Frak’s wallets sign with passkeys, which produce P-256 signatures, and on a chain without the RIP-7212 precompile something has to verify them in plain EVM code. The wrapper is that fallback, and its own NatSpec calls it a stopgap that becomes useless once the precompile is live. Where it does the verifying, +22% is about 47k gas on a 212k verification (259,725 − 212,299). That cost lands on the signature check, while the 40% wins land on getters that are cheap to begin with.

Averages hide that. A geomean over 40 functions weights FREEZE_DURATION() as much as the signature check. The per-test table shows the same pattern from another side: nine of the ten largest regressions under Solar (up to +18.4%) are in the one test contract whose setup deploys P256VerifierWrapper.

Why Smaller and Cheaper Still Stays in the Dev Loop

On the evidence above, Solar produces smaller bytecode and cheaper calls on most of this codebase. I still deploy with solc 0.8.23, for reasons that have nothing to do with the benchmark:

The last point has a consequence for the benchmark’s own gas tables. They compare Solar’s code to solc’s code, and only the second is what runs on mainnet. A “−12.7%” tells me about Solar. It does not predict what my users would pay if I switched, and the P256 row shows the sign can flip on the one contract where gas matters most.

The Profile

The configuration is short, and the details are in the comments:

# foundry.toml
[profile.solar]
solc = "solar"
# Own artifacts + cache: switching profiles keeps both builds warm, and Solar bytecode never lands in out/
out = "out-solar"
cache_path = "cache-solar"

The profile inherits everything else from default, so optimizer settings and the fuzz seed config are the same (the fuzz inputs still differ, as noted above). Separate output directories do two jobs. Switching between profiles keeps both builds warm instead of invalidating one with the other, and Solar artifacts cannot end up in out/, which is where forge script reads from. bun run test:solar and bun run build:solar wrap the two commands.

CI runs the suite under both profiles as a matrix, [default, solar], with fail-fast: false, so a divergence between compilers shows up as one red cell. It is a workflow_dispatch workflow, so it only runs when I trigger it. I also had to move it off version: nightly to v1.9.0: the nightly tag stopped moving in April 2026 and has no Solar. The same problem affects local installs. The old Bash foundryup resolves nightly through that frozen tag and installs a forge without Solar, so the README tells people to pin foundryup -v v1.9.0 or use the Rust foundryup.

What I Did Not Measure

Everything ran on one M1 Pro (8 cores, 16 GiB), on one project of 114 files and seven concrete contracts in src/. All gas numbers come from the unit-test suite, so I have no figure for a real user flow on a deployed contract. I did not separate the 0.8.38-versus-0.8.23 language level from the compiler itself, and I did not time Solar’s linter, which I turned off with FOUNDRY_LINT_ON_BUILD=false because it runs after every build whatever the compiler.

What Is Next

When Solar leaves experimental status, the first thing to rerun is bun run bench:solar, which regenerates the whole report with one command. The P256 row is the one I will read first. If the assembly-heavy regression is gone, what remains against deploying with it is explorer verification and CREATE2 addresses. That would be a separate decision, probably starting with a testnet deployment whose bytecode I can compare against the solc build.

What I would carry to another project is the shape of the harness: pin the profile in the environment, give every variant its own out/ and cache/, record the exact binary versions in meta.json, and run the test suite as well as the build. Both failures here were tests passing for the wrong reason, and they only showed because a second compiler disagreed with the first.

100%