Skip to content

Commit

Permalink
Assign specific jobs to dedicated workers (#564)
Browse files Browse the repository at this point in the history
* separate workers

* fix review comments

* add worker run modes

* change default queue

* update cargo.lock

* fix review comments

* testing changes

* separate segment proof and segment agg proof

* review comments

* fix review comments

* Update zero/src/bin/leader/cli.rs

Co-authored-by: Robin Salen <[email protected]>

* update paladin version

---------

Co-authored-by: Ben <[email protected]>
Co-authored-by: Robin Salen <[email protected]>
  • Loading branch information
3 people authored and einar-polygon committed Oct 21, 2024
1 parent d1e6efa commit a85080d
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 96 deletions.
97 changes: 44 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ num-bigint = "0.4.5"
num-traits = "0.2.19"
nunny = "0.2.1"
once_cell = "1.19.0"
paladin-core = "0.4.2"
paladin-core = "0.4.3"
parking_lot = "0.12.3"
paste = "1.0.15"
pest = "2.7.10"
Expand Down
41 changes: 36 additions & 5 deletions zero/src/bin/leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use anyhow::Result;
use clap::Parser;
use cli::Command;
use client::RpcParams;
use paladin::config::Config;
use paladin::runtime::Runtime;
use tracing::info;
use zero::env::load_dotenvy_vars_if_present;
use zero::prover::ProverConfig;
use zero::prover::{ProofRuntime, ProverConfig};
use zero::{
block_interval::BlockInterval, prover_state::persistence::set_circuit_cache_dir_env_if_not_set,
};
Expand All @@ -24,6 +25,10 @@ mod leader {
pub mod stdio;
}

const HEAVY_PROOF_ROUTING_KEY: &str = "heavy-proof";
const LIGHT_PROOF_ROUTING_KEY: &str = "light-proof";
const DEFAULT_ROUTING_KEY: &str = paladin::runtime::DEFAULT_ROUTING_KEY;

#[tokio::main]
async fn main() -> Result<()> {
load_dotenvy_vars_if_present();
Expand All @@ -36,7 +41,33 @@ async fn main() -> Result<()> {
return zero::prover_state::persistence::delete_all();
}

let runtime = Arc::new(Runtime::from_config(&args.paladin, register()).await?);
let mut light_proof_routing_key = DEFAULT_ROUTING_KEY.to_string();
let mut heavy_proof_routing_key = DEFAULT_ROUTING_KEY.to_string();
if args.worker_run_mode == cli::WorkerRunMode::Affinity {
// If we're running in affinity mode, we need to set the routing key for the
// heavy proof and light proof.
info!("Workers running in affinity mode");
light_proof_routing_key = LIGHT_PROOF_ROUTING_KEY.to_string();
heavy_proof_routing_key = HEAVY_PROOF_ROUTING_KEY.to_string();
}

let light_proof_paladin_args = Config {
task_bus_routing_key: Some(light_proof_routing_key),
..args.paladin.clone()
};

let heavy_proof_paladin_args = Config {
task_bus_routing_key: Some(heavy_proof_routing_key),
..args.paladin
};

let light_proof = Runtime::from_config(&light_proof_paladin_args, register()).await?;
let heavy_proof = Runtime::from_config(&heavy_proof_paladin_args, register()).await?;

let proof_runtime = Arc::new(ProofRuntime {
light_proof,
heavy_proof,
});
let prover_config: ProverConfig = args.prover_config.into();
if prover_config.block_pool_size == 0 {
panic!("block-pool-size must be greater than 0");
Expand All @@ -55,7 +86,7 @@ async fn main() -> Result<()> {
match args.command {
Command::Stdio { previous_proof } => {
let previous_proof = get_previous_proof(previous_proof)?;
stdio::stdio_main(runtime, previous_proof, Arc::new(prover_config)).await?;
stdio::stdio_main(proof_runtime, previous_proof, Arc::new(prover_config)).await?;
}
Command::Http { port, output_dir } => {
// check if output_dir exists, is a directory, and is writable
Expand All @@ -67,7 +98,7 @@ async fn main() -> Result<()> {
panic!("output-dir is not a writable directory");
}

http::http_main(runtime, port, output_dir, Arc::new(prover_config)).await?;
http::http_main(proof_runtime, port, output_dir, Arc::new(prover_config)).await?;
}
Command::Rpc {
rpc_url,
Expand All @@ -86,7 +117,7 @@ async fn main() -> Result<()> {

info!("Proving interval {block_interval}");
client_main(
runtime,
proof_runtime,
RpcParams {
rpc_url,
rpc_type,
Expand Down
Loading

0 comments on commit a85080d

Please sign in to comment.