mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 01:07:57 +00:00
Use CPU clock timeout for PVF jobs (#6282)
* Put in skeleton logic for CPU-time-preparation Still needed: - Flesh out logic - Refactor some spots - Tests * Continue filling in logic for prepare worker CPU time changes * Fix compiler errors * Update lenience factor * Fix some clippy lints for PVF module * Fix compilation errors * Address some review comments * Add logging * Add another log * Address some review comments; change Mutex to AtomicBool * Refactor handling response bytes * Add CPU clock timeout logic for execute jobs * Properly handle AtomicBool flag * Use `Ordering::Relaxed` * Refactor thread coordination logic * Fix bug * Add some timing information to execute tests * Add section about the mitigation to the IG * minor: Change more `Ordering`s to `Relaxed` * candidate-validation: Fix build errors
This commit is contained in:
@@ -638,7 +638,7 @@ trait ValidationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
async fn precheck_pvf(&mut self, pvf: Pvf) -> Result<(), PrepareError>;
|
||||
async fn precheck_pvf(&mut self, pvf: Pvf) -> Result<Duration, PrepareError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -664,7 +664,7 @@ impl ValidationBackend for ValidationHost {
|
||||
.map_err(|_| ValidationError::InternalError("validation was cancelled".into()))?
|
||||
}
|
||||
|
||||
async fn precheck_pvf(&mut self, pvf: Pvf) -> Result<(), PrepareError> {
|
||||
async fn precheck_pvf(&mut self, pvf: Pvf) -> Result<Duration, PrepareError> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
if let Err(_) = self.precheck_pvf(pvf, tx).await {
|
||||
return Err(PrepareError::DidNotMakeIt)
|
||||
|
||||
@@ -377,7 +377,7 @@ impl ValidationBackend for MockValidateCandidateBackend {
|
||||
result
|
||||
}
|
||||
|
||||
async fn precheck_pvf(&mut self, _pvf: Pvf) -> Result<(), PrepareError> {
|
||||
async fn precheck_pvf(&mut self, _pvf: Pvf) -> Result<Duration, PrepareError> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
@@ -894,11 +894,11 @@ fn pov_decompression_failure_is_invalid() {
|
||||
}
|
||||
|
||||
struct MockPreCheckBackend {
|
||||
result: Result<(), PrepareError>,
|
||||
result: Result<Duration, PrepareError>,
|
||||
}
|
||||
|
||||
impl MockPreCheckBackend {
|
||||
fn with_hardcoded_result(result: Result<(), PrepareError>) -> Self {
|
||||
fn with_hardcoded_result(result: Result<Duration, PrepareError>) -> Self {
|
||||
Self { result }
|
||||
}
|
||||
}
|
||||
@@ -914,7 +914,7 @@ impl ValidationBackend for MockPreCheckBackend {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
async fn precheck_pvf(&mut self, _pvf: Pvf) -> Result<(), PrepareError> {
|
||||
async fn precheck_pvf(&mut self, _pvf: Pvf) -> Result<Duration, PrepareError> {
|
||||
self.result.clone()
|
||||
}
|
||||
}
|
||||
@@ -931,7 +931,7 @@ fn precheck_works() {
|
||||
|
||||
let (check_fut, check_result) = precheck_pvf(
|
||||
ctx.sender(),
|
||||
MockPreCheckBackend::with_hardcoded_result(Ok(())),
|
||||
MockPreCheckBackend::with_hardcoded_result(Ok(Duration::default())),
|
||||
relay_parent,
|
||||
validation_code_hash,
|
||||
)
|
||||
@@ -977,7 +977,7 @@ fn precheck_invalid_pvf_blob_compression() {
|
||||
|
||||
let (check_fut, check_result) = precheck_pvf(
|
||||
ctx.sender(),
|
||||
MockPreCheckBackend::with_hardcoded_result(Ok(())),
|
||||
MockPreCheckBackend::with_hardcoded_result(Ok(Duration::default())),
|
||||
relay_parent,
|
||||
validation_code_hash,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user