Skip to content

Commit

Permalink
fix compile and update docker files
Browse files Browse the repository at this point in the history
Signed-off-by: smtmfft <[email protected]>
  • Loading branch information
smtmfft committed Oct 29, 2024
1 parent b5fc207 commit a43a58a
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 71 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM rust:1.75.0 AS builder

ENV DEBIAN_FRONTEND=noninteractive
ARG BUILD_FLAGS=""
ARG TASKDB=${TASKDB:-in-memory}

# risc0 dependencies
# RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash && \
Expand All @@ -10,7 +11,8 @@ ARG BUILD_FLAGS=""

WORKDIR /opt/raiko
COPY . .
RUN cargo build --release ${BUILD_FLAGS} --features "sgx" --features "docker_build"
RUN echo "Building for sgx with taskdb: ${TASKDB}"
RUN cargo build --release ${BUILD_FLAGS} --features "sgx" --features "docker_build" --features ${TASKDB}

FROM gramineproject/gramine:1.7-jammy AS runtime
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.zk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FROM base-builder AS builder

ENV DEBIAN_FRONTEND=noninteractive
ARG BUILD_FLAGS=""
ARG TASKDB=${TASKDB:-in-memory}

WORKDIR /opt/raiko
# build related files
Expand All @@ -58,7 +59,7 @@ RUN make guest
RUN echo "Building for sp1"
ENV TARGET=sp1
RUN make guest
RUN cargo build --release ${BUILD_FLAGS} --features "sp1,risc0" --features "docker_build"
RUN cargo build --release ${BUILD_FLAGS} --features "sp1,risc0" --features "docker_build" --features ${TASKDB}

