Skip to content

Commit 0e6cf5f

Browse files
authored
Merge branch 'develop' into fix/fix-delegate-stack-increase-events
2 parents b8e3af0 + dcc89d2 commit 0e6cf5f

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

stackslib/src/core/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ pub const BITCOIN_TESTNET_STACKS_24_BURN_HEIGHT: u64 = 2_432_545;
137137
pub const BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT: u64 = 2_583_893;
138138
pub const BITCOIN_TESTNET_STACKS_30_BURN_HEIGHT: u64 = 30_000_000;
139139

140+
/// This constant sets the approximate testnet bitcoin height at which 2.5 Xenon
141+
/// was reorged back to 2.5 instantiation. This is only used to calculate the
142+
/// expected affirmation maps (so it only must be accurate to the reward cycle).
143+
pub const BITCOIN_TESTNET_STACKS_25_REORGED_HEIGHT: u64 = 2_586_000;
144+
140145
pub const BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT: u64 = 0;
141146
pub const BITCOIN_REGTEST_FIRST_BLOCK_TIMESTAMP: u32 = 0;
142147
pub const BITCOIN_REGTEST_FIRST_BLOCK_HASH: &str =

testnet/stacks-node/src/config.rs

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rand::RngCore;
1313
use serde::Deserialize;
1414
use stacks::burnchains::affirmation::AffirmationMap;
1515
use stacks::burnchains::bitcoin::BitcoinNetworkType;
16-
use stacks::burnchains::{Burnchain, MagicBytes, BLOCKSTACK_MAGIC_MAINNET};
16+
use stacks::burnchains::{Burnchain, MagicBytes, PoxConstants, BLOCKSTACK_MAGIC_MAINNET};
1717
use stacks::chainstate::nakamoto::signer_set::NakamotoSigners;
1818
use stacks::chainstate::stacks::boot::MINERS_NAME;
1919
use stacks::chainstate::stacks::index::marf::MARFOpenOpts;
@@ -22,8 +22,10 @@ use stacks::chainstate::stacks::miner::{BlockBuilderSettings, MinerStatus};
2222
use stacks::chainstate::stacks::MAX_BLOCK_LEN;
2323
use stacks::core::mempool::{MemPoolWalkSettings, MemPoolWalkTxTypes};
2424
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,
2729
};
2830
use stacks::cost_estimates::fee_medians::WeightedMedianFeeRateEstimator;
2931
use stacks::cost_estimates::fee_rate_fuzzer::FeeRateFuzzer;
@@ -211,7 +213,7 @@ mod tests {
211213
ConfigFile::from_str(&format!(
212214
r#"
213215
[[burnchain.affirmation_overrides]]
214-
reward_cycle = 1
216+
reward_cycle = 413
215217
affirmation = "{affirmation_string}"
216218
"#
217219
))
@@ -222,7 +224,7 @@ mod tests {
222224
assert_eq!(config.burnchain.affirmation_overrides.len(), 1);
223225
assert_eq!(config.burnchain.affirmation_overrides.get(&0), None);
224226
assert_eq!(
225-
config.burnchain.affirmation_overrides.get(&1),
227+
config.burnchain.affirmation_overrides.get(&413),
226228
Some(&affirmation)
227229
);
228230
}
@@ -267,7 +269,7 @@ mod tests {
267269
)
268270
.expect("Expected to be able to parse affirmation map from file");
269271
// Should default add xenon affirmation overrides
270-
assert_eq!(config.burnchain.affirmation_overrides.len(), 3);
272+
assert_eq!(config.burnchain.affirmation_overrides.len(), 5);
271273
}
272274
}
273275

@@ -1445,7 +1447,7 @@ impl BurnchainConfigFile {
14451447
/// 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
14461448
/// invalidated, which requires overrides in the affirmation map to continue correct operation. Those overrides are required for cycles 413, 414, and 415.
14471449
pub fn add_affirmation_overrides_xenon(&mut self) {
1448-
let default_overrides = vec![
1450+
let mut default_overrides = vec![
14491451
AffirmationOverride {
14501452
reward_cycle: 413,
14511453
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpa".to_string()
@@ -1458,6 +1460,37 @@ impl BurnchainConfigFile {
14581460
reward_cycle: 415,
14591461
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaaa".to_string()
14601462
}];
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+
14611494
if let Some(affirmation_overrides) = self.affirmation_overrides.as_mut() {
14621495
for affirmation in default_overrides {
14631496
affirmation_overrides.push(affirmation);
@@ -1503,6 +1536,12 @@ impl BurnchainConfigFile {
15031536
ao.reward_cycle, ao.affirmation
15041537
));
15051538
};
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+
}
15061545
affirmation_overrides.insert(ao.reward_cycle, affirmation_map);
15071546
}
15081547
}

0 commit comments

Comments
 (0)