style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -110,17 +110,17 @@ impl PrepareError {
|
||||
pub fn is_deterministic(&self) -> bool {
|
||||
use PrepareError::*;
|
||||
match self {
|
||||
Prevalidation(_) |
|
||||
Preparation(_) |
|
||||
JobError(_) |
|
||||
OutOfMemory |
|
||||
CouldNotDecompressCodeBlob(_) => true,
|
||||
IoErr(_) |
|
||||
JobDied { .. } |
|
||||
CreateTmpFile(_) |
|
||||
RenameTmpFile { .. } |
|
||||
ClearWorkerDir(_) |
|
||||
Kernel(_) => false,
|
||||
Prevalidation(_)
|
||||
| Preparation(_)
|
||||
| JobError(_)
|
||||
| OutOfMemory
|
||||
| CouldNotDecompressCodeBlob(_) => true,
|
||||
IoErr(_)
|
||||
| JobDied { .. }
|
||||
| CreateTmpFile(_)
|
||||
| RenameTmpFile { .. }
|
||||
| ClearWorkerDir(_)
|
||||
| Kernel(_) => false,
|
||||
// Can occur due to issues with the PVF, but also due to factors like local load.
|
||||
TimedOut => false,
|
||||
// Can occur due to issues with the PVF, but also due to local errors.
|
||||
|
||||
@@ -160,16 +160,17 @@ pub fn params_to_wasmtime_semantics(par: &ExecutorParams) -> (Semantics, Determi
|
||||
|
||||
for p in par.iter() {
|
||||
match p {
|
||||
ExecutorParam::MaxMemoryPages(max_pages) =>
|
||||
ExecutorParam::MaxMemoryPages(max_pages) => {
|
||||
sem.heap_alloc_strategy = HeapAllocStrategy::Dynamic {
|
||||
maximum_pages: Some((*max_pages).saturating_add(DEFAULT_HEAP_PAGES_ESTIMATE)),
|
||||
},
|
||||
}
|
||||
},
|
||||
ExecutorParam::StackLogicalMax(slm) => stack_limit.logical_max = *slm,
|
||||
ExecutorParam::StackNativeMax(snm) => stack_limit.native_stack_max = *snm,
|
||||
ExecutorParam::WasmExtBulkMemory => sem.wasm_bulk_memory = true,
|
||||
ExecutorParam::PrecheckingMaxMemory(_) |
|
||||
ExecutorParam::PvfPrepTimeout(_, _) |
|
||||
ExecutorParam::PvfExecTimeout(_, _) => (), /* Not used here */
|
||||
ExecutorParam::PrecheckingMaxMemory(_)
|
||||
| ExecutorParam::PvfPrepTimeout(_, _)
|
||||
| ExecutorParam::PvfExecTimeout(_, _) => (), /* Not used here */
|
||||
}
|
||||
}
|
||||
sem.deterministic_stack_limit = Some(stack_limit.clone());
|
||||
|
||||
@@ -133,8 +133,8 @@ impl fmt::Debug for PvfPrepData {
|
||||
|
||||
impl PartialEq for PvfPrepData {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.code_hash == other.code_hash &&
|
||||
self.executor_params.hash() == other.executor_params.hash()
|
||||
self.code_hash == other.code_hash
|
||||
&& self.executor_params.hash() == other.executor_params.hash()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -562,8 +562,8 @@ fn recv_worker_handshake(stream: &mut UnixStream) -> io::Result<WorkerHandshake>
|
||||
///
|
||||
/// Returns a `Duration` representing the total CPU time.
|
||||
pub fn get_total_cpu_usage(rusage: Usage) -> Duration {
|
||||
let micros = (((rusage.user_time().tv_sec() + rusage.system_time().tv_sec()) * 1_000_000) +
|
||||
(rusage.system_time().tv_usec() + rusage.user_time().tv_usec()) as i64) as u64;
|
||||
let micros = (((rusage.user_time().tv_sec() + rusage.system_time().tv_sec()) * 1_000_000)
|
||||
+ (rusage.system_time().tv_usec() + rusage.user_time().tv_usec()) as i64) as u64;
|
||||
|
||||
return Duration::from_micros(micros);
|
||||
}
|
||||
|
||||
@@ -121,11 +121,12 @@ fn try_restrict(worker_info: &WorkerInfo) -> Result<()> {
|
||||
worker_dir_path_c.as_ptr(),
|
||||
worker_dir_path_c.as_ptr(),
|
||||
ptr::null(), // ignored when MS_BIND is used
|
||||
libc::MS_BIND |
|
||||
libc::MS_REC | libc::MS_NOEXEC |
|
||||
libc::MS_NODEV | libc::MS_NOSUID |
|
||||
libc::MS_NOATIME |
|
||||
additional_flags,
|
||||
libc::MS_BIND
|
||||
| libc::MS_REC | libc::MS_NOEXEC
|
||||
| libc::MS_NODEV
|
||||
| libc::MS_NOSUID
|
||||
| libc::MS_NOATIME
|
||||
| additional_flags,
|
||||
ptr::null(), // ignored when MS_BIND is used
|
||||
) < 0
|
||||
{
|
||||
|
||||
@@ -82,12 +82,12 @@ fn clone_flags(have_unshare_newuser: bool) -> CloneFlags {
|
||||
// SIGCHLD flag is used to inform clone that the parent process is
|
||||
// expecting a child termination signal, without this flag `waitpid` function
|
||||
// return `ECHILD` error.
|
||||
maybe_clone_newuser |
|
||||
CloneFlags::CLONE_NEWCGROUP |
|
||||
CloneFlags::CLONE_NEWIPC |
|
||||
CloneFlags::CLONE_NEWNET |
|
||||
CloneFlags::CLONE_NEWNS |
|
||||
CloneFlags::CLONE_NEWPID |
|
||||
CloneFlags::CLONE_NEWUTS |
|
||||
CloneFlags::from_bits_retain(libc::SIGCHLD)
|
||||
maybe_clone_newuser
|
||||
| CloneFlags::CLONE_NEWCGROUP
|
||||
| CloneFlags::CLONE_NEWIPC
|
||||
| CloneFlags::CLONE_NEWNET
|
||||
| CloneFlags::CLONE_NEWNS
|
||||
| CloneFlags::CLONE_NEWPID
|
||||
| CloneFlags::CLONE_NEWUTS
|
||||
| CloneFlags::from_bits_retain(libc::SIGCHLD)
|
||||
}
|
||||
|
||||
@@ -319,18 +319,20 @@ fn validate_using_artifact(
|
||||
// [`executor_interface::prepare`].
|
||||
execute_artifact(compiled_artifact_blob, executor_params, params)
|
||||
} {
|
||||
Err(ExecuteError::RuntimeConstruction(wasmerr)) =>
|
||||
return JobResponse::runtime_construction("execute", &wasmerr.to_string()),
|
||||
Err(ExecuteError::RuntimeConstruction(wasmerr)) => {
|
||||
return JobResponse::runtime_construction("execute", &wasmerr.to_string())
|
||||
},
|
||||
Err(err) => return JobResponse::format_invalid("execute", &err.to_string()),
|
||||
Ok(d) => d,
|
||||
};
|
||||
|
||||
let result_descriptor = match ValidationResult::decode(&mut &descriptor_bytes[..]) {
|
||||
Err(err) =>
|
||||
Err(err) => {
|
||||
return JobResponse::format_invalid(
|
||||
"validation result decoding failed",
|
||||
&err.to_string(),
|
||||
),
|
||||
)
|
||||
},
|
||||
Ok(r) => r,
|
||||
};
|
||||
|
||||
@@ -383,8 +385,9 @@ fn handle_clone(
|
||||
pov_size,
|
||||
execution_timeout,
|
||||
),
|
||||
Err(security::clone::Error::Clone(errno)) =>
|
||||
Ok(Err(internal_error_from_errno("clone", errno))),
|
||||
Err(security::clone::Error::Clone(errno)) => {
|
||||
Ok(Err(internal_error_from_errno("clone", errno)))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,8 +243,8 @@ impl Artifacts {
|
||||
let Some(file_name) = path.file_name().and_then(|f| f.to_str()) else { continue };
|
||||
if path.is_dir() && file_name.starts_with(WORKER_DIR_PREFIX) {
|
||||
let _ = fs::remove_dir_all(path);
|
||||
} else if path.extension().map_or(false, |ext| ext == ARTIFACT_EXTENSION) ||
|
||||
file_name.starts_with(ARTIFACT_OLD_PREFIX)
|
||||
} else if path.extension().map_or(false, |ext| ext == ARTIFACT_EXTENSION)
|
||||
|| file_name.starts_with(ARTIFACT_OLD_PREFIX)
|
||||
{
|
||||
let _ = fs::remove_file(path);
|
||||
}
|
||||
|
||||
@@ -524,14 +524,16 @@ async fn handle_job_finish(
|
||||
)
|
||||
},
|
||||
|
||||
Err(WorkerInterfaceError::InternalError(err)) |
|
||||
Err(WorkerInterfaceError::WorkerError(WorkerError::InternalError(err))) =>
|
||||
(None, Err(ValidationError::Internal(err)), None, None, None),
|
||||
Err(WorkerInterfaceError::InternalError(err))
|
||||
| Err(WorkerInterfaceError::WorkerError(WorkerError::InternalError(err))) => {
|
||||
(None, Err(ValidationError::Internal(err)), None, None, None)
|
||||
},
|
||||
// Either the worker or the job timed out. Kill the worker in either case. Treated as
|
||||
// definitely-invalid, because if we timed out, there's no time left for a retry.
|
||||
Err(WorkerInterfaceError::HardTimeout) |
|
||||
Err(WorkerInterfaceError::WorkerError(WorkerError::JobTimedOut)) =>
|
||||
(None, Err(ValidationError::Invalid(InvalidCandidate::HardTimeout)), None, None, None),
|
||||
Err(WorkerInterfaceError::HardTimeout)
|
||||
| Err(WorkerInterfaceError::WorkerError(WorkerError::JobTimedOut)) => {
|
||||
(None, Err(ValidationError::Invalid(InvalidCandidate::HardTimeout)), None, None, None)
|
||||
},
|
||||
// "Maybe invalid" errors (will retry).
|
||||
Err(WorkerInterfaceError::CommunicationErr(_err)) => (
|
||||
None,
|
||||
|
||||
@@ -533,10 +533,12 @@ async fn handle_to_host(
|
||||
handle_execute_pvf(artifacts, prepare_queue, execute_queue, awaiting_prepare, inputs)
|
||||
.await?;
|
||||
},
|
||||
ToHost::HeadsUp { active_pvfs } =>
|
||||
handle_heads_up(artifacts, prepare_queue, active_pvfs).await?,
|
||||
ToHost::UpdateActiveLeaves { update, ancestors } =>
|
||||
handle_update_active_leaves(execute_queue, update, ancestors).await?,
|
||||
ToHost::HeadsUp { active_pvfs } => {
|
||||
handle_heads_up(artifacts, prepare_queue, active_pvfs).await?
|
||||
},
|
||||
ToHost::UpdateActiveLeaves { update, ancestors } => {
|
||||
handle_update_active_leaves(execute_queue, update, ancestors).await?
|
||||
},
|
||||
#[cfg(feature = "test-utils")]
|
||||
ToHost::ReplaceArtifactChecksum { checksum, new_checksum } => {
|
||||
artifacts.replace_artifact_checksum(checksum, new_checksum);
|
||||
@@ -567,8 +569,9 @@ async fn handle_precheck_pvf(
|
||||
*last_time_needed = SystemTime::now();
|
||||
let _ = result_sender.send(Ok(()));
|
||||
},
|
||||
ArtifactState::Preparing { waiting_for_response, num_failures: _ } =>
|
||||
waiting_for_response.push(result_sender),
|
||||
ArtifactState::Preparing { waiting_for_response, num_failures: _ } => {
|
||||
waiting_for_response.push(result_sender)
|
||||
},
|
||||
ArtifactState::FailedToProcess { error, .. } => {
|
||||
// Do not retry an artifact that previously failed preparation.
|
||||
let _ = result_sender.send(PrecheckResult::Err(error.clone()));
|
||||
@@ -887,8 +890,9 @@ async fn handle_prepare_done(
|
||||
}
|
||||
|
||||
*state = match result {
|
||||
Ok(PrepareSuccess { checksum, path, size, .. }) =>
|
||||
ArtifactState::Prepared { checksum, path, last_time_needed: SystemTime::now(), size },
|
||||
Ok(PrepareSuccess { checksum, path, size, .. }) => {
|
||||
ArtifactState::Prepared { checksum, path, last_time_needed: SystemTime::now(), size }
|
||||
},
|
||||
Err(error) => {
|
||||
let last_time_failed = SystemTime::now();
|
||||
let num_failures = *num_failures + 1;
|
||||
@@ -1033,8 +1037,8 @@ fn can_retry_prepare_after_failure(
|
||||
|
||||
// Retry if the retry cooldown has elapsed and if we have already retried less than
|
||||
// `NUM_PREPARE_RETRIES` times. IO errors may resolve themselves.
|
||||
SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN &&
|
||||
num_failures <= NUM_PREPARE_RETRIES
|
||||
SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN
|
||||
&& num_failures <= NUM_PREPARE_RETRIES
|
||||
}
|
||||
|
||||
/// A stream that yields a pulse continuously at a given interval.
|
||||
|
||||
@@ -330,8 +330,9 @@ fn handle_mux(
|
||||
// If we receive an outcome that the worker is unreachable or that an error occurred on
|
||||
// the worker, we attempt to kill the worker process.
|
||||
match outcome {
|
||||
Outcome::Concluded { worker: idle, result } =>
|
||||
handle_concluded_no_rip(from_pool, spawned, worker, idle, result),
|
||||
Outcome::Concluded { worker: idle, result } => {
|
||||
handle_concluded_no_rip(from_pool, spawned, worker, idle, result)
|
||||
},
|
||||
// Return `Concluded`, but do not kill the worker since the error was on the host
|
||||
// side.
|
||||
Outcome::CreateTmpFileErr { worker: idle, err } => handle_concluded_no_rip(
|
||||
|
||||
@@ -271,8 +271,9 @@ async fn handle_from_pool(queue: &mut Queue, from_pool: pool::FromPool) -> Resul
|
||||
use pool::FromPool;
|
||||
match from_pool {
|
||||
FromPool::Spawned(worker) => handle_worker_spawned(queue, worker).await?,
|
||||
FromPool::Concluded { worker, rip, result } =>
|
||||
handle_worker_concluded(queue, worker, rip, result).await?,
|
||||
FromPool::Concluded { worker, rip, result } => {
|
||||
handle_worker_concluded(queue, worker, rip, result).await?
|
||||
},
|
||||
FromPool::Rip(worker) => handle_worker_rip(queue, worker).await?,
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -157,7 +157,7 @@ pub async fn start_work(
|
||||
|
||||
match result {
|
||||
// Received bytes from worker within the time limit.
|
||||
Ok(Ok(prepare_worker_result)) =>
|
||||
Ok(Ok(prepare_worker_result)) => {
|
||||
handle_response(
|
||||
metrics,
|
||||
IdleWorker { stream, pid, worker_dir },
|
||||
@@ -167,7 +167,8 @@ pub async fn start_work(
|
||||
&cache_path,
|
||||
preparation_timeout,
|
||||
)
|
||||
.await,
|
||||
.await
|
||||
},
|
||||
Ok(Err(err)) => {
|
||||
// Communication error within the time limit.
|
||||
gum::warn!(
|
||||
|
||||
@@ -105,8 +105,8 @@ impl FullSecurityStatus {
|
||||
}
|
||||
|
||||
fn all_errs_allowed(&self) -> bool {
|
||||
!self.partial.secure_validator_mode ||
|
||||
self.errs.iter().all(|err| err.is_allowed_in_secure_mode(&self.partial))
|
||||
!self.partial.secure_validator_mode
|
||||
|| self.errs.iter().all(|err| err.is_allowed_in_secure_mode(&self.partial))
|
||||
}
|
||||
|
||||
fn errs_string(&self) -> String {
|
||||
@@ -141,8 +141,9 @@ impl SecureModeError {
|
||||
match self {
|
||||
// Landlock is present on relatively recent Linuxes. This is optional if the unshare
|
||||
// capability is present, providing FS sandboxing a different way.
|
||||
CannotEnableLandlock { .. } =>
|
||||
security_status.can_unshare_user_namespace_and_change_root,
|
||||
CannotEnableLandlock { .. } => {
|
||||
security_status.can_unshare_user_namespace_and_change_root
|
||||
},
|
||||
// seccomp should be present on all modern Linuxes unless it's been disabled.
|
||||
CannotEnableSeccomp(_) => false,
|
||||
// Should always be present on modern Linuxes. If not, Landlock also provides FS
|
||||
|
||||
Reference in New Issue
Block a user