Skip to content

Commit 92b1a3d

Browse files
committed
Add some debug logs to tenure extend timestamp calc and roundup the processing time
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 3bccb23 commit 92b1a3d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

stacks-signer/src/signerdb.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,15 +1001,19 @@ impl SignerDb {
10011001
})?;
10021002
let mut tenure_processing_time_ms = 0_u64;
10031003
let mut tenure_start_time = None;
1004-
for row in rows {
1004+
let mut nmb_rows = 0;
1005+
for (i, row) in rows.enumerate() {
1006+
nmb_rows += 1;
10051007
let (tenure_change_block, proposed_time, validation_time_ms) = row?;
10061008
tenure_processing_time_ms =
10071009
tenure_processing_time_ms.saturating_add(validation_time_ms.unwrap_or(0));
10081010
tenure_start_time = Some(proposed_time);
10091011
if tenure_change_block {
1012+
debug!("Found tenure change block {i} blocks ago in tenure {tenure}");
10101013
break;
10111014
}
10121015
}
1016+
debug!("Calculated tenure extend timestamp from {nmb_rows} blocks in tenure {tenure}");
10131017
Ok((
10141018
tenure_start_time.unwrap_or(get_epoch_time_secs()),
10151019
tenure_processing_time_ms,
@@ -1024,9 +1028,19 @@ impl SignerDb {
10241028
) -> u64 {
10251029
let tenure_idle_timeout_secs = tenure_idle_timeout.as_secs();
10261030
let (tenure_start_time, tenure_process_time_ms) = self.get_tenure_times(tenure).inspect_err(|e| error!("Error occurred calculating tenure extend timestamp: {e:?}. Defaulting to {tenure_idle_timeout_secs} from now.")).unwrap_or((get_epoch_time_secs(), 0));
1027-
tenure_start_time
1031+
// Plus (ms + 999)/1000 to round up to the nearest second
1032+
let tenure_extend_timestamp = tenure_start_time
10281033
.saturating_add(tenure_idle_timeout_secs)
1029-
.saturating_add(tenure_process_time_ms / 1000)
1034+
.saturating_add(tenure_process_time_ms.saturating_add(999) / 1000);
1035+
debug!("Calculated tenure extend timestamp";
1036+
"tenure_extend_timestamp" => tenure_extend_timestamp,
1037+
"tenure_start_time" => tenure_start_time,
1038+
"tenure_process_time_ms" => tenure_process_time_ms,
1039+
"tenure_idle_timeout_secs" => tenure_idle_timeout_secs,
1040+
"tenure_extend_in" => tenure_extend_timestamp.saturating_sub(get_epoch_time_secs()),
1041+
"consensus_hash" => %tenure,
1042+
);
1043+
tenure_extend_timestamp
10301044
}
10311045
}
10321046

0 commit comments

Comments
 (0)