@@ -539,7 +539,28 @@ RejectCodeTypePrefix {
539
539
/// The block was rejected due to a mismatch with expected sortition view
540
540
SortitionViewMismatch = 4 ,
541
541
/// The block was rejected due to a testing directive
542
- TestingDirective = 5
542
+ TestingDirective = 5 ,
543
+ /// The block attempted to reorg the previous tenure but was not allowed
544
+ ReorgNotAllowed = 6 ,
545
+ /// The bitvec field does not match what is expected
546
+ InvalidBitvec = 7 ,
547
+ /// The miner's pubkey hash does not match the winning pubkey hash
548
+ PubkeyHashMismatch = 8 ,
549
+ /// The miner has been marked as invalid
550
+ InvalidMiner = 9 ,
551
+ /// Miner is last sortition winner, when the current sortition winner is
552
+ /// still valid
553
+ NotLatestSortitionWinner = 10 ,
554
+ /// The block does not confirm the expected parent block
555
+ InvalidParentBlock = 11 ,
556
+ /// The block does not confirm the expected parent tenure
557
+ InvalidParentTenure = 12 ,
558
+ /// The block contains a block found tenure change, but we've already seen
559
+ /// a block found
560
+ DuplicateBlockFound = 13 ,
561
+ /// The block attempted a tenure extend but the burn view has not changed
562
+ /// and not enough time has passed for a time-based tenure extend
563
+ InvalidTenureExtend = 14
543
564
} ) ;
544
565
545
566
impl TryFrom < u8 > for RejectCodeTypePrefix {
@@ -555,11 +576,20 @@ impl From<&RejectCode> for RejectCodeTypePrefix {
555
576
fn from ( reject_code : & RejectCode ) -> Self {
556
577
match reject_code {
557
578
RejectCode :: ValidationFailed ( _) => RejectCodeTypePrefix :: ValidationFailed ,
558
- RejectCode :: ConnectivityIssues => RejectCodeTypePrefix :: ConnectivityIssues ,
579
+ RejectCode :: ConnectivityIssues ( _ ) => RejectCodeTypePrefix :: ConnectivityIssues ,
559
580
RejectCode :: RejectedInPriorRound => RejectCodeTypePrefix :: RejectedInPriorRound ,
560
581
RejectCode :: NoSortitionView => RejectCodeTypePrefix :: NoSortitionView ,
561
582
RejectCode :: SortitionViewMismatch => RejectCodeTypePrefix :: SortitionViewMismatch ,
562
583
RejectCode :: TestingDirective => RejectCodeTypePrefix :: TestingDirective ,
584
+ RejectCode :: ReorgNotAllowed => RejectCodeTypePrefix :: ReorgNotAllowed ,
585
+ RejectCode :: InvalidBitvec => RejectCodeTypePrefix :: InvalidBitvec ,
586
+ RejectCode :: PubkeyHashMismatch => RejectCodeTypePrefix :: PubkeyHashMismatch ,
587
+ RejectCode :: InvalidMiner => RejectCodeTypePrefix :: InvalidMiner ,
588
+ RejectCode :: NotLatestSortitionWinner => RejectCodeTypePrefix :: NotLatestSortitionWinner ,
589
+ RejectCode :: InvalidParentBlock => RejectCodeTypePrefix :: InvalidParentBlock ,
590
+ RejectCode :: InvalidParentTenure => RejectCodeTypePrefix :: InvalidParentTenure ,
591
+ RejectCode :: DuplicateBlockFound => RejectCodeTypePrefix :: DuplicateBlockFound ,
592
+ RejectCode :: InvalidTenureExtend => RejectCodeTypePrefix :: InvalidTenureExtend ,
563
593
}
564
594
}
565
595
}
@@ -572,13 +602,34 @@ pub enum RejectCode {
572
602
/// No Sortition View to verify against
573
603
NoSortitionView ,
574
604
/// The block was rejected due to connectivity issues with the signer
575
- ConnectivityIssues ,
605
+ ConnectivityIssues ( String ) ,
576
606
/// The block was rejected in a prior round
577
607
RejectedInPriorRound ,
578
608
/// The block was rejected due to a mismatch with expected sortition view
579
609
SortitionViewMismatch ,
580
610
/// The block was rejected due to a testing directive
581
611
TestingDirective ,
612
+ /// The block attempted to reorg the previous tenure but was not allowed
613
+ ReorgNotAllowed ,
614
+ /// The bitvec field does not match what is expected
615
+ InvalidBitvec ,
616
+ /// The miner's pubkey hash does not match the winning pubkey hash
617
+ PubkeyHashMismatch ,
618
+ /// The miner has been marked as invalid
619
+ InvalidMiner ,
620
+ /// Miner is last sortition winner, when the current sortition winner is
621
+ /// still valid
622
+ NotLatestSortitionWinner ,
623
+ /// The block does not confirm the expected parent block
624
+ InvalidParentBlock ,
625
+ /// The block does not confirm the expected parent tenure
626
+ InvalidParentTenure ,
627
+ /// The block contains a block found tenure change, but we've already seen
628
+ /// a block found
629
+ DuplicateBlockFound ,
630
+ /// The block attempted a tenure extend but the burn view has not changed
631
+ /// and not enough time has passed for a time-based tenure extend
632
+ InvalidTenureExtend ,
582
633
}
583
634
584
635
define_u8_enum ! (
@@ -796,7 +847,7 @@ impl SignerMessageMetadata {
796
847
}
797
848
798
849
/// The latest version of the block response data
799
- pub const BLOCK_RESPONSE_DATA_VERSION : u8 = 2 ;
850
+ pub const BLOCK_RESPONSE_DATA_VERSION : u8 = 3 ;
800
851
801
852
/// Versioned, backwards-compatible struct for block response data
802
853
#[ derive( Clone , Debug , PartialEq , Serialize , Deserialize ) ]
@@ -1070,11 +1121,20 @@ impl StacksMessageCodec for RejectCode {
1070
1121
// Do not do a single match here as we may add other variants in the future and don't want to miss adding it
1071
1122
match self {
1072
1123
RejectCode :: ValidationFailed ( code) => write_next ( fd, & ( * code as u8 ) ) ?,
1073
- RejectCode :: ConnectivityIssues
1124
+ RejectCode :: ConnectivityIssues ( _ )
1074
1125
| RejectCode :: RejectedInPriorRound
1075
1126
| RejectCode :: NoSortitionView
1076
1127
| RejectCode :: SortitionViewMismatch
1077
- | RejectCode :: TestingDirective => {
1128
+ | RejectCode :: TestingDirective
1129
+ | RejectCode :: ReorgNotAllowed
1130
+ | RejectCode :: InvalidBitvec
1131
+ | RejectCode :: PubkeyHashMismatch
1132
+ | RejectCode :: InvalidMiner
1133
+ | RejectCode :: NotLatestSortitionWinner
1134
+ | RejectCode :: InvalidParentBlock
1135
+ | RejectCode :: InvalidParentTenure
1136
+ | RejectCode :: DuplicateBlockFound
1137
+ | RejectCode :: InvalidTenureExtend => {
1078
1138
// No additional data to serialize / deserialize
1079
1139
}
1080
1140
} ;
@@ -1093,11 +1153,22 @@ impl StacksMessageCodec for RejectCode {
1093
1153
) )
1094
1154
} ) ?,
1095
1155
) ,
1096
- RejectCodeTypePrefix :: ConnectivityIssues => RejectCode :: ConnectivityIssues ,
1156
+ RejectCodeTypePrefix :: ConnectivityIssues => {
1157
+ RejectCode :: ConnectivityIssues ( "unspecified" . to_string ( ) )
1158
+ }
1097
1159
RejectCodeTypePrefix :: RejectedInPriorRound => RejectCode :: RejectedInPriorRound ,
1098
1160
RejectCodeTypePrefix :: NoSortitionView => RejectCode :: NoSortitionView ,
1099
1161
RejectCodeTypePrefix :: SortitionViewMismatch => RejectCode :: SortitionViewMismatch ,
1100
1162
RejectCodeTypePrefix :: TestingDirective => RejectCode :: TestingDirective ,
1163
+ RejectCodeTypePrefix :: ReorgNotAllowed => RejectCode :: ReorgNotAllowed ,
1164
+ RejectCodeTypePrefix :: InvalidBitvec => RejectCode :: InvalidBitvec ,
1165
+ RejectCodeTypePrefix :: PubkeyHashMismatch => RejectCode :: PubkeyHashMismatch ,
1166
+ RejectCodeTypePrefix :: InvalidMiner => RejectCode :: InvalidMiner ,
1167
+ RejectCodeTypePrefix :: NotLatestSortitionWinner => RejectCode :: NotLatestSortitionWinner ,
1168
+ RejectCodeTypePrefix :: InvalidParentBlock => RejectCode :: InvalidParentBlock ,
1169
+ RejectCodeTypePrefix :: InvalidParentTenure => RejectCode :: InvalidParentTenure ,
1170
+ RejectCodeTypePrefix :: DuplicateBlockFound => RejectCode :: DuplicateBlockFound ,
1171
+ RejectCodeTypePrefix :: InvalidTenureExtend => RejectCode :: InvalidTenureExtend ,
1101
1172
} ;
1102
1173
Ok ( code)
1103
1174
}
@@ -1108,9 +1179,9 @@ impl std::fmt::Display for RejectCode {
1108
1179
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
1109
1180
match self {
1110
1181
RejectCode :: ValidationFailed ( code) => write ! ( f, "Validation failed: {:?}" , code) ,
1111
- RejectCode :: ConnectivityIssues => write ! (
1182
+ RejectCode :: ConnectivityIssues ( reason ) => write ! (
1112
1183
f,
1113
- "The block was rejected due to connectivity issues with the signer. "
1184
+ "The block was rejected due to connectivity issues with the signer: {reason} "
1114
1185
) ,
1115
1186
RejectCode :: RejectedInPriorRound => write ! (
1116
1187
f,
@@ -1128,6 +1199,48 @@ impl std::fmt::Display for RejectCode {
1128
1199
RejectCode :: TestingDirective => {
1129
1200
write ! ( f, "The block was rejected due to a testing directive." )
1130
1201
}
1202
+ RejectCode :: ReorgNotAllowed => {
1203
+ write ! (
1204
+ f,
1205
+ "The block attempted to reorg the previous tenure but was not allowed."
1206
+ )
1207
+ }
1208
+ RejectCode :: InvalidBitvec => {
1209
+ write ! ( f, "The bitvec field does not match what is expected." )
1210
+ }
1211
+ RejectCode :: PubkeyHashMismatch => {
1212
+ write ! (
1213
+ f,
1214
+ "The miner's pubkey hash does not match the winning pubkey hash."
1215
+ )
1216
+ }
1217
+ RejectCode :: InvalidMiner => {
1218
+ write ! ( f, "The miner has been marked as invalid." )
1219
+ }
1220
+ RejectCode :: NotLatestSortitionWinner => {
1221
+ write ! (
1222
+ f,
1223
+ "Miner is last sortition winner, when the current sortition winner is still valid."
1224
+ )
1225
+ }
1226
+ RejectCode :: InvalidParentBlock => {
1227
+ write ! ( f, "The block does not confirm the expected parent block." )
1228
+ }
1229
+ RejectCode :: InvalidParentTenure => {
1230
+ write ! ( f, "The block does not confirm the expected parent tenure." )
1231
+ }
1232
+ RejectCode :: DuplicateBlockFound => {
1233
+ write ! (
1234
+ f,
1235
+ "The block contains a block found tenure change, but we've already seen a block found."
1236
+ )
1237
+ }
1238
+ RejectCode :: InvalidTenureExtend => {
1239
+ write ! (
1240
+ f,
1241
+ "The block attempted a tenure extend but the burn view has not changed and not enough time has passed for a time-based tenure extend."
1242
+ )
1243
+ }
1131
1244
}
1132
1245
}
1133
1246
}
@@ -1180,7 +1293,7 @@ mod test {
1180
1293
. expect ( "Failed to deserialize RejectCode" ) ;
1181
1294
assert_eq ! ( code, deserialized_code) ;
1182
1295
1183
- let code = RejectCode :: ConnectivityIssues ;
1296
+ let code = RejectCode :: ConnectivityIssues ( "" . to_string ( ) ) ;
1184
1297
let serialized_code = code. serialize_to_vec ( ) ;
1185
1298
let deserialized_code = read_next :: < RejectCode , _ > ( & mut & serialized_code[ ..] )
1186
1299
. expect ( "Failed to deserialize RejectCode" ) ;
@@ -1203,7 +1316,7 @@ mod test {
1203
1316
1204
1317
let rejection = BlockRejection :: new (
1205
1318
Sha512Trunc256Sum ( [ 1u8 ; 32 ] ) ,
1206
- RejectCode :: ConnectivityIssues ,
1319
+ RejectCode :: ConnectivityIssues ( "reason" . to_string ( ) ) ,
1207
1320
& StacksPrivateKey :: random ( ) ,
1208
1321
thread_rng ( ) . gen_bool ( 0.5 ) ,
1209
1322
thread_rng ( ) . next_u64 ( ) ,
0 commit comments