Skip to content

feat: GKR LogUp #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft

feat: GKR LogUp #1565

wants to merge 25 commits into from

Conversation

zlangley
Copy link
Contributor

@zlangley zlangley commented Apr 9, 2025

No description provided.

jonathanpwang and others added 16 commits March 28, 2025 17:30
`cargo openvm build` will use `rustup` to check if the required nightly
toolchain and `rust-src` component are installed, and will install them
if they are not. If this step fails, then the entire build process
errors (I wasn't sure if this was the preferred behavior or if we should
let the rest of the cargo build attempt continue, but it felt like for
earlier stopping and debugging it's better to fail the process).

Updated only the cli workflow because in multithreaded tests, I don't
want it to try to install the toolchain in multiple threads
simultaneously.

closes INT-2911
This fix only affects logging and segmentation logic during execution
under certain misconfigured parameter settings. It does not affect any
circuit soundness.

Fixes two separate issues around segmentation with respect to fixed-size
traces: the first being that `constant_trace_height` was not implemented
for some wrapper types, and the second being that
`VmChipComplex::current_trace_cells` did not check if a chip had
constant trace height.
The symbolic expression multiplication unit test was being run with an
incorrect expected result. The test became out-of-date after #1473
changed the `max_abs` method.

This PR updates the test with the correct expected result and adds the
Mod Builder crate's unit tests to the CI workflow.

This change has no impact on the functionality of the Mod Builder crate
as it only updates the tests.
- use absolute paths for structs used only in the derive macro
This adds the ability to use different engines for proving.
- Not a soundness issue. Just an issue of `RootVerifierLocalProver`
implementation in SDK.
- In some edge cases, the trace heights of the root verifier circuit are
less than the required heights. In this case, `RootVerifierLocalProver`
should pad its traces to the required heights.
- [Breaking change] Add a new field `internal_heights` into
`RootVerifierProvingKey`.
Closes INT-3706

- Moved existing benchmarks to `benchmarks/prove` crate
- Added a new `benchmarks/execute` binary crate that runs execution for
a list of guest programs
- Added programs for benchmarking in `benchmarks/guest`
- Added a ci workflow to run execution benchmarks
- Note: Timing metrics for summary are currently being parsed from logs.
I'll change it to use proper metrics in a follow up
This PR adds a new verifier contract generation that wraps the original
`snark-verifier` output (via inheritance). The goal of this wrapper
`OpenVmHalo2Verifier` is to expose a more friendly interface to users
that cleanly separates out the guest program public values.
`OpenVmHalo2Verifier` exposes the following interface:

```solidity
interface IOpenVmHalo2Verifier {
    function verify(bytes calldata publicValues, bytes calldata proofData, bytes32 appExeCommit, bytes32 appVmCommit)
        external
        view;
}
```

- `publicValues`: The bytes revealed in the OpenVM guest program packed
together.
- `proofData`: Defined as `abi.encodePacked(KZG accumulators,
publicValuesSuffix)`
- `appExeCommit`: The commitment to the OpenVM application executable
whose execution is being verified.
- `appVmCommit`: The commitment to the VM configuration (aka
`leaf_exe_commit`)

Once received, the proof is constructed into the format expected by
`snark-verifier`. The expected format is
`abi.encodePacked(proofData[0:0x180], appExeCommit, appVmExeCommit,
publicValuesPayload, proofData[0x180:])` where `publicValuesPayload` is
a memory payload with each byte in `publicValues` separated into its own
`bytes32` word.

Since `OpenVmHalo2Verifier` inherits the `snark-verifier` output, the
proof is forwarded via self-call.

## Verifier Generation

The smart contract is written as a template that does not compile in
isolation. During generation, the OpenVM SDK will fill out the maximum
amount of public values and the OpenVM version with which the generation
happened.

Given an output folder, the relevant contracts are written into the
following folder structure:

```
halo2/
├── interfaces/
│   └── IOpenVmHalo2Verifier.sol
├── OpenVmHalo2Verifier.sol
├── Halo2Verifier.sol
```

`cargo openvm setup` will now generate this output directly into the
`~/.openvm/` dir.

Closes INT-3710
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.43.0 to 1.43.1.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/tokio-rs/tokio/commit/a7b658c35bd40f6811e557aeb97cbb361b612c56"><code>a7b658c</code></a>
chore: prepare Tokio v1.43.1 release</li>
<li><a
href="https://github.com/tokio-rs/tokio/commit/c1c8d1033d637d7027fdc137ec8008c5801cbc0d"><code>c1c8d10</code></a>
Merge remote-tracking branch 'origin/tokio-1.38.x' into
forward-port-1.38.x</li>
<li><a
href="https://github.com/tokio-rs/tokio/commit/aa303bc2051f7c21b48bb7bfcafe8fd4f39afd21"><code>aa303bc</code></a>
chore: prepare Tokio v1.38.2 release</li>
<li><a
href="https://github.com/tokio-rs/tokio/commit/7b6ccb515ff067151ed62db835f735e5653f8784"><code>7b6ccb5</code></a>
chore: backport CI fixes</li>
<li><a
href="https://github.com/tokio-rs/tokio/commit/4b174ce2c95fe1d1a217917db93fcc935e17e0da"><code>4b174ce</code></a>
sync: fix cloning value when receiving from broadcast channel</li>
<li>See full diff in <a
href="https://github.com/tokio-rs/tokio/compare/tokio-1.43.0...tokio-1.43.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio&package-manager=cargo&previous-version=1.43.0&new-version=1.43.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/openvm-org/openvm/network/alerts).

</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

This comment has been minimized.

@zlangley zlangley changed the title [feat] GKR LogUp feat: GKR LogUp Apr 9, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@zlangley zlangley force-pushed the gkr-logup-2 branch 2 times, most recently from cc2b56a to 87e76b4 Compare April 10, 2025 14:41

This comment has been minimized.

This comment has been minimized.

Bumps [crossbeam-channel](https://github.com/crossbeam-rs/crossbeam)
from 0.5.14 to 0.5.15.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/crossbeam-rs/crossbeam/releases">crossbeam-channel's
releases</a>.</em></p>
<blockquote>
<h2>crossbeam-channel 0.5.15</h2>
<ul>
<li>Fix regression introduced in 0.5.12 that can lead to a double free
when dropping unbounded channel. (<a
href="https://redirect.github.com/crossbeam-rs/crossbeam/issues/1187">#1187</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/crossbeam-rs/crossbeam/commit/d35ffde18a76ae9667f602d8c0127ff89ac2e4d4"><code>d35ffde</code></a>
Prepare for the next release</li>
<li><a
href="https://github.com/crossbeam-rs/crossbeam/commit/6ec74ecae896df5fc239518b45a1bfd258c9db68"><code>6ec74ec</code></a>
crossbeam-channel: prevent double free on Drop (<a
href="https://redirect.github.com/crossbeam-rs/crossbeam/issues/1187">#1187</a>)</li>
<li>See full diff in <a
href="https://github.com/crossbeam-rs/crossbeam/compare/crossbeam-channel-0.5.14...crossbeam-channel-0.5.15">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crossbeam-channel&package-manager=cargo&previous-version=0.5.14&new-version=0.5.15)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/openvm-org/openvm/network/alerts).

</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

This comment has been minimized.

@zlangley zlangley force-pushed the gkr-logup-2 branch 2 times, most recently from 91e28f3 to a60d2e9 Compare April 10, 2025 18:31

This comment has been minimized.

This comment has been minimized.

@zlangley zlangley force-pushed the gkr-logup-2 branch 2 times, most recently from e2811c7 to 904d2f5 Compare April 10, 2025 21:43

This comment has been minimized.

This comment has been minimized.

Introduce `AggregationTreeConfig` struct for simple configuration of
aggregation tree.

These were already in the provers, but not exposed to be changeable. 

Breaking API changes in SDK:
- `AggStarkProver::new`
- `ContinuationProver::new`
- `Sdk` now internally contains `AggregationTreeConfig`, although
`Sdk::new()` is unchanged and just sets a default

Towards INT-3302
The total proving time of `num_children_internal=4` vs 3 is about the
same, but 4 leads to the `internal.0` verifier circuit's size being
larger than the leaf verifier, so for the sake of having smaller
circuits, we switch to `3` as the default.

This is configurable via CLI and SDK, so it's just a default for
convenience.
@zlangley zlangley force-pushed the gkr-logup-2 branch 2 times, most recently from aa48188 to a6845ba Compare April 14, 2025 15:48

This comment has been minimized.

jonathanpwang and others added 3 commits April 14, 2025 11:52
Previously we were very sloppy with enabling of features:
`openvm-native-recursion` was always enabling the `snark-verifier`
feature "revm" which imports a fixed version of revm only used for
testing purposes. Since revm version changes rather frequently, this can
cause Cargo dependency conflicts if someone wants to use the SDK with
another version of revm.

I've added new features "evm-prove" and "evm-verify" to
`openvm-native-recursion`, `openvm-sdk`, `cargo-openvm` so that
- "evm-prove" allows for generation of EVM halo2 proofs, which just
enables some additional features in `snark-verifier` but no additional
other dependencies.
- "evm-verify" allows for revm simulation of EVM contract calls to
verify halo2 proofs. This includes imports of `revm` and some `alloy`
crates, with fixed versions. If you enable this feature (on by default),
the revm and alloy versions will be fixed in the cargo tree.

Also added some re-exported features to SDK and CLI, and switched
default memory allocator to `jemalloc` since that's what we mostly use.
The circuit flamegraphs being generated were incorrect due to a bug in
the multi-segment execution logic. In particular, each segment takes the
metric data from the previous segment, but the first segment was using
an empty metrics struct instead of being initialized with the correct
`fn_bounds` data.

This comment has been minimized.

Copy link

group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (+1070 [+83.1%]) 2,358 334,142 17,677,298 - - -
fibonacci_program (+2456 [+90.7%]) 5,164 1,500,277 50,589,503 - - -
regex_program (+7015 [+86.5%]) 15,122 4,165,226 166,511,152 - - -
ecrecover_program (+1520 [+104.8%]) 2,970 289,447 14,470,186 - - -
pairing (+3623 [+73.8%]) 8,531 1,820,436 95,832,407 - - -

Commit: 2958db1

Benchmark Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants