Skip to content

Commit 78393a9

Browse files
feat: v2 base and deferral solidity verifiers (#24)
1 parent c7e9118 commit 78393a9

18 files changed

Lines changed: 11630 additions & 7 deletions
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: OpenVM SDK Consistency Check
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "OpenVM version to check, e.g. 2.0.0"
8+
required: true
9+
10+
env:
11+
GENERATOR_MANIFEST: tools/generate-verifier/Cargo.toml
12+
VERSION: ${{ github.event.inputs.version }}
13+
14+
jobs:
15+
consistency-check:
16+
name: v${{ github.event.inputs.version }}-${{ matrix.variant }}
17+
runs-on:
18+
- runs-on=${{ github.run_id }}
19+
- family=m7a.24xlarge
20+
- volume=80gb
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
variant: [base, deferral]
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: dtolnay/rust-toolchain@stable
30+
31+
- uses: Swatinem/rust-cache@v2
32+
with:
33+
workspaces: tools/generate-verifier
34+
35+
- name: Install solc
36+
run: |
37+
(hash svm 2>/dev/null || cargo install --version 0.2.23 svm-rs)
38+
svm install 0.8.19
39+
solc --version
40+
41+
- uses: foundry-rs/foundry-toolchain@v1
42+
with:
43+
version: v1.5.0
44+
45+
- name: Build generator
46+
run: |
47+
cargo fmt --check --manifest-path "${GENERATOR_MANIFEST}"
48+
cargo build --release --locked --manifest-path "${GENERATOR_MANIFEST}" --bin generate-verifier
49+
50+
- name: Generate verifier
51+
run: |
52+
trunc_version="$(echo "${VERSION}" | cut -d '.' -f1-2)"
53+
expected="${VERSION%.*}"
54+
test "${trunc_version}" = "${expected}"
55+
expected_dir="v${trunc_version}-${{ matrix.variant }}"
56+
57+
generated_dir="$(mktemp -d)"
58+
tools/generate-verifier/target/release/generate-verifier \
59+
--variant "${{ matrix.variant }}" \
60+
--output-dir "${generated_dir}"
61+
62+
test -d "${generated_dir}/src/${expected_dir}"
63+
test -d "src/${expected_dir}"
64+
65+
echo "GENERATED_DIR=${generated_dir}" >> "$GITHUB_ENV"
66+
echo "VERSION_DIR=${expected_dir}" >> "$GITHUB_ENV"
67+
68+
- name: Compare bytecode
69+
run: |
70+
repo_root="$(mktemp -d)"
71+
generated_root="$(mktemp -d)"
72+
mkdir -p "${repo_root}/src" "${generated_root}/src"
73+
74+
cp foundry.toml "${repo_root}/foundry.toml"
75+
cp foundry.toml "${generated_root}/foundry.toml"
76+
cp -R "src/${VERSION_DIR}" "${repo_root}/src/${VERSION_DIR}"
77+
cp -R "${GENERATED_DIR}/src/${VERSION_DIR}" "${generated_root}/src/${VERSION_DIR}"
78+
79+
forge fmt --root "${repo_root}"
80+
forge fmt --root "${generated_root}"
81+
forge build --force --root "${repo_root}" --config-path "${repo_root}/foundry.toml"
82+
forge build --force --root "${generated_root}" --config-path "${generated_root}/foundry.toml"
83+
84+
diff \
85+
<(jq -r '.bytecode.object | ltrimstr("0x")' "${repo_root}/out/OpenVmHalo2Verifier.sol/OpenVmHalo2Verifier.json") \
86+
<(jq -r '.bytecode.object | ltrimstr("0x")' "${generated_root}/out/OpenVmHalo2Verifier.sol/OpenVmHalo2Verifier.json")

.github/workflows/consistency.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ on:
1212

1313
env:
1414
VERSION: ${{ github.event.inputs.version }}
15+
SDK_VERSION: ${{ github.event.inputs.sdk-version }}
1516

1617
concurrency:
17-
group: ${{ github.workflow }}-${{ github.event.inputs.version }}
18+
group: ${{ github.workflow }}-${{ github.event.inputs.version }}-${{ github.event.inputs.sdk-version }}
1819
cancel-in-progress: true
1920

2021
run-name: "check ${{ github.event.inputs.sdk-version }} verifier is consistent with OpenVM version ${{ github.event.inputs.version }}"
@@ -41,6 +42,14 @@ jobs:
4142
echo "::error::TRUNC_VERSION mismatch: got '$TRUNC_VERSION' but expected '$expected'"
4243
exit 1
4344
fi
45+
if [[ "$SDK_VERSION" != "$TRUNC_VERSION" && "$SDK_VERSION" != "$TRUNC_VERSION"-* ]]; then
46+
echo "::error::sdk-version '$SDK_VERSION' must be '$TRUNC_VERSION' or a '$TRUNC_VERSION-*' variant"
47+
exit 1
48+
fi
49+
if [[ "$TRUNC_VERSION" == v2.* && "$SDK_VERSION" != "$TRUNC_VERSION-base" ]]; then
50+
echo "::error::cargo openvm setup --evm only generates the '$TRUNC_VERSION-base' verifier; got sdk-version '$SDK_VERSION'"
51+
exit 1
52+
fi
4453
4554
- name: Install solc # svm should support arm64 linux
4655
run: (hash svm 2>/dev/null || cargo install --version 0.2.23 svm-rs) && svm install 0.8.19 && solc --version
@@ -65,8 +74,8 @@ jobs:
6574
mkdir -p "${compare_dir}/repo/src" "${compare_dir}/generated/src"
6675
cp foundry.toml "${compare_dir}/repo/foundry.toml"
6776
cp foundry.toml "${compare_dir}/generated/foundry.toml"
68-
cp -R "src/${TRUNC_VERSION}" "${compare_dir}/repo/src/${TRUNC_VERSION}"
69-
cp -R "${HOME}/.openvm/halo2/src/${TRUNC_VERSION}" "${compare_dir}/generated/src/${TRUNC_VERSION}"
77+
cp -R "src/${SDK_VERSION}" "${compare_dir}/repo/src/${SDK_VERSION}"
78+
cp -R "${HOME}/.openvm/halo2/src/${SDK_VERSION}" "${compare_dir}/generated/src/${SDK_VERSION}"
7079
7180
forge fmt --root "${compare_dir}/repo"
7281
forge fmt --root "${compare_dir}/generated"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiler files
22
cache/
33
out/
4+
target/
45

56
# Ignores development broadcast logs
67
!/broadcast

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/openvm-org/openvm-solidity-sdk)
44

