Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore bootcode contract call and stx transfer only blocks in processing time calculation #5488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ impl SignerDb {
// If we have no blocks known for this tenure, we will assume it has only JUST started and calculate
// our tenure extend timestamp based on the epoch time in secs.
let mut tenure_start_timestamp = None;
let mut tenure_process_time_ms = 0;
let mut tenure_process_time_ms = 0_u64;
// Note that the globally accepted blocks are already returned in descending order of stacks height, therefore by newest block to oldest block
for block_info in self
.get_globally_accepted_blocks(consensus_hash)
Expand All @@ -865,7 +865,9 @@ impl SignerDb {
{
// Always use the oldest block as our tenure start timestamp
tenure_start_timestamp = Some(block_info.proposed_time);
tenure_process_time_ms += block_info.validation_time_ms.unwrap_or(0);

tenure_process_time_ms =
tenure_process_time_ms.saturating_add(block_info.validation_time_ms.unwrap_or(0));

if block_info
.block
Expand Down
17 changes: 16 additions & 1 deletion stacks-signer/src/v0/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use std::sync::mpsc::Sender;
use std::time::{Duration, Instant};

use blockstack_lib::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader};
use blockstack_lib::chainstate::stacks::address::StacksAddressExtensions;
use blockstack_lib::chainstate::stacks::TransactionPayload;
use blockstack_lib::net::api::postblock_proposal::{
BlockValidateOk, BlockValidateReject, BlockValidateResponse,
};
Expand Down Expand Up @@ -587,7 +589,20 @@ impl Signer {
block_info.signed_self.get_or_insert(get_epoch_time_secs());
}
// Record the block validation time
block_info.validation_time_ms = Some(block_validate_ok.validation_time_ms);
let non_bootcode_contract_call_block = block_info.block.txs.iter().any(|tx| {
jferrant marked this conversation as resolved.
Show resolved Hide resolved
// We only care about blocks that contain a non bootcode contract call
match &tx.payload {
TransactionPayload::ContractCall(cc) => !cc.address.is_boot_code_addr(),
TransactionPayload::SmartContract(..) => true,
_ => false,
}
});
if non_bootcode_contract_call_block {
block_info.validation_time_ms = Some(block_validate_ok.validation_time_ms);
} else {
// Ignore purely boot code and stx transfers when calculating the processing/validation time
block_info.validation_time_ms = Some(0);
}

let signature = self
.private_key
Expand Down