Skip to content

Commit d9280e3

Browse files
authored
Merge pull request #4313 from quake/quake/dev-chain-miner-doc
chore: add how to test miner on dev chain doc
2 parents cd4bae1 + 12e1bd0 commit d9280e3

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ Mainnet Mirana or Testnet Pudge, switch to the branch [master].
7070
- [Platform Support](docs/platform-support.md)
7171
- [How to Download or Build CKB Binary](https://docs.nervos.org/docs/basics/guides/get-ckb)
7272
- [How to Download or Build CKB Binary on Windows](https://docs.nervos.org/docs/basics/guides/ckb-on-windows)
73+
- [How to test miner on dev chain](docs/dev-miner.md)
7374

7475
You can find a more comprehensive document website at [https://docs.nervos.org](https://docs.nervos.org).

docs/dev-miner.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# How to test miner on dev chain
2+
3+
`dev` chain is a local chain for development, its pow algorithm is `Dummy`, which is not a real pow algorithm, it just mines a block in a fixed or random time interval. If you want to test your miner or mining pool related features, you may change the pow algorithm to `Eaglesong` and use dev chain to test. The following steps will show you how to do it.
4+
5+
## Initialize a dev chain
6+
7+
First, you need to prepare one public/private keypair, then initialize a dev chain by passing the public key hash to `--ba-arg` option:
8+
9+
```shell
10+
mkdir ckb-dev-miner-test
11+
cd ckb-dev-miner-test
12+
ckb init --chain dev --ba-arg 0x470dcdc5e44064909650113a274b3b36aecb6dc7
13+
```
14+
15+
## Modify the config file
16+
17+
Then you need to modify the config file `specs/dev.toml`, change the option `func` under the section `[pow]` from `Dummy` to `Eaglesong`:
18+
19+
```diff
20+
- func = "Dummy"
21+
+ func = "Eaglesong"
22+
```
23+
24+
## Start the ckb node
25+
26+
Start the ckb node:
27+
28+
```shell
29+
ckb run
30+
```
31+
32+
You will see the node is listening on the default rpc port `8114` by checking the log output:
33+
34+
```
35+
main INFO ckb_rpc::server Listen HTTP RPCServer on address: 127.0.0.1:8114
36+
```
37+
38+
## Verify the setup
39+
40+
ckb provides a built-in miner which can be used to verify the setup, you need to modify the section `[[miner.workers]]` of config file `ckb-miner.toml`:
41+
42+
```diff
43+
- worker_type = "Dummy"
44+
- delay_type = "Constant"
45+
- value = 9500
46+
+ worker_type = "EaglesongSimple"
47+
+ threads = 1
48+
```
49+
50+
then start the miner (please note that you need to start the miner in another terminal):
51+
52+
```shell
53+
ckb miner
54+
```
55+
56+
if you see the following similar output, it means the setup is correct:
57+
58+
```
59+
Found! #38 0xb7c7a93578e72316ad35db9131822e9dc52745ad511673b521150cf10ccb2280
60+
Found! #39 0x0c78d91f877764e90e88f11dede4b6e70933bb70d87ef3b14fb42291833ddb86
61+
Found! #40 0xc37b8c375f9ec4b671dc8a553791630d2ffc7a0a4a3fe7d6195121754b08c458
62+
Found! #41 0x43768c4a1a8b723f6b4a23426fda14c044ecc501d56bc2f18fef50829d8e132b
63+
...
64+
```
65+
66+
Now you can stop the miner process and start your own miner or mining pool to test your features.

0 commit comments

Comments
 (0)