-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from BadBoiLabs/willem/update-to-cannon-v2
simplify for cannonv2
- Loading branch information
Showing
19 changed files
with
53 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
target | ||
build | ||
venv | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,45 @@ | ||
# 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](https://github.com/ethereum-optimism/cannon). | ||
|
||
It comes with a few barebones helpers for reading the input hashes, writing output and using the pre-image oracle. | ||
This repo contains a build system and a minimal Rust program for building MIPS binaries that are executable in the context of [Optimism Cannon](https://github.com/ethereum-optimism/optimism/tree/develop/cannon). | ||
|
||
It is intended to be used as a template with `cargo generate` e.g. | ||
|
||
```shell | ||
cargo generate willemolding/rust-cannon-template | ||
cargo generate BadBoiLabs/rust-cannon-template | ||
``` | ||
|
||
## Usage | ||
## Building | ||
|
||
### Building with Docker | ||
|
||
The template uses Docker for cross-compiling MIPS on any host. First build the docker image by running: | ||
Preferred build method is using docker. BadBoiLabs provides a builder image for Cannon-rs projects | ||
|
||
```shell | ||
make docker_image | ||
docker run --rm -v `pwd`/..:/code -w="/code" ghcr.io/badboilabs/cannon-rs/builder:main cargo build --release -Zbuild-std | ||
``` | ||
|
||
After this a Cannon ready MIPS binary can be build with: | ||
## Patching and running in Cannon | ||
|
||
Install the `cannon` tool from Optimism (requires Golang installed) | ||
|
||
```shell | ||
make build | ||
git clone https://github.com/ethereum-optimism/optimism | ||
cd optimism/cannon | ||
go install . | ||
``` | ||
|
||
This will write an `out.bin` file to the build directory. | ||
|
||
--- | ||
Patch the elf | ||
|
||
Alternatively if you want to experiment in the build environment you can load up an interactive shell with | ||
|
||
```shell | ||
make docker_image | ||
docker run -it --rm -v $(pwd):/code {{project-name}}/builder bash | ||
cannon load-elf --path ../target/mips-unknown-none/release/{{project-name}} --patch stack | ||
``` | ||
(replace with your project name as required) | ||
|
||
and from there you can run | ||
Run it in the Cannon emulator | ||
|
||
```shell | ||
./build.sh | ||
cannon run --input ./state.json --info-at %100 --stop-at never | ||
``` | ||
to produce the output | ||
|
||
## Credits | ||
|
||
The majority of this amazing work was done by @pepyakin in their [Cannon fork](https://github.com/pepyakin/rusty-cannon/). This just pulls out the relevant pieces and adds a few quality of life improvements to the build system. | ||
The origins of this amazing work is from @pepyakin in their [Cannon fork](https://github.com/pepyakin/rusty-cannon/). This has evolved into a streamlined Cannon build system and been migrated to the latest version of Cannon |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.