Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dd2090d
added total_tenure_size tracking and limiting
rdeioris Sep 12, 2025
669a9cc
prepare for better test
rdeioris Sep 12, 2025
0438a27
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Sep 15, 2025
29c484e
improve integration test
rdeioris Sep 15, 2025
fbc31c1
added integration tests
rdeioris Sep 16, 2025
209b9c1
fixed typo, enforce max_tenure_bytes to 0 for shadow blocks
rdeioris Sep 18, 2025
d292f8a
added CHAINSTATE_VERSION_NUMBER
rdeioris Sep 18, 2025
1c25cb8
refactored total_tenure_size query
rdeioris Sep 24, 2025
9b841d9
added tenure extend if total tenure size is > 50% [prototype]
rdeioris Sep 24, 2025
01affd3
merged with develop
rdeioris Sep 24, 2025
fa75b94
fixed tests
rdeioris Sep 24, 2025
fd3193e
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Sep 25, 2025
7461739
merged with develop
rdeioris Sep 25, 2025
bffb2d8
report max_tenure_bytes
rdeioris Sep 25, 2025
c569ba7
take into account tenure size limit when tenure extending
rdeioris Sep 26, 2025
2e5576d
check if signers still fail
rdeioris Sep 26, 2025
b2c29fe
fix cargo check
rdeioris Sep 28, 2025
2d9ca07
another check for CI
rdeioris Sep 28, 2025
5aceb9e
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Sep 29, 2025
2390efc
fixed postblock_proposal
rdeioris Sep 29, 2025
55b7c5f
re-added tenure extend management
rdeioris Sep 29, 2025
d00bd11
fixed tenure extend support
rdeioris Sep 29, 2025
f0759f5
added config option for log_skipped_transactions
rdeioris Sep 30, 2025
84cb785
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Oct 2, 2025
5b12dce
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Oct 7, 2025
d6a0e87
better error management for get_block_header_nakamoto_total_tenure_size
rdeioris Oct 7, 2025
6c1e699
fixed typo
rdeioris Oct 7, 2025
23f3477
added sql comment about total_tenure_size
rdeioris Oct 7, 2025
432252a
added tenure extend check
rdeioris Oct 7, 2025
686d36d
ensure no tenure extend in tests
rdeioris Oct 7, 2025
ef4a9dc
added comment about total_tenure_size not being consensus critical
rdeioris Oct 7, 2025
c819417
merged with develop
rdeioris Oct 20, 2025
abbac45
removed automatic tenure extend based on tenure size
rdeioris Oct 20, 2025
ad8e934
removed space
rdeioris Oct 20, 2025
591d431
added docs for log_skipped_transactions
rdeioris Oct 20, 2025
1800f4f
added docs for max_tenure_bytes
rdeioris Oct 20, 2025
0f36e8a
added warning if tenure size cannot be retrieved
rdeioris Oct 23, 2025
f256d9b
Merge branch 'develop' into feat/max_tenure_bytes
rdeioris Oct 23, 2025
7698014
merged with develop
rdeioris Oct 30, 2025
5f6c0c4
fixed signer test
rdeioris Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions stacks-node/src/nakamoto_node/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[cfg(test)]
use std::sync::LazyLock;
use std::thread;
use std::time::{Duration, Instant};
use std::{cmp, thread};

use clarity::boot_util::boot_code_id;
use clarity::vm::costs::ExecutionCost;
Expand Down Expand Up @@ -1661,6 +1661,9 @@ impl BlockMinerThread {
}
}
};

let parent_block_id = parent_block_info.stacks_parent_header.index_block_hash();

// Check if we can and should include a time-based tenure extend.
if self.last_block_mined.is_some() {
if self.config.miner.replay_transactions
Expand All @@ -1673,12 +1676,30 @@ impl BlockMinerThread {
info!("Tenure extend: In replay, always extending tenure");
self.tenure_extend_reset();
} else {
// Do not extend if we have spent < 50% of the budget, since it is
// Do not extend if we have spent < 50% of the budget and < 50% of the tenure size limit, since it is
// not necessary.

let mut tenure_size_usage = 0;

if let Some(total_tenure_size) =
match NakamotoChainState::get_block_header_nakamoto_total_tenure_size(
chainstate.db(),
&parent_block_id,
) {
Ok(total_tenure_size) => total_tenure_size,
Err(_) => Some(0),
}
{
tenure_size_usage =
total_tenure_size / cmp::max(1, self.config.miner.max_tenure_bytes / 100);
}

let usage = self
.tenure_budget
.proportion_largest_dimension(&self.tenure_cost);
if usage < self.config.miner.tenure_extend_cost_threshold {
if usage < self.config.miner.tenure_extend_cost_threshold
&& tenure_size_usage < self.config.miner.tenure_extend_cost_threshold
{
return Ok(NakamotoTenureInfo {
coinbase_tx: None,
tenure_change_tx: None,
Expand All @@ -1705,7 +1726,6 @@ impl BlockMinerThread {
}
}

let parent_block_id = parent_block_info.stacks_parent_header.index_block_hash();
let mut payload = TenureChangePayload {
tenure_consensus_hash: self.burn_election_block.consensus_hash.clone(),
prev_tenure_consensus_hash: parent_tenure_info.parent_tenure_consensus_hash.clone(),
Expand Down
Loading