Skip to content

Commit cd1b4cc

Browse files
committed
Remove affirmation_overrides config
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 33fbe18 commit cd1b4cc

File tree

2 files changed

+4
-222
lines changed

2 files changed

+4
-222
lines changed

stacks-node/src/run_loop/neon.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,19 +1028,9 @@ impl RunLoop {
10281028
let liveness_thread = self.spawn_chain_liveness_thread(globals.clone());
10291029

10301030
// Wait for all pending sortitions to process
1031-
let mut burnchain_db = burnchain_config
1031+
let burnchain_db = burnchain_config
10321032
.open_burnchain_db(true)
10331033
.expect("FATAL: failed to open burnchain DB");
1034-
if !self.config.burnchain.affirmation_overrides.is_empty() {
1035-
let tx = burnchain_db
1036-
.tx_begin()
1037-
.expect("FATAL: failed to begin burnchain DB tx");
1038-
for (reward_cycle, affirmation) in self.config.burnchain.affirmation_overrides.iter() {
1039-
tx.set_override_affirmation_map(*reward_cycle, affirmation.clone()).unwrap_or_else(|_| panic!("FATAL: failed to set affirmation override ({affirmation}) for reward cycle {reward_cycle}"));
1040-
}
1041-
tx.commit()
1042-
.expect("FATAL: failed to commit burnchain DB tx");
1043-
}
10441034
let burnchain_db_tip = burnchain_db
10451035
.get_canonical_chain_tip()
10461036
.expect("FATAL: failed to query burnchain DB");

stackslib/src/config/mod.rs

Lines changed: 3 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ use stacks_common::util::get_epoch_time_ms;
3636
use stacks_common::util::hash::hex_bytes;
3737
use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
3838

39-
use crate::burnchains::affirmation::AffirmationMap;
4039
use crate::burnchains::bitcoin::BitcoinNetworkType;
41-
use crate::burnchains::{Burnchain, MagicBytes, PoxConstants, BLOCKSTACK_MAGIC_MAINNET};
40+
use crate::burnchains::{Burnchain, MagicBytes, BLOCKSTACK_MAGIC_MAINNET};
4241
use crate::chainstate::nakamoto::signer_set::NakamotoSigners;
4342
use crate::chainstate::stacks::boot::MINERS_NAME;
4443
use crate::chainstate::stacks::index::marf::MARFOpenOpts;
@@ -49,8 +48,7 @@ use crate::config::chain_data::MinerStats;
4948
use crate::core::mempool::{MemPoolWalkSettings, MemPoolWalkStrategy, MemPoolWalkTxTypes};
5049
use crate::core::{
5150
MemPoolDB, StacksEpoch, StacksEpochExtension, StacksEpochId,
52-
BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT, BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT,
53-
BITCOIN_TESTNET_STACKS_25_REORGED_HEIGHT, CHAIN_ID_MAINNET, CHAIN_ID_TESTNET,
51+
CHAIN_ID_MAINNET, CHAIN_ID_TESTNET,
5452
PEER_VERSION_MAINNET, PEER_VERSION_TESTNET, STACKS_EPOCHS_REGTEST, STACKS_EPOCHS_TESTNET,
5553
};
5654
use crate::cost_estimates::fee_medians::WeightedMedianFeeRateEstimator;
@@ -229,7 +227,7 @@ impl ConfigFile {
229227
}
230228

231229
pub fn xenon() -> ConfigFile {
232-
let mut burnchain = BurnchainConfigFile {
230+
let burnchain = BurnchainConfigFile {
233231
mode: Some("xenon".to_string()),
234232
rpc_port: Some(18332),
235233
peer_port: Some(18333),
@@ -238,8 +236,6 @@ impl ConfigFile {
238236
..BurnchainConfigFile::default()
239237
};
240238

241-
burnchain.add_affirmation_overrides_xenon();
242-
243239
let node = NodeConfigFile {
244240
bootstrap_node: Some("029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444".to_string()),
245241
miner: Some(false),
@@ -1587,25 +1583,6 @@ pub struct BurnchainConfig {
15871583
/// @default: `None`
15881584
/// @deprecated: This setting is ignored in Epoch 3.0+.
15891585
pub ast_precheck_size_height: Option<u64>,
1590-
/// Overrides for the burnchain block affirmation map for specific reward cycles.
1591-
/// Allows manually setting the miner affirmation ('p'resent/'n'ot-present/'a'bsent)
1592-
/// map for a given cycle, bypassing the map normally derived from sortition results.
1593-
///
1594-
/// Special defaults are added when [`BurnchainConfig::mode`] is "xenon", but
1595-
/// config entries take precedence. At startup, these overrides are written to
1596-
/// the `BurnchainDB` (`overrides` table).
1597-
/// ---
1598-
/// @default: Empty map
1599-
/// @deprecated: This setting is ignored in Epoch 3.0+. Only used in the neon chain mode.
1600-
/// @notes:
1601-
/// - Primarily used for testing or recovering from network issues.
1602-
/// - Configured as a list `[[burnchain.affirmation_overrides]]` in TOML, each with
1603-
/// `reward_cycle` (integer) and `affirmation` (string of 'p'/'n'/'a', length `reward_cycle - 1`).
1604-
/// @toml_example: |
1605-
/// [[burnchain.affirmation_overrides]]
1606-
/// reward_cycle = 413
1607-
/// affirmation = "pna..." # Must be 412 chars long
1608-
pub affirmation_overrides: HashMap<u64, AffirmationMap>,
16091586
/// Fault injection setting for testing. Introduces an artificial delay (in
16101587
/// milliseconds) before processing each burnchain block download. Simulates a
16111588
/// slow burnchain connection.
@@ -1672,7 +1649,6 @@ impl BurnchainConfig {
16721649
sunset_end: None,
16731650
wallet_name: "".to_string(),
16741651
ast_precheck_size_height: None,
1675-
affirmation_overrides: HashMap::new(),
16761652
fault_injection_burnchain_block_delay: 0,
16771653
max_unspent_utxos: Some(1024),
16781654
}
@@ -1773,76 +1749,11 @@ pub struct BurnchainConfigFile {
17731749
pub sunset_end: Option<u32>,
17741750
pub wallet_name: Option<String>,
17751751
pub ast_precheck_size_height: Option<u64>,
1776-
pub affirmation_overrides: Option<Vec<AffirmationOverride>>,
17771752
pub fault_injection_burnchain_block_delay: Option<u64>,
17781753
pub max_unspent_utxos: Option<u64>,
17791754
}
17801755

17811756
impl BurnchainConfigFile {
1782-
/// Add affirmation overrides required to sync Xenon Testnet node.
1783-
///
1784-
/// The Xenon Testnet Stacks 2.4 activation height occurred before the finalized SIP-024 updates and release of the stacks-node versioned 2.4.0.0.0.
1785-
/// 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
1786-
/// invalidated, which requires overrides in the affirmation map to continue correct operation. Those overrides are required for cycles 413, 414, and 415.
1787-
#[allow(clippy::indexing_slicing)] // bad affirmation map override should panic
1788-
pub fn add_affirmation_overrides_xenon(&mut self) {
1789-
let mut default_overrides = vec![
1790-
AffirmationOverride {
1791-
reward_cycle: 413,
1792-
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpa".to_string()
1793-
},
1794-
AffirmationOverride {
1795-
reward_cycle: 414,
1796-
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaa".to_string()
1797-
},
1798-
AffirmationOverride {
1799-
reward_cycle: 415,
1800-
affirmation: "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaaa".to_string()
1801-
}];
1802-
1803-
// Now compute the 2.5 overrides.
1804-
let affirmations_pre_2_5 = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpaaaapppppppnnnnnnnnnnnnnnnnnnnnnnnpnppnppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnpnpppppppppnppnnnnnnnnnnnnnnnnnnnnnnnnnppnppppppppp";
1805-
let xenon_pox_consts = PoxConstants::testnet_default();
1806-
let last_present_cycle = xenon_pox_consts
1807-
.block_height_to_reward_cycle(
1808-
BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT,
1809-
BITCOIN_TESTNET_STACKS_25_BURN_HEIGHT,
1810-
)
1811-
.unwrap();
1812-
assert_eq!(
1813-
u64::try_from(affirmations_pre_2_5.len()).unwrap(),
1814-
last_present_cycle - 1
1815-
);
1816-
let last_override = xenon_pox_consts
1817-
.block_height_to_reward_cycle(
1818-
BITCOIN_TESTNET_FIRST_BLOCK_HEIGHT,
1819-
BITCOIN_TESTNET_STACKS_25_REORGED_HEIGHT,
1820-
)
1821-
.unwrap();
1822-
let override_values = ["a", "n"];
1823-
1824-
for (override_index, reward_cycle) in (last_present_cycle + 1..=last_override).enumerate() {
1825-
assert!(override_values.len() > override_index);
1826-
let overrides = override_values[..(override_index + 1)].join("");
1827-
let affirmation = format!("{affirmations_pre_2_5}{overrides}");
1828-
default_overrides.push(AffirmationOverride {
1829-
reward_cycle,
1830-
affirmation,
1831-
});
1832-
}
1833-
1834-
if let Some(affirmation_overrides) = self.affirmation_overrides.as_mut() {
1835-
for affirmation in default_overrides {
1836-
// insert at front, so that the hashmap uses the configured overrides
1837-
// instead of the defaults (the configured overrides will write over the
1838-
// the defaults because they come later in the list).
1839-
affirmation_overrides.insert(0, affirmation);
1840-
}
1841-
} else {
1842-
self.affirmation_overrides = Some(default_overrides);
1843-
};
1844-
}
1845-
18461757
fn into_config_default(
18471758
mut self,
18481759
default_burnchain_config: BurnchainConfig,
@@ -1851,7 +1762,6 @@ impl BurnchainConfigFile {
18511762
if self.magic_bytes.is_none() {
18521763
self.magic_bytes = ConfigFile::xenon().burnchain.unwrap().magic_bytes;
18531764
}
1854-
self.add_affirmation_overrides_xenon();
18551765
}
18561766

18571767
let mode = self.mode.unwrap_or(default_burnchain_config.mode);
@@ -1870,25 +1780,6 @@ impl BurnchainConfigFile {
18701780
}
18711781
}
18721782

1873-
let mut affirmation_overrides = HashMap::new();
1874-
if let Some(aos) = self.affirmation_overrides {
1875-
for ao in aos {
1876-
let Some(affirmation_map) = AffirmationMap::decode(&ao.affirmation) else {
1877-
return Err(format!(
1878-
"Invalid affirmation override for reward cycle {}: {}",
1879-
ao.reward_cycle, ao.affirmation
1880-
));
1881-
};
1882-
if u64::try_from(affirmation_map.len()).unwrap() != ao.reward_cycle - 1 {
1883-
return Err(format!(
1884-
"Invalid affirmation override for reward cycle {}. Map len = {}, but expected {}.",
1885-
ao.reward_cycle, affirmation_map.len(), ao.reward_cycle - 1,
1886-
));
1887-
}
1888-
affirmation_overrides.insert(ao.reward_cycle, affirmation_map);
1889-
}
1890-
}
1891-
18921783
let mut config = BurnchainConfig {
18931784
chain: self.chain.unwrap_or(default_burnchain_config.chain),
18941785
chain_id: match self.chain_id {
@@ -1993,7 +1884,6 @@ impl BurnchainConfigFile {
19931884
pox_prepare_length: self
19941885
.pox_prepare_length
19951886
.or(default_burnchain_config.pox_prepare_length),
1996-
affirmation_overrides,
19971887
fault_injection_burnchain_block_delay: self
19981888
.fault_injection_burnchain_block_delay
19991889
.unwrap_or(default_burnchain_config.fault_injection_burnchain_block_delay),
@@ -4844,104 +4734,6 @@ mod tests {
48444734
);
48454735
}
48464736

4847-
#[test]
4848-
fn should_load_affirmation_map() {
4849-
let affirmation_string = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpa";
4850-
let affirmation =
4851-
AffirmationMap::decode(affirmation_string).expect("Failed to decode affirmation map");
4852-
let config = Config::from_config_file(
4853-
ConfigFile::from_str(&format!(
4854-
r#"
4855-
[[burnchain.affirmation_overrides]]
4856-
reward_cycle = 413
4857-
affirmation = "{affirmation_string}"
4858-
"#
4859-
))
4860-
.expect("Expected to be able to parse config file from string"),
4861-
false,
4862-
)
4863-
.expect("Expected to be able to parse affirmation map from file");
4864-
4865-
assert_eq!(config.burnchain.affirmation_overrides.len(), 1);
4866-
assert_eq!(config.burnchain.affirmation_overrides.get(&0), None);
4867-
assert_eq!(
4868-
config.burnchain.affirmation_overrides.get(&413),
4869-
Some(&affirmation)
4870-
);
4871-
}
4872-
4873-
#[test]
4874-
fn should_fail_to_load_invalid_affirmation_map() {
4875-
let bad_affirmation_string = "bad_map";
4876-
let file = ConfigFile::from_str(&format!(
4877-
r#"
4878-
[[burnchain.affirmation_overrides]]
4879-
reward_cycle = 1
4880-
affirmation = "{bad_affirmation_string}"
4881-
"#
4882-
))
4883-
.expect("Expected to be able to parse config file from string");
4884-
4885-
assert!(Config::from_config_file(file, false).is_err());
4886-
}
4887-
4888-
#[test]
4889-
fn should_load_empty_affirmation_map() {
4890-
let config = Config::from_config_file(
4891-
ConfigFile::from_str(r#""#)
4892-
.expect("Expected to be able to parse config file from string"),
4893-
false,
4894-
)
4895-
.expect("Expected to be able to parse affirmation map from file");
4896-
4897-
assert!(config.burnchain.affirmation_overrides.is_empty());
4898-
}
4899-
4900-
#[test]
4901-
fn should_include_xenon_default_affirmation_overrides() {
4902-
let config = Config::from_config_file(
4903-
ConfigFile::from_str(
4904-
r#"
4905-
[burnchain]
4906-
chain = "bitcoin"
4907-
mode = "xenon"
4908-
"#,
4909-
)
4910-
.expect("Expected to be able to parse config file from string"),
4911-
false,
4912-
)
4913-
.expect("Expected to be able to parse affirmation map from file");
4914-
// Should default add xenon affirmation overrides
4915-
assert_eq!(config.burnchain.affirmation_overrides.len(), 5);
4916-
}
4917-
4918-
#[test]
4919-
fn should_override_xenon_default_affirmation_overrides() {
4920-
let affirmation_string = "aaapnnnnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnpppppnnnnnnnnnnnnnnnnnnnnnnnpppppppppppppppnnnnnnnnnnnnnnnnnnnnnnnppppppppppnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnppppppppnnnnnnnnnnnnnnnnnnnnnnnppnppnnnnnnnnnnnnnnnnnnnnnnnppppnnnnnnnnnnnnnnnnnnnnnnnnnppppppnnnnnnnnnnnnnnnnnnnnnnnnnppnnnnnnnnnnnnnnnnnnnnnnnnnpppppppnnnnnnnnnnnnnnnnnnnnnnnnnnpnnnnnnnnnnnnnnnnnnnnnnnnnpppnppppppppppppppnnppppnpa";
4921-
let affirmation =
4922-
AffirmationMap::decode(affirmation_string).expect("Failed to decode affirmation map");
4923-
4924-
let config = Config::from_config_file(
4925-
ConfigFile::from_str(&format!(
4926-
r#"
4927-
[burnchain]
4928-
chain = "bitcoin"
4929-
mode = "xenon"
4930-
4931-
[[burnchain.affirmation_overrides]]
4932-
reward_cycle = 413
4933-
affirmation = "{affirmation_string}"
4934-
"#,
4935-
))
4936-
.expect("Expected to be able to parse config file from string"),
4937-
false,
4938-
)
4939-
.expect("Expected to be able to parse affirmation map from file");
4940-
// Should default add xenon affirmation overrides, but overwrite with the configured one above
4941-
assert_eq!(config.burnchain.affirmation_overrides.len(), 5);
4942-
assert_eq!(config.burnchain.affirmation_overrides[&413], affirmation);
4943-
}
4944-
49454737
#[test]
49464738
fn test_into_config_default_chain_id() {
49474739
// Helper function to create BurnchainConfigFile with mode and optional chain_id

0 commit comments

Comments
 (0)