Run A Full Node
Last updated
Last updated
Run the following command to connect to the KCC mainnet:
"geth" is the client binary you have built or installed in the previous section. If it is not in one of your $PATH, you should use an absolute path (i.e., /path/to/geth
) Instead.
All the chain data is in the directory following the option --datadir
. So you should ensure the disk mounted to this directory has enough free space.
And if you want to connect to the KCC testnet, you can use the following command instead:
In the following sections, we will only talk about the mainnet. However, all the following commands will work on testnet, except that you should add an extra --testnet
option.
If you want to access your node through the Ethereum JSON-RPC, you can use the following command to enable the HTTP and WebSocket RPC servers:
--http
enables an HTTP-RPC server that listens onlocalhost:8545
--ws
enables a Websocket-RPC server that listens onlocalhost:8546
With the commands above, you can only access your RPC servers from the same machine that runs your node. If you want to make your RPC servers publicly accessible, you need to specify the listening addresses of your RPC servers:
Use --http.addr
to specify the listening address of your HTTP-RPC server and use --ws.addr
for the listening address of your Websocket-RPC server.
Your node could be vulnerable if you make your RPC servers publicly accessible.
The state is a snapshot of all accounts on KCC, which includes the balance and nonce of each account, the code of each contract, and the storage of each smart contract. If you want to query the historical state at some block, you can replay all the transactions starting from the genesis block to reconstruct the state at that block. However, if you want to save all states on your disk, that would take a lot of disk space. Therefore, although a full node saves all the historical blocks and receipts, it does not hold all the historical states.
Nevertheless, in some scenarios, you want to save all the historical states on your disk. For example, you are building some analyzing system that frequently queries the historical states, and you don't want to waste time reconstructing the historical states. You can run an archive node as follows:
"--syncmode full
" tells the node to replay transactions in each block by itself, and "--gcmode archive
" asks the node to record all the intermediate states when replaying those transactions.
We highly recommend managing your node with a process manager. A process manager watches your node client process, collects and rotates the logs, and restarts your node if needed. Here is a list of some popular process managers:
The entry point of our docker image is geth
, so it is quite straightforward to run your node in a docker container:
Use --name
to specify the name of your running container
Use -d
to make your container run in the background
Use -v
to map a host path into the container
The trailing "--datadir /data/.kcc" are arguments passed to the `geth` process in the container.