Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: seoincorporation on September 25, 2024, 01:06:01 PM



Title: How does a testnet netwok die?
Post by: seoincorporation on September 25, 2024, 01:06:01 PM
Currently, we have two testnet network running on Bitcoin, version 3 and the new version 4. And my question is simple.

When will the version 3 die? And how will this happen?

I feel like it will come with a core update where the engine only works with version 4, but if that happens some users will not update to continue supporting version 3. And if you ask my who would people do this? i would answer "Because the is money involved in version 3", since that one has a market some users don't want to see it gone.


Title: Re: How does a testnet netwok die?
Post by: vjudeu on September 25, 2024, 01:43:08 PM
Quote
When will the version 3 die?
When users will stop using it (which may be never, if there is strong enough community to maintain it, as an altcoin).

Quote
And how will this happen?
By dropping the support for it, in the next versions of Bitcoin Core. Which means, that any new bugfixes and improvements simply won't happen on testnet3 anymore. It will be left as it is, without any changes. If some people will agree to become a new developers, then it may have a chance to live as an altcoin. But most likely it will die, because some people believe, that if something is not supported by Bitcoin Core, then it is not Bitcoin (which is not true, but if enough people believe in that, then the network will die quickly).

Quote
some users will not update to continue supporting version 3
Yes. And if they will encounter blockstorms, or other attacks, then they will have nobody to blame, because if you use outdated network, then you are responsible for keeping it alive, if you want to use it. The same would happen, if someone would decide to run Satoshi prenet version, with 20-bit difficulty blocks. Of course, you can use it, everything is decentralized, and so on, but if you will see, that your client blindly follows the longest chain (instead of the heaviest chain, with the most chainwork), then you can only blame yourself, because your node enforces those outdated rules (not to mention OP_TRUE OP_RETURN bug, Value Overflow Incident, and other issues).


Title: Re: How does a testnet netwok die?
Post by: Accardo on September 25, 2024, 04:53:25 PM

I feel like it will come with a core update where the engine only works with version 4, but if that happens some users will not update to continue supporting version 3. And if you ask my who would people do this? i would answer "Because the is money involved in version 3", since that one has a market some users don't want to see it gone.

As a result of people who no longer want to give up their testnet3 killing the reason for testnet; free distribution - a once a while reset can help reduce the importance of having to stay on old version for monetary gains. However, testnet3 will not die, it's been around for 13 years, the BTC client will have to support both Testnet3 and testnet4.


