Feature/20 rayon parallelism#23
Conversation
🤖 Augment PR SummarySummary: Adds an optional Rayon-based parallel execution path for WOTS+ chain-segment computation while keeping outputs deterministic and RFC-compatible. Changes:
Technical Notes: Parallelism is limited to independent outer segments; internal per-chain hashing remains sequential, and ordering is preserved by collecting from Rayon’s indexed iterators. 🤖 Was this summary useful? React with 👍 or 👎 |
|
|
||
| #[cfg(feature = "parallel")] | ||
| use rayon::prelude::*; | ||
| use std::time::Instant; |
There was a problem hiding this comment.
use std::time::Instant; is in the main library module but only used in the test module, which can break cargo build-sbf/no-std-ish Solana builds (and also creates an unused-import warning in non-test builds). Consider gating it with #[cfg(test)] or moving it into the tests module.
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| { | ||
| let Self::Array { buf, len } = self; | ||
| let end = *len + data.len(); | ||
| buf[*len..end].copy_from_slice(data); |
There was a problem hiding this comment.
In the non-solana SignatureBuffer::push_slice branch, an overflow will panic via slice indexing rather than an explicit invariant check, so the failure mode/message is much less clear than the solana branch. Consider adding an explicit length bound check here as well so callers get a predictable panic reason.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| [dependencies] | ||
| rayon = { version = "1.8", optional = true } | ||
| sha3 = "0.10" |
There was a problem hiding this comment.
sha3 is listed under [dependencies] but appears to be used only from #[cfg(test)] code, so it will be pulled into all downstream builds (including the Solana program). Consider moving it to [dev-dependencies] (or gating it) to avoid inflating the dependency graph for library consumers.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| [features] | ||
| default = ["solana"] | ||
| solana = [] | ||
| parallel = ["rayon"] No newline at end of file |
There was a problem hiding this comment.
With default = ["solana"], it’s possible to enable --features parallel alongside solana, but Rayon/threaded parallelism typically won’t work for Solana SBF/BPF targets. Consider documenting or preventing this incompatible feature combination so consumers don’t accidentally break on-chain builds.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| fn keccak256_hash(data: &[u8]) -> [u8; 32] { | ||
| let mut hasher = Keccak256::new(); | ||
| hasher.update(data); |
There was a problem hiding this comment.
Reiterate the init_var for calling upon instantiation of the var
Summary
This MR introduces an optional parallel feature using Rayon to enable parallel computation of WOTS+ chain segments while preserving deterministic ordering and RFC-compatible behavior.
Changes
+ par_iter().map().collect()
Security & Correctness Notes
Testing
Tested with:
All tests pass in both sequential and parallel modes.