From a958849cb515268c7fa855f3ceb4dca5bb616381 Mon Sep 17 00:00:00 2001 From: "Bill.W" <0xbillw@gmail.com> Date: Tue, 6 Feb 2024 02:46:03 +0000 Subject: [PATCH 1/2] fix: the `system.args` not restored correctly --- crates/cestory/src/lib.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/cestory/src/lib.rs b/crates/cestory/src/lib.rs index 60c1a4e3..f9e0f07d 100644 --- a/crates/cestory/src/lib.rs +++ b/crates/cestory/src/lib.rs @@ -14,7 +14,7 @@ use serde::{ Deserialize, Deserializer, Serialize, Serializer, }; -use crate::{light_validation::LightValidation, system::System}; +use crate::light_validation::LightValidation; use anyhow::{anyhow, Context as _, Result}; use ces_crypto::{ aead, @@ -314,6 +314,7 @@ impl Ceseal { if let Some(system) = &mut self.system { system.sealing_path = self.args.sealing_path.clone(); system.storage_path = self.args.storage_path.clone(); + system.args = self.args.clone(); } } @@ -599,14 +600,11 @@ impl Ceseal { let recv_mq = &mut runtime_state.recv_mq; let send_mq = &mut runtime_state.send_mq; let seq = &mut seq; - let mut system: System = - ces_mq::checkpoint_helper::using_dispatcher(recv_mq, move || { - ces_mq::checkpoint_helper::using_send_mq(send_mq, || { - seq.next_element()?.ok_or_else(|| de::Error::custom("Missing System")) - }) - })?; - system.args = factory.args.clone(); - Some(system) + ces_mq::checkpoint_helper::using_dispatcher(recv_mq, move || { + ces_mq::checkpoint_helper::using_send_mq(send_mq, || { + seq.next_element()?.ok_or_else(|| de::Error::custom("Missing System")) + }) + })? }; } else { let _: Option = seq.next_element()?; From 1d697f434e4a4f48aaaa4aee44d7e4a4d633226f Mon Sep 17 00:00:00 2001 From: "Bill.W" <0xbillw@gmail.com> Date: Tue, 6 Feb 2024 02:47:51 +0000 Subject: [PATCH 2/2] fix: potential subtraction overflow --- crates/cestory/src/expert.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cestory/src/expert.rs b/crates/cestory/src/expert.rs index 90dbc3e2..49f1f782 100644 --- a/crates/cestory/src/expert.rs +++ b/crates/cestory/src/expert.rs @@ -76,7 +76,7 @@ pub struct CesealExpertStub { impl CesealExpertStub { pub fn new(ceseal_props: CesealProperties) -> (Self, ExpertCmdReceiver) { let (tx, rx) = mpsc::channel(16); - let thread_pool_cap = std::cmp::max(ceseal_props.cores - 1, 1); + let thread_pool_cap = ceseal_props.cores.saturating_sub(1).max(1); let thread_pool = threadpool::ThreadPool::new(thread_pool_cap as usize); info!("PODR2 compute thread pool capacity: {}", thread_pool.max_count()); let role = ceseal_props.role.clone();