paint-brush
Experience the Power of OlaVM Proof of Concept: The Next-Gen Full-Featured zkVMby@sin7y
387 reads
387 reads

Experience the Power of OlaVM Proof of Concept: The Next-Gen Full-Featured zkVM

by Sin7YFebruary 15th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In August 2022, Sin7y released the White Paper of OlaVM, formally planting the seeds of scalability and privacy in the fertile soil of Ethereum. With the completion of OlaVM PoC, the seeds have broken through the ground, indicating that the seeds have successfully germinated. This article will mainly introduce the progress and some strategic adjustments of OlaVM at this stage.
featured image - Experience the Power of OlaVM Proof of Concept: The Next-Gen Full-Featured zkVM
Sin7Y HackerNoon profile picture


In August 2022, Sin7y released the White Paper of OlaVM, formally planting the seeds of scalability and privacy in the fertile soil of Ethereum. With the completion of OlaVM PoC, the seeds have broken through the ground, indicating that the seeds have successfully germinated. This article will mainly introduce the progress and some strategic adjustments of OlaVM at this stage.


  • We are excited to make the following announcements:


    • We have preliminarily completed the PoC of OlaVM, and you can check the relevant engineering implementation and related document design through Sin7Y/olavm.


    • We have completed the initial design and implementation of the custom smart contract language Ola-lang, and you can check the related engineering design and related document design through Sin7Y/ola-lang.


    • We have initially completed the integration of Olang into the developer-friendly IDE: Visual Studio Code, allowing developers to write Olang programs on VSCode and then execute proof generation and proof verification processes. You can view the operation tutorial through Sin7Y/vscode-ola.


  • And some adjustments:


    • The project name was officially adjusted from OlaVM to Ola. OlaVM will be a key module in Ola, and other modules include smart contract language Ola-lang, Ola-compiler, Ola-sequencer, etc.


    • The project goal is expanded from programmable scalability to programmable scalability and privacy. We believe that programmable scalability and privacy will be the next important features of Ethereum and even the blockchain industry.

The Dawn of OlaVM

OlaVM is one of the most significant modules in the Ola system. Whether in a public or private scene, the main function of OlaVM is to execute programs and generate execution traces and valid proofs. Therefore, in order to have a high throughput rate for the entire Ola system, the efficiency of the OlaVM module is very crucial, requiring fast program execution, fast execution trace generation, and most importantly, fast proof generation.


In order to generate proofs quickly, OlaVM must be designed as zk-friendly as possible and involve:


  1. Instruction Set Architecture (ISA) Design

  2. Finite Field Selection

  3. Builtins, referring to predefined calculations that could not be proven efficiently by splitting into CPU instructions

  4. Prophets, referring to nondeterministic calculations that are inefficient to prove but can be verified efficiently.


ISA design

OlaVM adopted the RISC (Reduce Instruction Set Computer) architecture, which features a small number of instructions, as opposed to the CISC (Complex Instruction Set Computer) architecture. For a detailed comparison between the RISC and CISC architectures, please refer to RISC VS CISC. Here are two major reasons for choosing the RISC architecture.


  • Firstly, the size of the instruction set is directly related to the complexity of the constraint system. The main manifestation is that the increase in the number of instructions will lead to an increase in the number of selector polynomials and instruction constraints. It may even increase the polynomial order of the entire constraint system and increase the workload to prove it.


  • Secondly, the frequency of instruction is used. If it is based on the CISC design, more instructions may lead to partial failure in most computing scenarios Instructions are idle or used in a small amount, but the constraints related to these instructions still exist in the entire constraint system, increasing the workload of proof without reason, which returns to the problem mentioned in the first point.


Finite Field selection

Similar to Cairo's design, OlaVM also adopts the Algebraic RISC architecture. The meaning of RISC is similar to that described above, and Algebraic represents that the operations performed by OlaVM are all field operations, which is one of the reasons why OlaVM can implement RISC. The operations of OlaVM are all field operations, meaning that the word and instruction operands in OlaVM are also field elements. Different from the field used in Cairo (P = 2^251 + 17 * 2^192 + 1), the field used by OlaVM is the Goldilock field (P = 2^64 - 2^32 + 1). Therefore, the computation in the Goldilock field can be executed faster because of the huge difference in field size.


Builtins

For some special simple calculations, when you want to constrain it, you would find that the constraints are very heavy, such as bitwise operations, and keccak calculations that contain a large number of bitwise operations. As the execution trace table has an upper limit in size, the fewer rows occupied by a single execution, the more executions are included in this table.


Therefore, for the zk-unfriendly calculations involved in the transaction execution logic, it needs to be put into a separate table to verify the correctness. This is the idea behind the builtins design. Since we need to identify which data in the trace is consistent with the corresponding builtins, we need to add an additional selector to enable it. OlaVM currently supports bitwise, range check, and comparison builtins. Other builtin types, such as hash, ecdsa, etc., will be supported in the near future.


