Project Venus Documentation

repository·master·Indexed 22 days ago

https://github.com/filecoin-project/venus

An implementation of the Filecoin Distributed Storage Network featuring a modular architecture for participating in the Filecoin ecosystem. This documentation covers building and installing the software, using the gengen tool for genesis.car generation, managing Filecoin wallets, interacting with the blockchain via the chain CLI, and operating the Venus daemon and development networks.

Tokens
61.3K
Snippets
141
Records
437
Agent score
84%

What's inside Venus

  1. Overview of Project Venus

    master
    Venus is an implementation of the Filecoin Distributed Storage Network. It is designed with a focus on security, ease of use, and the ability to participate in distributed storage pools. Unlike other implementations like Lotus, Venus utilizes a modular architecture where various modules work together to realize a fully featured Filecoin implementation.
  2. Venus API v1 Method Groups Overview

    master

    The Venus API v1 is organized into several functional groups. Developers can interact with the following high-level modules:

    • Account: Manage account keys and state.
    • Actor: Interact with actors, list them, or subscribe to actor events.
    • BlockStore: Low-level object storage operations (Put, Get, Stat, Delete).
    • ChainInfo: Retrieve chain state, blocks, messages, receipts, and tipsets.
    • Common: Basic node information like status and version.
    • ETH: Ethereum-compatible JSON-RPC methods (e.g., EthGetBalance, EthSendRawTransaction).
    • F3: F3-specific operations like certificate management and participation.
    • Market: Access market participant state.
    • MessagePool: Manage the pool of pending messages and gas estimation.
    • MinerState: Detailed queries regarding miner allocations, sectors, and balances.
    • Mining: Core mining operations like creating blocks.
    • Network: Peer discovery, connectivity, and bandwidth statistics.
    • Paychan: Payment channel operations (Fund, Settle, Voucher management).
    • Syncer: Synchronization logic and tipset management.
    • Wallet: Wallet management including signing, importing, and address handling.
  3. Understand Filecoin networking via libp2p

    master

    Filecoin uses libp2p as its modular networking stack. This stack provides the building blocks for peer-to-peer communication, including:

    • Peer discovery: Finding other nodes in the network.
    • Transport switching & multiplexing: Using a single physical connection (currently TCP) to channel multiple protocols (e.g., Kad DHT, Filecoin Hello) via libp2p streams.
    • NAT traversal: Overcoming connectivity issues caused by routers/NAT devices.
    • Pubsub: Propagating blockchain blocks and messages using Gossipsub.
    • Circuit relay: Enabling connectivity between nodes that cannot be reached directly.
  4. What is a designdoc and how to write one

    master

    A designdoc is a short document used to capture design intent. Its purpose is to articulate a problem, propose a solution, and provide the reasoning (the why) behind that solution. It is a planning tool used to discover truths and evaluate hypotheses collectively, rather than a document meant to defend a fixed position.

    To be effective, a designdoc should include these core sections:

    • Problem Statement: Clearly define what problem is being solved and why it matters.
    • Requirements and anti-requirements: Enumerate assumptions, constraints, non-goals, and anti-requirements.
    • Proposal & Rationale: A sketch of the proposed solution and the reasoning behind it (e.g., what is gained by doing this vs. what is lost if not done).
    • Alternatives: Explicitly state what other approaches were considered and why they were rejected.

    Key Characteristics:

    • Focus on 'Why': Unlike a specification (spec), a designdoc focuses on the rationale and the big picture.
    • Brevity: It should be concise and prioritize clarity over length.
    • Not a Spec: A spec is a dense, detail-oriented contract for interoperability; a designdoc is a high-level tool for rationalizing a plan before implementation.
    • Not a GitHub Issue: While it can be hosted in an issue, it should serve as a coherent summary of conclusions rather than a raw discussion thread.
  5. Understand Venus Data Encoding and Interoperability

    master

    Venus leverages patterns from the IPFS project to ensure interoperability.

    • Data Encoding: Uses IPLD and CIDs (Content-IDs) for encoding data.
    • Block Distinction: Be aware that the term "block" is used in two different contexts:
      1. Blockchain Blocks: Defined in types/block.go (specifically venus-shared/types/block_header.go).
      2. Content-addressed Blocks: Used within the Block Service for content-id-addressed data.

    While blockchain blocks are stored within the block service, they are distinct entities.

  6. Wallet Client operations

    master

    The WalletClient group provides administrative methods for managing wallet information and signing operations. All methods require admin permissions.

    • ListWalletInfo: Lists all wallet information.
    • ListWalletInfoByWallet: Lists information for a specific wallet.
    • WalletHas: Checks if a wallet has a specific address.
    • WalletSign: Signs data using a wallet.
  7. How actor shims are designed in Venus

    master

    The venus-shared/actors/builtin package provides shims used to abstract over different actor versions. These shims follow three core design principles to ensure stability across protocol upgrades:

    1. Structure Agnostic: Shim interfaces are designed to remain stable even if the underlying data structure changes. To achieve this, all shims utilize an internal store object, allowing state to be moved without altering function signatures. Additionally, all functions are required to return an error to maintain a consistent signature.
    2. Minimalism: Interfaces are kept minimal to reduce the maintenance burden during upgrades.
    3. Queries over Field Accessors: Functions are designed to query state (e.g., asking 'is this actor active?') rather than simply acting as field assessors (e.g., 'get the status field'). Queries are more resilient to changes in the underlying specification/actor upgrades. However, developers should avoid implementing overly complex logic within the shim itself to prevent duplication across different shim implementations.
  8. How Autorelay services solve connectivity issues

    master

    When AutoNAT detects a node is behind a private NAT, the Autorelay service enables reachability through delegated routing:

    1. Discovery: The node performs a DHT provider search for the /libp2p/relay namespace to find candidate relay nodes.
    2. Connection: The node selects three random results and establishes long-lived connections using the /libp2p/circuit/relay/0.1.0 protocol.
    3. Address Enhancement: The node adds relay-enabled multiaddrs to its local address list. These addresses follow the format: /ip4/1.2.3.4/tcp/4001/p2p/QmRelay/p2p-circuit (where 1.2.3.4 is the relay's public IP, 4001 is the port, and QmRelay is the relay's Peer ID).
    4. Announcement: The node announces these new relay-enabled addresses to existing connected peers via the IdentifyPush protocol, allowing them to be used for routing when others look the node up.
  9. Manage Wallet Service Provider addresses

    master

    The WalletServiceProvider group allows for managing which addresses are supported by the wallet service. These methods require read permissions.

    • AddNewAddress: Adds a new address to the supported list.
    • RemoveAddress: Removes an address from the supported list.
    • SupportNewAccount: Configures support for a new account.
    • ListenWalletEvent: Subscribes to wallet-related events (e.g., signing events).