YUL and EVM assembly recompiler to LLVM, targetting RISC-V on PolkaVM.
Visit contracts.polkadot.io to learn more about contracts on Polkadot!
This is experimental software in active development and not ready just yet for production usage. Please do report any compiler related issues or missing features that are not yet known to us here.
Discussion around the development is hosted on the Polkadot Forum.
resolc
depends on the solc binary installed on your system.
Building from source requires a compatible LLVM build.
revive
requires a build of LLVM v18.1.8 with the RISC-V embedded target, including compiler-rt
. Use the provided revive-llvm utility to compile a compatible LLVM build locally and point $LLVM_SYS_181_PREFIX
to the installation directory afterwards.
To install the resolc
Solidity frontend executable:
# Build the host LLVM dependency with PolkaVM target support
make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
# Build the resolc frontend executable
make install-bin
resolc --version
Cross-compile resolc.js frontend executable to Wasm for running it in a Node.js or browser environment. The REVIVE_LLVM_TARGET_PREFIX
environment variable is used to control the target environment LLVM dependency.
# Build the host LLVM dependency with PolkaVM target support
make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
# Build the target LLVM dependency with PolkaVM target support
revive-llvm --target-env emscripten clone
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build
export REVIVE_LLVM_TARGET_PREFIX=${PWD}/target-llvm/emscripten/target-final
# Build the resolc frontend executable
make install-wasm
make test-wasm
Please consult the Makefile targets to learn how to run tests and benchmarks.
Ensure that your branch passes make test
locally when submitting a pull request.
revive
uses solc, the Ethereum Solidity compiler, as the Solidity frontend to process smart contracts written in Solidity. The YUL IR code (or legacy EVM assembly as a fallback for older solc
versions) emitted by solc
is then translated to LLVM IR, targetting Polkadots revive
pallet.
Frontend and code generator are based of ZKSync zksolc
.
Before running the tests, ensure that Geth (Go Ethereum) is installed on your system. Follow the installation guide here: Installing Geth. Once Geth is installed, you can run the tests using the following command:
make test