Skip to content

Commit dd80215

Browse files
committed
Merge branch 'develop' into fix/burn-view
2 parents 275f1e2 + 403aefc commit dd80215

File tree

8 files changed

+372
-17
lines changed

8 files changed

+372
-17
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
# - tests::neon_integrations::size_overflow_unconfirmed_microblocks_integration_test
5555
# - tests::neon_integrations::size_overflow_unconfirmed_stream_microblocks_integration_test
5656
# - tests::neon_integrations::runtime_overflow_unconfirmed_microblocks_integration_test
57+
# - tests::epoch_25::microblocks_disabled
5758
# Disable this flaky test. Microblocks are no longer supported anyways.
5859
# - tests::neon_integrations::microblock_large_tx_integration_test_FLAKY
5960
- tests::neon_integrations::miner_submit_twice
@@ -80,7 +81,6 @@ jobs:
8081
- tests::neon_integrations::bitcoin_reorg_flap
8182
- tests::neon_integrations::bitcoin_reorg_flap_with_follower
8283
- tests::neon_integrations::start_stop_bitcoind
83-
- tests::epoch_25::microblocks_disabled
8484
- tests::should_succeed_handling_malformed_and_valid_txs
8585
- tests::nakamoto_integrations::simple_neon_integration
8686
- tests::nakamoto_integrations::flash_blocks_on_epoch_3
@@ -145,6 +145,8 @@ jobs:
145145
- tests::signer::v0::fast_sortition
146146
- tests::signer::v0::single_miner_empty_sortition
147147
- tests::signer::v0::multiple_miners_empty_sortition
148+
- tests::signer::v0::block_proposal_timeout
149+
- tests::signer::v0::rejected_blocks_count_towards_miner_validity
148150
- tests::nakamoto_integrations::burn_ops_integration_test
149151
- tests::nakamoto_integrations::check_block_heights
150152
- tests::nakamoto_integrations::clarity_burn_state

