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

BFLMiner unable to connect #209

Closed
stevenroose opened this issue Jan 7, 2015 · 27 comments
Closed

BFLMiner unable to connect #209

stevenroose opened this issue Jan 7, 2015 · 27 comments

Comments

@stevenroose
Copy link
Contributor

I just setup btcd with testnet and an accompanying btcwallet and btcgui setup that works fine.

Now I followed these instructions and pointed my BFLMiner to bfgminer -o https://localhost:18334 -u rpcuser -p rpcpass but it gives the error Pool 0 slow/down or URL or credentials invalid.

Is this a BFLMiner issue or a btcd issue?

@dajohi
Copy link
Member

dajohi commented Jan 7, 2015

Did you add btcd's rpc.cert to the CA list?

https://github.com/conformal/btcd/wiki#Mining

@stevenroose
Copy link
Contributor Author

As I mentioned, yes I did. I also tried both http and https.

@luke-jr
Copy link

luke-jr commented Jan 7, 2015

miningaddr probably needs to be a testnet address if you're trying to mine testnet. Do you mean BFGMiner? If so, try running with

bfgminer -o https://localhost:18334 -u rpcuser -p rpcpass --debuglog -P --log-file debug.log

And upload debug.log somewhere with a link here.

@stevenroose
Copy link
Contributor Author

Thanks for the fast reply btw!

This is the debug file: https://gist.github.com/stevenroose/300667579170e3b90247

I already had one miningaddr enabled.

@dajohi
Copy link
Member

dajohi commented Jan 7, 2015

@luke-jr btcd will not start if --miningaddr is specified and the address is on the wrong network.

@stevenroose does btcctl --testnet getblocktemplate work?

@stevenroose
Copy link
Contributor Author

Hmm, weird. It did work before. But not it prints
rpcCommand: -1: The local time is before the minimum allowed time for a block - current time 2015-01-07 22:03:58.285543695 +0100 CET, minimum time 2015-01-07 22:20:35 +0100 CET

This might well be the issue.

@luke-jr
Copy link

luke-jr commented Jan 7, 2015

Looks like a conflict between your gnutls/curl and btcd?

 [2015-01-07 21:55:42] Stratum connect failed with TLS to pool 0: gnutls_handshake() failed: Handshake failed

I suppose it's possible the handshake may fail if the system clock is too wrong.

@davecgh
Copy link
Member

davecgh commented Jan 7, 2015

It's also possible to run btcd with --notls now if you're only binding to localhost.

EDIT: With master, not the last release.

@stevenroose
Copy link
Contributor Author

So what can I do to resolve it? Will --notls fix this? I suppose I will have to connect using regular HTTP then?

@stevenroose
Copy link
Contributor Author

Using --notls, BFLMiner launches fine, but shows these messages

 [2015-01-07 22:52:00] Pool 0 http://localhost:18334 alive
 [2015-01-07 22:52:00] No suitable long-poll found for http://localhost:18334

But it seems to be mining already, I'll wait until I find a testnet block...

@dajohi
Copy link
Member

dajohi commented Jan 7, 2015

So it looks like it was indeed a certificate issue.

Can you paste btcctl --notls --testnet getblocktemplate?

@stevenroose
Copy link
Contributor Author

$ btcctl --notls --testnet getblocktemplate
rpcCommand: error getting json reply: error sending json message: Post http://<username>:<password>@localhost:18332: malformed HTTP response "\x15\x03\x01\x00\x02\x02\x16"

@dajohi
Copy link
Member

dajohi commented Jan 7, 2015

Well, add -u rpcuser and -P rpcpass. Try with and without --notls

@jrick
Copy link
Member

jrick commented Jan 7, 2015

Could you also dig into your btcd logs and see what interface/ports the RPC server is listening on?

Should look something like this:

09:05:54 2015-01-07 [INF] RPCS: RPC server listening on [::1]:18556
09:05:54 2015-01-07 [INF] RPCS: RPC server listening on 127.0.0.1:18556

@stevenroose
Copy link
Contributor Author

22:51:41 2015-01-07 [INF] RPCS: RPC server listening on 127.0.0.1:18334
The port is correct and the same port as I used for BFLMiner.

I have a btcctl.conf file with rpc auth config inside.

Skipping the notls makes it with indefinitely, probably because the btcd has notls as well.

@stevenroose
Copy link
Contributor Author

Ok, I had to add rpcserver=localhost:18334 to btcctl.conf because it seemed to default to port 18332 instead. But then again, I get the error

rpcCommand: -1: The local time is before the minimum allowed time for a block - current time 2015-01-08 01:40:05.212091354 +0100 CET, minimum time 2015-01-08 01:47:19 +0100 CET

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

So it looks like you're connecting fine.

Can you check your local system clock? Based on the error, it says your system clock is wrong (too far in the past).

