config.json
Overview
This file, `config.json`, serves as the primary configuration file for a blockchain-related application, likely a node or service interacting with the Gnosis Chain (formerly xDAI). It contains key-value pairs representing runtime parameters and settings used to connect with various services (like RPC endpoints and fiat rate APIs), control operational behavior (mempool settings, timeouts), and define coin-specific metadata.
The configuration enables the application to:
Retrieve node version information from a local consensus node.
Fetch fiat currency conversion rates from CoinGecko.
Configure RPC connection parameters.
Adjust mempool transaction processing concurrency.
Define coin identity and display labels.
Control parsing and resync behaviors.
This JSON file is loaded at startup and its values are referenced throughout the system to customize behavior without hardcoding parameters.
Detailed Explanation of Configuration Parameters
Key | Type | Description | Example / Default |
|---|---|---|---|
`consensusNodeVersion` | string | URL to retrieve the consensus node's version information, typically used for health checks or compatibility validation. | `"http://localhost:5052/eth/v1/node/version"` |
`fiat_rates` | string | Identifier for the fiat rates provider service. Currently set to ["coingecko"](/projects/291/69194), implying CoinGecko API is used for currency conversion rates. | |
`fiat_rates_params` | string (JSON) | Stringified JSON defining parameters for the fiat rates API call, including base URL, coin identifier, platform, target currency, and update period in seconds. | |
`fiat_rates_vs_currencies` | string | Comma-separated list of currency codes supported for fiat conversion rates, including fiat currencies and cryptocurrencies like BTC and ETH. | `"AED,ARS,AUD,...,BTC,ETH"` |
`mempoolTxTimeoutHours` | integer | Number of hours after which a transaction in the mempool times out and is discarded if not confirmed. | `24` |
`queryBackendOnMempoolResync` | boolean | Flag to determine if the backend should be queried during mempool resynchronization. | `false` |
`coin_name` | string | Full name of the coin or token the application is dealing with. | |
`coin_shortcut` | string | Abbreviated shortcut or ticker symbol for the coin. | `"xDAI"` |
`coin_label` | string | Label for UI display or logging purposes, often same as coin_name. | |
`rpc_url` | string | WebSocket URL of the RPC server to connect to the blockchain node. | `"ws://localhost:8546"` |
`rpc_user` | string | Username for RPC authentication (empty if not required). | `""` |
`rpc_pass` | string | Password for RPC authentication (empty if not required). | `""` |
`rpc_timeout` | integer | Timeout in seconds for RPC calls before considering them failed. | `25` |
`parse` | boolean | Flag indicating if blocks/transactions should be parsed or just indexed. | `true` |
`message_queue_binding` | string | Identifier or binding key for message queue integration (empty if not used). | `""` |
`subversion` | string | Subversion string for node identification or logging (empty if not set). | `""` |
`address_format` | string | Format identifier for blockchain addresses (e.g., hex, bech32) (empty if default). | `""` |
`mempool_workers` | integer | Number of worker threads or processes dedicated to mempool transaction processing. | `8` |
`mempool_sub_workers` | integer | Number of sub-worker threads for finer-grained concurrency in mempool processing. | `2` |
`block_addresses_to_keep` | integer | Number of block addresses to retain in memory or cache for quick access. | `300` |
Usage Examples
Since this file is a static JSON configuration, it is typically loaded at application startup. Example usage in a Node.js-like environment might be:
const fs = require('fs');
const config = JSON.parse(fs.readFileSync('config.json', 'utf8'));
console.log('RPC URL:', config.rpc_url);
console.log('Coin Name:', config.coin_name);
// Use config.rpc_url to establish WebSocket connection
// Use config.fiat_rates_params to fetch fiat currency rates at intervals
Important Implementation Details
Fiat Rates Parameters as Stringified JSON:
Thefiat_rates_paramsis stored as a string containing a JSON object rather than a nested JSON object itself. This design choice might be to support easy substitution or to pass the raw string directly to some service or environment that expects it in this format.Mempool Concurrency Configuration:
The mempool processing is split intomempool_workersandmempool_sub_workers, allowing for multi-level parallelism. This likely helps in balancing workload between transaction reception and detailed processing.RPC Connection:
The application connects to an Ethereum-compatible node using a WebSocket (ws://localhost:8546), which supports real-time event subscriptions and low-latency communication.Currency Support:
Thefiat_rates_vs_currenciesfield includes a comprehensive list of fiat and crypto currencies, enabling broad conversion rate support for UI or reporting modules.
Interaction with Other System Components
Consensus Node:
The application queries the consensus node version via the URL specified inconsensusNodeVersion. This is likely used to ensure compatibility or to log the node version.External APIs:
The CoinGecko API (as defined infiat_rates_params) is used to obtain fiat currency conversion rates for the specified coin. This data is probably used in the UI or backend to display values in user-preferred currencies.Mempool and Backend Services:
The mempool configuration directs how the system handles unconfirmed transactions in memory and whether to query backend databases during resyncs.RPC Node:
The RPC URL and credentials configure the connection to the blockchain node, enabling the application to send and receive blockchain data.Message Queue:
If configured, themessage_queue_bindingwould connect this service to a message queue (e.g., RabbitMQ), facilitating event-driven architecture or inter-service communication.
Visual Diagram: Configuration Structure Flowchart
flowchart TD
A[config.json] --> B[Node Version URL]
A --> C[Fiat Rates Provider]
C --> C1[fiat_rates_params (CoinGecko API details)]
C --> C2[Supported Currencies List]
A --> D[Coin Metadata]
D --> D1[coin_name]
D --> D2[coin_shortcut]
D --> D3[coin_label]
A --> E[RPC Connection]
E --> E1[rpc_url]
E --> E2[rpc_user]
E --> E3[rpc_pass]
E --> E4[rpc_timeout]
A --> F[Mempool Configuration]
F --> F1[mempoolTxTimeoutHours]
F --> F2[queryBackendOnMempoolResync]
F --> F3[mempool_workers]
F --> F4[mempool_sub_workers]
F --> F5[block_addresses_to_keep]
A --> G[Miscellaneous]
G --> G1[parse]
G --> G2[message_queue_binding]
G --> G3[subversion]
G --> G4[address_format]
Summary
The `config.json` file is a critical configuration component that governs how the blockchain node or service interacts with external services, manages mempool transactions, connects to blockchain nodes, and handles fiat currency conversions. Its flexible and extensible design enables easy customization of runtime parameters without code changes, supporting scalability and maintainability in a modular blockchain architecture.