The zkEVM Vyper compiler.

Overview

zkSync Era: Vyper Compiler

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 repository contains the compiler from Vyper to zkEVM bytecode.

Building

  1. Install some tools system-wide:
    1.a. apt install cmake ninja-build clang-13 lld-13 parallel on a Debian-based Linux, with optional musl-tools if you need a musl build
    1.b. pacman -S cmake ninja clang lld parallel on an Arch-based Linux
    1.c. On MacOS, install the HomeBrew package manager (being careful to install it as the appropriate user), then brew install cmake ninja coreutils parallel. Install your choice of a recent LLVM/Clang compiler, e.g. via Xcode, Apple’s Command Line Tools, or your preferred package manager.
    1.d. Their equivalents with other package managers

  2. Install Rust

    Currently we are not pinned to any specific version of Rust, so just install the latest stable build for your platform.
    Also install the musl target if you are compiling on Linux in order to distribute the binary:
    rustup target add x86_64-unknown-linux-musl

  3. Check out or clone the appropriate branch of this repository.

  4. Go to the project root and run git checkout <ref> with the tag, branch, or commit you want to build.

  5. Install the zkEVM LLVM framework builder:
    5.a. cargo install compiler-llvm-builder on MacOS, or Linux for personal use
    5.b. cargo install compiler-llvm-builder --target x86_64-unknown-linux-musl on Linux for distribution

    The builder is not the zkEVM LLVM framework itself; it is just a tool that clones our repository and runs the sequence of build commands. By default it is installed in ~/.cargo/bin/, which is recommended to be added to your $PATH. Execute zkevm-llvm --help for more information. If you need a specific branch of zkEVM LLVM, change it in the LLVM.lock file at the root of this repository.

  6. Run the builder to clone and build the zkEVM LLVM framework at this repository root:
    6.1. zkevm-llvm clone
    6.2. zkevm-llvm build

  7. Build the Vyper compiler executable:
    7.a. cargo build --release on MacOS or Linux for personal use
    7.b. cargo build --release --target x86_64-unknown-linux-musl on Linux for distribution

  8. If you need to move the built binary elsewhere, grab it from the build directory:
    8.a. On MacOS or Linux for the default target:
    ./target/release/zkvyper
    8.b. On Linux, if you are building for the target x86_64-unknown-linux-musl:
    ./target/x86_64-unknown-linux-musl/release/zkvyper

Usage

