Skip to content

Commit b3efa58

Browse files
authored
Merge pull request #6665 from stacks-network/release/3.3.0.0.1
Merge release/3.3.0.0.1 to master
2 parents 9dd85db + 1cba695 commit b3efa58

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8+
## [3.3.0.0.1]
9+
10+
- Add indexes to `nakamoto_block_headers` to fix a performance regression. Node may take a few minutes to restart during the upgrade while the new indexes are created.
11+
812
## [3.3.0.0.0]
913

1014
### Added

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ pub static NAKAMOTO_CHAINSTATE_SCHEMA_6: &[&str] = &[
288288
"CREATE INDEX IF NOT EXISTS nakamoto_block_headers_by_ch_bv ON nakamoto_block_headers(consensus_hash, burn_view);"
289289
];
290290

291+
pub static NAKAMOTO_CHAINSTATE_SCHEMA_7: &[&str] = &[
292+
// schema change is JUST a new index, but the index is on a table
293+
// created by a migration, so don't add the index to the CHAINSTATE_INDEXES
294+
r#"UPDATE db_config SET version = "12";"#,
295+
"CREATE INDEX IF NOT EXISTS naka_block_headers_by_burn_hash ON nakamoto_block_headers(burn_header_hash);",
296+
"CREATE INDEX IF NOT EXISTS naka_block_headers_by_burn_ht ON nakamoto_block_headers(burn_header_height);"
297+
];
298+
291299
#[cfg(test)]
292300
mod fault_injection {
293301
static PROCESS_BLOCK_STALL: std::sync::Mutex<bool> = std::sync::Mutex::new(false);

stackslib/src/chainstate/stacks/db/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ use crate::chainstate::nakamoto::{
5050
HeaderTypeNames, NakamotoBlockHeader, NakamotoChainState, NakamotoStagingBlocksConn,
5151
NAKAMOTO_CHAINSTATE_SCHEMA_1, NAKAMOTO_CHAINSTATE_SCHEMA_2, NAKAMOTO_CHAINSTATE_SCHEMA_3,
5252
NAKAMOTO_CHAINSTATE_SCHEMA_4, NAKAMOTO_CHAINSTATE_SCHEMA_5, NAKAMOTO_CHAINSTATE_SCHEMA_6,
53+
NAKAMOTO_CHAINSTATE_SCHEMA_7,
5354
};
5455
use crate::chainstate::stacks::address::StacksAddressExtensions;
5556
use crate::chainstate::stacks::boot::*;
@@ -282,8 +283,8 @@ impl DBConfig {
282283
});
283284
match epoch_id {
284285
StacksEpochId::Epoch10 => true,
285-
StacksEpochId::Epoch20 => (1..=11).contains(&version_u32),
286-
StacksEpochId::Epoch2_05 => (2..=11).contains(&version_u32),
286+
StacksEpochId::Epoch20 => (1..=12).contains(&version_u32),
287+
StacksEpochId::Epoch2_05 => (2..=12).contains(&version_u32),
287288
StacksEpochId::Epoch21
288289
| StacksEpochId::Epoch22
289290
| StacksEpochId::Epoch23
@@ -292,7 +293,7 @@ impl DBConfig {
292293
| StacksEpochId::Epoch30
293294
| StacksEpochId::Epoch31
294295
| StacksEpochId::Epoch32
295-
| StacksEpochId::Epoch33 => (3..=11).contains(&version_u32),
296+
| StacksEpochId::Epoch33 => (3..=12).contains(&version_u32),
296297
}
297298
}
298299
}
@@ -651,7 +652,7 @@ impl<'a> DerefMut for ChainstateTx<'a> {
651652
}
652653
}
653654

654-
pub const CHAINSTATE_VERSION: &str = "11";
655+
pub const CHAINSTATE_VERSION: &str = "12";
655656

656657
const CHAINSTATE_INITIAL_SCHEMA: &[&str] = &[
657658
"PRAGMA foreign_keys = ON;",
@@ -1144,6 +1145,14 @@ impl StacksChainState {
11441145
tx.execute_batch(cmd)?;
11451146
}
11461147
}
1148+
"11" => {
1149+
info!(
1150+
"Migrating chainstate schema from version 11 to 12: add index for nakamoto_block_headers"
1151+
);
1152+
for cmd in NAKAMOTO_CHAINSTATE_SCHEMA_7.iter() {
1153+
tx.execute_batch(cmd)?;
1154+
}
1155+
}
11471156
_ => {
11481157
error!(
11491158
"Invalid chain state database: expected version = {}, got {}",

stackslib/src/chainstate/stacks/db/transactions.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,13 +1560,14 @@ impl StacksChainState {
15601560

15611561
// what version of Clarity did the transaction caller want? And, is it valid now?
15621562
let clarity_version = StacksChainState::get_tx_clarity_version(clarity_block, tx)?;
1563-
if clarity_version == ClarityVersion::Clarity2 {
1564-
// requires 2.1 and higher
1565-
if clarity_block.get_epoch() < StacksEpochId::Epoch21 {
1566-
let msg = format!("Invalid transaction {}: asks for Clarity2, but not in Stacks epoch 2.1 or later", tx.txid());
1567-
info!("{}", &msg);
1568-
return Err(Error::InvalidStacksTransaction(msg, false));
1569-
}
1563+
if clarity_version > ClarityVersion::default_for_epoch(epoch) {
1564+
let msg = format!(
1565+
"Invalid transaction {}: asks for {clarity_version}, but current epoch {epoch} only supports up to {}",
1566+
tx.txid(),
1567+
ClarityVersion::default_for_epoch(epoch)
1568+
);
1569+
info!("{msg}");
1570+
return Err(Error::InvalidStacksTransaction(msg, false));
15701571
}
15711572

15721573
let mut transaction = clarity_block.connection().start_transaction_processing();
@@ -8668,7 +8669,9 @@ pub mod test {
86688669
if let Err(Error::InvalidStacksTransaction(msg, ..)) =
86698670
StacksChainState::process_transaction(&mut conn, &smart_contract_v2, false, None)
86708671
{
8671-
assert!(msg.find("not in Stacks epoch 2.1 or later").is_some());
8672+
assert!(msg
8673+
.find("asks for Clarity 2, but current epoch 2.05 only supports up to Clarity 1")
8674+
.is_some());
86728675
} else {
86738676
panic!("FATAL: did not recieve the appropriate error in processing a clarity2 tx in pre-2.1 epoch");
86748677
}

versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Update these values when a new release is created.
22
# `stacks-common/build.rs` will automatically update `versions.rs` with these values.
3-
stacks_node_version = "3.3.0.0.0"
4-
stacks_signer_version = "3.3.0.0.0.0"
3+
stacks_node_version = "3.3.0.0.1"
4+
stacks_signer_version = "3.3.0.0.1.0"

0 commit comments

Comments
 (0)