Skip to content

Commit 9aa669c

Browse files
authored
Merge branch 'develop' into feat/sip-029
2 parents fc6db45 + ea7f7cd commit 9aa669c

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

stacks-signer/src/client/stacks_client.rs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ impl StacksClient {
173173
&self,
174174
consensus_hash: &ConsensusHash,
175175
) -> Result<StacksBlockHeaderTypes, ClientError> {
176+
debug!("StacksClient: Getting tenure tip";
177+
"consensus_hash" => %consensus_hash,
178+
);
176179
let send_request = || {
177180
self.stacks_node_client
178181
.get(self.tenure_tip_path(consensus_hash))
@@ -192,6 +195,7 @@ impl StacksClient {
192195

193196
/// Get the last set reward cycle stored within the stackerdb contract
194197
pub fn get_last_set_cycle(&self) -> Result<u128, ClientError> {
198+
debug!("StacksClient: Getting last set cycle");
195199
let signer_stackerdb_contract_id = boot_code_id(SIGNERS_NAME, self.mainnet);
196200
let function_name_str = "get-last-set-cycle";
197201
let function_name = ClarityName::from(function_name_str);
@@ -210,6 +214,10 @@ impl StacksClient {
210214
stackerdb_contract: &QualifiedContractIdentifier,
211215
page: u32,
212216
) -> Result<Vec<(StacksAddress, u128)>, ClientError> {
217+
debug!("StacksClient: Getting signer slots";
218+
"stackerdb_contract" => %stackerdb_contract,
219+
"page" => page,
220+
);
213221
let function_name_str = "stackerdb-get-signer-slots-page";
214222
let function_name = ClarityName::from(function_name_str);
215223
let function_args = &[ClarityValue::UInt(page.into())];
@@ -250,6 +258,9 @@ impl StacksClient {
250258
&self,
251259
reward_cycle: u64,
252260
) -> Result<HashMap<StacksAddress, SignerSlotID>, ClientError> {
261+
debug!("StacksClient: Getting parsed signer slots";
262+
"reward_cycle" => reward_cycle,
263+
);
253264
let signer_set =
254265
u32::try_from(reward_cycle % 2).expect("FATAL: reward_cycle % 2 exceeds u32::MAX");
255266
let signer_stackerdb_contract_id = boot_code_id(SIGNERS_NAME, self.mainnet);
@@ -272,6 +283,7 @@ impl StacksClient {
272283

273284
/// Determine the stacks node current epoch
274285
pub fn get_node_epoch(&self) -> Result<StacksEpochId, ClientError> {
286+
debug!("StacksClient: Getting node epoch");
275287
let pox_info = self.get_pox_data()?;
276288
let burn_block_height = self.get_burn_block_height()?;
277289

@@ -302,7 +314,7 @@ impl StacksClient {
302314

303315
/// Submit the block proposal to the stacks node. The block will be validated and returned via the HTTP endpoint for Block events.
304316
pub fn submit_block_for_validation(&self, block: NakamotoBlock) -> Result<(), ClientError> {
305-
debug!("stacks_node_client: Submitting block for validation...";
317+
debug!("StacksClient: Submitting block for validation";
306318
"signer_sighash" => %block.header.signer_signature_hash(),
307319
"block_id" => %block.header.block_id(),
308320
"block_height" => %block.header.chain_length,
@@ -337,6 +349,10 @@ impl StacksClient {
337349
chosen_parent: &ConsensusHash,
338350
last_sortition: &ConsensusHash,
339351
) -> Result<Vec<TenureForkingInfo>, ClientError> {
352+
debug!("StacksClient: Getting tenure forking info";
353+
"chosen_parent" => %chosen_parent,
354+
"last_sortition" => %last_sortition,
355+
);
340356
let mut tenures: VecDeque<TenureForkingInfo> =
341357
self.get_tenure_forking_info_step(chosen_parent, last_sortition)?;
342358
if tenures.is_empty() {
@@ -373,7 +389,7 @@ impl StacksClient {
373389
chosen_parent: &ConsensusHash,
374390
last_sortition: &ConsensusHash,
375391
) -> Result<VecDeque<TenureForkingInfo>, ClientError> {
376-
debug!("stacks_node_client: Getting tenure forking info...";
392+
debug!("StacksClient: Getting tenure forking info";
377393
"chosen_parent" => %chosen_parent,
378394
"last_sortition" => %last_sortition,
379395
);
@@ -402,7 +418,7 @@ impl StacksClient {
402418

403419
/// Get the current winning sortition and the last winning sortition
404420
pub fn get_current_and_last_sortition(&self) -> Result<CurrentAndLastSortition, ClientError> {
405-
debug!("stacks_node_client: Getting current and prior sortition...");
421+
debug!("StacksClient: Getting current and prior sortition");
406422
let path = format!("{}/latest_and_last", self.sortition_info_path());
407423
let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin);
408424
let send_request = || {
@@ -443,7 +459,7 @@ impl StacksClient {
443459

444460
/// Get the current peer info data from the stacks node
445461
pub fn get_peer_info(&self) -> Result<PeerInfo, ClientError> {
446-
debug!("stacks_node_client: Getting peer info...");
462+
debug!("StacksClient: Getting peer info");
447463
let timer =
448464
crate::monitoring::new_rpc_call_timer(&self.core_info_path(), &self.http_origin);
449465
let send_request = || {
@@ -466,7 +482,9 @@ impl StacksClient {
466482
&self,
467483
reward_cycle: u64,
468484
) -> Result<Option<Vec<NakamotoSignerEntry>>, ClientError> {
469-
debug!("stacks_node_client: Getting reward set signers for reward cycle {reward_cycle}...");
485+
debug!("StacksClient: Getting reward set signers";
486+
"reward_cycle" => reward_cycle,
487+
);
470488
let timer = crate::monitoring::new_rpc_call_timer(
471489
&format!("{}/v3/stacker_set/:reward_cycle", self.http_origin),
472490
&self.http_origin,
@@ -502,7 +520,7 @@ impl StacksClient {
502520

503521
/// Retrieve the current pox data from the stacks node
504522
pub fn get_pox_data(&self) -> Result<RPCPoxInfoData, ClientError> {
505-
debug!("stacks_node_client: Getting pox data...");
523+
debug!("StacksClient: Getting pox data");
506524
let timer = crate::monitoring::new_rpc_call_timer(&self.pox_path(), &self.http_origin);
507525
let send_request = || {
508526
self.stacks_node_client
@@ -521,11 +539,13 @@ impl StacksClient {
521539

522540
/// Helper function to retrieve the burn tip height from the stacks node
523541
fn get_burn_block_height(&self) -> Result<u64, ClientError> {
542+
debug!("StacksClient: Getting burn block height");
524543
self.get_peer_info().map(|info| info.burn_block_height)
525544
}
526545

527546
/// Get the current reward cycle info from the stacks node
528547
pub fn get_current_reward_cycle_info(&self) -> Result<RewardCycleInfo, ClientError> {
548+
debug!("StacksClient: Getting current reward cycle info");
529549
let pox_data = self.get_pox_data()?;
530550
let blocks_mined = pox_data
531551
.current_burnchain_block_height
@@ -548,7 +568,9 @@ impl StacksClient {
548568
&self,
549569
address: &StacksAddress,
550570
) -> Result<AccountEntryResponse, ClientError> {
551-
debug!("stacks_node_client: Getting account info...");
571+
debug!("StacksClient: Getting account info";
572+
"address" => %address,
573+
);
552574
let timer_label = format!("{}/v2/accounts/:principal", self.http_origin);
553575
let timer = crate::monitoring::new_rpc_call_timer(&timer_label, &self.http_origin);
554576
let send_request = || {
@@ -570,6 +592,11 @@ impl StacksClient {
570592
///
571593
/// In tests, this panics if the retry takes longer than 30 seconds.
572594
pub fn post_block_until_ok<F: Display>(&self, log_fmt: &F, block: &NakamotoBlock) -> bool {
595+
debug!("StacksClient: Posting block to stacks node";
596+
"signer_sighash" => %block.header.signer_signature_hash(),
597+
"block_id" => %block.header.block_id(),
598+
"block_height" => %block.header.chain_length,
599+
);
573600
let start_time = Instant::now();
574601
loop {
575602
match self.post_block(block) {
@@ -595,7 +622,8 @@ impl StacksClient {
595622
/// Returns `true` if the block was accepted or `false` if the block
596623
/// was rejected.
597624
pub fn post_block(&self, block: &NakamotoBlock) -> Result<bool, ClientError> {
598-
debug!("stacks_node_client: Posting block to the stacks node...";
625+
debug!("StacksClient: Posting block to the stacks node";
626+
"signer_sighash" => %block.header.signer_signature_hash(),
599627
"block_id" => %block.header.block_id(),
600628
"block_height" => %block.header.chain_length,
601629
);
@@ -630,7 +658,9 @@ impl StacksClient {
630658
function_name: &ClarityName,
631659
function_args: &[ClarityValue],
632660
) -> Result<ClarityValue, ClientError> {
633-
debug!("stacks_node_client: Calling read-only function {function_name} with args {function_args:?}...");
661+
debug!(
662+
"StacksClient: Calling read-only function {function_name} with args {function_args:?}"
663+
);
634664
let args = function_args
635665
.iter()
636666
.filter_map(|arg| arg.serialize_to_hex().ok())

0 commit comments

Comments
 (0)