Overview
Fiber Network is a next-generation public lightning network built on Nervos CKB and off-chain channels, which can provide fast, low-cost and decentralized multi-currency for RGB++ assets. Payments and peer-to-peer transactions.
Background
The Development and Challenges of Blockchain Technology p>
Blockchain technology has experienced rapid development since the advent of Bitcoin. From the initial simple payment function, it has gradually expanded to smart contracts, decentralized finance (DeFi ), non-fungible tokens (NFT) and other broad application areas. Although blockchain technology has significant advantages in security, transparency and decentralization, it faces many challenges in terms of scalability and transaction speed.
Scalability issue: Traditional blockchains such as Bitcoin and Ethereum suffer from transaction throughput There are significant bottlenecks. Due to Bitcoin's block size limit and 10-minute block generation time, its network can only process about 7 transactions per second; Ethereum, despite its improvements, is also far less capable of processing transactions per second than traditional payment networks .
High transaction fees: As network congestion increases, transaction fees rise significantly. For example, gas fees during peak periods on the Ethereum network can be higher than the transaction amount itself, which severely affects the user experience and reduces the viability of micropayments.
Long transaction confirmation time: In traditional blockchain networks, transactions need to wait for multiple block confirmations before they can be considered final confirm. This process may take several minutes to hours and is not suitable for instant payment application scenarios.
Although Nervos CKB has improved in performance and confirmation time, it still needs to further improve transaction speed and reduce transaction costs. To meet the needs of micropayments and instant payments.
Inspiration from the Lightning Network
Lightning Network, as a second-layer expansion solution for the Bitcoin network, successfully implements fast and low-cost micropayments through off-chain transactions and payment channel technology. Its core concepts include:
Payment channel: users create payment channels on the chain and the channels are opened Afterwards, both parties can conduct off-chain transactions an unlimited number of times, and on-chain settlement will only occur when the channel is closed. This significantly reduces the number of transactions on the chain, increases transaction speed, and reduces transaction fees.
Hash Time Lock Contract (HTLC): The HTLC technology lightning network can ensure the safe transfer of funds and avoid counterparty risks. Even if off-chain transactions fail, users can obtain financial protection through on-chain contracts.
Routing mechanism: The Lightning Network uses multi-hop routing, so that users can complete payments without opening a direct channel with the payee. This increases network flexibility and availability.
Nervos Advantages of CKB
Nervos CKB is a blockchain platform focused on versatility and security. Its unique design gives it unique advantages in solving blockchain scalability and interoperability issues:
Consensus mechanism: Based on NC-Max[1] consensus protocol, it also combines proof of work (PoW) and state leasing mechanism to ensure network security and effectiveness of resource utilization.
Powerful smart contract model: CKB’s unique Cell model and RISC-V instruction set virtual machine greatly enhance the UTXO model Ability to not only support Turing-complete smart contracts, but also easily implement features such as abstract accounts and covenants, providing more flexible programmability, better interoperability and scalability for decentralized applications.
Economic model: CKB’s economic model encourages long-term holding and rational use of network resources, providing benefits for decentralized applications, developers and Users are provided with a safe and sustainable decentralized ecological environment.
Fiber The significance of the Network project
By building an off-chain channel on Nervos CKB, we hope to combine the successful experience of the Lightning Network and CKB’s Technical advantages to build a fast, low-cost and decentralized multi-asset real-time payment exchange network. Specifically:
Solving scalability issues: through off-chain payment channels and multi-hop routing Technology, Fiber network can achieve high-throughput transaction processing to meet the needs of large-scale users.
Reduce transaction costs: Reduce the frequency of transactions on the chain and reduce user transaction fees, making micropayments feasible and efficient.
Improving transaction speed: through instant confirmation of off-chain transactions, a second-level payment confirmation experience is achieved, suitable for various instant payment scenarios .
Multi-asset support: Supports payment of multiple digital assets, providing users with a wider range of payment options.
Support network interoperability: Support interoperability with the Bitcoin Lightning Network, providing support for cross-chain payments and asset transfers.
Architecture Design
Overall Architecture
The overall architecture of Fiber Network includes the following core modules:
Off-chain payment channel
Off-chain payment channel is the core of Fiber Network, through which multiple off-chain transactions can be realized, only On-chain settlement occurs when the channel is closed. This mechanism significantly reduces the number of on-chain transactions, increases transaction speed and reduces transaction fees.
The general workflow is as follows:
Channel creation: Users from both parties create payment channels on the chain and lock a certain amount of CKB or RGB++ assets.
Off-chain transactions: During the opening of the channel, both parties can conduct off-chain transactions any number of times, and the channel status is updated for each transaction. But it does not need to be broadcast to the chain immediately.
Channel closure: When either party decides to close the channel, the final channel status will be broadcast to the chain for settlement to ensure that both parties The final balance is confirmed.
For specific message interaction format, please refer to Fiber Network P2P Message Protocol[2]
On-chain contract
Currently we use the Hash Time Lock Contract (HTLC) to ensure the security of off-chain transactions and be compatible with the Lightning Network. It can avoid counterparty risks and ensure that even if off-chain transactions fail, users can obtain financial protection through on-chain contracts.
The general workflow is as follows:
Transaction initiation: The payment initiator creates a transaction with hash lock and time lock conditions to lock a certain amount of CKB.
Hash verification: The payment recipient must provide the correct hash image within the specified time to unlock the transaction and complete the funds transfer.
Timeout refund: If the receiver fails to provide the correct hash image within the specified time, the transaction will be automatically unlocked and Refund to the payment originator.
Thanks to CKB’s Turing completeness, we can implement more flexible and secure on-chain contracts. In the future, the functions of the contract will be further expanded, such as the introduction of a cancellation mechanism based on version numbers and more secure Point Time-Locked Contracts.
Multi-hop routing
Multi-hop routing technology allows users to complete payments through multiple intermediate nodes without directly establishing a payment channel with the other party. This mechanism enhances network flexibility and coverage.
Workflow:
Path discovery: The payment initiator discovers the optimal path from itself to the payment recipient through the routing module.
Path locking: Create a corresponding HTLC contract at each node on the path to ensure safe transfer of funds.
The payment is completed: the payment recipient unlocks the HTLC, and the funds are transferred to each node on the path in turn.
At the same time, we will also use the HTLC contract to implement cross-chain payment and support it through the cross-chain hub service. For details on interoperability with the Lightning Network, please refer to Payment Channel Cross-Chain Protocol with HTLC[3]
Monitoring service
Monitoring service is an important part of Fiber Network. It is responsible for monitoring the payment channels under the chain. status to ensure the security of the channel and the safety of funds. The functions and functions are as follows:
Channel monitoring: monitor the payment channel status of all participating users in real time, Including the process of channel creation, update and closure.
Anomaly detection: Detect abnormal activities in the channel, such as malicious users trying to close the channel in an old state or attempting a double-spend attack.
Active response: When an abnormality is detected, the latest channel status is broadcast to the blockchain network in a timely manner to prevent malicious behavior. Loss of funds.
Current Progress and plans
Currently we have completed a prototype of Fiber Network, realizing the creation of a channel between two nodes, The basic functions of updating and closing also verify the cross-chain function with the Bitcoin Lightning Network. The project code can be found in these 2 GitHub repositories:
The next work plan is to complete multi-hop routing and monitoring services, as well as improve the RPC interface and SDK enables more developers to easily access Fiber Network.
The multi-hop routing protocol is based on the Dijkstra algorithm to search for payment paths, thereby reducing routing costs and improving the success rate of multi-hop path payment. After Fiber Network goes online, we will optimize the routing algorithm based on network traffic and operating conditions, and are expected to provide 2 to 3 path search strategies to adapt to users' different routing preferences and needs. Fiber Network will also introduce a multi-path payment strategy, dividing larger payments into multiple parts, with each part transmitted by a different path, further increasing the probability of payment success.
Monitoring services will be provided by some nodes in the Fiber Network. They stay online, pay attention to abnormal situations in the network, and help protect assets in the channel. The monitoring service will also track the cross-chain hub service. Even if the user is offline for a period of time, the monitoring service ensures that exchanges with the Lightning Network can proceed successfully.
In addition, we will also consider adding more functions to Fiber Network, such as using the programmability of CKB to implement privacy protection algorithms and optimizing routing based on this Algorithms and monitoring services to protect the security and privacy of user payment information.