Skip to content

Commit

Permalink
Cheery pick #133 and #135 and update risc0-zkvm dependencies to v1.0.…
Browse files Browse the repository at this point in the history
…0-rc.7 (#136)

Includes the following three PRs:
- bootstrap for 1.0-rc.7 changes (#133)
- Add bonsai integration CI workflow (#135)
- update risc0 dependencies to 1.0.0-rc.7 (#132)

---------

Co-authored-by: Angelo Capossele <[email protected]>
Co-authored-by: Erik Kaneda <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 157cb34 commit b96ab6f
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 120 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/bonsai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Bonsai integration

on:
pull_request:
branches: ["release-*"]
workflow_dispatch:

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

# this is needed to gain access via OIDC to the S3 bucket for caching
permissions:
id-token: write
contents: read

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_TOOLCHAIN_VERSION: v2024-04-22.0
RISC0_MONOREPO_REF: "v1.0.0-rc.7"

jobs:
e2e-test:
# TODO: Using the nvidia_rtx_a5000 as a workaround because it has jq installed.
# Need to refactor the test-local-deployment.sh script or ensure jq is installed in this job instead.
runs-on: [self-hosted, prod, Linux, nvidia_rtx_a5000]
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- 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) || :"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: risc0/risc0/.github/actions/[email protected]
- uses: risc0/risc0/.github/actions/[email protected]
with:
key: Linux-default
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: ./.github/actions/cargo-risczero-install
with:
ref: ${{ env.RISC0_MONOREPO_REF }}
toolchain-version: ${{ env.RISC0_TOOLCHAIN_VERSION }}
features: default
- name: build erc20-Counter
run: cargo build
working-directory: examples/erc20-counter
- name: test erc20-Counter
run: ./test-local-deployment.sh
env:
BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }}
BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }}
working-directory: examples/erc20-counter
- run: sccache --show-stats
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_TOOLCHAIN_VERSION: v2024-04-22.0
RISC0_MONOREPO_REF: "main"
RISC0_MONOREPO_REF: "v1.0.0-rc.7"

jobs:
# see: https://github.com/orgs/community/discussions/26822
Expand All @@ -45,7 +45,7 @@ jobs:
# Full history is required by license-check.py
fetch-depth: 0
submodules: recursive
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/rustup@v1.0.0-rc.7
- name: Install cargo-sort
uses: risc0/cargo-install@b9307573043522ab0d3e3be64a51763b765b52a4
with:
Expand Down Expand Up @@ -93,9 +93,9 @@ jobs:
with:
submodules: recursive
- if: matrix.feature == 'cuda'
uses: risc0/risc0/.github/actions/cuda@main
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
uses: risc0/risc0/.github/actions/cuda@v1.0.0-rc.7
- uses: risc0/risc0/.github/actions/rustup@v1.0.0-rc.7
- uses: risc0/risc0/.github/actions/sccache@v1.0.0-rc.7
with:
key: ${{ matrix.os }}-${{ matrix.feature }}
- uses: ./.github/actions/cargo-risczero-install
Expand Down Expand Up @@ -134,9 +134,9 @@ jobs:
with:
submodules: recursive
- if: matrix.feature == 'cuda'
uses: risc0/risc0/.github/actions/cuda@main
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
uses: risc0/risc0/.github/actions/cuda@v1.0.0-rc.7
- uses: risc0/risc0/.github/actions/rustup@v1.0.0-rc.7
- uses: risc0/risc0/.github/actions/sccache@v1.0.0-rc.7
with:
key: ${{ matrix.os }}-${{ matrix.feature }}
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
Expand Down Expand Up @@ -167,8 +167,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
- uses: risc0/risc0/.github/actions/rustup@v1.0.0-rc.7
- uses: risc0/risc0/.github/actions/sccache@v1.0.0-rc.7
with:
key: macOS-default
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
Expand Down
43 changes: 22 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ resolver = "2"
members = ["build", "contracts", "ffi", "steel"]

[workspace.package]
version = "1.0.0-rc.6"
version = "1.0.0-rc.7"
edition = "2021"
license = "Apache-2.0"
homepage = "https://risczero.com/"
repository = "https://github.com/risc0/risc0-ethereum/"

[workspace.dependencies]
# Intra-workspace dependencies
risc0-build-ethereum = { version = "1.0.0-rc.6", default-features = false, path = "build" }
risc0-ethereum-contracts = { version = "1.0.0-rc.6", default-features = false, path = "contracts" }
risc0-build-ethereum = { version = "1.0.0-rc.7", default-features = false, path = "build" }
risc0-ethereum-contracts = { version = "1.0.0-rc.7", default-features = false, path = "contracts" }
risc0-steel = { version = "0.11.0", default-features = false, path = "steel" }
risc0-forge-ffi = { version = "1.0.0-rc.6", default-features = false, path = "ffi" }
risc0-forge-ffi = { version = "1.0.0-rc.7", default-features = false, path = "ffi" }

# risc0 monorepo dependencies.
risc0-build = { version = "1.0.0-rc.6", default-features = false }
risc0-zkp = { version = "1.0.0-rc.6", default-features = false }
risc0-zkvm = { version = "1.0.0-rc.6", default-features = false }
risc0-build = { version = "1.0.0-rc.7", default-features = false }
risc0-zkp = { version = "1.0.0-rc.7", default-features = false }
risc0-zkvm = { version = "1.0.0-rc.7", default-features = false }

