Skip to content

Commit 9999941

Browse files
authored
Merge pull request #5530 from stacks-network/feat/time-based-tenure-extend
Time based tenure extend
2 parents 025af8e + 0e8d40f commit 9999941

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2912
-1195
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ jobs:
122122
- tests::signer::v0::signer_set_rollover
123123
- tests::signer::v0::signing_in_0th_tenure_of_reward_cycle
124124
- tests::signer::v0::continue_after_tenure_extend
125+
- tests::signer::v0::tenure_extend_after_idle
126+
- tests::signer::v0::stx_transfers_dont_effect_idle_timeout
127+
- tests::signer::v0::idle_tenure_extend_active_mining
125128
- tests::signer::v0::multiple_miners_with_custom_chain_id
126129
- tests::signer::v0::block_commit_delay
127130
- tests::signer::v0::continue_after_fast_block_no_sortition

clarity/src/vm/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ mod test {
353353
) -> std::result::Result<ExecutionCost, CostErrors> {
354354
self.invoked_functions.push((cost_f, input.to_vec()));
355355
self.invocation_count += 1;
356-
Ok(ExecutionCost::zero())
356+
Ok(ExecutionCost::ZERO)
357357
}
358358
fn add_cost(&mut self, _cost: ExecutionCost) -> std::result::Result<(), CostErrors> {
359359
self.cost_addition_count += 1;

clarity/src/vm/costs/mod.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl CostTracker for () {
140140
_cost_function: ClarityCostFunction,
141141
_input: &[u64],
142142
) -> std::result::Result<ExecutionCost, CostErrors> {
143-
Ok(ExecutionCost::zero())
143+
Ok(ExecutionCost::ZERO)
144144
}
145145
fn add_cost(&mut self, _cost: ExecutionCost) -> std::result::Result<(), CostErrors> {
146146
Ok(())
@@ -707,7 +707,7 @@ impl LimitedCostTracker {
707707
contract_call_circuits: HashMap::new(),
708708
limit,
709709
memory_limit: CLARITY_MEMORY_LIMIT,
710-
total: ExecutionCost::zero(),
710+
total: ExecutionCost::ZERO,
711711
memory: 0,
712712
epoch,
713713
mainnet,
@@ -731,7 +731,7 @@ impl LimitedCostTracker {
731731
contract_call_circuits: HashMap::new(),
732732
limit,
733733
memory_limit: CLARITY_MEMORY_LIMIT,
734-
total: ExecutionCost::zero(),
734+
total: ExecutionCost::ZERO,
735735
memory: 0,
736736
epoch,
737737
mainnet,
@@ -880,7 +880,7 @@ impl LimitedCostTracker {
880880
pub fn get_total(&self) -> ExecutionCost {
881881
match self {
882882
Self::Limited(TrackerData { total, .. }) => total.clone(),
883-
Self::Free => ExecutionCost::zero(),
883+
Self::Free => ExecutionCost::ZERO,
884884
}
885885
}
886886
#[allow(clippy::panic)]
@@ -1050,7 +1050,7 @@ impl CostTracker for LimitedCostTracker {
10501050
match self {
10511051
Self::Free => {
10521052
// tracker is free, return zero!
1053-
return Ok(ExecutionCost::zero());
1053+
return Ok(ExecutionCost::ZERO);
10541054
}
10551055
Self::Limited(ref mut data) => {
10561056
if cost_function == ClarityCostFunction::Unimplemented {
@@ -1195,15 +1195,13 @@ impl CostOverflowingMath<u64> for u64 {
11951195
}
11961196

11971197
impl ExecutionCost {
1198-
pub fn zero() -> ExecutionCost {
1199-
Self {
1200-
runtime: 0,
1201-
write_length: 0,
1202-
read_count: 0,
1203-
write_count: 0,
1204-
read_length: 0,
1205-
}
1206-
}
1198+
pub const ZERO: Self = Self {
1199+
runtime: 0,
1200+
write_length: 0,
1201+
read_count: 0,
1202+
write_count: 0,
1203+
read_length: 0,
1204+
};
12071205

12081206
/// Returns the percentage of self consumed in `numerator`'s largest proportion dimension.
12091207
pub fn proportion_largest_dimension(&self, numerator: &ExecutionCost) -> u64 {
@@ -1328,6 +1326,10 @@ impl ExecutionCost {
13281326
read_length: first.read_length.max(second.read_length),
13291327
}
13301328
}
1329+
1330+
pub fn is_zero(&self) -> bool {
1331+
*self == Self::ZERO
1332+
}
13311333
}
13321334

13331335
// ONLY WORKS IF INPUT IS u64

0 commit comments

Comments
 (0)