Skip to content

Latest commit

 

History

History
108 lines (70 loc) · 6.15 KB

File metadata and controls

108 lines (70 loc) · 6.15 KB

Project Layout

This repository contains several Rust crates that implement the different building blocks of a Conflux node. The high-level structure of the repository is as follows:

  • bins: All binary crates located in this folder
  • crates: All library crates
  • tools: Tools for benchmark, testing (These crates are stand-alone and not included in the whole workspace)
  • internal_contract: Internal contracts's abi and interface
  • integration_tests and tests: The python integration tests
  • run: Node run misc, include default config file and start scripts
  • dev-support: Dev support scripts
  • docs: Documentation
  • changelogs: Changelogs, especially for the JSON-RPC APIs

Crates

binaries

The bins directory contains some binary crates:

  • conflux: The conflux binary program, which serves as both the node's startup program and a CLI tool. It can be used for account management, calling RPC interfaces, etc.
  • cfx_store: A tool for managing accounts.
  • cfx_key: A conflux account key generation tool.
  • pos-genesis-tool: A tool for generating PoS genesis data.

basic crates

  • cfx_bytes: Provides some general byte manipulation functions.
  • cfx_types:Provides some commonly used type definitions in blockchain, such as Address, U256, H256, etc.
  • cfx_addr: Conflux base32 address encoding/decoding.

primitives

The primitives crate contains the core data structures used in the Conflux system. For example, block, transaction, and receipt. This crate forms the foundational data structures of the entire Conflux system.

cfxcore

The Conflux Protocol's core code located at cfxcore directory. Including consensus, pow, transaction pool etc.

execution

The execution directory contains the execution engine, which is responsible for executing transactions and managing the state of the blockchain. It includes the following core crates:

And tracer crates:

Other utility crates:

dbs

All database-related code is located under dbs, which contains the core logic for the entire node's data storage. Specifically, it mainly includes two major categories of data: blockchain (block header, block body, receipt) and state (state trie, storage trie), as well as some indexing and development data (trace).

The underlying layer primarily uses rocksdb, and also uses sqlite to store some snapshot-related data.

  1. kvdb-rocksdb: Rust wrapper for rocksdb, which depends on third-party crates (kvdb, rocksdb) at the underlying layer
  2. db: Mainly provides the open_database method, which returns a db instance that can be used for data reading and writing
  3. db-errors: Database operation error definitions
  4. storage: The main implementation of the state database, including mpt, mpt snapshot and other logic, providing lower-level read/write interfaces StateTrait. This crate is the core code for state storage
  5. statedb: Simple wrapper around storage, providing higher-level read interfaces StateDbExt

Additionally, the upper-level modules that call the db module mainly consist of two parts:

  1. crates/cfxcore/core/src/block_data_manager: Encapsulates all data read/write interfaces
  2. crates/execution/executor/src/state: The state object of the execution module, which essentially wraps StateDb and provides account state reading and updating interfaces for EVM.

network

The network directory contains the network crate.

client

The client crate contains the client startup logic and the Core Space RPC implementation.

RPC

Conflux provides a standard JSON-RPC 2.0 interface to allow external ecosystems (SDKs, wallets, etc.) to interact with the blockchain. Conflux includes two spaces: Core Space and eSpace, each with its own RPC.

The RPC implementation for eSpace is mainly located in the crates/rpc directory and is developed using the jsonrpsee RPC framework. It includes multiple crates:

  • rpc-primitives: Definitions of the raw types for RPC.
  • rpc-cfx-types: RPC type definitions for Core Space.
  • rpc-eth-types: RPC type definitions for eSpace.
  • rpc-eth-api: RPC interface definitions for eSpace, organized by namespace.
  • rpc-eth-impl: RPC interface implementation for eSpace.
  • rpc-cfx-impl: RPC interface implementation for Core Space.
  • rpc-builder: Logic for RPC interface registration and service startup.
  • rpc-utils: Implementation of common utilities, such as error code definitions.

The RPC implementation for Core Space is located in the crates/client crate, developed using jsonrpc-coree. The core code is in the src/rpc directory.

Stratum

Conflux uses the industry-standard Stratum protocol for implementing PoW mining. The protocol implementation code is primarily located in the crates/stratum and crates/blockgen directories. Additionally, there is some related code in the crates/cfxcore/core/src/pow/mod.rs file.

util

The util directory contains some general utility crates.