What are Stacks? What challenges may BTC Layer 2 Network Stacks face?

By @EatonAshton2, Beosin Security Researcher.

Since the launch of the Ordinals protocol in February 2023, the minting of BTC NFT and the upsurge of BRC-20 tokens have led to a highly active BTC network. What followed was a surge in BTC network fees and network congestion. In addition, the fact that the BTC network does not support smart contracts limits the development of more complex ecological services. The market began to focus on BTC's second-tier network and applications, hoping to capture the benefits of BTC's ecological growth.

**In this article, we will explain the BTC layer-2 network Stacks for you. We will talk about its architectural design, its ecological part, and the challenges it faces. **

**What are Stacks? **

Stacks was created by Muneeb Ali based on his doctoral thesis, which carefully introduced an internet framework built around BTC. In the early days, the project was called Blockstack, and it was officially renamed Stacks in 2020. It defines itself as the smart contract layer for BTC.

Architecture Design:

Stacks execute smart contracts written in Clarity on their own blockchain and finalize transactions in BTC. The two chains interact through the Proof of Transfer mechanism (the details are introduced in the consensus mechanism), so as to use the security of the BTC network to ensure transaction security.

Source: Beosin

Since the transaction data of Stacks needs to be confirmed by the BTC network, and the BTC network generates a new block about every 10 minutes, how does Stacks expand and speed up?

First of all, Stacks has designed a special mechanism that allows multiple small blocks called microblock streams to be generated on the Stacks chain, allowing the miners responsible for confirming the current block of Stacks to make full use of the BTC network to generate two blocks. The time interval between blocks, to process more transactions. When Bitcoin confirms the current block, these micro-blocks will also be finalized, and the next Stacks block will be linked to the current last micro-block. **As shown below:

Source: Dystopia Labs, Beosin

Mechanism Detail:

Stacks sets the miners who confirm the micro-blocks will get 60% of these micro-blocks fees, and the nodes that generate these micro-blocks will get 40% of the fees to encourage miners to package micro-blocks and avoid micro-blocks. abuse.

Secondly, Stacks has launched Hiro HyperChains, which can be understood as Layer 2 of Stacks, providing developers with a high-performance blockchain development platform to meet low-latency, high-TPS application scenarios. Of course, other types of subnets can also be built on Stacks to meet various needs. These subnets will first confirm transactions on the Stacks network, and then confirm the final status on the BTC network.

Consensus mechanism: Proof of Transfer(PoX)

Stacks employs a consensus mechanism called Proof of Transfer (PoX). PoX is a consensus algorithm between two blockchains, which can be seen as Proof of Work + Proof of Burn. Like PoW, PoX requires miners to spend existing resources (BTC) to compete for the opportunity to mint the next Stacks block; similar to PoB, PoX requires miners to "burn" BTC to get STX token rewards.

A feature of PoX is that the bitcoins spent by miners will not be destroyed, but transferred to STX token holders who have locked STX tokens, which is called Stacking. Through the PoX mechanism, miners spend BTC to compete for the right to generate blocks on Stacks, and get STX token rewards and transaction fees for the block; STX holders lock STX tokens to get BTC rewards, and the current APY is about 9%.

Source:

The Stacks network will use a verifiable random function VRF to randomly select block producers (the more BTC spent, the greater the probability of being selected). When miners obtain the right to produce Stacks blocks, they will start packaging new Stacks blocks. Each Stacks block contains a hash pointer pointing to the previous Stacks block and a hash pointer pointing to the corresponding BTC block, thus connecting the Stacks network and the BTC network.

**What changes will Nakamoto bring to the next major upgrade of Stacks? **

Nakamoto is the next important upgrade of Stacks and is expected to be completed in Q4 of 2023. The upgrade will optimize the Clarity language, introduce subnets and sBTC. This upgrade will provide relatively complete basic conditions for the next outbreak of the BTC ecosystem.

Subnet:

Stacks will introduce subnets that support other programming languages and execution environments, such as EVM subnets. This will make it easier for projects on Ethereum to migrate to the Stacks network, allowing Stacks to capture the funds and traffic of the EVM chain. At the same time, these smart contracts can use Bitcoin as their assets, and finally settle on the Bitcoin network.

Subnet is the expansion solution of Stacks, which improves network performance by sacrificing certain decentralization. The subnet can choose miner nodes with high network bandwidth or miner nodes belonging to the subnet whitelist to process subnet transactions to ensure high performance.

sBTC:

sBTC is a decentralized BTC anchoring solution launched by Stacks in the Nakamoto upgrade. The introduction of sBTC will solve the problem of how to use BTC assets in the BTC second-tier network. Smart contracts on Stacks and Stacks subnets can use sBTC to carry out various DeFi businesses such as lending, exchanging, and minting stable coins, increasing the TVL of the BTC ecosystem.

At present, there are many kinds of BTC-anchored assets in the market, such as Wrapped BTC (wBTC), RenBTC and tBTC that introduce BTC into Ethereum; RBTC that introduces BTC into the BTC two-layer RSK network. The anchoring principle is roughly the same: first lock BTC on the BTC network, then mint the same number of anchored BTCs on the target network; destroy the anchored BTCs on the target network, and then unlock the same number of BTCs on the BTC network. But the key lies in the degree of centralization of locked BTC assets. For example, wBTC is BTC locked by users held by cryptocurrency custodian service providers, and the risk of centralization is relatively high. 3AC and Alameda were wBTC co-distributors before, and their bankruptcy caused some users to be unable to exchange wBTC back to BTC. RBTC uses the multi-signature address of the BTC network to be responsible for locking BTC, and uses the Powpeg mechanism to ensure that the information locked by BTC is correctly transmitted to the RSK network and signed, further reducing the risk of centralization.

