Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Move PrepareError to the error module
  • Loading branch information
slumber committed Sep 27, 2021
commit d323ac6dc64dc8b80f7b940c3ac45bdef3c6f6b1
13 changes: 1 addition & 12 deletions node/core/pvf/src/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::error::PrepareError;
use always_assert::always;
use async_std::path::{Path, PathBuf};
use parity_scale_codec::{Decode, Encode};
Expand All @@ -23,18 +24,6 @@ use std::{
time::{Duration, SystemTime},
};

/// An error that occurred during the prepare part of the PVF pipeline.
#[derive(Debug, Clone, Encode, Decode)]
pub enum PrepareError {
/// During the prevalidation stage of preparation an issue was found with the PVF.
Prevalidation(String),
/// Compilation failed for the given PVF.
Preparation(String),
/// This state indicates that the process assigned to prepare the artifact wasn't responsible
/// or were killed. This state is reported by the validation host (not by the worker).
DidNotMakeIt,
}

/// A wrapper for the compiled PVF code.
#[derive(Encode, Decode)]
pub struct CompiledArtifact(Vec<u8>);
Expand Down
14 changes: 13 additions & 1 deletion node/core/pvf/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::artifacts::PrepareError;
use parity_scale_codec::{Decode, Encode};

/// An error that occurred during the prepare part of the PVF pipeline.
#[derive(Debug, Clone, Encode, Decode)]
pub enum PrepareError {
/// During the prevalidation stage of preparation an issue was found with the PVF.
Prevalidation(String),
/// Compilation failed for the given PVF.
Preparation(String),
/// This state indicates that the process assigned to prepare the artifact wasn't responsible
/// or were killed. This state is reported by the validation host (not by the worker).
DidNotMakeIt,
}

/// A error raised during validation of the candidate.
#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion node/core/pvf/src/prepare/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use super::worker::{self, Outcome};
use crate::{
artifacts::PrepareError,
error::PrepareError,
metrics::Metrics,
worker_common::{IdleWorker, WorkerHandle},
LOG_TARGET,
Expand Down
4 changes: 1 addition & 3 deletions node/core/pvf/src/prepare/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

use super::pool::{self, Worker};
use crate::{
artifacts::{ArtifactId, PrepareError},
metrics::Metrics,
Priority, Pvf, LOG_TARGET,
artifacts::ArtifactId, error::PrepareError, metrics::Metrics, Priority, Pvf, LOG_TARGET,
};
use always_assert::{always, never};
use async_std::path::PathBuf;
Expand Down
3 changes: 2 additions & 1 deletion node/core/pvf/src/prepare/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::{
artifacts::{CompiledArtifact, PrepareError},
artifacts::CompiledArtifact,
error::PrepareError,
worker_common::{
bytes_to_path, framed_recv, framed_send, path_to_bytes, spawn_with_program_path,
tmpfile_in, worker_event_loop, IdleWorker, SpawnErr, WorkerHandle,
Expand Down