Skip to content

Commit

Permalink
fix: read env variables for prover configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Jun 15, 2024
1 parent dd331d3 commit c99349a
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions core/src/utils/options.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
use std::env;

const DEFAULT_SHARD_SIZE: usize = 1 << 22;
const DEFAULT_SHARD_BATCH_SIZE: usize = 16;
const DEFAULT_SHARD_CHUNKING_MULTIPLIER: usize = 1;
const DEFAULT_RECONSTRUCT_COMMITMENTS: bool = true;

#[derive(Debug, Clone, Copy)]
pub struct SphinxCoreOpts {
pub shard_size: usize,
Expand All @@ -9,10 +16,25 @@ pub struct SphinxCoreOpts {
impl Default for SphinxCoreOpts {
fn default() -> Self {
Self {
shard_size: 1 << 22,
shard_batch_size: 16,
shard_chunking_multiplier: 1,
reconstruct_commitments: false,
shard_size: env::var("SHARD_SIZE").map_or_else(
|_| DEFAULT_SHARD_SIZE,
|s| s.parse::<usize>().unwrap_or(DEFAULT_SHARD_SIZE),
),
shard_batch_size: env::var("SHARD_BATCH_SIZE").map_or_else(
|_| DEFAULT_SHARD_BATCH_SIZE,
|s| s.parse::<usize>().unwrap_or(DEFAULT_SHARD_BATCH_SIZE),
),
shard_chunking_multiplier: env::var("SHARD_CHUNKING_MULTIPLIER").map_or_else(
|_| DEFAULT_SHARD_CHUNKING_MULTIPLIER,
|s| {
s.parse::<usize>()
.unwrap_or(DEFAULT_SHARD_CHUNKING_MULTIPLIER)
},
),
reconstruct_commitments: env::var("RECONSTRUCT_COMMITMENTS").map_or_else(
|_| DEFAULT_RECONSTRUCT_COMMITMENTS,
|s| s.parse::<bool>().unwrap_or(DEFAULT_RECONSTRUCT_COMMITMENTS),
),
}
}
}
Expand Down

0 comments on commit c99349a

Please sign in to comment.