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

Add support for pox-3 #59

Merged
merged 48 commits into from
Aug 31, 2023
Merged

Add support for pox-3 #59

merged 48 commits into from
Aug 31, 2023

Conversation

whoabuddy
Copy link
Contributor

@whoabuddy whoabuddy commented Mar 30, 2023

With the Stacks 2.1 launch the original .pox contract is now replaced with .pox-2.

There was a bug found in .pox-2 on the Stacks blockchain that is currently being mitigated by:

  • a hard fork to disable .pox-2 functionality for at least one cycle
  • a hard fork to implement .pox-3 as the new stacking protocol

More info on this can be found on the Stacks forum and is being tracked as part of a SIP here.

We now want to target .pox-3 with any anticipated changes, and ideally time this upgrade with the release of .pox-3 to avoid any additional missed cycles.

Remaining Tasks

Treasury:

  • update stacking methods to use pox-3

Proposal:

  • enable new treasury extensions
  • set allowed tokens in new treasury extensions
  • transfer funds to new treasury extensions
  • stack funds in new treasury extensions
  • add treasuries to ccd005-city-data
  • disable mining-v1 contract

Mining V2:

  • update get-city-info with new treasury name
  • explore using data-var with DAO-gated setter

Community Voting:

  • implement basic threshold vote required to pass proposal
  • create trait to use with future proposals

Testing:

Also adds a proposal for ccip-014 which would be the proposal that activates stacking through pox-2.
@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Merging #59 (da0d488) into main (40c9ba4) will increase coverage by 3.38%.
The diff coverage is 97.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   84.20%   87.58%   +3.38%     
==========================================
  Files          15       19       +4     
  Lines         785     1168     +383     
  Branches        0      170     +170     
==========================================
+ Hits          661     1023     +362     
- Misses        124      137      +13     
- Partials        0        8       +8     
Files Changed Coverage Δ
...ontracts/extensions/ccd006-citycoin-mining-v2.clar 95.58% <95.58%> (ø)
contracts/proposals/ccip014-pox-3.clar 97.56% <97.56%> (ø)
contracts/extensions/ccd002-treasury-v2.clar 98.00% <98.00%> (ø)
contracts/extensions/ccd007-citycoin-stacking.clar 96.96% <100.00%> (+0.75%) ⬆️
contracts/proposals/ccip014-pox-3-v2.clar 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40c9ba4...da0d488. Read the comment docs.

@whoabuddy whoabuddy changed the title Add support for pox-2 Add support for pox-3 Apr 25, 2023
@whoabuddy
Copy link
Contributor Author

Note that the tests are expected to fail at this stage - the pox-3 contract is in this branch but not known to Clarinet yet.

@whoabuddy
Copy link
Contributor Author

@friedger do we know the pool address for pox-3 stacking with Friedger Pool yet? Have it marked as TODO right now.

@friedger
Copy link
Contributor

friedger commented May 5, 2023

Probably .fast-pool-self-service-v2

@whoabuddy
Copy link
Contributor Author

Probably .fast-pool-self-service-v2

Is that deployed already? Do you have a link?

Didn't see it at the fast pool address or in the boomcrypto repo.

@friedger
Copy link
Contributor

friedger commented May 5, 2023

Pox-3 is not yet deployed

@whoabuddy
Copy link
Contributor Author

whoabuddy commented May 5, 2023

Pox-3 is not yet deployed

Got ahead of myself 😅

Where does the code live? Think I found it.
https://github.com/friedger/clarity-stacking-pools/tree/main/contracts

whoabuddy added 15 commits May 10, 2023 15:00
Waiting on clarification for Clarinet settings, still showing error with function replace-at? but should be included with Clarity 2 rules.
Also fixes Clarinet.toml to specify correct epoch / clarity version for new contracts.
This requires a custom version of Clarinet built from the feat/devnet-epoch-2.2 branch of clarinet, as well as the feat/2.4-clarity-wasm branch of stacks-blockchain. The link between the two is relative, so the clarinet/ and stacks-blockchain/ directories should be at the same level.
Also renames error constants using proposal number.
These two were failing after upgrading Clarinet, but seems to be a regression as the structure of this function didn't change. ERR_ALREADY_CLAIMED short-circuits before ERR_MINER_NOT_WINNER in these scenarios.
@whoabuddy
Copy link
Contributor Author

This is pretty much ready to go! Noting that tests still fail in the CI because Clarinet does not support Stacks 2.4 without a custom build.

Output from clarinet check and clarinet test locally:

$ clarinet check
✔ 107 contracts checked
$ clarinet test
...
ok | 240 passed | 0 failed (9s)

Note: to build this version of Clarinet, it requires using branch feat/devnet-epoch-2.2 of hirosystems/clarinet and branch feat/2.4-clarity-wasm of Stacks blockchain with folders in the same parent directory. From there, run cargo clarinet-install to configure the working version.

whoabuddy added 7 commits May 27, 2023 13:49
The original proposal failed with err u7006 due to cycle 59 not being complete. This would not allow us to stack for cycle 60, so the related code will be removed and saved for a future proposal.

The voting functionality will be removed as well and instead of checking internally if it can be executed, it will call the original ccip-014.
@whoabuddy
Copy link
Contributor Author

whoabuddy commented May 29, 2023

CCIP-014 was trying to pay out cycles 56-59 but cycle 59 isn't complete, so we get the error u7006 or ERR_INCOMPLETE_CYCLE.
https://explorer.hiro.so/txid/0xb4149b1885697d4f0314329c4d40eac29c73c2c0cc70dede9a8f2c4af49a7f39?chain=mainnet

Good news is there's still time left, and we can still use the vote data from CCIP-014 to pass a second proposal that:

  • removes the payouts for past cycles (can be handled by separate CCIP)
  • removes the voting code/logic in favor of checking CCIP-014 original results
  • performs all the other actions required to execute CCIP-014

@Rapha-btc
Copy link

Kudos for this accomplishment WAB!

@whoabuddy
Copy link
Contributor Author

Fixed and updated testing now that Clarinet supports pox-3, also adds some missing tests found along the way and up the code a bit. This should be ready to merge now!

@whoabuddy whoabuddy merged commit 8106042 into main Aug 31, 2023
@whoabuddy whoabuddy deleted the fix/support-pox-2 branch August 31, 2023 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing for ccd006-citycoin-mining Testing for CCIP-014 Prepare for pox-3 stacking changes
3 participants