Project Venus Documentation
repository·master·Indexed 22 days ago
https://github.com/filecoin-project/venusAn 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.
What's inside Venus
- 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.
Venus API v1 Method Groups Overview
masterThe 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.
Understand Filecoin networking via libp2p
masterFilecoin 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.
What is a designdoc and how to write one
masterA 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.
Market Service Provider events
masterThe
MarketServiceProvidergroup allows users withreadpermissions to listen for and respond to market events.ListenMarketEvent: Subscribes to market events for a specific miner.ResponseMarketEvent: Responds to a previously received market event.
Understand Venus Data Encoding and Interoperability
masterVenus leverages patterns from the IPFS project to ensure interoperability.
- Data Encoding: Uses
IPLDandCIDs(Content-IDs) for encoding data. - Block Distinction: Be aware that the term "block" is used in two different contexts:
- Blockchain Blocks: Defined in
types/block.go(specificallyvenus-shared/types/block_header.go). - Content-addressed Blocks: Used within the Block Service for content-id-addressed data.
- Blockchain Blocks: Defined in
While blockchain blocks are stored within the block service, they are distinct entities.
- Data Encoding: Uses
Wallet Client operations
masterThe
WalletClientgroup provides administrative methods for managing wallet information and signing operations. All methods requireadminpermissions.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.
Proof Client operations
masterThe
ProofClientgroup provides administrative methods for proof computation and miner connection management. All methods requireadminpermissions.ComputeProof: Computes a proof for a given set of sectors.ListConnectedMiners: Lists all miners currently connected.ListMinerConnection: Retrieves connection details for a specific miner.
How actor shims are designed in Venus
masterThe
venus-shared/actors/builtinpackage provides shims used to abstract over different actor versions. These shims follow three core design principles to ensure stability across protocol upgrades:- Structure Agnostic: Shim interfaces are designed to remain stable even if the underlying data structure changes. To achieve this, all shims utilize an internal
storeobject, allowing state to be moved without altering function signatures. Additionally, all functions are required to return anerrorto maintain a consistent signature. - Minimalism: Interfaces are kept minimal to reduce the maintenance burden during upgrades.
- 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.
- Structure Agnostic: Shim interfaces are designed to remain stable even if the underlying data structure changes. To achieve this, all shims utilize an internal
How Autorelay services solve connectivity issues
masterWhen AutoNAT detects a node is behind a private NAT, the Autorelay service enables reachability through delegated routing:
- Discovery: The node performs a DHT provider search for the
/libp2p/relaynamespace to find candidate relay nodes. - Connection: The node selects three random results and establishes long-lived connections using the
/libp2p/circuit/relay/0.1.0protocol. - Address Enhancement: The node adds relay-enabled
multiaddrsto its local address list. These addresses follow the format:/ip4/1.2.3.4/tcp/4001/p2p/QmRelay/p2p-circuit(where1.2.3.4is the relay's public IP,4001is the port, andQmRelayis the relay's Peer ID). - Announcement: The node announces these new relay-enabled addresses to existing connected peers via the
IdentifyPushprotocol, allowing them to be used for routing when others look the node up.
- Discovery: The node performs a DHT provider search for the
Manage payment channels with Paychan API
masterThePaychangroup of APIs provides functionality for managing payment channels. This includes creating channels, managing vouchers (the mechanism for transferring value within a channel), checking funds, and settling or collecting funds. Most state-changing operations requiresignpermissions.Manage Wallet Service Provider addresses
masterThe
WalletServiceProvidergroup allows for managing which addresses are supported by the wallet service. These methods requirereadpermissions.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).