Skip to content

Commit

Permalink
add worker run modes
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Sep 2, 2024
1 parent ee50295 commit d0b5d83
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
17 changes: 16 additions & 1 deletion zero_bin/leader/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use alloy::transports::http::reqwest::Url;
use clap::{Parser, Subcommand, ValueHint};
use clap::{Parser, Subcommand, ValueEnum, ValueHint};
use prover::cli::CliProverConfig;
use rpc::RpcType;
use zero_bin_common::prover_state::cli::CliProverStateConfig;
Expand All @@ -22,6 +22,21 @@ pub(crate) struct Cli {
// mode.
#[clap(flatten)]
pub(crate) prover_state_config: CliProverStateConfig,

// Mode to use for worker for setup (split or unified)
#[clap(flatten)]
pub(crate) worker_config: WorkerConfig,
}

#[derive(Parser, Clone, PartialEq, Debug)]
pub struct WorkerConfig {
pub run_mode: WorkerRunMode,
}

#[derive(ValueEnum, Clone, PartialEq, Debug)]
pub enum WorkerRunMode {
Split,
Unified,
}

#[derive(Subcommand)]
Expand Down
16 changes: 14 additions & 2 deletions zero_bin/leader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fn get_previous_proof(path: Option<PathBuf>) -> Result<Option<GeneratedBlockProo

const SEGMENT_PROOF_ROUTING_KEY: &str = "segment_proof";
const BLOCK_PROOF_ROUTING_KEY: &str = "block_proof";
const DEFAULT_ROUTING_KEY: &str = "task";

#[tokio::main]
async fn main() -> Result<()> {
Expand All @@ -58,11 +59,22 @@ async fn main() -> Result<()> {

let args = cli::Cli::parse();

let mut block_proof_routing_key = DEFAULT_ROUTING_KEY.to_string();
let mut segment_proof_routing_key = DEFAULT_ROUTING_KEY.to_string();
println!("{:?}", args.worker_config.run_mode);
if args.worker_config.run_mode == cli::WorkerRunMode::Split {
// If we're running in split mode, we need to set the routing key for the
// block proof and segment proof.
info!("Workers running in split mode");
block_proof_routing_key = BLOCK_PROOF_ROUTING_KEY.to_string();
segment_proof_routing_key = SEGMENT_PROOF_ROUTING_KEY.to_string();
}

let mut block_proof_paladin_args = args.paladin.clone();
block_proof_paladin_args.task_bus_routing_key = Some(BLOCK_PROOF_ROUTING_KEY.to_string());
block_proof_paladin_args.task_bus_routing_key = Some(block_proof_routing_key);

let mut segment_proof_paladin_args = args.paladin.clone();
segment_proof_paladin_args.task_bus_routing_key = Some(SEGMENT_PROOF_ROUTING_KEY.to_string());
segment_proof_paladin_args.task_bus_routing_key = Some(segment_proof_routing_key);

let block_proof_runtime = Runtime::from_config(&block_proof_paladin_args, register()).await?;
let segment_proof_runtime =
Expand Down
6 changes: 4 additions & 2 deletions zero_bin/tools/prove_rpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ fi
if [[ $8 == "test_only" ]]; then
# test only run
echo "Proving blocks ${BLOCK_INTERVAL} in a test_only mode now... (Total: ${TOT_BLOCKS})"
command='cargo r --release --bin leader -- --test-only --runtime in-memory --load-strategy on-demand rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" '
# TODO - Change this
command='cargo r --release --bin leader -- --run-mode split --test-only --load-strategy on-demand rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" '
if [ "$OUTPUT_TO_TERMINAL" = true ]; then
eval $command
retVal=$?
Expand All @@ -125,7 +126,8 @@ if [[ $8 == "test_only" ]]; then
else
# normal run
echo "Proving blocks ${BLOCK_INTERVAL} now... (Total: ${TOT_BLOCKS})"
command='cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" '
# TODO - Change this
command='cargo r --release --bin leader -- --run-mode split --load-strategy on-demand rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES"'
if [ "$OUTPUT_TO_TERMINAL" = true ]; then
eval $command
echo -e "Proof generation finished with result: $?"
Expand Down

0 comments on commit d0b5d83

Please sign in to comment.