Prophets

A great advantage of customized zkVM is that zk-friendly can be applied in any component of the system. The above-mentioned design points are related to the design of the OlaVM itself, and the prophets will be integrated into Ola-complier. For example, it is necessary to set a special write-once memory segment in OlaVM and judge whether it is a prophet code segment when allocating compiler memory.


Here is an example of how the prophet plays its role. If the prover wants to prove "I know the square root of the number y is x", for most virtual machines, since there is no instruction or builtin corresponding to the square function, it can only be realized with virtual machine instructions, and then to generate a proof, since the logic of this calculation is complex, it will increase the workload of the prover.


Fortunately, the verification of this calculation is simple, for example, you only need to introduce two logics: x * x = y. rangecheck(x). This is where prophets come into play. It is like a "prophet" that helps you calculate the results of the current calculation. Then, you only need to introduce the verification logic described above into the program. Figure 1 shows the theoretical performance of different processing methods for the processing of nondeterministic calculations.


Figure 1. Processing Options for nondeterministic calculations


  • It is worth noting that there are essential differences between prophets and builtins.


    • The verification logic of prophets is in the program while the verification logic of builtins is a circuit.

    • The prophets will only add a few complexities for prover while the increase of prover complexities by builtins will be much larger.

    • Finally, the types of calculations solved by the two are also different. Prophets solve nondeterministic calculations, while builtins solve zk-unfriendly calculations.


For more design details, please refer to the Olavm design document and the OlaVM project.


Ola-lang

Ola-lang is a high-level language for implementing smart contracts. From the outset, it is designed to be a zk-friendly programming language. It is influenced by Solidity and Rust. It is very easy for developers familiar with these languages to get started as it is statically typed and supports complex user-defined types among other features. With Ola-lang, you can create contracts for a variety of uses.

The Design Goals

  • Security: The results of the program executions are deterministic, declared at the language level/syntax, and guaranteed at the compiler level.


  • Efficiency: The speed of execution and proof of the program is well balanced to be efficient.


  • Universal: Easy to use and readable code, it is developer friendly with minimal learning thresholds for developers familiar with mainstream programming languages such as C++/Rust, to quickly get into writing arithmetic programs.


  • Turing complete: Ola-lang can be used for complex programs such as loops, recursion, etc.


Key Features

  • Ola-lang natively supports field operations and plans to support u32, u64, and u256 types based on field elements.


  • It supports compiling smart contracts to LLVM IR as well as custom IR, which allows the compiler to be separated from the front and back ends for easier optimization.


  • it supports Prophets, which makes it easy to verify some NP-liked calculations.


  • it supports Builtins, which makes it easy to deal with zk-unfriendly computation.


  • it is based on solidity's syntax and the way contracts are written (Solidity's front end may be supported at a later stage.)


Architecture Overview

The Ola compiler introduces LLVM-IR as the middle end of the compilation, which makes it possible to separate the front and back ends of the compilation and optimize them as much as possible. The architecture of the Ola compiler is shown in the following diagram.


Figure 2. The Architecture Overview of Ola Compiler



The Road to Full-featured OlaVM


Features

Status

Simple computation logic

Completed

Function calls

Completed

U32, U64, U256 libs

Ongoing

For Loop, Global variable ...

Ongoing

Storage

Ongoing

Full-featured Assembler

Ongoing

Full-featured LLVM

Not started

Builtins

Not started

Prophets

Not started

Table 1: The Road to Full-Featured OlaVM


In addition to the milestone design above, there are more details that need to be refined. See the open issues page for a list of proposed features (and known issues). For more information about the Ola language and how to use the Ola compiler,  please check out the repo.


Join Us

Sin7y Labs is seeking talented and driven individuals to join our team as developers and local ambassadors/community managers. We offer a dynamic and tech-centered work environment, competitive salary and benefits, and opportunities for career growth and development. If you're interested in being a part of a leading technology company and have a passion for zero-knowledge technology, we'd love to hear from you.


To apply, please write to [email protected] and submit your resume and a cover letter outlining your qualifications and interest in the role. Join the Sin7y - Ola Discord server if you have any further questions


About us

Founded in 2021 and powered by top-notch blockchain developers, Sin7y is a project incubator and blockchain technology research team that explores the most important and cutting-edge technologies, including EVM, Layer2, cross-chain, privacy computing, autonomous payment solutions, etc. We are currently building Ola, a one-stop platform bolstering the Ethereum ecosystem with programmable privacy, programmable scalability, and developer compatibility. If you are interested in talking with us, feel free to join our Discord server or email us at [email protected].