FROM ubuntu:22.04 AS raiko-zk
RUN mkdir -p \
Expand Down
29 changes: 25 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
context: ..
args:
ENABLE_SELF_REGISTER: "true"
TASKDB: ${TASKDB:-in-memory"}
dockerfile: Dockerfile
image: us-docker.pkg.dev/evmchain/images/raiko:latest
container_name: raiko-init-self-register
Expand All @@ -46,12 +47,15 @@ services:
- HOLESKY_RPC=${HOLESKY_RPC}
- HOLESKY_BEACON_RPC=${HOLESKY_BEACON_RPC}
- TAIKO_A7_RPC=${TAIKO_A7_RPC}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
#- PCCS_HOST=host.docker.internal:8081
depends_on:
- pccs
raiko:
build:
context: ..
args:
TASKDB: ${TASKDB:-in-memory"}
dockerfile: Dockerfile
image: us-docker.pkg.dev/evmchain/images/raiko:latest
container_name: raiko
Expand All @@ -78,17 +82,23 @@ services:
- TAIKO_MAINNET_RPC=${TAIKO_MAINNET_RPC}
- L1_NETWORK=${L1_NETWORK}
- NETWORK=${NETWORK}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
# you can use your own PCCS host
#- PCCS_HOST=host.docker.internal:8081
# use the host's network to connect to the PCCS
#extra_hosts:
# - "host.docker.internal:host-gateway"
# use the host's network to connect to the PCCS
#extra_hosts:
# - "host.docker.internal:host-gateway"
depends_on:
- redis
- pccs
profiles:
- prod-redis
raiko-self-register:
build:
context: ..
dockerfile: Dockerfile
args:
TASKDB: ${TASKDB:-in-memory"}
image: us-docker.pkg.dev/evmchain/images/raiko:latest
container_name: raiko-self-register
command: --config-path=/etc/raiko/config.sgx.json --chain-spec-path=/etc/raiko/chain_spec_list.docker.json
Expand All @@ -115,6 +125,7 @@ services:
- TAIKO_MAINNET_RPC=${TAIKO_MAINNET_RPC}
- L1_NETWORK=${L1_NETWORK}
- NETWORK=${NETWORK}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
# use the host's network to connect to the PCCS
#extra_hosts:
# - "host.docker.internal:host-gateway"
Expand All @@ -124,6 +135,8 @@ services:
build:
context: ..
dockerfile: Dockerfile.zk
args:
TASKDB: ${TASKDB:-in-memory"}
image: us-docker.pkg.dev/evmchain/images/raiko-zk:latest
container_name: raiko-zk
command: --config-path=/etc/raiko/config.sgx.json --chain-spec-path=/etc/raiko/chain_spec_list.docker.json
Expand Down Expand Up @@ -153,6 +166,7 @@ services:
- SKIP_SIMULATION=true
- SP1_VERIFIER_RPC_URL=${SP1_VERIFIER_RPC_URL}
- SP1_VERIFIER_ADDRESS=${SP1_VERIFIER_ADDRESS}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
pccs:
build:
context: ..
Expand All @@ -162,4 +176,11 @@ services:
volumes:
- ${HOME}/.config/sgx-pccs/default.json:/opt/intel/pccs/config/default.json
- ${HOME}/.config/sgx-pccs/file.crt:/opt/intel/pccs/ssl_key/file.crt
- ${HOME}/.config/sgx-pccs/private.pem:/opt/intel/pccs/ssl_key/private.pem
- ${HOME}/.config/sgx-pccs/private.pem:/opt/intel/pccs/ssl_key/private.pem
redis:
image: redis
container_name: redis
ports:
- "6379:6379"
profiles:
- prod-redis
121 changes: 56 additions & 65 deletions taskdb/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod tests {
use rand_chacha::ChaCha8Rng;

use raiko_lib::{input::BlobProofType, primitives::B256};
use raiko_tasks::{get_task_manager, TaskManager, TaskManagerOpts, TaskStatus};
use raiko_tasks::{get_task_manager, TaskDescriptor, TaskManager, TaskManagerOpts, TaskStatus};

fn create_random_task(rng: &mut ChaCha8Rng) -> (u64, B256, ProofRequest) {
let chain_id = 100;
Expand Down Expand Up @@ -127,6 +127,7 @@ mod tests {
.get_task_proving_status(
&(
chain_id,
request.block_number,
blockhash,
request.proof_type,
request.prover.to_string(),
Expand Down Expand Up @@ -160,42 +161,40 @@ mod tests {
.await
.unwrap();
println!("{task_status:?}");
tama.update_task_progress(
(tasks[0].0, tasks[0].1, tasks[0].3, tasks[0].4.to_string()).into(),
TaskStatus::Cancelled_NeverStarted,
None,
let task_0_desc: &TaskDescriptor = &(
tasks[0].0,
tasks[0].2,
tasks[0].1,
tasks[0].3,
tasks[0].4.to_string(),
)
.await
.unwrap();

let task_status = tama
.get_task_proving_status(
&(tasks[0].0, tasks[0].1, tasks[0].3, tasks[0].4.to_string()).into(),
)
.into();
tama.update_task_progress(task_0_desc, TaskStatus::Cancelled_NeverStarted, None)
.await
.unwrap();

let task_status = tama.get_task_proving_status(task_0_desc).await.unwrap();
println!("{task_status:?}");
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::Cancelled_NeverStarted);
assert_eq!(task_status[0].0, TaskStatus::Registered);
}
// -----------------------
{
tama.update_task_progress(
(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
TaskStatus::WorkInProgress,
None,
let task_1_desc = &(
tasks[1].0,
tasks[1].2,
tasks[1].1,
tasks[1].3,
tasks[1].4.to_string(),
)
.await
.unwrap();
.into();
tama.update_task_progress(task_1_desc, TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap();
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
Expand All @@ -204,7 +203,14 @@ mod tests {
std::thread::sleep(Duration::from_millis(1));

tama.update_task_progress(
(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
&(
tasks[0].0,
tasks[0].2,
tasks[0].1,
tasks[0].3,
tasks[0].4.to_string(),
)
.into(),
TaskStatus::CancellationInProgress,
None,
)
Expand All @@ -214,7 +220,14 @@ mod tests {
{
let task_status = tama
.get_task_proving_status(
&(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
&(
tasks[0].0,
tasks[0].2,
tasks[0].1,
tasks[0].3,
tasks[0].4.to_string(),
)
.into(),
)
.await
.unwrap();
Expand All @@ -235,12 +248,7 @@ mod tests {
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap();
assert_eq!(task_status.len(), 4);
assert_eq!(task_status[3].0, TaskStatus::Cancelled);
assert_eq!(task_status[2].0, TaskStatus::CancellationInProgress);
Expand All @@ -251,21 +259,20 @@ mod tests {

// -----------------------
{
tama.update_task_progress(
(tasks[2].0, tasks[2].1, tasks[2].3, tasks[2].4.to_string()).into(),
TaskStatus::WorkInProgress,
None,
let task_2_desc = &(
tasks[2].0,
tasks[2].2,
tasks[2].1,
tasks[2].3,
tasks[2].4.to_string(),
)
.await
.unwrap();
.into();
tama.update_task_progress(task_2_desc, TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[2].0, tasks[2].1, tasks[2].3, tasks[2].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap();
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
Expand All @@ -274,35 +281,19 @@ mod tests {
std::thread::sleep(Duration::from_millis(1));

let proof: Vec<_> = (&mut rng).gen_iter::<u8>().take(128).collect();
tama.update_task_progress(
(tasks[2].0, tasks[2].1, tasks[2].3, tasks[2].4.to_string()).into(),
TaskStatus::Success,
Some(&proof),
)
.await
.unwrap();
tama.update_task_progress(task_2_desc, TaskStatus::Success, Some(&proof))
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[2].0, tasks[2].1, tasks[2].3, tasks[2].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap();
assert_eq!(task_status.len(), 3);
assert_eq!(task_status[2].0, TaskStatus::Success);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
}

assert_eq!(
proof,
tama.get_task_proof(
&(tasks[2].0, tasks[2].1, tasks[2].3, tasks[2].4.to_string()).into()
)
.await
.unwrap()
);
assert_eq!(proof, tama.get_task_proof(task_2_desc,).await.unwrap());
}

// -----------------------
Expand Down

0 comments on commit a43a58a

Please sign in to comment.