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 1 commit
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
17 changes: 3 additions & 14 deletions stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::path::Path;
use std::time::{Duration, SystemTime};

use blockstack_lib::chainstate::nakamoto::NakamotoBlock;
use blockstack_lib::chainstate::stacks::address::StacksAddressExtensions;
use blockstack_lib::chainstate::stacks::TransactionPayload;
use blockstack_lib::util_lib::db::{
query_row, query_rows, sqlite_open, table_exists, tx_begin_immediate, u64_to_sql,
Expand Down Expand Up @@ -866,19 +865,9 @@ impl SignerDb {
{
// Always use the oldest block as our tenure start timestamp
tenure_start_timestamp = Some(block_info.proposed_time);
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 {
tenure_process_time_ms = tenure_process_time_ms
.saturating_add(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