@@ -13,7 +13,7 @@ use rand::RngCore;
13
13
use serde:: Deserialize ;
14
14
use stacks:: burnchains:: affirmation:: AffirmationMap ;
15
15
use stacks:: burnchains:: bitcoin:: BitcoinNetworkType ;
16
- use stacks:: burnchains:: { Burnchain , MagicBytes , BLOCKSTACK_MAGIC_MAINNET } ;
16
+ use stacks:: burnchains:: { Burnchain , MagicBytes , PoxConstants , BLOCKSTACK_MAGIC_MAINNET } ;
17
17
use stacks:: chainstate:: nakamoto:: signer_set:: NakamotoSigners ;
18
18
use stacks:: chainstate:: stacks:: boot:: MINERS_NAME ;
19
19
use stacks:: chainstate:: stacks:: index:: marf:: MARFOpenOpts ;
@@ -22,8 +22,10 @@ use stacks::chainstate::stacks::miner::{BlockBuilderSettings, MinerStatus};
22
22
use stacks:: chainstate:: stacks:: MAX_BLOCK_LEN ;
23
23
use stacks:: core:: mempool:: { MemPoolWalkSettings , MemPoolWalkTxTypes } ;
24
24
use stacks:: core:: {
25
- MemPoolDB , StacksEpoch , StacksEpochExtension , StacksEpochId , CHAIN_ID_MAINNET ,
26
- CHAIN_ID_TESTNET , PEER_VERSION_MAINNET , PEER_VERSION_TESTNET ,
25
+ MemPoolDB , StacksEpoch , StacksEpochExtension , StacksEpochId ,
26
+ BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT , BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT ,
27
+ BITCOIN_TESTNET_STACKS_25_REORGED_HEIGHT , CHAIN_ID_MAINNET , CHAIN_ID_TESTNET ,
28
+ PEER_VERSION_MAINNET , PEER_VERSION_TESTNET ,
27
29
} ;
28
30
use stacks:: cost_estimates:: fee_medians:: WeightedMedianFeeRateEstimator ;
29
31
use stacks:: cost_estimates:: fee_rate_fuzzer:: FeeRateFuzzer ;
@@ -211,7 +213,7 @@ mod tests {
211
213
ConfigFile :: from_str ( & format ! (
212
214
r#"
213
215
[[burnchain.affirmation_overrides]]
214
- reward_cycle = 1
216
+ reward_cycle = 413
215
217
affirmation = "{affirmation_string}"
216
218
"#
217
219
) )
@@ -222,7 +224,7 @@ mod tests {
222
224
assert_eq ! ( config. burnchain. affirmation_overrides. len( ) , 1 ) ;
223
225
assert_eq ! ( config. burnchain. affirmation_overrides. get( & 0 ) , None ) ;
224
226
assert_eq ! (
225
- config. burnchain. affirmation_overrides. get( & 1 ) ,
227
+ config. burnchain. affirmation_overrides. get( & 413 ) ,
226
228
Some ( & affirmation)
227
229
) ;
228
230
}
@@ -267,7 +269,7 @@ mod tests {
267
269
)
268
270
. expect ( "Expected to be able to parse affirmation map from file" ) ;
269
271
// Should default add xenon affirmation overrides
270
- assert_eq ! ( config. burnchain. affirmation_overrides. len( ) , 3 ) ;
272
+ assert_eq ! ( config. burnchain. affirmation_overrides. len( ) , 5 ) ;
271
273
}
272
274
}
273
275
@@ -1445,7 +1447,7 @@ impl BurnchainConfigFile {
1445
1447
/// This caused the Stacks Xenon testnet to undergo a deep reorg when 2.4.0.0.0 was finalized. This deep reorg meant that 3 reward cycles were
1446
1448
/// invalidated, which requires overrides in the affirmation map to continue correct operation. Those overrides are required for cycles 413, 414, and 415.
1447
1449
pub fn add_affirmation_overrides_xenon ( & mut self ) {
1448
- let default_overrides = vec ! [
1450
+ let mut default_overrides = vec ! [
1449
1451
AffirmationOverride {
1450
1452
reward_cycle: 413 ,
1451
1453
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpa" . to_string( )
@@ -1458,6 +1460,37 @@ impl BurnchainConfigFile {
1458
1460
reward_cycle: 415 ,
1459
1461
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaaa" . to_string( )
1460
1462
} ] ;
1463
+
1464
+ // Now compute the 2.5 overrides.
1465
+ let affirmations_pre_2_5 = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaaaapppppppnnnnnnnnnnnnnnnnnnnnnnnpnppnppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnpnpppppppppnppnnnnnnnnnnnnnnnnnnnnnnnnnppnppppppppp" ;
1466
+ let xenon_pox_consts = PoxConstants :: testnet_default ( ) ;
1467
+ let last_present_cycle = xenon_pox_consts
1468
+ . block_height_to_reward_cycle (
1469
+ BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT ,
1470
+ BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT ,
1471
+ )
1472
+ . unwrap ( ) ;
1473
+ eprintln ! ( "last_present_cycle = {last_present_cycle}" ) ;
1474
+ assert_eq ! (
1475
+ u64 :: try_from( affirmations_pre_2_5. len( ) ) . unwrap( ) ,
1476
+ last_present_cycle - 1
1477
+ ) ;
1478
+ let last_override = xenon_pox_consts
1479
+ . block_height_to_reward_cycle (
1480
+ BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT ,
1481
+ BITCOIN_TESTNET_STACKS_25_REORGED_HEIGHT ,
1482
+ )
1483
+ . unwrap ( ) ;
1484
+ eprintln ! ( "last_present_cycle = {last_present_cycle}, last_override = {last_override}" ) ;
1485
+
1486
+ for ( override_index, reward_cycle) in ( last_present_cycle + 1 ..=last_override) . enumerate ( ) {
1487
+ let affirmation = format ! ( "{affirmations_pre_2_5}{}" , "a" . repeat( override_index + 1 ) ) ;
1488
+ default_overrides. push ( AffirmationOverride {
1489
+ reward_cycle,
1490
+ affirmation,
1491
+ } ) ;
1492
+ }
1493
+
1461
1494
if let Some ( affirmation_overrides) = self . affirmation_overrides . as_mut ( ) {
1462
1495
for affirmation in default_overrides {
1463
1496
affirmation_overrides. push ( affirmation) ;
@@ -1503,6 +1536,12 @@ impl BurnchainConfigFile {
1503
1536
ao. reward_cycle, ao. affirmation
1504
1537
) ) ;
1505
1538
} ;
1539
+ if u64:: try_from ( affirmation_map. len ( ) ) . unwrap ( ) != ao. reward_cycle - 1 {
1540
+ return Err ( format ! (
1541
+ "Invalid affirmation override for reward cycle {}. Map len = {}, but expected {}." ,
1542
+ ao. reward_cycle, affirmation_map. len( ) , ao. reward_cycle - 1 ,
1543
+ ) ) ;
1544
+ }
1506
1545
affirmation_overrides. insert ( ao. reward_cycle , affirmation_map) ;
1507
1546
}
1508
1547
}
0 commit comments