The consensus rules prevent new blocks that have timestamps before the median timestamp of the last 11 blocks. This check is protecting you from wasting resources mining a block that would be rejected because the timestamp is too far in the past.

@stevenroose
Copy link
Contributor Author

I use a regular Ubuntu 14.04 LTS installation. The clock displayed on my homepage is correct on the minute.

$ date
Don Jan  8 02:24:12 CET 2015

Compare that to timeanddate.com
timeanddate.com

My clock seems to be correct :)

@stevenroose
Copy link
Contributor Author

Also

$ btcctl getblocktemplate
rpcCommand: -1: The local time is before the minimum allowed time for a block - current time 2015-01-08 02:25:37.741123354 +0100 CET, minimum time 2015-01-08 03:07:24 +0100 CET
$ date
Don Jan  8 02:25:49 CET 2015

It seems like the minimum time is incorrect. So it must be an issue in btcd.

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

Ok. Thanks for the data points. So, btcd is not wrong about the minimum time based upon the timestamps of the blocks. It appears somebody on testnet is mining way ahead of the current time.

That said, we should probably generate block templates with timestamps at the minimum allowed time if it's ahead of the current system time rather than just preventing the template from being served.

EDIT: I should've said adjusted time instead of current system time.

Here are the commands I used to see if the minimum time is correct:

$ ./btcctl --testnet getblockcount
317269
$ bcstart=$(./btcctl --testnet getblockcount)
$ bcend=$(expr $bcstart - 11)
$ rm -f timestamps.txt
$ for (( i=$bcstart; i>$bcend; i-- )); do ./btcctl --testnet getblock $(./btcctl --testnet getblockhash $i) | grep time | cut -f2 -d: | cut -f1 -d, >> timestamps.txt; done
$ cat timestamps.txt | sort
 1420686447
 1420686913
 1420687648
 1420688114
 1420688849
 1420689315 <---- median
 1420690050
 1420690516
 1420691251
 1420691717
 1420692452
$ date -r 1420689315
Wed Jan  7 21:55:15 CST 2015
$ date
Wed Jan  7 21:37:28 CST 2015

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

After reviewing the code in question, I see this is an RPC issue as opposed to template generation which already handles this properly as described above.

I have a PR prepared which resolves this that I am testing thoroughly at the moment.

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

@stevenroose Can you please try with pr #213? This should resolve the issue. I've tested it thoroughly locally with no issues.

@stevenroose
Copy link
Contributor Author

Uhm. Can you quickly tell me how I build from source? Currently I used go get github.com/conf....

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

$ cd $GOPATH/src/github.com/conformal/btcd
$ git checkout -b davecgh-fix_209 master
$ git pull https://github.com/davecgh/btcd.git fix_209
$ go build
$ ./btcd --params...

Then once you're done testing, you can go back to master (git checkout master) so future go get -u github.com/conformal/btcd/... will update you to the latest master (which also rebuilds it and installs it to your $GOPATH).

@stevenroose
Copy link
Contributor Author

It works! And it still does not work with the standard build, so "It appears somebody on testnet is mining way ahead of the current time." this guy is still active :)

$ btcctl getblocktemplate
{
    "bits": "1a05da55",
    "capabilities": [
        "proposal"
    ],
    "coinbaseaux": {
        "flags": "0b2f503253482f627463642f"
    },
    "coinbasevalue": 2.5e+09,
    "curtime": 1.420709275e+09,
    "height": 317303,
    "longpollid": "0000000037f8f63cf37206a0f7b47725db182e32d1fb3a3d5257661354cc9683-1420708709",
    "maxtime": 1.420715909e+09,
    "mintime": 1.420709275e+09,
    "mutable": [
        "time",
        "transactions/add",
        "prevblock",
        "coinbase/append"
    ],
    "noncerange": "00000000ffffffff",
    "previousblockhash": "0000000037f8f63cf37206a0f7b47725db182e32d1fb3a3d5257661354cc9683",
    "sigoplimit": 20000,
    "sizelimit": 1e+06,
    "target": "00000000000005da550000000000000000000000000000000000000000000000",
    "transactions": [],
    "version": 2
}

@davecgh
Copy link
Member

davecgh commented Jan 8, 2015

Great. Thanks for testing. Once others have had a chance to review the changes, we'll get it merged to master.

@davecgh davecgh closed this as completed in a64ffb8 Jan 8, 2015
@dajohi
Copy link
Member

dajohi commented Jan 9, 2015

regarding getting https to work, can you try the following:

$ env CURL_CA_BUNDLE=/home/user/.btcd/rpc.cert bfgminer -o https://localhost:18334 -u rpcuser -p rpcpass

kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 29, 2024
…-leaves

mempool: refactor fetchInputUtxosFromUData to fetchInputUtxosFromLeaves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants