Skip to content

Commit

Permalink
New Bonsai Foundry Template (#74)
Browse files Browse the repository at this point in the history
New foundry template, sans relay
  • Loading branch information
capossele authored Feb 24, 2024
1 parent d41f9e9 commit 9f194e4
Show file tree
Hide file tree
Showing 49 changed files with 2,997 additions and 3,208 deletions.
28 changes: 1 addition & 27 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
[build]
rustflags = [
"-Dclippy::correctness",
"-Dclippy::suspicious",
"-Wclippy::complexity",
"-Wclippy::perf",
"-Wclippy::style",
"-Wclippy::unwrap_used",
"-Wclippy::expect_used",
"-Dclippy::needless_return",
"-Dbad_style",
"-Dbare_trait_objects",
"-Ddead_code",
"-Dimproper_ctypes",
"-Dno_mangle_generic_items",
"-Dnon_shorthand_field_patterns",
"-Doverflowing_literals",
"-Dpath_statements",
"-Dpatterns_in_fns_without_body",
"-Dtrivial_casts",
"-Dtrivial_numeric_casts",
"-Dunconditional_recursion",
"-Dunused_allocation",
"-Dunused_comparisons",
"-Wunused_extern_crates",
"-Dunused_parens",
"-Dwhile_true",
]
rustflags = ["-Dclippy::all", "-Dwarnings"]

[net]
git-fetch-with-cli = true
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/clean.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/lint.yml

This file was deleted.

91 changes: 66 additions & 25 deletions .github/workflows/test.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: main

on:
push:
Expand All @@ -13,27 +13,26 @@ concurrency:
cancel-in-progress: true

env:
RUST_BACKTRACE: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_VERSION: 0.20.1
RISC0_TOOLCHAIN_VERSION: test-release-2
RUST_BACKTRACE: "1"
RISC0_CRATE_VERSION: "^0.20"
RISC0_TOOLCHAIN_VERSION: v2024-01-31.1

jobs:
integration:
name: local mock relay integration tests
runs-on: [self-hosted, prod, Linux, X64]
test:
runs-on: ubuntu-latest
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- name: checkout dummy commit (submodule bug workaround)
run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"

- name: clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: install rust
uses: risc0/risc0/.github/actions/rustup@release-0.19
- name: Install rust
uses: risc0/risc0/.github/actions/rustup@release-0.20

- name: Install Foundry
uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
Expand All @@ -44,34 +43,39 @@ jobs:
crate: cargo-binstall

- name: Cargo binstall cargo-risczero
run: cargo binstall -y --force cargo-risczero@${{ env.RISC0_VERSION }}
run: cargo binstall -y --force cargo-risczero@${{ env.RISC0_CRATE_VERSION }}

- name: risczero toolchain install
run: cargo risczero install --version $RISC0_TOOLCHAIN_VERSION

- name: build rust guest
run: cargo build

- name: build solidity contracts
run: forge build

- name: build rust guest
run: cargo build
- name: run tests
run: cargo test

- name: run foundry tests with local exec
- name: run foundry tests in dev mode
env:
RISC0_DEV_MODE: true
run: forge test -vvv

e2e:
name: end 2 end tests
runs-on: [self-hosted, prod, Linux, X64]
bonsai-integration:
name: test bonsai integration
runs-on: ubuntu-latest
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- name: checkout dummy commit (submodule bug workaround)
run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"

- name: clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: install rust
- name: Install rust
uses: risc0/risc0/.github/actions/[email protected]

- name: Install Foundry
Expand All @@ -83,20 +87,57 @@ jobs:
crate: cargo-binstall

- name: Cargo binstall cargo-risczero
run: cargo binstall -y --force cargo-risczero@${{ env.RISC0_VERSION }}
run: cargo binstall -y --force cargo-risczero@${{ env.RISC0_CRATE_VERSION }}

- name: risczero toolchain install
run: cargo risczero install --version $RISC0_TOOLCHAIN_VERSION

- name: build solidity contracts
run: forge build

- name: build rust guest
run: cargo build

- name: run foundry tests with bonsai alpha proving
- name: build solidity contracts
run: forge build

- name: run foundry tests with bonsai proving
env:
BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }}
BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }}
RISC0_DEV_MODE: false
run: forge test -vvv

lint:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
with:
submodules: recursive

- name: install rust
uses: risc0/risc0/.github/actions/[email protected]

- name: install cargo-sort
uses: risc0/cargo-install@v1
with:
crate: cargo-sort
version: "=1.0.7"

- name: Install Foundry
uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f

- name: lint rust code
run: cargo fmt --all --check

- name: lint guest rust code
working-directory: methods/guest
run: cargo fmt --all --check

- name: lint cargo files
run: cargo sort --workspace --check

- name: lint guest cargo files
working-directory: methods/guest
run: cargo sort --workspace --check

- name: check solidity code formatting
run: forge fmt --check
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ out/
/broadcast/*/11155111/
/broadcast/**/dry-run/

# Autogenerated contracts
contracts/ImageID.sol
tests/Elf.sol

# Dotenv file
.env

# Cargo
target/

# Misc
.idea
.DS_Store
.idea
7 changes: 3 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
[submodule "lib/solidity-bytes-utils"]
path = lib/solidity-bytes-utils
url = https://github.com/GNSPS/solidity-bytes-utils
[submodule "lib/risc0"]
path = lib/risc0
url = https://github.com/risc0/risc0
branch = "release-0.20"
[submodule "lib/risc0-ethereum"]
path = lib/risc0-ethereum
url = https://github.com/risc0/risc0-ethereum
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rust-analyzer.linkedProjects": [
"./apps/Cargo.toml",
"./methods/Cargo.toml",
"./methods/guest/Cargo.toml",
]
}
Loading

0 comments on commit 9f194e4

Please sign in to comment.