bitcoin: CGminer can't connect over RPC on 0.20.0

After upgrading to 0.20.0 cgminer throws the following error: Pool 0 JSON failed to decode GBT I’m assuming there are some additional rpc settings for the .conf file which I need to specify as of 0.20.0, but I don’t know which. I downgraded to 0.19.1 and it’s working fine. Any help would be appreciated. `

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 37 (17 by maintainers)

Most upvoted comments

@mshalabi1990 I haven’t found a block yet (though I wouldn’t tell anyone if I did 😉 ) but my highest share has been 537m. That’s a long way from 20.6t.

@Zwilla Check attached patch.

From 915d0c399a450a1af024acfc9e8e4f86e20eaa94 Mon Sep 17 00:00:00 2001
From: Miku <miku@example.com>
Date: Sun, 16 Jan 2022 08:14:10 +0000
Subject: [PATCH] Fix handling GBT with no flags in coinbaseaux

bitcoind >=0.20.0's GBT reply no longer includes a flags string
in the coinbaseaux object. It was an empty string in 0.19.1.

0.19.1: "coinbaseaux":{"flags":""}
22.0  : "coinbaseaux":{}

If flags is not in coinbaseaux of the GBT response, we
allocate an empty string for flags to prevent segfault.
flags needs to be dynamically allocated because it will be freed.

A more robust future fix is to remove dependence on the coinbaseaux
object in the GBT response as it isn't required per BIP 0022.

Fix has been verified to find several testnet blocks with bitcoind 22.0,
the latest version as of writing.
---
 src/bitcoin.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/bitcoin.c b/src/bitcoin.c
index b114fd06..88ed1bb1 100644
--- a/src/bitcoin.c
+++ b/src/bitcoin.c
@@ -147,7 +147,14 @@ bool gen_gbtbase(connsock_t *cs, gbtbase_t *gbt)
 	coinbase_aux = json_object_get(res_val, "coinbaseaux");
 	flags = json_string_value(json_object_get(coinbase_aux, "flags"));
 
-	if (unlikely(!previousblockhash || !target || !version || !curtime || !bits || !coinbase_aux || !flags)) {
+	/* bitcoind >= 0.20.0 GBT respose coinbaseaux has no flags */
+	/* 2022-01-16 https://github.com/bitcoin/bitcoin/issues/19182 */
+	if(!flags) {
+		/* LOGDEBUG("No flags in coinbaseaux of GBT JSON"); */
+		flags = calloc(1, 1);
+	}
+
+	if (unlikely(!previousblockhash || !target || !version || !curtime || !bits || !coinbase_aux)) {
 		LOGERR("JSON failed to decode GBT %s %s %d %d %s %s", previousblockhash, target, version, curtime, bits, flags);
 		goto out;
 	}
-- 
2.20.1

after starting ckpool, on fresh install of bitcoind and ready synced with txindex=1 I got this lines on bitcoind, and ckpool tries and tries this :

[2021-01-19 08:47:53.442] CRITICAL: No bitcoinds active! [2021-01-19 08:47:55.446] JSON failed to decode GBT 0000000000000000000048840346957d513da4037b325689baa97f5acecabd90 0000000000000000000da8a10000000000000000000000000000000000000000 536870912 1611042475 170da8a1 (null) with errno 11: Resource temporarily unavailable [2021-01-19 08:47:58.711] JSON failed to decode GBT 0000000000000000000048840346957d513da4037b325689baa97f5acecabd90 0000000000000000000da8a10000000000000000000000000000000000000000 536870912 1611042478 170da8a1 (null) with errno 11: Resource temporarily unavailable [2021-01-19 08:47:58.716] CRITICAL: No bitcoinds active! [2021-01-19 08:48:00.523] JSON failed to decode GBT 0000000000000000000048840346957d513da4037b325689baa97f5acecabd90 0000000000000000000da8a10000000000000000000000000000000000000000 536870912 1611042480 170da8a1 (null) with errno 11: Resource temporarily unavailable [2021-01-19 08:48:04.022] JSON failed to decode GBT 0000000000000000000048840346957d513da4037b325689baa97f5acecabd90 0000000000000000000da8a10000000000000000000000000000000000000000 536870912 1611042483 170da8a1 (null) with errno 11: Resource temporarily unavailable [2021-01-19 08:48:04.026] CRITICAL: No bitcoinds active!

BITCOIND 2021-01-19T07:43:40Z CreateNewBlock(): block weight: 3992781 txs: 3647 fees: 107078831 sigops 21180 2021-01-19T07:43:46Z CreateNewBlock(): block weight: 3992635 txs: 3647 fees: 107107389 sigops 21165 2021-01-19T07:43:52Z CreateNewBlock(): block weight: 3992582 txs: 3634 fees: 107157062 sigops 21149 2021-01-19T07:43:58Z CreateNewBlock(): block weight: 3992810 txs: 3635 fees: 107215306 sigops 21139 2021-01-19T07:44:05Z CreateNewBlock(): block weight: 3992685 txs: 3641 fees: 107256027 sigops 21091 2021-01-19T07:44:14Z CreateNewBlock(): block weight: 3992486 txs: 3650 fees: 107379829 sigops 20965 2021-01-19T07:44:19Z CreateNewBlock(): block weight: 3992559 txs: 3651 fees: 107393032 sigops 20973 2021-01-19T07:44:25Z CreateNewBlock(): block weight: 3992485 txs: 3648 fees: 107537358 sigops 20948 2021-01-19T07:44:35Z CreateNewBlock(): block weight: 3992815 txs: 3646 fees: 107587114 sigops 20957 2021-01-19T07:44:45Z CreateNewBlock(): block weight: 3992548 txs: 3634 fees: 107653973 sigops 20996 2021-01-19T07:44:51Z CreateNewBlock(): block weight: 3992658 txs: 3631 fees: 107734503 sigops 21002 2021-01-19T07:45:00Z CreateNewBlock(): block weight: 3992667 txs: 3633 fees: 107768766 sigops 20999 2021-01-19T07:45:07Z CreateNewBlock(): block weight: 3992750 txs: 3636 fees: 107792206 sigops 20988

Yes, I downgraded Bitcoin in the meantime to continue using cgminer directly, but I don’t like the idea of being stuck on a prior version with no way to upgrade.

Point it at localhost:3334

(But if it’s a USB stick miner, you can probably just use BFGMiner by itself…)