Skip to content

Latest commit

 

History

History

project-template

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Rust Cannon Template 🦀💣💥

This repo contains a build system and a minimal Rust program for building MIPS binaries that are executable in the context of Optimism Cannon.

It is intended to be used as a template with cargo generate e.g.

cargo generate BadBoiLabs/Cannon-rs

Building

Building with Docker

Preferred build method is using docker. BadBoiLabs provides a builder image for Cannon-rs projects

docker run --rm -v `pwd`/..:/code -w="/code" ghcr.io/badboilabs/cannon-rs/builder:main cargo build --release -Zbuild-std 

or use the just script provided

just build

Patching and running in Cannon

Install the cannon tool from Optimism (requires Golang installed)

git clone https://github.com/ethereum-optimism/optimism
cd optimism/cannon
go install .

Patch the elf

cannon load-elf --path ../target/mips-unknown-none/release/{{project-name}} --patch stack

Run it in the Cannon emulator

cannon run --input ./state.json --info-at %100 --stop-at never

Credits

The origins of this amazing work is from @pepyakin in their Cannon fork. This has evolved into a streamlined Cannon build system and been migrated to the latest version of Cannon