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

* add: add consensus validation reason to error messages

* add additional instances
This commit is contained in:
Conrado Gouvea 2024-12-04 15:45:10 -03:00 committed by GitHub
parent eb9e1f150a
commit a3bb1e2e05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 34 additions and 30 deletions

View File

@ -30,7 +30,7 @@ pub enum HistoryTreeError {
#[non_exhaustive] #[non_exhaustive]
InnerError { inner: zcash_history::Error }, InnerError { inner: zcash_history::Error },
#[error("I/O error")] #[error("I/O error: {0}")]
IOError(#[from] io::Error), IOError(#[from] io::Error),
} }

View File

@ -74,19 +74,19 @@ pub enum VerifyBlockError {
#[error(transparent)] #[error(transparent)]
Time(zebra_chain::block::BlockTimeError), Time(zebra_chain::block::BlockTimeError),
#[error("unable to commit block after semantic verification")] #[error("unable to commit block after semantic verification: {0}")]
// TODO: make this into a concrete type, and add it to is_duplicate_request() (#2908) // TODO: make this into a concrete type, and add it to is_duplicate_request() (#2908)
Commit(#[source] BoxError), Commit(#[source] BoxError),
#[cfg(feature = "getblocktemplate-rpcs")] #[cfg(feature = "getblocktemplate-rpcs")]
#[error("unable to validate block proposal: failed semantic verification (proof of work is not checked for proposals)")] #[error("unable to validate block proposal: failed semantic verification (proof of work is not checked for proposals): {0}")]
// TODO: make this into a concrete type (see #5732) // TODO: make this into a concrete type (see #5732)
ValidateProposal(#[source] BoxError), ValidateProposal(#[source] BoxError),
#[error("invalid transaction")] #[error("invalid transaction: {0}")]
Transaction(#[from] TransactionError), Transaction(#[from] TransactionError),
#[error("invalid block subsidy")] #[error("invalid block subsidy: {0}")]
Subsidy(#[from] SubsidyError), Subsidy(#[from] SubsidyError),
} }

View File

@ -992,9 +992,9 @@ pub enum VerifyCheckpointError {
CheckpointList(BoxError), CheckpointList(BoxError),
#[error(transparent)] #[error(transparent)]
VerifyBlock(VerifyBlockError), VerifyBlock(VerifyBlockError),
#[error("invalid block subsidy")] #[error("invalid block subsidy: {0}")]
SubsidyError(#[from] SubsidyError), SubsidyError(#[from] SubsidyError),
#[error("invalid amount")] #[error("invalid amount: {0}")]
AmountError(#[from] amount::Error), AmountError(#[from] amount::Error),
#[error("too many queued blocks at this height")] #[error("too many queued blocks at this height")]
QueuedLimit, QueuedLimit,

View File

@ -121,7 +121,7 @@ pub enum TransactionError {
transaction_hash: zebra_chain::transaction::Hash, transaction_hash: zebra_chain::transaction::Hash,
}, },
#[error("coinbase transaction failed subsidy validation")] #[error("coinbase transaction failed subsidy validation: {0}")]
#[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Subsidy(#[from] SubsidyError), Subsidy(#[from] SubsidyError),
@ -140,7 +140,7 @@ pub enum TransactionError {
#[error("if there are no Spends or Outputs, the value balance MUST be 0.")] #[error("if there are no Spends or Outputs, the value balance MUST be 0.")]
BadBalance, 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Script(#[from] zebra_script::Error), Script(#[from] zebra_script::Error),
@ -149,29 +149,29 @@ pub enum TransactionError {
// TODO: the underlying error is bellman::VerificationError, but it does not implement // TODO: the underlying error is bellman::VerificationError, but it does not implement
// Arbitrary as required here. // 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), Groth16(String),
// TODO: the underlying error is io::Error, but it does not implement Clone as required here. // 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), MalformedGroth16(String),
#[error( #[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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Ed25519(#[from] zebra_chain::primitives::ed25519::Error), 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
RedJubjub(zebra_chain::primitives::redjubjub::Error), 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
RedPallas(zebra_chain::primitives::reddsa::Error), RedPallas(zebra_chain::primitives::reddsa::Error),
// temporary error type until #1186 is fixed // 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), InternalDowncastError(String),
#[error("either vpub_old or vpub_new must be zero")] #[error("either vpub_old or vpub_new must be zero")]
@ -201,12 +201,12 @@ pub enum TransactionError {
#[error("could not find a mempool transaction input UTXO in the best chain")] #[error("could not find a mempool transaction input UTXO in the best chain")]
TransparentInputNotFound, 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
// This error variant is at least 128 bytes // This error variant is at least 128 bytes
ValidateContextError(Box<ValidateContextError>), 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
// TODO: turn this into a typed error // TODO: turn this into a typed error
ValidateMempoolLockTimeError(String), ValidateMempoolLockTimeError(String),
@ -236,7 +236,9 @@ pub enum TransactionError {
min_spend_height: block::Height, 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))] #[cfg_attr(any(test, feature = "proptest-impl"), proptest(skip))]
Zip317(#[from] zebra_chain::transaction::zip317::Error), Zip317(#[from] zebra_chain::transaction::zip317::Error),
} }

View File

@ -251,10 +251,10 @@ pub enum HandshakeError {
#[error("Peer closed connection")] #[error("Peer closed connection")]
ConnectionClosed, ConnectionClosed,
/// An error occurred while performing an IO operation. /// An error occurred while performing an IO operation.
#[error("Underlying IO error")] #[error("Underlying IO error: {0}")]
Io(#[from] std::io::Error), Io(#[from] std::io::Error),
/// A serialization error occurred while reading or writing a message. /// A serialization error occurred while reading or writing a message.
#[error("Serialization error")] #[error("Serialization error: {0}")]
Serialization(#[from] SerializationError), Serialization(#[from] SerializationError),
/// The remote peer offered a version older than our minimum version. /// The remote peer offered a version older than our minimum version.
#[error("Peer offered obsolete version: {0:?}")] #[error("Peer offered obsolete version: {0:?}")]

View File

@ -220,13 +220,13 @@ pub enum ValidateContextError {
height: Option<block::Height>, height: Option<block::Height>,
}, },
#[error("error updating a note commitment tree")] #[error("error updating a note commitment tree: {0}")]
NoteCommitmentTreeError(#[from] zebra_chain::parallel::tree::NoteCommitmentTreeError), NoteCommitmentTreeError(#[from] zebra_chain::parallel::tree::NoteCommitmentTreeError),
#[error("error building the history tree")] #[error("error building the history tree: {0}")]
HistoryTreeError(#[from] Arc<HistoryTreeError>), HistoryTreeError(#[from] Arc<HistoryTreeError>),
#[error("block contains an invalid commitment")] #[error("block contains an invalid commitment: {0}")]
InvalidBlockCommitment(#[from] block::CommitmentError), InvalidBlockCommitment(#[from] block::CommitmentError),
#[error( #[error(

View File

@ -115,16 +115,16 @@ pub enum TransactionDownloadVerifyError {
#[error("transaction is already in state")] #[error("transaction is already in state")]
InState, InState,
#[error("error in state service")] #[error("error in state service: {0}")]
StateError(#[source] CloneError), StateError(#[source] CloneError),
#[error("error downloading transaction")] #[error("error downloading transaction: {0}")]
DownloadFailed(#[source] CloneError), DownloadFailed(#[source] CloneError),
#[error("transaction download / verification was cancelled")] #[error("transaction download / verification was cancelled")]
Cancelled, Cancelled,
#[error("transaction did not pass consensus validation")] #[error("transaction did not pass consensus validation: {0}")]
Invalid(#[from] zebra_consensus::error::TransactionError), Invalid(#[from] zebra_consensus::error::TransactionError),
} }

View File

@ -23,7 +23,9 @@ pub enum MempoolError {
/// ///
/// Note that the mempool caches this error. See [`super::storage::Storage`] /// Note that the mempool caches this error. See [`super::storage::Storage`]
/// for more details. /// for more details.
#[error("the transaction will be rejected from the mempool until the next chain tip block")] #[error(
"the transaction will be rejected from the mempool until the next chain tip block: {0}"
)]
StorageExactTip(#[from] ExactTipRejectionError), StorageExactTip(#[from] ExactTipRejectionError),
/// Transaction rejected based on its effects (spends, outputs, transaction /// Transaction rejected based on its effects (spends, outputs, transaction
@ -33,7 +35,7 @@ pub enum MempoolError {
/// ///
/// Note that the mempool caches this error. See [`super::storage::Storage`] /// Note that the mempool caches this error. See [`super::storage::Storage`]
/// for more details. /// for more details.
#[error("any transaction with the same effects will be rejected from the mempool until the next chain tip block")] #[error("any transaction with the same effects will be rejected from the mempool until the next chain tip block: {0}")]
StorageEffectsTip(#[from] SameEffectsTipRejectionError), StorageEffectsTip(#[from] SameEffectsTipRejectionError),
/// Transaction rejected based on its effects (spends, outputs, transaction /// Transaction rejected based on its effects (spends, outputs, transaction
@ -44,7 +46,7 @@ pub enum MempoolError {
/// ///
/// Note that the mempool caches this error. See [`super::storage::Storage`] /// Note that the mempool caches this error. See [`super::storage::Storage`]
/// for more details. /// for more details.
#[error("any transaction with the same effects will be rejected from the mempool until a chain reset")] #[error("any transaction with the same effects will be rejected from the mempool until a chain reset: {0}")]
StorageEffectsChain(#[from] SameEffectsChainRejectionError), StorageEffectsChain(#[from] SameEffectsChainRejectionError),
/// Transaction rejected because the mempool already contains another /// Transaction rejected because the mempool already contains another

View File

@ -55,7 +55,7 @@ pub(crate) const MAX_EVICTION_MEMORY_ENTRIES: usize = 40_000;
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))] #[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
#[allow(dead_code)] #[allow(dead_code)]
pub enum ExactTipRejectionError { pub enum ExactTipRejectionError {
#[error("transaction did not pass consensus validation")] #[error("transaction did not pass consensus validation: {0}")]
FailedVerification(#[from] zebra_consensus::error::TransactionError), FailedVerification(#[from] zebra_consensus::error::TransactionError),
} }