Title: Re: How does a testnet netwok die?
Post by: garlonicon on September 26, 2024, 03:31:07 AM
Quote
the BTC client will have to support both Testnet3 and testnet4
https://github.com/bitcoin/bitcoin/pull/29775/files#diff-c534c365a32e58168519cb10607734c54323b7f79049dd9a0a3dfbdfd649b31c
Code:
argsman.AddArg("-testnet", "Use the testnet3 chain. Equivalent to -chain=test. Support for testnet3 is deprecated and will be removed with the next release. Consider moving to testnet4 now by using -testnet4.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
See? Removing support is planned. And you can confirm it, by reading the comments in the discussion between developers.

If someone else would want to develop testnet3, as an altcoin, then sure, go on. But it would be removed from Bitcoin Core in the future.


Title: Re: How does a testnet netwok die?
Post by: BlackBoss_ on September 26, 2024, 04:06:59 AM
Currently, we have two testnet network running on Bitcoin, version 3 and the new version 4. And my question is simple.

When will the version 3 die? And how will this happen?
When something is wrong with Testnet 1, Testnet 2, developers will reset testnet and create a new testnet iteration.

Bitcoin Testnet (https://en.bitcoin.it/wiki/Testnet)
Quote
Testnet2 was just the first testnet reset with a different genesis block, because people were starting to trade testnet coins for real money.

Has the TestNet ever been reset? (https://bitcoin.stackexchange.com/questions/9975/has-the-testnet-ever-been-reset)

If something is seriously misused with Testnet 3, Testnet 4, we will have Testnet 5.


Title: Re: How does a testnet netwok die?
Post by: Reatim on September 26, 2024, 04:44:40 AM
When will the version 3 die? And how will this happen?
Has there been any announcement already for the version 4? If not well that is how it will start but it will not immediately be used by everyone. There will probably a time where the two versions will coexist at the same time with a few using the version 4 while others still using version 3 until eventually more and more people use version 4 and almost no one is using version 3 then that is when it will die already.
Quote
"Because the is money involved in version 3", since that one has a market some users don't want to see it gone.
There will definitely still some benefits from using the version 3 but will it outweigh the risks it involves by continuing to use that instead of the consensually used by most version 4? There will be new incentives by using version 4 and many might choose to change to that immediately.


Title: Re: How does a testnet netwok die?
Post by: pooya87 on September 26, 2024, 05:13:41 AM
The low block reward which means high cost of mining for no reward + the currently ongoing attack where blocks are being mined every second + the fact that the chain & UTXO set and even blockheaders file have gotten massive for a test network could result in its death.

By dropping the support for it, in the next versions of Bitcoin Core. Which means, that any new bugfixes and improvements simply won't happen on testnet3 anymore.
TestNet3 is not some separated altcoin to need specific bug fixes. It is pretty much MainNet with only 1 difference (as far as I can remember: 20 minute min diff fallback) when it comes to its consensus rules. Which means any changes, bug fixes, etc. that is done to bitcoin core affecting the MainNet will affect all other networks including TestNet3.

Has there been any announcement already for the version 4?
https://mempool.space/testnet4
The network has been active for a while and already 47k blocks mined on it.


Title: Re: How does a testnet netwok die?
Post by: NotATether on September 26, 2024, 05:46:33 AM
Quote
When will the version 3 die?
When users will stop using it (which may be never, if there is strong enough community to maintain it, as an altcoin).

Quote
And how will this happen?
By dropping the support for it, in the next versions of Bitcoin Core. Which means, that any new bugfixes and improvements simply won't happen on testnet3 anymore. It will be left as it is, without any changes. If some people will agree to become a new developers, then it may have a chance to live as an altcoin. But most likely it will die, because some people believe, that if something is not supported by Bitcoin Core, then it is not Bitcoin (which is not true, but if enough people believe in that, then the network will die quickly).

It is not possible to completely halt the operation of the network, but you can make enough people get off of it by doing what you said. But where will always be running old versions of nodes and not upgrading, so while the majority of nodes will be using the latest versions, a small few will stay behind for one reason or another.

I would disagree on the altcoin classification though.


Title: Re: How does a testnet netwok die?
Post by: ABCbits on September 26, 2024, 09:39:37 AM
Quote
And how will this happen?
By dropping the support for it, in the next versions of Bitcoin Core. Which means, that any new bugfixes and improvements simply won't happen on testnet3 anymore. It will be left as it is, without any changes. If some people will agree to become a new developers, then it may have a chance to live as an altcoin. But most likely it will die, because some people believe, that if something is not supported by Bitcoin Core, then it is not Bitcoin (which is not true, but if enough people believe in that, then the network will die quickly).

But it's worth to mention that,
1. Bitcoin Core isn't the only full node software which support testnet3 network.
2. People could continue using older version of Bitcoin Core which support testnet3.

the BTC client will have to support both Testnet3 and testnet4.

It's not how open-source software works. You can't force the developer to keep supporting certain feature, especially if you don't pay or sponsor them specifically for that reason.


Title: Re: How does a testnet netwok die?
Post by: vjudeu on September 26, 2024, 12:56:08 PM
Quote
Which means any changes, bug fixes, etc. that is done to bitcoin core affecting the MainNet will affect all other networks including TestNet3.
I don't think so. Timewarp protection is tested only in testnet4, and is not moved into testnet3. And future soft-forks also won't be ported. Which means, that if you have for example testnet3 in v28, and it will be removed in v29, then a few years later, you may have Bitcoin Core v40, while using testnet3 will require going back to v28.

Of course, it is possible to get the latest master, modify the code, and use it on testnet3. But: even if you do that now, then you basically fork yourself, by splitting the chain into those, who enforce ASIC-mined block, during difficulty adjustment, and between the old nodes, who don't have this rule. Testnet4 will have test cases, which will be present only there, and then ported into mainnet. And you won't get for example anchor support in testnet3.

So, the end result of testnet3, would be just like a lot of different altcoins, which were created before Segwit, or before Taproot, and which simply didn't activate any new rules, even if they could. To stay compatible, you need some group of developers. If you have none, then you can just stick with old versions, which will get more and more outdated over time, and where more and more attacks will be possible.

Quote
I would disagree on the altcoin classification though.
Why? Each test network creates its own chain, and is altcoin "by definition". If you want to have a test network, which would not be an altcoin, then it would need to follow the mainnet. For example: if you would have a testnet client, which would allow you to put some regtest-difficulty blocks on mainnet, if nothing is produced for 20 minutes, and then your block would always be reorged, then you would have a testnet, consisting of just some stale blocks with low difficulty. And then, you can really say: "start from block 123,456, mine something on top of that, test things, and then move on, just by downloading next blocks, and destroy all of your test coins in that way".

So, do you want to touch non-altcoin testnet? Then for example sign some mainnet coins, test your things, and then destroy test coins, when they will move on-chain. This is the simplest non-altcoin testnet I can think of. If you have non-mainnet coins, then you have an altcoin, no matter if you like it or not. You have new coins, created from scratch. And an alternative history, an alternative coin ownership, and altered consensus rules. This is the definition of the altcoin.


Title: Re: How does a testnet netwok die?
Post by: NotATether on September 26, 2024, 01:05:53 PM
Quote
I would disagree on the altcoin classification though.
Why? Each test network creates its own chain, and is altcoin "by definition". If you want to have a test network, which would not be an altcoin, then it would need to follow the mainnet. For example: if you would have a testnet client, which would allow you to put some regtest-difficulty blocks on mainnet, if nothing is produced for 20 minutes, and then your block would always be reorged, then you would have a testnet, consisting of just some stale blocks with low difficulty. And then, you can really say: "start from block 123,456, mine something on top of that, test things, and then move on, just by downloading next blocks, and destroy all of your test coins in that way".

So, do you want to touch non-altcoin testnet? Then for example sign some mainnet coins, test your things, and then destroy test coins, when they will move on-chain. This is the simplest non-altcoin testnet I can think of. If you have non-mainnet coins, then you have an altcoin, no matter if you like it or not. You have new coins, created from scratch. And an alternative history, an alternative coin ownership, and altered consensus rules. This is the definition of the altcoin.

Practically speaking, there are not enough changes made in (either) testnet to make it deviate sufficiently from mainnet to the point where people's software have to be rewritten.

If somebody picks up testnet3 and starts adding stuff to it by means of publishing a new client, and people pick up on it, then that would be generally accepted as an altcoin, but the way we're going now, it's just going to be abandoned. [Ironically just like most altcoin projects.]


Title: Re: How does a testnet netwok die?
Post by: garlonicon on September 26, 2024, 01:20:38 PM
Quote
there are not enough changes made in (either) testnet to make it deviate sufficiently from mainnet
We already had enough disruption in testnet4, to activate UASF, and use new timewarp rules: https://github.com/bitcoin/bitcoin/issues/30786

So, the differences are big enough, to split the chain. And if you apply testnet4 rules on testnet3, you will probably land on a different chain.

Even in testnet4, I landed on a different chain, just by mining blocks 20 hours in the future. The new ASIC block will resolve those issues, but it is easy to trigger CPU-based chainsplit.


Title: Re: How does a testnet netwok die?
Post by: seoincorporation on September 26, 2024, 01:34:47 PM
thanks for your answers, i really enjoy the topic.

Some important points to recap are the fact that the depreciation of Testnet 3 is in process, and the developers are in charge of this move. And if the users want to keep it alive they will have to run older versions of the Bitcoin Core.

But i don't think T3 will stay alive, maybe some users try it, but when they realize how they can't send their coins to other users then they will realize the waste of time and waste of resources.


Title: Re: How does a testnet netwok die?
Post by: Cricktor on September 27, 2024, 12:59:23 PM
i would answer "Because the is money involved in version 3", since that one has a market some users don't want to see it gone.
Well, this is the problem, that there are stupids that assign tBTC some value and establish a "market" for it. Testnet coins are not supposed to have a value. You kill the concept of an important testing playground almost identical to Mainnet by assigning some arbitrary value! Please, don't do and support this! I'm not addressing you in particular.

Ideally, anybody should've access to just enough tBTC and be able to do some testing (via faucets e.g.). If you're unfamiliar with a particular software or hardware wallet, play with it with tBTC. Practice anything, practice recovery without fear of loosing value. Would recommend it to everybody.

I don't know much about Testnet1 and Testnet2 and what exactly killed them. I just find it silly how much hashpower by single mining entities is thrown at Testnet3 and now also at Testnet4 already. I don't have high hopes for the longevity of Testnet4. Open for surprises...


Title: Re: How does a testnet netwok die?
Post by: pooya87 on September 28, 2024, 05:05:14 AM
Well, this is the problem, that there are stupids that assign tBTC some value and establish a "market" for it. Testnet coins are not supposed to have a value. You kill the concept of an important testing playground almost identical to Mainnet by assigning some arbitrary value!
I think it's just a matter of supply and demand. Of course there are a couple of reasons for tbtc gaining value (like the altcoins that used it for their airdrops) but the main reason is the supply and demand.

When I think about it, I see that over time it became increasingly harder to acquire tbtc. The block reward fell significantly due to it being farther ahead in halving cycles and hashrate grew (ASIC attacks) making it expensive to mine blocks. On top of that some faucets shut down, ran dry or gave out very tiny amounts (eg. 1000 satoshi). That creates a shortage so when a market is formed, the price can remain higher than it should be (eg 3000 sat per tbtc).

Otherwise if there were an abundance of it in circulation, it would have dumped the price to below 1 satoshi very quickly therefore would have killed that market quickly.


Title: Re: How does a testnet netwok die?
Post by: Wind_FURY on September 28, 2024, 06:25:15 AM

When will the version 3 die? And how will this happen?


In my personal opinion, when the majority of developers have migrated to Signet?

Plus who would continue testing their projects in Version 3 if they there are reliability issues. I didn't do any actual research on it, but a friend told be that it was attacked, and the attacker produced years worth of blocks with merely a small amount of resources?


Title: Re: How does a testnet netwok die?
Post by: NotATether on September 28, 2024, 06:50:05 AM
In my personal opinion, when the majority of developers have migrated to Signet?

Most tools out there still offer just mainnet and testnet options, so the migration is not going as fast as some people would like.

Quote
Plus who would continue testing their projects in Version 3 if they there are reliability issues. I didn't do any actual research on it, but a friend told be that it was attacked, and the attacker produced years worth of blocks with merely a small amount of resources?

That is called a 'griefing attack' and it was described by Jameson Lopp in one of his blog posts on his website.

Basically taking advantage of the fact that you can 'pre-mine' (I think that's the correct term) a bunch of blocks ahead of time, before their respective timestamps have arrived.


Title: Re: How does a testnet netwok die?
Post by: vjudeu on September 28, 2024, 10:24:27 AM
Quote
when the majority of developers have migrated to Signet?
Signet doesn't have decentralized mining. Only specific people can test mining, so only specific people will mine signet blocks. Everyone else will stick with testnet, just because of mining. For example, today I use testnet4, mainly because I can mine blocks there, so I can test some features, which are available, only if you are a miner.

Quote
Plus who would continue testing their projects in Version 3 if they there are reliability issues.
1. Those, who want to test fee-based block rewards. No other network than testnet3 has low enough basic block reward for that kind of tests.
2. CPU miners, who don't want to be stuck, after reaching difficulty adjustment (in testnet4, it is required to mine at least one ASIC block per each difficulty adjustment).

Quote
and the attacker produced years worth of blocks with merely a small amount of resources?
This is called "timewarp attack", and people are experimenting with testnet4 rules, to fix it. And when around 90% of blocks are mined by CPUs in testnet4, then we can clearly see, if timewarp protection is working correctly or not.

Quote
a bunch of blocks ahead of time, before their respective timestamps have arrived
Not only that. First, you mine blocks with future timestamps, and then, you mine some, with past timestamps. So, the time to mine 2016 blocks, is then decided by the miner, who can lower the difficulty, as much as desired. And because testnet has an option to reset the difficulty after 20 minutes, then it can be used to make the attack even stronger, than it would be on the mainnet.

Edit: If signet would be so good, then it wouldn't need that: https://delvingbitcoin.org/t/proof-of-work-based-signet-faucet/937


Title: Re: How does a testnet netwok die?
Post by: mikeywith on September 29, 2024, 10:18:19 AM
Depends on how you define "death", testnet3 is already dead to me. When you have stupid people (https://bitcointalk.org/index.php?topic=5489309.msg63821521#msg63821521) wanting to buy tens of thousands of testnet coins.

So the fact that no regular developer with a regular PC can mine on the blockchain makes it dead to me, people hammering it with top of the line gears made it unusable, even the stupid themselves can't use it now because even if you are using an S21s on it, your are still subject to infinite block reorgs caused by the other stupid people.

In fact, the irony with testnet3 is that block subsidy is now 0.00152 given that we are in block 3007923, so we are 142,077 blocks away from another halving, and yet, those spammers keep hammering the network, which is good so that they would stay away from testnet4, we are now at block 47853, while the first block was mined on 2024-05-04 so the average blocktime is roughly 4.5 mins which is great compared to the testnet3 average blocktime which is 2.5 mins, in fact it's even a lot less than than if you would just take the last 4-5 years data and ignore the early stages when people didn't screw the testnet.


Title: Re: How does a testnet netwok die?
Post by: Wind_FURY on September 29, 2024, 03:06:19 PM
Quote
when the majority of developers have migrated to Signet?
Signet doesn't have decentralized mining. Only specific people can test mining, so only specific people will mine signet blocks. Everyone else will stick with testnet, just because of mining. For example, today I use testnet4, mainly because I can mine blocks there, so I can test some features, which are available, only if you are a miner.

Quote
Plus who would continue testing their projects in Version 3 if they there are reliability issues.
1. Those, who want to test fee-based block rewards. No other network than testnet3 has low enough basic block reward for that kind of tests.
2. CPU miners, who don't want to be stuck, after reaching difficulty adjustment (in testnet4, it is required to mine at least one ASIC block per each difficulty adjustment).

Quote
and the attacker produced years worth of blocks with merely a small amount of resources?
This is called "timewarp attack", and people are experimenting with testnet4 rules, to fix it. And when around 90% of blocks are mined by CPUs in testnet4, then we can clearly see, if timewarp protection is working correctly or not.

Quote
a bunch of blocks ahead of time, before their respective timestamps have arrived
Not only that. First, you mine blocks with future timestamps, and then, you mine some, with past timestamps. So, the time to mine 2016 blocks, is then decided by the miner, who can lower the difficulty, as much as desired. And because testnet has an option to reset the difficulty after 20 minutes, then it can be used to make the attack even stronger, than it would be on the mainnet.

Edit: If signet would be so good, then it wouldn't need that: https://delvingbitcoin.org/t/proof-of-work-based-signet-faucet/937


Plus was Jameson Lopp's "time-warp attack" in that same situation when Ordinals developers were testing their projects in testnet 3? There were some people saying that the disruption was caused by an "Ordinals hater" and that he tried to stop the testnet to therefore also stop all Ordinals testing.

The "disruptor" might be a regular poster in BitcoinTalk.

https://cdn.imgchest.com/files/6yxkca3aae7.jpeg


Title: Re: How does a testnet netwok die?
Post by: vjudeu on September 29, 2024, 07:42:51 PM
Quote
Ordinals developers were testing their projects in testnet 3?
It is good, that Ordinals are in testnets, if that stops them from using mainnet. Testnet coins are worthless, so pushing data is the only thing you can do there. And if you also add non-standardness, then testnets are even better for Ordinals, because then, they can push their data easier, without some mainnet restrictions.

Quote
the disruption was caused by an "Ordinals hater"
No. It was all about timewarp testing. And using testnet3 was quite obvious, because you cannot use signet, if you don't have the private keys for signet challenge. For regtest, nobody would see your tests, so nobody would care. So, what other test network would you pick to test timewarp? As I said, some test cases require mining, and timewarp is one of them.

Quote
and that he tried to stop the testnet to therefore also stop all Ordinals testing
Even if there is a blockstorm, then you can still use a network, if you have a full node. Which is why if you check the latest block on mempool.space, then it can often show you some old block, hundreds of blocks behind, while your full node is up-to-date. Another thing is if there is any blockstorm, and someone requires for example 100 confirmations, then you can get it after around 15-20 seconds.

Also, as you can see, testnet3 blocks still contain a lot of Ordinals, so even if someone's end goal was to stop them, then it failed. Because if you make coins worthless by definition, then pushing data is the only thing, that is left, and testnet3 was used as a data pushing network, long before Ordinals.

Quote
testnet3 is already dead to me
Well, technically, it still works. And it will probably live as an altcoin, at least for a while. I will consider testnet3 "dead", if no peers will be there.

Meanwhile, testnet4 is going to achieve "one ASIC block per difficulty adjustment" state, so testnet4 chain can even "halt" for a while, if ASIC miners will turn their devices off, after they see the current difficulty. Also, testnet4 already had UASF, related to timewarp rules. So, it is alive, but unfinished, and miners may still switch into testnet3 for a while, if testnet4 will for example halt, when 99% blocks will be CPU-mined, and when everyone will wait into the next ASIC block (because consensus rules require at least one ASIC block per difficulty adjustment).

Quote
So the fact that no regular developer with a regular PC can mine on the blockchain makes it dead to me
Well, the code shared by Garlo Nicon, works on both testnet3 and testnet4. And also, testnet3 will never be "stuck", because you can push the whole chain forward, by just having a single CPU miner, while testnet4 will wait for the next ASIC block, because of the new timewarp rules.

Quote
even if you are using an S21s on it, your are still subject to infinite block reorgs caused by the other stupid people
Meanwhile in testnet4:
Code:
getchaintips
...
{
    "height": 47300,
    "hash": "00000000104ace9976e4d88537269fb24dbff9b6d4c24d43a4f5ea765a6c0c6e",
    "branchlen": 114,
    "status": "valid-fork"
},
...
When testnet4 network will be dominated by CPUs, and when 99% blocks will be mined by them, it will be normal to see a lot of reorgs, up to the 2016 block reorg, when some ASIC will come in, and pick the proper chain.

Quote
the irony with testnet3 is that block subsidy is now 0.00152
Test coins are worthless, so they can work as well with zero coins. As long as CPU mining works, you can mine a block or two every day, and do all tests you need. Also, as long as some people would want to test things, block rewards from fees would be sufficient. Another thing, is that eventually, the mainnet will also get there, so if low fees is a problem, then testnet3 is the best network to check, how people would react to any changes in that matter.


Title: Re: How does a testnet netwok die?
Post by: garlonicon on October 02, 2024, 08:58:23 PM
Quote
Meanwhile, testnet4 is going to achieve "one ASIC block per difficulty adjustment" state, so testnet4 chain can even "halt" for a while, if ASIC miners will turn their devices off, after they see the current difficulty.
Here we are. Testnet4 is now stuck on block number 48383: https://mempool.space/testnet4/block/00000000761cd6bff5e11258943e401e1bb094a8013e810e1d6031ce273a4b7c

Now, we are waiting for ASICs. Which means, that testnet4 may be resistant to timewarp attacks, but on the other hand, it is not resistant to being stuck, if only CPU miners will be there.

Edit: This time, someone pushed us forward: https://mempool.space/testnet4/block/000000000000000926c6550e123e4825ae9210bf79bb1efbc7af0d11e18a8b8a

However, it took around 4 hours (blocks were 2 hours in the future, and then, the actual time was put there). If nothing changes, it will take longer and longer, until the difficulty will start falling.


Title: Re: How does a testnet netwok die?
Post by: NotATether on October 03, 2024, 08:21:41 AM
Quote
Meanwhile, testnet4 is going to achieve "one ASIC block per difficulty adjustment" state, so testnet4 chain can even "halt" for a while, if ASIC miners will turn their devices off, after they see the current difficulty.
Here we are. Testnet4 is now stuck on block number 48383: https://mempool.space/testnet4/block/00000000761cd6bff5e11258943e401e1bb094a8013e810e1d6031ce273a4b7c

Now, we are waiting for ASICs. Which means, that testnet4 may be resistant to timewarp attacks, but on the other hand, it is not resistant to being stuck, if only CPU miners will be there.

Edit: This time, someone pushed us forward: https://mempool.space/testnet4/block/000000000000000926c6550e123e4825ae9210bf79bb1efbc7af0d11e18a8b8a

However, it took around 4 hours (blocks were 2 hours in the future, and then, the actual time was put there). If nothing changes, it will take longer and longer, until the difficulty will start falling.

How trivial is it to configure an ASIC to point it to a testnet mining pool? Or set one up that mines testnet4 block templates?


Title: Re: How does a testnet netwok die?
Post by: vjudeu on October 03, 2024, 10:16:15 AM
Quote
How trivial is it to configure an ASIC to point it to a testnet mining pool?
It is similar to mainnet configuration. You call "getblocktemplate", pass the result of that into your mining software, and then, your miner should submit the final block back into Bitcoin Core, which will propagate it into the whole network.
Code:
$ ./bitcoin-cli -testnet4 getblocktemplate '{"rules":["segwit"]}'
{
  "capabilities": [
    "proposal"
  ],
  "version": 536870912,
  "rules": [
    "csv",
    "!segwit",
    "taproot"
  ],
  "vbavailable": {
  },
  "vbrequired": 0,
  "previousblockhash": "00000000e4638c4e530c074a2703024445b8f3786c2b54f0977e67958f90bfe5",
  "transactions": [
    {
      "data": "02000000027ebb48a39075aaac83c831500dd7a16ff6801e65cc10b8a9df1708c7be99ea2f010000006a47304402201e5e09eca4236c171f40c536e1d3df9a5004386ce23d037405f46922c32eba4e0220346cb04655fbb64f2951691c78c077c7d482252023e9c330679749c15183bec90121035d3c761a498da64b60b19eca302ed3fc7de2cf387c43e28ff53eddfac751dd65fdffffff2aa29fa2fd6b1d97508e1fc4ecd6327c4265e3ecd9864a609e29db4fac70e0a6010000006a473044022042a8a8b5bd0ca68e28b8be39a196eef568a0f5871ad91acaa899b59d5f07251d0220217e86f84e845b491eda7022781f09efe4b3576f876af4c54e7679129146d0f101210265d606112603849e67670012a6a45b1f5d1e1860bbd52a3a0b5f3578f479c203fdffffff020ac203000000000017a9145ba02b1f091846fd46893b93ced478f1172cc63c8782b00b00000000001600145fa28881cb5b0764a6461a2dc849118143ee0d6548bd0000",
      "txid": "24e2fa9f084af2814fb8fe7eb57424c3822f9065df0c58d2efcc6f670bf22e1a",
      "hash": "24e2fa9f084af2814fb8fe7eb57424c3822f9065df0c58d2efcc6f670bf22e1a",
      "depends": [
      ],
      "fee": 5386,
      "sigops": 0,
      "weight": 1468
    },
    {
      "data": "02000000000101eea5f8f694506a9068858d2494748bbcd04c205a1d23dcebf028e41e6a3158a20100000000fdffffff022b0b000000000000160014306a4705f4554444b40bc852663faa0d18c643264ce90000000000001600144685d4c4dc66311f7828cb859e87138035b955fe0247304402203ed33ec2f600e9ff7ef5c2d5b57d21519756f3415f4fcf59858a94ba211b3786022030a76a74c41105e6a73bf50ad19306b4b8413c27b806ee78a7754f43d6efe77201210359ee745c5dde9692df29ef98894b6d87485d49031e24f830a7a5475ff9ae874b00000000",
      "txid": "b122f43a346be288bd2da4c470b798112b5ae5d5c5a090c375a5225917eef4de",
      "hash": "f4be9b8a7bbeed83994886c8985682ae0a09e838f29b23a4b45041d22e84c2e4",
      "depends": [
      ],
      "fee": 141,
      "sigops": 1,
      "weight": 561
    }
  ],
  "coinbaseaux": {
  },
  "coinbasevalue": 5000000000,
  "longpollid": "00000000e4638c4e530c074a2703024445b8f3786c2b54f0977e67958f90bfe5577",
  "target": "00000000ffff0000000000000000000000000000000000000000000000000000",
  "mintime": 1727952073,
  "mutable": [
    "time",
    "transactions",
    "prevblock"
  ],
  "noncerange": "00000000ffffffff",
  "sigoplimit": 80000,
  "sizelimit": 4000000,
  "weightlimit": 4000000,
  "curtime": 1727958156,
  "bits": "1d00ffff",
  "height": 48457,
  "default_witness_commitment": "6a24aa21a9ed5d6ff26aa2222eed24a58f76598eab0740a06f1a36325180bf2f5cc4b96a63d6"
}
And then, if you want to get CPU-mined block, you can just make sure, that Bitcoin Core will give you "1d00ffff". In other case, it is usually too difficult to mine on CPU (for example during difficulty adjustment), and then, it is usually a good idea to turn them off, and let them mine a single block, to push the chain forward.

Quote
Or set one up that mines testnet4 block templates?
If you want to do some CPU mining, then Bitcoin Core is the only thing you need. However, if you want to do ASIC mining instead, then embedding the code for mining into Bitcoin Core is probably not what you want. Because you probably don't want to rebuild Bitcoin Core, every time you improve your mining setup.

So, as you can see above, getblocktemplate command can give you everything you need. Then, the rest of your configuration is hardware-specific. The simplest case is to extract 80-byte block header, pass it to bitcoin-util, and then pass it back. This is what you can do on just a CPU. If you can do that, then you can use the same trick with any external tool, because usually, it just grinds a given 80-byte header (optionally, in case of stratum, it may also require a coinbase transaction, to grind the extra nonce).