sBTC uses the threshold signature wallet to manage locked BTC in the BTC network, and mints BTC through smart contracts in the Stacks network, thereby realizing non-custodial and decentralized BTC anchoring. To perform a peg-out operation to unlock BTC, a valid signature must be obtained: at least 70% of the stackers (users who locked STX tokens to obtain BTC rewards in PoX) signature power. This greatly reduces the centralization risk of asset custody.

Source:

Advantages of Stacks

Ecological advantages:

Stacks is currently the most active BTC layer-2 network. After the launch of the Ordinals protocol, the market's interest in BTC NFT has gradually increased, and NFT activities on Stacks have also become active. According to Muneeb Ali, the Stacks network has minted over $650,000 worth of NFTs.

In addition, the TVL of Stacks' DeFi project Alex has increased by 500% in the first half of this year, and the current TVL has reached $24.61M. Alex is the head Dex of Stacks, with a very complete product structure, providing functions such as transactions, loans, new transactions, and perpetual contracts. With the upgrade of Stacks and the growth of the BTC ecosystem, Alex still has more room for development.

The Arkadiko project of the Stacks ecosystem is similar to MakerDAO, focusing on over-collateralized assets to mint the decentralized stablecoin USDA to improve the asset liquidity of the Stacks network. Although the protocol has not exploded yet, we can look forward to its performance after sBTC is introduced into the Stacks network.

Source:

Citycoin:

CityCoin is a protocol built on Stacks that allows the community to contribute to the city's treasury by spending STX tokens to earn rewards in Citycoin. Participants spend STX tokens to become "miners" to mine Citycoin. 30% of the spent STX tokens will be stored in the city treasury, and the remaining 70% will be rewarded as CityCoin Stackers. If you understand the PoX mechanism above, the incentive design of Citycoin is almost the same.

source:

Miami was the first city to join the project, launching MiamiCoin (MIA). The total value of the Miami City Vault wallets has exceeded $20 million, representing approximately 2 percent of the City of Miami's public budget, and these funds will be used to give back to the local community. New York subsequently joined the initiative, launching NYCCoin. This allows more people to access and use digital assets and wallets, raise funds for public services in the region, and also helps the Stacks brand establish a good image.

Stacks possible challenges

PoX Design Risks:

PoX requires BTC miners to spend BTC to participate in the Stacks block competition, so as to obtain STX token rewards. At present, the competition among BTC miners is small, and the income is huge (1000 STX/block, the reward is halved every 4 years, and finally reduced to 125 STX/block), and miners have great motivation to participate in the competition of Stacks. As can be seen from the data in the figure below, miners who participated in 7278 competitions spent about 3.56 BTC and obtained 1,337,000 STX tokens (currently about 29.4 BTC)

Statistics:

If the Stacks rewards decrease in the future, and the number of miners participating in the competition increases, and the STX token rewards miners receive are less than the BTC they spend, will miners continue to participate in PoX? According to data from Onstacks, there are currently only 6 active miners participating in PoX. Subsequent Stacks will continue to develop. Assuming that the number of miners only increases by 10 times, and the STX reward will be halved to 500 STX/block in about a year, then the STX/BTC exchange rate needs to increase by 2.5 times to ensure that miners are profitable. So as to be motivated to participate in PoX. Therefore, either the value of STX can continue to increase, or there is an upper limit on the number of miners participating in the competition, in order to ensure the continued operation of the Stacks network. Can Stacks, like BTC, recover even after miners "shutdown"?

Contract Vulnerability of PoX:

On April 19, 2023, Stacks discovered that there was a loophole in the stacks-increase function in its pox-2 contract, which resulted in the address bc1qpyjutel6d4gj50dscphjrqcp29ljtfjel7ccap receiving more BTC rewards than theoretical calculations. **This calculation is wrong because the stacks-increase function mixes operations such as database modifications with the logic that determines state changes, and then uses reward-cycle-total-stacked as a global variable to save the state in successive iterations. **At present, the Stacks team temporarily switches Stacks to the PoB consensus, and then replaces the pox-2 contract with the pox-3 contract, and then Stacks resumes the PoX consensus. Some developers in the community call for improving Clarity to a functional, expression-oriented development language to facilitate static analysis and formal verification, and to avoid such vulnerabilities from recurring on the mainnet in the future.

Summarize

Stacks is undoubtedly the head project of the BTC layer-2 network, with a sustainable ecology and high-quality brand effect, and is about to usher in a major upgrade: reliable, trustless BTC bridge, sBTC, subnet and Clarity language optimization, for BTC Ecological explosion provides basic conditions. **But at the same time, the complexity of the PoX mechanism has brought some difficulties to the Stacks team, and the introduction of subsequent subnets will increase the complexity of the entire network. How to ensure the correct operation of the Stacks network and successfully complete the Nakamoto upgrade is a challenge that the Stacks team needs to work hard to solve. **

View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • Comment
  • Share
Comment
0/400
No comments
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)