Skip to content

Commit e248b68

Browse files
committed
Merge branch 'fix/burn-view' of https://github.com/stacks-network/stacks-core into fix/burn-view
2 parents 9970130 + ddc1eca commit e248b68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1083
-1194
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ 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-
## [Unreleased]
8+
## [3.1.0.0.3]
99

1010
### Added
1111

1212
- Add `tenure_timeout_secs` to the miner for determining when a time-based tenure extend should be attempted.
1313
- Added configuration option `block_proposal_max_age_secs` under `[connection_options]` to prevent processing stale block proposals
1414

1515
### Changed
16-
- The RPC endpoint `/v3/block_proposal` no longer will evaluate block proposals more than `block_proposal_max_age_secs` old
1716

17+
- The RPC endpoint `/v3/block_proposal` no longer will evaluate block proposals more than `block_proposal_max_age_secs` old
1818
- When a transaction is dropped due to replace-by-fee, the `/drop_mempool_tx` event observer payload now includes `new_txid`, which is the transaction that replaced this dropped transaction. When a transaction is dropped for other reasons, `new_txid` is `null`. [#5381](https://github.com/stacks-network/stacks-core/pull/5381)
1919
- Nodes will assume that all PoX anchor blocks exist by default, and stall initial block download indefinitely to await their arrival (#5502)
2020

21+
### Fixed
22+
23+
- Signers no longer accept messages for blocks from different reward cycles (#5662)
24+
2125
## [3.1.0.0.2]
2226

2327
### Added

stacks-signer/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
99

1010
## Added
1111

12+
## Changed
13+
14+
## [3.1.0.0.3.0]
15+
16+
## Added
17+
1218
- Introduced the `block_proposal_max_age_secs` configuration option for signers, enabling them to automatically ignore block proposals that exceed the specified age in seconds.
1319
- When a new block proposal is received while the signer is waiting for an existing proposal to be validated, the signer will wait until the existing block is done validating before submitting the new one for validating. ([#5453](https://github.com/stacks-network/stacks-core/pull/5453))
1420

@@ -24,6 +30,14 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2430

2531
- Prevent old reward cycle signers from processing block validation response messages that do not apply to blocks from their cycle.
2632

33+
# [3.1.0.0.2.1]
34+
35+
## Added
36+
37+
## Changed
38+
39+
- Prevent old reward cycle signers from processing block validation response messages that do not apply to blocks from their cycle.
40+
2741
## [3.1.0.0.2.0]
2842

2943
## Added

stackslib/src/blockstack_cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ fn main_handler(mut argv: Vec<String>) -> Result<String, CliError> {
864864
if let Some(custom_chain_id) = flag.split('=').nth(1) {
865865
// Attempt to parse the custom chain ID from hex
866866
chain_id = u32::from_str_radix(custom_chain_id.trim_start_matches("0x"), 16)
867-
.map_err(|err| CliError::InvalidChainId(err))?;
867+
.map_err(CliError::InvalidChainId)?;
868868
} else {
869869
// Use the default testnet chain ID
870870
chain_id = CHAIN_ID_TESTNET;

stackslib/src/burnchains/bitcoin/address.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,10 @@ impl BitcoinAddress {
591591
} else {
592592
BitcoinNetworkType::Testnet
593593
};
594-
if let Some(addr) = BitcoinAddress::from_scriptpubkey(network_id, scriptpubkey) {
595-
if let BitcoinAddress::Segwit(sw) = addr {
596-
return Some(BitcoinAddress::Segwit(sw));
597-
}
594+
if let Some(BitcoinAddress::Segwit(sw)) =
595+
BitcoinAddress::from_scriptpubkey(network_id, scriptpubkey)
596+
{
597+
return Some(BitcoinAddress::Segwit(sw));
598598
}
599599
return None;
600600
}

stackslib/src/burnchains/bitcoin/bits.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ impl BitcoinTxInputStructured {
223223
Instruction::Op(btc_opcodes::OP_CHECKMULTISIG),
224224
) => {
225225
// op1 and op2 must be integers
226-
match (
227-
btc_opcodes::from(*op1).classify(),
228-
btc_opcodes::from(*op2).classify(),
229-
) {
226+
match (op1.classify(), op2.classify()) {
230227
(Class::PushNum(num_sigs), Class::PushNum(num_pubkeys)) => {
231228
// the "#instructions - 3" comes from the OP_m, OP_n, and OP_CHECKMULTISIG
232229
if num_sigs < 1

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,11 @@ impl BitcoinIndexer {
503503
start_block: u64,
504504
remove_old: bool,
505505
) -> Result<SpvClient, btc_error> {
506-
if remove_old {
507-
if PathBuf::from(&reorg_headers_path).exists() {
508-
fs::remove_file(&reorg_headers_path).map_err(|e| {
509-
error!("Failed to remove {}", reorg_headers_path);
510-
btc_error::Io(e)
511-
})?;
512-
}
506+
if remove_old && PathBuf::from(&reorg_headers_path).exists() {
507+
fs::remove_file(&reorg_headers_path).map_err(|e| {
508+
error!("Failed to remove {}", reorg_headers_path);
509+
btc_error::Io(e)
510+
})?;
513511
}
514512

515513
// bootstrap reorg client

stackslib/src/burnchains/bitcoin/spv.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,11 @@ impl SpvClient {
328328
} else {
329329
return Err(btc_error::DBError(db_error::NoDBError));
330330
}
331-
} else {
331+
} else if readwrite {
332332
// can just open
333-
if readwrite {
334-
OpenFlags::SQLITE_OPEN_READ_WRITE
335-
} else {
336-
OpenFlags::SQLITE_OPEN_READ_ONLY
337-
}
333+
OpenFlags::SQLITE_OPEN_READ_WRITE
334+
} else {
335+
OpenFlags::SQLITE_OPEN_READ_ONLY
338336
};
339337

340338
let mut conn = sqlite_open(headers_path, open_flags, false)

stackslib/src/burnchains/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl BurnchainDBTransaction<'_> {
393393
let args = params![u64_to_sql(target_reward_cycle)?];
394394
self.sql_tx
395395
.execute(sql, args)
396-
.map_err(|e| DBError::SqliteError(e))?;
396+
.map_err(DBError::SqliteError)?;
397397

398398
let sql = "UPDATE block_commit_metadata SET anchor_block = ?1 WHERE burn_block_hash = ?2 AND txid = ?3";
399399
let args = params![
@@ -424,7 +424,7 @@ impl BurnchainDBTransaction<'_> {
424424
self.sql_tx
425425
.execute(sql, args)
426426
.map(|_| ())
427-
.map_err(|e| DBError::SqliteError(e))
427+
.map_err(DBError::SqliteError)
428428
}
429429

430430
/// Calculate a burnchain block's block-commits' descendancy information.

stackslib/src/burnchains/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl PoxConstants {
629629
// TODO: I *think* the logic of `== 0` here requires some further digging.
630630
// `mod 0` may not have any rewards, but it does not behave like "prepare phase" blocks:
631631
// is it already a member of reward cycle "N" where N = block_height / reward_cycle_len
632-
reward_index == 0 || reward_index > u64::from(reward_cycle_length - prepare_length)
632+
reward_index == 0 || reward_index > reward_cycle_length - prepare_length
633633
}
634634
}
635635

@@ -658,7 +658,7 @@ impl PoxConstants {
658658
} else {
659659
let effective_height = block_height - first_block_height;
660660
let reward_index = effective_height % reward_cycle_length;
661-
reward_index > u64::from(reward_cycle_length - prepare_length)
661+
reward_index > reward_cycle_length - prepare_length
662662
}
663663
}
664664

stackslib/src/burnchains/tests/affirmation.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -351,29 +351,27 @@ pub fn make_reward_cycle_with_vote(
351351
let append = if !burnchain.is_in_prepare_phase(block_commit.block_height) {
352352
// non-prepare-phase commits always confirm their parent
353353
true
354+
} else if confirm_anchor_block {
355+
// all block-commits confirm anchor block
356+
true
354357
} else {
355-
if confirm_anchor_block {
356-
// all block-commits confirm anchor block
358+
// fewer than anchor_threshold commits confirm anchor block
359+
let next_rc_start = burnchain.reward_cycle_to_block_height(
360+
burnchain
361+
.block_height_to_reward_cycle(block_commit.block_height)
362+
.unwrap()
363+
+ 1,
364+
);
365+
if block_commit.block_height
366+
+ (burnchain.pox_constants.anchor_threshold as u64)
367+
+ 1
368+
< next_rc_start
369+
{
370+
// in first half of prepare phase, so confirm
357371
true
358372
} else {
359-
// fewer than anchor_threshold commits confirm anchor block
360-
let next_rc_start = burnchain.reward_cycle_to_block_height(
361-
burnchain
362-
.block_height_to_reward_cycle(block_commit.block_height)
363-
.unwrap()
364-
+ 1,
365-
);
366-
if block_commit.block_height
367-
+ (burnchain.pox_constants.anchor_threshold as u64)
368-
+ 1
369-
< next_rc_start
370-
{
371-
// in first half of prepare phase, so confirm
372-
true
373-
} else {
374-
// in second half of prepare phase, so don't confirm
375-
false
376-
}
373+
// in second half of prepare phase, so don't confirm
374+
false
377375
}
378376
};
379377

@@ -414,7 +412,7 @@ pub fn make_reward_cycle_with_vote(
414412
commits
415413
.into_iter()
416414
.flatten()
417-
.map(|cmt| BlockstackOperationType::LeaderBlockCommit(cmt))
415+
.map(BlockstackOperationType::LeaderBlockCommit)
418416
.collect()
419417
};
420418

@@ -1612,7 +1610,7 @@ fn test_update_pox_affirmation_maps_unique_anchor_block() {
16121610
let cmt_ops: Vec<BlockstackOperationType> = cmts
16131611
.iter()
16141612
.filter_map(|op| op.clone())
1615-
.map(|op| BlockstackOperationType::LeaderBlockCommit(op))
1613+
.map(BlockstackOperationType::LeaderBlockCommit)
16161614
.collect();
16171615

16181616
burnchain_db

0 commit comments

Comments
 (0)