Conflux is a fully decentralized network based on PoW (Proof of Work). If you want to participate in this decentralized network mining, or have your own RPC service, you need to run a node (also known as client) by yourself. This article will introduce how to run a Conflux node.

Archivenode VS fullnode

Conflux's nodes are divided into three types: archive node (archivenode), full node (fullnode), light node (lightnode). The difference between different types of nodes lies in the amount of data retained and stored, the archive node is the most complete, and the light node is the least. Of course, the more data stored, the more system hardware resources are consumed. For a detailed introduction to different types of nodes see here

Normally, if you want to participate in mining, you can run a full node. If you want to use it as an RPC service, you need to run an Archivenode. Light nodes are mainly used as wallets.

Machine configuration

The machine resources for running an archivenode are roughly as follows:

  • CPU:4Core
  • Memory: 16G
  • Hard Disk: 200G

Fullnode has lower requirements for machine configuration. If you want to participate in mining and block production, you need a separate graphics card.

In addition: It is recommended to increase the maximum number of open files of the system to 10000 . Generally, the Linux system defaults to 1024, which is not enough.

How to get the node program and configuration

The first way to obtain the Conflux network node program is to download it from the Release Conflux-rust warehouse. Generally, you can directly download the latest Release version. Each Release version not only contains source code, but also provides pre-compiled node programs for Windows, Mac, and Linux platforms.

image.png

needs to pay attention to that currently has two versions of the main network and test network node programs: the main network is generally Conflux-vx.x.x , and the test network is Conflux-vx.x.x-testnet . When downloading the program, you need to choose the correct version line according to your needs.

The downloaded zip package, after decompression, is a run folder, which contains the following contents:

➜  run tree
.
├── conflux  # 节点程序
├── log.yaml # 日志配置文件
├── start.bat # windows 启动脚本
├── start.sh # unix 启动脚本
├── tethys.toml # 主网配置文件
└── throttling.toml # 限流配置文件

0 directories, 6 files

The main files are conflux and tethys.toml . If the download is a windows package, the node program is conflux.exe

Another way is to compile from source node, if you are interested, you can refer to this document compile it yourself.

Main configuration items

Before running the node, you need to prepare the node configuration file. The configuration file can be found in the downloaded program package. Generally, the main network is tethys.toml and the test network is testnet.toml . The main difference between the two configuration files is that the configuration values of bootnodes and chainId Developers can also find configuration files under run directory conflux-rust Github repository. The file name is also tethys.toml or testnet.toml .

Normally, the user does not need to modify any configuration, just run the startup script directly to (don’t want to know the configuration details? Just skip to the next chapter to run the node). But if you want to open certain functions or customize certain behaviors of the node, you need to set some configuration parameters yourself. The following are some of the most commonly used configurations:

Node type

  • node_type : used to set the type of startup node, optional values are full (default value), archive , light

chainId

  • chainId is used to configure the ID of the chain to be connected to the node, the main network is 1029, and the test network is 1 (generally no need to modify)

Miner related

  • mining_address : Node mining reward receiving address, you can configure hex40 address or CIP-37 address (note: the network prefix of the address needs to be consistent with the currently configured chainId), if this minint_type default to stratum
  • mining_type : Optional values are stratum , cpu , disable
  • stratum_listen_address : stratum address
  • stratum_port : stratum port number
  • stratum_secret : stratum connection certificate

RPC related

  • jsonrpc_cors : used to control the rpc domain name verification strategy, optional values are none , all , or comma (no spaces) separated domain names
  • jsonrpc_http_keep_alive : false or true used to control whether to set KeepAlive for rpc HTTP connections
  • jsonrpc_ws_port : websocket rpc port number
  • jsonrpc_http_port : http rpc port number
  • public_rpc_apis : rpc api open to the outside world, optional values are all , safe , cfx , debug , pubsub , test , trace , 061d274ce0d85f (sub)safece0d85f (sub). Generally recommended to set to safe
  • persist_tx_index : true or false If you need to process transaction-related RPCs, you need to open this configuration at the same time, otherwise you will only be able to access the most recent transaction information
  • persist_block_number_index : true or false If you want to query block information by blockNumber, you need to open this configuration
  • executive_trace : true or false whether to open the trace EVM execution function, if open the trace will be recorded in the database
  • get_logs_filter_max_epoch_range : Event log acquisition method cfx_getLogs called, which has a great impact on node performance. This option can be used to configure the maximum epoch range that this method can query at a time
  • get_logs_filter_max_limit : cfx_getLogs method can return the maximum number of logs in one query

Snapshot

  • additional_maintained_snapshot_count : Used to set the number of snapshots that need to be retained before stable checkpoint, the default is 0, and snapshots before stable genesis will be deleted. If the user wants to query the relatively long history status, this option needs to be set. After this option starts, the disk usage will also increase a lot.

directries

  • conflux_data_dir : Data storage directory (block data, state data, node database)
  • block_db_dir : The block data storage directory, by default it will be stored in the blockchain_db directory under the conflux_data_dir specified directory
  • netconf_dir : Used to control network-related persistent directories, including net_key

Log related

  • log_conf : Used to specify log detailed configuration files such as log.yaml , the settings in the configuration file will override the log_level settings
  • log_file : Specify the log path, if not set, it will be output to stdout
  • log_level : log printing level, optional values are error , warn , info , debug , trace , off

The higher the log level of the log, the more logs will be printed, and the response will take up the storage space of Gondo, which will also affect the performance of the node.

Developer (dev) mode

Conflux-rust also provides a developer (dev) mode, in which a single-node chain is started, and all RPC methods are turned on by default. This model node is very suitable for smart contract developers to quickly deploy and debug contracts.
The configuration method is as follows:

  • bootnodes : Comment out this configuration
  • mode : Configure the mode option to dev
  • dev_block_interval_ms : Block generation interval time, in milliseconds (ms)

