Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
**/*.rs.bk
43 changes: 43 additions & 0 deletions risc0-eth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:22.04

# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
build-essential \
git \
libssl-dev \
pkg-config

# Install Rust via rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Verify cargo is available
RUN cargo --version

# Install Foundry
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="/root/.foundry/bin:${PATH}"
RUN foundryup

# Install Foundry & Risc0VM
# RUN curl -L https://foundry.paradigm.xyz | bash
RUN curl -L https://risczero.com/install | bash
# add rzup to path
ENV PATH="/root/.risc0/bin:${PATH}"
RUN rzup install
RUN cargo risczero --version

# Set working directory
WORKDIR /app/src

# # Build the repo during image creation
# RUN git submodule update --init
# RUN cargo build
# RUN forge build

# Optional: Run tests during build (uncomment if desired)
# RUN cargo test
# RUN RISC0_DEV_MODE=false forge test -vvv

# Default command (can be overridden in docker-compose)
# CMD ["bash", "-c", "RISC0_DEV_MODE=false forge test -vvvvv"]
26 changes: 26 additions & 0 deletions risc0-eth/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Running the Project

This project is based on the [risc0-foundry-template](https://github.com/risc0/risc0-foundry-template/).

## Option 1: Run directly on host machine
```bash
cd src
```

## Option 2: Run inside Docker
```bash
docker-compose up --build
docker-compose run --rm risc0-test bash
```

## Build & Test
After setting up using one of the options above, you can:
```bash
# Build the project
cargo build
forge build

# Run tests
cargo test
RISC0_DEV_MODE=false forge test -vvv
```
14 changes: 14 additions & 0 deletions risc0-eth/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
risc0-test:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
volumes:
- ./src:/app/src
environment:
- RISC0_DEV_MODE=false
working_dir: /app/src
command: bash -c "echo 123" # git submodule update --init && cargo build && forge build && cargo test && forge test -vvvvv"

# docker-compose run --rm risc0-test bash
29 changes: 29 additions & 0 deletions risc0-eth/src/.github/workflows/linear.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Find or Create Linear Issue for PR

on:
workflow_dispatch:
pull_request:
branches:
- main
types: ["opened", "edited", "reopened", "synchronize"]

permissions:
pull-requests: write
repository-projects: read


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false

jobs:
create-linear-issue-pr:
runs-on: ubuntu-latest
steps:
- name: Find or create a Linear Issue
uses: risc0/action-find-or-create-linear-issue@risc0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
linear-api-key: ${{ secrets.LINEAR_API_KEY }}
linear-team-key: "WEB3"
linear-created-issue-state-id: "2505ebd6-1fbe-4b25-b2a8-792dfaa50ad9" # in progress
156 changes: 156 additions & 0 deletions risc0-eth/src/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: main

on:
push:
branches: [ main ]
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUST_BACKTRACE: "1"
RISC0_VERSION: 2.0.0
RISC0_TOOLCHAIN_VERSION: 1.85.0

jobs:
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@v4
with:
submodules: recursive

- name: Install rust
uses: risc0/risc0/.github/actions/[email protected]
with:
toolchain: '1.85'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install rzup
run: |
curl -L https://risczero.com/install | bash
echo "$HOME/.risc0/bin" >> $GITHUB_PATH
shell: bash

- name: Install toolchains
run: |
rzup install --verbose cargo-risczero ${{ env.RISC0_VERSION }}
rzup install --verbose r0vm ${{ env.RISC0_VERSION }}
rzup install --verbose --force rust ${{ env.RISC0_TOOLCHAIN_VERSION }}
rzup install --verbose cpp
shell: bash

- name: build rust guest
run: cargo build

- name: build solidity contracts
run: forge build

- name: run tests
run: cargo test

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

integration-test:
name: integration test
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: full
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@v4
with:
submodules: recursive

- name: Install rust
uses: risc0/risc0/.github/actions/[email protected]
with:
toolchain: '1.85'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install rzup
run: |
curl -L https://risczero.com/install | bash
echo "$HOME/.risc0/bin" >> $GITHUB_PATH
shell: bash

- name: Install toolchains
run: |
rzup install --verbose cargo-risczero ${{ env.RISC0_VERSION }}
rzup install --verbose r0vm ${{ env.RISC0_VERSION }}
rzup install --verbose --force rust ${{ env.RISC0_TOOLCHAIN_VERSION }}
rzup install --verbose cpp
shell: bash

- name: build rust guest
run: cargo build

- name: build solidity contracts
run: forge build

- name: run foundry tests with local prover
env:
RISC0_DEV_MODE: false
run: forge test -vvv

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

- name: Install rust
uses: risc0/risc0/.github/actions/[email protected]
with:
toolchain: '1.85'

- name: install cargo-sort
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3
with:
crate: cargo-sort
version: "=1.0.9"
locked: true

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- 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
23 changes: 23 additions & 0 deletions risc0-eth/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
broadcast/

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

# Dotenv file
.env

# Cargo
target/

# Misc
.DS_Store
.idea

# ignore submodules
lib/risc0-ethereum
3 changes: 3 additions & 0 deletions risc0-eth/src/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/risc0-ethereum"]
path = lib/risc0-ethereum
url = https://github.com/risc0/risc0-ethereum
3 changes: 3 additions & 0 deletions risc0-eth/src/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}
10 changes: 10 additions & 0 deletions risc0-eth/src/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rust-analyzer.linkedProjects": [
"./apps/Cargo.toml",
"./methods/Cargo.toml",
"./methods/guest/Cargo.toml",
],
"rust-analyzer.check.extraEnv": {
"RISC0_SKIP_BUILD": "1",
}
}
31 changes: 31 additions & 0 deletions risc0-eth/src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[workspace]
resolver = "2"
members = ["apps", "methods"]
exclude = ["lib"]

[workspace.package]
version = "0.1.0"
edition = "2021"

[workspace.dependencies]
alloy = { version = "0.12", features = ["full"] }
alloy-primitives = { version = "0.8", default-features = false, features = ["rlp", "serde", "std"] }
alloy-sol-types = { version = "0.8" }
anyhow = { version = "1.0.75" }
bincode = { version = "1.3" }
bytemuck = { version = "1" }
hex = { version = "0.4" }
log = { version = "0.4" }
methods = { path = "./methods" }
risc0-build = { version = "2.0.1", features = ["docker"] }
# using git references here to ensure this matches the submodules in ./lib
risc0-build-ethereum = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.0.0" }
risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.0.0" }
risc0-zkvm = { version = "2.0.0" }
risc0-zkp = { version = "2.0.0", default-features = false }
serde = { version = "1.0", features = ["derive", "std"] }
url = { version = "2.5" }

[profile.release]
debug = 1
lto = true
Loading