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) diff --git a/README.md b/README.md index 9265b45..479d861 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,44 @@ -## Foundry +# OpenVM Solidity SDK -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** +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. -Foundry consists of: +The contracts are built on every _minor_ release as OpenVM guarantees verifier backward compatibility across patch releases. -- **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. +## Installation -## Documentation +To install `openvm-solidity-sdk` as a dependency in your forge project, run the following: -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). diff --git a/foundry.toml b/foundry.toml index ebbf0b6..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.0.1/evm.proof"}] +fs_permissions = [{ access = "read", path = "./test/v1.1/evm.proof"}] [profile.default.optimizer_details] constantOptimizer = false diff --git a/src/v1.0.1/Halo2Verifier.sol b/src/v1.1/Halo2Verifier.sol similarity index 100% rename from src/v1.0.1/Halo2Verifier.sol rename to src/v1.1/Halo2Verifier.sol diff --git a/src/v1.0.1/OpenVmHalo2Verifier.sol b/src/v1.1/OpenVmHalo2Verifier.sol similarity index 99% rename from src/v1.0.1/OpenVmHalo2Verifier.sol rename to src/v1.1/OpenVmHalo2Verifier.sol index ef41b44..5969495 100644 --- a/src/v1.0.1/OpenVmHalo2Verifier.sol +++ b/src/v1.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/interfaces/IOpenVmHalo2Verifier.sol similarity index 100% rename from src/v1.0.1/interfaces/IOpenVmHalo2Verifier.sol rename to src/v1.1/interfaces/IOpenVmHalo2Verifier.sol diff --git a/test/v1.0.1/OpenVmHalo2Verifer.t.sol b/test/v1.1/OpenVmHalo2Verifer.t.sol similarity index 96% rename from test/v1.0.1/OpenVmHalo2Verifer.t.sol rename to test/v1.1/OpenVmHalo2Verifer.t.sol index 66ba4a6..c4071d9 100644 --- a/test/v1.0.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.0.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.0.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.0.1/evm.proof b/test/v1.1/evm.proof similarity index 100% rename from test/v1.0.1/evm.proof rename to test/v1.1/evm.proof