Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add env support to all leader prog args #786

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions zero/src/bin/leader/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,49 +54,54 @@ pub(crate) enum Command {
/// Reads input from stdin and writes output to stdout.
Stdio {
/// The previous proof output.
#[arg(long, short = 'f', value_hint = ValueHint::FilePath)]
#[arg(short = 'f', long, env="ZERO_BIN_PREVIOUS_PROOF", value_hint = ValueHint::FilePath)]
previous_proof: Option<PathBuf>,
},
/// Reads input from a node rpc and writes output to stdout.
Rpc {
// The node RPC URL.
#[arg(long, short = 'u', value_hint = ValueHint::Url)]
#[arg(short = 'u', long, env="ZERO_BIN_RPC_URL", value_hint = ValueHint::Url)]
rpc_url: Url,
// The node RPC type (jerigon / native).
#[arg(long, short = 't', default_value = "jerigon")]
#[arg(
short = 'T',
long,
env = "ZERO_BIN_RPC_TYPE",
default_value = "jerigon"
)]
rpc_type: RpcType,
/// The start of the block range to prove (inclusive).
#[arg(long, short = 's')]
#[arg(short = 's', long, env = "ZERO_BIN_START_BLOCK")]
start_block: BlockId,
/// The end of the block range to prove (inclusive).
/// If not provided, leader will work in dynamic mode from `start_block`
/// following head of the blockchain.
#[arg(long, short = 'e')]
#[arg(short = 'e', long, env = "ZERO_BIN_END_BLOCK")]
end_block: Option<BlockId>,
/// The checkpoint block.
#[arg(short, long, default_value = "0")]
#[arg(short, long, env = "ZERO_BIN_CHECKPOINT_BLOCK", default_value = "0")]
checkpoint_block: BlockId,
/// The previous proof output.
#[arg(long, short = 'f', value_hint = ValueHint::FilePath)]
#[arg(short = 'f', long, env="ZERO_BIN_PREVIOUS_PROOF", value_hint = ValueHint::FilePath)]
previous_proof: Option<PathBuf>,
/// Blockchain network block time in milliseconds. This value is used
/// to determine the blockchain node polling interval.
#[arg(short, long, env = "ZERO_BIN_BLOCK_TIME", default_value_t = 2000)]
block_time: u64,
/// Backoff in milliseconds for retry requests
#[arg(long, default_value_t = 0)]
#[arg(long, env = "ZERO_BIN_BACKOFF", default_value_t = 0)]
backoff: u64,
/// The maximum number of retries
#[arg(long, default_value_t = 0)]
#[arg(long, env = "ZERO_BIN_MAX_RETRIES", default_value_t = 0)]
max_retries: u32,
},
/// Reads input from HTTP and writes output to a directory.
Http {
/// The port on which to listen.
#[arg(short, long, default_value_t = 8080)]
#[arg(short, long, env = "ZERO_BIN_PORT", default_value_t = 8080)]
port: u16,
/// The directory to which output should be written.
#[arg(short, long, value_hint = ValueHint::DirPath)]
#[arg(short, long, env="ZERO_BIN_OUTPUT_DIR", value_hint = ValueHint::DirPath)]
output_dir: PathBuf,
},
}
17 changes: 11 additions & 6 deletions zero/src/bin/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ struct FetchParams {
#[derive(Args, Clone, Debug)]
struct RpcToolConfig {
/// The RPC URL.
#[arg(short = 'u', long, value_hint = ValueHint::Url)]
#[arg(short = 'u', long, env="ZERO_BIN_RPC_URL", value_hint = ValueHint::Url)]
rpc_url: Url,
/// The RPC Tracer Type.
#[arg(short = 't', long, default_value = "jerigon")]
#[arg(
short = 't',
long,
env = "ZERO_BIN_RPC_TYPE",
default_value = "jerigon"
)]
rpc_type: RpcType,
/// Backoff in milliseconds for retry requests.
#[arg(long, default_value_t = 0)]
#[arg(long, env = "ZERO_BIN_BACKOFF", default_value_t = 0)]
backoff: u64,
/// The maximum number of retries.
#[arg(long, default_value_t = 0)]
#[arg(long, env = "ZERO_BIN_MAX_RETRIES", default_value_t = 0)]
max_retries: u32,
}

