ComputeManager::new accepts batch_size: Some(0) without validation, and start() then panics
inside slice::chunks.
Reproduce
use e3_compute_provider::{ComputeInput, ComputeManager, ComputeProvider, FHEInputs};
struct Dummy;
impl ComputeProvider for Dummy {
type Output = ();
fn prove(&self, _: &ComputeInput) -> Self::Output {}
}
fn processor(_: &FHEInputs) -> Vec<u8> { Vec::new() }
fn main() {
let inputs = FHEInputs { ciphertexts: vec![], params: vec![] };
let mut m = ComputeManager::new(Dummy, inputs, processor, true, Some(0));
println!("constructor accepted batch_size = Some(0)");
let _ = m.start();
}
Output:
constructor accepted batch_size = Some(0)
thread 'main' panicked at crates/compute-provider/src/compute_manager.rs:84:14:
chunk size must be non-zero
Where
ComputeManager::new stores the value as given (src/compute_manager.rs:30-47).
start_parallel resolves it with unwrap_or(2) and passes it straight to chunks (:78, :84),
before any FHE work, so the panic happens on the first parallel run regardless of the input.
Reachability
No caller in this repository hits it. start_parallel has no external call sites, and all three
ComputeManager::new call sites pass use_parallel: false and batch_size: None
(crates/support-scripts/dev/src/main.rs:50, crates/support/host/src/lib.rs:431, :470).
ComputeManager is public API of the published e3-compute-provider crate, and
crates/compute-provider/Readme.md documents both parameters, so a downstream user can reach it.
Note on the documentation
The crate README claimed batch_size "must be a power of 2", which nothing enforced. #1813 corrects
that text to describe the current behaviour. This issue is about the code: whether the constructor
should reject Some(0), and whether the power-of-two constraint the README described was intended
and should be enforced too.
Happy to open a PR once the intended behaviour is settled.
ComputeManager::newacceptsbatch_size: Some(0)without validation, andstart()then panicsinside
slice::chunks.Reproduce
Output:
Where
ComputeManager::newstores the value as given (src/compute_manager.rs:30-47).start_parallelresolves it withunwrap_or(2)and passes it straight tochunks(:78,:84),before any FHE work, so the panic happens on the first parallel run regardless of the input.
Reachability
No caller in this repository hits it.
start_parallelhas no external call sites, and all threeComputeManager::newcall sites passuse_parallel: falseandbatch_size: None(
crates/support-scripts/dev/src/main.rs:50,crates/support/host/src/lib.rs:431,:470).ComputeManageris public API of the publishede3-compute-providercrate, andcrates/compute-provider/Readme.mddocuments both parameters, so a downstream user can reach it.Note on the documentation
The crate README claimed
batch_size"must be a power of 2", which nothing enforced. #1813 correctsthat text to describe the current behaviour. This issue is about the code: whether the constructor
should reject
Some(0), and whether the power-of-two constraint the README described was intendedand should be enforced too.
Happy to open a PR once the intended behaviour is settled.