This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
PVF: Don't dispute on missing artifact #7011
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b66e91
PVF: Don't dispute on missing artifact
mrcnski 6fa0046
Add some context to wasm error message (it is quite long)
mrcnski d1a3050
Fix impl guide
mrcnski 5982b8b
Add check for missing/inaccessible file
mrcnski ff77e2a
Add comment referencing Substrate issue
mrcnski b450803
Add test for retrying internal errors
mrcnski 9259f72
Merge remote-tracking branch 'origin/master' into mrcnski/pvf-missing…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,38 +691,54 @@ trait ValidationBackend { | |
|
||
/// Tries executing a PVF. Will retry once if an error is encountered that may have been | ||
/// transient. | ||
/// | ||
/// NOTE: Should retry only on errors that are a result of execution itself, and not of | ||
/// preparation. | ||
async fn validate_candidate_with_retry( | ||
&mut self, | ||
raw_validation_code: Vec<u8>, | ||
exec_timeout: Duration, | ||
params: ValidationParams, | ||
executor_params: ExecutorParams, | ||
) -> Result<WasmValidationResult, ValidationError> { | ||
// Construct the PVF a single time, since it is an expensive operation. Cloning it is cheap. | ||
let prep_timeout = pvf_prep_timeout(&executor_params, PvfPrepTimeoutKind::Lenient); | ||
// Construct the PVF a single time, since it is an expensive operation. Cloning it is cheap. | ||
let pvf = PvfPrepData::from_code(raw_validation_code, executor_params, prep_timeout); | ||
|
||
let mut validation_result = | ||
self.validate_candidate(pvf.clone(), exec_timeout, params.encode()).await; | ||
|
||
// If we get an AmbiguousWorkerDeath error, retry once after a brief delay, on the | ||
// assumption that the conditions that caused this error may have been transient. Note that | ||
// this error is only a result of execution itself and not of preparation. | ||
if let Err(ValidationError::InvalidCandidate(WasmInvalidCandidate::AmbiguousWorkerDeath)) = | ||
validation_result | ||
{ | ||
// Wait a brief delay before retrying. | ||
futures_timer::Delay::new(PVF_EXECUTION_RETRY_DELAY).await; | ||
// Allow limited retries for each kind of error. | ||
let mut num_internal_retries_left = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could make this higher, since this kind of error is probably the most likely to be transient. |
||
let mut num_awd_retries_left = 1; | ||
loop { | ||
match validation_result { | ||
Err(ValidationError::InvalidCandidate( | ||
WasmInvalidCandidate::AmbiguousWorkerDeath, | ||
)) if num_awd_retries_left > 0 => num_awd_retries_left -= 1, | ||
Err(ValidationError::InternalError(_)) if num_internal_retries_left > 0 => | ||
num_internal_retries_left -= 1, | ||
_ => break, | ||
} | ||
|
||
// If we got a possibly transient error, retry once after a brief delay, on the assumption | ||
// that the conditions that caused this error may have resolved on their own. | ||
{ | ||
// Wait a brief delay before retrying. | ||
futures_timer::Delay::new(PVF_EXECUTION_RETRY_DELAY).await; | ||
|
||
gum::warn!( | ||
target: LOG_TARGET, | ||
?pvf, | ||
"Re-trying failed candidate validation due to AmbiguousWorkerDeath." | ||
); | ||
gum::warn!( | ||
target: LOG_TARGET, | ||
?pvf, | ||
"Re-trying failed candidate validation due to possible transient error: {:?}", | ||
validation_result | ||
); | ||
|
||
// Encode the params again when re-trying. We expect the retry case to be relatively | ||
// rare, and we want to avoid unconditionally cloning data. | ||
validation_result = self.validate_candidate(pvf, exec_timeout, params.encode()).await; | ||
// Encode the params again when re-trying. We expect the retry case to be relatively | ||
// rare, and we want to avoid unconditionally cloning data. | ||
validation_result = | ||
self.validate_candidate(pvf.clone(), exec_timeout, params.encode()).await; | ||
} | ||
} | ||
|
||
validation_result | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating candidate-validation tests would not harm