Skip to content

Commit

Permalink
feat(raiko): init redis impl
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft committed Oct 17, 2024
1 parent 8f55ae4 commit 1b67b7a
Show file tree
Hide file tree
Showing 8 changed files with 1,696 additions and 763 deletions.
1,857 changes: 1,100 additions & 757 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
"provers/sgx/setup",
"pipeline",
"core",
"tasks",
"taskdb",
]

# Always optimize; building and running the guest takes much longer without optimization.
Expand All @@ -36,7 +36,7 @@ opt-level = 3
# raiko
raiko-lib = { path = "./lib", features = ["std"] }
raiko-core = { path = "./core" }
raiko-tasks = { path = "./tasks" }
raiko-tasks = { path = "./taskdb" }

# reth
reth-primitives = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false, features = [
Expand Down Expand Up @@ -165,6 +165,9 @@ thiserror-no-std = "2.0.2"
# SQLite
rusqlite = { version = "0.31.0", features = ["bundled"] }

# redis
redis = { version = "0.27.0" }

# misc
hashbrown = { version = "0.14", features = ["inline-more"] }
tempfile = "3.8"
Expand Down
9 changes: 6 additions & 3 deletions tasks/Cargo.toml → taskdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
name = "raiko-tasks"
version = "0.1.0"
authors = ["Taiko Labs"]
edition = "2021"
edition = "2021"

[dependencies]
raiko-lib = { workspace = true }
raiko-core = { workspace = true }
rusqlite = { workspace = true, features = ["chrono"] }
rusqlite = { workspace = true, features = ["chrono"], optional = true }
num_enum = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
thiserror = { workspace = true }
Expand All @@ -19,6 +19,7 @@ anyhow = { workspace = true }
tokio = { workspace = true }
async-trait = { workspace = true }
utoipa = { workspace = true }
redis = { workspace = true, optional = true }

[dev-dependencies]
rand = "0.9.0-alpha.1" # This is an alpha version, that has rng.gen_iter::<T>()
Expand All @@ -29,8 +30,10 @@ rusqlite = { workspace = true, features = ["trace"] }

[features]
default = ["in-memory"]
sqlite = []
sqlite = ["rusqlite"]
in-memory = []
redis-db = ["redis"]


[[test]]
name = "tasks_tests"
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion tasks/src/lib.rs → taskdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ use crate::{adv_sqlite::SqliteTaskManager, mem_db::InMemoryTaskManager};

mod adv_sqlite;
mod mem_db;
mod redis;

// Types
// ----------------------------------------------------------------
#[derive(PartialEq, Debug, thiserror::Error)]
#[derive(Debug, thiserror::Error)]
pub enum TaskManagerError {
#[error("IO Error {0}")]
IOError(IOErrorKind),
#[error("SQL Error {0}")]
SqlError(String),
#[error("Redis Error {0}")]
RedisError(#[from] crate::redis::RedisDbError),
#[error("No data for query")]
NoData,
#[error("Anyhow error: {0}")]
Expand Down Expand Up @@ -183,6 +186,7 @@ pub type TaskReport = (TaskDescriptor, TaskStatus);
pub struct TaskManagerOpts {
pub sqlite_file: PathBuf,
pub max_db_size: usize,
pub redis_url: String,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -465,6 +469,7 @@ mod test {
let opts = TaskManagerOpts {
sqlite_file: sqlite_file.to_path_buf(),
max_db_size: 1024 * 1024,
redis_url: "redis://localhost:6379".to_string(),
};
let mut task_manager = get_task_manager(&opts);

Expand Down
File renamed without changes.
Loading

0 comments on commit 1b67b7a

Please sign in to comment.