Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(diagnostics): Updates error messages to include inner error types #9066

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 13 additions & 11 deletions zebra-consensus/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub enum TransactionError {
transaction_hash: zebra_chain::transaction::Hash,
},

#[error("coinbase transaction failed subsidy validation")]
#[error("coinbase transaction failed subsidy validation: {0}")]
arya2 marked this conversation as resolved.
Show resolved Hide resolved
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Subsidy(#[from] SubsidyError),

Expand All @@ -140,7 +140,7 @@ pub enum TransactionError {
#[error("if there are no Spends or Outputs, the value balance MUST be 0.")]
BadBalance,

#[error("could not verify a transparent script")]
#[error("could not verify a transparent script: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Script(#[from] zebra_script::Error),

Expand All @@ -149,29 +149,29 @@ pub enum TransactionError {

// TODO: the underlying error is bellman::VerificationError, but it does not implement
// Arbitrary as required here.
#[error("spend proof MUST be valid given a primary input formed from the other fields except spendAuthSig")]
#[error("spend proof MUST be valid given a primary input formed from the other fields except spendAuthSig: {0}")]
Groth16(String),

// TODO: the underlying error is io::Error, but it does not implement Clone as required here.
#[error("Groth16 proof is malformed")]
#[error("Groth16 proof is malformed: {0}")]
MalformedGroth16(String),

#[error(
"Sprout joinSplitSig MUST represent a valid signature under joinSplitPubKey of dataToBeSigned"
"Sprout joinSplitSig MUST represent a valid signature under joinSplitPubKey of dataToBeSigned: {0}"
)]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Ed25519(#[from] zebra_chain::primitives::ed25519::Error),

#[error("Sapling bindingSig MUST represent a valid signature under the transaction binding validating key bvk of SigHash")]
#[error("Sapling bindingSig MUST represent a valid signature under the transaction binding validating key bvk of SigHash: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
RedJubjub(zebra_chain::primitives::redjubjub::Error),

#[error("Orchard bindingSig MUST represent a valid signature under the transaction binding validating key bvk of SigHash")]
#[error("Orchard bindingSig MUST represent a valid signature under the transaction binding validating key bvk of SigHash: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
RedPallas(zebra_chain::primitives::reddsa::Error),

// temporary error type until #1186 is fixed
#[error("Downcast from BoxError to redjubjub::Error failed")]
#[error("Downcast from BoxError to redjubjub::Error failed: {0}")]
InternalDowncastError(String),

#[error("either vpub_old or vpub_new must be zero")]
Expand Down Expand Up @@ -201,12 +201,12 @@ pub enum TransactionError {
#[error("could not find a mempool transaction input UTXO in the best chain")]
TransparentInputNotFound,

#[error("could not validate nullifiers and anchors on best chain")]
#[error("could not validate nullifiers and anchors on best chain: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
// This error variant is at least 128 bytes
ValidateContextError(Box<ValidateContextError>),

#[error("could not validate mempool transaction lock time on best chain")]
#[error("could not validate mempool transaction lock time on best chain: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
// TODO: turn this into a typed error
ValidateMempoolLockTimeError(String),
Expand Down Expand Up @@ -236,7 +236,9 @@ pub enum TransactionError {
min_spend_height: block::Height,
},

#[error("failed to verify ZIP-317 transaction rules, transaction was not inserted to mempool")]
#[error(
"failed to verify ZIP-317 transaction rules, transaction was not inserted to mempool: {0}"
)]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Zip317(#[from] zebra_chain::transaction::zip317::Error),
}
Expand Down
6 changes: 3 additions & 3 deletions zebrad/src/components/mempool/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ pub enum TransactionDownloadVerifyError {
#[error("transaction is already in state")]
InState,

#[error("error in state service")]
#[error("error in state service: {0}")]
StateError(#[source] CloneError),

#[error("error downloading transaction")]
#[error("error downloading transaction: {0}")]
DownloadFailed(#[source] CloneError),

#[error("transaction download / verification was cancelled")]
Cancelled,

#[error("transaction did not pass consensus validation")]
#[error("transaction did not pass consensus validation: {0}")]
Invalid(#[from] zebra_consensus::error::TransactionError),
}

Expand Down
2 changes: 1 addition & 1 deletion zebrad/src/components/mempool/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(crate) const MAX_EVICTION_MEMORY_ENTRIES: usize = 40_000;
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[allow(dead_code)]
pub enum ExactTipRejectionError {
#[error("transaction did not pass consensus validation")]
#[error("transaction did not pass consensus validation: {0}")]
FailedVerification(#[from] zebra_consensus::error::TransactionError),
}

Expand Down
Loading