Mining
Mining via Official Kadena Software
We recommend chainweb-miner
, our dedicated Mining Client. Work requests are sent to known Nodes, which construct blocks for the client. Once solved, the client returns the block to the Node for submission to the wider network.
You will need a Key Pair before beginning.
Obtaining a Key Pair
The easiest way to obtain a Key Pair is via the chainweb-miner keys
command. Once generated, please be very careful to save the public and secret (private) keys because you don’t want to lose them.
The first time you mine a block with your key pair an account is created for you. You can use any account name that doesn’t yet exist. It is recommended to use public key of your key pair as account name.
Installation
A docker image of the latest version is available at ghcr.io/kadena-io/chainweb-mining-client:latest
.
Binaries can also be compiled with a recent version of GHC and cabal directly from Hackage
or from the GitHub sources
Usage
Calling chainweb-mining-client --help
provides an overview of the available usage options:
Usage Examples
Generating a New Key Pair
This outputs a public and a private key. The public key is given to the mining client. The private key must be kept secret.
Mining on Mainnet With an ASIC
chainweb-mining-client needs access to the mining API of a full Chainweb node in the Kadena Mainnet. The node must be configured to enable the mining API with the Pact public key (and, optionally, account name) of the miner. Rewards for mined blocks will be credited to that account. The default is to use the k:
account for the key.
The --enable-mining-coordination
, --mining-public-key
can be used to configure chainweb-node for mining. The mining API is served on the service API port (default is 1848).
Assuming that example.com
serves the chainweb-node mining API on port 1848, the following command can be used to run chainweb-mining-client with the stratum server on port 1917:
Assuming that the host on which chainweb-mining-client runs is 192.168.1.2, the pool address that is used to configure the ASIC miner is stratum+tcp://192.168.1.2:1917
.
One can point more than a single ASIC miner to the same chainweb-mining-client stratum server. All connected clients work together and all mining rewards are credited to the same account, that is configured in chainweb node.
By default the stratum server sets the difficulty of the work that is sent to the mining clients to the actual difficulty of the block of the most recent work. This means that it can take a long time before the client solves any work. It also means that the target is reset for each new block.
It is also possible to set a custom difficulty. As a consequence not all accepted solutions qualify as solved blocks, but ASIC miner may provide a more continuous feedback on its current performance. Some devices may also be more efficient in this mode an yield higher returns.
The thread count determines how many independent stratum works are used to concurrently provide work to the clients. Each stratum worker receives one work header at a time from the chainweb-node mining API and emits jobs for that work to all clients at a configurable rate. The effective rate of jobs is higher than then configured rate because when upstream work gets preempted. Each client receives are all jobs from all workers.
The following command runs two stratum workers that serve jobs at least every 500 milliseconds at a fixed difficulty level of 50.
The solution space for each mining job is about 280 terra hashes. The --stratum-rate
should be chosen such that the mining devices does not perform more than that number of hashes within the provided time range. For instance, for an miner that performs 140TH/s the --stratum-rate
should be at least 2000 (2 seconds).
The --stratum-difficulty
parameter expects a integral number between 0 and 256. It denotes the difficulty as a logarithm of base 2. In practice the actual target uses a difficulty level of at least 42 and at most the difficulty of block of the current work.
It may help to experiment a little with the --stratum-difficulty
, --stratum-rate
, and the --thread-count
parameters. We found, that small values for --thread-count
(one to three) and moderate values for --stratum-difficulty
(in the upper forties / lower fifties) yielded good results. The But that may differ between different devices and setups.
If the chainweb-node mining API is served via a reverse proxy with TLS the --tls
flag must be used to enable HTTPS.
CPU Mining
Assuming that example.com
serves the chainweb-node mining API on port 1848, the following command can be used for CPU mining to the from the previous example:
GPU Mining
GPU mining is supported via calling an external worker that does the mining work. An example for such a GPU mining tool for Kadena is bigolchunugus.
For selecting the GPU or passing additional arguments to the external tools, the extra parameters are appended to the command. E.g.
The external mining tool is called by adding the target as the last command line parameter and passing the work bytes on stdin.
Creating a Configuration File
The current configuration of chainweb-mining-client can be stored in a configuration file by adding the --print-config
parameter
This results in the following configuration file:
The configuration can then be used via
Last updated