Skip to content

Commit 6fccd18

Browse files
committed
chore: add comments requested in code review
Also add one more assertion to the test.
1 parent 870187b commit 6fccd18

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

stackslib/src/chainstate/nakamoto/miner.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,18 @@ pub struct MinerTenureInfo<'a> {
150150
pub tenure_block_commit_opt: Option<LeaderBlockCommitOp>,
151151
}
152152

153+
/// Structure returned from `NakamotoBlockBuilder::build_nakamoto_block` with
154+
/// information about the block that was built.
153155
pub struct BlockMetadata {
156+
/// The block that was built
154157
pub block: NakamotoBlock,
158+
/// The execution cost consumed so far by the current tenure
155159
pub tenure_consumed: ExecutionCost,
160+
/// The cost budget for the current tenure
156161
pub tenure_budget: ExecutionCost,
162+
/// The size of the blocks in the current tenure in bytes
157163
pub tenure_size: u64,
164+
/// The events emitted by the transactions included in this block
158165
pub tx_events: Vec<TransactionEvent>,
159166
}
160167

stackslib/src/config/mod.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,40 @@ pub const OP_TX_ANY_ESTIM_SIZE: u64 = fmax!(
8686
OP_TX_VOTE_AGG_ESTIM_SIZE
8787
);
8888

89+
/// Default maximum percentage of `satoshis_per_byte` that a Bitcoin fee rate
90+
/// may be increased to when RBFing a transaction
8991
const DEFAULT_MAX_RBF_RATE: u64 = 150; // 1.5x
92+
/// Amount to increment the fee by, in Sats/vByte, when RBFing a Bitcoin
93+
/// transaction
9094
const DEFAULT_RBF_FEE_RATE_INCREMENT: u64 = 5;
95+
/// Default number of reward cycles of blocks to sync in a non-full inventory
96+
/// sync
9197
const INV_REWARD_CYCLES_TESTNET: u64 = 6;
98+
/// Default minimum time to wait between mining blocks in milliseconds. The
99+
/// value must be greater than or equal to 1000 ms because if a block is mined
100+
/// within the same second as its parent, it will be rejected by the signers.
92101
const DEFAULT_MIN_TIME_BETWEEN_BLOCKS_MS: u64 = 1_000;
102+
/// Default time in milliseconds to pause after receiving the first threshold
103+
/// rejection, before proposing a new block.
93104
const DEFAULT_FIRST_REJECTION_PAUSE_MS: u64 = 5_000;
105+
/// Default time in milliseconds to pause after receiving subsequent threshold
106+
/// rejections, before proposing a new block.
94107
const DEFAULT_SUBSEQUENT_REJECTION_PAUSE_MS: u64 = 10_000;
108+
/// Default time in milliseconds to wait for a Nakamoto block after seeing a
109+
/// burnchain block before submitting a block commit.
95110
const DEFAULT_BLOCK_COMMIT_DELAY_MS: u64 = 20_000;
111+
/// Default percentage of the remaining tenure cost limit to consume each block
96112
const DEFAULT_TENURE_COST_LIMIT_PER_BLOCK_PERCENTAGE: u8 = 25;
113+
/// Default number of seconds to wait in-between polling the sortition DB to
114+
/// see if we need to extend the ongoing tenure (e.g. because the current
115+
/// sortition is empty or invalid).
97116
const DEFAULT_TENURE_EXTEND_POLL_SECS: u64 = 1;
98-
99-
// This should be greater than the signers' timeout. This is used for issuing fallback tenure extends
117+
/// Default duration to wait before attempting to issue a tenure extend.
118+
/// This should be greater than the signers' timeout. This is used for issuing
119+
/// fallback tenure extends
100120
const DEFAULT_TENURE_TIMEOUT_SECS: u64 = 180;
121+
/// Default percentage of block budget that must be used before attempting a
122+
/// time-based tenure extend
101123
const DEFAULT_TENURE_EXTEND_COST_THRESHOLD: u64 = 50;
102124

103125
static HELIUM_DEFAULT_CONNECTION_OPTIONS: LazyLock<ConnectionOptions> =
@@ -1192,9 +1214,13 @@ pub struct BurnchainConfig {
11921214
pub process_exit_at_block_height: Option<u64>,
11931215
pub poll_time_secs: u64,
11941216
pub satoshis_per_byte: u64,
1217+
/// Maximum percentage of `satoshis_per_byte` that a Bitcoin fee rate may
1218+
/// be increased to when RBFing a transaction
11951219
pub max_rbf: u64,
11961220
pub leader_key_tx_estimated_size: u64,
11971221
pub block_commit_tx_estimated_size: u64,
1222+
/// Amount to increment the fee by, in Sats/vByte, when RBFing a Bitcoin
1223+
/// transaction
11981224
pub rbf_fee_increment: u64,
11991225
pub first_burn_block_height: Option<u64>,
12001226
pub first_burn_block_timestamp: Option<u32>,

stackslib/src/net/connection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ pub struct ConnectionOptions {
379379
/// Units are milliseconds. A value of 0 means "never".
380380
pub log_neighbors_freq: u64,
381381
pub inv_sync_interval: u64,
382+
// how many reward cycles of blocks to sync in a non-full inventory sync
382383
pub inv_reward_cycles: u64,
383384
pub download_interval: u64,
384385
pub pingback_timeout: u64,

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12683,6 +12683,11 @@ fn tenure_extend_cost_threshold() {
1268312683
})
1268412684
.expect("Contract not included in block");
1268512685

12686+
// Ensure the tenure was not extended in that block
12687+
assert!(!last_block_contains_tenure_change_tx(
12688+
TenureChangeCause::Extended
12689+
));
12690+
1268612691
// Now, lets call the contract a bunch of times to increase the tenure cost
1268712692
for _ in 0..num_txs {
1268812693
let call_tx = make_contract_call(

0 commit comments

Comments
 (0)