From 1ec12c26819869ef22f1de847505aea7f74687d5 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakoff Date: Fri, 29 Nov 2024 00:28:22 +0400 Subject: [PATCH 1/5] Refactor ProofGenMode --- bin/citrea/src/rollup/bitcoin.rs | 7 +++--- bin/citrea/src/rollup/mock.rs | 6 ++--- crates/prover-services/src/lib.rs | 21 ++++++++++++++++- crates/prover-services/src/parallel/mod.rs | 26 +++++++++++++--------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/bin/citrea/src/rollup/bitcoin.rs b/bin/citrea/src/rollup/bitcoin.rs index 6a3a4c0ef..73428f9a3 100644 --- a/bin/citrea/src/rollup/bitcoin.rs +++ b/bin/citrea/src/rollup/bitcoin.rs @@ -29,8 +29,8 @@ use sov_rollup_interface::spec::SpecId; use sov_rollup_interface::zk::Zkvm; use sov_state::ZkStorage; use sov_stf_runner::ProverGuestRunConfig; -use tokio::sync::broadcast; use tokio::sync::mpsc::unbounded_channel; +use tokio::sync::{broadcast, Mutex}; use tracing::instrument; use crate::CitreaRollupBlueprint; @@ -201,7 +201,7 @@ impl RollupBlueprint for BitcoinRollup { ProverGuestRunConfig::Skip => ProofGenMode::Skip, ProverGuestRunConfig::Simulate => { let stf_verifier = StateTransitionVerifier::new(zk_stf, da_verifier); - ProofGenMode::Simulate(stf_verifier) + ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, ProverGuestRunConfig::Prove => ProofGenMode::Prove, @@ -241,7 +241,8 @@ impl RollupBlueprint for BitcoinRollup { ProverGuestRunConfig::Skip => ProofGenMode::Skip, ProverGuestRunConfig::Simulate => { let stf_verifier = StateTransitionVerifier::new(zk_stf, da_verifier); - ProofGenMode::Simulate(stf_verifier) + + ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, ProverGuestRunConfig::Prove => ProofGenMode::Prove, diff --git a/bin/citrea/src/rollup/mock.rs b/bin/citrea/src/rollup/mock.rs index b87adae9f..10df80fe1 100644 --- a/bin/citrea/src/rollup/mock.rs +++ b/bin/citrea/src/rollup/mock.rs @@ -23,7 +23,7 @@ use sov_rollup_interface::spec::SpecId; use sov_rollup_interface::zk::Zkvm; use sov_state::ZkStorage; use sov_stf_runner::ProverGuestRunConfig; -use tokio::sync::broadcast; +use tokio::sync::{broadcast, Mutex}; use crate::CitreaRollupBlueprint; @@ -132,7 +132,7 @@ impl RollupBlueprint for MockDemoRollup { ProverGuestRunConfig::Skip => ProofGenMode::Skip, ProverGuestRunConfig::Simulate => { let stf_verifier = StateTransitionVerifier::new(zk_stf, da_verifier); - ProofGenMode::Simulate(stf_verifier) + ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, ProverGuestRunConfig::Prove => ProofGenMode::Prove, @@ -158,7 +158,7 @@ impl RollupBlueprint for MockDemoRollup { ProverGuestRunConfig::Skip => ProofGenMode::Skip, ProverGuestRunConfig::Simulate => { let stf_verifier = StateTransitionVerifier::new(zk_stf, da_verifier); - ProofGenMode::Simulate(stf_verifier) + ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, ProverGuestRunConfig::Prove => ProofGenMode::Prove, diff --git a/crates/prover-services/src/lib.rs b/crates/prover-services/src/lib.rs index a23f701a5..10c983894 100644 --- a/crates/prover-services/src/lib.rs +++ b/crates/prover-services/src/lib.rs @@ -1,7 +1,10 @@ +use std::sync::Arc; + use citrea_stf::verifier::StateTransitionVerifier; use sov_rollup_interface::services::da::DaService; use sov_rollup_interface::stf::StateTransitionFunction; use sov_rollup_interface::zk::ZkvmHost; +use tokio::sync::Mutex; mod parallel; pub use parallel::*; @@ -15,10 +18,26 @@ where /// Skips proving. Skip, /// The simulator runs the rollup verifier logic without even emulating the zkVM - Simulate(StateTransitionVerifier), + Simulate(Arc>>), /// The executor runs the rollup verification logic in the zkVM, but does not actually /// produce a zk proof Execute, /// The prover runs the rollup verification logic in the zkVM and produces a zk proof Prove, } + +impl Clone for ProofGenMode +where + Da: DaService, + Vm: ZkvmHost, + Stf: StateTransitionFunction, +{ + fn clone(&self) -> Self { + match self { + Self::Skip => Self::Skip, + Self::Execute => Self::Execute, + Self::Prove => Self::Prove, + Self::Simulate(simulate) => Self::Simulate(Arc::clone(simulate)), + } + } +} diff --git a/crates/prover-services/src/parallel/mod.rs b/crates/prover-services/src/parallel/mod.rs index 904b06dbb..d7f681ea6 100644 --- a/crates/prover-services/src/parallel/mod.rs +++ b/crates/prover-services/src/parallel/mod.rs @@ -1,4 +1,3 @@ -use std::ops::DerefMut; use std::sync::Arc; use async_trait::async_trait; @@ -27,7 +26,7 @@ where { thread_pool: rayon::ThreadPool, - proof_mode: Arc>>, + proof_mode: ProofGenMode, da_service: Arc, vm: Vm, @@ -80,7 +79,7 @@ where Ok(Self { thread_pool, - proof_mode: Arc::new(Mutex::new(proof_mode)), + proof_mode, da_service, vm, zk_storage, @@ -190,7 +189,7 @@ where async fn prove(&self) -> anyhow::Result> { let mut proof_queue = self.proof_queue.lock().await; - if let ProofGenMode::Skip = *self.proof_mode.lock().await { + if let ProofGenMode::Skip = self.proof_mode { tracing::debug!("Skipped proving {} proofs", proof_queue.len()); proof_queue.clear(); return Ok(vec![]); @@ -233,7 +232,7 @@ where fn make_proof( mut vm: Vm, zk_storage: Stf::PreState, - proof_mode: Arc>>, + proof_mode: ProofGenMode, ) -> Result where Da: DaService, @@ -241,13 +240,18 @@ where Stf: StateTransitionFunction + Send + Sync, Stf::PreState: Send + Sync, { - let mut proof_mode = proof_mode.blocking_lock(); - match proof_mode.deref_mut() { + let proof_mode = proof_mode; + match proof_mode { ProofGenMode::Skip => Ok(Vec::default()), - ProofGenMode::Simulate(ref mut verifier) => verifier - .run_sequencer_commitments_in_da_slot(vm.simulate_with_hints(), zk_storage) - .map(|_| Vec::default()) - .map_err(|e| anyhow::anyhow!("Guest execution must succeed but failed with {:?}", e)), + ProofGenMode::Simulate(verifier) => { + let mut verifier = verifier.blocking_lock(); + verifier + .run_sequencer_commitments_in_da_slot(vm.simulate_with_hints(), zk_storage) + .map(|_| Vec::default()) + .map_err(|e| { + anyhow::anyhow!("Guest execution must succeed but failed with {:?}", e) + }) + } ProofGenMode::Execute => vm.run(false), ProofGenMode::Prove => vm.run(true), } From 9c1520f663d652b2ad07b5997d93ec7f30efd62b Mon Sep 17 00:00:00 2001 From: Roman Proskuryakoff Date: Fri, 29 Nov 2024 16:32:48 +0400 Subject: [PATCH 2/5] Always prove, even if it's a fake proof --- bin/citrea/src/rollup/bitcoin.rs | 4 +-- bin/citrea/src/rollup/mock.rs | 4 +-- crates/batch-prover/src/da_block_handler.rs | 32 ++++++++------------- crates/prover-services/src/lib.rs | 16 +++++++++-- crates/prover-services/src/parallel/mod.rs | 17 +++++++++-- 5 files changed, 43 insertions(+), 30 deletions(-) diff --git a/bin/citrea/src/rollup/bitcoin.rs b/bin/citrea/src/rollup/bitcoin.rs index 73428f9a3..092a1774b 100644 --- a/bin/citrea/src/rollup/bitcoin.rs +++ b/bin/citrea/src/rollup/bitcoin.rs @@ -204,7 +204,7 @@ impl RollupBlueprint for BitcoinRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove, + ProverGuestRunConfig::Prove => ProofGenMode::Prove(prover_config.proof_sampling_number), }; ParallelProverService::new_from_env( @@ -245,7 +245,7 @@ impl RollupBlueprint for BitcoinRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove, + ProverGuestRunConfig::Prove => ProofGenMode::Prove(prover_config.proof_sampling_number), }; ParallelProverService::new(da_service.clone(), vm, proof_mode, zk_storage, 1, ledger_db) diff --git a/bin/citrea/src/rollup/mock.rs b/bin/citrea/src/rollup/mock.rs index 10df80fe1..2950b3b45 100644 --- a/bin/citrea/src/rollup/mock.rs +++ b/bin/citrea/src/rollup/mock.rs @@ -135,7 +135,7 @@ impl RollupBlueprint for MockDemoRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove, + ProverGuestRunConfig::Prove => ProofGenMode::Prove(prover_config.proof_sampling_number), }; ParallelProverService::new(da_service.clone(), vm, proof_mode, zk_storage, 1, ledger_db) @@ -161,7 +161,7 @@ impl RollupBlueprint for MockDemoRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove, + ProverGuestRunConfig::Prove => ProofGenMode::Prove(prover_config.proof_sampling_number), }; ParallelProverService::new(da_service.clone(), vm, proof_mode, zk_storage, 1, ledger_db) diff --git a/crates/batch-prover/src/da_block_handler.rs b/crates/batch-prover/src/da_block_handler.rs index dcbd42ef6..90108d6e4 100644 --- a/crates/batch-prover/src/da_block_handler.rs +++ b/crates/batch-prover/src/da_block_handler.rs @@ -12,7 +12,6 @@ use citrea_common::utils::merge_state_diffs; use citrea_common::BatchProverConfig; use citrea_primitives::compression::compress_blob; use citrea_primitives::MAX_TXBODY_SIZE; -use rand::Rng; use serde::de::DeserializeOwned; use serde::Serialize; use sov_db::ledger_db::BatchProverLedgerOps; @@ -233,25 +232,18 @@ where l1_block.header().height(), ); - // if proof_sampling_number is 0, then we always prove and submit - // otherwise we submit and prove with a probability of 1/proof_sampling_number - let should_prove = self.prover_config.proof_sampling_number == 0 - || rand::thread_rng().gen_range(0..self.prover_config.proof_sampling_number) == 0; - - if should_prove { - if l1_height >= self.skip_submission_until_l1 { - prove_l1::( - self.prover_service.clone(), - self.ledger_db.clone(), - self.code_commitments_by_spec.clone(), - l1_block.clone(), - sequencer_commitments, - inputs, - ) - .await?; - } else { - info!("Skipping proving for l1 height {}", l1_height); - } + if l1_height >= self.skip_submission_until_l1 { + prove_l1::( + self.prover_service.clone(), + self.ledger_db.clone(), + self.code_commitments_by_spec.clone(), + l1_block.clone(), + sequencer_commitments, + inputs, + ) + .await?; + } else { + info!("Skipping proving for l1 height {}", l1_height); } if let Err(e) = self diff --git a/crates/prover-services/src/lib.rs b/crates/prover-services/src/lib.rs index 10c983894..224542837 100644 --- a/crates/prover-services/src/lib.rs +++ b/crates/prover-services/src/lib.rs @@ -9,6 +9,9 @@ use tokio::sync::Mutex; mod parallel; pub use parallel::*; +type Simulator = + Arc>>; + pub enum ProofGenMode where Da: DaService, @@ -18,12 +21,19 @@ where /// Skips proving. Skip, /// The simulator runs the rollup verifier logic without even emulating the zkVM - Simulate(Arc>>), + Simulate(Simulator), /// The executor runs the rollup verification logic in the zkVM, but does not actually /// produce a zk proof Execute, /// The prover runs the rollup verification logic in the zkVM and produces a zk proof - Prove, + Prove( + /// Average number of commitments to prove + /// If proof_sampling_number is 0, then we always prove and submit + /// Otherwise we submit and prove with a probability of 1/proof_sampling_number + /// + /// proof_sampling_number: + usize, + ), } impl Clone for ProofGenMode @@ -36,7 +46,7 @@ where match self { Self::Skip => Self::Skip, Self::Execute => Self::Execute, - Self::Prove => Self::Prove, + Self::Prove(proof_sampling_number) => Self::Prove(*proof_sampling_number), Self::Simulate(simulate) => Self::Simulate(Arc::clone(simulate)), } } diff --git a/crates/prover-services/src/parallel/mod.rs b/crates/prover-services/src/parallel/mod.rs index d7f681ea6..57f07dd58 100644 --- a/crates/prover-services/src/parallel/mod.rs +++ b/crates/prover-services/src/parallel/mod.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use async_trait::async_trait; use futures::future; +use rand::Rng; use sov_db::ledger_db::LedgerDB; use sov_rollup_interface::da::DaData; use sov_rollup_interface::services::da::DaService; @@ -67,8 +68,14 @@ where ProofGenMode::Execute => { tracing::info!("Prover is configured to execute proving"); } - ProofGenMode::Prove => { - tracing::info!("Prover is configured to prove"); + ProofGenMode::Prove(proof_sampling_number) => { + if proof_sampling_number == 0 { + tracing::info!("Prover is configured to prove"); + } else { + tracing::info!( + "Prover is configured to prove with 1/{proof_sampling_number} sampling" + ); + } } }; @@ -253,6 +260,10 @@ where }) } ProofGenMode::Execute => vm.run(false), - ProofGenMode::Prove => vm.run(true), + ProofGenMode::Prove(proof_sampling_number) => { + let with_prove = proof_sampling_number == 0 + || rand::thread_rng().gen_range(0..proof_sampling_number) == 0; + vm.run(with_prove) + } } } From 34fcc8b721c7bc403ed9bdd5cc95f7c13e0cb5bc Mon Sep 17 00:00:00 2001 From: Roman Proskuryakoff Date: Mon, 2 Dec 2024 23:52:21 +0400 Subject: [PATCH 3/5] Don't add duplicate SequencerCommitment on prove_l1 --- .../full-node/db/sov-db/src/ledger_db/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs index cd28da4b4..50d8967f8 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs @@ -349,9 +349,13 @@ impl SharedLedgerOps for LedgerDB { match commitments { // If there were other commitments, upsert Some(mut commitments) => { - commitments.push(commitment); - self.db - .put::(&SlotNumber(height), &commitments) + if !commitments.contains(&commitment) { + commitments.push(commitment); + self.db + .put::(&SlotNumber(height), &commitments) + } else { + Ok(()) + } } // Else insert None => self From 26f81780fd9a6f652e08a37d2b7d31cce8cf5025 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakoff Date: Tue, 3 Dec 2024 22:48:24 +0400 Subject: [PATCH 4/5] Add a different proving mode --- bin/citrea/src/rollup/bitcoin.rs | 5 ++- bin/citrea/src/rollup/mock.rs | 5 ++- crates/batch-prover/src/da_block_handler.rs | 43 +++++++++++++------ crates/prover-services/src/lib.rs | 16 ++++--- crates/prover-services/src/parallel/mod.rs | 19 ++++++-- .../sov-stf-runner/src/prover_service/mod.rs | 3 ++ 6 files changed, 66 insertions(+), 25 deletions(-) diff --git a/bin/citrea/src/rollup/bitcoin.rs b/bin/citrea/src/rollup/bitcoin.rs index abeeb807a..d82e8e3bb 100644 --- a/bin/citrea/src/rollup/bitcoin.rs +++ b/bin/citrea/src/rollup/bitcoin.rs @@ -264,7 +264,10 @@ impl RollupBlueprint for BitcoinRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove(proof_sampling_number), + ProverGuestRunConfig::Prove => ProofGenMode::ProveWithSampling, + ProverGuestRunConfig::ProveWithFakeProofs => { + ProofGenMode::ProveWithSamplingWithFakeProofs(proof_sampling_number) + } }; ParallelProverService::new_from_env( diff --git a/bin/citrea/src/rollup/mock.rs b/bin/citrea/src/rollup/mock.rs index e40ecec12..311e8c4fa 100644 --- a/bin/citrea/src/rollup/mock.rs +++ b/bin/citrea/src/rollup/mock.rs @@ -193,7 +193,10 @@ impl RollupBlueprint for MockDemoRollup { ProofGenMode::Simulate(Arc::new(Mutex::new(stf_verifier))) } ProverGuestRunConfig::Execute => ProofGenMode::Execute, - ProverGuestRunConfig::Prove => ProofGenMode::Prove(proof_sampling_number), + ProverGuestRunConfig::Prove => ProofGenMode::ProveWithSampling, + ProverGuestRunConfig::ProveWithFakeProofs => { + ProofGenMode::ProveWithSamplingWithFakeProofs(proof_sampling_number) + } }; ParallelProverService::new(da_service.clone(), vm, proof_mode, zk_storage, 1, ledger_db) diff --git a/crates/batch-prover/src/da_block_handler.rs b/crates/batch-prover/src/da_block_handler.rs index ef47955c3..5e910f9bc 100644 --- a/crates/batch-prover/src/da_block_handler.rs +++ b/crates/batch-prover/src/da_block_handler.rs @@ -13,6 +13,7 @@ use citrea_common::BatchProverConfig; use citrea_primitives::compression::compress_blob; use citrea_primitives::forks::FORKS; use citrea_primitives::MAX_TXBODY_SIZE; +use rand::Rng; use serde::de::DeserializeOwned; use serde::Serialize; use sov_db::ledger_db::BatchProverLedgerOps; @@ -24,7 +25,7 @@ use sov_rollup_interface::services::da::{DaService, SlotData}; use sov_rollup_interface::soft_confirmation::SignedSoftConfirmation; use sov_rollup_interface::spec::SpecId; use sov_rollup_interface::zk::ZkvmHost; -use sov_stf_runner::ProverService; +use sov_stf_runner::{ProverGuestRunConfig, ProverService}; use tokio::select; use tokio::sync::{mpsc, Mutex}; use tokio::time::{sleep, Duration}; @@ -237,19 +238,33 @@ where l1_block.header().height(), ); - if l1_height >= self.skip_submission_until_l1 { - prove_l1::( - self.prover_service.clone(), - self.ledger_db.clone(), - self.code_commitments_by_spec.clone(), - self.elfs_by_spec.clone(), - l1_block.clone(), - sequencer_commitments, - inputs, - ) - .await?; - } else { - info!("Skipping proving for l1 height {}", l1_height); + let should_prove = match self.prover_config.proving_mode { + ProverGuestRunConfig::ProveWithFakeProofs => { + // Unconditionally call `prove_l1()` + true + } + _ => { + // Call `prove_l1()` with a probability + self.prover_config.proof_sampling_number == 0 + || rand::thread_rng().gen_range(0..self.prover_config.proof_sampling_number) + == 0 + } + }; + if should_prove { + if l1_height >= self.skip_submission_until_l1 { + prove_l1::( + self.prover_service.clone(), + self.ledger_db.clone(), + self.code_commitments_by_spec.clone(), + self.elfs_by_spec.clone(), + l1_block.clone(), + sequencer_commitments, + inputs, + ) + .await?; + } else { + info!("Skipping proving for l1 height {}", l1_height); + } } if let Err(e) = self diff --git a/crates/prover-services/src/lib.rs b/crates/prover-services/src/lib.rs index 224542837..5fd74c1c9 100644 --- a/crates/prover-services/src/lib.rs +++ b/crates/prover-services/src/lib.rs @@ -26,10 +26,13 @@ where /// produce a zk proof Execute, /// The prover runs the rollup verification logic in the zkVM and produces a zk proof - Prove( - /// Average number of commitments to prove - /// If proof_sampling_number is 0, then we always prove and submit - /// Otherwise we submit and prove with a probability of 1/proof_sampling_number + ProveWithSampling, + /// The prover runs the rollup verification logic in the zkVM and produces a zk/fake proof + ProveWithSamplingWithFakeProofs( + /// Average number of _REAL_ commitments to prove + /// If proof_sampling_number is 0, then we always produce real proofs + /// Otherwise we prove with a probability of 1/proof_sampling_number, + /// but produce fake proofs with a probability of (1-1/proof_sampling_number). /// /// proof_sampling_number: usize, @@ -46,7 +49,10 @@ where match self { Self::Skip => Self::Skip, Self::Execute => Self::Execute, - Self::Prove(proof_sampling_number) => Self::Prove(*proof_sampling_number), + Self::ProveWithSampling => Self::ProveWithSampling, + Self::ProveWithSamplingWithFakeProofs(proof_sampling_number) => { + Self::ProveWithSamplingWithFakeProofs(*proof_sampling_number) + } Self::Simulate(simulate) => Self::Simulate(Arc::clone(simulate)), } } diff --git a/crates/prover-services/src/parallel/mod.rs b/crates/prover-services/src/parallel/mod.rs index 51bd6e562..040bf78f7 100644 --- a/crates/prover-services/src/parallel/mod.rs +++ b/crates/prover-services/src/parallel/mod.rs @@ -68,12 +68,15 @@ where ProofGenMode::Execute => { tracing::info!("Prover is configured to execute proving"); } - ProofGenMode::Prove(proof_sampling_number) => { + ProofGenMode::ProveWithSampling => { + tracing::info!("Prover is configured to prove"); + } + ProofGenMode::ProveWithSamplingWithFakeProofs(proof_sampling_number) => { if proof_sampling_number == 0 { - tracing::info!("Prover is configured to prove"); + tracing::info!("Prover is configured to always prove"); } else { tracing::info!( - "Prover is configured to prove with 1/{proof_sampling_number} sampling" + "Prover is configured to prove with fake proofs with 1/{proof_sampling_number} sampling" ); } } @@ -261,7 +264,15 @@ where }) } ProofGenMode::Execute => vm.run(elf, false), - ProofGenMode::Prove(proof_sampling_number) => { + ProofGenMode::ProveWithSampling => { + // `make_proof` is called with a probability in this case. + // When it's called, we have to produce a real proof. + vm.run(elf, true) + } + ProofGenMode::ProveWithSamplingWithFakeProofs(proof_sampling_number) => { + // `make_proof` is called unconditionally in this case. + // When it's called, we have to calculate the probabiliry for a proof + // and produce a real proof if we are lucky. If unlucky - produce a fake proof. let with_prove = proof_sampling_number == 0 || rand::thread_rng().gen_range(0..proof_sampling_number) == 0; vm.run(elf, with_prove) diff --git a/crates/sovereign-sdk/full-node/sov-stf-runner/src/prover_service/mod.rs b/crates/sovereign-sdk/full-node/sov-stf-runner/src/prover_service/mod.rs index 224418904..6ff15c577 100644 --- a/crates/sovereign-sdk/full-node/sov-stf-runner/src/prover_service/mod.rs +++ b/crates/sovereign-sdk/full-node/sov-stf-runner/src/prover_service/mod.rs @@ -16,6 +16,8 @@ pub enum ProverGuestRunConfig { Execute, /// Run the rollup verifier and create a SNARK of execution. Prove, + /// Run the rollup verifier and create a SNARK or a fake proof of execution. + ProveWithFakeProofs, } impl<'de> Deserialize<'de> for ProverGuestRunConfig { @@ -29,6 +31,7 @@ impl<'de> Deserialize<'de> for ProverGuestRunConfig { "simulate" => Ok(ProverGuestRunConfig::Simulate), "execute" => Ok(ProverGuestRunConfig::Execute), "prove" => Ok(ProverGuestRunConfig::Prove), + "prove-with-fakes" => Ok(ProverGuestRunConfig::ProveWithFakeProofs), _ => Err(serde::de::Error::custom("invalid prover guest run config")), } } From 6a7eb77c688bcfa1f2f9f45f2331fec6d8861ad6 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakoff Date: Tue, 3 Dec 2024 22:49:22 +0400 Subject: [PATCH 5/5] Review fixes --- crates/prover-services/src/parallel/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/prover-services/src/parallel/mod.rs b/crates/prover-services/src/parallel/mod.rs index 040bf78f7..f32a8a175 100644 --- a/crates/prover-services/src/parallel/mod.rs +++ b/crates/prover-services/src/parallel/mod.rs @@ -251,7 +251,6 @@ where Stf: StateTransitionFunction + Send + Sync, Stf::PreState: Send + Sync, { - let proof_mode = proof_mode; match proof_mode { ProofGenMode::Skip => Ok(Vec::default()), ProofGenMode::Simulate(verifier) => {