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

PoX-4 Draft #64

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [sBTC Requests and Responses](./sbtc-operations.md)
- [Bitcoin Transactions](./sbtc-operations/bitcoin-transactions.md)
- [The Commit-Reveal System](./sbtc-operations/commit-reveal-system.md)
- [The sBTC Token](./sbtc-contract.md)
- [The PoX Contract](./pox-contract.md)
- [Stacker responsibilities](./stacker-responsibilities.md)
- [Signature Aggregation with FROST](./stacker-responsibilities/frost.md)
Expand Down
1 change: 1 addition & 0 deletions src/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Stacking is performed through a special smart contract, called the PoX contract.
People who stack are called stackers.

In sBTC we introduce the following changes to Stacks consensus:
* TODO: Introduce sBTC Token contract...
* The PoX contract is extended to include sBTC as a [SIP-010 fungible token](https://github.com/stacksgov/sips/blob/main/sips/sip-010/sip-010-fungible-token-standard.md).
* The Stacks blockchain is required to monitor Bitcoin for sBTC requests. The blockchain mints and burns sBTC tokens as defined in the PoX contract in direct response to valid sBTC requests.
* Stackers must provide a Bitcoin address for sBTC deposits in the PoX contract.
Expand Down
1 change: 1 addition & 0 deletions src/clarity-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Clarity Contracts
57 changes: 55 additions & 2 deletions src/pox-contract.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,57 @@
# The PoX Contract
Explanation of the PoX contracts and it's public functions. It should be clear which functions a user would interact with, which ones are used by stackers, and which ones that are called as part of Stacks consensus (sBTC mint/burn).
The PoX contract, PoX-4, is the crux of stacking & therefore the general consensus between Bitcoin & Stacks. Miners on Bitcoin mine STX blocks by sending Bitcoin to a weighted lottery every block; on the Stacks side, users can "stack" their STX, every two weeks, for receive a part of the Bitcoin mining rewards.

TODO: [#9](https://github.com/stacks-network/sbtc-docs/issues/9)
The fourth version of this, PoX-4, introduces the logic necessary for a decentralized two-way Bitcoin-peg (sBTC). Specifically, it introduces the mechanics necessary for stackers to now evolve into signers: instead of stacking & passively receiving mining rewards, signers are now incentivized to help process (by signing) peg-ins(deposits), peg-outs(withdraws) & peg-transfers (handoffs).
Copy link
Contributor

Choose a reason for hiding this comment

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

The fourth version of this, PoX-4, introduces the logic necessary for a decentralized two-way Bitcoin-peg (sBTC).

This feels a bit detached from the rest of the docs. We have already introduced sBTC here. I'd suggest something in the spirit of: "sBTC introduced the the forth version of PoX. In PoX-4 we introduce mechanics necessary for...".


PoX-2 documentation lives [here](https://docs.stacks.co/docs/clarity/noteworthy-contracts/stacking-contract). Below we introduce the likely *new* public functions that'll fold into PoX-4. First, though, we'll review the user types before hopping into the PoX-4 lifecycle which lasts ~2100 blocks & is split over five windows.


# User Types
**Observer**
Any active principal in the Stacks network, regardless of whether they hold STX or sBTC. They're not incentivized to *sign* anything, but, they are incentivized to throw a flag (aka start a penalty) if they see an issue with the protocol. Both Current & Registered Signers (below) are subsets of an Observer.

**Pre-Registered Signer**
For the developer release, a pre-registered stacker is an observer that wants to become a signer for at least one future cycle.

**Registered Signer**
For the developer release, this is a stacker that is now registered to be a signer (for the next cycle); they're either a pre-registered stacker or a current-signer.

**Voted Signer**
For the developer release, this is a registered signer that has now voted for a threshold wallet candidate (for the next cycle).

**Current Signer**
This is a principal that is a signer for the current PoX cycle. The previous cycle they registered & voted. This current cycle, as a current signer, they can also register & vote for the *next* cycle.


# PoX Lifecycle & Functions
Below we'll review the PoX lifecycle along with what public functions are avaiable to which user type.

**Disbursement [x]**
The disbursement window is the first window yet also acts as the final window of the **previous** cycle. This is when the PoX rewards from the *previous* cycle are disbursed to the previous signers. Since these rewards are disbursed in Bitcoin, someone [either Observer or any of the Signer user types] needs to verify the disbursements on Stacks.
Comment on lines +29 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we won't have a disbursement window in Nakamoto, as opposed to the developer release. Instead, PoX rewards are on a consensus level distributed to the signers directly as part of the block production operations.


Observer -> (penalty-pox-reward-disbursement ...)
Observer -> (prove-rewards-were-disbursed ...)
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a mermaid chart?


**Registration [1600 - x blocks]**
Once disbursement has been proven on Stacks, the registration window opens (it's worth noting that this is the only window with a dynamic start height). This is the window when either pre-registered signers or current signers register to be a signer for the next cycle.
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to figure out how registration connects with the Nakamoto consensus rules. I assume this is also different in 1.0 as opposed to 0.1.


Pre-registered Signer -> (signer-register ...)
Current Signer -> (signer-register ...)

**Vote [300 blocks]**
After, registered signers can vote for the next cycle sBTC threshold/peg-wallet. The goal here is for registered signers to reach a 70% consensus on a candidate.

Observer -> (penalty-pox-reward-disbursement ...)
Registered Signer -> (vote-for-threshold-wallet-candidate ...)

**Transfer [100 blocks]**
Once the vote windows is over, a new threshold/peg wallet should've been - this is now the window when the current signers can transfer the pegged-sBTC balance to the new threshold wallet (aka passing on the responsibility).

Observer -> (penalty-pox-transfer ...)
Observer -> (balance-was-transferred ...)

**Penalize [100 blocks]**
The final window before the new cycle starts with the disbursement window; the main role here is for any observer to throw a flag (aka start a penalty) if they see an issue with the protocol.

Observer -> (penalty-balance-transfer ...)
Observer -> (penalty-unhandled-request ...)
5 changes: 5 additions & 0 deletions src/sbtc-contract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The sBTC Token
The sBTC Token is defined as a [SIP-010 fungible token contract](https://github.com/stacksgov/sips/blob/main/sips/sip-010/sip-010-fungible-token-standard.md).

Content for this page:
- Tokenomics: How many tokens can be minted? Who can mint and burn the token?
Comment on lines +1 to +5
Copy link
Contributor

Choose a reason for hiding this comment

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

We can save this page as a follow-up, alternatively reformulate it. We need to work this in with the rest of the documentation.