alloy-primitives = { version = "0.7", features = ["serde", "rlp", "std"] }
alloy-rlp = { version = "0.3.4", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ethers = { version = "2.0", features = ["rustls", "ws"] }
risc0-zkvm = { workspace = true }

[dev-dependencies]
regex = "1.10"
tokio = { version = "1", features = ["macros", "rt"] }

[lib]
Expand Down
41 changes: 41 additions & 0 deletions contracts/src/groth16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,44 @@ pub fn encode(seal: Vec<u8>) -> Result<Vec<u8>> {

Ok(selector_seal)
}

#[cfg(test)]
mod tests {
use anyhow::anyhow;
use ethers::utils::hex;
use regex::Regex;

use super::*;
use std::fs;

const CONTROL_ID_PATH: &str = "./src/groth16/ControlID.sol";
const CONTROL_ROOT: &str = "CONTROL_ROOT";
const BN254_CONTROL_ID: &str = "BN254_CONTROL_ID";

fn parse_digest(file_path: &str, name: &str) -> Result<String, anyhow::Error> {
let content = fs::read_to_string(file_path)?;
let re_digest = Regex::new(&format!(r#"{}\s*=\s*hex"([0-9a-fA-F]+)""#, name))?;
re_digest
.captures(&content)
.and_then(|caps| caps.get(1).map(|m| m.as_str().to_string()))
.ok_or(anyhow!("{name} not found"))
}
#[test]
fn control_root_is_consistent() {
let params = Groth16ReceiptVerifierParameters::default();
let expected_control_root = params.control_root.to_string();
let control_root = parse_digest(CONTROL_ID_PATH, CONTROL_ROOT).unwrap();
assert_eq!(control_root, expected_control_root);
}

#[test]
fn bn254_control_id_is_consistent() {
let params = Groth16ReceiptVerifierParameters::default();
let mut expected_bn254_control_id = params.bn254_control_id;
expected_bn254_control_id.as_mut_bytes().reverse();
let expected_bn254_control_id = hex::encode(expected_bn254_control_id);
let bn254_control_id = parse_digest(CONTROL_ID_PATH, BN254_CONTROL_ID).unwrap();

assert_eq!(bn254_control_id, expected_bn254_control_id);
}
}
4 changes: 2 additions & 2 deletions contracts/src/groth16/ControlID.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pragma solidity ^0.8.9;

library ControlID {
bytes32 public constant CONTROL_ROOT = hex"2c4aec26b74fdb27cd637d6106cfd64f6222aa55de73cd2b73189315b901ca09";
bytes32 public constant CONTROL_ROOT = hex"a516a057c9fbf5629106300934d48e0e775d4230e41e503347cad96fcbde7e2e";
// NOTE: This has opposite byte order to the value in the risc0 repository.
bytes32 public constant BN254_CONTROL_ID = hex"10ff834dbef62ccbba201ecd26a772e3036a075aacbaf47200679a11dcdcf10d";
bytes32 public constant BN254_CONTROL_ID = hex"0eb6febcf06c5df079111be116f79bd8c7e85dc9448776ef9a59aaf2624ab551";
}
2 changes: 1 addition & 1 deletion contracts/test/RiscZeroGroth16Verifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ contract RiscZeroGroth16VerifierTest is Test {
}

function testSelectorIsStable() external view {
require(verifier.SELECTOR() == hex"f7ca3f2c");
require(verifier.SELECTOR() == hex"310fe598");
}
}
4 changes: 2 additions & 2 deletions contracts/test/TestReceipt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pragma solidity ^0.8.13;

library TestReceipt {
bytes public constant SEAL =
hex"f7ca3f2c22c5b4ed763b535cc393c82b9331cd989a4b14070c0faf3c57fa865bd21754472f7cfd5c6a1dbd5fb869ec0835f0793dd6b7e9bccbb13d441a0850b3bf2def4221e20e3da20273e1fba741201759604f9c9acebf94cf37c4486f777ea1d1cd641193b851303c6cc7576145a77cc2db43ee905b6e62b87d82a6599fd345c641fa11634451dff4fe89f8891ddc02c3a8f4d1afe9db973b045571dd6fa327af731b12d02316a9624beef3c42f582d43502b48ac7502b73ddcd96d9bff6bfb92c9ae1af70ed70e95631746b4f0e48c338ce97f27d2ec9a4e3125e0e2f0c24212ba2f20eef84631cafea2f0b7fa6a04c454057f9b24b2829df14fb859c49a6efaa7e7";
hex"310fe598039b6a4c59c576a9afc538bef01bd396cdbc979fe912c4d9c8f4f665c39b8a8f103328a969252a25e1aa69352f7d74b0093476c09e1cc4785201459259341fa220774a7b3e64067d37fa72251fd4766292dbebdea69b55e0790df3fedac65a601cca6fa7ec7d89b5711d8cf0533c1e44dc954de20dd1a7449544a11bd3dd6a453003d2b7dcfae42c88d3b38aa8ce84fc4e022ed91fa1f3ee06ae4b1eacf3033b2d4927494fc2a4dc44b18fac3084fd91d7e161e0e526a033e161f8d69de3babb163578f5916b554bd4a45531913d8c472f03744175bc1000de45110b7cef06d31257b005c5ca02af4704976f6fad82bf6e9e52ea208c7a4c535dc029db456589";
bytes public constant JOURNAL = hex"6a75737420612073696d706c652072656365697074";
bytes32 public constant IMAGE_ID = hex"e3a35e555b8c69a10a97aee621d67321c1d43f018fcf1bfc041faa53e7b869a9";
bytes32 public constant IMAGE_ID = hex"0e3b8f40fe72d3e43d0c29df23fd4b02607c9ae59bc166fb306fa2aa2ac7d640";
}
Loading

0 comments on commit b96ab6f

Please sign in to comment.