Nervos Network RFCs

repository·master·Indexed 42 days ago

https://github.com/nervosnetwork/rfcs

The central hub for Nervos Network's Request for Comments (RFC) process, containing proposals, standards, and documentation for the network's evolution. Includes the Positioning Paper (RFC 0001) detailing the layered architecture, the Common Knowledge Base (CKB), the CKB Cell Model, and the RISC-V based CKB-VM.

Tokens
90.3K
Snippets
125
Records
341
Agent score
48%

What's inside Nervos Network

  1. Overview of the CKB P2P Scoring System and Security Strategies

    master

    The CKB P2P Networking layer utilizes a scoring system to mitigate network security threats, specifically targeting 'Eclipse Attacks'. In an Eclipse Attack, a malicious actor attempts to occupy all of a victim node's peer connection slots to filter the victim's view of the blockchain.

    To defend against this, CKB clients are expected to implement a scoring system based on three core principles:

    1. Peer Information Storage: Nodes should store as much peer information as possible.
    2. Continuous Scoring: Nodes must continuously score peers based on both good and bad behaviors.
    3. Peer Management: Nodes should prioritize retaining high-score (good) peers and evicting low-score (bad) peers.

    This scoring system provides a foundation for implementing more sophisticated security strategies similar to those used in the Bitcoin network to handle generalized network security cases.

  2. Understand the CKB Transaction Structure

    master
    A CKB transaction is the fundamental data structure used to state changes on the network. It is composed of several key components that manage value storage, data integrity, and script execution. The structure is divided into Core Features (Value Storage, Cell Data, Code Locating, Lock Scripts, and Type Scripts) and Extensions (Dep Groups, Upgradable Scripts, Type IDs, and Header Deps).
  3. Understand the CKB Light Client Protocol

    master

    The CKB Light Client Protocol is a FlyClient-based implementation designed to allow resource-constrained clients to verify the validity of the CKB blockchain without downloading all blocks or headers.

    Key features include:

    • Efficiency: It requires downloading only a logarithmic number of block headers.
    • Low Storage: It only needs to store a single block header between executions.
    • Security: It uses a sampling protocol tailored for the [NC-Max] difficulty adjustment algorithm to ensure security against adversaries with significant computing power.
  4. Understand the Nervos Network Positioning Paper

    master
    The Nervos Network Positioning Paper (RFC 0001) serves as a high-level conceptual guide to the network's design philosophy. It provides context on the problems facing public permissionless blockchains (such as scalability and sustainability) and explains the rationale behind Nervos's specific design decisions and trade-offs. Use this document to understand how the various protocols and innovations within the Nervos Network work together to achieve the network's overall vision.
  5. CKB-VM Version 1 Overview

    master
    CKB-VM Version 1 is an updated version of the CKB Virtual Machine that introduces several improvements over Version 0. Key changes include bug fixes for stack alignment and memory bounds, new RISC-V extensions, performance optimizations like lazy memory initialization, and debugging features like Chaos memory mode. Developers should be aware that upgrading from Version 0 to Version 1 may change how binaries are loaded due to an update to the goblin crate.
  6. Overview of CKB Consensus

    master

    CKB uses an improved Nakamoto consensus based on Proof-of-Work (PoW). It is designed to be an open, permissionless system where nodes can join or exit freely.

    Key characteristics include:

    • ASIC-neutral PoW: Uses a function designed to distribute tokens evenly and maximize network security by remaining resistant to specialized ASIC hardware.
    • Node Roles: Nodes participate by either mining (running the algorithm to produce new blocks) or verifying (checking that new blocks are valid).
    • Correctness Goals: Aims for eventual consistency (identical state across nodes), availability (timely responses), and fairness (equitable returns for miners).
    • Performance Metrics: Performance is measured by transaction latency (time to confirmation) and transaction throughput (transactions per second), both of which are influenced by the block time.
  7. What is Cheque Lock and when to use it

    master

    Cheque Lock is a lock script designed to facilitate asset transfers (like SUDT or mNFT) between users without requiring the receiver to have a pre-existing ACP (Anyone-Can-Pay) cell or the sender to provide CKBytes for the receiver's destination cell.

    How it works:

    1. Sender creates a 'Cheque cell' containing the asset and specifies the receiver's address. The sender provides the CKBytes for this cell.
    2. Receiver can claim the asset at any time. To claim, the receiver must provide the CKBytes for their own destination cell. These CKBytes are returned to the sender during the claim process.
    3. Time Lock: The asset is locked for 6 epochs (~24 hours). During this window, only the receiver can claim. After 6 epochs, the sender can choose to withdraw the asset if it hasn't been claimed.

    Use Case: Use Cheque Lock to improve UX by allowing users to receive assets without prior setup, and to reduce sender costs by returning CKBytes to the sender upon successful claim.

  8. Overview of the CKB P2P Scoring System and Network Security

    master

    The CKB P2P network layer implements a scoring system designed to mitigate security threats like 'Eclipse Attacks'. In an Eclipse Attack, malicious nodes attempt to occupy all of a victim node's peer connections to control the victim's view of the network, potentially leading to double-spending or manipulated hash power.

    To defend against these attacks, the CKB P2P network follows three core rules:

    1. Store Peer Information: Nodes should store as much information about known peers as possible.
    2. Continuous Scoring: Nodes must constantly score peers based on their good and bad behaviors.
    3. Peer Management: Nodes should retain high-scoring (good) peers and evict low-scoring (bad) peers.
  9. Overview of the CKB-VM architecture

    master

    The CKB Virtual Machine (VM) is used to validate transactions by executing scripts to determine if a transaction's inputs and outputs satisfy specific rules.

    CKB implements the rv64imc RISC-V architecture:

    • RV64I: Base 64-bit integer ISA.
    • M: Standard extension for integer multiplication and division.
    • C: RISC-V Compressed Instructions (to reduce contract size).

    Key Constraints:

    • No Floating Point: CKB does not support floating-point instructions. Developers requiring floating-point math must use a software-based (softfloat) implementation packed into the binary.
    • Single-Threaded: The VM follows a strict single-threaded model. While contracts can implement their own coroutines, atomic instructions are not required.
    • Memory Limit: The VM has a maximum runtime memory of 4 MB, which includes executable code pages, stack space, head space, and mmapped pages for external cells.
    • Format: CKB uses the Linux ELF format directly for contract files to ensure maximum tooling and debugging support.
  10. What is CKB-VM version 2

    master

    CKB-VM version 2 is the specification implemented in the CKB Meepo hardfork. It is designed to improve the security, portability, and efficiency of scripts on the Nervos Network compared to version 1.

    Key improvements include:

    • Enhanced Script Isolation: Introduces the Spawn system call, allowing scripts to create child scripts with independent memory areas. This provides a secure alternative to dynamic library calls (which share memory space and pose security risks) and the Exec system call (which is difficult to use effectively).
    • Performance Optimizations: Implements Macro-Operation Fusion (MOP) to reduce cycle counts for common instruction sequences, specifically targeting complex scripts like zero-knowledge proofs.
  11. What is the Nervos Common Knowledge Base (CKB)?

    master
    The Nervos Common Knowledge Base (CKB) is a storage and verification system designed to maintain 'common knowledge'—state verified by global consensus and accepted by all participants in the network. Unlike Bitcoin, which primarily stores a UTXO set, the CKB generalizes this by storing global state as a set of active programmable cells. It supports user-defined crypto-assets (fungible and non-fungible tokens) and cryptographic proofs for higher-layer protocols like payment channels and commit chains. While it possesses full smart contract capabilities, its economic model is optimized for preserving common knowledge rather than simply paying for decentralized computation.