Skip to content

Commit 2713236

Browse files
authored
Merge pull request #16 from Wollac/fix/risc0/precompiles
Enable more risc0 precompiles
2 parents 08ea41e + 75fe933 commit 2713236

File tree

5 files changed

+17
-38
lines changed

5 files changed

+17
-38
lines changed

crates/zkevm-risc0/host/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
2-
name = "host"
2+
name = "risc0-host"
33
version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
77
methods = { path = "../methods" }
8-
risc0-zkvm = { version = "^2.0.2" }
8+
risc0-zkvm = { version = "^2.0.2", features = ["unstable"] }
99
witness-generator.workspace = true
1010
zkevm-metrics.workspace = true
1111
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,13 @@
1-
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
2-
// The ELF is used for proving and the ID is used for verification.
3-
use methods::{RISC0GUEST_ELF, RISC0GUEST_ID};
1+
use methods::RISC0_GUEST_ELF;
42
use risc0_zkvm::{default_prover, ExecutorEnv};
5-
use std::collections::HashMap;
63
use witness_generator::generate_stateless_witness::generate;
7-
use zkevm_metrics::WorkloadMetrics;
84

95
fn main() {
106
// Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run`
117
tracing_subscriber::fmt()
128
.with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
139
.init();
1410

15-
// An executor environment describes the configurations for the zkVM
16-
// including program inputs.
17-
// A default ExecutorEnv can be created like so:
18-
// `let env = ExecutorEnv::builder().build().unwrap();`
19-
// However, this `env` does not have any inputs.
20-
//
21-
// To add guest input to the executor environment, use
22-
// ExecutorEnvBuilder::write().
23-
// To access this method, you'll need to use ExecutorEnv::builder(), which
24-
// creates an ExecutorEnvBuilder. When you're done adding input, call
25-
// ExecutorEnvBuilder::build().
26-
27-
// For example:
28-
let input: u32 = 15 * u32::pow(2, 27) + 1;
29-
let env = ExecutorEnv::builder()
30-
.write(&input)
31-
.unwrap()
32-
.build()
33-
.unwrap();
34-
3511
// Obtain the default prover.
3612
let prover = default_prover();
3713

@@ -57,7 +33,6 @@ fn main() {
5733
let block_number = client_input.block.number;
5834

5935
let env = ExecutorEnv::builder()
60-
// Send a & b to the guest
6136
.write(&client_input)
6237
.unwrap()
6338
.write(&blockchain_corpus.network)
@@ -67,7 +42,7 @@ fn main() {
6742

6843
// Proof information by proving the specified ELF binary.
6944
// This struct contains the receipt along with statistics about execution of the guest
70-
let _prove_info = prover.prove(env, RISC0GUEST_ELF).unwrap();
45+
let _prove_info = prover.prove(env, RISC0_GUEST_ELF).unwrap();
7146
}
7247
}
7348
}

crates/zkevm-risc0/methods/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[build-dependencies]
7-
risc0-build = { version = "^2.1.1" }
7+
risc0-build = { version = "^2.1.1", features = ["unstable"] }
88

99
[package.metadata.risc0]
1010
methods = ["guest"]
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
[package]
2-
name = "risc0guest"
2+
name = "risc0-guest"
33
version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
risc0-zkvm = { version = "^2.0.2", default-features = false, features = [
8-
'std',
9-
] }
10-
reth-stateless.workspace = true
7+
alloy-primitives.workspace = true
8+
c-kzg = { version = "=2.1.0", default-features = true }
119
reth-ethereum-primitives = { workspace = true, features = [
1210
"serde",
1311
"serde-bincode-compat",
@@ -16,4 +14,9 @@ reth-primitives-traits = { workspace = true, features = [
1614
"serde",
1715
"serde-bincode-compat",
1816
] }
19-
alloy-primitives.workspace = true
17+
reth-stateless.workspace = true
18+
revm = { version = "22.0", features = ["std", "c-kzg", "blst", "bn"] }
19+
risc0-zkvm = { version = "^2.0.2", default-features = false, features = [
20+
"std", "unstable"
21+
] }
22+
sha2 = "=0.10.8"

precompile-patches/risc0.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[patch.crates-io]
2+
blst = { git = "https://github.com/risc0/blst", tag = "v0.3.14-risczero.0" }
3+
c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", tag = "c-kzg/v2.1.0-risczero.0" }
24
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }
35
tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", tag = "tiny-keccak/v2.0.2-risczero.0" }
4-
k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.1" }
6+
k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.4-risczero.1" }
57
p256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "p256/v0.13.2-risczero.1" }
6-
rsa = { git = "https://github.com/risc0/RustCrypto-RSA", tag = "v0.9.6-risczero.0" }
78
substrate-bn = { git = "https://github.com/risc0/paritytech-bn", tag = "v0.6.0-risczero.0" }
89
bls12_381 = { git = "https://github.com/risc0/zkcrypto-bls12_381", tag = "bls12_381/v0.8.0-risczero.1" }
910
crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" }

0 commit comments

Comments
 (0)