From 6e5e35706275e1b30633bba0b5a44791509f1b39 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Thu, 30 May 2024 14:09:46 -0400 Subject: [PATCH 1/2] fix: update `supports_epoch` for version `5` This should have been included in #4812 but was overlooked. The fix solves the issue with the various Nakamoto integration tests. --- stackslib/src/chainstate/stacks/db/mod.rs | 40 +++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/stackslib/src/chainstate/stacks/db/mod.rs b/stackslib/src/chainstate/stacks/db/mod.rs index f10a87dccc..865758ed01 100644 --- a/stackslib/src/chainstate/stacks/db/mod.rs +++ b/stackslib/src/chainstate/stacks/db/mod.rs @@ -294,16 +294,32 @@ impl DBConfig { || self.version == "2" || self.version == "3" || self.version == "4" + || self.version == "5" } StacksEpochId::Epoch2_05 => { - self.version == "2" || self.version == "3" || self.version == "4" + self.version == "2" + || self.version == "3" + || self.version == "4" + || self.version == "5" + } + StacksEpochId::Epoch21 => { + self.version == "3" || self.version == "4" || self.version == "5" + } + StacksEpochId::Epoch22 => { + self.version == "3" || self.version == "4" || self.version == "5" + } + StacksEpochId::Epoch23 => { + self.version == "3" || self.version == "4" || self.version == "5" + } + StacksEpochId::Epoch24 => { + self.version == "3" || self.version == "4" || self.version == "5" + } + StacksEpochId::Epoch25 => { + self.version == "3" || self.version == "4" || self.version == "5" + } + StacksEpochId::Epoch30 => { + self.version == "3" || self.version == "4" || self.version == "5" } - StacksEpochId::Epoch21 => self.version == "3" || self.version == "4", - StacksEpochId::Epoch22 => self.version == "3" || self.version == "4", - StacksEpochId::Epoch23 => self.version == "3" || self.version == "4", - StacksEpochId::Epoch24 => self.version == "3" || self.version == "4", - StacksEpochId::Epoch25 => self.version == "3" || self.version == "4", - StacksEpochId::Epoch30 => self.version == "3" || self.version == "4", } } } @@ -2933,4 +2949,14 @@ pub mod test { MAINNET_2_0_GENESIS_ROOT_HASH ); } + + #[test] + fn latest_db_version_supports_latest_epoch() { + let db = DBConfig { + version: CHAINSTATE_VERSION.to_string(), + mainnet: true, + chain_id: CHAIN_ID_MAINNET, + }; + assert!(db.supports_epoch(StacksEpochId::latest())); + } } From 634c8663b56e5037feb957f60d361425a77d3921 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Thu, 30 May 2024 14:30:39 -0400 Subject: [PATCH 2/2] test: add simple unit test for `SortitionDB` Ensures that the latest DB version supports the latest epoch. --- stackslib/src/chainstate/burn/db/sortdb.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stackslib/src/chainstate/burn/db/sortdb.rs b/stackslib/src/chainstate/burn/db/sortdb.rs index e3802d6ec1..dc1e65f28d 100644 --- a/stackslib/src/chainstate/burn/db/sortdb.rs +++ b/stackslib/src/chainstate/burn/db/sortdb.rs @@ -10830,4 +10830,12 @@ pub mod tests { let db_epochs = SortitionDB::get_stacks_epochs(sortdb.conn()).unwrap(); assert_eq!(db_epochs, STACKS_EPOCHS_MAINNET.to_vec()); } + + #[test] + fn latest_db_version_supports_latest_epoch() { + assert!(SortitionDB::is_db_version_supported_in_epoch( + StacksEpochId::latest(), + SORTITION_DB_VERSION + )); + } }