Skip to content
Merged
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
20 changes: 15 additions & 5 deletions .github/workflows/consistency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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)
72 changes: 25 additions & 47 deletions README.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a nice way we could not have to copy paste this between the openvm book and here

Original file line number Diff line number Diff line change
@@ -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 <your_rpc_url> --private-key <your_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 <subcommand>
```

### 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).
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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");
Expand Down
File renamed without changes.