Skip to content

Conversation

@MarcosNicolau
Copy link
Member

@MarcosNicolau MarcosNicolau commented Apr 15, 2025

Description

Implements risc0 aggregation program to support Risc0 stark proofs. The changes include:

  • The proof aggregator includes a feature flag to specify which aggregator to run: sp1 or risc0
  • The fetcher will now fetch proofs based on the specified aggregator.
  • ProofAggregationService contract was modified to support risc0 proofs verification.

To run it locally, go to #1876, which deploys risc0 contracts in anvil.

Type of change

  • New feature

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

@github-actions
Copy link

github-actions bot commented Apr 15, 2025

Changes to gas cost

Generated at commit: bfde084d9b90ed6660605726f6009ef37cc2ade9, compared to commit: 837b4fbe4715d1b848b001bf77ce517608ae7d02

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager createNewTask +20 ❌ +0.03%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 8,319,208 (0) createNewTask 57,818 (-24) -0.04% 77,817 (+20) +0.03% 78,006 (+84) +0.11% 78,705 (-87) -0.11% 256 (0)
BLSApkRegistryHarness 3,124,225 (-12)

@MarcosNicolau MarcosNicolau changed the title feat(agg-mode): support risc0 Composite proofs feat(agg-mode): support risc0 stark proofs Apr 16, 2025

build_aligned_contracts:
@cd contracts/src/core && forge build
@cd contracts/src/core && forge build --via-ir
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to this flag as the ci would fail otherwise. Here is what it does: https://docs.soliditylang.org/en/latest/ir-breaking-changes.html#solidity-ir-based-codegen-changes. But the TLDR: it uses a newer form of compiling solidity that has very tiny modifications that shouldn't affect us at all.

@MarcosNicolau MarcosNicolau marked this pull request as ready for review April 22, 2025 14:02
@MarcosNicolau MarcosNicolau force-pushed the feat/aggregation-mode-risc0 branch from 4d417b8 to 454f80c Compare April 22, 2025 17:20
Copy link
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

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

Some missing changes:

  • Update the holesky config files with the Risc0 contract
  • Add target and script to upgrade proof_aggregator
  • There is missing --via-ir flag to deployment scripts

@MarcosNicolau
Copy link
Member Author

@JuArce, following up on your comments:

@MarcosNicolau MarcosNicolau requested a review from JuArce April 23, 2025 14:36
@JuArce JuArce requested a review from Copilot April 24, 2025 19:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for risc0 stark proofs in the aggregation program. Key changes include:

  • Adding risc0 contracts remapping and new dependency configurations.
  • Extending the proof aggregator and fetcher logic to handle both SP1 and risc0 proofs.
  • Introducing a new risc0 aggregator module and updating build scripts, README, and CI workflow to integrate risc0 support.

Reviewed Changes

Copilot reviewed 24 out of 29 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
contracts/remappings.txt Added remapping for risc0 contracts.
aggregation_mode/src/backend/mod.rs Updated aggregator service to select between SP1 and risc0 proofs and added seal encoding for risc0.
aggregation_mode/src/backend/fetcher.rs Modified fetcher to process proofs based on the chosen engine (SP1 or risc0).
aggregation_mode/src/aggregators/sp1_aggregator.rs Adjusted conversion to Box for SP1 proofs for consistent API usage.
aggregation_mode/src/aggregators/risc0_aggregator.rs Introduced risc0 aggregator implementation with proof aggregation and verification logic.
aggregation_mode/src/aggregators/mod.rs Updated enums and proof variants to support both SP1 and risc0 proofs.
aggregation_mode/build.rs Integrated risc0 build step via embed_methods.
aggregation_mode/aggregation_programs/risc0/ New risc0 aggregation program implementation.
aggregation_mode/README.md Updated instructions to include risc0 deployment and proof sending.
aggregation_mode/Cargo.toml & .github/workflows/build-and-test-rust.yml Updated dependencies and CI to install and build with the risc0 toolchain.
Files not reviewed (5)
  • .gitmodules: Language not supported
  • Makefile: Language not supported
  • contracts/lib/risc0-ethereum: Language not supported
  • contracts/script/deploy/AlignedProofAggregationServiceDeployer.s.sol: Language not supported
  • contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.config.json: Language not supported
Comments suppressed due to low confidence (1)

aggregation_mode/src/aggregators/mod.rs:16

  • [nitpick] Consider using consistent casing for the Display output of the ZKVMEngine variants (e.g., 'RISC0' instead of 'Risc0') to match the enum variant naming.
impl Display for ZKVMEngine { ... Self::RISC0 => write!(f, "Risc0"), ... }

.filter_map(|p| match p.proving_system {
ProvingSystemId::Risc0 => {
let mut image_id = [0u8; 32];
image_id.copy_from_slice(p.vm_program_code?.as_slice());
Copy link

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

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

Ensure that 'p.vm_program_code' always yields a 32-byte slice before copying to avoid potential panics; consider adding a length check or validation.

Suggested change
image_id.copy_from_slice(p.vm_program_code?.as_slice());
let vm_program_code = p.vm_program_code?;
if vm_program_code.len() != 32 {
error!("Invalid vm_program_code length: expected 32, got {}", vm_program_code.len());
return None;
}
image_id.copy_from_slice(vm_program_code.as_slice());

Copilot uses AI. Check for mistakes.
@MauroToscano MauroToscano added this pull request to the merge queue Apr 24, 2025
Merged via the queue into staging with commit 2e8796f Apr 24, 2025
6 checks passed
@MauroToscano MauroToscano deleted the feat/aggregation-mode-risc0 branch April 24, 2025 20:06
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.

4 participants