Expand All @@ -59,10 +64,10 @@ enum Command {
},
Extract {
/// Transaction hash.
#[arg(long, short)]
#[arg(short, long, env = "ZERO_BIN_TX")]
tx: String,
/// Number of transactions in a batch to process at once.
#[arg(short, long, default_value_t = 1)]
#[arg(short, long, env = "ZERO_BIN_BATCH_SIZE", default_value_t = 1)]
batch_size: usize,
},
}
Expand Down
2 changes: 1 addition & 1 deletion zero/src/bin/trie_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub(crate) struct Cli {
pub(crate) prover_config: CliProverConfig,

/// The previous proof output.
#[arg(long, short = 'f', value_hint = ValueHint::FilePath)]
#[arg(short = 'f', long, env="ZERO_BIN_PREVIOUS_PROOF", value_hint = ValueHint::FilePath)]
previous_proof: Option<PathBuf>,
}

Expand Down
14 changes: 7 additions & 7 deletions zero/src/prover/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ fn get_default_output_path() -> PathBuf {
#[derive(Args, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
pub struct CliProverConfig {
/// The log of the max number of CPU cycles per proof.
#[arg(short, long, help_heading = HELP_HEADING, default_value_t = 19)]
#[arg(short, long, env="ZERO_BIN_MAX_CPU_LEN_LOG", help_heading = HELP_HEADING, default_value_t = 19)]
max_cpu_len_log: usize,
/// Number of transactions in a batch to process at once.
#[arg(short, long, help_heading = HELP_HEADING, default_value_t = 10)]
#[arg(short, long, env="ZERO_BIN_BATCH_SIZE", help_heading = HELP_HEADING, default_value_t = 10)]
batch_size: usize,
/// If true, save the public inputs to disk on error.
#[arg(short='i', long, help_heading = HELP_HEADING, default_value_t = false)]
#[arg(short='i', long, env="ZERO_BIN_SAVE_INPUTS_ON_ERROR", help_heading = HELP_HEADING, default_value_t = false)]
save_inputs_on_error: bool,
/// If true, only test the trace decoder and witness generation without
/// generating a proof.
#[arg(long, help_heading = HELP_HEADING, default_value_t = false)]
#[arg(long, env="ZERO_BIN_TEST_ONLY", help_heading = HELP_HEADING, default_value_t = false)]
test_only: bool,
/// Directory where the generated proofs will be written.
#[arg(long, short = 'o', value_hint = ValueHint::FilePath, default_value = get_default_output_path().into_os_string())]
#[arg(short = 'o', long, env="ZERO_BIN_PROOF_OUTPUT_DIR", value_hint = ValueHint::FilePath, default_value = get_default_output_path().into_os_string())]
proof_output_dir: PathBuf,
/// Keep intermediate proofs. Default action is to
/// delete them after the final proof is generated.
Expand All @@ -41,11 +41,11 @@ pub struct CliProverConfig {
keep_intermediate_proofs: bool,
/// Number of blocks in a batch. For every block batch, the prover will
/// generate one proof file.
#[arg(long, default_value_t = 8)]
#[arg(long, env = "ZERO_BIN_BLOCK_BATCH_SIZE", default_value_t = 8)]
block_batch_size: usize,
/// The maximum number of block proving tasks that can run in parallel. Must
/// be greater than zero.
#[arg(long, default_value_t = 16)]
#[arg(long, env = "ZERO_BIN_BLOCK_POOL_SIZE", default_value_t = 16)]
block_pool_size: usize,
}

Expand Down
Loading