use neptune_mutator_set::removal_record::removal_record_list::RemovalRecordListUnpackError;
use crate::type_scripts::native_currency_amount::NativeCurrencyAmount;
#[derive(Debug, Clone, Copy, thiserror::Error, PartialEq, Eq)]
pub enum BlockValidationError {
#[error("block height must equal that of predecessor plus one")]
BlockHeight,
#[error("block header must point to predecessor block")]
PrevBlockDigest,
#[error("block mmr must contain predecessor digest")]
BlockMmrUpdate,
#[error("block timestamp must be later than predecessor in excess of minimum block time")]
MinimumBlockTime,
#[error("target difficulty must be updated correctly")]
Difficulty,
#[error("block cumulative proof-of-work must be updated correctly")]
CumulativeProofOfWork,
#[error("block must not be from the future")]
FutureDating,
#[error("block appendix must contain expected claims")]
AppendixMissingClaim,
#[error("block appendix cannot contain too many claims")]
AppendixTooLarge,
#[error("block proof must be SingleProof")]
ProofQuality,
#[error("block proof must be valid")]
ProofValidity,
#[error("block must not exceed max size")]
MaxSize,
#[error("Version in pow field and in header must match")]
VersionMismatch,
#[error("cannot unpack removal records")]
RemovalRecordsUnpackFailure,
#[error("all removal records must be valid relative to predecessor block's mutator set")]
RemovalRecordsValidity,
#[error("all removal records must be unique")]
RemovalRecordsUniqueness,
#[error("mutator set update must be possible")]
MutatorSetUpdateImpossible,
#[error("mutator set must evolve in accordance with transaction")]
MutatorSetUpdateIntegrity,
#[error("transaction timestamp must not exceed block timestamp, nor be too old")]
TransactionTimestamp,
#[error("coinbase cannot exceed block subsidy")]
CoinbaseTooBig,
#[error("coinbase cannot be negative")]
NegativeCoinbase,
#[error("fee must be non-negative")]
NegativeFee,
#[error("number of inputs may not be too large")]
TooManyInputs,
#[error("number of outputs may not be too large")]
TooManyOutputs,
#[error("number of announcements may not be too large")]
TooManyAnnouncements,
#[error("Could not parse lustration counter")]
BadLustrationCounterEncoding,
#[error("Could not parse lustration counter of parent")]
BadLustrationCounterEncodingOfParent,
#[error("Missing lustration announcement in transaction kernel")]
MissingLustrationAnnouncement,
#[error("Lustration barrier must be correctly updated. Got {got}, expected: {expected}")]
BadLustrationCounter {
got: NativeCurrencyAmount,
expected: NativeCurrencyAmount,
},
#[error(
"Lustration AOCL leaf index threshold must set correctly. Got {got}, expected: {expected}."
)]
BadLustrationAoclThreshold { got: u64, expected: u64 },
#[error("Negative lustration counter: {got}")]
NegativeLustrationCounter { got: NativeCurrencyAmount },
#[error("Lustration counter exceeds initial value. Got: {got}, initial: {initial}")]
LustrationCounterExceedsInitialValue {
got: NativeCurrencyAmount,
initial: NativeCurrencyAmount,
},
#[error("Unknown lustration problem. This should not happen.")]
UnknownLustrationProblem,
#[error("Transaction mutator set must match parent block")]
TransactionMutatorSetMismatch,
}
impl From<RemovalRecordListUnpackError> for BlockValidationError {
fn from(_: RemovalRecordListUnpackError) -> Self {
Self::RemovalRecordsUnpackFailure
}
}