1use std::{path::PathBuf, sync::Arc};
4
5use chrono::{DateTime, Utc};
6use derive_new::new;
7use thiserror::Error;
8
9use tokio::sync::broadcast::error::RecvError;
10use zebra_chain::{
11 amount::{self, NegativeAllowed, NonNegative},
12 block,
13 history_tree::HistoryTreeError,
14 ironwood, orchard, sapling, sprout, transaction, transparent,
15 value_balance::{ValueBalance, ValueBalanceError},
16 work::difficulty::CompactDifficulty,
17};
18
19use crate::{constants::MIN_TRANSPARENT_COINBASE_MATURITY, HashOrHeight, KnownBlock};
20
21#[derive(Debug, Error, Clone)]
24#[error(transparent)]
25pub struct CloneError {
26 source: Arc<dyn std::error::Error + Send + Sync + 'static>,
27}
28
29impl From<CommitSemanticallyVerifiedError> for CloneError {
30 fn from(source: CommitSemanticallyVerifiedError) -> Self {
31 let source = Arc::new(source);
32 Self { source }
33 }
34}
35
36impl From<BoxError> for CloneError {
37 fn from(source: BoxError) -> Self {
38 let source = Arc::from(source);
39 Self { source }
40 }
41}
42
43pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
45
46#[derive(Debug, Error, Clone, PartialEq, Eq)]
51pub enum BlockReadError {
52 #[error("block body unavailable at height {height:?}: stored transactions are incomplete")]
54 BlockBodyUnavailable {
55 height: block::Height,
57 },
58
59 #[error("corrupt block metadata at height {height:?}")]
61 CorruptBlock {
62 height: block::Height,
64 },
65}
66
67#[derive(Debug, Error)]
72#[non_exhaustive]
73pub enum StateInitError {
74 #[error(
81 "cannot open read-only state: cache directory {path:?} is missing or unreadable. \
82 Hint: a read-only state requires an existing Zebra cache directory; check that the \
83 state cache_dir in the Zebra config points at a running Zebra node's cache directory"
84 )]
85 ReadOnlyCacheDirUnreadable {
86 path: PathBuf,
88 source: std::io::Error,
90 },
91
92 #[error(
98 "cannot open read-only state: no database found at {path:?}. \
99 Hint: a read-only state requires an existing finalized database created by a running \
100 Zebra node; check that the state cache_dir in the Zebra config points at that node's \
101 cache directory"
102 )]
103 ReadOnlyDatabaseNotFound {
104 path: PathBuf,
106 },
107
108 #[error(
114 "cannot open read-only state: an ephemeral database was also requested. \
115 Hint: a read-only state follows an existing Zebra node's database and must not \
116 delete it; set `ephemeral = false`, or do not request a read-only state"
117 )]
118 ReadOnlyEphemeralConflict,
119}
120
121#[derive(Debug, Error, Clone, PartialEq, Eq, new)]
123pub enum CommitBlockError {
124 #[error("block hash is a duplicate: already in {location}")]
125 Duplicate {
127 hash_or_height: Option<HashOrHeight>,
129 location: KnownBlock,
131 },
132
133 #[error("could not contextually validate semantically verified block")]
135 ValidateContextError(#[from] Box<ValidateContextError>),
136
137 #[error("block commit task exited. Is Zebra shutting down?")]
139 #[non_exhaustive]
140 WriteTaskExited,
141
142 #[error("block was dropped from the full queue of blocks waiting for their parent blocks")]
145 OrphanQueueFull,
146}
147
148impl CommitBlockError {
149 pub fn is_duplicate_request(&self) -> bool {
152 matches!(self, CommitBlockError::Duplicate { .. })
153 }
154
155 pub fn is_auth_commitment_mismatch(&self) -> bool {
163 match self {
164 CommitBlockError::ValidateContextError(err) => err.is_auth_commitment_mismatch(),
165 CommitBlockError::Duplicate { .. }
166 | CommitBlockError::WriteTaskExited
167 | CommitBlockError::OrphanQueueFull => false,
168 }
169 }
170
171 pub fn is_descendant_of_auth_commitment_mismatch(&self) -> bool {
176 match self {
177 CommitBlockError::ValidateContextError(err) => {
178 err.is_descendant_of_auth_commitment_mismatch()
179 }
180 CommitBlockError::Duplicate { .. }
181 | CommitBlockError::WriteTaskExited
182 | CommitBlockError::OrphanQueueFull => false,
183 }
184 }
185
186 pub fn misbehavior_score(&self) -> u32 {
191 match self {
192 CommitBlockError::ValidateContextError(err) => err.misbehavior_score(),
193 CommitBlockError::Duplicate { .. }
194 | CommitBlockError::WriteTaskExited
195 | CommitBlockError::OrphanQueueFull => 0,
196 }
197 }
198}
199
200#[derive(Debug, Error, Clone, PartialEq, Eq)]
202#[error("could not commit semantically-verified block")]
203pub struct CommitSemanticallyVerifiedError(#[from] CommitBlockError);
204
205impl CommitSemanticallyVerifiedError {
206 pub fn inner(&self) -> &CommitBlockError {
208 &self.0
209 }
210}
211
212impl From<ValidateContextError> for CommitSemanticallyVerifiedError {
213 fn from(value: ValidateContextError) -> Self {
214 Self(CommitBlockError::ValidateContextError(Box::new(value)))
215 }
216}
217
218#[derive(Debug, Error)]
219pub enum LayeredStateError<E: std::error::Error + std::fmt::Display> {
220 #[error("{0}")]
221 State(E),
222 #[error("{0}")]
223 Layer(BoxError),
224}
225
226impl<E: std::error::Error + 'static> From<BoxError> for LayeredStateError<E> {
227 fn from(err: BoxError) -> Self {
228 match err.downcast::<E>() {
229 Ok(state_err) => Self::State(*state_err),
230 Err(layer_error) => Self::Layer(layer_error),
231 }
232 }
233}
234
235#[derive(Debug, Error, Clone)]
237#[error("could not commit checkpoint-verified block")]
238pub struct CommitCheckpointVerifiedError(#[from] CommitBlockError);
239
240impl CommitCheckpointVerifiedError {
241 pub fn inner(&self) -> &CommitBlockError {
243 &self.0
244 }
245}
246
247impl From<ValidateContextError> for CommitCheckpointVerifiedError {
248 fn from(value: ValidateContextError) -> Self {
249 Self(CommitBlockError::ValidateContextError(Box::new(value)))
250 }
251}
252
253#[derive(Debug, Error)]
255#[non_exhaustive]
256pub enum InvalidateError {
257 #[error("cannot invalidate blocks while still committing checkpointed blocks")]
259 ProcessingCheckpointedBlocks,
260
261 #[error("failed to send invalidate block request to block write task")]
263 SendInvalidateRequestFailed,
264
265 #[error("invalidate block request was unexpectedly dropped")]
267 InvalidateRequestDropped,
268
269 #[error("block hash {0} not found in any non-finalized chain")]
271 BlockNotFound(block::Hash),
272
273 #[error("cannot invalidate block {0}: it is the root of the only non-finalized chain")]
275 OnlyChainRoot(block::Hash),
276}
277
278#[derive(Debug, Error)]
280#[non_exhaustive]
281pub enum ReconsiderError {
282 #[error("Block with hash {0} was not previously invalidated")]
284 MissingInvalidatedBlock(block::Hash),
285
286 #[error("Parent chain not found for block {0}")]
288 ParentChainNotFound(block::Hash),
289
290 #[error("Invalidated blocks list is empty when it should contain at least one block")]
292 InvalidatedBlocksEmpty,
293
294 #[error("cannot reconsider blocks while still committing checkpointed blocks")]
296 CheckpointCommitInProgress,
297
298 #[error("failed to send reconsider block request to block write task")]
300 ReconsiderSendFailed,
301
302 #[error("reconsider block request was unexpectedly dropped")]
304 ReconsiderResponseDropped,
305
306 #[error("replaying a previously invalidated block failed contextual validation: {0}")]
309 ReplayFailed(#[source] ValidateContextError),
310}
311
312#[derive(Debug, Error)]
314#[non_exhaustive]
315pub enum AwaitUtxoError {
316 #[error("the state stopped responding before the UTXO arrived")]
319 Cancelled,
320
321 #[error("internal channel error while waiting for the UTXO: receiver lagged by {0}")]
323 Lagged(u64),
324
325 #[error("the read state service returned an error: {0}")]
327 ReadStateFailed(#[source] BoxError),
328}
329
330impl From<RecvError> for AwaitUtxoError {
331 fn from(err: RecvError) -> Self {
332 match err {
333 RecvError::Closed => AwaitUtxoError::Cancelled,
334 RecvError::Lagged(skipped) => AwaitUtxoError::Lagged(skipped),
335 }
336 }
337}
338
339#[derive(Debug, Error, Clone, PartialEq, Eq)]
341#[non_exhaustive]
342#[allow(missing_docs)]
343pub enum ValidateContextError {
344 #[error("block hash {block_hash} was previously invalidated")]
345 #[non_exhaustive]
346 BlockPreviouslyInvalidated { block_hash: block::Hash },
347
348 #[error("block parent not found in any chain, or not enough blocks in chain")]
349 #[non_exhaustive]
350 NotReadyToBeCommitted,
351
352 #[error("block height {candidate_height:?} is lower than the current finalized height {finalized_tip_height:?}")]
353 #[non_exhaustive]
354 OrphanedBlock {
355 candidate_height: block::Height,
356 finalized_tip_height: block::Height,
357 },
358
359 #[error("block height {candidate_height:?} is not one greater than its parent block's height {parent_height:?}")]
360 #[non_exhaustive]
361 NonSequentialBlock {
362 candidate_height: block::Height,
363 parent_height: block::Height,
364 },
365
366 #[error("block height {candidate_height:?} is not one greater than its finalized parent block's height {parent_height:?}")]
367 #[non_exhaustive]
368 NonSequentialFinalizedChild {
369 candidate_height: block::Height,
370 parent_height: block::Height,
371 },
372
373 #[error("block time {candidate_time:?} is less than or equal to the median-time-past for the block {median_time_past:?}")]
374 #[non_exhaustive]
375 TimeTooEarly {
376 candidate_time: DateTime<Utc>,
377 median_time_past: DateTime<Utc>,
378 },
379
380 #[error("block time {candidate_time:?} is greater than the median-time-past for the block plus 90 minutes {block_time_max:?}")]
381 #[non_exhaustive]
382 TimeTooLate {
383 candidate_time: DateTime<Utc>,
384 block_time_max: DateTime<Utc>,
385 },
386
387 #[error("block difficulty threshold {difficulty_threshold:?} is not equal to the expected difficulty for the block {expected_difficulty:?}")]
388 #[non_exhaustive]
389 InvalidDifficultyThreshold {
390 difficulty_threshold: CompactDifficulty,
391 expected_difficulty: CompactDifficulty,
392 },
393
394 #[error("transparent double-spend: {outpoint:?} is spent twice in {location:?}")]
395 #[non_exhaustive]
396 DuplicateTransparentSpend {
397 outpoint: transparent::OutPoint,
398 location: &'static str,
399 },
400
401 #[error("missing transparent output: possible double-spend of {outpoint:?} in {location:?}")]
402 #[non_exhaustive]
403 MissingTransparentOutput {
404 outpoint: transparent::OutPoint,
405 location: &'static str,
406 },
407
408 #[error("out-of-order transparent spend: {outpoint:?} is created by a later transaction in the same block")]
409 #[non_exhaustive]
410 EarlyTransparentSpend { outpoint: transparent::OutPoint },
411
412 #[error(
413 "unshielded transparent coinbase spend: {outpoint:?} \
414 must be spent in a transaction which only has shielded outputs"
415 )]
416 #[non_exhaustive]
417 UnshieldedTransparentCoinbaseSpend { outpoint: transparent::OutPoint },
418
419 #[error(
420 "immature transparent coinbase spend: \
421 attempt to spend {outpoint:?} at {spend_height:?}, \
422 but spends are invalid before {min_spend_height:?}, \
423 which is {MIN_TRANSPARENT_COINBASE_MATURITY:?} blocks \
424 after it was created at {created_height:?}"
425 )]
426 #[non_exhaustive]
427 ImmatureTransparentCoinbaseSpend {
428 outpoint: transparent::OutPoint,
429 spend_height: block::Height,
430 min_spend_height: block::Height,
431 created_height: block::Height,
432 },
433
434 #[error("sprout double-spend: duplicate nullifier: {nullifier:?}, in finalized state: {in_finalized_state:?}")]
435 #[non_exhaustive]
436 DuplicateSproutNullifier {
437 nullifier: sprout::Nullifier,
438 in_finalized_state: bool,
439 },
440
441 #[error("sapling double-spend: duplicate nullifier: {nullifier:?}, in finalized state: {in_finalized_state:?}")]
442 #[non_exhaustive]
443 DuplicateSaplingNullifier {
444 nullifier: sapling::Nullifier,
445 in_finalized_state: bool,
446 },
447
448 #[error("orchard double-spend: duplicate nullifier: {nullifier:?}, in finalized state: {in_finalized_state:?}")]
449 #[non_exhaustive]
450 DuplicateOrchardNullifier {
451 nullifier: orchard::Nullifier,
452 in_finalized_state: bool,
453 },
454
455 #[error("ironwood double-spend: duplicate nullifier: {nullifier:?}, in finalized state: {in_finalized_state:?}")]
456 #[non_exhaustive]
457 DuplicateIronwoodNullifier {
458 nullifier: ironwood::Nullifier,
459 in_finalized_state: bool,
460 },
461
462 #[error(
463 "the remaining value in the transparent transaction value pool MUST be nonnegative:\n\
464 {amount_error:?},\n\
465 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
466 )]
467 #[non_exhaustive]
468 NegativeRemainingTransactionValue {
469 amount_error: amount::Error,
470 height: block::Height,
471 tx_index_in_block: usize,
472 transaction_hash: transaction::Hash,
473 },
474
475 #[error(
476 "error calculating the remaining value in the transaction value pool:\n\
477 {amount_error:?},\n\
478 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
479 )]
480 #[non_exhaustive]
481 CalculateRemainingTransactionValue {
482 amount_error: amount::Error,
483 height: block::Height,
484 tx_index_in_block: usize,
485 transaction_hash: transaction::Hash,
486 },
487
488 #[error(
489 "error calculating value balances for the remaining value in the transaction value pool:\n\
490 {value_balance_error:?},\n\
491 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
492 )]
493 #[non_exhaustive]
494 CalculateTransactionValueBalances {
495 value_balance_error: ValueBalanceError,
496 height: block::Height,
497 tx_index_in_block: usize,
498 transaction_hash: transaction::Hash,
499 },
500
501 #[error(
502 "error calculating the block chain value pool change:\n\
503 {value_balance_error:?},\n\
504 {height:?}, {block_hash:?},\n\
505 transactions: {transaction_count:?}, spent UTXOs: {spent_utxo_count:?}"
506 )]
507 #[non_exhaustive]
508 CalculateBlockChainValueChange {
509 value_balance_error: ValueBalanceError,
510 height: block::Height,
511 block_hash: block::Hash,
512 transaction_count: usize,
513 spent_utxo_count: usize,
514 },
515
516 #[error(
517 "error adding value balances to the chain value pool:\n\
518 {value_balance_error:?},\n\
519 {chain_value_pools:?},\n\
520 {block_value_pool_change:?},\n\
521 {height:?}"
522 )]
523 #[non_exhaustive]
524 AddValuePool {
525 value_balance_error: ValueBalanceError,
526 chain_value_pools: Box<ValueBalance<NonNegative>>,
527 block_value_pool_change: Box<ValueBalance<NegativeAllowed>>,
528 height: Option<block::Height>,
529 },
530
531 #[error(
532 "invalid block subsidy, funding stream, or miner fee payment in block {block_hash:?} at \
533 {height:?}: {subsidy_error}"
534 )]
535 #[non_exhaustive]
536 InvalidSubsidy {
537 subsidy_error: zebra_chain::parameters::subsidy::CoinbaseTransactionError,
538 height: block::Height,
539 block_hash: block::Hash,
540 },
541
542 #[error("error updating a note commitment tree: {0}")]
543 NoteCommitmentTreeError(#[from] zebra_chain::parallel::tree::NoteCommitmentTreeError),
544
545 #[error("error building the history tree: {0}")]
546 HistoryTreeError(#[from] Arc<HistoryTreeError>),
547
548 #[error("block contains an invalid commitment: {0}")]
549 InvalidBlockCommitment(#[from] block::CommitmentError),
550
551 #[error(
552 "unknown Sprout anchor: {anchor:?},\n\
553 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
554 )]
555 #[non_exhaustive]
556 UnknownSproutAnchor {
557 anchor: sprout::tree::Root,
558 height: Option<block::Height>,
559 tx_index_in_block: Option<usize>,
560 transaction_hash: transaction::Hash,
561 },
562
563 #[error(
564 "unknown Sapling anchor: {anchor:?},\n\
565 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
566 )]
567 #[non_exhaustive]
568 UnknownSaplingAnchor {
569 anchor: sapling::tree::Root,
570 height: Option<block::Height>,
571 tx_index_in_block: Option<usize>,
572 transaction_hash: transaction::Hash,
573 },
574
575 #[error(
576 "unknown Orchard anchor: {anchor:?},\n\
577 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
578 )]
579 #[non_exhaustive]
580 UnknownOrchardAnchor {
581 anchor: orchard::tree::Root,
582 height: Option<block::Height>,
583 tx_index_in_block: Option<usize>,
584 transaction_hash: transaction::Hash,
585 },
586
587 #[error(
588 "unknown Ironwood anchor: {anchor:?},\n\
589 {height:?}, index in block: {tx_index_in_block:?}, {transaction_hash:?}"
590 )]
591 #[non_exhaustive]
592 UnknownIronwoodAnchor {
593 anchor: orchard::tree::Root,
595 height: Option<block::Height>,
596 tx_index_in_block: Option<usize>,
597 transaction_hash: transaction::Hash,
598 },
599
600 #[error("ancestor block {ancestor_hash} failed contextual validation")]
607 #[non_exhaustive]
608 AncestorRejected {
609 ancestor_hash: block::Hash,
610 source: Box<ValidateContextError>,
611 },
612}
613
614impl ValidateContextError {
615 pub fn is_auth_commitment_mismatch(&self) -> bool {
624 matches!(
625 self,
626 ValidateContextError::InvalidBlockCommitment(
627 block::CommitmentError::InvalidChainHistoryBlockTxAuthCommitment { .. },
628 )
629 )
630 }
631
632 pub fn is_descendant_of_auth_commitment_mismatch(&self) -> bool {
639 matches!(
640 self,
641 ValidateContextError::AncestorRejected { source, .. }
642 if source.is_auth_commitment_mismatch()
643 )
644 }
645
646 pub fn for_descendant(&self, ancestor_hash: block::Hash) -> Self {
650 match self {
651 ValidateContextError::AncestorRejected { .. } => self.clone(),
653 _ => ValidateContextError::AncestorRejected {
654 ancestor_hash,
655 source: Box::new(self.clone()),
656 },
657 }
658 }
659
660 pub fn misbehavior_score(&self) -> u32 {
662 match self {
663 ValidateContextError::InvalidBlockCommitment(
666 block::CommitmentError::InvalidChainHistoryBlockTxAuthCommitment { .. },
667 ) => 100,
668 ValidateContextError::InvalidSubsidy { .. } => 100,
671 ValidateContextError::NonSequentialFinalizedChild { .. } => 100,
673 _other => 0,
674 }
675 }
676}
677
678impl From<sprout::tree::NoteCommitmentTreeError> for ValidateContextError {
679 fn from(value: sprout::tree::NoteCommitmentTreeError) -> Self {
680 ValidateContextError::NoteCommitmentTreeError(value.into())
681 }
682}
683
684pub trait DuplicateNullifierError {
686 fn duplicate_nullifier_error(&self, in_finalized_state: bool) -> ValidateContextError;
688}
689
690impl DuplicateNullifierError for sprout::Nullifier {
691 fn duplicate_nullifier_error(&self, in_finalized_state: bool) -> ValidateContextError {
692 ValidateContextError::DuplicateSproutNullifier {
693 nullifier: *self,
694 in_finalized_state,
695 }
696 }
697}
698
699impl DuplicateNullifierError for sapling::Nullifier {
700 fn duplicate_nullifier_error(&self, in_finalized_state: bool) -> ValidateContextError {
701 ValidateContextError::DuplicateSaplingNullifier {
702 nullifier: *self,
703 in_finalized_state,
704 }
705 }
706}
707
708impl DuplicateNullifierError for orchard::Nullifier {
709 fn duplicate_nullifier_error(&self, in_finalized_state: bool) -> ValidateContextError {
710 ValidateContextError::DuplicateOrchardNullifier {
711 nullifier: *self,
712 in_finalized_state,
713 }
714 }
715}
716
717impl DuplicateNullifierError for ironwood::Nullifier {
718 fn duplicate_nullifier_error(&self, in_finalized_state: bool) -> ValidateContextError {
719 ValidateContextError::DuplicateIronwoodNullifier {
720 nullifier: *self,
721 in_finalized_state,
722 }
723 }
724}
725
726#[cfg(test)]
727mod tests {
728 use super::*;
729 use zebra_chain::block::Height;
730
731 #[test]
732 fn commit_block_error_misbehavior_scores() {
733 let context_err = CommitBlockError::ValidateContextError(Box::new(
734 ValidateContextError::NonSequentialBlock {
735 candidate_height: Height(5),
736 parent_height: Height(3),
737 },
738 ));
739 assert_eq!(context_err.misbehavior_score(), 0);
740
741 let dup_err = CommitBlockError::Duplicate {
742 hash_or_height: None,
743 location: KnownBlock::BestChain,
744 };
745 assert_eq!(dup_err.misbehavior_score(), 0);
746
747 let auth_commitment_err = CommitBlockError::ValidateContextError(Box::new(
750 ValidateContextError::InvalidBlockCommitment(
751 block::CommitmentError::InvalidChainHistoryBlockTxAuthCommitment {
752 expected: [1; 32],
753 actual: [2; 32],
754 },
755 ),
756 ));
757 assert_eq!(auth_commitment_err.misbehavior_score(), 100);
758 }
759
760 #[test]
764 fn descendant_errors_are_not_scored() {
765 let auth_commitment_err = ValidateContextError::InvalidBlockCommitment(
766 block::CommitmentError::InvalidChainHistoryBlockTxAuthCommitment {
767 expected: [1; 32],
768 actual: [2; 32],
769 },
770 );
771 let forged_hash = block::Hash([1; 32]);
772
773 let child_err = auth_commitment_err.for_descendant(forged_hash);
774 assert_eq!(child_err.misbehavior_score(), 0);
775 assert!(!child_err.is_auth_commitment_mismatch());
776 assert!(child_err.is_descendant_of_auth_commitment_mismatch());
777
778 let grandchild_err = child_err.for_descendant(block::Hash([2; 32]));
780 assert_eq!(grandchild_err, child_err);
781
782 let commit_err = CommitBlockError::ValidateContextError(Box::new(child_err));
783 assert_eq!(commit_err.misbehavior_score(), 0);
784 assert!(!commit_err.is_auth_commitment_mismatch());
785 assert!(commit_err.is_descendant_of_auth_commitment_mismatch());
786
787 let other_child_err = ValidateContextError::NonSequentialBlock {
789 candidate_height: Height(5),
790 parent_height: Height(3),
791 }
792 .for_descendant(forged_hash);
793 assert_eq!(other_child_err.misbehavior_score(), 0);
794 assert!(!other_child_err.is_descendant_of_auth_commitment_mismatch());
795 }
796
797 #[test]
798 fn invalid_subsidy_commit_error_misbehavior_score() {
799 use zebra_chain::parameters::subsidy::{CoinbaseTransactionError, SubsidyError};
800
801 let invalid_subsidy = ValidateContextError::InvalidSubsidy {
802 subsidy_error: CoinbaseTransactionError::Subsidy(SubsidyError::InvalidMinerFees),
803 height: Height(5),
804 block_hash: zebra_chain::block::Hash([0; 32]),
805 };
806 let descendant = invalid_subsidy.for_descendant(block::Hash([1; 32]));
807 assert_eq!(descendant.misbehavior_score(), 0);
808 assert!(!descendant.is_descendant_of_auth_commitment_mismatch());
809 let subsidy_err = CommitBlockError::ValidateContextError(Box::new(invalid_subsidy));
810 assert_eq!(subsidy_err.misbehavior_score(), 100);
811 }
812}