Skip to content

Commit

Permalink
add docker-compose & add storage
Browse files Browse the repository at this point in the history
  • Loading branch information
xander42280 committed Apr 4, 2024
1 parent 25f6e6d commit 540665d
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 117 deletions.
12 changes: 0 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions service/examples/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
10 changes: 2 additions & 8 deletions service/proto/src/proto/stage/v1/stage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -47,6 +42,5 @@ message GetStatusRequest {

message GetStatusResponse {
string proof_id = 1;
int32 status = 2;
bytes result = 4;
uint64 status = 2;
}
3 changes: 0 additions & 3 deletions service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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?;
Expand Down
7 changes: 2 additions & 5 deletions service/src/prover_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 1 addition & 11 deletions service/src/prover_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -62,16 +62,6 @@ macro_rules! on_done {
};
}

async fn run_back_task<F: FnOnce() -> 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(
Expand Down
7 changes: 1 addition & 6 deletions service/src/stage_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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,
Expand Down
67 changes: 0 additions & 67 deletions stage/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<Vec<String>>()
.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
)
}
}
2 changes: 0 additions & 2 deletions stage/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 540665d

Please sign in to comment.