Skip to content

Commit bc0c548

Browse files
committed
fix: last locally or globally accepted block in tenure
In `get_tenure_last_block_info`, if the last accepted block is globally accepted, then we shouldn't care about the timeout. That should only be checked for locally accepted blocks.
1 parent d185f2d commit bc0c548

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

stacks-signer/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
- Introduced `capitulate_miner_view_timeout_secs`: the duration (in seconds) for the signer to wait between updating the local state machine viewpoint and capitulating to other signers' miner views.
1414
- Added codepath to enable signers to evaluate block proposals and miner activity against global signer state for improved consistency and correctness. Currently feature gated behind the `SUPPORTED_SIGNER_PROTOCOL_VERSION`
1515

16+
### Fixed
17+
18+
- Fixed a bug where signers would incorrectly reject block proposals if the parent block was globally accepted and the signer hadn't signed it within the `tenure_last_block_proposal_timeout` period; if it is globally accepted, the signer should accept it regardless of the timeout.
19+
1620
## [3.1.0.0.13.0]
1721

1822
### Changed

stacks-signer/src/chainstate/mod.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,25 +268,37 @@ impl SortitionData {
268268
signer_db: &SignerDb,
269269
tenure_last_block_proposal_timeout: Duration,
270270
) -> Result<Option<BlockInfo>, ClientError> {
271-
// Get the last known block in the previous tenure
272-
let last_locally_accepted_block = signer_db
271+
// Get the last accepted block in the tenure
272+
let last_accepted_block = signer_db
273273
.get_last_accepted_block(consensus_hash)
274274
.map_err(|e| ClientError::InvalidResponse(e.to_string()))?;
275-
let Some(local_info) = last_locally_accepted_block else {
275+
276+
let Some(block_info) = last_accepted_block else {
276277
return Ok(None);
277278
};
278279

279-
let Some(signed_over_time) = local_info.signed_self else {
280+
// If the last accepted block was globally accepted, return it
281+
if block_info.state == BlockState::GloballyAccepted {
282+
return Ok(Some(block_info));
283+
}
284+
285+
// If the last accepted block was locally accepted, check if it has timed out
286+
let Some(signed_over_time) = block_info.signed_self else {
280287
return Ok(None);
281288
};
282289

283290
if signed_over_time.saturating_add(tenure_last_block_proposal_timeout.as_secs())
284291
> get_epoch_time_secs()
285292
{
286293
// The last locally accepted block is not timed out, return it
287-
Ok(Some(local_info))
294+
Ok(Some(block_info))
288295
} else {
289296
// The last locally accepted block is timed out
297+
info!(
298+
"Last locally accepted block hass timed out";
299+
"signer_signature_hash" => %block_info.block.header.signer_signature_hash(),
300+
"signed_over_time" => signed_over_time,
301+
);
290302
Ok(None)
291303
}
292304
}

0 commit comments

Comments
 (0)