Skip to content

Commit

Permalink
chore: remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
keroro520 committed Feb 11, 2025
1 parent 0c7f20f commit ae4f69e
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 2,365 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci-build-test-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
version_toolchain:
type: string
required: true
taskdb:
type: string
required: true

env:
CI: 1
Expand All @@ -34,11 +31,6 @@ jobs:
with:
submodules: recursive

- name: taskdb check
if: ${{ inputs.taskdb != '' }}
run: |
echo "TASKDB=${{ inputs.taskdb }}" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.version_toolchain }}
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/ci-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
version_toolchain:
type: string
required: true
taskdb:
type: string
required: true


env:
Expand All @@ -36,11 +33,6 @@ jobs:
with:
submodules: recursive

- name: taskdb check
if: ${{ inputs.taskdb != '' }}
run: |
echo "TASKDB=${{ inputs.taskdb }}" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.version_toolchain }}
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/ci-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,18 @@ name: CI - Native
on:
workflow_call:
pull_request:
paths:
- "taskdb/**"

jobs:
set-taskdb:
runs-on: ubuntu-latest
outputs:
taskdb: ${{ steps.check_file.outputs.taskdb }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check if specific file changed
id: check_file
run: |
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
if git diff --name-only origin/$BASE_BRANCH ${{ github.sha }} | grep -q "taskdb/src/redis_db.rs"; then
echo "redis changed"
echo "::set-output name=taskdb::raiko-tasks/redis-db"
else
echo "redis unchanged"
echo "::set-output name=taskdb::"
fi
build-test-native:
name: Build and test native
needs: set-taskdb
uses: ./.github/workflows/ci-build-test-reusable.yml
with:
version_name: "native"
version_toolchain: "nightly-2024-04-17"
taskdb: ${{ needs.set-taskdb.outputs.taskdb }}

integration-test-native:
name: Run integration tests on native
needs: set-taskdb
uses: ./.github/workflows/ci-integration-reusable.yml
with:
version_name: "native"
version_toolchain: "nightly-2024-04-17"
taskdb: ${{ needs.set-taskdb.outputs.taskdb }}
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM rust:1.81.0 AS builder

ENV DEBIAN_FRONTEND=noninteractive
ARG BUILD_FLAGS=""
ARG TASKDB=${TASKDB:-raiko-tasks/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 @@ -11,8 +10,7 @@ ARG TASKDB=${TASKDB:-raiko-tasks/in-memory}

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

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

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

WORKDIR /opt/raiko
# build related files
Expand Down Expand Up @@ -63,7 +62,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" --features ${TASKDB}
RUN cargo build --release ${BUILD_FLAGS} --features "sp1,risc0" --features "docker_build"

FROM ubuntu:22.04 AS raiko-zk
RUN mkdir -p \
Expand Down
7 changes: 0 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ services:
context: ..
args:
ENABLE_SELF_REGISTER: "true"
TASKDB: ${TASKDB:-raiko-tasks/in-memory}
dockerfile: Dockerfile
image: us-docker.pkg.dev/evmchain/images/raiko:latest
container_name: raiko-init-self-register
Expand Down Expand Up @@ -54,8 +53,6 @@ services:
raiko:
build:
context: ..
args:
TASKDB: ${TASKDB:-raiko-tasks/in-memory}
dockerfile: Dockerfile
image: us-docker.pkg.dev/evmchain/images/raiko:latest
container_name: raiko
Expand Down Expand Up @@ -98,8 +95,6 @@ services:
build:
context: ..
dockerfile: Dockerfile
args:
TASKDB: ${TASKDB:-raiko-tasks/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 Down Expand Up @@ -136,8 +131,6 @@ services:
build:
context: ..
dockerfile: Dockerfile.zk
args:
TASKDB: ${TASKDB:-raiko-tasks/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
9 changes: 1 addition & 8 deletions host/src/interfaces.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axum::response::IntoResponse;
use raiko_lib::proof_type::ProofType;
use raiko_lib::prover::ProverError;
use raiko_tasks::{TaskManagerError, TaskStatus};
use raiko_tasks::TaskStatus;
use tokio::sync::mpsc::error::TrySendError;
use utoipa::ToSchema;

Expand Down Expand Up @@ -69,10 +69,6 @@ pub enum HostError {
#[schema(value_type = Value)]
Anyhow(#[from] anyhow::Error),

/// For task manager errors.
#[error("There was an error with the task manager: {0}")]
TaskManager(#[from] TaskManagerError),

/// For system paused state.
#[error("System is paused")]
SystemPaused,
Expand All @@ -91,7 +87,6 @@ impl IntoResponse for HostError {
HostError::Guest(e) => ("guest_error", e.to_string()),
HostError::Core(e) => ("core_error", e.to_string()),
HostError::FeatureNotSupportedError(e) => ("feature_not_supported", e.to_string()),
HostError::TaskManager(e) => ("task_manager", e.to_string()),
HostError::Anyhow(e) => ("anyhow_error", e.to_string()),
HostError::HandleDropped => ("handle_dropped", "".to_owned()),
HostError::CapacityFull => ("capacity_full", "".to_owned()),
Expand Down Expand Up @@ -134,7 +129,6 @@ impl From<HostError> for TaskStatus {
HostError::Io(e) => TaskStatus::IoFailure(e.to_string()),
HostError::RPC(e) => TaskStatus::NetworkFailure(e.to_string()),
HostError::Guest(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::TaskManager(e) => TaskStatus::TaskDbCorruption(e.to_string()),
HostError::SystemPaused => TaskStatus::SystemPaused,
}
}
Expand All @@ -156,7 +150,6 @@ impl From<&HostError> for TaskStatus {
HostError::Io(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::RPC(e) => TaskStatus::NetworkFailure(e.to_string()),
HostError::Guest(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::TaskManager(e) => TaskStatus::TaskDbCorruption(e.to_string()),
HostError::SystemPaused => TaskStatus::SystemPaused,
}
}
Expand Down
119 changes: 3 additions & 116 deletions host/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::{alloc, path::PathBuf};

use anyhow::Context;
use cap::Cap;
use clap::Parser;
use raiko_core::{
interfaces::{AggregationOnlyRequest, ProofRequest, ProofRequestOpt},
merge,
};
use raiko_core::{interfaces::ProofRequestOpt, merge};
use raiko_lib::consts::SupportedChainSpecs;
use raiko_tasks::{get_task_manager, ProofTaskDescriptor, TaskManagerOpts, TaskManagerWrapperImpl};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use tokio::sync::mpsc;

use crate::{interfaces::HostResult, proof::ProofActor};
use crate::interfaces::HostResult;

pub mod cache;
pub mod interfaces;
pub mod metrics;
pub mod proof;
pub mod server;

#[derive(Default, Clone, Serialize, Deserialize, Debug, Parser)]
Expand Down Expand Up @@ -131,112 +123,6 @@ impl Opts {
}
}

impl From<Opts> for TaskManagerOpts {
fn from(val: Opts) -> Self {
Self {
max_db_size: val.max_db_size,
redis_url: val.redis_url.to_string(),
redis_ttl: val.redis_ttl,
}
}
}

impl From<&Opts> for TaskManagerOpts {
fn from(val: &Opts) -> Self {
Self {
max_db_size: val.max_db_size,
redis_url: val.redis_url.to_string(),
redis_ttl: val.redis_ttl,
}
}
}

#[derive(Debug, Clone)]
pub struct ProverState {
pub opts: Opts,
pub chain_specs: SupportedChainSpecs,
pub task_channel: mpsc::Sender<Message>,
pause_flag: Arc<AtomicBool>,
}

#[derive(Debug)]
pub enum Message {
Cancel(ProofTaskDescriptor),
Task(ProofRequest),
TaskComplete(ProofRequest),
CancelAggregate(AggregationOnlyRequest),
Aggregate(AggregationOnlyRequest),
SystemPause(tokio::sync::oneshot::Sender<HostResult<()>>),
}

impl ProverState {
pub fn init() -> HostResult<Self> {
let opts = parse_opts()?;
Self::init_with_opts(opts)
}

pub fn init_with_opts(opts: Opts) -> HostResult<Self> {
// Check if the cache path exists and create it if it doesn't.
if let Some(cache_path) = &opts.cache_path {
if !cache_path.exists() {
std::fs::create_dir_all(cache_path).context("Could not create cache dir")?;
}
}

let (task_channel, receiver) = mpsc::channel::<Message>(opts.concurrency_limit);
let pause_flag = Arc::new(AtomicBool::new(false));

let opts_clone = opts.clone();
let chain_specs = parse_chain_specs(&opts);
let chain_specs_clone = chain_specs.clone();
let sender = task_channel.clone();
tokio::spawn(async move {
ProofActor::new(sender, receiver, opts_clone, chain_specs_clone)
.run()
.await;
});

Ok(Self {
opts,
chain_specs,
task_channel,
pause_flag,
})
}

pub fn task_manager(&self) -> TaskManagerWrapperImpl {
get_task_manager(&(&self.opts).into())
}

pub fn request_config(&self) -> ProofRequestOpt {
self.opts.proof_request_opt.clone()
}

pub fn is_paused(&self) -> bool {
self.pause_flag.load(Ordering::SeqCst)
}

/// Set the pause flag and notify the task manager to pause, then wait for the task manager to
/// finish the pause process.
///
/// Note that this function is blocking until the task manager finishes the pause process.
pub async fn set_pause(&self, paused: bool) -> HostResult<()> {
self.pause_flag.store(paused, Ordering::SeqCst);
if paused {
// Notify task manager to start pause process
let (sender, receiver) = tokio::sync::oneshot::channel();
self.task_channel
.try_send(Message::SystemPause(sender))
.context("Failed to send pause message")?;

// Wait for the pause message to be processed
let result = receiver.await.context("Failed to receive pause message")?;
return result;
}
Ok(())
}
}

pub fn parse_opts() -> HostResult<Opts> {
// Read the command line arguments;
let mut opts = Opts::parse();
Expand All @@ -259,6 +145,7 @@ pub fn parse_chain_specs(opts: &Opts) -> SupportedChainSpecs {
#[global_allocator]
static ALLOCATOR: Cap<alloc::System> = Cap::new(alloc::System, usize::MAX);

#[allow(unused)]
mod memory {
use tracing::debug;

Expand Down
Loading

0 comments on commit ae4f69e

Please # to comment.