Stacks Nakamoto upgrade, a butterfly ready to emerge
Author: DeSpread
New Possibilities in the Bitcoin Network
At the beginning of 2023, "Ordinals" was introduced to the Bitcoin network, sparking a new debate on how to treat the network's block space. In May of the same year, the demand for BRC-20 surged, causing the Bitcoin network to temporarily be unable to process blocks, forcing the world's largest centralized exchange, Binance, to halt Bitcoin withdrawals temporarily.
The name "Ordinals" comes from the word ordinal, meaning "a number in a series," and is a protocol created by Casey Rodarmor in January 2023. It modifies Bitcoin scripts to enable the attachment of arbitrary data to the smallest unit of Bitcoin, "sats." Since inscriptions allow for the storage of text, images, audio, video, and code on the Bitcoin blockchain, it naturally led to the emergence of many PFPs and NFTs in the Bitcoin ecosystem, similar to Ethereum (Learn more).
As of April 24, the top 10 NFT collections by market cap; Source: Coingecko
Today, more than a year after the emergence of Ordinals, three NFT projects issued on the Bitcoin network have entered the top 10 by total NFT market cap (NodeMonkes, Runestone, and Bitcoin Puppets), indicating the potential of Bitcoin as a viable smart contract platform.
Bitcoin L2 and Stacks
This has also led to a surge in L2 projects on the Bitcoin network. According to data from Defillama, as of the time of writing (April 15), there are 11 projects classified as "Bitcoin sidechains," with a total TVL nearing $900 million. Although there are debates about whether these projects actually consider the Bitcoin network as L1, the rapidly growing TVL and number of projects reflect an increasing market interest in the Bitcoin narrative.
Among these projects, Stacks has recently developed uniquely. It is not only an OG project launched in 2017 but has also aimed to bring smart contracts to the Bitcoin network since 2021. In this regard, let's explore the current status of Stacks and the upcoming major upgrade, the "Nakamoto Upgrade."
The Beginning of Stacks - Blockstack
Munib Ali's TED talk video from 2016; Source: TEDx Talks
In 2017, Dr. Muneeb Ali completed his degree and published a white paper on Stacks (then called Blockstack), successfully raising $52 million in a token sale on CoinList. Prior to this, he and his early team had built a protocol and application called Onename directly on Bitcoin L1, which allowed for the creation of decentralized identities and profile pages on the Bitcoin network. These experiences helped shape the idea of Stacks in 2017 and inspired the team to create a more robust platform.
Blockstack noted that the existing internet overly relied on centralized data storage and management, thus aiming to leverage blockchain technology to create a decentralized network where users have sovereignty over their data, creating a blockchain layer that allows developers to easily build dApps, similar to Ethereum.
In 2019, the token of the Blockstack ecosystem, Stacks (STX), received approval from the U.S. Securities and Exchange Commission (SEC) under Regulation A+, successfully raising $23 million. This was the first token sale approved by the SEC, garnering significant market attention.
From 2018 to 2020, the Stacks team focused on building a solid project infrastructure. Stacks is a cross-chain consensus blockchain that seamlessly integrates with the Bitcoin network, designed to assist in programmatic editing on Bitcoin. The team also developed a custom programming language called Clarity for Stacks. During this period, Stacks raised funds from notable investors such as Union Square Ventures, Harvard Endowment, Winklevoss Capital, and Naval Ravikant.
Stacks 2.0
"I believe Bitcoin is the best and most decentralized currency layer. Currently, 1% of all circulating Bitcoin is issued on Ethereum as wrapped Bitcoin (wBTC), which means users need to use Bitcoin in smart contracts. Instead of wrapping Bitcoin in some smart contract platform, why not bring smart contract functionality to the Bitcoin network?" -- Excerpt from 'Bitcoin DeFi? It's a Thing, Says Stacks Founder Muneeb Ali, Decrypt'.
In January 2021, Blockstack launched the Stacks 2.0 mainnet, becoming the Stacks network. As noted in Muneeb Ali's interview, the starting point of Stacks 2.0 was to bring smart contract functionality to the Bitcoin network without modifying Bitcoin. The design of the chain inherits the decentralization and security of the Bitcoin network while adding smart contract capabilities to enhance the network's scalability.
Proof-of-Transfer (PoX)
Proof-of-Transfer process; Source: stacks.co
Stacks' consensus mechanism -- Proof-of-Transfer (PoX) -- can be seen as an extension of Proof of Burn and is key to inheriting the security of the Bitcoin network. Proof of Burn refers to a consensus mechanism in a Proof of Work (PoW) environment where mining is done by burning cryptocurrency in the network.
Unlike the "Proof of Burn" where miners burn Bitcoin, in "Proof of Transfer," miners send Bitcoin to STX holders participating in the Stacking process. Miners can participate in the mining process by running Stacks nodes, which use the Bitcoin network as an anchor chain to generate and mine blocks. The Proof-of-Transfer mechanism is as follows:
- Registration: Miners register as candidate miners by sending consensus data to the network.
- Commitment: Registered miners participate in mining by sending Bitcoin to STX token holders.
- Election: Miners are selected using a verifiable random function (VRF), and the elected miners create new blocks on the Stacks blockchain.
- Assembly: Selected miners create blocks and receive STX tokens as rewards.
Miners elected through the election process must record the hash of all new transactions on the Stacks chain in a Bitcoin block and complete the incentive system for Bitcoin miners and Stacker maintaining the Stacks chain by following Proof of Transfer. The operation of "Stacking" is similar to "Staking" in Proof of Stake (PoS) networks, with the difference being that Stacking earns anchor chain BTC tokens as rewards by locking STX. The specific roles of miners and Stakers are illustrated below:
Roles of miners and Stacker; Source: stacks docs
[Miner]
- Miners send BTC to Stacker to earn transaction fees and block rewards from Stacks.
- The probability of each miner being selected through VRF is determined by the ratio of BTC sent by the miner.
- Elected miners gain the right to create new blocks on the Stacks chain and broadcast microblocks.
- Elected miners receive STX and transaction fees as block rewards.
[Stacker]
- Stacker locks their STX for a certain period.
- They can choose to Stack independently or pool with other Stackers.
- Stacker provides their BTC address to receive BTC rewards, with the probability of receiving rewards proportional to the amount of STX locked.
- The STX locked in Stacking will be unlocked after the initially set locking period ends.
Bitcoin L2?
The significance of Stacks 2.0 lies in enabling Stacks to function as a smart contract platform on the Bitcoin network with the launch of the mainnet and the introduction of the Proof-of-Transfer mechanism. However, there is some controversy in calling it L2 on the Bitcoin network.
- Stacks 2.0 has its own token and an independent security budget, which is entirely different from the Bitcoin network.
- Security budget: Refers to the resources allocated to maintain network integrity, including mining reward funds, operational costs, network fees, etc.
- In L1, assets are not deposited or withdrawn by security and validators, as seen in L2s in Ethereum and other ecosystems.
For the reasons above, it is difficult to categorize Stacks 2.0 as a traditional L2. However, Stacks also struggles to be called a sidechain because transactions on the Stacks chain must ultimately settle on the Bitcoin network. This unique structure of the Stacks chain led Stacks co-founder Muneeb Ali to refer to it as "Layer 1.5" during a Decrypt interview in 2021.
Since the Bitcoin network was not initially a smart contract platform, initiatives to introduce smart contracts or enhance scalability have not occurred as they have on Ethereum and EVM chains. A reference to the article 'BITCOIN LAYERS - Tapestry of a Trustless Financial Era' published by Spartan Group in December 2023 can provide further insights into how to distinguish Bitcoin L2.
The three dilemmas of Bitcoin L2; Source: BITCOIN LAYERS --- Tapestry of a Trustless Financial Era
As shown in the figure above, the three dilemmas of Bitcoin L2 include:
- Open Network: Adopting an open network rather than a consortium model.
- No New Token: Not introducing new tokens.
- Full VM/Global State: Adopting a "Global State" rather than a limited off-chain contract form.
Stacks can be seen as meeting conditions 1 and 3 but not satisfying condition 2 as a Bitcoin L2 solution. In contrast, the Lightning Network meets conditions 1 and 2 but fails to meet condition 3 due to its use of a "local consensus" method, recording transactions on a peer-to-peer network separate from the main chain.
Towards Stacks 3.0, the Nakamoto Upgrade
Existing Issues with Stacks
The unique structure of the Stacks chain is the reason Stacks can function as a smart contract platform on the Bitcoin network, but it also brings some issues to the system, including:
- Security Model
- The Stacks chain has an independent security budget, which differs from the Bitcoin network's security budget, defined by BTC paid by Stacks miners.
- This makes the chain's security highly dependent on the budget of Stacks miners, meaning the potential for increased security risks.
- Performance and Scalability
- The connection structure between the Stacks chain and the Bitcoin network (such as the Proof-of-Transfer mechanism) helps enhance decentralization and security but limits on-chain performance and scalability.
- In particular, the process of creating new blocks through miner elections ties the Stacks chain to Bitcoin's block generation cycle, leading to very high transaction confirmation delays.
- This is not only a user experience flaw but also the root cause of difficulties in developing Stacks dApps.
- MEV Issues
- Bitcoin miners with a significant proportion of Bitcoin hash rate can review the commitment transactions sent by other Stacks miners in the Bitcoin blocks they mine (transactions sending BTC to participate in STX mining), ensuring they receive Stacks rewards and transaction fees.
Main Goals and Design Changes
Main Goals
The Nakamoto version is a major upgrade planned for the Stacks chain this year to address the aforementioned issues and improve the chain's performance and security.
- Fast Blocks
- The time for user-submitted transactions to be mined and confirmed within a block is reduced from minutes to seconds.
- After the Nakamoto upgrade, by separating the miner election process from the block generation mechanism, miners will be able to generate multiple blocks before the next miner election process.
- Transaction Security through Bitcoin Finality
- Transactions on the Stacks chain are secured by the hashing power of the Bitcoin network.
- This means transactions settle on the Bitcoin network, ensuring their immutability on the most secure network.
- Enhanced Anti-MEV Functionality
- Improvements have been made to the BTC bidding mechanism for STX rewards to address MEV issues in the miner election process.
- The miner election algorithm has been changed so that Bitcoin miners do not have advantages over Stacks miners.
Changes to Block Generation Mechanism and Stacker Role
Before the Nakamoto upgrade, the ratio of blocks generated on the Stacks chain to Bitcoin blocks was fixed at 1:1, resulting in slow block generation and transaction confirmation times.
After the Nakamoto upgrade, a "Tenure-based block production" mechanism will be introduced to speed up block generation. A block on the Stacks chain will no longer correspond to a Bitcoin block at a 1:1 ratio; instead, during the elected miner's tenure (i.e., within the Bitcoin block generation cycle), miners will be able to generate multiple Stacks blocks. This mechanism will reduce block generation and confirmation times to around 5 seconds, greatly enhancing Stacks' scalability.
The Stacks blocks generated during this time will be validated by Stackers. Before the Nakamoto upgrade, Stackers only locked (Stacked) STX tokens to contribute to the economic security of the Stacks network, but after the Nakamoto upgrade, Stackers will take on the role of signers, responsible for validating, storing, signing, and propagating each Stacks block generated during the miner's tenure. The relationship between miners and Stackers is illustrated below:
How miners and Stackers (or signers) interact after the Nakamoto upgrade; Source: stacks docs
- Miners send BTC to Stackers to participate in the Stacks miner election process.
- When a new miner is elected, a "tenure change" transaction occurs, granting the new miner a new tenure.
- Miners must collect signatures from Stackers during the process of creating and validating blocks every second.
- Block validation requires at least 70% of Stackers to sign off on the block.
As shown in the figure above, miners need Stacker signatures to create the next block, and Stackers need to perform signing operations to earn rewards under the Proof-of-Transfer mechanism and unlock their Stacked STX tokens.
Changing the Chain Structure to Achieve Bitcoin Finality
Signers (Stackers) prevent miners from arbitrarily forking the Stacks chain during tenure changes (or miner elections) by only signing the most recently generated blocks. This means Stackers are responsible for overseeing miners, validating previously generated blocks, and ensuring new blocks are generated based on the latest blocks.
Additionally, when miners submit transactions (tenure change transactions), they must include an indexed block hash, which contains the hash of the first Stacks block recorded during the previous miner's tenure and the hash of the block itself. This ensures that the state of the Stacks blockchain is recorded in Bitcoin blocks, with each miner performing the same work, ensuring the history of the Stacks blockchain is continuously recorded on the Bitcoin network.
The relationship diagram between Bitcoin blocks, Stacks blocks, and inventory bitmaps; Source: stacks docs
Thus, the relationship between Stacks blocks and Bitcoin blocks is illustrated in the figure above. Transactions submitted on the Stacks chain during period N will only be recorded in Bitcoin blocks during the next two periods, i.e., N+2, indicating that it takes three tenure changes to make reversing Stacks transactions as difficult as reversing Bitcoin blocks. From the user's perspective, the structure of the chain is similar to what we know as L2, with transactions confirmed in seconds, while settlement on Bitcoin takes about 30 minutes.
This system also brings positive changes to the security budget of the Stacks chain. The mechanism for validating Stacks blocks occurs through the signatures of at least 70% of Stackers, allowing the security budget of Stacks to increase up to 70% of the Stacking assets, and once a transaction achieves final settlement on Bitcoin, this security budget can reach 51% of Bitcoin's mining capacity.
To summarize the Stacks mechanism after the Nakamoto upgrade:
- Miners must include an indexed block hash along with the hash of the first block recorded during the previous tenure when submitting tenure change transactions.
- Signers will enforce miners to generate the next block based on the last block signed during the previous tenure.
- Transactions submitted during tenure N will be written into Bitcoin blocks during tenure N+2, achieving Bitcoin finality.
After the Nakamoto upgrade, the transaction speed of the Stacks chain will be greatly enhanced, while also achieving Bitcoin finality, ensuring data immutability. For users, this means faster transaction confirmation speeds, while for the system, it brings it closer to being a true Bitcoin L2, inheriting Bitcoin's security.
Addressing Bitcoin MEV Issues
Before the Nakamoto upgrade, MEV issues on the Stacks chain primarily occurred in the following ways. Bitcoin miners with a significant proportion of Bitcoin hash rate, such as F2Pool, could review the commitment transactions submitted by other Staking miners within the Bitcoin blocks they mined to adjust their submitted BTC bid amounts, ensuring they could earn Staking block rewards and transaction fees. This behavior reduced BTC rewards for Stackers and undermined trust in the mining process.
The Nakamoto upgrade introduces several new miner selection criteria to improve the fairness of the block mining process.
- Miners must participate in recent blocks
- Miners must have records of participation in the last 10 blocks to qualify for selection during tenure changes.
- This criterion can promote stability within the miner community and prevent attempts to steal blockchain rewards.
- Consideration of the Median of Past Bids Method
- The probability of miners being selected is calculated based on the median of all BTC bids recorded in the last 10 blocks.
- This criterion can prevent miners from obtaining block rewards through anomalous bids.
- Consideration of the Absolute Bid Total
- The miner selection process is based on stable economic standards, considering the absolute value of the total bids rather than the bid variables based on the immediate mining environment.
By introducing these anti-MEV standards, the Nakamoto upgrade will enhance the transparency and trustworthiness of the Stacks blockchain mining process.
Planning the Nakamoto Upgrade
Nakamoto upgrade roadmap; Source: nakamoto.run
Since the release of the sBTC and Nakamoto white papers at the end of 2022, the Stacks Foundation and related developers have been working on the Nakamoto upgrade for a long time. As shown in the figure above, since the functionalities of Nakamoto were finalized and integrated into the testnet in February 2024 (referred to as Nakamoto milestone 0.3, codename Argon), updates for the Nakamoto upgrade have been progressing rapidly. The first phase of the Nakamoto upgrade has now gone live on the mainnet, with subsequent upgrades to be rolled out.
The Nakamoto upgrade consists of two phases, each involving a hard fork. The process is divided into "Instantiation" and "Activation," allowing for a period of final adjustments, such as bug fixes, before fully activating the functionalities after the Nakamoto update, thereby excluding disruptions caused by changes in the on-chain environment.
Original Plan
- Phase 1: Instantiation (Started April 22)
- The POX-4 (an upgraded version of the Proof of Transfer mechanism) contract and most of the code included in the Nakamoto version will be applied, but functionalities will not be enabled.
- At least two Stacking cycles will be reserved for signers and partners to register for the POX-4 contract. During this period, the verification of whether the registered POX-4 signers correctly validate blocks will be conducted to determine if they can enter the activation phase.
- Phase 2: Activation (Expected between May 15 and May 29)
- This phase will apply the Nakamoto update, including the signer-based system, fast blocks, and Bitcoin finality, and activate the Nakamoto rules.
- The Nakamoto rules refer to the overall logic that distinguishes between before and after the Nakamoto upgrade.
Nakamoto release schedule; Source: Nakamoto Launch: Testnet and Mainnet Rollout Overview
Changes to the Plan
The first phase of the upgrade (Instantiation) began on April 22, assuming no major bugs were found and Instantiation was completed, with the second phase planned to start in mid-May. However, after the start of the first phase, some defects were discovered in the signer resiliency/recovery system, leading the Stacks Foundation to announce a modification of the original plan on May 1. Key points include:
- The initial activation phase of the Nakamoto upgrade only includes a basic signer recovery system.
- The plan to upgrade to an advanced signer recovery system will be deployed by the end of 2024 after the activation of the Nakamoto upgrade, but after the onboarding and progress of signers during the Instantiation phase, it was determined that an advanced signer recovery system was needed.
- Therefore, an additional 8 weeks of development time will be added before the activation phase of the Nakamoto upgrade, with the signer recovery system code completed by July 15, and the Nakamoto upgrade version activated on August 28.
- Work content includes:
- Enhancing miners' recovery capabilities for signature timeouts and signer errors.
- Strengthening processes for signers' responses and key loss situations.
- Improving the creation and extension methods for miners' tenures.
- Enhancing prevention against network uncertainties and flash block handling.
Revised Nakamoto release timeline; Source: stacks.org
According to the revised plan, code development will be completed by July 15, 8 weeks later, while the activation phase of the Nakamoto upgrade originally scheduled for mid-May will begin approximately 3 months later on August 28. The good news is that the sBTC upgrade originally planned for the third quarter will not be delayed and is expected to take place in the fourth week after the activation phase begins.
sBTC - The Final Piece to Achieve L2
The Nakamoto upgrade is expected to be fully activated in May, aiming to significantly improve the performance of the Stacks chain and achieve Bitcoin finality for Stacks blocks. However, to truly become an L2 on the Bitcoin network, the Nakamoto upgrade is only half the success.
Standards for distinguishing Bitcoin L2; Source: light tweet
After the release of the Nakamoto upgrade, Stacks will have an environment similar to Sovereign Rollup. However, it can only function as a true Bitcoin smart contract platform and L2 by bringing native Bitcoin assets, BTC, onto the chain and utilizing them. Stacks founder Muneeb Ali stated in the same tweet that moving BTC in and out of Bitcoin Layer is the hardest part and explained that sBTC is the closest solution to a trustless bridge, being a decentralized public signer group that can execute a pegging mechanism for BTC without modifying Bitcoin L1.
sBTC is based on two main attributes, bridging BTC assets between the Bitcoin network and the Stacks chain:
- 1:1 Redeemability: sBTC and BTC can always be redeemed at a 1:1 ratio unless the Stacks chain ceases to operate.
- Open Membership: Anyone can join the sBTC protocol, and no centralized entity can control BTC.
Previously, there were BTC-related assets on the Stacks chain, such as xBTC and aBTC, similar to Ethereum's wBTC (wrapped BTC), but they were based on centralized custodians requiring multi-signature bridging. In contrast, sBTC uses the Proof-of-Transfer mechanism with Stackers as a group of signers to achieve BTC bridging in a trustless manner.
How sBTC works (1); Source: stacks docs
How sBTC works (2); Source: sbtc.tech
The updates and implementation plans for sBTC are scheduled for the third quarter of 2024. The Nakamoto upgrade and sBTC updates are key milestones in Stacks' ambitious journey to become the preferred smart contract platform on the Bitcoin network. We can continue to monitor Stacks to see if it can truly become Bitcoin L2 and effectively utilize the still dormant BTC as a smart contract platform.
Source: BITCOIN LAYERS --- Tapestry of a Trustless Financial Era