Client Configuration Guide

Dhive Node and Client Configuration Guide

This document provides a comprehensive guide for configuring a Dhive node and client. A node is responsible for running the blockchain network, producing blocks, and validating transactions. The client serves as a gateway for interacting with the blockchain by submitting transactions and querying the network state. Additionally, we will cover the setup of the JSON-RPC server.

Proper configuration of these components is crucial as it directly impacts the performance, security, and functionality of the node. Therefore, understanding and correctly setting up your Dhive node and client is essential.

Configuration and Data Directory

By default, configuration files and data are stored in the ~/.dhived directory. You can modify this default location using the --home flag. Multiple home directories can be created to represent different blockchain instances.

.                                   # ~/.dhived
  ├── data/                           # Stores databases used by the node.
  └── config/
      ├── app.toml                   # Application-related configuration file.
      ├── config.toml                # Tendermint-related configuration file.
      ├── genesis.json               # The genesis block configuration.
      ├── node_key.json              # Private key for node authentication in the P2P protocol.
      └── priv_validator_key.json    # Private key used for validation in the consensus protocol.

To specify a custom Dhive configuration and data storage directory, use the following global flag:

dhived --home <directory>

Node Configuration

The Cosmos SDK generates two primary configuration files in ~/.dhived/config/:

  • config.toml: Configures Tendermint. Refer to the official Tendermint documentation for details.

  • app.toml: Generated by the Cosmos SDK, this file is used to configure various aspects such as state pruning strategies, telemetry, gRPC, REST servers, state synchronization, and JSON-RPC settings.

These files contain extensive comments for reference. One key configuration to consider is the minimum-gas-prices field in app.toml, which defines the minimum gas fee that the validator node accepts for transaction processing. This acts as an anti-spam mechanism.

If left empty, the node will halt on startup. Ensure the field has a value, such as:

# Minimum gas price required for processing transactions.
minimum-gas-prices = "0adhive"

State Pruning

There are four available pruning strategies, applicable only to state data (not block storage). The pruning setting is configured in ~/.dhived/config/app.toml:

  • everything: Removes all saved states except the current state.

  • nothing: Retains all states indefinitely.

  • default: Retains the last 100 states and the state of every 10,000th block.

  • custom: Allows manual configuration using pruning-keep-recent, pruning-keep-every, and pruning-interval parameters.

By default, nodes operate in default mode, which is recommended for most environments. To change the pruning strategy during initialization, use:

dhived start --pruning everything

Warning: When pruning is enabled, querying historical block heights outside the retained range will not be possible.

Client Configuration

To view the default client settings, use the following command:

dhived config

Example output:

{
 "chain-id": "",
 "keyring-backend": "os",
 "output": "text",
 "node": "tcp://localhost:26657",
 "broadcast-mode": "sync"
}

Configuration settings can be modified using:

dhived config "chain-id" dhive_9000-4

Example modified output:

{
 "chain-id": "dhive_9000-4",
 "keyring-backend": "os",
 "output": "text",
 "node": "tcp://localhost:26657",
 "broadcast-mode": "sync"
}

Alternatively, configurations can be directly modified in client.toml located in ~/.dhived/config/client.toml.

Running the JSON-RPC Server

The JSON-RPC server allows external applications to interact with the Dhive blockchain. It supports multiple transport layers, including HTTP and WebSocket. A server with a minimum 8-core CPU and 64GB of RAM is recommended. Ensure ports 8545 and 8546 are open in your firewall.

Enabling the JSON-RPC Server

To enable the server, use:

dhived start --json-rpc.enable

Defining Namespaces

By default, eth, net, and web3 namespaces are enabled. Additional namespaces can be added in app.toml:

# JSON-RPC namespaces to enable
api = "eth,net,web3,txpool,debug,personal"

Setting a Gas Cap

The eth_call and eth_estimateGas methods impose a global gas cap to prevent DoS attacks. The default value (25,000,000) can be modified in app.toml:

gas-cap = 25000000

Enabling CORS

For browser access, Cross-Origin Resource Sharing (CORS) must be enabled in app.toml:

enabled-unsafe-cors = true

Pruning Considerations for JSON-RPC

To enable all JSON-RPC methods, the node must maintain a full copy of the blockchain. Disable pruning in app.toml:

pruning = "nothing"
pruning-keep-recent = "0"
pruning-keep-every = "0"
pruning-interval = "0"

WebSocket Server Configuration

WebSockets provide bidirectional communication between the client and server. They are efficient for handling a high volume of requests and event subscriptions. The WebSocket server can be enabled in app.toml:

ws-address = "0.0.0.0:8546"

By following these configuration steps, you can ensure that your Dhive node and client are properly set up for optimal performance, security, and functionality.

Last updated

Was this helpful?