Skip to content

Commit e446794

Browse files
committed
Merge branch 'feat/aggregation-mode-risc0' into feat/aggregation-mode-risc0-contracts
2 parents a478287 + 74f15be commit e446794

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

.github/workflows/build-and-test-rust.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: Install risc0 toolchain
3535
run: |
3636
curl -L https://risczero.com/install | bash
37-
source /home/runner/.bashrc
38-
/home/runner/.risc0/bin/rzup install
37+
source ~/.bashrc
38+
~/.risc0/bin/rzup install
3939
4040
- name: Cache Rust dependencies
4141
uses: actions/cache@v3
@@ -99,8 +99,8 @@ jobs:
9999
- name: Install risc0 toolchain
100100
run: |
101101
curl -L https://risczero.com/install | bash
102-
source /home/runner/.bashrc
103-
/home/runner/.risc0/bin/rzup install
102+
source ~/.bashrc
103+
~/.risc0/bin/rzup install
104104
105105
- name: Cache Rust dependencies
106106
uses: actions/cache@v3

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ is_aggregator_set:
163163
fi
164164

165165
start_proof_aggregator_dev: is_aggregator_set ## Starts proof aggregator with mock proofs (DEV mode)
166-
RISC0_DEV_MODE=1 cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features $(AGGREGATOR) -- config-files/config-proof-aggregator-mock.yaml
166+
AGGREGATOR=$(AGGREGATOR) RISC0_DEV_MODE=1 cargo run --manifest-path ./aggregation_mode/Cargo.toml --release -- config-files/config-proof-aggregator-mock.yaml
167167

168168
start_proof_aggregator: is_aggregator_set ## Starts proof aggregator with proving activated
169-
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,$(AGGREGATOR) -- config-files/config-proof-aggregator.yaml
169+
AGGREGATOR=$(AGGREGATOR) cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove -- config-files/config-proof-aggregator.yaml
170170

171171
start_proof_aggregator_gpu: is_aggregator_set ## Starts proof aggregator with proving + GPU acceleration (CUDA)
172-
SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu,$(AGGREGATOR) -- config-files/config-proof-aggregator.yaml
172+
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu -- config-files/config-proof-aggregator.yaml
173173

174174
_AGGREGATOR_:
175175

@@ -717,7 +717,7 @@ build_aligned_contracts:
717717

718718
show_aligned_error_codes:
719719
@echo "\nAlignedLayerServiceManager errors:"
720-
@cd contracts && forge inspect src/core/IAligedLayerServiceManager.sol:IAlignedLayerServiceManager errors
720+
@cd contracts && forge inspect src/core/IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
721721
@echo "\nBatcherPaymentService errors:"
722722
@cd contracts && forge inspect src/core/BatcherPaymentService.sol:BatcherPaymentService errors
723723

aggregation_mode/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,4 @@ opt-level = 3
4040
[features]
4141
default = []
4242
prove = []
43-
sp1 = []
44-
risc0 = []
4543
gpu = ["risc0-zkvm/cuda"]

aggregation_mode/aggregation_programs/Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregation_mode/aggregation_programs/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ version = "0.1.0"
44
edition = "2021"
55
resolver = "2"
66
members = ["sp1", "risc0"]
7+
8+
[patch.crates-io]
9+
# Adding RISC Zero keccak precompile support
10+
tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", tag = "tiny-keccak/v2.0.2-risczero.0" }
11+

aggregation_mode/aggregation_programs/risc0/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ resolver = "2"
77
[dependencies]
88
serde = { version = "1.0.203" }
99
serde_json = "1.0.117"
10-
risc0-zkvm = { git = "https://github.com/risc0/risc0", tag="v2.0.0", default-features = false, features = ["std"] }
10+
# Unstable feature is necessary for tiny-keccak patch, see: https://dev.risczero.com/api/zkvm/precompiles#stability
11+
risc0-zkvm = { git = "https://github.com/risc0/risc0", tag="v2.0.0", default-features = false, features = ["unstable", "std"] }
1112
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
1213

13-
[patch.crates-io]
14-
tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", tag = "tiny-keccak/v2.0.2-risczero.0", features = ["keccak"]}
15-
1614
[lib]
1715
path = "./src/lib.rs"
1816

aggregation_mode/aggregation_programs/risc0/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn combine_hashes(hash_a: &[u8; 32], hash_b: &[u8; 32]) -> [u8; 32] {
1616
hash
1717
}
1818

19-
/// Computes the merkle root for the given proofs using the vk
19+
/// Computes the merkle root for the given proofs
2020
fn compute_merkle_root(proofs: &[Risc0ImageIdAndPubInputs]) -> [u8; 32] {
2121
let mut leaves: Vec<[u8; 32]> = proofs
2222
.chunks(2)

aggregation_mode/src/aggregators/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,16 @@ impl Display for ZKVMEngine {
2323
}
2424

2525
impl ZKVMEngine {
26-
pub fn from_rust_features() -> Option<Self> {
27-
#[cfg(feature = "sp1")]
28-
{
29-
return Some(ZKVMEngine::SP1);
30-
}
31-
32-
#[cfg(feature = "risc0")]
33-
{
34-
return Some(ZKVMEngine::RISC0);
35-
}
26+
pub fn from_env() -> Option<Self> {
27+
let key = "AGGREGATOR";
28+
let value = std::env::var(key).ok()?;
29+
let engine = match value.as_str() {
30+
"sp1" => ZKVMEngine::SP1,
31+
"risc0" => ZKVMEngine::RISC0,
32+
_ => panic!("Invalid AGGREGATOR, possible options are: sp1|risc0"),
33+
};
3634

37-
None
35+
Some(engine)
3836
}
3937
}
4038

aggregation_mode/src/aggregators/risc0_aggregator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use sha3::{Digest, Keccak256};
55

66
use super::lib::{AggregatedProof, ProgramOutput, ProofAggregationError};
77

8+
/// Byte representation of the aggregator image_id, converted from `[u32; 8]` to `[u8; 32]`.
89
const RISC0_AGGREGATOR_PROGRAM_ID_BYTES: [u8; 32] = {
910
let mut res = [0u8; 32];
1011
let mut i = 0;

aggregation_mode/src/backend/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ impl ProofAggregator {
6464
rpc_provider,
6565
);
6666

67-
let engine = ZKVMEngine::from_rust_features().expect("A feature defining zkvm engine");
67+
let engine =
68+
ZKVMEngine::from_env().expect("AGGREGATOR env variable to be set to one of sp1|risc0");
6869
let fetcher = ProofsFetcher::new(config);
6970

7071
Self {
@@ -75,7 +76,7 @@ impl ProofAggregator {
7576
}
7677

7778
pub async fn start(&mut self, config: &Config) {
78-
info!("Starting proof aggregator service",);
79+
info!("Starting proof aggregator service");
7980

8081
info!("About to aggregate and submit proof to be verified on chain");
8182
let res = self.aggregate_and_submit_proofs_on_chain().await;

0 commit comments

Comments
 (0)