From 12e1bd0451429336240fa71c966cfb9caaa12cad Mon Sep 17 00:00:00 2001 From: quake Date: Sat, 20 Jan 2024 16:23:45 +0800 Subject: [PATCH] chore: add how to test miner on dev chain doc --- README.md | 1 + docs/dev-miner.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 docs/dev-miner.md diff --git a/README.md b/README.md index 033fe465cd..47cc6af360 100644 --- a/README.md +++ b/README.md @@ -70,5 +70,6 @@ Mainnet Mirana or Testnet Pudge, switch to the branch [master]. - [Platform Support](docs/platform-support.md) - [How to Download or Build CKB Binary](https://docs.nervos.org/docs/basics/guides/get-ckb) - [How to Download or Build CKB Binary on Windows](https://docs.nervos.org/docs/basics/guides/ckb-on-windows) +- [How to test miner on dev chain](docs/dev-miner.md) You can find a more comprehensive document website at [https://docs.nervos.org](https://docs.nervos.org). diff --git a/docs/dev-miner.md b/docs/dev-miner.md new file mode 100644 index 0000000000..1d51e49fa1 --- /dev/null +++ b/docs/dev-miner.md @@ -0,0 +1,66 @@ +# How to test miner on dev chain + +`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. + +## Initialize a dev chain + +First, you need to prepare one public/private keypair, then initialize a dev chain by passing the public key hash to `--ba-arg` option: + +```shell +mkdir ckb-dev-miner-test +cd ckb-dev-miner-test +ckb init --chain dev --ba-arg 0x470dcdc5e44064909650113a274b3b36aecb6dc7 +``` + +## Modify the config file + +Then you need to modify the config file `specs/dev.toml`, change the option `func` under the section `[pow]` from `Dummy` to `Eaglesong`: + +```diff +- func = "Dummy" ++ func = "Eaglesong" +``` + +## Start the ckb node + +Start the ckb node: + +```shell +ckb run +``` + +You will see the node is listening on the default rpc port `8114` by checking the log output: + +``` +main INFO ckb_rpc::server Listen HTTP RPCServer on address: 127.0.0.1:8114 +``` + +## Verify the setup + +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`: + +```diff +- worker_type = "Dummy" +- delay_type = "Constant" +- value = 9500 ++ worker_type = "EaglesongSimple" ++ threads = 1 +``` + +then start the miner (please note that you need to start the miner in another terminal): + +```shell +ckb miner +``` + +if you see the following similar output, it means the setup is correct: + +``` +Found! #38 0xb7c7a93578e72316ad35db9131822e9dc52745ad511673b521150cf10ccb2280 +Found! #39 0x0c78d91f877764e90e88f11dede4b6e70933bb70d87ef3b14fb42291833ddb86 +Found! #40 0xc37b8c375f9ec4b671dc8a553791630d2ffc7a0a4a3fe7d6195121754b08c458 +Found! #41 0x43768c4a1a8b723f6b4a23426fda14c044ecc501d56bc2f18fef50829d8e132b +... +``` + +Now you can stop the miner process and start your own miner or mining pool to test your features.