Solang, currently at version 0.1.0.
- Shawn Amundson <email@example.com>
- Silas Davis <firstname.lastname@example.org>
- Greg Hill <email@example.com>
- Sean Young <firstname.lastname@example.org>
Solang is a compiler for the Solidity language that can target ewasm (used by Hyperledger Burrow, future ethereum and others), Sawtooth Sabre, and Parity Substrate. It is written in rust and uses LLVM as the compiler backend. The aim is for full compatibility with the Solidity language where possible .
Once a compiler is written, other tooling can be written that depends on having compiler components available. Just like llvm is a compiler toolkit, Solang wants to be a Solidity toolkit. Linters, analysis tools, language servers, debuggers etc can be written by reusing the parsing/resolving phases of Solang.
Solidity as a language does have its quirks, however it has established itself as a defacto language commonly used for smart contracts. Having Solidity support for the Hyperledger ledgers would be a great feature, conversely it would be beneficial for those projects to collaborate on a common compiler component.
Solang does not depend on any other project.
The Ethereum Foundation has a Solidity compiler, which is a large C++ code base. It contains a handwritten Solidity parser, and code optimizer. It can only target EVM on Ethereum. In the first instance, Solang is a new implementation of a Solidity compiler with modern tooling: written in rust, generated parser, targeting wasm, and using llvm for code gen. This makes the code base much smaller and makes it possible to compile Solidity for a range of ledger projects.
Once this is done, a range of new further tooling can built on top of this:
- Improving the Solidity language itself, e.g. string processing or generics
- Implement a Solidity Language Server for IDEs, see Create a new Solidity Language Server (SLS) using Solang Compiler
- Integer overflow detection in Solidity
- Link C code to Solidity using the LLVM Linker-as-a-library
- Implement Solidity linter/style hints like rust clippy
- Implement Solidity debug builds and debugger (using llvm debug codegen)
- Static analysis tools
- Formal methods
- Generate EVM code using experimental evm llvm backend
Solang would move into incubation, if approved.
Solang does not have complete language support yet. The language features which are supported are clearly documented. See: https://solang.readthedocs.io/
Solang tries to be a traditional compiler
- parser (outputs: AST)
- resolver: (outputs: CFG)
- code emitter (output: LLVM IR)
- llvm wasm codegen
The layout of the source code is as follows:
lexer and LALRPOP Solidity grammer
output: Abstract Syntax Tree
Resolves types, variables, functions etc
Generates control flow graph
Converts Control Flow graph to LLVM IR
Has to do some tricks to generate PHI nodes
ABI encoder/decoder (eth/scale)
Converts wasm object file to final wasm file
Generates and reads ABIs
Efforts and Resources
This project is funded through a Web3 Foundation grant. In order to receive the grant, the project commits to a roadmap. This roadmap means Solang will have full Solidity language support in fall 2020.
The source code is hosted on github: https://github.com/hyperledger-labs/solang . Solang can compile Solidity for use with Hyperledger Burrow, and Hyperledger Sawtooth. How this can be done is documented: https://solang.readthedocs.io/en/latest/running.html
The aim is to provide great tooling for Solidity developers, whatever ledger they are using. If developers start using our tooling, then we are succeeding.
- Angelo De Caro
- Arnaud J Le Hors
- Christopher Ferris
- Dan Middleton
- Gari Singh
- Hart Montgomery
- Mark Wagner
- Nathan George
- Swetha Repakula
- Tracy Kuhrt
- Troy Ronda