kaspa_consensus_core/errors/
pruning.rs1use crate::BlockLevel;
2
3use super::{block::RuleError, tx::TxRuleError};
4use kaspa_hashes::Hash;
5use thiserror::Error;
6
7#[derive(Error, Debug, Clone)]
8pub enum PruningImportError {
9 #[error("pruning proof validation failed")]
10 ProofValidationError,
11
12 #[error("pruning proof doesn't have {0} levels")]
13 ProofNotEnoughLevels(usize),
14
15 #[error("block {0} level is {1} when it's expected to be at least {2}")]
16 PruningProofWrongBlockLevel(Hash, BlockLevel, BlockLevel),
17
18 #[error("the proof header {0} is missing known parents at level {1}")]
19 PruningProofHeaderWithNoKnownParents(Hash, BlockLevel),
20
21 #[error("proof level {0} is missing the block at depth m in level {1}")]
22 PruningProofMissingBlockAtDepthMFromNextLevel(BlockLevel, BlockLevel),
23
24 #[error("the selected tip {0} at level {1} is not a parent of the pruning point")]
25 PruningProofMissesBlocksBelowPruningPoint(Hash, BlockLevel),
26
27 #[error("the pruning proof selected tip {0} at level {1} is not the pruning point")]
28 PruningProofSelectedTipIsNotThePruningPoint(Hash, BlockLevel),
29
30 #[error("the pruning proof selected tip {0} at level {1} is not a parent of the pruning point on the same level")]
31 PruningProofSelectedTipNotParentOfPruningPoint(Hash, BlockLevel),
32
33 #[error("the proof doesn't have sufficient blue work in order to replace the current DAG")]
34 PruningProofInsufficientBlueWork,
35
36 #[error("the pruning proof doesn't have any shared blocks with the known DAGs, but doesn't have enough headers from levels higher than the existing block levels.")]
37 PruningProofNotEnoughHeaders,
38
39 #[error("block {0} already appeared in the proof headers for level {1}")]
40 PruningProofDuplicateHeaderAtLevel(Hash, BlockLevel),
41
42 #[error("got header-only trusted block {0} which is not in pruning point past according to available reachability")]
43 PruningPointPastMissingReachability(Hash),
44
45 #[error("new pruning point has an invalid transaction {0}: {1}")]
46 NewPruningPointTxError(Hash, TxRuleError),
47
48 #[error("new pruning point has some invalid transactions")]
49 NewPruningPointTxErrors,
50
51 #[error("new pruning point transaction {0} is missing a UTXO entry")]
52 NewPruningPointTxMissingUTXOEntry(Hash),
53
54 #[error("the imported multiset hash was expected to be {0} and was actually {1}")]
55 ImportedMultisetHashMismatch(Hash, Hash),
56
57 #[error("pruning import data lead to validation rule error")]
58 PruningImportRuleError(#[from] RuleError),
59
60 #[error("process exit was initiated while validating pruning point proof")]
61 PruningValidationInterrupted,
62}
63
64pub type PruningImportResult<T> = std::result::Result<T, PruningImportError>;