5-
This repository contains OpenVM verifier contracts generated from official release commits of the [openvm](https://github.com/openvm-org/openvm) repository using the default VM configuration via the cargo-openvm CLI tool. If you're using an advanced or custom VM configuration, you may need to generate and maintain your own verifier contracts separately.
5+
This repository contains OpenVM verifier contracts generated from official release commits of the [openvm](https://github.com/openvm-org/openvm) repository, either by the cargo-openvm CLI tool or the OpenVM SDK. Most releases use the default VM configuration; some releases may include additional supported variants, such as the v2.0 deferral-enabled verifier. If you're using an advanced or custom VM configuration, you may need to generate and maintain your own verifier contracts separately.
66

77
The contracts are built on every _minor_ release as OpenVM guarantees verifier backward compatibility across patch releases.
88

@@ -14,12 +14,21 @@ To install `openvm-solidity-sdk` as a dependency in your forge project, run the
1414
forge install openvm-org/openvm-solidity-sdk
1515
```
1616

17+
## v2.0 Contract Variants
18+
19+
The v2.0 verifier contracts are published in two variants:
20+
21+
- `v2.0-base` is the standard verifier generated for the default OpenVM v2.0 configuration.
22+
- `v2.0-deferral` is generated with deferral support enabled. Use this variant when your verifier must support verifying `verify-stark` guest programs.
23+
24+
The examples below use `v2.0-base`. If your application needs guest program `verify-stark` support, replace `v2.0-base` with `v2.0-deferral` in the import and deployment paths.
25+
1726
## Usage
1827

1928
If you are using a deployed instance of the verifier contract, then you can import the interfaces in your contract directly.
2029

2130
```solidity
22-
import { IOpenVmHalo2Verifier } from "openvm-solidity-sdk/v1.7/interfaces/IOpenVmHalo2Verifier.sol";
31+
import { IOpenVmHalo2Verifier } from "openvm-solidity-sdk/v2.0-base/interfaces/IOpenVmHalo2Verifier.sol";
2332
2433
contract MyContract {
2534
function myFunction() public view {
@@ -36,7 +45,7 @@ contract MyContract {
3645
If you want to deploy your own instance of the verifier contract, you can use `forge create`:
3746

3847
```bash
39-
forge create src/v1.7/OpenVmHalo2Verifier.sol:OpenVmHalo2Verifier --rpc-url $RPC --private-key $PRIVATE_KEY --broadcast
48+
forge create src/v2.0-base/OpenVmHalo2Verifier.sol:OpenVmHalo2Verifier --rpc-url $RPC --private-key $PRIVATE_KEY --broadcast
4049
```
4150

4251
If you want to import the verifier contract into your own repository for testing purposes, note that it is locked to Solidity version `0.8.19`. If your project uses a different version, the import may not compile. As a workaround, you can compile the contract separately and use `vm.etch()` to inject the raw bytecode into your tests.

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ optimizer = true
88
optimizer_runs = 100000
99
evm_version = "paris"
1010
show_progress = true
11-
fs_permissions = [{ access = "read", path = "./test/v1.2/evm.proof"}, { access = "read", path = "./test/v1.3/evm.proof"}, { access = "read", path = "./test/v1.4/evm.proof"}, { access = "read", path = "./test/v1.5/evm.proof"}, { access = "read", path = "./test/v1.6/evm.proof"}, { access = "read", path = "./test/v1.7/evm.proof"}]
11+
fs_permissions = [{ access = "read", path = "./test/v1.2/evm.proof"}, { access = "read", path = "./test/v1.3/evm.proof"}, { access = "read", path = "./test/v1.4/evm.proof"}, { access = "read", path = "./test/v1.5/evm.proof"}, { access = "read", path = "./test/v1.6/evm.proof"}, { access = "read", path = "./test/v1.7/evm.proof"}, { access = "read", path = "./test/v2.0-base/evm.proof"}, { access = "read", path = "./test/v2.0-deferral/evm.proof"}]
1212

1313
[profile.default.optimizer_details]
1414
constantOptimizer = false

0 commit comments

Comments
 (0)