Skip to content

Commit a48307b

Browse files
authored
CoreIndexMismatch: Include more information in the error (#9396)
1 parent aa010dc commit a48307b

File tree

1 file changed

+15
-4
lines changed
  • polkadot/primitives/src/vstaging

1 file changed

+15
-4
lines changed

polkadot/primitives/src/vstaging/mod.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,14 @@ pub enum CommittedCandidateReceiptError {
594594
/// The core index in commitments doesn't match the one in descriptor
595595
#[cfg_attr(
596596
feature = "std",
597-
error("The core index in commitments doesn't match the one in descriptor")
597+
error("The core index in commitments ({commitments:?}) doesn't match the one in descriptor ({descriptor:?})")
598598
)]
599-
CoreIndexMismatch,
599+
CoreIndexMismatch {
600+
/// The core index as found in the descriptor.
601+
descriptor: CoreIndex,
602+
/// The core index as found in the commitments.
603+
commitments: CoreIndex,
604+
},
600605
/// The core selector or claim queue offset is invalid.
601606
#[cfg_attr(feature = "std", error("The core selector or claim queue offset is invalid"))]
602607
InvalidSelectedCore,
@@ -787,7 +792,10 @@ impl<H: Copy> CommittedCandidateReceiptV2<H> {
787792
.copied()?;
788793

789794
if core_index != descriptor_core_index {
790-
return Err(CommittedCandidateReceiptError::CoreIndexMismatch)
795+
return Err(CommittedCandidateReceiptError::CoreIndexMismatch {
796+
descriptor: descriptor_core_index,
797+
commitments: core_index,
798+
})
791799
}
792800

793801
Ok(())
@@ -1368,7 +1376,10 @@ mod candidate_receipt_tests {
13681376
new_ccr.descriptor.set_core_index(CoreIndex(1));
13691377
assert_eq!(
13701378
new_ccr.parse_ump_signals(&cq),
1371-
Err(CommittedCandidateReceiptError::CoreIndexMismatch)
1379+
Err(CommittedCandidateReceiptError::CoreIndexMismatch {
1380+
descriptor: CoreIndex(1),
1381+
commitments: CoreIndex(0),
1382+
})
13721383
);
13731384
}
13741385

0 commit comments

Comments
 (0)