solx is a new optimizing compiler for EVM developed by Matter Labs.
Warning
The project is in pre-alpha state and not suitable for production use.
solx passes our test suite, which includes:
- tests from the solc project
- real-life projects such as UniswapV2 and Mooniswap
- additional tests written by the solx team
Our pool of tests is updated with every solc release. Arbitrary contracts are expected to compile correctly, but some may be temporary affected by stack-too-deep errors. Benchmarks indicate that solx generates larger code than solc, but reduces the gas consumption on average.
Our mid-term goals:
- support EOF
- further reduce gas usage and bytecode size
- eliminate the need for inline assembly for efficiency
- emit ethdebug for optimized code
- run more tests of real-life projects in CI
You can download the existing pre-releases from the Releases GitHub page.
We recommend using solx via Foundry. It behaves in the same way as solc v0.8.29, so you can download the executable and specify:
[profile.solx]
solc_version = "/path/to/solx"
It might work with Hardhat as well, but it has not been tested yet.
Otherwise, the interface is mostly compatible with solc, so you can use it via CLI or standard JSON.
Check out this repository to see a demo of the current state of the compiler.
solx consists of three main parts:
- solx executable from this repository. The repository also contains parts of the compiler front end: Yul and EVM assembly lowering.
- era-solidity, an LLVM-friendly fork of the Solidity compiler, that emits Yul and EVM assembly for solx. Despite the repository name, it is not directly related to either ZKsync or ZKsync Era.
- era-compiler-llvm, a fork of the LLVM project with an EVM target developed by the solx team.
The most important part of the project is the EVM target in LLVM. You can find its sources here.
solx documentation is provided as an mdBook, and its sources available in the docs/
directory.
To build the book, follow the instructions.
See also:
To run the unit and CLI tests, execute cargo test
at the repository root.
If you have multiple LLVM builds in your system, ensure that you choose the correct one to build the compiler.
The environment variable LLVM_SYS_191_PREFIX
sets the path to the directory with LLVM build artifacts, which typically ends with target-llvm/build-final
.
For example:
export LLVM_SYS_191_PREFIX="${HOME}/src/solx/target-llvm/build-final"
If you suspect that the compiler is not using the correct LLVM build, check by running set | grep LLVM
, and reset all LLVM-related environment variables.
For reference, see llvm-sys and Local LLVM Configuration Guide.
- Crates solx and solx-solc are licensed under GNU General Public License v3.0
- Crates solx-standard-json and solx-yul are licensed under the terms of either
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
era-solidity
is licensed under GNU General Public License v3.0era-compiler-llvm
is licensed under the terms of Apache License, Version 2.0 with LLVM Exceptions, (LICENSE or https://llvm.org/LICENSE.txt)
Email us at [email protected].