Skip to content

Commit 5a0f9a2

Browse files
committed
initial powdr support
1 parent a497171 commit 5a0f9a2

37 files changed

+670
-3307
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ members = [
77
"harness/macro",
88
"provers/sp1/driver",
99
"provers/sp1/builder",
10+
"provers/powdr/driver",
11+
"provers/powdr/builder",
1012
"provers/risc0/driver",
1113
"provers/risc0/builder",
1214
"provers/sgx/prover",

core/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ edition = "2021"
88
# provers
99
sp1-driver = { path = "../provers/sp1/driver", optional = true }
1010
risc0-driver = { path = "../provers/risc0/driver", optional = true }
11+
powdr-driver = { path = "../provers/powdr/driver", optional = true }
1112
sgx-prover = { path = "../provers/sgx/prover", optional = true }
1213

1314
# raiko
@@ -69,4 +70,5 @@ ethers-core = { workspace = true }
6970
# powdr = ["dep:powdr"]
7071
sp1 = ["dep:sp1-driver", "sp1-driver/enable"]
7172
risc0 = ["dep:risc0-driver", "risc0-driver/enable"]
73+
powdr = ["dep:powdr-driver", "powdr-driver/enable"]
7274
sgx = ["dep:sgx-prover", "sgx-prover/enable"]

core/src/interfaces.rs

+34
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ pub enum ProofType {
113113
///
114114
/// Uses the RISC0 prover to build the block.
115115
Risc0,
116+
/// # powdr
117+
///
118+
/// Uses powdrVM to build the block.
119+
Powdr,
116120
}
117121

118122
impl std::fmt::Display for ProofType {
@@ -122,6 +126,7 @@ impl std::fmt::Display for ProofType {
122126
ProofType::Sp1 => "sp1",
123127
ProofType::Sgx => "sgx",
124128
ProofType::Risc0 => "risc0",
129+
ProofType::Powdr => "powdr",
125130
})
126131
}
127132
}
@@ -135,6 +140,7 @@ impl FromStr for ProofType {
135140
"sp1" => Ok(ProofType::Sp1),
136141
"sgx" => Ok(ProofType::Sgx),
137142
"risc0" => Ok(ProofType::Risc0),
143+
"powdr" => Ok(ProofType::Powdr),
138144
_ => Err(RaikoError::InvalidProofType(s.to_string())),
139145
}
140146
}
@@ -149,6 +155,7 @@ impl TryFrom<u8> for ProofType {
149155
1 => Ok(Self::Sp1),
150156
2 => Ok(Self::Sgx),
151157
3 => Ok(Self::Risc0),
158+
4 => Ok(Self::Powdr),
152159
_ => Err(RaikoError::Conversion("Invalid u8".to_owned())),
153160
}
154161
}
@@ -161,6 +168,7 @@ impl From<ProofType> for VerifierType {
161168
ProofType::Sp1 => VerifierType::SP1,
162169
ProofType::Sgx => VerifierType::SGX,
163170
ProofType::Risc0 => VerifierType::RISC0,
171+
ProofType::Powdr => VerifierType::Powdr,
164172
}
165173
}
166174
}
@@ -194,6 +202,14 @@ impl ProofType {
194202
#[cfg(not(feature = "risc0"))]
195203
Err(RaikoError::FeatureNotSupportedError(*self))
196204
}
205+
ProofType::Powdr => {
206+
#[cfg(feature = "powdr")]
207+
return powdr_driver::PowdrProver::run(input.clone(), output, config, store)
208+
.await
209+
.map_err(|e| e.into());
210+
#[cfg(not(feature = "powdr"))]
211+
Err(RaikoError::FeatureNotSupportedError(*self))
212+
}
197213
ProofType::Sgx => {
198214
#[cfg(feature = "sgx")]
199215
return sgx_prover::SgxProver::run(input.clone(), output, config, store)
@@ -233,6 +249,14 @@ impl ProofType {
233249
#[cfg(not(feature = "risc0"))]
234250
Err(RaikoError::FeatureNotSupportedError(*self))
235251
}
252+
ProofType::Powdr => {
253+
#[cfg(feature = "powdr")]
254+
return powdr_driver::PowdrProver::aggregate(input.clone(), output, config, store)
255+
.await
256+
.map_err(|e| e.into());
257+
#[cfg(not(feature = "powdr"))]
258+
Err(RaikoError::FeatureNotSupportedError(*self))
259+
}
236260
ProofType::Sgx => {
237261
#[cfg(feature = "sgx")]
238262
return sgx_prover::SgxProver::aggregate(input.clone(), output, config, store)
@@ -271,6 +295,14 @@ impl ProofType {
271295
#[cfg(not(feature = "risc0"))]
272296
Err(RaikoError::FeatureNotSupportedError(*self))
273297
}
298+
ProofType::Powdr => {
299+
#[cfg(feature = "powdr")]
300+
return powdr_driver::PowdrProver::cancel(proof_key, read)
301+
.await
302+
.map_err(|e| e.into());
303+
#[cfg(not(feature = "powdr"))]
304+
Err(RaikoError::FeatureNotSupportedError(*self))
305+
}
274306
ProofType::Sgx => {
275307
#[cfg(feature = "sgx")]
276308
return sgx_prover::SgxProver::cancel(proof_key, read)
@@ -355,6 +387,8 @@ pub struct ProverSpecificOpts {
355387
pub sp1: Option<Value>,
356388
/// RISC0 prover specific options.
357389
pub risc0: Option<Value>,
390+
/// Powdr prover specific options.
391+
pub powdr: Option<Value>,
358392
}
359393

360394
impl<S: ::std::hash::BuildHasher + ::std::default::Default> From<ProverSpecificOpts>

core/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ mod tests {
274274
}
275275
},
276276
);
277+
prover_args.insert(
278+
"powdr".to_string(),
279+
json! {
280+
{
281+
"prover": "mock",
282+
}
283+
},
284+
);
277285
prover_args.insert(
278286
"sgx".to_string(),
279287
json! {

harness/macro/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ proc-macro = true
1010

1111
[dependencies]
1212
syn = { workspace = true }
13-
quote = { workspace = true }
14-
proc-macro2 = { workspace = true }
13+
quote = { workspace = true }
14+
proc-macro2 = { workspace = true }
1515

1616
[features]
1717
sp1 = []
18-
risc0 = []
18+
risc0 = []
19+
powdr = []

harness/macro/src/lib.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use proc_macro::TokenStream;
33
use quote::quote;
44
use syn::{parse_macro_input, Item, ItemFn, ItemMod};
55

6-
#[cfg(any(feature = "sp1", feature = "risc0"))]
6+
#[cfg(any(feature = "sp1", feature = "risc0", feature = "powdr"))]
77
use syn::{punctuated::Punctuated, Ident, Path, Token};
88

99
// Helper struct to parse input
10-
#[cfg(any(feature = "sp1", feature = "risc0"))]
10+
#[cfg(any(feature = "sp1", feature = "risc0", feature = "powdr"))]
1111
struct EntryArgs {
1212
main_entry: Ident,
1313
test_modules: Option<Punctuated<Path, Token![,]>>,
1414
}
1515

16-
#[cfg(any(feature = "sp1", feature = "risc0"))]
16+
#[cfg(any(feature = "sp1", feature = "risc0", feature = "powdr"))]
1717
impl syn::parse::Parse for EntryArgs {
1818
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
1919
let main_entry: Ident = input.parse()?;
@@ -33,7 +33,7 @@ impl syn::parse::Parse for EntryArgs {
3333
}
3434

3535
#[proc_macro]
36-
#[cfg(any(feature = "sp1", feature = "risc0"))]
36+
#[cfg(any(feature = "sp1", feature = "risc0", feature = "powdr"))]
3737
pub fn entrypoint(input: TokenStream) -> TokenStream {
3838
let input = parse_macro_input!(input as EntryArgs);
3939
let main_entry = input.main_entry;
@@ -100,11 +100,29 @@ pub fn entrypoint(input: TokenStream) -> TokenStream {
100100
}
101101
};
102102

103+
#[cfg(feature = "powdr")]
104+
let output = quote! {
105+
#[cfg(test)]
106+
#tests_entry
107+
108+
#[cfg(not(test))]
109+
const ZKVM_ENTRY: fn() = #main_entry;
110+
#[cfg(test)]
111+
const ZKVM_ENTRY: fn() = run_tests;
112+
113+
mod zkvm_generated_main {
114+
#[no_mangle]
115+
fn main() {
116+
super::ZKVM_ENTRY()
117+
}
118+
}
119+
};
120+
103121
output.into()
104122
}
105123

106124
#[proc_macro]
107-
#[cfg(not(any(feature = "sp1", feature = "risc0")))]
125+
#[cfg(not(any(feature = "sp1", feature = "risc0", feature = "powdr")))]
108126
pub fn entrypoint(_input: TokenStream) -> TokenStream {
109127
quote! {
110128
mod generated_main {

host/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ default-run = "raiko-host"
99
# provers
1010
sp1-driver = { path = "../provers/sp1/driver", optional = true }
1111
risc0-driver = { path = "../provers/risc0/driver", optional = true }
12+
powdr-driver = { path = "../provers/powdr/driver", optional = true }
1213
sgx-prover = { path = "../provers/sgx/prover", optional = true }
1314

1415
# raiko
@@ -86,6 +87,7 @@ ethers-core = { workspace = true }
8687
default = []
8788
sp1 = ["raiko-core/sp1"]
8889
risc0 = ["raiko-core/risc0"]
90+
powdr = ["raiko-core/powdr"]
8991
sgx = ["raiko-core/sgx"]
9092
integration = []
9193

host/config/config.json

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"prover": "mock",
2525
"verify": false
2626
},
27+
"sp1": {
28+
"prover": "mock"
29+
},
2730
"native" : {
2831
"json_guest_input": null
2932
}

host/src/server/api/v1/proof.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use super::ProofResponse;
3030
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
3131
/// - sp1 - uses the sp1 prover
3232
/// - risc0 - uses the risc0 prover
33+
/// - powdr - uses the powdr prover
3334
async fn proof_handler(
3435
State(prover_state): State<ProverState>,
3536
Json(req): Json<Value>,

host/src/server/api/v2/proof/cancel.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::{interfaces::HostResult, server::api::v2::CancelStatus, Message, Prov
2222
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
2323
/// - sp1 - uses the sp1 prover
2424
/// - risc0 - uses the risc0 prover
25+
/// - powdr - uses the powdr prover
2526
async fn cancel_handler(
2627
State(prover_state): State<ProverState>,
2728
Json(req): Json<Value>,

host/src/server/api/v2/proof/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub mod report;
3232
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
3333
/// - sp1 - uses the sp1 prover
3434
/// - risc0 - uses the risc0 prover
35+
/// - powdr - uses the powdr prover
3536
async fn proof_handler(
3637
State(prover_state): State<ProverState>,
3738
Json(req): Json<Value>,

host/src/server/api/v3/proof/aggregate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::{
2828
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
2929
/// - sp1 - uses the sp1 prover
3030
/// - risc0 - uses the risc0 prover
31+
/// - powdr - uses the powdr prover
3132
async fn aggregation_handler(
3233
State(prover_state): State<ProverState>,
3334
Json(mut aggregation_request): Json<AggregationOnlyRequest>,

host/src/server/api/v3/proof/cancel.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::{interfaces::HostResult, server::api::v2::CancelStatus, Message, Prov
2424
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
2525
/// - sp1 - uses the sp1 prover
2626
/// - risc0 - uses the risc0 prover
27+
/// - powdr - uses the powdr prover
2728
async fn cancel_handler(
2829
State(prover_state): State<ProverState>,
2930
Json(mut aggregation_request): Json<AggregationRequest>,

host/src/server/api/v3/proof/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mod cancel;
3333
/// - sgx - uses the sgx environment to construct a block and produce proof of execution
3434
/// - sp1 - uses the sp1 prover
3535
/// - risc0 - uses the risc0 prover
36+
/// - powdr - uses the powdr prover
3637
async fn proof_handler(
3738
State(prover_state): State<ProverState>,
3839
Json(mut aggregation_request): Json<AggregationRequest>,

host/tests/common/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub async fn make_request() -> anyhow::Result<ProofRequestOpt> {
130130
sgx: None,
131131
sp1: None,
132132
risc0: None,
133+
powdr: None,
133134
},
134135
})
135136
}

lib/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ std = [
7575
sgx = []
7676
sp1 = []
7777
risc0 = []
78-
sp1-cycle-tracker = []
78+
powdr = []
79+
sp1-cycle-tracker = []
80+
proof_of_equivalence = []

lib/src/consts.rs

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ pub enum VerifierType {
134134
SGX,
135135
SP1,
136136
RISC0,
137+
Powdr,
137138
}
138139

139140
/// Specification of a specific chain.
@@ -397,6 +398,7 @@ mod tests {
397398
(VerifierType::SGX, Some(Address::default())),
398399
(VerifierType::SP1, None),
399400
(VerifierType::RISC0, Some(Address::default())),
401+
(VerifierType::Powdr, None),
400402
]),
401403
)]),
402404
genesis_time: 0u64,

lib/src/protocol_instance.rs

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ fn get_blob_proof_type(
317317
VerifierType::SGX => BlobProofType::KzgVersionedHash,
318318
VerifierType::SP1 => BlobProofType::ProofOfEquivalence,
319319
VerifierType::RISC0 => BlobProofType::ProofOfEquivalence,
320+
VerifierType::Powdr => BlobProofType::ProofOfEquivalence,
320321
}
321322
}
322323

pipeline/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ sp1-sdk = { workspace = true, optional = true }
2222
[features]
2323
risc0 = ["dep:risc0-binfmt", "dep:pathdiff", "dep:hex"]
2424
sp1 = ["dep:sp1-sdk"]
25+
# TODO: make powdr feature work
26+
powdr = []

pipeline/src/executor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl Executor {
121121
fs::create_dir_all(&dest_dir).expect("Couldn't create destination directories");
122122
}
123123

124+
println!("#### {:#?}", self.artifacts);
124125
for src in &self.artifacts {
125126
let mut name = file_name(src);
126127

0 commit comments

Comments
 (0)