Coder Social home page Coder Social logo

badboilabs / cannon-rs Goto Github PK

View Code? Open in Web Editor NEW
43.0 2.0 6.0 160 KB

Tooling to develop and emulate verifyable programs compatible with Optimism Cannon and the OP Stack ๐Ÿฆ€๐ŸŽ†

License: GNU Lesser General Public License v3.0

Rust 97.60% Just 2.40%

cannon-rs's Introduction

Cannon-rs cannon-rs logo

Contributors Forks Stargazers Issues LGPL-3 License

A comprehensive collection of crates and tools to support development of Cannon programs in Rust

Thinking about contributing? There are bounties available for meaningful contributions via our OnlyDust page!

About The Project

Cannon-rs aims to support the emerging number of projects using Rust to develop provable programs for Optimism Cannon. This is the evolution of the rust-cannon-template supported by the Optimism RetroPGF round 2.

Advantages of using Rust are:

  • Code Reuse - Take advantage of existing, trusted crates in the crypto ecosystem
  • Compact Binaries - Cannon programs built using Rust are much smaller than their Golang equivalents
  • Proving Speed - Generating proofs through emulation for large programs can be slow. Effective use of Rust can reduce the length of the program trace required speeding up the proving process

The project itself provides a number of tools to enable this:

Build system using Docker

Although MIPS is a standard Rust target the specific configuration needed to support the Cannon ISA is quite different. Cannon-rs provides a custom Rust target and a Docker image configured to build elf files which can be patched to run within Cannon.

Guest<->Host Communication

Cannon uses syscalls for communication between the guest program and the host. The cannon-io crate exposes a simple and safe wrapper around the low level syscalls to allow printing to stdout, retrieving data via the pre-image oracle and safely terminating a program with an exit code.

Preimage Server

The Optimism Cannon emulator uses custom IO streams to communicate with a child process responsible for retrieving preimage data given its key. The Cannon preimage server implementation is geared toward providing access to the Ethereum data required for rollup execution.

Cannon-rs provides a simple CLI tool for serving preimages stored in a JSON file. This can be extended with new implementations of the PreimageProvider trait in order to provide a tool suited to your application.

Cargo Cannon tool (WIP)

Makes generating and building new Cannon projects as easy as:

cargo cannon new
cargo cannon build

Prerequisites

Cross compiling for Cannon requires:

  • Docker
  • Just (cargo install just)

Getting Started

  1. Copy the project-template from this repo to get started
  2. Build something awesome in Rust ๐Ÿฆ€
  3. Build for Cannon using just build

Roadmap

  • Rust build system for Cannon MIPS target (no_std)
  • Heap implementation
  • Guest<->Host Communication
    • stdout
    • Request data via Preimage Oracle
    • Hints
  • Template for bootstrapping own projects
  • Preimage Server
  • cargo cannon tooling
    • cargo cannon build to wrap docker cross-compilation
    • cargo cannon new to create new Cannon projects

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are very welcome! To contribute please

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

A huge thanks to all existing contributors from the community!!

Used By

License

Distributed under the LGPL-3 License. See LICENSE for more information.

Contact

Willem Olding - @willemolding1 - [email protected]

Project Link: https://github.com/BadBoiLabs/Cannon-rs

cannon-rs's People

Contributors

ec2 avatar willemolding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cannon-rs's Issues

`cargo cannon new` command

Add a command to the cargo-cannon CLI tool that bootstraps a new cannon-rs project.

This should use a template taken from this repo and fill it with user-defined info

A great example that this could basically copy is cargo-risc0 new.

Add support for hints

The Cannon-vm supports hints as an optional way for the guest program to communicate with the host. It has no effect in the on-chain VM.

This is used in Optimism for example to allow the guest to advise the host to pre-fetch certain pieces of chain data early in execution rather than when it is needed via the pre-image oracle.

Cannon-rs currently does not support the hint syscalls and these should be added for full support.

Write `cargo cannon build` command

Currently the cargo cannon build command is stubbed.

This command should build the project as defined by the cargo arguments (e.g. package, workspace) using the cannon-rs/builder docker image. This image should be retrieved if needed.

See cargo cross for examples of cross-compiling using docker as a cargo extension

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.