diff --git a/docker-compose.yml b/docker-compose.yml index 82758f0..e56edaf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,12 +14,6 @@ services: zkm-snark: condition: service_started image: zkm-prover:latest - deploy: - resources: - limits: - memory: 4G - reservations: - memory: 256M ports: - 50000:50000 environment: @@ -36,12 +30,6 @@ services: container_name: zkm-prover restart: unless-stopped image: zkm-prover:latest - deploy: - resources: - limits: - memory: 400G - reservations: - memory: 256M environment: - RUST_LOG=info volumes: diff --git a/service/examples/stage.rs b/service/examples/stage.rs index 277b1e8..5b533e8 100644 --- a/service/examples/stage.rs +++ b/service/examples/stage.rs @@ -7,9 +7,6 @@ use std::path::Path; use std::time::Instant; use tonic::transport::ClientTlsConfig; use tonic::transport::Endpoint; - -use std::time::{Instant, Duration}; - pub mod stage_service { tonic::include_proto!("stage.v1"); } diff --git a/service/proto/src/proto/stage/v1/stage.proto b/service/proto/src/proto/stage/v1/stage.proto index ca8628c..44325d1 100644 --- a/service/proto/src/proto/stage/v1/stage.proto +++ b/service/proto/src/proto/stage/v1/stage.proto @@ -19,11 +19,6 @@ message BlockFileItem { bytes file_content = 2; } -message BlockFileItem { - string file_name = 1; - bytes file_content = 2; -} - message GenerateProofRequest { uint64 chain_id = 1; uint64 timestamp = 2; @@ -35,7 +30,7 @@ message GenerateProofRequest { } message GenerateProofResponse { - int32 status = 1; + uint32 executor_error = 1; string error_message = 2; string proof_id = 3; bytes result = 4; @@ -47,6 +42,5 @@ message GetStatusRequest { message GetStatusResponse { string proof_id = 1; - int32 status = 2; - bytes result = 4; + uint64 status = 2; } \ No newline at end of file diff --git a/service/src/main.rs b/service/src/main.rs index 7b581d3..6a84638 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -37,9 +37,6 @@ async fn main() -> Result<(), Box> { for node in &runtime_config.snark_addrs { nodes_data.add_snark_node(ProverNode::new(node)); } - for node in runtime_config.snark_addrs { - nodes_data.add_snark_node(ProverNode::new(&node)); - } } let prover = prover_service::ProverServiceSVC::default(); let stage = stage_service::StageServiceSVC::new(runtime_config.clone()).await?; diff --git a/service/src/prover_client.rs b/service/src/prover_client.rs index 5c2a165..e53d759 100644 --- a/service/src/prover_client.rs +++ b/service/src/prover_client.rs @@ -203,9 +203,6 @@ pub async fn aggregate_all( return Some(agg_all_task); } } - agg_task.state = TASK_STATE_FAILED; - } else { - agg_task.state = TASK_STATE_UNPROCESSED; } tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; Some(agg_all_task) @@ -253,9 +250,9 @@ pub async fn final_proof( } } } - agg_all_task.state = TASK_STATE_FAILED; + final_task.state = TASK_STATE_FAILED; } else { - agg_all_task.state = TASK_STATE_UNPROCESSED; + final_task.state = TASK_STATE_UNPROCESSED; } tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; Some(final_task) diff --git a/service/src/prover_service.rs b/service/src/prover_service.rs index 64a51b7..629269b 100644 --- a/service/src/prover_service.rs +++ b/service/src/prover_service.rs @@ -11,7 +11,7 @@ use prover_service::{ProveRequest, ProveResponse}; use prover_service::{SplitElfRequest, SplitElfResponse}; use std::time::Instant; -use tonic::{Request, Response, Status}; +use tonic::{Request, Response, Status}; use self::prover_service::ResultCode; #[allow(clippy::module_inception)] @@ -62,16 +62,6 @@ macro_rules! on_done { }; } -async fn run_back_task bool + Send + 'static> (callable: F) -> bool { - let rt = tokio::runtime::Handle::current(); - let (tx, rx) = tokio::sync::oneshot::channel(); - let _ = rt.spawn_blocking(move || { - let result = callable(); - tx.send(result).unwrap(); - }).await; - rx.await.unwrap() -} - #[tonic::async_trait] impl ProverService for ProverServiceSVC { async fn get_status( diff --git a/service/src/stage_service.rs b/service/src/stage_service.rs index d1adefe..c15ce31 100644 --- a/service/src/stage_service.rs +++ b/service/src/stage_service.rs @@ -70,7 +70,7 @@ impl StageService for StageServiceSVC { ..Default::default() }; if let Some(status) = status { - response.status = *status as i32; + response.status = *status as u64; } Ok(Response::new(response)) } @@ -136,11 +136,6 @@ impl StageService for StageServiceSVC { ); } - { - let mut taskmap = GLOBAL_TASKMAP.lock().unwrap(); - taskmap.insert(request.get_ref().proof_id.clone(), stage_service::ExecutorError::Unspecified.into()); - } - let generate_context = stage::contexts::GenerateContext::new( &request.get_ref().proof_id, &dir_path, diff --git a/stage/src/stage.rs b/stage/src/stage.rs index 5c9cfe7..a13a700 100644 --- a/stage/src/stage.rs +++ b/stage/src/stage.rs @@ -27,15 +27,6 @@ pub fn get_timestamp() -> u64 { duration_since_epoch.as_secs() } -pub fn copy_file_bin(src: &String, dst: &String) { - let mut file_src = File::open(src).unwrap(); - let mut content = Vec::new(); - file_src.read_to_end(&mut content).unwrap(); - - let mut file_dst = File::open(dst).unwrap(); - file_dst.write_all(content.as_slice()).unwrap(); -} - pub struct Stage { pub generate_context: GenerateContext, pub split_task: SplitTask, @@ -76,30 +67,6 @@ macro_rules! get_task { }; } -macro_rules! on_task { - ($src:ident, $dst:ident) => { - assert!($src.proof_id == $dst.proof_id); - if $src.state == TASK_STATE_FAILED || $src.state == TASK_STATE_SUCCESS || $src.state == TASK_STATE_UNPROCESSED{ - $dst.state = $src.state; - if TASK_STATE_UNPROCESSED != $src.state { - log::info!("on_task {:#?}", $dst); - } - } - }; -} - -macro_rules! get_task { - ($src:ident) => { - if $src.state == TASK_STATE_UNPROCESSED || - $src.state == TASK_STATE_FAILED { - $src.state = TASK_STATE_PROCESSING; - return Some($src.clone()); - } - return None - }; -} - - impl Stage { pub fn new(generate_context: GenerateContext) -> Self { Stage { @@ -322,38 +289,4 @@ impl Stage { self.generate_context.proof_id, split_cost, root_prove_cost, agg_all_cost, final_cost ) } - - pub fn timecost_string(&self) -> String { - let split_cost = format!( - "split_id: {} cost: {} sec", - self.split_task.task_id, - self.split_task.finish_ts - self.split_task.start_ts - ); - let root_prove_cost = self - .prove_tasks - .iter() - .map(|task| { - format!( - "prove_id: {} cost: {} sec", - task.task_id, - task.finish_ts - task.start_ts - ) - }) - .collect::>() - .join("\r\n"); - let agg_all_cost = format!( - "agg_all_id: {} cost: {} sec", - self.agg_all_task.task_id, - self.agg_all_task.finish_ts - self.agg_all_task.start_ts - ); - let final_cost = format!( - "final_id: {} cost: {} sec", - self.final_task.task_id, - self.final_task.finish_ts - self.final_task.start_ts - ); - format!( - "proof_id: {}\r\n{}\r\n{}\r\n{}\r\n{}\r\n", - self.generate_context.proof_id, split_cost, root_prove_cost, agg_all_cost, final_cost - ) - } } diff --git a/stage/src/tasks/mod.rs b/stage/src/tasks/mod.rs index f6784f4..085c593 100644 --- a/stage/src/tasks/mod.rs +++ b/stage/src/tasks/mod.rs @@ -6,8 +6,6 @@ pub const TASK_STATE_FAILED: u32 = 4; pub const TASK_TIMEOUT: u64 = 7200; -pub const TASK_TIMEOUT :u64 = 3600; - pub mod split_task; pub use split_task::SplitTask;