Skip to content

Commit 9b09f0b

Browse files
committed
call correct .signers function, error fast rather than retry
1 parent 78b715c commit 9b09f0b

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

stacks-signer/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ pub(crate) mod tests {
605605
}
606606

607607
pub fn build_get_last_set_cycle_response(cycle: u64) -> String {
608-
let clarity_value = ClarityValue::UInt(cycle as u128);
608+
let clarity_value = ClarityValue::okay(ClarityValue::UInt(cycle as u128)).unwrap();
609609
build_read_only_response(&clarity_value)
610610
}
611611
}

stacks-signer/src/client/stacks_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ impl StacksClient {
165165
/// Get the last set reward cycle stored within the stackerdb contract
166166
pub fn get_last_set_cycle(&self) -> Result<u128, ClientError> {
167167
let signer_stackerdb_contract_id = boot_code_id(SIGNERS_NAME, self.mainnet);
168-
let function_name_str = "stackerdb-get-last-set-cycle";
168+
let function_name_str = "get-last-set-cycle";
169169
let function_name = ClarityName::from(function_name_str);
170170
let value = self.read_only_contract_call(
171171
&signer_stackerdb_contract_id.issuer.clone().into(),
172172
&signer_stackerdb_contract_id.name,
173173
&function_name,
174174
&[],
175175
)?;
176-
Ok(value.expect_u128()?)
176+
Ok(value.expect_result_ok()?.expect_u128()?)
177177
}
178178

179179
/// Retrieve the signer slots stored within the stackerdb contract

stacks-signer/src/runloop.rs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -297,31 +297,28 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
297297
};
298298

299299
// Ensure that the stackerdb has been updated for the reward cycle before proceeding
300-
retry_with_exponential_backoff(|| {
301-
let last_calculated_reward_cycle = self
302-
.stacks_client
303-
.get_last_set_cycle()
304-
.map_err(|e| backoff::Error::transient(e.into()))?;
305-
if last_calculated_reward_cycle < reward_cycle as u128 {
300+
let last_calculated_reward_cycle =
301+
self.stacks_client.get_last_set_cycle().map_err(|e| {
306302
warn!(
307-
"Stackerdb has not been updated for reward cycle {reward_cycle}. Last calculated reward cycle is {last_calculated_reward_cycle}."
303+
"Failed to fetch last calculated stackerdb cycle from stacks-node";
304+
"reward_cycle" => reward_cycle,
305+
"err" => ?e
308306
);
309-
Err(backoff::Error::transient(
310-
ConfigurationError::StackerDBNotUpdated,
311-
))
312-
} else {
313-
Ok(())
314-
}
315-
})?;
307+
ConfigurationError::StackerDBNotUpdated
308+
})?;
309+
if last_calculated_reward_cycle < reward_cycle as u128 {
310+
warn!(
311+
"Stackerdb has not been updated for reward cycle {reward_cycle}. Last calculated reward cycle is {last_calculated_reward_cycle}."
312+
);
313+
return Err(ConfigurationError::StackerDBNotUpdated);
314+
}
316315

317-
let signer_slot_ids = match self.get_parsed_signer_slots(&self.stacks_client, reward_cycle)
318-
{
319-
Ok(x) => x,
320-
Err(e) => {
316+
let signer_slot_ids = self
317+
.get_parsed_signer_slots(&self.stacks_client, reward_cycle)
318+
.map_err(|e| {
321319
warn!("Error while fetching stackerdb slots {reward_cycle}: {e:?}");
322-
return Err(e.into());
323-
}
324-
};
320+
e
321+
})?;
325322
let current_addr = self.stacks_client.get_signer_address();
326323

327324
let Some(signer_slot_id) = signer_slot_ids.get(current_addr) else {

0 commit comments

Comments
 (0)