mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-06-29 18:39:30 +00:00
Print full stats for PPE bench
This commit is contained in:
parent
7b099395d6
commit
28bfaa51d0
@ -6,7 +6,7 @@ use lee_core::{
|
|||||||
account::AccountWithMetadata,
|
account::AccountWithMetadata,
|
||||||
program::{ChainedCall, InstructionData, ProgramId, ProgramOutput},
|
program::{ChainedCall, InstructionData, ProgramId, ProgramOutput},
|
||||||
};
|
};
|
||||||
use risc0_zkvm::{ExecutorEnv, InnerReceipt, ProverOpts, Receipt, default_prover};
|
use risc0_zkvm::{ExecutorEnv, InnerReceipt, ProverOpts, Receipt, SessionStats, default_prover};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{InvalidProgramBehaviorError, LeeError},
|
error::{InvalidProgramBehaviorError, LeeError},
|
||||||
@ -70,7 +70,7 @@ pub fn execute_and_prove(
|
|||||||
account_identities: Vec<InputAccountIdentity>,
|
account_identities: Vec<InputAccountIdentity>,
|
||||||
program_with_dependencies: &ProgramWithDependencies,
|
program_with_dependencies: &ProgramWithDependencies,
|
||||||
) -> Result<(PrivacyPreservingCircuitOutput, Proof), LeeError> {
|
) -> Result<(PrivacyPreservingCircuitOutput, Proof), LeeError> {
|
||||||
let (output, proof, _cycles) = execute_and_prove_with_cycles(
|
let (output, proof, _stats) = execute_and_prove_with_stats(
|
||||||
pre_states,
|
pre_states,
|
||||||
instruction_data,
|
instruction_data,
|
||||||
account_identities,
|
account_identities,
|
||||||
@ -79,14 +79,14 @@ pub fn execute_and_prove(
|
|||||||
Ok((output, proof))
|
Ok((output, proof))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a proof and cycle count for the execution of a LEE program inside the privacy
|
/// Generates a proof and stats for the execution of a LEE program inside the privacy
|
||||||
/// preserving execution circuit.
|
/// preserving execution circuit.
|
||||||
pub fn execute_and_prove_with_cycles(
|
pub fn execute_and_prove_with_stats(
|
||||||
pre_states: Vec<AccountWithMetadata>,
|
pre_states: Vec<AccountWithMetadata>,
|
||||||
instruction_data: InstructionData,
|
instruction_data: InstructionData,
|
||||||
account_identities: Vec<InputAccountIdentity>,
|
account_identities: Vec<InputAccountIdentity>,
|
||||||
program_with_dependencies: &ProgramWithDependencies,
|
program_with_dependencies: &ProgramWithDependencies,
|
||||||
) -> Result<(PrivacyPreservingCircuitOutput, Proof, u64), LeeError> {
|
) -> Result<(PrivacyPreservingCircuitOutput, Proof, SessionStats), LeeError> {
|
||||||
let ProgramWithDependencies {
|
let ProgramWithDependencies {
|
||||||
program: initial_program,
|
program: initial_program,
|
||||||
dependencies,
|
dependencies,
|
||||||
@ -162,7 +162,7 @@ pub fn execute_and_prove_with_cycles(
|
|||||||
.decode()
|
.decode()
|
||||||
.map_err(|e| LeeError::CircuitOutputDeserializationError(e.to_string()))?;
|
.map_err(|e| LeeError::CircuitOutputDeserializationError(e.to_string()))?;
|
||||||
|
|
||||||
Ok((circuit_output, proof, prove_info.stats.user_cycles))
|
Ok((circuit_output, proof, prove_info.stats))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_and_prove_program(
|
fn execute_and_prove_program(
|
||||||
|
|||||||
@ -29,6 +29,10 @@ pub struct PpeBenchResult {
|
|||||||
pub prove_wall_ms: Option<f64>,
|
pub prove_wall_ms: Option<f64>,
|
||||||
/// Executor `user_cycles` of the privacy circuit.
|
/// Executor `user_cycles` of the privacy circuit.
|
||||||
pub user_cycles: Option<u64>,
|
pub user_cycles: Option<u64>,
|
||||||
|
/// `total_cycles` including padding.
|
||||||
|
pub total_cycles: Option<u64>,
|
||||||
|
/// Number of segments.
|
||||||
|
pub segments: Option<usize>,
|
||||||
/// borsh-serialized `InnerReceipt` length (`S_agg` in the fee model).
|
/// borsh-serialized `InnerReceipt` length (`S_agg` in the fee model).
|
||||||
pub proof_bytes: Option<usize>,
|
pub proof_bytes: Option<usize>,
|
||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
@ -66,16 +70,18 @@ pub fn print_table(results: &[PpeBenchResult]) {
|
|||||||
.max("label".len());
|
.max("label".len());
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"\n{:<lw$} {:>5} {:>20} {:>12} {:>12} {}",
|
"\n{:<lw$} {:>5} {:>20} {:>12} {:>12} {:>8} {:>12} {}",
|
||||||
"label",
|
"label",
|
||||||
"depth",
|
"depth",
|
||||||
"prove_ms (s)",
|
"prove_ms (s)",
|
||||||
"user_cycles",
|
"user_cycles",
|
||||||
|
"total_cycles",
|
||||||
|
"segments",
|
||||||
"proof_bytes",
|
"proof_bytes",
|
||||||
"error",
|
"error",
|
||||||
lw = lw,
|
lw = lw,
|
||||||
);
|
);
|
||||||
println!("{}", "-".repeat(lw + 72));
|
println!("{}", "-".repeat(lw + 92));
|
||||||
for r in results {
|
for r in results {
|
||||||
let p = r.prove_wall_ms.map_or_else(
|
let p = r.prove_wall_ms.map_or_else(
|
||||||
|| "-".to_owned(),
|
|| "-".to_owned(),
|
||||||
@ -84,16 +90,22 @@ pub fn print_table(results: &[PpeBenchResult]) {
|
|||||||
let c = r
|
let c = r
|
||||||
.user_cycles
|
.user_cycles
|
||||||
.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
||||||
|
let tc = r
|
||||||
|
.total_cycles
|
||||||
|
.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
||||||
|
let s = r.segments.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
||||||
let b = r
|
let b = r
|
||||||
.proof_bytes
|
.proof_bytes
|
||||||
.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
.map_or_else(|| "-".to_owned(), |n| n.to_string());
|
||||||
let e = r.error.as_deref().unwrap_or("");
|
let e = r.error.as_deref().unwrap_or("");
|
||||||
println!(
|
println!(
|
||||||
"{:<lw$} {:>5} {:>20} {:>12} {:>12} {}",
|
"{:<lw$} {:>5} {:>20} {:>12} {:>12} {:>8} {:>12} {}",
|
||||||
r.label,
|
r.label,
|
||||||
r.chain_depth,
|
r.chain_depth,
|
||||||
p,
|
p,
|
||||||
c,
|
c,
|
||||||
|
tc,
|
||||||
|
s,
|
||||||
b,
|
b,
|
||||||
e,
|
e,
|
||||||
lw = lw,
|
lw = lw,
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use std::{collections::HashMap, time::Instant};
|
|||||||
|
|
||||||
use lee::{
|
use lee::{
|
||||||
privacy_preserving_transaction::circuit::{
|
privacy_preserving_transaction::circuit::{
|
||||||
ProgramWithDependencies, Proof, execute_and_prove_with_cycles,
|
ProgramWithDependencies, Proof, execute_and_prove_with_stats,
|
||||||
},
|
},
|
||||||
program::Program,
|
program::Program,
|
||||||
};
|
};
|
||||||
@ -17,7 +17,7 @@ use lee_core::{
|
|||||||
account::{Account, AccountId, AccountWithMetadata},
|
account::{Account, AccountId, AccountWithMetadata},
|
||||||
program::ProgramId,
|
program::ProgramId,
|
||||||
};
|
};
|
||||||
use risc0_zkvm::serde::to_vec;
|
use risc0_zkvm::{SessionStats, serde::to_vec};
|
||||||
|
|
||||||
use super::PpeBenchResult;
|
use super::PpeBenchResult;
|
||||||
|
|
||||||
@ -37,14 +37,16 @@ pub fn run_auth_transfer_in_ppe(private: bool) -> PpeBenchResult {
|
|||||||
};
|
};
|
||||||
let started = Instant::now();
|
let started = Instant::now();
|
||||||
match prove_auth_transfer_in_ppe(private) {
|
match prove_auth_transfer_in_ppe(private) {
|
||||||
Ok((_out, proof, user_cycles)) => {
|
Ok((_out, proof, stats)) => {
|
||||||
let prove_ms = started.elapsed().as_secs_f64() * 1_000.0;
|
let prove_ms = started.elapsed().as_secs_f64() * 1_000.0;
|
||||||
PpeBenchResult {
|
PpeBenchResult {
|
||||||
label,
|
label,
|
||||||
chain_depth: 0,
|
chain_depth: 0,
|
||||||
prove_wall_ms: Some(prove_ms),
|
prove_wall_ms: Some(prove_ms),
|
||||||
proof_bytes: Some(proof.into_inner().len()),
|
proof_bytes: Some(proof.into_inner().len()),
|
||||||
user_cycles: Some(user_cycles),
|
user_cycles: Some(stats.user_cycles),
|
||||||
|
total_cycles: Some(stats.total_cycles),
|
||||||
|
segments: Some(stats.segments),
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,6 +56,8 @@ pub fn run_auth_transfer_in_ppe(private: bool) -> PpeBenchResult {
|
|||||||
prove_wall_ms: None,
|
prove_wall_ms: None,
|
||||||
proof_bytes: None,
|
proof_bytes: None,
|
||||||
user_cycles: None,
|
user_cycles: None,
|
||||||
|
total_cycles: None,
|
||||||
|
segments: None,
|
||||||
error: Some(err.to_string()),
|
error: Some(err.to_string()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -63,7 +67,7 @@ pub fn run_auth_transfer_in_ppe(private: bool) -> PpeBenchResult {
|
|||||||
/// `private` flag signals whether the receiver is a private account.
|
/// `private` flag signals whether the receiver is a private account.
|
||||||
pub fn prove_auth_transfer_in_ppe(
|
pub fn prove_auth_transfer_in_ppe(
|
||||||
private: bool,
|
private: bool,
|
||||||
) -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof, u64)> {
|
) -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof, SessionStats)> {
|
||||||
let pwd = ProgramWithDependencies::from(Program::new(AUTH_TRANSFER_ELF.to_vec())?);
|
let pwd = ProgramWithDependencies::from(Program::new(AUTH_TRANSFER_ELF.to_vec())?);
|
||||||
|
|
||||||
// Sender must already be claimed by auth_transfer for its balance to be debited.
|
// Sender must already be claimed by auth_transfer for its balance to be debited.
|
||||||
@ -104,7 +108,7 @@ pub fn prove_auth_transfer_in_ppe(
|
|||||||
(recipient, InputAccountIdentity::Public)
|
(recipient, InputAccountIdentity::Public)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(execute_and_prove_with_cycles(
|
Ok(execute_and_prove_with_stats(
|
||||||
vec![sender, recipient],
|
vec![sender, recipient],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
vec![InputAccountIdentity::Public, recipient_identity],
|
vec![InputAccountIdentity::Public, recipient_identity],
|
||||||
@ -116,14 +120,16 @@ pub fn run_chain_caller(depth: u32) -> PpeBenchResult {
|
|||||||
let label = format!("chain_caller depth={depth}");
|
let label = format!("chain_caller depth={depth}");
|
||||||
let started = Instant::now();
|
let started = Instant::now();
|
||||||
match prove_chain_caller(depth) {
|
match prove_chain_caller(depth) {
|
||||||
Ok((_out, proof, user_cycles)) => {
|
Ok((_out, proof, stats)) => {
|
||||||
let prove_ms = started.elapsed().as_secs_f64() * 1_000.0;
|
let prove_ms = started.elapsed().as_secs_f64() * 1_000.0;
|
||||||
PpeBenchResult {
|
PpeBenchResult {
|
||||||
label,
|
label,
|
||||||
chain_depth: depth as usize,
|
chain_depth: depth as usize,
|
||||||
prove_wall_ms: Some(prove_ms),
|
prove_wall_ms: Some(prove_ms),
|
||||||
proof_bytes: Some(proof.into_inner().len()),
|
proof_bytes: Some(proof.into_inner().len()),
|
||||||
user_cycles: Some(user_cycles),
|
user_cycles: Some(stats.user_cycles),
|
||||||
|
total_cycles: Some(stats.total_cycles),
|
||||||
|
segments: Some(stats.segments),
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,6 +139,8 @@ pub fn run_chain_caller(depth: u32) -> PpeBenchResult {
|
|||||||
prove_wall_ms: None,
|
prove_wall_ms: None,
|
||||||
proof_bytes: None,
|
proof_bytes: None,
|
||||||
user_cycles: None,
|
user_cycles: None,
|
||||||
|
total_cycles: None,
|
||||||
|
segments: None,
|
||||||
error: Some(err.to_string()),
|
error: Some(err.to_string()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -140,7 +148,7 @@ pub fn run_chain_caller(depth: u32) -> PpeBenchResult {
|
|||||||
|
|
||||||
fn prove_chain_caller(
|
fn prove_chain_caller(
|
||||||
num_chain_calls: u32,
|
num_chain_calls: u32,
|
||||||
) -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof, u64)> {
|
) -> anyhow::Result<(PrivacyPreservingCircuitOutput, Proof, SessionStats)> {
|
||||||
let chain_caller = Program::new(CHAIN_CALLER_ELF.to_vec())?;
|
let chain_caller = Program::new(CHAIN_CALLER_ELF.to_vec())?;
|
||||||
let auth_transfer = Program::new(AUTH_TRANSFER_ELF.to_vec())?;
|
let auth_transfer = Program::new(AUTH_TRANSFER_ELF.to_vec())?;
|
||||||
let mut deps = HashMap::new();
|
let mut deps = HashMap::new();
|
||||||
@ -177,7 +185,7 @@ fn prove_chain_caller(
|
|||||||
|
|
||||||
let account_identities = vec![InputAccountIdentity::Public; pre_states.len()];
|
let account_identities = vec![InputAccountIdentity::Public; pre_states.len()];
|
||||||
|
|
||||||
Ok(execute_and_prove_with_cycles(
|
Ok(execute_and_prove_with_stats(
|
||||||
pre_states,
|
pre_states,
|
||||||
instruction_data,
|
instruction_data,
|
||||||
account_identities,
|
account_identities,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user