Original Author: Glimmer @Glimmerllx , William, Hankester @0x Hankester
Mentors: Jademont, Elaine, Bill @Waterdrip Capital
Bitcoin (Bitcoin), referred to as BTC, is an open-source encrypted currency system based on the decentralized consensus of blockchain and using point-to-point network communication. It is jointly maintained by computer networks and nodes distributed all over the world. The BTC Whitepaper was released by Satoshi Nakamoto on October 31, 2008, and then on January 3, 2009, the BTC consensus chain produced the first block. However, as the encryption community and ecology grow and prosper, the early BTC technology has been unable to meet users' needs for the scalability of the cryptocurrency system. The complexity and community resistance of directly improving the BTC underlying protocol will increase the risk of the BTC system, leading to Hard fork and community splits. A more suitable solution is BTC Layer 2, which is to build a new layer based on BTC without making changes to BTC . It is compatible with BTC and meets users' needs for scalability. This article investigates BTC Layer 2, comprehensively expounds the status quo and problems of BTC , as well as the technical solutions and advantages and disadvantages of BTC Layer 2, and looks forward to its future.
Technical Introduction to BTC
The core of BTC is distributed ledger technology, which uses blockchain to store transaction data. The blockchain is based on a hash pointer linked list structure. Each section of the linked list is a data block, which contains the hash value, transaction data, time data, mining parameters and protocol version information of the previous block. In the BTC network, the writing power of the new blockchain, that is, the bookkeeping right, is obtained by nodes following the Proof-Of-Work of Work (PoW) mechanism and relying on computing power competition. After the node that has obtained the bookkeeping right successfully writes a new block, it will receive a certain amount of Bitcoin tokens as a reward, so this process is also called mining.
BTC block data structure, image source: https://www 3.ntu.edu.sg/home/ehchua/programming/blockchain/bitcoin.html
Image source of BTC bookkeeping workflow: BTC
BTC adopts a transaction-based ledger scheme based on transfer records, which only records transfer information in the blockchain without maintaining account balances. Therefore, in order to prevent double-spending attacks, the node needs to maintain a set of unspent transaction output data (Unspent Transaction Outputs, UTXO) locally, and the source of funds needs to be provided when the account is transferred, so that the node can verify the legitimacy of the transaction.
UTXO diagram of a single account, image source: https://docs.safepal.io/blockchain-tutorials/utxo-what-is-it-and-how-to-use-it
BTC uses asymmetric encryption and hashing algorithms to organize accounts, secure and verify transactions. An account includes account private key and account public key. The account private key is a randomly generated private key, and the account's public key is generated by processing the private key through elliptic curve multiplication. In addition, the address of the account is generated after processing the public key with a hashing algorithm. After the transaction is signed by the private key, it is broadcast to the nodes through the peer-to-peer network. The node uses the corresponding public key to verify the transaction, and after the verification is successful, the transaction is packaged in a new block.
Signature and verification of BTC account private key and public key, image source: Nakamoto, Satoshi. "Bitcoin whitepaper."
The consensus mechanism of BTC is PoW. All nodes each construct a new block header such that its hash value is less than or equal to a given target value. The node that first finds the eligible block header has the right to bookkeeping for the next block. By adjusting the size of the target value, the block generation time can be indirectly adjusted. The larger the target value, the easier the mining and the shorter the block generation time; the smaller the target value, the harder the mining and the longer the block generation time. BTC expects the block time of each block to be 10 minutes. Therefore, BTC will readjust the target value every 2016 blocks, that is, adjust the mining difficulty.
Proof Of Work process example, image source: https://www.ledger.com/academy/blockchain/what-is-proof-of-work
The status quo and problems encountered by BTC
BTC is the first digital currency system widely recognized by the global cryptocurrency community. Since 2013, the market value of BTC has accounted for more than half of the total market value of cryptocurrencies all year round, and it is a well-deserved leader in cryptocurrencies.
BTC market capitalization ratio, source: https://www.coinglass.com/zh/pro/i/MarketCap
For a long time, BTC has been sought after by users for its pioneering status and high security. However, with the growth of cryptocurrency users, it is difficult for BTC to satisfy users' requirements for low fees, convenience, real-time, privacy protection, and diverse assets of the cryptocurrency system. And the growing demand for diverse applications. In the long run, the ratio of the market value of BTC to the total market value of cryptocurrencies is slowly declining. Compared with Ethereum's prosperous ecology, Solana's low handling fee and high TPS (Transactions Per Second) and other public chains with their own merits, BTC seems to have no other core competitiveness except popularity and security, and faces the following problems:
Slow transaction speed, long confirmation time, and inconvenient: Each block of BTC has a capacity of 1 M, and the data of each transaction is about 250 B, so each block contains up to 4000 transactions. Calculated according to the expected block time of 10 minutes, the TPS of BTC is only about 7. Transactions on BTC need to wait for 6 blocks for credible confirmation, which results in a final confirmation time of about 1 hour. In addition, the transfer on BTC can only transfer all the balance out at one time. For change, you need to declare the transfer back to your own address, otherwise it will be rewarded to the miners. This cannot meet users' needs for transaction convenience and instant.
High transaction fees: When users use BTC to conduct transactions, they need to pay a fee to attract miners to pack the transaction. The higher the fee, the faster the transaction confirmation. When transactions are congested, handling fees will become extra expensive, reaching more than $60 in 2021. From May 14, 2020 to May 15, 2023, Bitcoin transaction fees will cost an average of $4.66. This fee cost prevents many users from using BTC.
Does not support smart contract programming: BTC does not support the direct construction of complex applications, and can only start from the protocol layer. However, the cost of developing applications from the protocol layer is much higher than that through standardized smart contracts. This limits the development of diverse applications and assets of BTC .
BTC transaction fees, source: https://bitinfocharts.com/zh/comparison/bitcoin-transactionfees.html#3 y
Improving resistance and Layer 2 solutions for BTC
Technical Difficulty : The problems encountered by BTC stem from the fact that the old technical solutions cannot meet the current needs. Even if fine-tuning is performed directly on BTC , the problems cannot be completely solved, and new problems will be derived instead. If BTC is expanded, each block is increased from 1 M to 100 M, and the TPS is increased to 700, it will result in the generation of nearly 5 T of new ledger data every year, which will increase the threshold for operating nodes and affect the degree of decentralization of the system , increasing the system risk. Even without considering the size of the ledger data, calculated based on the median Internet bandwidth of 13 Mbps and the size of each transaction in a block being 250 B, the upper limit of BTC ’s TPS is 13 Mbps/8 Mb/250 B ≈ 6815, which cannot be used on Polkadot , Solana and other public chains that can support tens of thousands or even hundreds of thousands of TPS compete. Bitcoin Cash (BCH) expands the block size of BTC and increases the block size of BTC . However, BCH client errors occur frequently, and it increases the operating cost of the full node, which brings centralization risks. In 2019, in order to fight against attackers who exploited BCH code vulnerabilities, the BCH mining pool launched a 51% attack to modify transaction data.
Community resistance : Between security and scalability, the BTC community prioritizes security. BTC core developers are cautious about technical risks, so they are very conservative in the suggestion of directly expanding BTC . The simplest extension is to increase the size of each block of BTC . The proposal to increase the BTC block size has been supported by many users, miners and developers since 2015. By increasing the block capacity, users can obtain faster transaction speeds, and miners can charge more transaction fees. However, some developers, led by Wladimir van der Laan, the general manager of the BTC developer team, do not agree with this expansion method and support solutions such as Segregated Witness and Lightning Network. The debate on block expansion caused the BTC community to split. Finally, after BTC introduced the isolation upgrade technology, some people rejected this technology upgrade. In August 2017, it caused a Hard fork of BTC and derived BCH . After the Hard fork of BCH , the upper limit of the block was increased to 8 M, and then increased to 32 M, with an average TPS of around 120. In addition, in 2018, the BCH community split again due to differences in the technical upgrade route, and Hard fork out of BSV (Bitcoin Satoshi Vision). This fork caused the total computing power of the BCH network to plummet, and it has not reached the level of computing power before the fork. BSV 's block size limit has been increased to 4 G, but lacks miners and users, and is far less secure than BTC .
BTC 's fork history, image source: https://www.blocktempo.com/forks-history-5 years-review/
BCH network total hashrate history, image source: https: BTC.com/zh-CN/ BCH/insights-hashrate
Layer 2 solution : In fact, directly modifying BTC is highly complex and has great resistance from the community. The solution that is more accepted by the community is to build a new layer based on BTC , which is compatible and does not affect the BTC system while solving the above problems. BTC has extremely high security. Using BTC as the core layer, relying on BTC block data and using BTC scripts, developers can build a BTC -compatible system on the upper layer of BTC , and execute a large number of transactions outside of BTC . The final state data is written into BTC . This type of scheme is called BTC Layer 2.
The goal and development history of the second layer of BTC
BTC Layer 2 refers to the second-layer expansion technology of Bitcoin (BTC). This type of technology aims to increase the transaction speed of Bitcoin, reduce handling fees, increase scalability, and solve a series of problems faced by BTC .
Layer 2 development goals:
Improve transaction speed: Layer 2 tries to increase the transaction speed of Bitcoin by optimizing the transaction processing method, batch processing transactions under the chain, and using the latest technology to synchronize and verify each transaction under the chain, thereby expanding the global scope of Bitcoin. application and promotion within.
Reduce transaction costs: Layer 2 processes transactions in batches under the BTC chain, and only writes the final state of the transaction into BTC . The intermediate transactions and states between the final state and the initial state exist off-chain and are not synchronized on BTC , reducing the Transaction fees, and reduce the burden on Bitcoin's underlying blockchain.
Increased scalability: The introduction of Layer 2 technology aims to alleviate the scalability problem of Bitcoin's underlying blockchain, making it more capable to cope with future transaction volume growth.
In recent years, Layer 2 has been one of the most important investment themes in the crypto industry, but in most scenarios it specifically refers to the Layer 2 expansion plan of Ethereum. However, the expansion plan of BTC is much earlier than the expansion proposal of Ethereum. Even Ethereum was created after Vitalik Buterin's proposed improvements to BTC were rejected.
In 2012, the concept of Pegged Sidechains was first proposed, derived from Two-way Peg, which allows assets to be seamlessly transferred between the two chains. This proposal laid the foundation for later sidechain technology.
In 2014, Blockstream was established to start researching and developing sidechain technology to improve the scalability of Bitcoin.
In 2015, the Lightning Network Whitepaper was released, and Tadge Dryja and Joseph Poon were the authors of the Whitepaper. Lightning Network is a solution that separates small transactions from the main chain. By creating a two-way payment channel, there is no need to record intermediate transactions on the blockchain, and only the final state needs to be recorded on BTC .
Because the design of BTC is relatively simple, and it does not have flexible scalability, it is difficult for the early BTC Layer 2 scheme to be embedded in Bitcoin, so it has not aroused great repercussions.
Until 2017, SegWit (Segregated Witness) was upgraded and activated, which solved the problem of transaction plasticity in the Bitcoin blockchain and made possible the development of Layer 2 technology.
Since 2018, developers have gradually begun to deploy Lightning Network nodes, and have gained certain users and support. According to statistics from the bitcoinvisuals website , as of June 4, 2023, the number of nodes in the Lightning Network has exceeded 18,000, and the number of payment channels that can accommodate exceeds 70,000. The network capacity exceeds 5,000 bitcoins, worth more than 100 million U.S. dollars .
Recently, the emergence of the BRC-20 token standard has further enriched the related ecology of Bitcoin, and at the same time brought BTC Layer 2 into the public eye. There are many projects building BTC Layer 2, the most well-known being the Lightning Network.
lightning network
The Lightning Network was first proposed in 2015 by Joseph Poon and Thaddeus Dryja in their Whitepaper. The Lightning Network uses micro-payments channel technology to place a large number of transactions outside the Bitcoin blockchain, and only put key links on the chain for confirmation. The transaction process is as follows: a user who needs to trade opens a room for offline transactions. When entering the room, the user pledges the currency to obtain a bill, and uses the new bill to distribute the pledged currency of both parties. After the transaction is completed, when the room is out, the transaction is settled. The latest note redemption currency.
A technical brief on the Lightning Network
In order to construct a safe and reliable micropayment channel, Lightning Network adopts Recoverable Sequence Maturity Contract (RSMC) and Time Lock Contract (Hashed Timelock Contract, HTLC) as key technologies.
RSMC provides pledge and settlement functions, that is, a multi-signature wallet fund pool. Both parties to the transaction pre-deposit a part of the funds into the fund pool. In the initial case, the distribution plan of both parties is equal to the pre-stored amount. Every time a transaction occurs, it is necessary to jointly confirm the fund distribution results generated after the transaction, and sign at the same time to invalidate the old version of the distribution plan. When any party needs to withdraw cash, he can write the transaction result signed by both parties to the blockchain network to be confirmed. From this process, we can see that BTC transactions are only required when withdrawing cash. The party who first initiates the withdrawal arrives 1000 blocks later than the other party, and the other party can refute within this time window.
Lightning network transaction process, image source:https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber= 8962150
HTLC establishes a transaction channel for both parties, analogous to a transaction room, sets a validity period, and automatically settles when the validity period expires. At the same time, HTLC also agrees on cross-channel transaction rules to facilitate transaction routing: In the Lightning Network, the establishment of transaction channels requires cost, and there may be no existing transaction channels between any two users. At this time, transaction channels that exist with other people can be used as Intermediary, conduct transactions.
Payment channel and routing of Lightning Network, image source: https://cypherpunks-core.github.io/bitcoinbook/ch 12.html
However, the early Lightning Network had the following problems:
Each transaction requires two parties to operate: In the channel, each transaction requires both parties to confirm the signature, and no unilateral transfer is possible
A game between the two sides of the transaction is required: if A and B conduct a transaction, and A uses the old transaction result to initiate a withdrawal, B can only submit an updated version of the transaction result as a rebuttal within 1000 blocks of time, otherwise A’s withdrawal will take effect
Channel state management: Users need to dynamically synchronize and back up the state of the channel, otherwise, if an old state is submitted, the counterparty can initiate a fraudulent rebuttal, request a claim, and obtain all assets in the channel
In fact, early versions of the Lightning Network required users to run full-node wallets or use fully-custodial wallets due to the aforementioned issues. Full-node wallets require users to manually manage temporary private keys and channel status, and the transaction experience is not good. Fully managed wallets, such as Chivo used in El Salvador, have a low threshold for use, and the custodian automatically operates on behalf of the user. However, the custodian has control over the private key of the user account, and its security is worrying. As developers continue to develop the Lightning Network, the above-mentioned problems are gradually being resolved, and a more complete Lightning Network and supporting facilities have been developed, such as OmniBOLT and the OBAndroid Lightning Network wallet developed by its team.
OmniBOLT Omni means complete and complete, and BOTL is the abbreviation of Basis of Lightning Technology. Based on BTC and Omni Layer, OmniBOLT proposes a complete Lightning Network protocol. While expanding the function of Lightning Network to pay BTC , it can also issue and trade diversified assets based on Omni Layer, and supports automated market maker mechanism (AMM: Automated market makers), allowing users to use the fund pool of the payment channel as Liquidity on the Lightning Network to build and use decentralized exchanges. OmniBOTL has a grand vision, but at present, the technology is complex, involving multiple protocols and systems, and there may be risks of vulnerabilities, and more time is needed to test its security.
OmniBOLT protocol architecture, image source: https://omnilaboratory.github.io/obd/#/
OBAndroid is a full-featured lightning network full-node mobile wallet. In this wallet, while the user has the right to control the private key, it can automatically monitor transactions, quickly synchronize full-node data, and support cloud and local backup channel status. In addition, OBAndroid also supports Omnilayer assets to be traded through OmniBOTL. OBAndroid makes the trading experience of the Lightning Network acceptable to users, lowering the threshold for using the Lightning Network.
OBAndroid full node wallet, image source: https://github.com/omnilaboratory/OBAndroid
Other BTC Layer 2 projects
In addition to the Lightning Network, there are other BTC Layer 2 projects in development:
Syscoin is BTC by the SYSLab team forking the BTC source code, aiming to take advantage of the security of BTC and be compatible with the Ethereum ecosystem. Currently, the SYSLab team has launched NEVM (Network-Enhanced Virtual Machine), a virtual machine built using the security of BTC 's PoW, compatible with Ethereum smart contracts. In addition, the SYSLab team also plans to launch ZK and Optimistic's Rollup, Validium with on-chain Proof of Data and other projects. The Syscoin project has little information, and it is difficult to evaluate its pros and cons technically. However, its source code library is updated frequently and is still under stable development.
Syscoin’s roadmap, source: https://syscoin.org/news/syscoin-roadmap-2022
RGB (Really Good for Bitcoin) is a BTC smart contract system integrated with Lightning Network, proposed by Giacomo Zucco and Peter Todd in 2016. RGB leverages BTC to maintain censorship resistance and combat double spend attacks. In RGB, the transaction and verification of all tokens are processed off-chain, and only the party receiving the payment needs to perform client verification. The client checks the source of funds of the payer in BTC , and after confirming that the transaction is valid, it directly modifies the UTXO of both parties to the transaction without writing the transaction data into the blockchain, which has the feature of protecting privacy. In addition, the client can directly introduce the function of the smart contract to judge the rules of the transaction, and because the global state consensus is not required, the data of the smart contract does not need to be uploaded to the chain, and the privacy feature can also be guaranteed. The RGB community has developed a Turing-complete smart contract virtual machine AluVM (algorithmic logic unit VM), which has good scalability, security and privacy protection.
Comparison of transactions on RGB and transactions on BTC , source: https://medium.com/@FedericoTenga/understanding-rgb-protocol-7dc7819d3059
Comparison of AluVM with other programming models, source: https://www.rgbfaq.com/glossary/aluvm
BTC Layer 2 Summary and Outlook
Although Bitcoin is the world's earliest, safest, most well-known and highest-valued blockchain network, its ecological development has continued to deepen. For example, the channel capacity of its largest second-layer network, the Lightning Network, continues to grow, the Taproot upgrade improves Bitcoin’s efficiency and privacy, and the Taro protocol introduces Stablecoin payments and on-chain native NFTs to the Lightning Network. However, compared with the number of Bitcoins on the Ethereum chain, the Bitcoin capacity of the Lightning Network is relatively low, and due to the full node data synchronization and channel state management, the use threshold of the Lightning Network is high, and the user scale is not as good as that of Ethereum, but This status quo may indicate huge growth potential. With the further development of Lightning Network-related ecology, the continuous development of the improved version of the Lightning Network protocol like OmniBOLT and the OBAndroid wallet that lowers the threshold for use will make the Lightning Network finally have good security and scalability. It is accepted by users because of its high quality and ease of use, which may bring the market value of BTC to a higher level.
At the same time, we also need to pay attention to the development of other Layer 2 projects, such as the RGB scheme with natural privacy protection and Syscoin compatible with the Ethereum ecosystem. These projects are not as famous as the Lightning Network, but they can also solve the problems faced by BTC , and have advantages that other solutions cannot match. However, compared with the second-layer expansion projects of Ethereum, these projects are not well-known enough, have received less investment, and do not receive the support of the BTC core development team like the Lightning Network. Their expansion of BTC will most likely be later than Ethereum The implementation of extensions, such as Syscoin's Rollup solution. In terms of Layer 2 ecology, it seems that the Ethereum ecology has a better virtuous circle and is more favored by investors.
In the future, we may see accelerated expansion of the Bitcoin ecosystem. As the Lightning Network infrastructure improves and attracts more and more attention, Lightning Network-based projects like OmniBOLT and RGB can benefit from it, gaining a better development foundation, more users and even more investment. And BTC Layer 2 projects compatible with Ethereum such as Syscoin will also benefit from the rapid development of Ethereum's second-layer ecosystem and accelerate the progress of its roadmap. In addition, the discussion on the BTC expansion scheme has not stopped: the Bitcoin-based zk-rollups two-layer network proposed by John Light in 2022 will likely bring more functions, higher scalability and Better privacy while maintaining its decentralized nature; Block, a company led by former Twitter CEO Jack Dorsey, is promoting the Liquidity improvement of the Lightning Network, which may mean that the Bitcoin ecosystem will be more popular in payments, DeFi, NFT, etc. Outside the field, open up a new track to cover more users.
[ 1 ] Nakamoto, Satoshi. "Bitcoin whitepaper." URL: https://bitcoin.org/bitcoin.pdf-(: 17.07. 2019) (2008).
[ 2 ] Poon, Joseph, and Thaddeus Dryja. "The bitcoin lightning network: Scalable off-chain instant payments." (2016).
[ 3 ] “Lightning Network Client Architectures.” URL: https://bolt.fun/guide/architecture
[ 4 ] Lin, Jian-Hong, et al. "Lightning network: a second path towards centralization of the bitcoin economy." New Journal of Physics 22.8 (2020): 083022.
[ 5 ] Discussion on increasing BTC block size: https://bitcoin-development.narkive.com/3 MPEfZHu/elopment-block-size-increase