diff --git a/README_Rootstock.txt b/README_Rootstock.txt index 920b005b..6ddfac15 100644 --- a/README_Rootstock.txt +++ b/README_Rootstock.txt @@ -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 =================== diff --git a/ckpool.conf b/ckpool.conf index 96214594..09298c01 100644 --- a/ckpool.conf +++ b/ckpool.conf @@ -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. diff --git a/src/ckpool.c b/src/ckpool.c index 81b092f1..b8aaf18a 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -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); } diff --git a/src/ckpool.h b/src/ckpool.h index 061c2635..9ba06ec5 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -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; diff --git a/src/rootstock.c b/src/rootstock.c index 161da63f..0dff2f38 100644 --- a/src/rootstock.c +++ b/src/rootstock.c @@ -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) diff --git a/src/rsktestconfig.h b/src/rsktestconfig.h deleted file mode 100644 index 1018a4ca..00000000 --- a/src/rsktestconfig.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2016 - */ - -/* Use in development mode only */ -#define DEV_MODE_ON false -/* Difficulty value that will be send to the miners */ -#define MINER_DIFF 0.005 -/* Difficulty value that will be used in block submission to RSK or BTC */ -#define RSK_CKPOOL_DIFF 0.0 -#define BTC_CKPOOL_DIFF 0.1 - -#define PERF_TEST_MODE_ON false diff --git a/src/stratifier.c b/src/stratifier.c index 987eb6b0..5f84dac5 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -31,8 +31,6 @@ #include "generator.h" #include "rootstock.h" -#include "rsktestconfig.h" - #define HASH_SIZE 32 #define BLOCK_HEADER_SIZE 80 @@ -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(), @@ -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; } @@ -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 */ @@ -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;