stacks-network / sbtc-docs Goto Github PK
View Code? Open in Web Editor NEWDocumentation about sBTC
Home Page: https://stacks-network.github.io/sbtc-docs/
License: MIT License
Documentation about sBTC
Home Page: https://stacks-network.github.io/sbtc-docs/
License: MIT License
As we're getting started putting together the initial documentation, we need to get the first content into place. A good place to start is to write down a high-level description of what sBTC is and how it's working.
We need to document the sBTC DR API so that developers understand how to integrate sBTC into their apps.
In the current design, anyone could replay a withdrawal request and cause the protocol to withdraw someone else's sBTC. We should not allow this.
The protocol has been updated so that withdrawal payloads are not replayable.
Enabling sBTC users to pay transaction fees in sBTC will remove friction from the UX and provide a better Bitcoin-native experience.
There is strong user demand for this. For example, Gamma cannot issue NFTs on sBTC without the native mint and gas fees in the same asset (effects the mint contracts).
Some ideas being explored:
Creating this issue to track ideas about how to simplify this UX.
We have an explanation of what sBTC Mini is, why it is being created, and the technical/economic differences between it and full sBTC.
The withdrawal contracts process withdrawal requests and verify Bitcoin withdrawal transactions.
Withdrawal requests start on Stacks. However, an sBTC holder that does not own any STX can still sign a Stacks transaction and pay transaction fees in sBTC. The protocol exposes a mechanism to submit the withdrawals by means of a sponsored Stacks transaction. The sponsor will then receive an amount of sBTC in return for sponsoring the transaction. A sponsor can decide to sponsor the transaction if they find the fee acceptable.
We need to:
The docs are now served in https://stacks-network.github.io/sbtc-docs/. However, mermaid charts are not rendered. We need to install mdbook-mermaid
in the GH action deploying the docs to render these charts.
The deployed docs render mermaid charts.
We need to update the design based on the discussion at the Signer hackathon. In the current design, the PoX prepare phase is distinct from the Handoff phase which contains both DKG and Signing. One problem with this, is that we need to separate DKG and signing to distinct phases. In addition to this, the new Nakamoto consensus rules allows us to run the consensus prepare phase in parallel with these phases, and run DKG immediately since the set of Stackers is known throughout the cycle.
(BTC Blocks)
|----Prepare (80)----|----Handoff (20)----|-----Reward(2000)----|
|------- DKG (80) --------|-----Handoff (20) --------|------Reward(2000)---|
The docs specify PoX phases which distinguish DKG from Handoff.
Stackers have a lot of responsibilities in sBTC. Let's explain them!
The responsibilities of Stackers is explained in the docs.
The contract that verifies that the hand-off to the next Bitcoin wallet was done properly.
It is mostly automated, but we need to document how it works and who submits hand-off proofs to the component. It is still a critical component to sBTC DR.
We have a placeholder section for how to operate as a Stacker, which should walk potential Stackers through the process of running a Signer binary and connecting to the p2p network of stackers/signers. Although this is not implemented yet, so we'll need to be clear that this is the envisioned interface.
The docs contains easy-to-follow instructions for how to participate in sBTC as a Stacker using the provided signer binary.
A current gap in the spec is the question of what to do if the signers process a deposit anyway while in a bad state?
Situation is as follows:
We had consensus that the protocol would effectively be frozen during a bad state, not allowing deposits and withdrawals. However, that can leave us in an awkward state as seen above.
I think that when the protocol is in a bad state, the onus is on the signers not to process deposits. If they do it anyway for whatever reason, then the protocol should still mint sBTC. In other words, there should be no guard in the deposit processor that would prevent sBTC minting when the protocol is in a bad state.
The sBTC token is implemented as a SIP-010 fungible token. It uses the controller for access control so that the sBTC Protocol contracts may mint and burn sBTC tokens.
Although SIP-010 tokens are second nature for a lot of us, the token contract should still be clearly explained in the docs.
The sBTC docs are served on a nice web page, and updated on every commit to master.
The documentation contains a chapter explaining which functions the new PoX contract should contain, their purpose and who calls them.
Note: This should focus on the public interface and anything critical to the sBTC design. Implementation details may be omitted.
While we have the high level responsibilities of stackers outlined in the docs, we need to specify practically how the signing protocol works so that stackers are able to participate in signing rounds.
We should provide an overview of
Some good resources in this issue: https://github.com/Trust-Machines/stacks-sbtc/issues/596
The documentation explains how signers collaborate to sign messages
I'm currently only aware of xBTC, which is the only asset mentioned in the sBTC whitepaper. SIP-021 does not name any peg system, although it suggests that there exist other "state-of-the-art" two-way peg systems.
The introduction section contains an exhaustive list of all known (to us sBTC developers) BTC-wrapped tokens on Stacks.
We had this discussion before on the stacks-sbtc repo. I'm moving it to sbtc-docs for visibility and to perhaps foster a longer discussion and timeline on this—what I think—important question.
Bitcoin transactions can be made more efficient if we allow multiple deposit and withdrawal reveals to exist in a single Bitcoin transaction. Right now it is capped at 1.
Deposit example: if there are 5 pending deposit commitments (funded P2TR escrow addresses) then the Signers could produce a single Bitcoin transaction to consume all of them.
Withdrawal example: if there are 5 pending withdrawal requests then the signers could fulfil all of them in a single Bitcoin transaction.
Hybrid example: if there are 2 pending deposit commitments and 3 pending withdrawal requests, can we settle it all in a single Bitcoin transaction?
Upsides:
Downsides:
Related:
These user stories inform the Product Requirements outlined here.
Also need to ensure that all user stories have requirements and tasks associated with them.
We have to document all errors defined in sBTC DR so that developers integrating sBTC into their apps understand how to handle them.
The roadmap for the sBTC development, with high-level milestones is included in the documentation
The sBTC operations are documented, including a brief description of the different types of operations and how they are represented on-chain.
Ordinals are driving developer interest in the Bitcoin ecosystem. It's imperative for sBTC to have an Ordinal strategy, given the user demand. Ordinals support was included in the original spec for sBTC Mini here and I wrote a more in depth summary of the opportunity here. Now is the time to revisit this topic to ensure sBTC is capable of supporting Ordinals in the future.
Definition of Done
There is an updated design spec for Ordinal support in the sBTC bridge.
The helper library that makes it easier to decode and interpret Bitcoin transaction in Clarity. Any component that receives Bitcoin transactions uses this library. It is an adapted version of an earlier open source library that we have to link.
Anything else we should explain about this component?
We need to define and document all events emitted from the sBTC DR protocol so that developers creating off-chains apps and indexers know what to look for.
The registry contract functions as the main storage space for the protocol. The other components use the registry to store protocol state. It is intended to allow for more seamless upgrades by keeping the registry the same across future soft upgrades.
We need to explain the things the registry stores and why, also how those things are updated. Special attention to be paid to the get-and-update function.
The controller is a single Clarity smart contract that manages which other contracts are part of the protocol. The other contracts use the controller for access control. The controller also exposes a pathway to upgrade the protocol by changing the access list.
We need to explain exactly how it works.
See #33
We need to ensure there is a migration path to upgrade sBTC held in the v0.1 contract to Nakamoto.
Potential solutions:
Currently, the reveal transaction in commit-reveal does not provide any information on the segwit version used to parse the script data. This means that anyone parsing a reveal transaction has to do a UTXO lookup to know how to interpret the witness data. However, we can easily solve this by adding a version byte to the OP_RETURN of the reveal transaction indicating which segwit version the witness data conforms to.
The commit-reveal specification is updated to enable parsing of witness data without looking up UTXOs
The ECDSA signature of the withdrawal requests is documented in a non-ambiguous way.
Marvin created a proof of concept for sBTC 0.1 in which withdrawals are initiated on the stacks chain here: https://github.com/Trust-Machines/stacks-sbtc/pull/595
For Mini it has turned out to be simpler to initiate withdrawals on Stacks, and we suspect that the final design would be simpler if that also were the case.
Let's explore the following three options
We have decided on one of the options above and updated the design in line with that option, as well as provide an explanation in the design for the interested reader motivating the design.
The sBTC Stacking pool proper that allows Stackers to participate in the sBTC Protocol. Stackers will participate in the distributed key generation scheme and individually vote on the next Bitcoin wallet address to use. They vote by locking their STX for the next cycle.
The pool is the most extensive contract in sBTC DR. It will need a thorough documentation and is likely deserving of a separate sub page right from the beginning.
From this Discord discussion: https://discord.com/channels/621759717756370964/730814571517968436/1135960606919368734
Briefly the idea is to allow a deposit flow with two steps:
With this change, users would only have to subsidize a single BTC transaction to deposit - as opposed to the current commit-reveal scheme where they would have to subsidize two transactions.
We have explored the possibility of supporting the deposit flow described above and any related variants, and decided on whether or not to include it in the design.
sBTC introduces a lot of updates to the Stacks consensus rules. We need to have a page outlining how these rules.
The sBTC additions to the Stacks consensus rules are documented.
In the sprint planning meeting today, it was raised that the current release names are confusing. The current releases are named Alpha, Mini, MVP and 1.0 and are outlined in this doc chapter: https://github.com/stacks-network/sbtc-docs/blob/master/src/sbtc-releases.md
We should create alignment around a better set of names, and rebrand the releases.
We have an explanation of what sBTC alpha is, and how it differs from the final release. The alpha architecture and components are explained in-depth in subsequent sections and the alpha code is linked.
Two items we should work into the roadmap:
The current design supports commit-reveal operations as an alternative method of constructing sBTC operations. To use commit-reveal, a user or application is dependent on a trusted entity to act as a revealer - which is the entity consuming the commit transaction and constructing the reveal transaction visible to the sBTC system (and anyone else observing the chain).
While anyone can act as a revealer, we anticipate that there will be low interest in community-provided revealers. Therefore, we'd like to add consensus-level support for commit-reveal, to ensure that sBTC comes with a solution for applications to leverage the commit-reveal protocol.
The sBTC consensus rules are updated to ensure there's always a reliable revealer available.
Currently, the wire formats leave some room for interpretation - for example how an amount integer gets represented as 8 bytes. The docs does not specify if this is using big-endian or little-endian encoding.
There is no ambiguity in the wire formats of the sBTC docs.
Commit-reveal operations are documented.
The deposit contracts verify Bitcoin deposit transactions. They trigger an sBTC mint to the recipient found in the Bitcoin transaction. The transaction format is described in the docs already.
We need to explain how deposits are processed, link back to BTC transaction structure and minimum confirmations required.
Deposit and withdrawal flows of sBTC are explained.
The MVP release of sBTC is Documented, giving an explanation of the first consensus-breaking release of sBTC. What it contains and how it differs from the final product.
The high-level techincal design of sBTC is documented
The sBTC Developer Release makes a bunch of assumptions. These should be documented.
Non-exhaustive list:
These are defined based on the aspects that sBTC DR is supposed to validate:
Document how to bootstrap sBTC DR. It should include:
upgrade
transaction to enable the protocol contracts.We have documentation for non-technical users how to deposit and withdraw their sBTC
To introduce the different versions of sBTC, we should have a single page which lists the different versions and outlines the differences between them.
There's an outline introducing the different sBTC versions and their features
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.