Configure genesis account

In dev mode, you can genesis_secrets.txt file. The file needs to place a private key (without the 0x prefix) in one line, and add the genesis_secrets configuration item to the configuration file, and configure the value to the path of the file :

genesis_secrets = './genesis_secrets.txt'

After the node is started, each account will initially have 10000,000,000,000,000,000,000 Drip, which is 1w CFX.

other

  • net_key : It is a 256-bit private key used to generate a unique node id. If this option is not adjusted, it will be randomly generated. If set, you can fill in a 64-bit hex string
  • tx_pool_size : The maximum number of transactions allowed to be stored in the transaction ( defaults to 50W)
  • tx_pool_min_tx_gas_price : The minimum limit of the transaction pool for transaction gasPrice ( is 1 by default)

Regarding the complete configuration items, you can directly view the configuration file, which contains all the configurable items, as well as detailed explanations.

Run node

After the configuration file is configured, you can run the node through the node program.

# 运行启动脚本
$ ./start.sh

If you see the following in the stdout or log file, it means that the node has been successfully started:

2021-04-14T11:54:23.518634+08:00 INFO  main                 network::thr - throttling.initialize: min = 10M, max = 64M, cap = 256M
2021-04-14T11:54:23.519229+08:00 INFO  main                 conflux      -
:'######:::'#######::'##::: ##:'########:'##:::::::'##::::'##:'##::::'##:
'##... ##:'##.... ##: ###:: ##: ##.....:: ##::::::: ##:::: ##:. ##::'##::
 ##:::..:: ##:::: ##: ####: ##: ##::::::: ##::::::: ##:::: ##::. ##'##:::
 ##::::::: ##:::: ##: ## ## ##: ######::: ##::::::: ##:::: ##:::. ###::::
 ##::::::: ##:::: ##: ##. ####: ##...:::: ##::::::: ##:::: ##::: ## ##:::
 ##::: ##: ##:::: ##: ##:. ###: ##::::::: ##::::::: ##:::: ##:: ##:. ##::
. ######::. #######:: ##::. ##: ##::::::: ########:. #######:: ##:::. ##:
:......::::.......:::..::::..::..::::::::........:::.......:::..:::::..::
Current Version: 1.1.3-testnet

2021-04-14T11:54:23.519271+08:00 INFO  main                 conflux      - Starting full client...

After the node is started, two folders blockchain_data and log will be created in the run directory to store node data and logs.

After starting a brand new mainnet or testnet node, it will synchronize historical block data from the network. The catching node is in catch up mode, and the status of the node and the latest epoch number can be seen from the log:

2021-04-16T14:49:11.896942+08:00 INFO  IO Worker #1         cfxcore::syn - Catch-up mode: true, latest epoch: 102120 missing_bodies: 0
2021-04-16T14:49:12.909607+08:00 INFO  IO Worker #3         cfxcore::syn - Catch-up mode: true, latest epoch: 102120 missing_bodies: 0
2021-04-16T14:49:13.922918+08:00 INFO  IO Worker #1         cfxcore::syn - Catch-up mode: true, latest epoch: 102120 missing_bodies: 0
2021-04-16T14:49:14.828910+08:00 INFO  IO Worker #1         cfxcore::syn - Catch-up mode: true, latest epoch: 102180 missing_bodies: 0

You can also cfx_getStatus obtain the latest epochNumber current node approach and comparison with the latest epoch scan to determine whether the data has been synchronized to the latest.

RPC service

After the node is started, and the RPC-related port number and configuration are opened, the wallet and Dapp can access the node through the RPC url. For example

http://node-ip:12537

You can use this address when adding a network to the Portal wallet or SDK instance.

Run node with Docker

Friends who are more familiar with Docker can also use Docker to run a node. The official provides various versions of Docker image can pull the image and run it by itself.

Because the node data is relatively large, it is recommended to mount a data directory to store node data when running image.

There are currently three pipelines for the released mirror tags:

  • x.x.x-mainnet : Mainnet mirror
  • x.x.x-testnet : Testnet mirror
  • x.x.x : Development mode mirroring, ten accounts will be automatically initialized in this mode, which can be used for local rapid development

common problem

Why does the synchronization take a long time after restarting?

After the node restarts, it will start to synchronize from the last checkpoint and replay the block data. According to the current distance from the last checkpoint, you need to wait for a different length of time to start synchronization from the latest block.
This is normal, and it usually takes a few minutes to ten minutes.

Why is the block synchronized by the node highly stuck and no longer grows?

If it is found that the block synchronization is stuck, no more growth. You can check the log or terminal to see if there is an error. If there is no error, it is probably due to network reasons. You can try to restart the node.

After modifying the configuration, do I need to clear the data to restart the node?

According to the situation, some need it, some don't need it. If the modified configuration involves data storage or data indexing, you need to clear the data and restart the node, such as:

  • persist_tx_index
  • executive_trace
  • persist_block_number_index

You do not need to clear the data to modify other configurations, just restart it.

How big is the current archive node data?

As of 2021.11.04, the compressed package size of block data is less than 90 G

How to participate in mining?

GPU participation is required for mining, please refer to here

How to quickly synchronize data to run an archive node

You can use fullnode-node download the data snapshot of the archive node. Using the snapshot node data, you can quickly synchronize to the latest data.

How to look at the error log of node operation?

If it is start.sh , you can view the cause of the error stderr.txt in the same directory.

How to run a PoS node?

TO BE UPDATE

refer to

Original link: How to run a Conflux node

related database:


Conflux中文社区
66 声望18 粉丝

Conflux网址:[链接]