- 点击右上角的
Download ZIP
下载该Gist中的相关配置文件。 - 下载 beam节点源代码 的Beam源代码。
如果要使用git获取源代码,请检出
cold_wallet
这个tag。注意某些分支或tag可能由于equihash
参数不同,导致GPU Miner
无法挖矿。 参考命令:
git clone https://github.com/BeamMW/beam.git
cd beam
git checkout cold_wallet
- 打开源代码中的
core/block_crypt.cpp
,找到Rules::Rules()
函数,把840
行的
TreasuryChecksum = {
0x5d, 0x9b, 0x18, 0x78, 0x9c, 0x02, 0x1a, 0x1e,
0xfb, 0x83, 0xd9, 0x06, 0xf4, 0xac, 0x7d, 0xce,
0x99, 0x7d, 0x4a, 0xc5, 0xd4, 0x71, 0xd7, 0xb4,
0x6f, 0x99, 0x77, 0x6e, 0x7a, 0xbd, 0x2e, 0xc9
};
Prehistoric = {
// BTC Block #556833
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x25, 0x2d, 0x12, 0x33, 0xb4, 0x5d, 0xb2,
0x39, 0x81, 0x47, 0x67, 0x6e, 0x16, 0x62, 0xf4,
0x3c, 0x26, 0xa5, 0x26, 0xd2, 0xe2, 0x20, 0x63,
};
修改为
TreasuryChecksum = Zero;
Prehistoric = Zero;
因为使用的是MainNet的分支,初始挖矿难度较高,需要打开core/block_crypt.h
,然后把107
行的
Difficulty Difficulty0 = Difficulty(22 << Difficulty::s_MantissaBits); // 2^22 = 4,194,304. For GPUs producing 7 sol/sec this is roughly equivalent to 10K GPUs.
修改为
Difficulty Difficulty0 = Difficulty(3 << Difficulty::s_MantissaBits); // 2^3 = 8. For GPUs producing 7 sol/sec this is roughly equivalent to 1 GPU.
- 编译该项目(构建说明),参考的构建参数(Ubuntu 18.04):
# 创建构建文件夹
mkdir build && cd build
# 创建makefile
cmake -DBEAM_NO_QT_UI_WALLET=ON ..
# 构建
make -j
- 进入构建目录(
build/
)中的beam
子目录,你可以看到构建好的beam-node
就在这里。把在第一步中下载的ZIP里的配置文件beam-node.cfg
,stratum.api.keys
,stratum.crt
和stratum.key
都放在该目录,然后使用以下命令启动节点:
./beam-node
- 可以用
GPU Miner
连接节点进行挖矿了。 (GPU Miner 下载地址,其中的*-opencl-miner.*
就是)。 参考参数:
beamMiner --server 127.0.0.1:3333 --key 12345678
- 即使不连接
GPU Miner
,节点也会从区块1开始通过CPU进行挖矿,不过速度可能较慢。你可以修改配置文件中的mining_threads
来启用更多挖矿线程。 正常运行的节点日志参考:
I 2018-12-31.21:35:59.208 Rules signature: a865248b891a3b22
I 2018-12-31.21:35:59.343 starting a node on 8200 port...
I 2018-12-31.21:35:59.405 Node ID=20b95c72db61b27c
I 2018-12-31.21:35:59.405 Initial Tip: 0-0000000000000000
I 2018-12-31.21:35:59.406 Sync mode
I 2018-12-31.21:35:59.406 Searching for the best peer...
I 2018-12-31.21:35:59.427 stratum server listens to 0.0.0.0:3333
I 2018-12-31.21:35:59.428 GenerateNewBlock: size of block = 294; amount of tx = 0
I 2018-12-31.21:35:59.428 Block generated: Height=1, Fee=0, Difficulty=02-000000(4), Size=294
I 2018-12-31.21:35:59.428 New job for external miner
I 2018-12-31.21:35:59.428 stratum server new job 1 will be sent to 0 connected peers
I 2018-12-31.21:35:59.428 Mining nonce = a834d1bed1dc5df6
D 2018-12-31.21:36:33.120 stratum server +peer 127.0.0.1:3492
V 2018-12-31.21:36:33.125 got {"method":"login", "api_key":"12345678", "id":"login","jsonrpc":"2.0"}
V 2018-12-31.21:36:33.720 got {"method" : "solution", "id": "1", "nonce": "e207f872d58f120b", "output": "1dc4ae5dd850fa32ef3316042735113cdb25be2b2a046b2acaa237e1076b66fee6204d2339a3ae742d4f3d4efb6a473eeb58e85620a5befb4d93854d8bf6074a464670ffac6fbab57c73ff09280f4bdf592129f5b74ed85224a19b6908daae110e878a34ff2cfb2b", "jsonrpc":"2.0" }
D 2018-12-31.21:36:33.721 sol.nonce=e207f872d58f120b sol.output=1dc4ae5dd850fa32ef3316042735113cdb25be2b2a046b2acaa237e1076b66fee6204d2339a3ae742d4f3d4efb6a473eeb58e85620a5befb4d93854d8bf6074a464670ffac6fbab57c73ff09280f4bdf592129f5b74ed85224a19b6908daae110e878a34ff2cfb2b
I 2018-12-31.21:36:33.721 stratum server solution to 1 from 127.0.0.1:3492
I 2018-12-31.21:36:33.722 New block mined: 1-e6820193db6b0da2
I 2018-12-31.21:36:33.722 1-e6820193db6b0da2 Header accepted
I 2018-12-31.21:36:33.723 1-e6820193db6b0da2 Block received
I 2018-12-31.21:36:33.724 1-e6820193db6b0da2 Block interpreted. Fwd=1
I 2018-12-31.21:36:33.724 My Tip: 1-e6820193db6b0da2, Work = 4
I 2018-12-31.21:36:33.760 GenerateNewBlock: size of block = 294; amount of tx = 0
I 2018-12-31.21:36:33.760 Block generated: Height=2, Fee=0, Difficulty=02-000000(4), Size=294
I 2018-12-31.21:36:33.760 New job for external miner
I 2018-12-31.21:36:33.760 stratum server new job 2 will be sent to 1 connected peers
- 挖矿的初始难度为4,后续难度会随着算力的增减而调整。
可以使用openssl
命令:
openssl s_client -connect localhost:3333
然后就可以像telnet那样使用了。 例如:
openssl s_client -connect localhost:3333
{"method":"login","api_key":"12345678","id":"login","jsonrpc":"2.0"}
{"difficulty":104080254,"id":"1","input":"736705edb35b6c6e9bfafc4349adf236ac479d271b222927dd9428d8c4af3925","jsonrpc":"2.0","method":"job"}
例如:
I 2018-12-31.21:38:51.481 Rules signature: c322cb3e12d24375
I 2018-12-31.21:38:51.602 starting a node on 8200 port...
I 2018-12-31.21:38:51.603 Node stopping...
I 2018-12-31.21:38:51.603 Node stopped
E 2018-12-31.21:38:51.603 Data configuration is incompatible: a865248b891a3b22. Current configuration: c322cb3e12d24375
区块链数据库(node.db
)与节点所在的区块链参数不兼容。
因为我们修改了区块链参数TreasuryChecksum
,如果你在修改前启动过节点,产生了数据文件,就会出现该问题。
删除节点目录下的node.db
文件。
例如:
V 2018-12-31.21:41:03.797 got {"method" : "solution", "id": "2", "nonce": "efb5a163191948f9", "output": "070f980e090eb8c21dbbf4578c8251fde326e9d89ab14f92981f358a61797ea669ec8bcec151f64ccdbafd21e4a9b837af4dfce52ce2b294d46c7ad6b2632a8b705198573c5adbeb7f037753d19c3047906a5efe749dcf954b597f5f76bcd929c65a0cb75abf06a2", "jsonrpc":"2.0" }
D 2018-12-31.21:41:03.797 sol.nonce=efb5a163191948f9 sol.output=070f980e090eb8c21dbbf4578c8251fde326e9d89ab14f92981f358a61797ea669ec8bcec151f64ccdbafd21e4a9b837af4dfce52ce2b294d46c7ad6b2632a8b705198573c5adbeb7f037753d19c3047906a5efe749dcf954b597f5f76bcd929c65a0cb75abf06a2
I 2018-12-31.21:41:03.798 stratum server solution to 2 from 127.0.0.1:3573
I 2018-12-31.21:41:03.798 invalid solution from external miner
testnet4_release (8bf66967e6af7f33d97479bfa3a7ffdbc9d9e046) 这个Release修改了equihash
参数,改为了N = 150, K = 5
。其他分支(比如master
)可能不是这个参数,导致与GPU Miner
的挖矿结果对不上。
下载 testnet4_release 的Beam源代码。
如果你通过git获得源代码,请 git checkout testnet4_release
官方的GPU Miner
似乎不支持localhost
这个域名,需要改成具体的IP地址。
使用--server 127.0.0.1:端口
代替--server localhost:端口
。
为了方便使用,配置文件中内置了挖矿奖励所用的私钥(key_mine
)和对应的密码pass
。
这意味着,任何看过该Gist
的人都有能力转走该私钥在公有区块链中的数字资产。
不过,由于我们要创建的是一个私有测试网络,里面的币没有任何价值,并且其他人也不能访问我们的节点,所以没有安全性担忧。
但是,我们在任何情况下都不应该把该配置文件中的公钥、私钥及密码(key_mine
,key_owner
,pass
)用于生产环境或Beam
主链。
本Gist及其作者不为任何丢币损失负责。