Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions algorithms/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use snarkvm_fields::ConstraintFieldError;

#[derive(Debug, Error)]
pub enum SNARKError {
#[error("{}", _0)]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),

#[error("{}", _0)]
#[error("constraint field error")]
ConstraintFieldError(#[from] ConstraintFieldError),

#[error("{}: {}", _0, _1)]
Expand All @@ -33,7 +33,7 @@ pub enum SNARKError {
#[error("{}", _0)]
Message(String),

#[error("{}", _0)]
#[error("synthesis error")]
SynthesisError(#[from] SynthesisError),

#[error("Batch size was zero; must be at least 1")]
Expand Down
2 changes: 1 addition & 1 deletion algorithms/src/polycommit/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/// The error type for `PolynomialCommitment`.
#[derive(Debug, Error)]
pub enum PCError {
#[error("{0}")]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),

#[error("QuerySet` refers to polynomial \"{label}\", but it was not provided.")]
Expand Down
12 changes: 3 additions & 9 deletions algorithms/src/r1cs/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub type SynthesisResult<T> = Result<T, SynthesisError>;
/// such as CRS generation, proving or verification.
#[derive(Debug, Error)]
pub enum SynthesisError {
#[error("{}", _0)]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),
/// During synthesis, we lacked knowledge of a variable assignment.
#[error("An assignment for a variable could not be computed")]
Expand All @@ -40,18 +40,12 @@ pub enum SynthesisError {
#[error("Encountered an identity element in the CRS")]
UnexpectedIdentity,
/// During proof generation, we encountered an I/O error with the CRS
#[error("Encountered an I/O error")]
IoError(std::io::Error),
#[error("I/O error")]
IoError(#[from] std::io::Error),
/// During verification, our verifying key was malformed.
#[error("Malformed verifying key, public input count was {} but expected {}", _0, _1)]
MalformedVerifyingKey(usize, usize),
/// During CRS generation, we observed an unconstrained auxiliary variable
#[error("Auxiliary variable was unconstrained")]
UnconstrainedVariable,
}

impl From<std::io::Error> for SynthesisError {
fn from(e: std::io::Error) -> SynthesisError {
SynthesisError::IoError(e)
}
}
12 changes: 3 additions & 9 deletions algorithms/src/snark/varuna/ahp/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
/// Describes the failure modes of the AHP scheme.
#[derive(Debug, Error)]
pub enum AHPError {
#[error("{}", _0)]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),

#[error("Batch size was zero; must be at least 1.")]
BatchSizeIsZero,

#[error("An error occurred during constraint generation.")]
ConstraintSystemError(crate::r1cs::errors::SynthesisError),
#[error("constraint generation error")]
ConstraintSystemError(#[from] crate::r1cs::errors::SynthesisError),

#[error("The instance generated during proving does not match that in the index.")]
InstanceDoesNotMatchIndex,
Expand All @@ -40,9 +40,3 @@ pub enum AHPError {
#[error("During synthesis, our polynomials ended up being too high of degree.")]
PolyTooLarge,
}

impl From<crate::r1cs::errors::SynthesisError> for AHPError {
fn from(other: crate::r1cs::errors::SynthesisError) -> Self {
AHPError::ConstraintSystemError(other)
}
}
10 changes: 2 additions & 8 deletions curves/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub enum GroupError {
#[error("{}: {}", _0, _1)]
Crate(&'static str, String),

#[error("{}", _0)]
FieldError(snarkvm_fields::FieldError),
#[error("field error")]
FieldError(#[from] snarkvm_fields::FieldError),

#[error("Invalid group element")]
InvalidGroupElement,
Expand All @@ -37,12 +37,6 @@ pub enum GroupError {
ParsingNonDigitCharacter,
}

impl From<snarkvm_fields::FieldError> for GroupError {
fn from(error: snarkvm_fields::FieldError) -> Self {
GroupError::FieldError(error)
}
}

impl From<std::io::Error> for GroupError {
fn from(error: std::io::Error) -> Self {
GroupError::Crate("std::io", format!("{error:?}"))
Expand Down
2 changes: 1 addition & 1 deletion fields/src/errors/constraint_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#[derive(Debug, Error)]
pub enum ConstraintFieldError {
#[error("{}", _0)]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),

#[error("{}: {}", _0, _1)]
Expand Down
16 changes: 11 additions & 5 deletions ledger/src/check_next_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,20 @@ pub enum CheckBlockError<N: Network> {
#[error("Block has invalid hash")]
InvalidHash,
/// An error related to the given prefix of pending blocks.
#[error("The prefix as an error at index {index} - {error:?}")]
#[error("The prefix has an error at index {index}")]
InvalidPrefix { index: usize, error: Box<CheckBlockError<N>> },
#[error("The block contains solution '{solution_id}', but it already exists in the ledger")]
SolutionAlreadyExists { solution_id: SolutionID<N> },
#[error("Failed to speculate over unconfirmed transactions - {inner}")]
SpeculationFailed { inner: anyhow::Error },
#[error("Failed to verify block - {inner}")]
VerificationFailed { inner: anyhow::Error },
#[error("Failed to speculate over unconfirmed transactions")]
SpeculationFailed {
#[source]
inner: anyhow::Error,
},
#[error("Failed to verify block")]
VerificationFailed {
#[source]
inner: anyhow::Error,
},
#[error("Prover '{prover_address}' has reached their solution limit for the current epoch")]
SolutionLimitReached { prover_address: Address<N> },
#[error("The previous block should contain solution '{solution_id}', but it does not exist in the ledger")]
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use thiserror::Error;
#[derive(Debug, Error)]
pub enum CreateTransferError {
/// VM execution failed.
#[error("VM execution failed: {0}")]
#[error("VM execution failed")]
VmExec(#[from] VmExecError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -34,7 +34,7 @@ pub enum CreateTransferError {
#[derive(Debug, Error)]
pub enum CreateDeployError {
/// VM deployment failed.
#[error("VM deployment failed: {0}")]
#[error("VM deployment failed")]
VmDeploy(#[from] VmDeployError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand Down
29 changes: 15 additions & 14 deletions synthesizer/error/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use thiserror::Error;
#[derive(Debug, Error)]
pub enum ProcessAuthError {
/// Stack authorization failed.
#[error("Stack authorization failed: {0}")]
#[error("Stack authorization failed")]
StackAuth(#[from] StackAuthError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -35,7 +35,7 @@ pub enum ProcessAuthError {
#[derive(Debug, Error)]
pub enum ProcessEvalError {
/// Stack evaluation failed.
#[error("Stack evaluation failed: {0}")]
#[error("Stack evaluation failed")]
StackEval(#[from] StackEvalError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -46,7 +46,7 @@ pub enum ProcessEvalError {
#[derive(Debug, Error)]
pub enum ProcessExecError {
/// Stack execution failed.
#[error("Stack execution failed: {0}")]
#[error("Stack execution failed")]
StackExec(#[from] StackExecError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -57,7 +57,7 @@ pub enum ProcessExecError {
#[derive(Debug, Error)]
pub enum ProcessDeployError {
/// Stack execution failed during synthesis.
#[error("Stack synthesis failed: {0}")]
#[error("Stack synthesis failed")]
StackExec(#[from] StackExecError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -68,7 +68,7 @@ pub enum ProcessDeployError {
#[derive(Debug, Error)]
pub enum CallEvalError {
/// An error occurred during substack evaluation.
#[error("Substack evaluation failed: {0}")]
#[error("Substack evaluation failed")]
StackEval(#[from] StackEvalError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -79,10 +79,10 @@ pub enum CallEvalError {
#[derive(Debug, Error)]
pub enum CallExecError {
/// An error occurred during substack execution.
#[error("Substack execution failed: {0}")]
#[error("Substack execution failed")]
StackExec(#[from] StackExecError),
/// An error occurred during substack evaluation.
#[error("Substack evaluation failed: {0}")]
#[error("Substack evaluation failed")]
StackEval(#[from] StackEvalError),
/// A circuit constraint was not satisfied.
#[error(transparent)]
Expand All @@ -96,10 +96,10 @@ pub enum CallExecError {
#[derive(Debug, Error)]
pub enum StackAuthError {
/// Stack execution failed.
#[error("Stack execution failed: {0}")]
#[error("Stack execution failed")]
Exec(#[from] StackExecError),
/// Stack evaluation failed.
#[error("Stack evaluation failed: {0}")]
#[error("Stack evaluation failed")]
Eval(#[from] StackEvalError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand Down Expand Up @@ -133,13 +133,14 @@ pub enum StackEvalError {

/// An instruction error occurred at a particular index.
#[derive(Debug, Error)]
#[error("Instruction ({instruction}) at index {index} failed: {error}")]
#[error("Instruction ({instruction}) at index {index} failed")]
pub struct IndexedInstructionError<E> {
/// The index of the failing instruction.
pub index: usize,
/// The failing instruction formatted.
pub instruction: String,
/// The instruction error.
#[source]
pub error: E,
}

Expand All @@ -148,10 +149,10 @@ pub struct IndexedInstructionError<E> {
#[derive(Debug, Error)]
pub enum InstructionError {
/// Failed to evaluate an instruction.
#[error("Failed to evaluate: {0}")]
#[error("Failed to evaluate")]
Eval(#[from] InstructionEvalError),
/// Failed to execute an instruction.
#[error("Failed to execute: {0}")]
#[error("Failed to execute")]
Exec(#[from] InstructionExecError),
}

Expand All @@ -162,7 +163,7 @@ pub enum InstructionEvalError {
#[error(transparent)]
Eval(#[from] EvalError),
/// An error occurred during a `Call` instruction.
#[error("Call failed: {0}")]
#[error("Call failed")]
Call(#[from] Box<CallEvalError>),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -173,7 +174,7 @@ pub enum InstructionEvalError {
#[derive(Debug, Error)]
pub enum InstructionExecError {
/// An error occurred during a `Call` instruction.
#[error("Call failed: {0}")]
#[error("Call failed")]
Call(#[from] Box<CallExecError>),
/// An instruction execution error.
#[error(transparent)]
Expand Down
10 changes: 5 additions & 5 deletions synthesizer/error/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use thiserror::Error;
#[derive(Debug, Error)]
pub enum VmExecError {
/// Authorization failed.
#[error("Authorization failed: {0}")]
#[error("Authorization failed")]
Auth(#[from] VmAuthError),
/// Process execution failed (contains instruction index).
#[error("Process execution failed: {0}")]
#[error("Process execution failed")]
Process(#[from] ProcessExecError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -37,7 +37,7 @@ pub enum VmExecError {
#[derive(Debug, Error)]
pub enum VmAuthError {
/// Process authorization failed.
#[error("Process authorization failed: {0}")]
#[error("Process authorization failed")]
Process(#[from] ProcessAuthError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand All @@ -48,10 +48,10 @@ pub enum VmAuthError {
#[derive(Debug, Error)]
pub enum VmDeployError {
/// Process deployment failed.
#[error("Process deployment failed: {0}")]
#[error("Process deployment failed")]
Process(#[from] ProcessDeployError),
/// Fee execution failed.
#[error("Fee execution failed: {0}")]
#[error("Fee execution failed")]
FeeExec(#[from] VmExecError),
/// A temporary variant for type-erased anyhow errors.
#[error(transparent)]
Expand Down
6 changes: 3 additions & 3 deletions synthesizer/tests/test_vm_execute_and_finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ fn run_test(test: &ProgramTest) -> serde_yaml::Mapping {
output.insert(
serde_yaml::Value::String("errors".to_string()),
serde_yaml::Value::Sequence(vec![serde_yaml::Value::String(format!(
"Failed to run `VM::deploy for program {}: {}",
"Failed to run `VM::deploy for program {}: {:#}",
program.id(),
error
anyhow::Error::from(error)
))]),
);
output
Expand Down Expand Up @@ -231,7 +231,7 @@ fn run_test(test: &ProgramTest) -> serde_yaml::Mapping {
Err(err) => {
result.insert(
serde_yaml::Value::String("execute".to_string()),
serde_yaml::Value::String(err.to_string()),
serde_yaml::Value::String(format!("{:#}", anyhow::Error::from(err))),
);
return (serde_yaml::Value::Mapping(result), serde_yaml::Value::Mapping(Default::default()));
}
Expand Down
4 changes: 2 additions & 2 deletions utilities/src/serialize/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#[derive(Error, Debug)]
pub enum SerializationError {
#[error("{}", _0)]
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),
/// During serialization with bincode, we encountered a serialization issue
#[error(transparent)]
Expand All @@ -27,7 +27,7 @@ pub enum SerializationError {
#[error("the input buffer contained invalid data")]
InvalidData,
/// During serialization, we countered an I/O error.
#[error("IoError: {0}")]
#[error("I/O error")]
IoError(#[from] std::io::Error),
/// During serialization, we didn't have enough space to write extra info.
#[error("the last byte does not have enough space to encode the extra info bits")]
Expand Down