stacks-signer/src/chainstate.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ impl SortitionState {
8989
if self.miner_status != SortitionMinerStatus::Valid {
9090
return Ok(false);
9191
}
92-
// if we've already signed a block in this tenure, the miner can't have timed out.
93-
let has_blocks = signer_db
94-
.get_last_signed_block_in_tenure(&self.consensus_hash)?
95-
.is_some();
92+
// if we've already seen a proposed block from this miner. It cannot have timed out.
93+
let has_blocks = signer_db.has_proposed_block_in_tenure(&self.consensus_hash)?;
9694
if has_blocks {
9795
return Ok(false);
9896
}

stacks-signer/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const BLOCK_PROPOSAL_TIMEOUT_MS: u64 = 600_000;
3939
const BLOCK_PROPOSAL_VALIDATION_TIMEOUT_MS: u64 = 120_000;
4040
const DEFAULT_FIRST_PROPOSAL_BURN_BLOCK_TIMING_SECS: u64 = 60;
4141
const DEFAULT_TENURE_LAST_BLOCK_PROPOSAL_TIMEOUT_SECS: u64 = 30;
42-
const TENURE_IDLE_TIMEOUT_SECS: u64 = 300;
42+
const TENURE_IDLE_TIMEOUT_SECS: u64 = 120;
4343

4444
#[derive(thiserror::Error, Debug)]
4545
/// An error occurred parsing the provided configuration

stacks-signer/src/signerdb.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,15 +746,13 @@ impl SignerDb {
746746
try_deserialize(result)
747747
}
748748

749-
/// Return the last signed block in a tenure (identified by its consensus hash)
750-
pub fn get_last_signed_block_in_tenure(
751-
&self,
752-
tenure: &ConsensusHash,
753-
) -> Result<Option<BlockInfo>, DBError> {
754-
let query = "SELECT block_info FROM blocks WHERE consensus_hash = ? AND signed_over = 1 ORDER BY stacks_height DESC LIMIT 1";
749+
/// Return whether a block proposal has been stored for a tenure (identified by its consensus hash)
750+
/// Does not consider the block's state.
751+
pub fn has_proposed_block_in_tenure(&self, tenure: &ConsensusHash) -> Result<bool, DBError> {
752+
let query = "SELECT block_info FROM blocks WHERE consensus_hash = ? LIMIT 1";
755753
let result: Option<String> = query_row(&self.db, query, [tenure])?;
756754

757-
try_deserialize(result)
755+
Ok(result.is_some())
758756
}
759757

760758
/// Return the first signed block in a tenure (identified by its consensus hash)
@@ -1904,4 +1902,28 @@ mod tests {
19041902
let pendings = db.get_all_pending_block_validations().unwrap();
19051903
assert_eq!(pendings.len(), 0);
19061904
}
1905+
1906+
#[test]
1907+
fn has_proposed_block() {
1908+
let db_path = tmp_db_path();
1909+
let consensus_hash_1 = ConsensusHash([0x01; 20]);
1910+
let consensus_hash_2 = ConsensusHash([0x02; 20]);
1911+
let mut db = SignerDb::new(db_path).expect("Failed to create signer db");
1912+
let (mut block_info, _) = create_block_override(|b| {
1913+
b.block.header.consensus_hash = consensus_hash_1;
1914+
b.block.header.chain_length = 1;
1915+
});
1916+
1917+
assert!(!db.has_proposed_block_in_tenure(&consensus_hash_1).unwrap());
1918+
assert!(!db.has_proposed_block_in_tenure(&consensus_hash_2).unwrap());
1919+
1920+
db.insert_block(&block_info).unwrap();
1921+
1922+
block_info.block.header.chain_length = 2;
1923+
1924+
db.insert_block(&block_info).unwrap();
1925+
1926+
assert!(db.has_proposed_block_in_tenure(&consensus_hash_1).unwrap());
1927+
assert!(!db.has_proposed_block_in_tenure(&consensus_hash_2).unwrap());
1928+
}
19071929
}

testnet/stacks-node/src/nakamoto_node/miner.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ use crate::nakamoto_node::VRF_MOCK_MINER_KEY;
5959
use crate::neon_node;
6060
use crate::run_loop::nakamoto::Globals;
6161
use crate::run_loop::RegisteredKey;
62-
6362
#[cfg(test)]
63+
/// Test flag to stall the miner thread
6464
pub static TEST_MINE_STALL: LazyLock<TestFlag<bool>> = LazyLock::new(TestFlag::default);
6565
#[cfg(test)]
66+
/// Test flag to stall block proposal broadcasting
6667
pub static TEST_BROADCAST_STALL: LazyLock<TestFlag<bool>> = LazyLock::new(TestFlag::default);
6768
#[cfg(test)]
6869
pub static TEST_BLOCK_ANNOUNCE_STALL: LazyLock<TestFlag<bool>> = LazyLock::new(TestFlag::default);
@@ -239,6 +240,10 @@ impl BlockMinerThread {
239240
}
240241
}
241242

243+
pub fn get_abort_flag(&self) -> Arc<AtomicBool> {
244+
self.abort_flag.clone()
245+
}
246+
242247
#[cfg(test)]
243248
fn fault_injection_block_broadcast_stall(new_block: &NakamotoBlock) {
244249
if TEST_BROADCAST_STALL.get() {

testnet/stacks-node/src/nakamoto_node/relayer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ impl RelayerThread {
10991099
reason,
11001100
burn_tip_at_start,
11011101
)?;
1102-
let miner_abort_flag = new_miner_state.abort_flag.clone();
1102+
let miner_abort_flag = new_miner_state.get_abort_flag();
11031103

11041104
debug!("Relayer: starting new tenure thread");
11051105

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,6 +5030,7 @@ fn forked_tenure_is_ignored() {
50305030
// Stall the miner thread; only wait until the number of submitted commits increases.
50315031
TEST_BROADCAST_STALL.set(true);
50325032
TEST_BLOCK_ANNOUNCE_STALL.set(true);
5033+
50335034
let blocks_before = mined_blocks.load(Ordering::SeqCst);
50345035
let commits_before = commits_submitted.load(Ordering::SeqCst);
50355036

0 commit comments

Comments
 (0)