Skip to content

chore: remove cost voting r1 - epoch 4.0 disablement gate - #7341

Merged
cylewitruk-stacks merged 5 commits into
stacks-network:pox-wf-integrationfrom
cylewitruk-stacks:chore/remove-cost-voting-r1
Jun 23, 2026
Merged

chore: remove cost voting r1 - epoch 4.0 disablement gate#7341
cylewitruk-stacks merged 5 commits into
stacks-network:pox-wf-integrationfrom
cylewitruk-stacks:chore/remove-cost-voting-r1

Conversation

@cylewitruk-stacks

@cylewitruk-stacks cylewitruk-stacks commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR disables the SIP-006's .cost-voting contract's side-effects starting from epoch 4.0 as proposed in SIP-044.

Most of the code additions here are tests and related; and most will get axed in r2.

Description

Applicable issues

Additional info (benefits, drawbacks, caveats)

  • The cost upgrade/voting function has never successfully been used in mainnet. Once disabled, the cost tracker skips applying .cost-voting state entirely and resolves all cost functions through the node's latest initialized boot cost contract (based on its current epoch). For epoch 4.0, this is the .costs-5 contract.
  • Added additional test coverage proving the effects of .cost-voting before and after epoch 4.0.
  • Minor test-only refactor adding Range syntax support and a couple of helpers for StacksEpochId.
  • initialize_epoch_4_0() requires .sbtc-token and .sbtc-registry, so I split out a boot-contract initialization helper and epoch 4.0 cost-contract initialization helper (which initialize_epoch_4_0() now calls -- future refactor potential for remaining initialization functions).

Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR retires SIP-006 .cost-voting side effects starting at epoch 4.0 (per SIP-044), so the cost tracker ignores .cost-voting state at/after epoch 4.0 and resolves cost functions exclusively via the epoch’s boot cost contract (e.g. .costs-5 in 4.0).

Changes:

  • Gate cost-voting state loading in the Clarity cost tracker so it is ignored for epoch >= 4.0.
  • Add/refactor cost-voting integration tests to assert behavior before epoch 4.0 and after epoch 4.0, plus test harness helpers for epoch bootstrapping.
  • Introduce a test-only StacksEpochId range helper trait to simplify epoch-range iteration in tests and update existing tests to use Rust range syntax.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
stackslib/src/net/api/tests/postblock_v3.rs Removes an unused Clarity hash import from API tests.
stackslib/src/clarity_vm/tests/costs.rs Refactors epoch setup for cost tests and adds assertions for pre/post epoch-4.0 cost-voting behavior.
stackslib/src/clarity_vm/clarity.rs Adds boot-contract instantiation helpers and exposes an epoch-4.0 cost-contract-only initializer for tests.
stackslib/src/chainstate/tests/runtime_tests.rs Switches test epoch ranges to use the new range extension helper.
stackslib/src/chainstate/tests/runtime_analysis_tests.rs Switches test epoch ranges to use the new range extension helper.
stackslib/src/chainstate/tests/consensus.rs Updates epoch range handling in tests and adjusts doc comment to match new range usage.
stackslib/src/chainstate/tests/consensus_unit_tests.rs Switches test epoch ranges to use the new range extension helper.
stacks-common/src/types/tests.rs Adds tests for the epoch-4.0 cost-voting gate and the new epoch range extension behavior.
stacks-common/src/types/mod.rs Adds supports_cost_voting_contract() and introduces a test-only epoch range extension trait + helpers.
clarity/src/vm/tests/epoch_gating.rs Updates epoch gating test to use the new range-based helper.
clarity/src/vm/costs/mod.rs Skips loading .cost-voting state at/after epoch 4.0 and falls back to boot defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stacks-common/src/types/tests.rs Outdated
Comment thread clarity/src/vm/costs/mod.rs
@cylewitruk-stacks
cylewitruk-stacks marked this pull request as ready for review June 22, 2026 11:33
@cylewitruk-stacks cylewitruk-stacks changed the title Chore/remove cost voting r1 chore: remove cost voting r1 - epoch 4.0 disablement gate Jun 22, 2026
@cylewitruk-stacks

cylewitruk-stacks commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Whoops, think I forgot the .added tail on the changelog file -- will fix that when I switch back from the r2 branch.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27958144415

Coverage increased (+0.2%) to 86.195%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 18 uncovered changes across 3 files (93 of 111 lines covered, 83.78%).
  • 8107 coverage regressions across 119 files.

Uncovered Changes

File Changed Covered %
clarity/src/vm/costs/mod.rs 11 4 36.36%
stacks-common/src/types/mod.rs 29 23 79.31%
stackslib/src/clarity_vm/clarity.rs 71 66 92.96%

Coverage Regressions

8107 previously-covered lines in 119 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/chainstate/burn/db/sortdb.rs 580 90.27%
stackslib/src/config/mod.rs 440 69.41%
stackslib/src/chainstate/nakamoto/mod.rs 404 84.76%
stackslib/src/net/mod.rs 310 78.15%
clarity/src/vm/database/clarity_db.rs 273 82.02%
stackslib/src/chainstate/stacks/db/transactions.rs 269 97.03%
stackslib/src/chainstate/stacks/index/storage.rs 263 82.41%
clarity/src/vm/database/structures.rs 253 77.25%
stackslib/src/chainstate/stacks/boot/mod.rs 246 94.28%
stackslib/src/chainstate/stacks/miner.rs 222 83.18%

Coverage Stats

Coverage Status
Relevant Lines: 228642
Covered Lines: 197077
Line Coverage: 86.19%
Coverage Strength: 18583957.98 hits per line

💛 - Coveralls

@brice-stacks brice-stacks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! 95% refactoring and code cleanup and 5% disabling cost-voting 😅

@cylewitruk-stacks
cylewitruk-stacks merged commit bb48404 into stacks-network:pox-wf-integration Jun 23, 2026
224 checks passed
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Closed PR has been locked after 14 days of inactivity.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants