The Gas Price Service estimates transaction gas prices dynamically based on Data Availability (DA) layer costs and network activity. It provides real-time gas price information to the transaction pool and block producer, ensuring that fees reflect current network conditions and DA posting costs.
This page covers the V1 algorithm implementation, configuration options, and the adapter patterns used to integrate gas pricing with other services. For information about transaction pool gas price usage, see Transaction Pool Architecture. For block producer integration, see Block Production Pipeline.
Sources: crates/fuel-core/src/service/sub_services.rs69-78 crates/fuel-core/src/service/config.rs102
The Gas Price Service operates as a background task that monitors block imports and DA layer costs, continuously updating the estimated gas price. It exposes shared state through multiple adapter interfaces for different consumers.
Sources: crates/fuel-core/src/service/sub_services.rs272-291 crates/fuel-core/src/service/adapters.rs11-18
The service is initialized during node startup as part of the sub-services initialization process. Configuration is provided through CLI arguments and the GasPriceConfig structure.
| Parameter | Type | Purpose |
|---|---|---|
starting_gas_price | u64 | Initial gas price at genesis |
gas_price_change_percent | u16 | Max percentage change between updates |
min_gas_price | u64 | Minimum allowed gas price |
gas_price_threshold_percent | u64 | Threshold for price adjustment triggers |
min_da_gas_price | u64 | Minimum DA-related gas price |
max_da_gas_price | u64 | Maximum DA-related gas price |
da_gas_price_p_component | i64 | Proportional component for DA pricing |
da_gas_price_d_component | i64 | Derivative component for DA pricing |
da_committer_url | Option<Url> | URL of DA cost API endpoint |
da_poll_interval | Duration | Interval for polling DA costs |
da_starting_recorded_height | Option<BlockHeight> | Starting height for DA cost tracking |
Sources: bin/fuel-core/src/cli/run.rs400-412 crates/fuel-core/src/service/config.rs102
Sources: crates/fuel-core/src/service/sub_services.rs272-291
The V1 algorithm calculates gas prices based on a combination of execution costs and DA layer posting costs. It uses a PD (Proportional-Derivative) controller to adjust prices dynamically.
Sources: crates/fuel-core/src/service/sub_services.rs69-78 crates/fuel-core/src/service/sub_services.rs286-291
The service exposes gas price information through two adapter implementations, each serving different use cases.
Provides general-purpose gas price estimates with configurable change percentage limits. Used by the transaction pool for validation and fee estimation.
The DEFAULT_GAS_PRICE_CHANGE_PERCENT is set to 10, meaning the provider will limit gas price changes to 10% increments when queried.
Sources: crates/fuel-core/src/service/sub_services.rs292-295 crates/fuel-core/src/service/sub_services.rs131 crates/fuel-core/src/service/adapters.rs11-18
Combines the algorithmic gas price with the universal provider for block production. This ensures block producers have access to both the raw algorithm output and the rate-limited public estimate.
Sources: crates/fuel-core/src/service/sub_services.rs297-300
The Gas Price Service uses a dedicated database column for persisting historical gas price data and algorithm state.
| Database | Purpose | Key Type | Value Type |
|---|---|---|---|
GasPriceDatabase | Historical prices and algorithm state | Block height or timestamp | Price data and metadata |
The database is accessed through database.gas_price() and is part of the CombinedDatabase system. The service both reads historical data for initialization and writes new prices as they are computed.
Sources: crates/fuel-core/src/service/sub_services.rs283
The transaction pool queries gas prices to validate incoming transactions and reject those with insufficient fees. It uses the UniversalGasPriceProvider which provides rate-limited price updates.
Sources: crates/fuel-core/src/service/sub_services.rs302-314
The block producer uses FuelGasPriceProvider to determine the gas price for newly produced blocks. The gas price is included in the block header and affects fee distribution.
Sources: crates/fuel-core/src/service/sub_services.rs333-342
The service subscribes to the chain state provider to receive consensus parameter updates and block height information, ensuring gas price calculations reflect current network conditions.
Sources: crates/fuel-core/src/service/sub_services.rs240-245 crates/fuel-core/src/service/sub_services.rs270-286
The service polls a Data Availability committer API to track the cost of posting block data to the DA layer (typically Ethereum L1). These costs directly influence gas price calculations.
The da_committer_url configuration specifies the HTTP endpoint. The service makes periodic requests to retrieve current DA posting costs and adjusts gas prices accordingly.
Sources: crates/fuel-core/src/service/sub_services.rs272-276
The service maintains shared state through the SharedData structure, which provides lock-free access to current gas price information.
The LatestGasPrice wraps an Arc<AtomicU64> for efficient, thread-safe reads without contention. Multiple services can query the current gas price simultaneously without blocking.
Sources: crates/fuel-core/src/service/sub_services.rs287-291
The Gas Price Service follows the standard RunnableService pattern used throughout fuel-core:
init_sub_servicesThe service runs independently and does not block other services. Consumers read the shared LatestGasPrice asynchronously.
Sources: crates/fuel-core/src/service/sub_services.rs276-286
Refresh this wiki