Giter Site home page Giter Site logo

malik672 / cannon-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anton-rs/cannon-rs

0.0 0.0 0.0 13.31 MB

An alternative implementation of the OP Stack's Cannon, a MIPS emulator for the EVM.

License: MIT License

Shell 0.66% Python 0.43% Go 0.65% Assembly 30.96% Rust 67.01% Makefile 0.27% Dockerfile 0.02%

cannon-rs's Introduction

Cannon

An alternative implementation of the OP Stack's Cannon in Rust.

Ci License OP Stack

What's a Cannon?OverviewCreditsBenchmarksContributingDocumentationDocker

What's a Cannon?

Cannon is an emulator designed to simulate a single MIPS thread context on the EVM. Its primary use is to execute the op-program (also known as the fault-proof program) for the OP Stack's interactive dispute protocol. The op-program consists of a stripped down version of op-geth's state transition code in addition to the derivation pipeline, and produces deterministic results. Subsequently, it is compiled to MIPS to be ran on top of Cannon on-chain to prove fault in claims about the state of L2 on L1. Cannon also has a native implementation of the MIPS thread context that mirrors the on-chain version, which enables the op-challenger to generate state commitments for an op-program execution trace and participate in dispute games.

TL;DR:

Overview

  • cannon-mipsevm - Contains the native implementation of the MIPS thread context emulator.
  • preimage-oracle - Rust bindings for interacting as client or sever over the Pre-image Oracle ABI.
  • cannon-contracts - [in OP monorepo] Contains the Solidity implementation of the MIPS thread context and the Preimage Oracle.

Credits

This repository is heavily inspired by the original Cannon, built by George Hotz and members of the OP Labs team. The original implementation is written in Go, and can be found in the Optimism monorepo. All credits for the original idea and reference implementation of this concept go to these folks.

Benchmarks

cannon-mipsevm benchmarks

The below benchmark was ran on a 2021 Macbook Pro with an M1 Max and 32 GB of unified memory on commit 71b68d5.

Benchmark Name cannon mean (Reference) cannon-rs mean
Memory Merkle Root (25MB) 736.94 ms 29.58 µs (-99%)
Memory Merkle Root (50MB) 1.54s 7.25 ms (-99%)
Memory Merkle Root (100MB) 3.34s 273.76 ms (-91.8%)
Memory Merkle Root (200MB) 6.30s 1.65s (-73.81%)

todo - execution benchmarks

Contributing

To get started, a few dependencies are required:

Testing

# With `cargo-nextest`
cargo +nightly nextest run --release --all --all-features
# Without `cargo-nextest`
cargo +nightly t --release --all --all-features

Linting and Formatting

cargo +nightly fmt --all -- && cargo +nightly clippy --all --all-features -- -D warnings

Running Benchmarks

cargo +nightly bench --all --all-features

Documentation

Rustdocs are available by running cargo doc --open after cloning the repo.

Specification

The specification for both Cannon and the preimage oracle can be found in the Optimism monorepo.

Docker

The docker image for cannon-rs is located in the docker directory, and can be built using the script provided.

cannon-rs's People

Contributors

clabby avatar refcell 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.