Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGminer can't connect over RPC on 0.20.0 #19182

Closed
Relaxo143 opened this issue Jun 5, 2020 · 37 comments
Closed

CGminer can't connect over RPC on 0.20.0 #19182

Relaxo143 opened this issue Jun 5, 2020 · 37 comments

Comments

@Relaxo143
Copy link

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.
`

@maflcko
Copy link
Member

maflcko commented Jun 6, 2020

Could be related to e42c959

@maflcko
Copy link
Member

maflcko commented Jun 6, 2020

nvm 0328dcd is in 0.19, so that shouldn't be the problem. ping @luke-jr

@jnewbery
Copy link
Contributor

There's a message in bitcoin talk that this is due to the coinbaseaux flags field being removed: https://bitcointalk.org/index.php?topic=5253096.msg54839526#msg54839526

@jnewbery
Copy link
Contributor

I'm not very familiar with ckpool but it looks like that's the problem: https://bitbucket.org/ckolivas/ckpool/src/b8f66852483542326de8c5705a3e36242347ad12/src/bitcoin.c#lines-147

If I'm right, that's a bug in ckpool. It shouldn't be failing on absence of the coinbaseaux flag, since that's not a required field in the gbt response: https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#block-template-request.

@jameshilliard does that look right to you?

@luke-jr
Copy link
Member

luke-jr commented Jul 27, 2020

Agree with @jnewbery's assessment.

@Beeskee
Copy link

Beeskee commented Oct 30, 2020

This happens with solo mining too. Also happens on 20.1

@asbourlotos
Copy link

I'm new to solo mining but I'm noticing the same after full node sync and cgminer config. Anyone find a workaround to the GBT decode issue?

@luke-jr
Copy link
Member

luke-jr commented Dec 29, 2020

If you need a workaround, you should be able to use BFGMiner as a stratum proxy for cgminer.

@Relaxo143
Copy link
Author

If you need a workaround, you should be able to use BFGMiner as a stratum proxy for cgminer.

Could you provide more detailed instructions?

@luke-jr
Copy link
Member

luke-jr commented Dec 30, 2020

bfgminer --stratum-port 3334

To validate your setup on testnet, also pass -o 'localhost:18332/#getcbaddr' -O rpcuser:rpcpass

@sipa
Copy link
Member

sipa commented Dec 30, 2020

Any reason we can't just include "coinbaseaux" : {"flags" : ""} in our GBT response?

@luke-jr
Copy link
Member

luke-jr commented Dec 30, 2020

@sipa that would probably work, but seems ugly just to deal with third-party unmaintained and broken code... Core doesn't even try to remain reasonably compatible with Knots, so why unreasonably for cgminer?

@sipa
Copy link
Member

sipa commented Dec 30, 2020

If it's unmaintained then I withdraw my suggestion.

@Relaxo143
Copy link
Author

We definitely need a maintained alternative for desktop miners. Even if usb asics do not make any profit, it's still a good learning experience and people use them.

@Relaxo143
Copy link
Author

bfgminer --stratum-port 3334

To validate your setup on testnet, also pass -o 'localhost:18332/#getcbaddr' -O rpcuser:rpcpass

Ok that's for bfg. What do I do with cgminer after that?

@luke-jr
Copy link
Member

luke-jr commented Dec 30, 2020

Point it at localhost:3334

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

@jameshilliard
Copy link
Contributor

jameshilliard commented Dec 30, 2020

@jameshilliard does that look right to you?

Yeah, looks right.

We definitely need a maintained alternative for desktop miners.

Last I checked Con Kolivas seemed open to transferring the cgminer project if a suitable organization was interested in maintaining cgminer.

@asbourlotos
Copy link

I just dropped BTC core 0.19 (latest before 0.20) on top of the new files to revert installation and keep block info and now it's working. Solo mining on valid address :) with cgminer and no stratum port. Not that I'll ever solve a block but maybe I'll start learning the space and make/update a miner?

@Beeskee
Copy link

Beeskee commented Jan 18, 2021

I've tried using bfgminer but it reports the pool is down or invalid, using the same server settings that I use for cgminer. I'll keep checking into this, I was using cgminer since it was updated for my device. If anyone has any suggestions, I'd appreciate them.

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2021

Did you include #getcbaddr in the URI?

@Beeskee
Copy link

Beeskee commented Jan 18, 2021

Yes, I tried it both with and without.

bfgminer -o 'http://127.0.0.1:8332/#getcbaddr' -u User -p Password --generate-to 394zcJWJfDwQPYxJ18u5fWaJkVwx76D8KP --stratum-port 3334

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2021

Add -T -D -P to see protocol dumps, might give a clue as to what's going on

Is the node synced?

@Beeskee
Copy link

Beeskee commented Jan 18, 2021

Yes the node is synced.

I see multiple errors in that log:

[2021-01-18 08:30:22] Stratum connect failed with TLS to pool 0: gnutls_handshake() failed: An unexpected TLS packet was received.

[2021-01-18 08:30:22] JSON decode failed(1): '[' or '{' expected near 'HTTP'

[2021-01-18 08:30:22] Pool 0: gnutls_handshake() failed: An unexpected TLS packet was received.

[2021-01-18 08:30:22] Pool 0: RECV: HTTP/1.1 400 Bad Request
[2021-01-18 08:30:22] JSON decode failed(1): '[' or '{' expected near 'HTTP'

[2021-01-18 08:30:22] FAILED to retrieve work from pool 0 http://127.0.0.1:8332/#getcbaddr
[2021-01-18 08:30:22] Pool 0 slow/down or URL or credentials invalid
[2021-01-18 08:30:22] No servers were found that could be used to get work from.

@asbourlotos
Copy link

@Beeskee Im not sure if this would have helped bfgminer but try downgrading your Bitcoin core to v0.19.1 and configuring cgminer again. I've been solo mining on 8 newpac miners @500mhz (907.5GH/s avg) for a couple weeks now with only one reboot for core disconnect. Two more incoming :) I know odds are crap but I told myself to build a 1TH unit and leave it for the lotto! Good luck!

@Beeskee
Copy link

Beeskee commented Jan 18, 2021

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.

@asbourlotos
Copy link

Gotcha. I thought about this as well. If you do get bfgminer working on newest core ver. Reach out to me. I might want to follow along.

@luke-jr
Copy link
Member

luke-jr commented Jan 18, 2021

bitcoin-cli getblocktemplate '{"rules":["segwit"]}'

@Zwilla
Copy link

Zwilla commented Jan 19, 2021

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

@mshalabi1990
Copy link

Did your lotto work

@asbourlotos
Copy link

@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.

@Joz3d
Copy link

Joz3d commented Feb 27, 2021

Sucks. I also solo mine with newpacs and cg. Finally was upgrading node from 19.1 to 21.0 tonight and wasted last 2h troubleshooting this. Downgrading...

@luke-jr
Copy link
Member

luke-jr commented Feb 27, 2021

@Joz3d Why downgrade the node rather than upgrade the miner?

@Joz3d
Copy link

Joz3d commented Feb 28, 2021

@luke-jr Downgraded to previous version bitcoind as the quickest solution to get up and running again. You're right, the miner needs to be upgraded but getting author to update that/forking if need-be is an unexpected effort. Oh well, will work on it.

@shinjukumiku
Copy link

@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

@cmmodtools
Copy link

This issue is resolved in https://github.com/cmmodtools/cgminer

Specifically in commit cmmodtools/cgminer@b9e0f86

@maflcko
Copy link
Member

maflcko commented Jun 16, 2022

Can this be closed, given that this is an upstream issue?

Let me know if it should be reopened.

@maflcko maflcko closed this as completed Jun 16, 2022
@koga73
Copy link

koga73 commented Feb 28, 2023

@Zwilla I ran into the same issue with ckpool v0.9.5 + bitcoind v22.0.0. I was able to get ckpool working by commenting out references to "coinbase_aux" in ckpool src/bitcoin.c as well as setting the "flags" variable to an empty string.

@bitcoin bitcoin locked and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

15 participants