From 5ce2a9cc9c2dd9aa8daeab67aaf8f85fa1b66a63 Mon Sep 17 00:00:00 2001 From: Hrik Bhowal <23041116+HrikB@users.noreply.github.com> Date: Mon, 5 May 2025 11:02:00 -0400 Subject: [PATCH 1/5] chore: update contracts for v1.1.1 --- foundry.toml | 2 +- src/{v1.0.1 => v1.1.1}/Halo2Verifier.sol | 0 src/{v1.0.1 => v1.1.1}/OpenVmHalo2Verifier.sol | 2 +- src/{v1.0.1 => v1.1.1}/interfaces/IOpenVmHalo2Verifier.sol | 0 test/{v1.0.1 => v1.1.1}/OpenVmHalo2Verifer.t.sol | 4 ++-- test/{v1.0.1 => v1.1.1}/evm.proof | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename src/{v1.0.1 => v1.1.1}/Halo2Verifier.sol (100%) rename src/{v1.0.1 => v1.1.1}/OpenVmHalo2Verifier.sol (99%) rename src/{v1.0.1 => v1.1.1}/interfaces/IOpenVmHalo2Verifier.sol (100%) rename test/{v1.0.1 => v1.1.1}/OpenVmHalo2Verifer.t.sol (97%) rename test/{v1.0.1 => v1.1.1}/evm.proof (100%) diff --git a/foundry.toml b/foundry.toml index ebbf0b6..c073ccf 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,7 +8,7 @@ optimizer = true optimizer_runs = 100000 evm_version = "paris" show_progress = true -fs_permissions = [{ access = "read", path = "./test/v1.0.1/evm.proof"}] +fs_permissions = [{ access = "read", path = "./test/v1.1.1/evm.proof"}] [profile.default.optimizer_details] constantOptimizer = false diff --git a/src/v1.0.1/Halo2Verifier.sol b/src/v1.1.1/Halo2Verifier.sol similarity index 100% rename from src/v1.0.1/Halo2Verifier.sol rename to src/v1.1.1/Halo2Verifier.sol diff --git a/src/v1.0.1/OpenVmHalo2Verifier.sol b/src/v1.1.1/OpenVmHalo2Verifier.sol similarity index 99% rename from src/v1.0.1/OpenVmHalo2Verifier.sol rename to src/v1.1.1/OpenVmHalo2Verifier.sol index ef41b44..5969495 100644 --- a/src/v1.0.1/OpenVmHalo2Verifier.sol +++ b/src/v1.1.1/OpenVmHalo2Verifier.sol @@ -29,7 +29,7 @@ contract OpenVmHalo2Verifier is Halo2Verifier, IOpenVmHalo2Verifier { uint256 private constant FULL_PROOF_LENGTH = (12 + 2 + PUBLIC_VALUES_LENGTH + 43) * 32; /// @dev The version of OpenVM that generated this verifier. - string public constant OPENVM_VERSION = "1.0.1-rc.0"; + string public constant OPENVM_VERSION = "1.1.1"; /// @notice A wrapper that constructs the proof into the right format for /// use with the `snark-verifier` verification. diff --git a/src/v1.0.1/interfaces/IOpenVmHalo2Verifier.sol b/src/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol similarity index 100% rename from src/v1.0.1/interfaces/IOpenVmHalo2Verifier.sol rename to src/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol diff --git a/test/v1.0.1/OpenVmHalo2Verifer.t.sol b/test/v1.1.1/OpenVmHalo2Verifer.t.sol similarity index 97% rename from test/v1.0.1/OpenVmHalo2Verifer.t.sol rename to test/v1.1.1/OpenVmHalo2Verifer.t.sol index 66ba4a6..af2e1b4 100644 --- a/test/v1.0.1/OpenVmHalo2Verifer.t.sol +++ b/test/v1.1.1/OpenVmHalo2Verifer.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.19; -import { OpenVmHalo2Verifier } from "../../src/v1.0.1/OpenVmHalo2Verifier.sol"; +import { OpenVmHalo2Verifier } from "../../src/v1.1.1/OpenVmHalo2Verifier.sol"; import { LibString } from "../helpers/LibString.sol"; import { Test, console2, safeconsole as console } from "forge-std/Test.sol"; @@ -26,7 +26,7 @@ contract OpenVmHalo2VerifierTest is Test { } function test_ValidProofVerifies() public view { - string memory evmProofJson = vm.readFile("test/v1.0.1/evm.proof"); + string memory evmProofJson = vm.readFile("test/v1.1.1/evm.proof"); bytes32 _appExeCommit = vm.parseJsonBytes32(evmProofJson, ".app_exe_commit"); bytes32 _appVmCommit = vm.parseJsonBytes32(evmProofJson, ".app_vm_commit"); bytes memory _guestPvs = vm.parseJsonBytes(evmProofJson, ".user_public_values"); diff --git a/test/v1.0.1/evm.proof b/test/v1.1.1/evm.proof similarity index 100% rename from test/v1.0.1/evm.proof rename to test/v1.1.1/evm.proof From 2a17102bf5e5eb39e6dc146498c3e2688c2cb364 Mon Sep 17 00:00:00 2001 From: Hrik Bhowal <23041116+HrikB@users.noreply.github.com> Date: Mon, 5 May 2025 14:45:22 -0400 Subject: [PATCH 2/5] docs: add README --- README.md | 72 +++++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 9265b45..9aef445 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,42 @@ -## Foundry +# OpenVM Solidity SDK -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** +This repo houses OpenVM verifier contracts generated on official release commits of the [openvm](https://github.com/openvm-org/openvm) repo with the default VM config using the `cargo-openvm` cli tool. Advanced VM configurations may require their own generations. -Foundry consists of: +## Installation -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. +To install `openvm-solidity-sdk` as a dependency in your forge project, run the following: -## Documentation - -https://book.getfoundry.sh/ - -## Usage - -### Build - -```shell -$ forge build -``` - -### Test - -```shell -$ forge test +```bash +forge install openvm-org/openvm-solidity-sdk ``` -### Format +## Usage -```shell -$ forge fmt -``` +If you are using a deployed instance of the verifier contract, then you can import the interfaces in your contract directly. -### Gas Snapshots +```solidity +import { IOpenVmHalo2Verifier } from "openvm-solidity-sdk/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol"; -```shell -$ forge snapshot -``` +contract MyContract { + function myFunction() public view { + // ... snip ... -### Anvil + IOpenVmHalo2Verifier(verifierAddress) + .verify(publicValues, proofData, appExeCommit, appVmCommit); -```shell -$ anvil + // ... snip ... + } +} ``` -### Deploy +If you want to deploy your own instance of the verifier contract, you can use `forge create`: -```shell -$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key +```bash +forge create src/v1.1.1/OpenVmHalo2Verifier.sol:OpenVmHalo2Verifier --rpc-url $RPC --private-key $PRIVATE_KEY --broadcast ``` -### Cast +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. -```shell -$ cast -``` - -### Help +## Audits -```shell -$ forge --help -$ anvil --help -$ cast --help -``` +You can find the audit reports for these contracts in the [OpenVM repo](https://github.com/openvm-org/openvm/tree/main/audits). From d8402680816754e6c2d934742c44fe99dc0df748 Mon Sep 17 00:00:00 2001 From: Hrik Bhowal <23041116+HrikB@users.noreply.github.com> Date: Mon, 5 May 2025 15:03:51 -0400 Subject: [PATCH 3/5] chore: ci --- .github/workflows/consistency.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/consistency.yml b/.github/workflows/consistency.yml index 6cec7b9..36237ab 100644 --- a/.github/workflows/consistency.yml +++ b/.github/workflows/consistency.yml @@ -2,13 +2,23 @@ name: OpenVM Repo Consistency Check on: workflow_dispatch: + inputs: + version: + description: "Version to check" + required: true + + release: + types: [published] + +env: + VERSION: ${{ github.event.inputs.version || github.event.release.tag_name }} concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + group: ${{ github.workflow }}-${{ github.event.inputs.version || github.event.release.tag_name }} cancel-in-progress: true jobs: - checks: + consistency-check: runs-on: - runs-on=${{ github.run_id }} - family=m7a.24xlarge @@ -25,7 +35,7 @@ jobs: run: | git clone https://github.com/openvm-org/openvm.git cd openvm - git checkout feat/format-verifier + git checkout ${VERSION} - name: Run openvm setup run: | @@ -37,9 +47,9 @@ jobs: - name: Compare output to version folder run: | - diff -r ~/.openvm/halo2/src/v1.0.1-rc.0 src/v1.0.1-rc.0 --exclude=verifier.bytecode.json + diff -r ~/.openvm/halo2/src/${VERSION} src/${VERSION} --exclude=verifier.bytecode.json - name: Compare compiled bytecode in repo to verifier.bytecode.json run: | forge build --force - diff <(jq -r '.bytecode.object | ltrimstr("0x")' out/OpenVmHalo2Verifier.sol/OpenVmHalo2Verifier.json) <(jq -r '.bytecode | ltrimstr("0x")' ~/.openvm/halo2/src/v1.0.1-rc.0/verifier.bytecode.json) + diff <(jq -r '.bytecode.object | ltrimstr("0x")' out/OpenVmHalo2Verifier.sol/OpenVmHalo2Verifier.json) <(jq -r '.bytecode | ltrimstr("0x")' ~/.openvm/halo2/src/${VERSION}/verifier.bytecode.json) From f3274fd8ffee9f8d90d82d2f7bf54fd81af0e26e Mon Sep 17 00:00:00 2001 From: Hrik Bhowal <23041116+HrikB@users.noreply.github.com> Date: Tue, 6 May 2025 14:00:50 -0400 Subject: [PATCH 4/5] chore: add comment in README about only building across minor releases --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9aef445..479d861 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # OpenVM Solidity SDK -This repo houses OpenVM verifier contracts generated on official release commits of the [openvm](https://github.com/openvm-org/openvm) repo with the default VM config using the `cargo-openvm` cli tool. Advanced VM configurations may require their own generations. +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. + +The contracts are built on every _minor_ release as OpenVM guarantees verifier backward compatibility across patch releases. ## Installation From 051c8a99fd2f594bea5e2ad43d8017af687c2704 Mon Sep 17 00:00:00 2001 From: Hrik Bhowal <23041116+HrikB@users.noreply.github.com> Date: Tue, 6 May 2025 17:30:13 -0400 Subject: [PATCH 5/5] chore: rename to v1.1 --- foundry.toml | 2 +- src/{v1.1.1 => v1.1}/Halo2Verifier.sol | 0 src/{v1.1.1 => v1.1}/OpenVmHalo2Verifier.sol | 0 src/{v1.1.1 => v1.1}/interfaces/IOpenVmHalo2Verifier.sol | 0 test/{v1.1.1 => v1.1}/OpenVmHalo2Verifer.t.sol | 4 ++-- test/{v1.1.1 => v1.1}/evm.proof | 0 6 files changed, 3 insertions(+), 3 deletions(-) rename src/{v1.1.1 => v1.1}/Halo2Verifier.sol (100%) rename src/{v1.1.1 => v1.1}/OpenVmHalo2Verifier.sol (100%) rename src/{v1.1.1 => v1.1}/interfaces/IOpenVmHalo2Verifier.sol (100%) rename test/{v1.1.1 => v1.1}/OpenVmHalo2Verifer.t.sol (96%) rename test/{v1.1.1 => v1.1}/evm.proof (100%) diff --git a/foundry.toml b/foundry.toml index c073ccf..fddcd84 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,7 +8,7 @@ optimizer = true optimizer_runs = 100000 evm_version = "paris" show_progress = true -fs_permissions = [{ access = "read", path = "./test/v1.1.1/evm.proof"}] +fs_permissions = [{ access = "read", path = "./test/v1.1/evm.proof"}] [profile.default.optimizer_details] constantOptimizer = false diff --git a/src/v1.1.1/Halo2Verifier.sol b/src/v1.1/Halo2Verifier.sol similarity index 100% rename from src/v1.1.1/Halo2Verifier.sol rename to src/v1.1/Halo2Verifier.sol diff --git a/src/v1.1.1/OpenVmHalo2Verifier.sol b/src/v1.1/OpenVmHalo2Verifier.sol similarity index 100% rename from src/v1.1.1/OpenVmHalo2Verifier.sol rename to src/v1.1/OpenVmHalo2Verifier.sol diff --git a/src/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol b/src/v1.1/interfaces/IOpenVmHalo2Verifier.sol similarity index 100% rename from src/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol rename to src/v1.1/interfaces/IOpenVmHalo2Verifier.sol diff --git a/test/v1.1.1/OpenVmHalo2Verifer.t.sol b/test/v1.1/OpenVmHalo2Verifer.t.sol similarity index 96% rename from test/v1.1.1/OpenVmHalo2Verifer.t.sol rename to test/v1.1/OpenVmHalo2Verifer.t.sol index af2e1b4..c4071d9 100644 --- a/test/v1.1.1/OpenVmHalo2Verifer.t.sol +++ b/test/v1.1/OpenVmHalo2Verifer.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.19; -import { OpenVmHalo2Verifier } from "../../src/v1.1.1/OpenVmHalo2Verifier.sol"; +import { OpenVmHalo2Verifier } from "../../src/v1.1/OpenVmHalo2Verifier.sol"; import { LibString } from "../helpers/LibString.sol"; import { Test, console2, safeconsole as console } from "forge-std/Test.sol"; @@ -26,7 +26,7 @@ contract OpenVmHalo2VerifierTest is Test { } function test_ValidProofVerifies() public view { - string memory evmProofJson = vm.readFile("test/v1.1.1/evm.proof"); + string memory evmProofJson = vm.readFile("test/v1.1/evm.proof"); bytes32 _appExeCommit = vm.parseJsonBytes32(evmProofJson, ".app_exe_commit"); bytes32 _appVmCommit = vm.parseJsonBytes32(evmProofJson, ".app_vm_commit"); bytes memory _guestPvs = vm.parseJsonBytes(evmProofJson, ".user_public_values"); diff --git a/test/v1.1.1/evm.proof b/test/v1.1/evm.proof similarity index 100% rename from test/v1.1.1/evm.proof rename to test/v1.1/evm.proof