diff --git a/core/src/lib.rs b/core/src/lib.rs index 48064e32..d424568a 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -373,6 +373,7 @@ mod tests { height - 100 } + #[ignore = "public node does not support long distance MPT proof query."] #[tokio::test(flavor = "multi_thread")] async fn test_prove_block_ethereum() { let proof_type = get_proof_type_from_env(); diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2033b16c..a4009cb4 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -167,6 +167,7 @@ services: - SKIP_SIMULATION=true - SP1_VERIFIER_RPC_URL=${SP1_VERIFIER_RPC_URL} - SP1_VERIFIER_ADDRESS=${SP1_VERIFIER_ADDRESS} + - PROVER_NETWORK_RPC=${PROVER_NETWORK_RPC} - REDIS_URL=${REDIS_URL:-redis://redis:6379} depends_on: - redis diff --git a/host/src/lib.rs b/host/src/lib.rs index f4f87a5c..6445d6f2 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -84,6 +84,9 @@ pub struct Opts { #[arg(long, require_equals = true, default_value = "redis://localhost:6379")] pub redis_url: String, + + #[arg(long, require_equals = true, default_value = "3600")] + pub redis_ttl: u64, } impl Opts { @@ -132,6 +135,7 @@ impl From for TaskManagerOpts { sqlite_file: val.sqlite_file, max_db_size: val.max_db_size, redis_url: val.redis_url.to_string(), + redis_ttl: val.redis_ttl, } } } @@ -142,6 +146,7 @@ impl From<&Opts> for TaskManagerOpts { sqlite_file: val.sqlite_file.clone(), max_db_size: val.max_db_size, redis_url: val.redis_url.to_string(), + redis_ttl: val.redis_ttl, } } } diff --git a/taskdb/src/lib.rs b/taskdb/src/lib.rs index 5f735d0a..b83339fa 100644 --- a/taskdb/src/lib.rs +++ b/taskdb/src/lib.rs @@ -233,6 +233,7 @@ pub struct TaskManagerOpts { pub sqlite_file: PathBuf, pub max_db_size: usize, pub redis_url: String, + pub redis_ttl: u64, } #[async_trait::async_trait] @@ -445,6 +446,7 @@ mod test { sqlite_file: sqlite_file.to_path_buf(), max_db_size: 1024 * 1024, redis_url: "redis://localhost:6379".to_string(), + redis_ttl: 3600, }; let mut task_manager = get_task_manager(&opts); diff --git a/taskdb/src/redis_db.rs b/taskdb/src/redis_db.rs index 43151422..518d8ede 100644 --- a/taskdb/src/redis_db.rs +++ b/taskdb/src/redis_db.rs @@ -28,6 +28,7 @@ use crate::{ pub struct RedisTaskDb { conn: Connection, + config: RedisConfig, } pub struct RedisTaskManager { @@ -129,14 +130,18 @@ impl ToRedisArgs for TaskIdDescriptor { } } -// redis key ttl -const TTL_SECS: u64 = 2 * 24 * 3600; // 2 days +#[derive(Debug, Clone, Default)] +pub struct RedisConfig { + url: String, + ttl: u64, +} impl RedisTaskDb { - fn new(url: &str) -> RedisDbResult { + fn new(config: RedisConfig) -> RedisDbResult { + let url = config.url.clone(); let client = Client::open(url).map_err(RedisDbError::RedisDb)?; let conn = client.get_connection().map_err(RedisDbError::RedisDb)?; - Ok(RedisTaskDb { conn }) + Ok(RedisTaskDb { conn, config }) } fn insert_proof_task( @@ -161,7 +166,7 @@ impl RedisTaskDb { V: ToRedisArgs, { self.conn - .set_ex(key, value, TTL_SECS) + .set_ex(key, value, self.config.ttl) .map_err(RedisDbError::RedisDb)?; Ok(()) } @@ -272,7 +277,7 @@ impl RedisTaskDb { } fn update_status_redis(&mut self, k: &String, v: &String) -> RedisDbResult<()> { - self.conn.set_ex(k, v, TTL_SECS)?; + self.conn.set_ex(k, v, self.config.ttl)?; Ok(()) } } @@ -553,7 +558,11 @@ impl TaskManager for RedisTaskManager { INIT.call_once(|| { unsafe { CONN = Some(Arc::new(Mutex::new({ - let db = RedisTaskDb::new(&opts.redis_url).unwrap(); + let db = RedisTaskDb::new(RedisConfig { + url: opts.redis_url.clone(), + ttl: opts.redis_ttl.clone(), + }) + .unwrap(); db }))) }; diff --git a/taskdb/tests/main.rs b/taskdb/tests/main.rs index 79f165ed..061ee1f4 100644 --- a/taskdb/tests/main.rs +++ b/taskdb/tests/main.rs @@ -68,6 +68,7 @@ mod tests { sqlite_file: file, max_db_size: 1_000_000, redis_url: env::var("REDIS_URL").unwrap_or_default(), + redis_ttl: 3600, }); let (chain_id, blockhash, request) = @@ -106,6 +107,7 @@ mod tests { sqlite_file: file, max_db_size: 1_000_000, redis_url: env::var("REDIS_URL").unwrap_or_default(), + redis_ttl: 3600, }); let mut rng = ChaCha8Rng::seed_from_u64(123);