-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename Prover namespace to BatchProver * Add light client type * Separate batch and light client prover configs * Add citrea light client proving config * lint * Remove unused dep * Minor cleanup * Fix comment * Lint
- Loading branch information
1 parent
669d14f
commit 629e82f
Showing
20 changed files
with
310 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::batch_prover::ProverGuestRunConfig; | ||
|
||
/// Light client prover configuration | ||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] | ||
pub struct LightClientProverConfig { | ||
/// Prover run mode | ||
pub proving_mode: ProverGuestRunConfig, | ||
/// Average number of commitments to prove | ||
pub proof_sampling_number: usize, | ||
/// If true prover will try to recover ongoing proving sessions | ||
pub enable_recovery: bool, | ||
} | ||
|
||
impl Default for LightClientProverConfig { | ||
fn default() -> Self { | ||
Self { | ||
proving_mode: ProverGuestRunConfig::Execute, | ||
proof_sampling_number: 0, | ||
enable_recovery: true, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::{ | ||
fs::File, | ||
io::{Read, Write}, | ||
path::Path, | ||
}; | ||
|
||
use serde::de::DeserializeOwned; | ||
use tempfile::NamedTempFile; | ||
|
||
use super::*; | ||
|
||
/// Reads toml file as a specific type. | ||
pub fn from_toml_path<P: AsRef<Path>, R: DeserializeOwned>(path: P) -> anyhow::Result<R> { | ||
let mut contents = String::new(); | ||
{ | ||
let mut file = File::open(path)?; | ||
file.read_to_string(&mut contents)?; | ||
} | ||
let result: R = toml::from_str(&contents)?; | ||
|
||
Ok(result) | ||
} | ||
|
||
fn create_config_from(content: &str) -> NamedTempFile { | ||
let mut config_file = NamedTempFile::new().unwrap(); | ||
config_file.write_all(content.as_bytes()).unwrap(); | ||
config_file | ||
} | ||
|
||
#[test] | ||
fn test_correct_prover_config() { | ||
let config = r#" | ||
proving_mode = "skip" | ||
proof_sampling_number = 500 | ||
enable_recovery = true | ||
"#; | ||
|
||
let config_file = create_config_from(config); | ||
|
||
let config: LightClientProverConfig = from_toml_path(config_file.path()).unwrap(); | ||
let expected = LightClientProverConfig { | ||
proving_mode: ProverGuestRunConfig::Skip, | ||
proof_sampling_number: 500, | ||
enable_recovery: true, | ||
}; | ||
assert_eq!(config, expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
use super::{ | ||
bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullFullNodeConfig, FullProverConfig, | ||
FullSequencerConfig, | ||
bitcoin::BitcoinConfig, test_case::TestCaseConfig, FullBatchProverConfig, FullFullNodeConfig, | ||
FullLightClientProverConfig, FullSequencerConfig, | ||
}; | ||
|
||
#[derive(Clone)] | ||
pub struct TestConfig { | ||
pub test_case: TestCaseConfig, | ||
pub bitcoin: Vec<BitcoinConfig>, | ||
pub sequencer: FullSequencerConfig, | ||
pub prover: FullProverConfig, | ||
pub batch_prover: FullBatchProverConfig, | ||
pub light_client_prover: FullLightClientProverConfig, | ||
pub full_node: FullFullNodeConfig, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.