Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions README_Rootstock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,29 +272,19 @@ 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
To activate Dev Mode the value set the `devmode` configuration value in `ckpool.conf` to `true`. Setting it to `false` will make CKPool work as usual and all the Dev Mode settings will be ignored.

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:

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
* `devmode_miner_diff`: Miner Difficulty. Value that will be sent to the miners.
* `devmode_rsk_diff`: Block submission difficulty for RSK. Value that determines when a block generated by the miner will be send to the RSK Node.
* `devmode_btc_diff`: Block submission difficulty for BTC. Value that determines when a block generated by the miner will be send to Bitcoind.

For example, the default configuration allows a rate of 1 BTC Block/Min and 1 RSK Block/10 Secs

Setting a negative or zero value will disable de setting even if Dev mode is enabled. For example:
* Setting the `devmode_miner_diff` to `0.0` will cause the pool to use the default miner difficulty and not the Dev Mode one.
* Setting the `devmode_rsk_diff` to `-1.0` will cause the pool to use the default rsk difficulty specified by the `getWork` result instead of a fix value.

Parsing ckpool logs
===================
Expand Down
6 changes: 5 additions & 1 deletion ckpool.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"maxdiff" : 0,
"logdir" : "logs",
"rskpollperiod" : 500,
"rsknotifypolicy": 1
"rsknotifypolicy": 1,
"devmode": false,
"devmode_miner_diff": 0.005,
"devmode_rsk_diff": 0.0,
"devmode_btc_diff": 0.1
}
Comments from here on are ignored.
5 changes: 5 additions & 0 deletions src/ckpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,11 @@ static void parse_config(ckpool_t *ckp)
json_get_int(&ckp->rskpollperiod, json_conf, "rskpollperiod");
json_get_int(&ckp->rsknotifypolicy, json_conf, "rsknotifypolicy");

json_get_bool(&ckp->devmode, json_conf, "devmode");
json_get_double(&ckp->devmode_miner_diff, json_conf, "devmode_miner_diff");
json_get_double(&ckp->devmode_rsk_diff, json_conf, "devmode_rsk_diff");
json_get_double(&ckp->devmode_btc_diff, json_conf, "devmode_btc_diff");

json_decref(json_conf);
}

Expand Down
6 changes: 6 additions & 0 deletions src/ckpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ struct ckpool_instance {
bool wmem_warn;
bool rmem_warn;

/* Enable development mode (custom target difficulties) */
bool devmode;
double devmode_miner_diff;
double devmode_rsk_diff;
double devmode_btc_diff;

/* Bitcoind data */
int btcds;
char **btcdurl;
Expand Down
2 changes: 0 additions & 2 deletions src/rootstock.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include "jansson.h"
#include "hashtable.h"

#include "rsktestconfig.h"

#define BIN_HASH_SIZE sizeof(((rsk_getwork_t*)0)->blockhashmergebin)
#define HEX_HASH_SIZE sizeof(((rsk_getwork_t*)0)->blockhashmerge)
#define HEX_TARGET_SIZE sizeof(((rsk_getwork_t*)0)->target)
Expand Down
13 changes: 0 additions & 13 deletions src/rsktestconfig.h

This file was deleted.

25 changes: 15 additions & 10 deletions src/stratifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "generator.h"
#include "rootstock.h"

#include "rsktestconfig.h"

#define HASH_SIZE 32
#define BLOCK_HEADER_SIZE 80

Expand Down Expand Up @@ -5892,8 +5890,9 @@ static void stratum_send_diff(sdata_t *sdata, const stratum_instance_t *client)

double client_diff = client->diff;

if(DEV_MODE_ON){
client_diff = MINER_DIFF;
if(client->ckp->devmode && (0 < client->ckp->devmode_miner_diff)){
LOGDEBUG("ROOTSTOCK: devmode miner diff %lf", client->ckp->devmode_miner_diff);
client_diff = client->ckp->devmode_miner_diff;
}

JSON_CPACK(json_msg, "{s[f]soss}", "params", client_diff, "id", json_null(),
Expand Down Expand Up @@ -5998,8 +5997,8 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, const double d

/* Diff rate ratio */
dsps = client->dsps5 / bias;
if (DEV_MODE_ON) {
drr = dsps / (MINER_DIFF + (double)client->diff);
if (ckp->devmode && (0 < client->ckp->devmode_miner_diff)) {
drr = dsps / ((double)client->diff + client->ckp->devmode_miner_diff);
} else {
drr = dsps / (double)client->diff;
}
Expand Down Expand Up @@ -6091,9 +6090,15 @@ test_blocksolve(const stratum_instance_t *client, const workbase_t *wb, const uc
bool submit_bitcoind = false;
bool submit_rskd = false;

if(DEV_MODE_ON){
sdata->current_workbase->rsk_diff = RSK_CKPOOL_DIFF;
sdata->current_workbase->network_diff = BTC_CKPOOL_DIFF;
if(client->ckp->devmode){
if (0 < client->ckp->devmode_rsk_diff) {
LOGDEBUG("ROOTSTOCK: devmode rsk diff %lf", client->ckp->devmode_rsk_diff);
sdata->current_workbase->rsk_diff = client->ckp->devmode_rsk_diff;
}
if (0 < client->ckp->devmode_btc_diff) {
LOGDEBUG("ROOTSTOCK: devmode btc diff %lf", client->ckp->devmode_btc_diff);
sdata->current_workbase->network_diff = client->ckp->devmode_btc_diff;
}
}

/* Rootstock difficulty */
Expand Down Expand Up @@ -6513,7 +6518,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg,
else
ckdbq_add(ckp, ID_SHARES, val);
out:
if (!sdata->wbincomplete && (((!result && !submit) || !share) && !DEV_MODE_ON)) {
if (!sdata->wbincomplete && (((!result && !submit) || !share) && !(client->ckp->devmode))) {
/* Is this the first in a run of invalids? */
if (client->first_invalid < client->last_share.tv_sec || !client->first_invalid)
client->first_invalid = now_t;
Expand Down