-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docker_compose storage mod & docker-compose
- Loading branch information
1 parent
c710665
commit 25f6e6d
Showing
10 changed files
with
194 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# image: zkm-prover:latest => https://github.com/zkMIPS/zkm-prover/blob/main/Dockerfile | ||
# image: gnark-plonky2-verifier:latest => https://github.com/zkMIPS/gnark-plonky2-verifier/blob/main/Dockerfile | ||
version: "3.5" | ||
networks: | ||
default: | ||
name: zkm-prover | ||
services: | ||
zkm-stage: | ||
container_name: zkm-stage | ||
restart: unless-stopped | ||
depends_on: | ||
zkm-prover: | ||
condition: service_started | ||
zkm-snark: | ||
condition: service_started | ||
image: zkm-prover:latest | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 4G | ||
reservations: | ||
memory: 256M | ||
ports: | ||
- 50000:50000 | ||
environment: | ||
- RUST_LOG=info | ||
volumes: | ||
- ./service/config/config_docker_compose.toml:/usr/local/bin/config.toml | ||
- /tmp/zkm-prover/data:/zkm/data | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
- "/usr/local/bin/service --config /usr/local/bin/config.toml" | ||
|
||
zkm-prover: | ||
container_name: zkm-prover | ||
restart: unless-stopped | ||
image: zkm-prover:latest | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 400G | ||
reservations: | ||
memory: 256M | ||
environment: | ||
- RUST_LOG=info | ||
volumes: | ||
- ./service/config/config_docker_compose.toml:/usr/local/bin/config.toml | ||
- /tmp/zkm-prover/data:/zkm/data | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
- "/usr/local/bin/service --config /usr/local/bin/config.toml" | ||
|
||
zkm-snark: | ||
container_name: zkm-snark | ||
restart: unless-stopped | ||
image: gnark-plonky2-verifier:latest | ||
volumes: | ||
- /tmp/zkm-prover/data:/zkm/data | ||
command: > | ||
/usr/local/bin/start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
addr = "0.0.0.0:50000" | ||
database_url = "mysql://root:123456@localhost:3306/stage" | ||
prover_addrs = ["127.0.0.1:50001", "127.0.0.1:50002"] | ||
snark_addrs = ["127.0.0.1:50051"] | ||
base_dir = "/tmp/zkm/test/test_proof" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
addr = "0.0.0.0:50000" | ||
database_url = "mysql://root:123456@localhost:3306/stage" | ||
prover_addrs = ["zkm-prover:50000"] | ||
snark_addrs = ["zkm-snark:50051"] | ||
base_dir = "/zkm/data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE DATABASE IF NOT EXISTS stage; | ||
|
||
use stage; | ||
|
||
CREATE TABLE IF NOT EXISTS stage_task | ||
( | ||
id varchar(255) primary key, | ||
status int not null default 0, | ||
context text , | ||
result text , | ||
check_at timestamp not null default now(), | ||
created_at timestamp not null default now(), | ||
updated_at timestamp not null default now() | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS prove_task | ||
( | ||
id varchar(255) not null primary key, | ||
proof_id varchar(255) not null default '', | ||
type int not null default 0, | ||
status int not null default 0, | ||
time_cost int not null default 0, | ||
node_info varchar(255) not null default '', | ||
request text , | ||
response text , | ||
check_at timestamp not null default now(), | ||
created_at timestamp not null default now(), | ||
updated_at timestamp not null default now() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use mysql_async::prelude::*; | ||
|
||
pub struct Storage { | ||
db_pool: mysql_async::Pool, | ||
} | ||
|
||
impl Storage { | ||
pub fn new(database_url: &str) -> Self { | ||
let db_pool = mysql_async::Pool::new(database_url); | ||
Storage { db_pool } | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub async fn insert_stage_task( | ||
&self, | ||
proof_id: &str, | ||
status: i32, | ||
context: &str, | ||
) -> std::result::Result<bool, String> { | ||
let mut conn = self.db_pool.get_conn().await.map_err(|e| (e.to_string()))?; | ||
let stmt = conn | ||
.prep("INSERT INTO stage_task (id, status, context) values (:id, :status, :context)") | ||
.await | ||
.map_err(|e| (e.to_string()))?; | ||
let params = mysql_async::Params::from(vec![ | ||
( | ||
String::from("id"), | ||
mysql_async::Value::Bytes(proof_id.as_bytes().to_vec()), | ||
), | ||
( | ||
String::from("status"), | ||
mysql_async::Value::Int(status as i64), | ||
), | ||
( | ||
String::from("context"), | ||
mysql_async::Value::Bytes(context.as_bytes().to_vec()), | ||
), | ||
]); | ||
let _: std::result::Result<Vec<String>, String> = | ||
conn.exec(stmt, params).await.map_err(|e| (e.to_string())); | ||
Ok(true) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub async fn update_stage_task( | ||
&mut self, | ||
proof_id: &str, | ||
status: i32, | ||
result: &str, | ||
) -> std::result::Result<bool, String> { | ||
let mut conn = self.db_pool.get_conn().await.map_err(|e| (e.to_string()))?; | ||
let stmt = conn | ||
.prep("UPDATE stage_task set status = :status, result = :result where id = :id)") | ||
.await | ||
.map_err(|e| (e.to_string()))?; | ||
let params = mysql_async::Params::from(vec![ | ||
( | ||
String::from("id"), | ||
mysql_async::Value::Bytes(proof_id.as_bytes().to_vec()), | ||
), | ||
( | ||
String::from("status"), | ||
mysql_async::Value::Int(status as i64), | ||
), | ||
( | ||
String::from("result"), | ||
mysql_async::Value::Bytes(result.as_bytes().to_vec()), | ||
), | ||
]); | ||
let _: std::result::Result<Vec<String>, String> = | ||
conn.exec(stmt, params).await.map_err(|e| (e.to_string())); | ||
Ok(true) | ||
} | ||
} |