Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Gavin Andresen on January 30, 2011, 06:25:56 PM



Title: [RFC] Testnet reset
Post by: Gavin Andresen on January 30, 2011, 06:25:56 PM
Difficulty on the -testnet is annoyingly high.   I propose resetting the -testnet with a new genesis block, and changing the -testnet rules for difficulty adjustment as follows:

1. Adjust difficulty on the testnet every 126 blocks (1/16'th the regular net adjustment).
2. Keep the "difficulty can adjust up at most *4", but remove the limit on how quickly difficulty can adjust down.  Minimal difficulty would remain the same.

Unless I hear howls of protest or better ideas, I'll generate a genesis block and submit a pull request with the changes.  I won't switch the -testnet faucet to the new chain until we've got 0.3.20 release candidate builds out.


Title: Re: [RFC] Testnet reset
Post by: slush on January 30, 2011, 06:29:05 PM
I absolutely agree, those rules will make testnet more useful for software testing.


Title: Re: [RFC] Testnet reset
Post by: jgarzik on January 30, 2011, 06:42:35 PM
+1 agreed


Title: Re: [RFC] Testnet reset
Post by: davout on January 30, 2011, 08:41:56 PM
Yea, that's nice, but will we reset the main network the day someone pulls the same trick on it ?


Title: Re: [RFC] Testnet reset
Post by: Gavin Andresen on January 31, 2011, 01:07:31 AM
Yea, that's nice, but will we reset the main network the day someone pulls the same trick on it ?

No, if necessary we'd change the difficulty adjustment rules and make the code:

if (current block is > some_number)
  ... new rules for adjusting difficulty
else
  ... old rules for adjusting difficulty

I could have done that and kept the testnet block chain, but it is cleaner to just reset it with new rules.

And "pulling the same trick" means throwing an overwhelmingly massive amount of hashing power at the main network (like 16 times the current overall hashing power) for a significant amount of time, which is getting increasingly hard to do.


Title: Re: [RFC] Testnet reset
Post by: Gavin Andresen on January 31, 2011, 02:32:00 PM
Patch/pull request is:
  https://github.com/bitcoin/bitcoin/pull/53



Title: Re: [RFC] Testnet reset
Post by: Cdecker on January 31, 2011, 10:16:31 PM
Great work ^^
We do not need to be concerned too much about adjusting the testnet difficulty since it's all throw away anyway :-)


Title: Re: [RFC] Testnet reset
Post by: davout on February 01, 2011, 12:31:29 AM
Well, I think it's kind of weird to have different rules for testnet than main net...
Usually, a staging environment is kept as close as possible to the production one.

Resetting it is not a bad thing per se, having different rules for each net is definitely not a good thing IMO. What if tomorrow we decide that testnet should have extra X, Y and Z features because it's more "convenient" ?

Maybe the lessons learned with the overtaking of test net should be applied to main net too, if one individual took test net over, what can an organization do ? And how can we anticipate that ?

What I vote for is the following :
 - reset testnet with the same rules than main net,
 - commit to the fact that the only difference between main and test are the port and the genesis block,
 - anticipate a way to deal with main net being overtaken by someone who decided it was worth doing it

A simple solution I can think of :
 - If no block has been generated for 24h,, 48h or whatever divide difficulty by 2

I don't think that :
 - accepting that main and test have different rules,
 - not anticipating this particular kind of attack
is a good thing.


Title: Re: [RFC] Testnet reset
Post by: slush on February 01, 2011, 12:58:55 AM
A simple solution I can think of :
 - If no block has been generated for 24h,, 48h or whatever divide difficulty by 2

...which doesn't solve current problem with testnet. Testnet difficulty is not insanely high, it is still possible to mine a block with a decent hardware in a hour or so. But it is too high to effective testing some software, where you need many blocks to pass all tests.

I see your point and partially agree. Some better algorithm to lower difficulty should be adopter both to testnet and main net. But for current situation, changes which Gavin proposed are fine for me.


Title: Re: [RFC] Testnet reset
Post by: Anonymous on February 01, 2011, 01:17:07 AM
If the testnet is a clone of bitcoin completely it could be a backup block chain in case of disaster. Might be good to have a separate network there just in case ,although the same thing could happen with a weaker network as happened to the first test network.


Is it possible to create a version of bitcoin you can run on lots of virtual machines that simulates the real network?

Bitcoin test network in a sandbox.





Title: Re: [RFC] Testnet reset
Post by: nanotube on February 01, 2011, 06:43:09 AM
Yea, that's nice, but will we reset the main network the day someone pulls the same trick on it ?

No, if necessary we'd change the difficulty adjustment rules and make the code:

if (current block is > some_number)
  ... new rules for adjusting difficulty
else
  ... old rules for adjusting difficulty

I could have done that and kept the testnet block chain, but it is cleaner to just reset it with new rules.

And "pulling the same trick" means throwing an overwhelmingly massive amount of hashing power at the main network (like 16 times the current overall hashing power) for a significant amount of time, which is getting increasingly hard to do.


i for one would prefer this approach to completely restarting the chain.


Title: Re: [RFC] Testnet reset
Post by: ribuck on February 01, 2011, 10:48:58 AM
Keep testnet as close as possible to the live system. It will sort itself out in a few weeks.

Create an additional block chain for those whose development needs require something other than what testnet provides.


Title: Re: [RFC] Testnet reset
Post by: davout on February 01, 2011, 10:54:31 AM
I think that resetting testnet once in a while is a good thing, it will mean resetting the difficulty too, so specific difficulty rules for testnet are not only useless but adding complexity and prone to introducing bugs (this (https://github.com/gavinandresen/bitcoin-git/commit/e948fa446e80045306a05a55553311de019aaab9) for example)


Title: Re: [RFC] Testnet reset
Post by: Gavin Andresen on February 02, 2011, 02:56:54 PM
Keep testnet as close as possible to the live system. It will sort itself out in a few weeks.

Create an additional block chain for those whose development needs require something other than what testnet provides.

No, it won't sort itself out "after a few weeks".  Let me see if I can do a back-of-the-envelope:

Difficulty on testnet currently at 373.  We want it no higher than, oh, 5, so with the typical 3-or-4 machines CPU-hashing on testnet generate a block in a reasonable amount of time.

So we generate 2016 blocks over 8 weeks.  That cuts difficulty by four: ~90
Then do it again: ~22
and again... ~5  SIX MONTHS later

That's optimistically assuming we can find people to cooperate to contribute hashing power to generate 2016 blocks at difficulty 300 in 8 weeks or less.

If you'd like to continue using the old testnet chain, be my guest.

I'm sympathetic to the "testnet and main net should have the same rules", but the truth is the testnet has, and always will have, many fewer people hashing on it.

Changing the main net downard-difficulty-adjustment code might make sense, but that's the topic for another thread.  Allowing main net difficulty to adjust all the way from 22,000 to 1 isn't the right answer (it makes sybil attacks where an attacker feeds you a bogus version of the block chain much easier).


Title: Re: [RFC] Testnet reset
Post by: davout on February 02, 2011, 03:03:32 PM
I'm sympathetic to the "testnet and main net should have the same rules", but the truth is the testnet has, and always will have, many fewer people hashing on it.
Let's make it a policy to reset testnet every month/release/whatever.
Problem solved, same rules for both, difficulty will stay really low since no one will want to mine for TBTC since it will be clear they will never be valuable.


Title: Re: [RFC] Testnet reset
Post by: davout on February 02, 2011, 05:32:06 PM
Why change the difficulty at all on the testnet?

Why not just keep it at 1 permanently? If we make it change every every 126 blocks, someone with a GPU could screw everyone with the difficulty change quickly, and then it takes 126 blocks for it to get back down (which could be a week or more)
The point of testnet is to make tests that are significant and reproductible on main net, if the two have different rules you might as well not test anything

What's so bad about changing the real network every 126 blocks too?
good question




Title: Re: [RFC] Testnet reset
Post by: lfm on February 03, 2011, 12:04:54 PM
If testnet has different rules it looses some of its value as a testbed since you are not testing the production rules any more.


Title: Re: [RFC] Testnet reset
Post by: davout on February 03, 2011, 01:23:52 PM
If testnet has different rules it looses some of its value as a testbed since you are not testing the production rules any more.
Yes.

From what I understand, there are two different things testnet is used for testing generation -> you need low difficulty in order to make testing easy, testnet also has to have the same rules than main net, otherwise tests can't be very meaningful.

If you need some long running tests, you might as well test with a couple of main net coins.

I don't mind doing the coding associated with this task once in a while when difficulty makes testing harder.
Patch is here (https://github.com/bitcoin/bitcoin/pull/57)


Title: Re: [RFC] Testnet reset
Post by: LZ on February 04, 2011, 12:58:50 AM
What about to use multiple chains with different rules?
Code:
-testnet=0
-testnet=1
-testnet=n


Title: Re: [RFC] Testnet reset
Post by: davout on February 04, 2011, 08:59:59 AM
Maybe the best would be to clearly document how to setup a different testnet.
I'll document what I did to reset the current test net, let's start from there.