config.json
Overview
The `config.json` file serves as a central configuration point for enabling, disabling, and controlling the behavior of various Ethereum-related APIs and system features in the application. It defines which Ethereum APIs are exposed through the system, and toggles key operational flags such as state synchronization, data pruning, local transaction handling, and querying capabilities.
This file is crucial for customizing the runtime environment of the Ethereum node or service, allowing operators to tailor performance, functionality, and resource usage according to their specific deployment needs.
Detailed Explanation
This file is a JSON-formatted configuration containing key-value pairs that influence the system's Ethereum API exposure and internal feature toggles.
Properties
eth-apis
Type: Array of strings
Description: Specifies the list of Ethereum-related API namespaces that should be enabled and made available to clients.
Values:
"eth": Core Ethereum JSON-RPC API"eth-filter": Event filtering and subscription API"net": Network status API"debug-tracer": Debugging and tracing API"web3": Web3 API for general Ethereum interaction"internal-eth","internal-blockchain","internal-transaction","internal-tx-pool","internal-debug": Internal APIs for advanced or administrative operations not typically exposed publicly
Usage Example:
To expose only the core Ethereum API and network info, you might configure:"eth-apis": ["eth", "net"]
state-sync-enabled
Type: Boolean
Description: Enables or disables state synchronization. When enabled, the system will synchronize the Ethereum state from peers rather than relying solely on local data.
Default Value:
falseUsage Notes:
Disabling state sync might be suitable for development or testing environments where full synchronization is unnecessary.
pruning-enabled
Type: Boolean
Description: Controls whether blockchain data pruning is enabled. Pruning helps reduce disk space by discarding old state data that is no longer necessary.
Default Value:
falseUsage Notes:
Enabling pruning can save storage but may restrict access to historical state data.
local-txs-enabled
Type: Boolean
Description: Determines if local transactions are enabled, allowing the system to handle transactions locally before propagating them to the network.
Default Value:
trueUsage Notes:
Useful for scenarios requiring local transaction pool management.
allow-unfinalized-queries
Type: Boolean
Description: Allows queries to access unfinalized blockchain data, which might be subject to change due to chain reorganizations.
Default Value:
trueUsage Notes:
Setting tofalserestricts queries to finalized data only, increasing data reliability at the cost of freshness.
Implementation Details
Format: The file uses standard JSON syntax for easy parsing by the application at startup or during configuration reloads.
Parsing: The system likely loads this file into an internal configuration object, which governs API exposure and feature toggles throughout the node's lifecycle.
Extensibility: New API namespaces or feature flags can be added by extending the JSON structure, ensuring backward compatibility.
Default Behavior: Missing keys might fall back to system defaults, so explicitly specifying all desired flags is recommended.
Interaction with Other Components
API Layer: The
eth-apisarray directly controls which API modules are initialized and exposed via the JSON-RPC server or other communication layers.Synchronization Module: The
state-sync-enabledflag affects the behavior of the blockchain synchronization mechanism, influencing data consistency and startup times.Storage Layer: The
pruning-enabledflag instructs the database or state storage component on whether to retain or discard historical data.Transaction Pool: The
local-txs-enabledflag configures the transaction pool management, affecting how locally submitted transactions are handled.Query Processor: The
allow-unfinalized-queriessetting informs the query subsystem whether to serve potentially unstable data or restrict to finalized blockchain states.
Together, these settings allow the application to adapt its runtime behavior for different environments such as development, testing, or production.
Visual Diagram
Below is a flowchart illustrating the configuration properties and their influence on the system components:
flowchart TD
A[config.json] --> B[eth-apis]
A --> C[state-sync-enabled]
A --> D[pruning-enabled]
A --> E[local-txs-enabled]
A --> F[allow-unfinalized-queries]
B --> G[API Layer Initialization]
C --> H[State Synchronization Module]
D --> I[Storage / Pruning Module]
E --> J[Transaction Pool Management]
F --> K[Query Processing Module]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B,C,D,E,F fill:#bbf,stroke:#333,stroke-width:1px
style G,H,I,J,K fill:#bfb,stroke:#333,stroke-width:1px
Summary
The `config.json` file is a lightweight yet critical configuration resource that shapes the Ethereum node's API exposure and core operational features. By adjusting its parameters, operators control the node's behavior regarding synchronization, data retention, transaction handling, and query precision. This file supports flexible deployment scenarios and enables fine-tuned control over system performance and capabilities.