Skip to content
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

feat(core,host): initial aggregation API #375

Open
wants to merge 23 commits into
base: proof-aggregation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
83d538b
feat(core,host): initial aggregation API
petarvujovic98 Sep 17, 2024
df758fa
fix(core,host,sgx): fix compiler and clippy errors
petarvujovic98 Sep 17, 2024
ccb2fb3
Merge branch 'proof-aggregation' into proof-aggregation-api
petarvujovic98 Sep 17, 2024
9b829db
fix(core): remove double member
petarvujovic98 Sep 17, 2024
2ccac77
fix(sp1): fix dependency naming
petarvujovic98 Sep 17, 2024
247ffee
refactor(risc0): clean up aggregation file
petarvujovic98 Sep 17, 2024
2e6f7d8
fix(sp1): enable verification for proof aggregation
petarvujovic98 Sep 17, 2024
29e6fb1
feat(host): migrate to v3 API
petarvujovic98 Sep 17, 2024
a887cc6
feat(sp1): run cargo fmt
petarvujovic98 Sep 17, 2024
c2b0db5
feat(raiko): traversal to find inclusion block if none inclusion numb…
smtmfft Sep 17, 2024
5d29f78
feat(core): make `l1_inclusion_block_number` optional
petarvujovic98 Sep 18, 2024
8a3947b
fixproof req input into prove state manager
smtmfft Sep 19, 2024
7276c7b
feat(core,host,lib,tasks): add aggregation tasks and API
petarvujovic98 Sep 19, 2024
83df208
fix(core): fix typo
petarvujovic98 Sep 19, 2024
f4f818d
fix(raiko): refine error return (#378)
smtmfft Sep 20, 2024
00e2374
chore(main): release 1.2.0 (#370)
taiko-kitty Sep 20, 2024
728cb3a
Merge remote-tracking branch 'origin/main' into proof-aggregation-api
smtmfft Sep 20, 2024
16e4abc
fix v3 error return
smtmfft Sep 20, 2024
fa6fe88
feat(sp1): implement aggregate function
petarvujovic98 Sep 20, 2024
1aaec18
fix sgx aggregation for back compatibility
smtmfft Sep 23, 2024
789a599
fix(lib): fix typo
petarvujovic98 Sep 23, 2024
0358a26
fix risc0 aggregation
smtmfft Sep 24, 2024
a033011
Merge branch 'proof-aggregation-api' of https://github.com/taikoxyz/r…
smtmfft Sep 24, 2024
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [1.2.0](https://github.com/taikoxyz/raiko/compare/v1.1.0...v1.2.0) (2024-09-20)


### Features

* **raiko:** make raiko-zk docker image ([#374](https://github.com/taikoxyz/raiko/issues/374)) ([65ff9a4](https://github.com/taikoxyz/raiko/commit/65ff9a4935ac66f0c21785a0b8415313942bda82))
* **raiko:** traversal to find inclusion block if none inclusion number is sent ([#377](https://github.com/taikoxyz/raiko/issues/377)) ([c2b0db5](https://github.com/taikoxyz/raiko/commit/c2b0db5a61e920840f9de083de8684a8375e51b3))
* **sgx:** add wallet to provider builder when register instance ([#369](https://github.com/taikoxyz/raiko/issues/369)) ([a250edf](https://github.com/taikoxyz/raiko/commit/a250edf2ca42d5481ba92d97ca6ade5b46bb536c))


### Bug Fixes

* **raiko:** refine error return ([#378](https://github.com/taikoxyz/raiko/issues/378)) ([f4f818d](https://github.com/taikoxyz/raiko/commit/f4f818d43a33ba1caf95cb1db4160ba90824eb2d))
* **script:** output build message and skip `pos` flag ([#367](https://github.com/taikoxyz/raiko/issues/367)) ([2c881dc](https://github.com/taikoxyz/raiko/commit/2c881dc22d5df553bffc24f8bbac6a86e2fd9688))

## [1.1.0](https://github.com/taikoxyz/raiko/compare/v1.0.0...v1.1.0) (2024-09-13)


Expand Down
124 changes: 116 additions & 8 deletions core/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use raiko_lib::{
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_with::{serde_as, DisplayFromStr};
use std::{collections::HashMap, path::Path, str::FromStr};
use std::{collections::HashMap, fmt::Display, path::Path, str::FromStr};
use utoipa::ToSchema;

#[derive(Debug, thiserror::Error, ToSchema)]
Expand Down Expand Up @@ -345,7 +345,7 @@ pub struct ProofRequestOpt {
pub prover_args: ProverSpecificOpts,
}

#[derive(Default, Clone, Serialize, Deserialize, Debug, ToSchema, Args)]
#[derive(Default, Clone, Serialize, Deserialize, Debug, ToSchema, Args, PartialEq, Eq, Hash)]
pub struct ProverSpecificOpts {
/// Native prover specific options.
pub native: Option<Value>,
Expand Down Expand Up @@ -442,14 +442,122 @@ impl TryFrom<ProofRequestOpt> for ProofRequest {
}
}

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Default, Clone, Serialize, Deserialize, Debug, ToSchema)]
#[serde(default)]
/// A request for proof aggregation of multiple proofs.
pub struct AggregationRequest {
/// All the proofs to verify
/// The block numbers and l1 inclusion block numbers for the blocks to aggregate proofs for.
pub block_numbers: Vec<(u64, Option<u64>)>,
/// The network to generate the proof for.
pub network: Option<String>,
/// The L1 network to generate the proof for.
pub l1_network: Option<String>,
// Graffiti.
pub graffiti: Option<String>,
/// The protocol instance data.
pub prover: Option<String>,
/// The proof type.
pub proof_type: Option<String>,
/// Blob proof type.
pub blob_proof_type: Option<String>,
smtmfft marked this conversation as resolved.
Show resolved Hide resolved
#[serde(flatten)]
/// Any additional prover params in JSON format.
pub prover_args: ProverSpecificOpts,
}

impl AggregationRequest {
/// Merge proof request options into aggregation request options.
pub fn merge(&mut self, opts: &ProofRequestOpt) -> RaikoResult<()> {
let this = serde_json::to_value(&self)?;
let mut opts = serde_json::to_value(opts)?;
merge(&mut opts, &this);
*self = serde_json::from_value(opts)?;
Ok(())
}
}

impl From<AggregationRequest> for Vec<ProofRequestOpt> {
fn from(value: AggregationRequest) -> Self {
value
.block_numbers
.iter()
.map(
|&(block_number, l1_inclusion_block_number)| ProofRequestOpt {
block_number: Some(block_number),
l1_inclusion_block_number,
network: value.network.clone(),
l1_network: value.l1_network.clone(),
graffiti: value.graffiti.clone(),
prover: value.prover.clone(),
proof_type: value.proof_type.clone(),
blob_proof_type: value.blob_proof_type.clone(),
prover_args: value.prover_args.clone(),
},
)
.collect()
}
}

impl From<ProofRequestOpt> for AggregationRequest {
fn from(value: ProofRequestOpt) -> Self {
let block_numbers = if let Some(block_number) = value.block_number {
vec![(block_number, value.l1_inclusion_block_number)]
} else {
vec![]
};

Self {
block_numbers,
network: value.network,
l1_network: value.l1_network,
graffiti: value.graffiti,
prover: value.prover,
proof_type: value.proof_type,
blob_proof_type: value.blob_proof_type,
prover_args: value.prover_args,
}
}
}

#[derive(Default, Clone, Serialize, Deserialize, Debug, ToSchema, PartialEq, Eq, Hash)]
#[serde(default)]
/// A request for proof aggregation of multiple proofs.
pub struct AggregationOnlyRequest {
/// The block numbers and l1 inclusion block numbers for the blocks to aggregate proofs for.
pub proofs: Vec<Proof>,
/// The proof type.
pub proof_type: ProofType,
/// Additional prover params.
pub prover_args: HashMap<String, Value>,
pub proof_type: Option<String>,
#[serde(flatten)]
/// Any additional prover params in JSON format.
pub prover_args: ProverSpecificOpts,
}

impl Display for AggregationOnlyRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&format!(
"AggregationOnlyRequest {{ {:?}, {:?} }}",
self.proof_type, self.prover_args
))
}
}

impl From<(AggregationRequest, Vec<Proof>)> for AggregationOnlyRequest {
fn from((request, proofs): (AggregationRequest, Vec<Proof>)) -> Self {
Self {
proofs,
proof_type: request.proof_type,
prover_args: request.prover_args,
}
}
}

impl AggregationOnlyRequest {
/// Merge proof request options into aggregation request options.
pub fn merge(&mut self, opts: &ProofRequestOpt) -> RaikoResult<()> {
let this = serde_json::to_value(&self)?;
let mut opts = serde_json::to_value(opts)?;
merge(&mut opts, &this);
*self = serde_json::from_value(opts)?;
Ok(())
}
}
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ mod tests {
.unwrap();

let proof_request = ProofRequest {
l1_inclusion_block_number: 0,
block_number,
l1_inclusion_block_number: 0,
network,
graffiti: B256::ZERO,
prover: Address::ZERO,
Expand Down
Loading
Loading