Skip to content

Commit

Permalink
Merge pull request #5488 from stacks-network/chore/ignore-stx-transfe…
Browse files Browse the repository at this point in the history
…r-blocks

Ignore bootcode contract call and stx transfer only blocks in processing time calculation
  • Loading branch information
obycode authored Nov 22, 2024
2 parents c361f1d + b6cf238 commit 59e74ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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| {
// 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

0 comments on commit 59e74ac

Please sign in to comment.