The Stacks 2.0 Network went live on January 14, 2021. Daemon Technologies has keenly watched this new network evolve, with a specific focus on STX Mining. We've previously published two reports: The First 1000 Blocks & The First 5000 Blocks.
Today we'd like to present an analysis of the early success of STX Mining, which has now secured the network for over 16,000 blocks. More specifically, the focus of this report is on how to think about the security of the Stacks 2.0 chain now and in the future.
It's important to be able to quantify the security and decentralization of the Stacks chain, and to date there has not been an established method of doing so. As a result we have seen some attempts at estimation using the same methods for measuring security and decentralization of PoW based networks. This is not accurate, and PoX is not PoW. As a refresher, here are the details of how PoX works. At a high level, STX miners spend BTC to compete to mine new Stacks blocks. For each miner the amount spent is combined with a Verifiable Random Function (VRF) to determine mining sortition. The more an STX miner spends per block, the higher the probability of winning each block.
The following analysis highlights 3 properties of PoX security: (1) Most attacks against the Stacks chain are easy to identify in advance, (2) because of this, attacks are easy for the network to prevent or route around, and (3) preparing for an attack in private is not feasible, and is at least as hard as successfully creating a private Bitcoin fork.
Unlike PoW based networks, like Bitcoin, the number of STX miners alone is not an accurate reflection of a miner's relative ability to win blocks over time, and as a result does not reflect the security or decentralization of the network.
In order to successfully attack Stacks 2.0, a miner would need to mine a genuinely longer chain than the rest of the network. Unlike a PoW based chain, the Stacks chain quality is measured by its length, and not the total amount of BTC burned (or resources expended). This means that simply spending 100x the BTC of every other miner will not result in a longer or better Stacks chain tip. In order to successfully attack the Stacks chain, a miner would have to consistently out-mine every other participant. In order to do this, a "bad actor" miner would need to effectively guarantee they could win every block over the time period their attack takes place. This is difficult to accomplish, and even more difficult to maintain for any amount of time. This is because the protocol considers each miner's average spend over a rolling 6 block window when choosing the next miner to produce a block, which prevents miners from being able to easily win blocks by suddenly increasing their BTC spend. Because the weight of a miner's selection is min(median_burn_from_last_6_blocks, last_burn) over the last 6 blocks, a miner would need to start burning significant amounts of BTC for at least two blocks before it would have any impact on their selection. Exchanges, wallets, other miners, and every other participant on the network would easily notice this and adapt (e.g. by increasing their own BTC commitments, and/or by increasing the confirmation threshold).
To illustrate the above, let's consider what would happen if a miner attempted to pull of a "double spend" attack on Stacks. In this theoretical example a "bad actor" miner, Trevor, wants to reverse a previous transaction that sent 1 million STX from Trevor to another participant on the network, Aaron.
To do this successfully, Trevor needs to build his mining power, or probability of winning the next block, to at least 51% if he hopes to pull of an attack. For this example, we look at an extreme case where Trevor spends 100x more than all other miners and attempts to build his probability to as close to 100% as possible. The below spreadsheet illustrates, block by block, how Trevor prepares for the attack:
The above considers a scenario where STX miners have been spending a total of 0.02 BTC per Stacks block, which is meant to loosely mimic the reality today. Trevor starts preparing to attack by spending 100x the amount of all other miners per block: 2 BTC. He starts mining with this spend at block N+1. The spend history in the table lists the amount of BTC spent for each of the last 6 blocks. The min and median of these 6 values is then used by the sortition algorithm to calculate the probability a miner will win a block, which is shown in the bottom row.
When Trevor first spends 2 BTC on block N+1, he functionally has no chance of winning that block. In fact, this continues for block N+2, where Trevor spends another 2 BTC. It's not until Trevor spends 2 more BTC to compete to mine block N+3 that his mining power reaches 25%. 25%, however, is insufficient for him to pull of his desired attack. He continues spending 2 BTC per block until block n+6. Once there, he will have spent 10 BTC over the previous 5 blocks, compared to a total of 0.1 BTC by all other miners. Now at block N+6, and 10 BTC poorer, Trevor has a 99% chance of winning, and is ready to attack.
As is the case with PoW based blockchains, the success of Trevor's attack is ultimately determined by his ability to out-mine the rest of the Stacks network to the point that his "double spend" chain is longer. The Stacks network and PoX, however, has a feature that makes Trevor's attack easy to thwart:
No matter how strong Trevor is, it takes at least 2 blocks before he can do anything.
This is a key piece that makes the Stacks chain difficult to attack. During the minimum 2 blocks of preparation, every other miner, large Stackers, exchanges, and anyone else monitoring the network will immediately notice the 100x BTC spend to mine. This is because it's not rational for an economic actor to willfully choose to start losing a significant amount of BTC per block. Other participants on the network now have a number of options for how to censor Trevor's attack before it's ready. If economically viable to do so, other miners could simply start spending more BTC per block themselves. Even a modest increase will throw off Trevor's ability of ever getting his "double spend" chain ahead of the canonical chain. Separately, or in addition to this, network participants in general could simply move to increase the confirmation threshold, anchoring it at block N and extending for as long as it takes for Trevor to run out of BTC.
Interestingly, the above also holds true in the case where Trevor is an "honest" miner for any amount of time prior to preparing for his attack. The only way Trevor can avoid this is to build a private Stacks fork. To do so, however, he can't use the Bitcoin chain fork that the rest of the Stacks network follows, which is the canonical Bitcoin chain; otherwise they'll see his block commits. Trevor, therefore, would need to mine a private Bitcoin fork that contains his block commits. Once ready to attack, he would first broadcast his attack Bitcoin fork, and then broadcast the associated Stacks blocks. This means that the Stacks network makes building a hidden Stacks fork at least as difficult as building a hidden Bitcoin fork.
As a result, the Stacks chain is difficult to attack, and in the short term may be more difficult, and certainly more complex to attack than PoW based chains. This is because, unlike with PoW chains, the honest, long-standing network participants on Stacks can quickly identify an incoming attacker's activity before it has a chance to impact the system. Because building an attack in private equates to building a private Bitcoin fork, the Stacks chain leverages the mining difficulty of Bitcoin to force attackers to reveal themselves before they can do any damage. All of this is to say the Stacks Network is actually incredibly difficult to attack, even at miner numbers that would not be considered optimal on a PoW network.
At the most basic level, STX mining has already proven that people will spend Bitcoin for STX when it is economically profitable to do so. To date more than 500 BTC have been spent to mine over 30 million new STX tokens. In terms of profitability, STX mining is a numbers game: miners need to compete for enough blocks that the law of large numbers becomes relevant, and their probability of expected return is realized. In most cases, STX mining has been profitable and sustainable for miners who consistently stay online. To this end, Daemon is aware of at least 2 currently active mining pools. These are some of the first, as the pooling software is still in early stages.
Currently, STX mining has reached an temporary economic equilibrium of between 2.0 - 3.0 million Satoshis being spent by STX miners every block. As we move forward from the first 4 months of the Stacks 2.0, we expect that number per block to grow, potentially dramatically. This will happen as STX appreciates compared to BTC. But why would that happen?
The main utility of the Stacks chain and network is to enable smart contracts, and more generally DeFi and Web 3.0, on top of Bitcoin. STX tokens themselves can be thought of as compute credits in many ways, serving this exact use case. As more and more of this utility is built in the coming months and years, a large amount of value could accrue to STX by creating popular smart contract use cases that can settle down to Bitcoin. Any resulting appreciation of STX compared to BTC would represent the market value of smart contracts on top of Bitcoin.
Today, Clarity smart contracts have been live for 4 months, and are at the very beginning of the adoption curve. This can be quantified. 1 STX token is currently worth ~0.00003 BTC. Put another way, STX is roughly 0.0003% the value of BTC. This makes sense given the nascence of the network and Clarity. In the near future, however, if the value of smart contract use cases on Bitcoin is worth even 1% the value of BTC, then we will see miners spending considerably more per block, and a much higher equilibrium may form. In addition, the imminent existence of STX mining pools will continue to allow more participation in mining.
What this means for Daemon Technologies going forward is we are focused on two paths: (1) continue building tools for STX miners and mining pools, and (2) create and incentivize others to create valuable applications, products, and services with Clarity smart contracts. We should be able to start measuring early results in the coming months, and we expect the economics of mining to naturally adjust to allow a higher BTC spend per block and/or a higher number of miners (e.g. higher gas fees).
It's still early days for STX Mining, and for the Stacks 2.0 chain in general. STX Mining has been initially validated, and Daemon is excited about the ability for the network to profitably support many more miners in the future. The reason is the Stacks network uses Bitcoin as an ultimate settlement layer, making smart contracts, and use cases such as DeFi, on top of Bitcoin possible. We believe this is the killer use case for Bitcoin, and that this type of system design on top of BTC will become the norm over time.