Skip to content

Commit dc555b4

Browse files
authored
Merge pull request #6673 from brice-stacks/3.3.0.0.1-to-develop
3.3.0.0.1 to develop
2 parents c7c7fd6 + 99a809e commit dc555b4

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1313
- Added `result_hex` and `post_condition_aborted` to the block replay RPC endpoint
1414
- Added `--epoch <epoch_number>` flag to `clarity-cli` commands to specify the epoch context for evaluation.
1515

16+
## [3.3.0.0.1]
17+
18+
- 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.
19+
1620
## [3.3.0.0.0]
1721

1822
### Added

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,18 @@ pub static NAKAMOTO_CHAINSTATE_SCHEMA_6: &[&str] = &[
289289
];
290290

291291
pub static NAKAMOTO_CHAINSTATE_SCHEMA_7: &[&str] = &[
292-
r#"
293-
UPDATE db_config SET version = "12";
294-
"#,
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+
299+
pub static NAKAMOTO_CHAINSTATE_SCHEMA_8: &[&str] = &[
300+
r#"UPDATE db_config SET version = "13";"#,
295301
// Add a `total_tenure_size` field to the block header row, so we can keep track
296302
// of the whole tenure size (and eventually limit it)
297303
//
298-
//
299-
//
300304
// Default to 0.
301305
r#"
302306
-- total_tenure_size cannot be consensus critical as existing nodes which migrate will report a 0 size while

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +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,
53+
NAKAMOTO_CHAINSTATE_SCHEMA_7, NAKAMOTO_CHAINSTATE_SCHEMA_8,
5454
};
5555
use crate::chainstate::stacks::address::StacksAddressExtensions;
5656
use crate::chainstate::stacks::boot::*;
@@ -665,8 +665,8 @@ impl<'a> DerefMut for ChainstateTx<'a> {
665665
}
666666
}
667667

668-
pub const CHAINSTATE_VERSION: &str = "12";
669-
pub const CHAINSTATE_VERSION_NUMBER: u32 = 12;
668+
pub const CHAINSTATE_VERSION: &str = "13";
669+
pub const CHAINSTATE_VERSION_NUMBER: u32 = 13;
670670

671671
const CHAINSTATE_INITIAL_SCHEMA: &[&str] = &[
672672
"PRAGMA foreign_keys = ON;",
@@ -1161,12 +1161,20 @@ impl StacksChainState {
11611161
}
11621162
"11" => {
11631163
info!(
1164-
"Migrating chainstate schema from version 11 to 12: add total_tenure_size field"
1164+
"Migrating chainstate schema from version 11 to 12: add index for nakamoto_block_headers"
11651165
);
11661166
for cmd in NAKAMOTO_CHAINSTATE_SCHEMA_7.iter() {
11671167
tx.execute_batch(cmd)?;
11681168
}
11691169
}
1170+
"12" => {
1171+
info!(
1172+
"Migrating chainstate schema from version 12 to 13: add total_tenure_size field"
1173+
);
1174+
for cmd in NAKAMOTO_CHAINSTATE_SCHEMA_8.iter() {
1175+
tx.execute_batch(cmd)?;
1176+
}
1177+
}
11701178
_ => {
11711179
error!(
11721180
"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
@@ -1558,13 +1558,14 @@ impl StacksChainState {
15581558

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

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

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)