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

Chore/cache timestamp calc #5494

Merged
merged 11 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,14 @@ impl ExecutionCost {
read_length: first.read_length.max(second.read_length),
}
}

pub fn is_zero(&self) -> bool {
self.write_length == 0
&& self.write_count == 0
&& self.read_length == 0
&& self.read_count == 0
&& self.runtime == 0
}
}

// ONLY WORKS IF INPUT IS u64
Expand Down
2 changes: 1 addition & 1 deletion stacks-signer/src/chainstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl SortitionsView {
let changed_burn_view =
tenure_extend.burn_view_consensus_hash != sortition_consensus_hash;
let enough_time_passed = get_epoch_time_secs()
> signer_db.get_tenure_extend_timestamp(
> signer_db.calculate_tenure_extend_timestamp(
self.config.tenure_idle_timeout,
&sortition_consensus_hash,
);
Expand Down
2 changes: 2 additions & 0 deletions stacks-signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pub trait Signer<T: SignerEventTrait>: Debug + Display {
);
/// Check if the signer is in the middle of processing blocks
fn has_unprocessed_blocks(&self) -> bool;
/// Cleanup signer stale data
fn cleanup_stale_data(&mut self, current_reward_cycle: u64);
}

/// A wrapper around the running signer type for the signer
Expand Down
8 changes: 8 additions & 0 deletions stacks-signer/src/runloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
"is_in_next_prepare_phase" => is_in_next_prepare_phase,
);

if reward_cycle_before_refresh != current_reward_cycle {
for signer in self.stacks_signers.values_mut() {
if let ConfiguredSigner::RegisteredSigner(signer) = signer {
signer.cleanup_stale_data(current_reward_cycle);
}
}
}

// Check if we need to refresh the signers:
// need to refresh the current signer if we are not configured for the current reward cycle
// need to refresh the next signer if we're not configured for the next reward cycle, and we're in the prepare phase
Expand Down
Loading