forked from rsksmart/ckpool
-
Notifications
You must be signed in to change notification settings - Fork 4
/
README_Rootstock.txt
295 lines (205 loc) · 6.91 KB
/
README_Rootstock.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
Building ckpool
===============
ckpool should be build on linux (or a cross compiler)
0) Install tools and dependencies
> apt-get install build-essential autoconf automake libtool git
1) Checkout source
> git clone https://github.com/rootstock/ckpool.git
2) Generate configure files
> ./autogen.sh
3) Generate Makefile. It is easier to setup without ckdb. ckdb is a backend that uses postgresql to store miners information.
> ./configure --without-ckdb
4) Compilar
> make
The compiled binaries will be in ./src
Testing
=======
Bitcoind
--------
1) Create a directories for bitcoind, and two diretories one for each instance
> mkdir btcd
> cd btcd
> mkdir A
> mkdir B
2) Now we launch bitcoind in regtest mode
> bitcoind -server -listen -port=31591 -rpcuser=admin -rpcpassword=admin -rpcport=32591 -datadir=./A -connect=localhost:31592 -regtest -daemon -debug
> bitcoind -server -listen -port=31592 -rpcuser=admin -rpcpassword=admin -rpcport=32592 -datadir=./B -connect=localhost:31591 -regtest -daemon -debug
3) We now can verify that it is running
> bitcoin-cli -regtest -rpcconnect=127.0.0.1 -rpcuser=admin -rpcpassword=admin -rpcport=32591 getinfo
4) The output have to something like this
{
"version": 120000,
"protocolversion": 70012,
"walletversion": 60000,
"balance": 0.00000000,
"blocks": 0,
"timeoffset": 0,
"connections": 2,
"proxy": "",
"difficulty": 4.656542373906925e-10,
"testnet": false,
"keypoololdest": 1458240195,
"keypoolsize": 101,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"errors": ""
}
5) Check what getblocktemplate returns
> bitcoin-cli -regtest -rpcconnect=127.0.0.1 -rpcuser=admin -rpcpassword=admin -rpcport=32591 getblocktemplate
If it returns an error
```
error code: -10
error message:
Bitcoin is downloading blocks...
```
We generate a block to start
> bitcoin-cli -regtest -rpcconnect=127.0.0.1 -rpcuser=admin -rpcpassword=admin -rpcport=32591 generate 1
```
[
"716162d5acae71e322ab4531e2ac0be0771f110c4fd213c4306f7b7d09e45094"
]
```
Now getblocktemplate should work
> bitcoin-cli -regtest -rpcconnect=127.0.0.1 -rpcuser=admin -rpcpassword=admin -rpcport=32591 getblocktemplate
The output should be something like
```
{
"capabilities": [
"proposal"
],
"version": 4,
"previousblockhash": "716162d5acae71e322ab4531e2ac0be0771f110c4fd213c4306f7b7d09e45094",
"transactions": [
],
"coinbaseaux": {
"flags": ""
},
"coinbasevalue": 5000000000,
"longpollid": "716162d5acae71e322ab4531e2ac0be0771f110c4fd213c4306f7b7d09e450944",
"target": "7fffff0000000000000000000000000000000000000000000000000000000000",
"mintime": 1458241314,
"mutable": [
"time",
"transactions",
"prevblock"
],
"noncerange": "00000000ffffffff",
"sigoplimit": 20000,
"sizelimit": 1000000,
"curtime": 1458241367,
"bits": "207fffff",
"height": 2
}
```
RootstockJ
----------
0) Install Oracle Java 8
> sudo add-apt-repository ppa:webupd8team/java
> sudo apt-get update
> sudo apt-get install oracle-java8-installer
1) Checkout RootstockJ source in a directory named RootstockJ
> git clone https://github.com/rootstock/rootstockJ.git
2) Generate fat jar for RootstockJ
- Inside RootstockJ's directory (where it was cloned on step 1), run the following command:
> gradle shadow
- The fat jar will be generated in ethereumj-core/build/libs/
3) Run miner
> java -Dethereumj.conf.file=node1.conf -cp rootstock.jar io.rootstock.Start
- rootstock.jar is the name of the fatjar.
- Configuration file for node1 is named node1.conf.
- node1.conf is in the same folder as the jar.
- Node1 will be listening for RPC at 127.0.0.1:4444.
Ckpool
------
1) Inside ckpool folder we create a directory to run out tests
> mkdir run
> cd run
So we have the binaries in ckpool/src and our test will run on ckpool/run
2) We need to create a configuration file ckpool.conf with the following content
```
{
"btcd" : [
{
"url" : "127.0.0.1:32591",
"auth" : "admin",
"pass" : "admin",
"notify" : false
}
],
"rskd" : [
{
"url" : "127.0.0.1:4444",
"auth" : "user",
"pass" : "pass"
}
],
"upstream" : "main.ckpool.org:3336",
"btcaddress" : "n19XNjTfYwLx3YbQk7GG2tLjzcqUeWP42D",
"btcsig" : "/mined by ck/",
"blockpoll" : 10000,
"nonce1length" : 4,
"nonce2length" : 8,
"update_interval" : 30,
"serverurl" : [
"192.168.0.121:3333",
"127.0.0.1:3333"
],
"nodeserver" : [
"127.0.0.1:3335"
],
"trusted" : [
"127.0.0.1:3336"
],
"mindiff" : 0,
"startdiff" : 1,
"maxdiff" : 0,
"logdir" : "logs",
"rskpollperiod" : 10000,
"rsknotifypolicy": 0
}
```
"btcd" : entry should point to the bitcoind running in regtest mode.
"rskd" : should point to the rootstockj running.
"serverurl" : are the address that ckpool will be listening for miners
3) Now within run/ we can lauch ckpool
> ../src/ckpool -A -l 7 -c ckpool.conf
Flags used:
"A" : standalone mode, will accept from any miner (user:pass will be ignored)
"l" : set log level to debug (all the info is logged in run/ckpool.log)
"c" : configuration file
It should output something like this
```
[2016-03-17 16:07:07.582] ckpool stratifier starting
[2016-03-17 16:07:07.582] ckpool connector starting
[2016-03-17 16:07:07.585] ckpool connector ready
[2016-03-17 16:07:07.587] ckpool generator starting
[2016-03-17 16:07:07.586] ckpool rootstock starting
[2016-03-17 16:07:07.604] ckpool generator ready
[2016-03-17 16:07:07.606] Connected to bitcoind: 127.0.0.1:32591
[2016-03-17 16:07:07.613] ckpool stratifier ready
[2016-03-17 16:07:07.841] ckpool rootstock ready
[2016-03-17 16:07:07.846] Connected to rskd: 127.0.0.1:4444
```
4) It should be ready to connect with a miner
For example it can be used with this miner https://bitcointalk.org/index.php?topic=55038.0
> minerd -a sha256d -t 2 --url=stratum+tcp://192.168.0.121:3333 --userpass=user:pass
"a" : sha256d to mine in bitcoind mode
"t" : to use 2 threads
"url" : addres of ckpool
"userpass" : The user:pass will be ignored by ckpool in standalone mode.
Ckpool Dev Mode
---------------
Created to allow miners to receive a very small difficulty value for mining.
As a consequence, miners will mine at a faster rate.
Needed because on a regular computer mining can take too long.
To activate Dev Mode the value of te following line (located on file. stratifier.c) should be true:
> #define DEV_MODE_ON true
false will make CKPool work as usual and all the Dev Mode settings will be ignored.
The following settings can be modified and will impact on the mining rate:
- Miner Difficulty. Value that will be send to the miners
> #define MINER_DIFF 0.005
- Block submission difficulty for RSK. Value that determines when a block generated by the miner will be send to the RSK Node
> #define RSK_CKPOOL_DIFF 0.0
- Block submission difficulty for BTC. Value that determines when a block generated by the miner will be send to Bitcoind
> #define BTC_CKPOOL_DIFF 0.1
For example, the previous configuration allows a rate of 1 BTC Block/Min and 1 RSK Block/10 Secs