Skip to content

Commit

Permalink
sp1_4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
anylots committed Feb 18, 2025
1 parent cc53bdd commit 05e6cfe
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 434 deletions.
708 changes: 426 additions & 282 deletions prover/Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ ruzstd = { git = "https://github.com/KillingSpark/zstd-rs.git", branch = "master

# crypto
c-kzg = "1.0.3"
kzg-rs = { git = "https://github.com/morph-l2/kzg-rs.git", branch = "sp1-bls-dev" }
kzg-rs = { version = "0.2.5" }
sha2 = "0.10.8"

sp1-zkvm = { git = "https://github.com/morph-l2/sp1.git", branch = "fix-memcopy-chip"}
sp1-sdk = { git = "https://github.com/morph-l2/sp1.git", branch = "fix-memcopy-chip"}
sp1-helper = { git = "https://github.com/morph-l2/sp1.git", branch = "fix-memcopy-chip"}
sp1-zkvm = { git = "https://github.com/morph-l2/sp1.git", branch = "v4"}
sp1-sdk = { git = "https://github.com/morph-l2/sp1.git", branch = "v4"}
sp1-helper = { git = "https://github.com/morph-l2/sp1.git", branch = "v4"}

# dependencies from scroll-tech
poseidon-bn254 = { git = "https://github.com/morph-l2/poseidon-bn254.git", branch = "main", features = ["bn254"] }
poseidon-bn254 = { git = "https://github.com/morph-l2/poseidon-bn254.git", branch = "v4", features = ["bn254"] }
zktrie = { git = "https://github.com/scroll-tech/zktrie.git", branch = "main", features= ["rs_zktrie"] }


Expand Down Expand Up @@ -103,7 +103,7 @@ morph-prove = { path = "bin/host" }

[workspace.dependencies.revm]
git = "https://github.com/morph-l2/revm"
branch = "poseidon-dev"
branch = "sp1_v4_dev"
default-features = false
features = [
"morph-default-handler",
Expand All @@ -114,7 +114,7 @@ features = [

[workspace.dependencies.revm-primitives]
git = "https://github.com/morph-l2/revm"
branch = "poseidon-dev"
branch = "sp1_v4_dev"
default-features = false
features = [
"morph-default-handler",
Expand Down
Binary file modified prover/bin/client/elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
15 changes: 0 additions & 15 deletions prover/bin/host/build.rs

This file was deleted.

6 changes: 3 additions & 3 deletions prover/bin/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ pub fn prove(
// Execute the program in sp1-vm
let mut stdin = SP1Stdin::new();
stdin.write(&serde_json::to_string(&client_input).unwrap());
let client = ProverClient::new();
let client = ProverClient::from_env();

if read_env_var("DEVNET", false) {
let (mut public_values, execution_report) = client
.execute(BATCH_VERIFIER_ELF, stdin.clone())
.execute(BATCH_VERIFIER_ELF, &stdin.clone())
.run()
.map_err(|e| anyhow!(format!("sp1-vm execution err: {:?}", e)))?;

Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn prove(
// Generate the proof
let start = Instant::now();
let mut proof = client
.prove(&pk, stdin)
.prove(&pk, &stdin)
.plonk()
.run()
.map_err(|e| anyhow!(format!("proving failed: {:?}", e)))?;
Expand Down
18 changes: 12 additions & 6 deletions prover/crates/morph-executor/client/src/verifier/blob_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ impl BlobVerifier {
let commitent = Bytes48::from_slice(&blob_info.commitment).unwrap();
let proof = Bytes48::from_slice(&blob_info.proof).unwrap();

// let verify_result =
// kzg_rs::KzgProof::verify_blob_kzg_proof(blob, &commitent, &proof,
// &get_kzg_settings()) .map_err(|e| anyhow!("blob verification failed, kzg
// err: {:?}", e))?; if !verify_result {
// return Err(anyhow!("The blob kzg verification result is Failed"));
// }
let verify_result =
kzg_rs::KzgProof::verify_blob_kzg_proof(blob, &commitent, &proof, &get_kzg_settings())
.map_err(|e| {
anyhow!(
"blob verification failed, kzg
err: {:?}",
e
)
})?;
if !verify_result {
return Err(anyhow!("The blob kzg verification result is Failed"));
}
println!("cycle-tracker-end: verify_blob_kzg_proof");
println!(
"verify_blob_kzg_proof successfully, versioned_hash: {:?}",
Expand Down
12 changes: 0 additions & 12 deletions prover/tests/algebra/host/build.rs

This file was deleted.

6 changes: 3 additions & 3 deletions prover/tests/algebra/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
let dev_elf: &[u8] = include_bytes!("../../client/elf/riscv32im-succinct-zkvm-elf");

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Setup the inputs.
let mut stdin = SP1Stdin::new();
Expand All @@ -25,7 +25,7 @@ fn main() {
stdin.write(&data);

// Execute the program in sp1-vm
let (public_values, execution_report) = client.execute(dev_elf, stdin.clone()).run().unwrap();
let (public_values, execution_report) = client.execute(dev_elf, &stdin.clone()).run().unwrap();
println!("Program executed successfully.");
// Record the number of cycles executed.
println!("Number of cycles: {}", execution_report.total_instruction_count());
Expand All @@ -39,7 +39,7 @@ fn main() {
let (pk, vk) = client.setup(dev_elf);

// Generate the proof
let proof = client.prove(&pk, stdin).plonk().run().expect("failed to generate proof");
let proof = client.prove(&pk, &stdin).plonk().run().expect("failed to generate proof");

let duration_mins = start.elapsed().as_secs() / 60;
println!("Successfully generated proof!, time use: {:?} minutes", duration_mins);
Expand Down
12 changes: 0 additions & 12 deletions prover/tests/bls12381/host/build.rs

This file was deleted.

24 changes: 6 additions & 18 deletions prover/tests/bls12381/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
let dev_elf: &[u8] = include_bytes!("../../client/elf/riscv32im-succinct-zkvm-elf");

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Setup the inputs.
let mut stdin = SP1Stdin::new();
Expand All @@ -18,36 +18,24 @@ fn main() {
stdin.write(&data);

// Execute the program in sp1-vm
let (public_values, execution_report) = client.execute(dev_elf, stdin.clone()).run().unwrap();
let (public_values, execution_report) = client.execute(dev_elf, &stdin.clone()).run().unwrap();
println!("Program executed successfully.");
// Record the number of cycles executed.
println!(
"Number of cycles: {}",
execution_report.total_instruction_count()
);
println!("Number of cycles: {}", execution_report.total_instruction_count());

let rt_data = public_values.as_slice();
println!(
"pi_hash generated with sp1-vm execution: {}",
hex::encode(rt_data)
);
println!("pi_hash generated with sp1-vm execution: {}", hex::encode(rt_data));

let start = Instant::now();

// Setup the program for proving.
let (pk, vk) = client.setup(dev_elf);

// Generate the proof
let proof = client
.prove(&pk, stdin)
.run()
.expect("failed to generate proof");
let proof = client.prove(&pk, &stdin).run().expect("failed to generate proof");

let duration_mins = start.elapsed().as_secs() / 60;
println!(
"Successfully generated proof!, time use: {:?} minutes",
duration_mins
);
println!("Successfully generated proof!, time use: {:?} minutes", duration_mins);

// Verify the proof.
client.verify(&proof, &vk).expect("failed to verify proof");
Expand Down
12 changes: 0 additions & 12 deletions prover/tests/keccak256/host/build.rs

This file was deleted.

24 changes: 6 additions & 18 deletions prover/tests/keccak256/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
let dev_elf: &[u8] = include_bytes!("../../client/elf/riscv32im-succinct-zkvm-elf");

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Setup the inputs.
let mut stdin = SP1Stdin::new();
Expand All @@ -18,36 +18,24 @@ fn main() {
stdin.write(&data);

// Execute the program in sp1-vm
let (public_values, execution_report) = client.execute(dev_elf, stdin.clone()).run().unwrap();
let (public_values, execution_report) = client.execute(dev_elf, &stdin.clone()).run().unwrap();
println!("Program executed successfully.");
// Record the number of cycles executed.
println!(
"Number of cycles: {}",
execution_report.total_instruction_count()
);
println!("Number of cycles: {}", execution_report.total_instruction_count());

let rt_data = public_values.as_slice();
println!(
"pi_hash generated with sp1-vm execution: {}",
hex::encode(rt_data)
);
println!("pi_hash generated with sp1-vm execution: {}", hex::encode(rt_data));

let start = Instant::now();

// Setup the program for proving.
let (pk, vk) = client.setup(dev_elf);

// Generate the proof
let proof = client
.prove(&pk, stdin)
.run()
.expect("failed to generate proof");
let proof = client.prove(&pk, &stdin).run().expect("failed to generate proof");

let duration_mins = start.elapsed().as_secs() / 60;
println!(
"Successfully generated proof!, time use: {:?} minutes",
duration_mins
);
println!("Successfully generated proof!, time use: {:?} minutes", duration_mins);

// Verify the proof.
client.verify(&proof, &vk).expect("failed to verify proof");
Expand Down
Binary file modified prover/tests/poseidon-bn254/client/elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
12 changes: 0 additions & 12 deletions prover/tests/poseidon-bn254/host/build.rs

This file was deleted.

6 changes: 4 additions & 2 deletions prover/tests/poseidon-bn254/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ fn main() {

// Step2. Run in sp1-vm
// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM.
// let dev_elf: &[u8] = include_elf!("poseidon");
let dev_elf: &[u8] = include_bytes!("../../client/elf/riscv32im-succinct-zkvm-elf");

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();
// Setup the inputs.
let stdin = SP1Stdin::new();
// Execute the program in sp1-vm
let (public_values, execution_report) = client.execute(dev_elf, stdin.clone()).run().unwrap();
let (public_values, execution_report) = client.execute(dev_elf, &stdin.clone()).run().unwrap();
// Record the number of cycles executed.
println!(
"Program executed successfully, Number of cycles: {}",
Expand Down
12 changes: 0 additions & 12 deletions prover/tests/zstd/host/build.rs

This file was deleted.

27 changes: 7 additions & 20 deletions prover/tests/zstd/host/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use sp1_sdk::{ProverClient, SP1Stdin};
use std::io::Read;
use std::{fs::File, path::Path, time::Instant};
use std::{fs::File, io::Read, path::Path, time::Instant};

fn main() {
// Setup the logger.
Expand All @@ -19,38 +18,26 @@ fn main() {

stdin.write_slice(&data);

let client = ProverClient::new();
let client = ProverClient::from_env();
// Execute the program in sp1-vm
let (public_values, execution_report) = client.execute(dev_elf, stdin.clone()).run().unwrap();
let (public_values, execution_report) = client.execute(dev_elf, &stdin.clone()).run().unwrap();
println!("Program executed successfully.");
// Record the number of cycles executed.
println!(
"Number of cycles: {}",
execution_report.total_instruction_count()
);
println!("Number of cycles: {}", execution_report.total_instruction_count());

let rt_data = public_values.as_slice();
println!(
"pi_hash generated with sp1-vm execution: {}",
hex::encode(rt_data)
);
println!("pi_hash generated with sp1-vm execution: {}", hex::encode(rt_data));

let start = Instant::now();

// Setup the program for proving.
let (pk, vk) = client.setup(dev_elf);

// Generate the proof
let proof = client
.prove(&pk, stdin)
.run()
.expect("failed to generate proof");
let proof = client.prove(&pk, &stdin).run().expect("failed to generate proof");

let duration_mins = start.elapsed().as_secs() / 60;
println!(
"Successfully generated proof!, time use: {:?} minutes",
duration_mins
);
println!("Successfully generated proof!, time use: {:?} minutes", duration_mins);

// Verify the proof.
client.verify(&proof, &vk).expect("failed to verify proof");
Expand Down

0 comments on commit 05e6cfe

Please sign in to comment.