How to solo mine testnet bitcoins using cgminer, Bitcoin Core, and a Compac F

19 replies 475 views
WildGuruFull Member
Posts: 77 · Reputation: 559
#1Aug 6, 2021, 12:58 PM
Want to snag some testnet bitcoins? Solo mining is a solid way to do it. I’ve noticed that most guides floating around are pretty outdated, so I put together this one that works with the latest tools and gear. Here’s what you’ll need: - The latest Bitcoin Core version (v23.0 as of now) - A special build of cgminer for solo mining, which you can find at https://github.com/cmmodtools/cgminer, plus a little tweak from this guide. - Ideally, you'll want an ASIC miner. If you don’t have one, any miner compatible with cgminer will do, even the USB miner from GekkoScience, like the Compac F. To keep it straightforward, I’m assuming you’ve got two machines: one for your Compac F miner and another for running Bitcoin Core. Doesn’t matter if they’re on the same computer or different ones. Step 1: Get Bitcoin Core installed and running. We’ll use the folder ~/bitcoin_testnet to keep everything organized, making it easy to delete later. Feel free to choose a different path if you prefer. Inside ~/bitcoin_testnet, create a folder named data: Download the Bitcoin Core for your operating system into ~/bitcoin_testnet/ and unpack it there. Next up, let’s set up the config file. Create a text file called bitcoin_testnet.conf in ~/bitcoin_testnet/ and add these details: The key thing to grasp here is that you’re configuring the Bitcoin node for testnet operation, specifying an RPC port (5000 in this instance, but it can be anything), as well as a username and password, plus whitelisting a specific IP to connect to your node (YOUR_MINER_IP). You’ll need these credentials and your Bitcoin n.
8 Reply Quote Share
LuckyCoinLegendary
Posts: 832 · Reputation: 4795
#2Aug 6, 2021, 05:02 PM
A few blocks overnight? That means the testnet difficulty is extremely low. Exactly what was the testnet difficulty when you wrote this guide? I'm sure this will help a bunch of people who are setting up testnet bitcoin mining farms.
3 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#3Aug 6, 2021, 06:35 PM
The difficulty was in the millions: But apparently testnet3 resets diff to 1 at some blocks, as those are the ones I hit:
1 Reply Quote Share
raven23Member
Posts: 26 · Reputation: 199
#4Aug 8, 2021, 01:30 AM
Nicely detailed guide!
3 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#5Aug 8, 2021, 04:19 AM
Thanks for writing this guide. Although people who currently don't have ASIC better use Signet or Regtest, unless they also want to try their luck with solo mining on Bitcoin mainnet. Not at some blocks, but after 20 minutes since last block mined. That might be why you mine more block than @NotATether expected.
2 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#6Aug 8, 2021, 09:06 AM
That's great to know! I wasn't aware of this rule. Will spin a Compac F up to mine some testnet BTC, then.. I've never hit a solo block, so this should be a pretty cool experience.
1 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#7Aug 8, 2021, 01:57 PM
That was the motivation for me to do this in the first place  A couple of things you might want to do: Keep the log of your first block: And you can of course write something into the coinbase of the block you found, just add this option to the config file:
1 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#8Aug 8, 2021, 06:28 PM
It's a simple text argument, the same as the btc-address argument you have to give in the config file. Just add another line with that. Just try it out, that's the whole point of the testnet
2 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#9Aug 8, 2021, 11:10 PM
I just posted a new guide that doesn't require an ASIC. It only uses the CPU and/or the GPU of a normal computer, so you should be able to test it.
4 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#10Aug 10, 2021, 06:12 PM
A few recommendations and fixes: (1) Just add datadir=/home/user/bitcoin_testnet/data to the conf file, as well. Then you won't have to specify it through CLI anymore. (2) There is a typo here. It should be --enable-gekko; otherwise it will compile just fine, but without Gekko support and you won't even notice. (3) Cgminer complains about the comma at the end of the last line ("failover-only" : true,); it has to be removed to work. (4) For anyone unsure how to do this:
6 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#11Aug 10, 2021, 11:26 PM
Nullama, your guide worked great (besides the few points I raised)! Amazing; I hadn't expected to mine multiple blocks per day. In fact, I managed to grab almost 30 blocks in 24h. Sitting at roughly 0.9tBTC right now. Even consecutive blocks a few times... I must have very good network latency or something. Only a single Compac F hashing at just under 300GH/s. It was an awesome experience to solo-mine again (and hit blocks!) and I'll definitely do it again if I need testnet coins and / or for validating a miner / miner driver software. PS: Check last 24h of blocks for hidden message!
2 Reply Quote Share
vault2019Member
Posts: 57 · Reputation: 212
#12Aug 12, 2021, 06:31 PM
What needs to be changed for this to work on main net? Remove testnet=1 ?
3 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#13Aug 12, 2021, 08:28 PM
Interesting; I would have expected a CPU / GPU setup to work fine, too then. At difficulty 1, you need a fast network latency in my opinion, but also a block candidate immediately. In case the ASIC is 100x faster, that could play a bigger role than what I anticipated. Again; I got consecutive blocks a few times, so I guess that a couple hundred GH suffice for consistent blocks rewards. Yes It is also displayed by mempool.space. Oddly enough; someone just sent me ‎0.00017893 tBTC, which was no coinbase transaction. Typo? Never happened on mainnet to me, in all these years. I mined: Block 2411861, Block 2411862 and Block 2411863 in a row.
0 Reply Quote Share
WildGuruFull Member
Posts: 77 · Reputation: 559
#14Aug 13, 2021, 12:29 AM
Glad to see people now solo mining testnet bitcoins with this guide
3 Reply Quote Share
degen_apeMember
Posts: 28 · Reputation: 231
#15Aug 13, 2021, 03:22 AM
That's 50,000 times faster than my CPU mining! Would you be interested to try? I still have a synced testnet blockchain running, and could give you access. At low difficulty, I wonder if I made a mistake for not getting anything in days.
2 Reply Quote Share
degen_apeMember
Posts: 28 · Reputation: 231
#16Aug 13, 2021, 08:57 AM
It's a quad core Xeon E3-1270 V2 @ 3.50GHz. That's why I'm wondering if I did something wrong somewhere.
1 Reply Quote Share
colddiamondHero Member
Posts: 623 · Reputation: 2467
#17Aug 14, 2021, 06:00 AM
Stale has less to do with mining and more to do with propagation. If you have all the cores screaming running the SHA did you have enough CPU power left over to do the rest and get it out to the world. It's not a lot of computing power, but if you don't have any to spare it could cause issues. The other half of stale is networking. How many nodes is your node talking to? If there is a lag there and more nodes see the other block then you loose. Also, it could be other miners deliberately causing reorgs. I don't see the point on testnet, but if I have enough power I can just ignore some blocks figuring I will get 2 or 3 while the rest of the network gets 1. That would just be a waste, but I can see people messing around to see if they can do it. -Dave
3 Reply Quote Share
hodlg4ngSenior Member
Posts: 129 · Reputation: 853
#18Aug 14, 2021, 06:11 AM
You found my messages! Nice! I've got to plant some more (on a new address) then.. Sure, let's do it. Sorry, only just revisited this thread again.
3 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#19Aug 14, 2021, 08:13 PM
Usually in parallel programming (multi-thread) when one thread finds the answer it breaks out of it and sends a "signal" to other threads to break too. Which means after finding the new block at least part of CPU has to be freed to be used for the broadcasting process.
3 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#20Aug 17, 2021, 07:25 AM
As far as I could see, I never mined a block. I followed Solo mine testnet bitcoins with bfgminer, Bitcoin Core, and a CPU (but somehow ended up posting in this thread). I assume that's not a problem, Linux multitasking should be able to handle this. And I used nice for the miner. If that would be the problem, I would have expected to see orphaned blocks, right? Thanks! I'll PM you the details (and let's switch back to the correct thread).
2 Reply Quote Share

Related topics