Check ./target/*/zkvyper --help for compiler usage.

Version 0.3.3 of Vyper compiler must be available in PATH, or the --vyper option must be used instead.

For big projects it is more convenient to use the compiler via the hardhat plugin. For single-file contract or small projects, however, the CLI is more than fine.

Troubleshooting

  • If you get a “failed to authenticate when downloading repository… if the git CLI succeeds then net.git-fetch-with-cli may help here” error, then prepending the cargo command with CARGO_NET_GIT_FETCH_WITH_CLI=true may help.
  • On MacOS, git config --global credential.helper osxkeychain followed by cloning a repository manually with a personal access token may help.
  • Unset any LLVM-related environment variables you may have set, especially LLVM_SYS_<version>_PREFIX (see e.g. https://crates.io/crates/llvm-sys and https://llvm.org/docs/GettingStarted.html#local-llvm-configuration). To make sure: set | grep LLVM

License

The Vyper compiler is distributed under the terms of either

at your option.

Resources

Vyper documentation

Vyper LLL IR

Some parts of the documentation may be outdated.
Please contact the Vyper team for assistance.

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.

You might also like...
Nederlandse programmeertaal. Geinterpreteerd en met dynamische types. Met bytecode compiler en virtual machine, in Rust.

Nederlang Nederlang is een geinterpreteerde programmeertaal, in het Nederlands! Met als bestandsnaam extensie.... .nl! Het maakt gebruik van dynamisch

The JavaScript Oxidation Compiler - Linter / Prettier

The JavaScript Oxidation Compiler (oxc) Why this project? The goal of this project is to: Create a blazingly fast JavaScript Compiler written in Rust.

⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in 🦀 Rust 🦀

Cairo 1.0 🐺 ⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in 🦀 Rust 🦀 Report a Bug - Request a Feature - Ask a Question Getting Started Prerequisi

Unborrowed Rust Compiler (rustc without a borrowchecker)

ubrustc: Unborrowed rustc This is rustc with the borrow checker disabled. I wrote it in like, 30 minutes because this tweet made me laugh. Example //

C compiler done wrong (for learning).

crust 🥧 Crust is a small C to x86-64 compiler, built using Rust. This project is meant for me to learn about compilers and the modules that they are

Compiler frontend for the PureScript programming language.

purescript-analyzer Goals Provide an independent frontend for providing information for IDE tooling, separate from the compiler. Implement a rich edit

This rust compiler backend emmits valid CLR IR, enambling you to use Rust in .NET projects

What is rustc_codegen_clr? NOTE: this project is a very early proof-of-concept This is a compiler backend for rustc which targets the .NET platform an

An interpreter and compiler for the Brainfuck language.

Brainrust 🧠 An interpreter and compiler for the Brainfuck language. Prerequisites You need a LLVM 16.0.* installation on your system. On Windows, you

Vyper-Compiler Version Manager in Rust

Vyper Compiler Version Manager in Rust Install $ cargo install --git https://github.com/storming0x/vvm-rs --locked vvm-rs Install from source $ git c

A rust library to interact with the Vyper compiler!

vyper-rs A rust library to interact with the Vyper compiler! Dependencies Please ensure that the Vyper compiler is installed and added to PATH! To ins

Generate perfect Vyper compatible code headers every time.

headers-vy Generate perfect Vyper-compatible code headers every time. Build You need Rust and Cargo installed on your machine. See the installation gu

🛠️ Uses zkevm-circuits and anvil mainnetfork to prove that a tx solves an EVM challenge

zk-proof-of-evm-execution This is a PoC developed at hackathon that enables a user to prove that they know some calldata that can solve a challenge on

Polyexen demo of Plonkish Arithmetiation Format (Plaf) on the zkevm-circuits

Plaf demo This is a demo of Plaf: Plonkish Arithmetiation Format on the zkevm-circuits Steps to run this: Clone these three repositories in the same f

A "Type 0" zkEVM. Prove validity of Ethereum blocks using RISC Zero's zkVM

zeth NEW: Zeth now supports Optimism blocks! Just pass in --network=optimism! Zeth is an open-source ZK block prover for Ethereum built on the RISC Ze

A performant, type-1 zkEVM written in Rust & SP1.
A performant, type-1 zkEVM written in Rust & SP1.

SP1 Reth SP1 Reth is a 100% open-source POC that showcases how any rollup can use SP1 to build a performant (type-1, bytecode compatible) zkEVM with l

C-like language compiler, the final project of ZJU Compiler Principle course
C-like language compiler, the final project of ZJU Compiler Principle course

cc99 cc99 (not cc98.org) is a C-like language compiler, which is the final project of ZJU Compiler Principle course. It supports many of the C99 langu

FlatBuffers compiler (flatc) as API (with focus on transparent `.fbs` to `.rs` code-generation via Cargo build scripts integration)

FlatBuffers flatc API for Rust This crate provides a programmatical way to invoke flatc command (e.g. from build.rs) to generate Rust (or, in fact, an

Compiler for Jade-like template language to cito.js-based virtual dom

Marafet A very experimental DSL for creating (mostly) single page applications in HTML. It's mostly a Jade-like (or Haml-like) templating language wit

Comments
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    Update Rust crate rayon to 1.7
    • Schedule: ["at any time"]
    • Branch name: renovate/rayon-1.x
    • Merge into: main
    • Upgrade rayon to 1.7

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
Owner
Matter Labs
Practical applications of Zero-Knowledge Proofs
Matter Labs
A rust library to interact with the Vyper compiler!

vyper-rs A rust library to interact with the Vyper compiler! Dependencies Please ensure that the Vyper compiler is installed and added to PATH! To ins

crypdough.eth 21 Jul 24, 2023
Generate perfect Vyper compatible code headers every time.

headers-vy Generate perfect Vyper-compatible code headers every time. Build You need Rust and Cargo installed on your machine. See the installation gu

t11s 15 Feb 12, 2023
Polyexen demo of Plonkish Arithmetiation Format (Plaf) on the zkevm-circuits

Plaf demo This is a demo of Plaf: Plonkish Arithmetiation Format on the zkevm-circuits Steps to run this: Clone these three repositories in the same f

Eduard S. 17 Apr 6, 2023
Tools - The Rome Toolchain. A linter, compiler, bundler, and more for JavaScript, TypeScript, HTML, Markdown, and CSS.

Rome is currently being rewritten in Rust. Read more about it in our latest blog post. The documentation below is out of date and available for poster

Rome 22k Jan 3, 2023
Minimal Pandoc compiler -> HTML

Minimal Pandoc compiler -> HTML

/c/ympfh 1 Apr 6, 2022
Compiler for an "extended" version of the Mindustry logic language

Minblur Compiler Minblur is a compiler for a superset of "logic" programming language in the game Mindustry. It helps reduce code-duplication, making

Binder News 15 May 2, 2022
An awesome language and its compiler.

Calocom Project Build Build with cargo-make Just run cargo make in the root directory of the project. Or, if you want to build it in release mode, run

Aoyang Yu 31 Sep 16, 2022
Open-source compiler for the Papyrus scripting language of Bethesda games.

Open Papyrus Compiler This project is still WORK IN PROGRESS. If you have any feature requests, head over to the Issues tab and describe your needs. Y

erri120 22 Dec 5, 2022
Discord-to-Cohost compiler written in Rust using Tera

Cohoard - Post formatted chatlogs to Cohost! Cohoard is a tool for turning chatlogs into formatted posts on Cohost. You can use Cohoard to easily form

Aaron Kofsky 14 Dec 15, 2022
🐱 HQ9C is a very serioues compiler for HQ9+, it meta-compiles with Rust.

HQ9+ Compiler HQ9c (Or HQ9+ Compiler) is a blockchain-based NFT minting AI machine-learning cloud infraestructure for the compiling of the great progr

Alex 5 Aug 28, 2022