Fuel Core is the official Rust-based node implementation for the Fuel blockchain network. This document provides an overview of the fuel-core codebase, its architecture, core components, and fundamental concepts necessary for understanding how the system operates.
Scope: This page covers the high-level structure and purpose of fuel-core. For detailed information about specific subsystems, refer to:
Sources: README.md1-241 Cargo.toml1-195 crates/fuel-core/src/service.rs1-136
Fuel Core is a modular blockchain client that implements the Fuel protocol. It serves as the foundation for running Fuel network nodes, providing block production, transaction execution, state management, and network communication capabilities.
Key Characteristics:
/v1/graphql README.md237-238Current Version: 0.47.1 is deployed on Fuel Ignition (mainnet), Testnet, and Devnet README.md12-18
Workspace Structure:
The codebase is organized as a Cargo workspace containing:
bin/fuel-core: CLI binary for running nodescrates/fuel-core: Core library aggregating all business logiccrates/services/*: Individual service implementations (executor, txpool, p2p, relayer, etc.)crates/types: Shared type definitionscrates/storage: Storage abstractions and implementationscrates/database: Database layercrates/chain-config: Chain configuration and genesisSources: README.md1-10 Cargo.toml1-46 crates/fuel-core/Cargo.toml1-13
Architecture Overview: Fuel Core Node Layers
The system is organized into distinct layers:
fuel-core CLI binary and external SDKs that interact with the nodeServiceRunner manages the lifecycle of all sub-services through the SharedState structureSources: crates/fuel-core/src/service.rs77-112 crates/fuel-core/src/service/sub_services.rs1-50 Diagram 1 from high-level diagrams
The FuelService is the main entry point that orchestrates all sub-services crates/fuel-core/src/service.rs114-136:
It manages the lifecycle of the node through the ServiceRunner pattern, which implements a state machine with states: NotStarted, Starting, Started, Stopping, Stopped crates/services/src/state.rs6-20
Sources: crates/fuel-core/src/service.rs114-136 crates/services/src/state.rs1-20
The executor supports protocol upgrades through a dual execution model crates/services/upgradable-executor/src/executor.rs138-164:
fuel-vm directly when block version matches (version 32)The current native version is defined as:
Sources: crates/services/upgradable-executor/src/executor.rs138-267
The transaction pool v2 (fuel-core-txpool) manages pending transactions with features including bin/fuel-core/src/cli/run.rs276-278:
Sources: bin/fuel-core/src/cli/run.rs276-278 Cargo.toml129
The CombinedDatabase aggregates multiple domain-specific databases crates/fuel-core/src/service.rs94:
Sources: crates/fuel-core/src/service.rs77-112 Diagram 3 from high-level diagrams
The P2P service uses libp2p 0.54 with multiple protocol behaviors Cargo.lock119-120:
Sources: Diagram 4 from high-level diagrams, Cargo.toml1-195
Build Dependencies:
cmake, pkg-config, build-essential, clang (Linux) README.md41-52wasm32-unknown-unknown target for WASM executor README.md57-60Runtime Requirements:
~/.fuel/db) bin/fuel-core/src/cli.rs28-30Sources: README.md30-60 README.md195-201 bin/fuel-core/src/cli.rs28-30
The cargo xtask build command handles additional build steps like GraphQL schema generation README.md107-114
Sources: README.md73-114
Basic local node:
Configuration options via CLI bin/fuel-core/src/cli/run.rs127-340:
--db-path: Database location (default: ~/.fuel/db)--db-type: rocks-db (persistent) or in-memory (testing)--snapshot: Path to genesis snapshot--port: GraphQL API port (default: 4000)--debug: Enable debug mode (manual block production, debugger endpoints)--poa-instant: Instant block production on transaction arrival--utxo-validation: Enable full UTXO validationSources: README.md133-168 bin/fuel-core/src/cli/run.rs127-340
Chain configuration is specified via JSON snapshot files bin/fuel-core/chainspec/local-testnet/chain_config.json:
Sources: bin/fuel-core/chainspec/local-testnet/chain_config.json1-50
Block Structure: Fuel uses versioned block headers crates/types/src/blockchain/header.rs38-48:
Each block header contains:
da_height, consensus_parameters_version, state_transition_bytecode_version, transactions dataprev_root, height, time, consensus-specific dataState Transition Bytecode Version: Determines which executor version processes the block crates/types/src/blockchain/header.rs70-80:
Sources: crates/types/src/blockchain/header.rs1-80 crates/services/upgradable-executor/src/executor.rs203-267
Transaction Lifecycle States
Transactions progress through states managed by the TxStatusManager crates/fuel-core/src/service.rs83-84:
Sources: Diagram 2 from high-level diagrams, crates/fuel-core/src/service.rs77-112
Fuel Core currently implements Proof of Authority (PoA) consensus crates/fuel-core/src/service/config.rs96:
Block Production Triggers crates/fuel-core/src/service/config.rs96:
Instant: Produce block immediately when transactions arriveInterval: Produce blocks at fixed time intervalsNever: Disable block production (validator/follower mode)Block Production Flow:
Sources: crates/fuel-core/src/service/config.rs8-9 crates/fuel-core/src/service/config.rs96 Diagram 2 from high-level diagrams
The storage architecture separates consensus-critical data from derived indexes crates/fuel-core/src/service.rs94:
On-Chain Database (consensus-critical):
FuelBlocks: Block headers and transactionsCoins, Messages: UTXO setContractsRawCode, ContractsState: Contract bytecode and storageConsensusParameters: Protocol parameters by versionStateTransitionBytecode: WASM modules for upgradesOff-Chain Database (derived/indexed):
TransactionStatuses: Transaction execution statusOwnedCoins, OwnedMessageIds: UTXO ownership indexesCoinBalances, MessageBalances: Aggregated balances by ownerCoinsToSpendIndex: Optimized coin selection indexThe GraphQL Worker maintains off-chain indexes by processing block import events asynchronously crates/fuel-core/src/service.rs94
Sources: crates/fuel-core/src/service.rs77-112 Diagram 3 from high-level diagrams
When RocksDB is enabled, fuel-core supports state rewind through StateRewindPolicy bin/fuel-core/src/cli/run.rs169-180:
Historical execution enables:
Sources: bin/fuel-core/src/cli/run.rs169-180 crates/fuel-core/src/service/config.rs85-89
For detailed information about specific subsystems:
Sources: Table of contents JSON provided in prompt
Refresh this wiki