reilabs / hieratika

Efforts to compile LLVM bytecode to run on top of the CairoVM and hence execute provably on Starknet
http://starknet.io
Apache License 2.0
1 stars 0 forks source link
compiler emulator llvm starknet

Hieratika: Compiling LLVM to CairoVM

hieratiká /ˌhaɪ(ə)ˈɹætɪka/, adjective

Of or pertaining to the cursive writing system that developed alongside the hieroglyphic system as its handwritten counterpart for every-day use. It took the "priestly", domain-specific hieroglyphics and repurposed them for non-domain-specific expression.

This repository contains the efforts to enable compilation of LLVM bytecode to run on top of the CairoVM and hence Starknet. The goals of this project are threefold:

  1. Provable Rust Execution: To provide the ability to prove the execution of LLVM bytecode using Starknet's proving infrastructure, thereby allowing verification of said execution.
  2. Writing Contracts in LLVM Languages: To provide the ability to write contracts for execution on Starknet using any language that compiles to LLVM (while recognizing that this will require a small per-language effort).
  3. Using Foreign Libraries from Cairo: There exist a wealth of useful cryptographic libraries in languages such as Rust that compile to LLVM. Rather than requiring users to reimplement them in Cairo, this effort would allow them to be exposed directly.

The initial efforts for this project are focusing on using Rust as the source of the LLVM bytecode, and will see support libraries implemented for this language. Nevertheless, this project aims to be agnostic to the actual source language of the bytecode besides the language-specific libraries.

Architectural Overview

As there is a significant mismatch between the computational model expected by LLVM, and the Cairo model of execution, we take a multi-layered approach.

As Cairo is not an operating system, we restrict our source code to be #[no_std] or the equivalent for other languages. This is necessary as we cannot provide useful primitives for things like the filesystem, network, or even threading.

In the future, we intend to move many of our polyfilled operations into native operations as part of the CASM instruction set, or as Cairo builtins to improve performance. Starting with the emulation or polyfill layer, however, lets us determine which operations are going to be most effective to transfer first, and help us arrive to the final design of such operations before moving them to AIR.

Contributing

If you want to contribute code or documentation (non-code contributions are always welcome) to this project, please take a look at our contributing documentation. It provides an overview of how to get up and running, as well as what the contribution process looks like for this repository.