GithubHelp home page GithubHelp logo

era-compiler-llvm's Introduction

ZKsync Era: The ZKsync LLVM Framework

Logo

ZKsync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or decentralization. As it's EVM-compatible (with Solidity/Vyper), 99% of Ethereum projects can redeploy without needing to refactor or re-audit any code. ZKsync Era also uses an LLVM-based compiler that will eventually enable developers to write smart contracts in popular languages such as C++ and Rust.

This directory and its sub-directories contain the source code for the ZKsync fork of the LLVM framework, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments used by the Solidity and Vyper compilers developed by Matter Labs.

Overview

Welcome to the ZKsync LLVM project!

The project has multiple components. The core of the project is the llvm directory. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer. These tools are not yet officially supported for third-party front-ends. It also contains ZKsync modifications of the standard LLVM regression tests.

Building

The ZKsync LLVM framework must be built with our tool called zksync-llvm:

1. Install the system prerequisites.
  • Linux (Debian):

    Install the following packages:

    apt install cmake ninja-build curl git libssl-dev pkg-config clang lld
  • Linux (Arch):

    Install the following packages:

    pacman -Syu which cmake ninja curl git pkg-config clang lld
  • MacOS:

    • Install the HomeBrew package manager.

    • Install the following packages:

      brew install cmake ninja coreutils
    • Install your choice of a recent LLVM/Clang compiler, e.g. via Xcode, Apple’s Command Line Tools, or your preferred package manager.

2. Install Rust.
  • Follow the latest official instructions:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    . ${HOME}/.cargo/env

    Currently we are not pinned to any specific version of Rust, so just install the latest stable build for your platform.

3. Install the ZKsync LLVM framework builder.
  • Install the builder using cargo:

    cargo install compiler-llvm-builder

    The builder is not the ZKsync LLVM framework itself, but a tool that clones its repository and runs a sequence of build commands. By default it is installed in ~/.cargo/bin/, which is recommended to be added to your $PATH.

4. Create the `LLVM.lock` file.
  • In a directory in which you want the llvm directory, create an LLVM.lock file with the URL and branch or tag you want to build, for example:

    url = "https://github.com/matter-labs/era-compiler-llvm"
    branch = "main"
5. Build LLVM.
  • Clone and build the ZKsync LLVM framework using the zksync-llvm tool:

    zksync-llvm clone
    zksync-llvm build

    The build artifacts will end up in the ./target-llvm/target-final/ directory. You may point your LLVM_SYS_170_PREFIX to that directory to use this build as a compiler dependency. If built with the --enable-tests option, test tools will be in the ./target-llvm/build-final/ directory, along with copies of the build artifacts. For all supported build options, run zksync-llvm build --help.

Troubleshooting

  • Make sure your system is up-to-date.
  • Make sure you have the required system prerequisites installed.
  • Unset any LLVM-related environment variables you may have set.
  • If you encounter any problems with the building process, please open an issue in the era-compiler-llvm repository.

License

The ZKsync fork of the LLVM framework is distributed under the terms of Apache License, Version 2.0 with LLVM Exceptions, (LICENSE or https://llvm.org/LICENSE.txt)

Resources

Official LLVM documentation

Official Links

Disclaimer

ZKsync Era has been through extensive testing and audits, and although it is live, it is still in alpha state and will undergo further audits and bug bounty programs. We would love to hear our community's thoughts and suggestions about it! It's important to note that forking it now could potentially lead to missing important security updates, critical features, and performance improvements.

era-compiler-llvm's People

Contributors

lattner avatar topperc avatar rksimon avatar espindola avatar rotateright avatar arsenm avatar tkremenek avatar ddunbar avatar douggregor avatar d0k avatar rui314 avatar zygoloid avatar maskray avatar chandlerc avatar isanbard avatar nico avatar nikic avatar echristo avatar dwblaikie avatar rnk avatar chapuni avatar fhahn avatar lebedevri avatar klausler avatar labath avatar jdevlieghere avatar akyrtzi avatar stoklund avatar lhames avatar eefriedman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.