Bitcoin Forum

Bitcoin => Mining => Topic started by: Bobcat on January 06, 2012, 07:57:46 PM



Title: Miners work together to keep the difficulty low
Post by: Bobcat on January 06, 2012, 07:57:46 PM
I have been monitor the difficulty for the past few weeks thru allchains.info and I noticed that the dif change base on the total GH on the btc network

Two week ago: total btc GH ~7000+ and the the est next dif about  -5%
Last week: total btc GH ~ 8000 and the est next dif about  +2%
This week: total btc GH ~10000+ and the est next dif about  +26%  which is about 1464931.53474


As you can see the more GH in the network increase the more dif will increase till the next cycle in (1d 20hr). So I am thinking if miners stop mining an hour or two before the the next cycle start, it will drop the GH that and the dif will drop and remain for another 10 day till the next cycle start again, Once the dif drop and miner can start mine again.

I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

What do you guys think ?


Title: Re: Miners work together to keep the difficulty low
Post by: DeepBit on January 06, 2012, 08:02:48 PM
So I am thinking if miners stop mining an hour or two before the the next cycle start, it will drop the GH that and the dif will drop and remain for another 10 day till the next cycle start again, Once the dif drop and miner can start mine again.
I wonder why so many people think of this method.
1. No, miner's won't stop mining.
2. An hour or two won't make difference because measurement window is 2 weeks.


Title: Re: Miners work together to keep the difficulty low
Post by: DeathAndTaxes on January 06, 2012, 08:21:36 PM
Even assuming you could get all miners to agree (which you can't) why would I want to lose 1 hour of revenue?
Even if it cost me nothing I wouldn't try and halt all economic activity for a couple hours.

Quote
I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

Difficulty change is based on the how long it took to complete the last 2016 blocks.  On average it will take 20,160 minutes or 336 hours.  If it takes less then difficulty rises by the amount necessary to increase time to 20,160 minutes.  If it takes more time then difficulty falls by the amount necessary to reduce time to 20,160 minutes.


Title: Re: Miners work together to keep the difficulty low
Post by: Bobcat on January 06, 2012, 08:40:25 PM
Even assuming you could get all miners to agree (which you can't) why would I want to lose 1 hour of revenue?
Even if it cost me nothing I wouldn't try and halt all economic activity for a couple hours.

Quote
I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

Difficulty change is based on the how long it took to complete the last 2016 blocks.  On average it will take 20,160 minutes or 336 hours.  If it takes less then difficulty rises by the amount necessary to increase time to 20,160 minutes.  If it takes more time then difficulty falls by the amount necessary to reduce time to 20,160 minutes.

Yes your explaination make sense.
Obviously, I not clear how the dif calculation work, I thought when the dif change it looks at the current network hash rate then do its calculation.


Title: Re: Miners work together to keep the difficulty low
Post by: DeathAndTaxes on January 06, 2012, 08:50:24 PM
Even assuming you could get all miners to agree (which you can't) why would I want to lose 1 hour of revenue?
Even if it cost me nothing I wouldn't try and halt all economic activity for a couple hours.

Quote
I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

Difficulty change is based on the how long it took to complete the last 2016 blocks.  On average it will take 20,160 minutes or 336 hours.  If it takes less then difficulty rises by the amount necessary to increase time to 20,160 minutes.  If it takes more time then difficulty falls by the amount necessary to reduce time to 20,160 minutes.

Yes your explaination make sense.
Obviously, I not clear how the dif calculation work, I thought when the dif change it looks at the current network hash rate then do its calculation.

Yeah you got to watch those online difficulty estimators.  They are simply guestimating what the difficulty will be based on historical hashrate and projecting out current hashrate.  Also remember hashrate is not known.  Estimators are using prior block times to make an estimate of the hashrate.  So if the network gets "lucky" and solves 5 blocks 10% quicker than normal the estimators will think the network has a 10% higher hashrate.

I have found this estimator (namecoin & bitcoin) to be one of the best.
http://dot-bit.org/tools/nextDifficulty.php

Looks like it is predicting a 8% rise in difficulty to ~1.25M


Title: Re: Miners work together to keep the difficulty low
Post by: gmaxwell on January 07, 2012, 02:37:56 AM
I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

What do you guys think ?


The difficulty algorithm is linear (well, except for the clamps at 1/4 and 4x). Assuming constant mining power, this means speedup next cycle plus the slowdown on the cycle after it would only match the work not done on this cycle. You come out the same.  And someone defecting from the voluntary slowdown would make more (they'd still get the benefit of whatever shift the slowdown did achieve, plus they'd mine during the 'down' time).



Title: Re: Miners work together to keep the difficulty low
Post by: sharky112065 on January 07, 2012, 06:58:45 AM
I have been monitor the difficulty for the past few weeks thru allchains.info and I noticed that the dif change base on the total GH on the btc network

Two week ago: total btc GH ~7000+ and the the est next dif about  -5%
Last week: total btc GH ~ 8000 and the est next dif about  +2%
This week: total btc GH ~10000+ and the est next dif about  +26%  which is about 1464931.53474


As you can see the more GH in the network increase the more dif will increase till the next cycle in (1d 20hr). So I am thinking if miners stop mining an hour or two before the the next cycle start, it will drop the GH that and the dif will drop and remain for another 10 day till the next cycle start again, Once the dif drop and miner can start mine again.

I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

What do you guys think ?


The difficulty increase will not be +26%. Allchains.info was reset so, the displayed increase will not be what we will see when it actually increases.


Title: Re: Miners work together to keep the difficulty low
Post by: Costia on January 21, 2012, 10:48:02 PM
I dont know how the calculation work of the dif change, but so far base on what i have seen if we can maintain the GH around 7000-8000 before the dif change cycle then the dif should stay around 1 milllion.

What do you guys think ?


The difficulty algorithm is linear (well, except for the clamps at 1/4 and 4x). Assuming constant mining power, this means speedup next cycle plus the slowdown on the cycle after it would only match the work not done on this cycle. You come out the same.  And someone defecting from the voluntary slowdown would make more (they'd still get the benefit of whatever shift the slowdown did achieve, plus they'd mine during the 'down' time).


but you can hop chain blocks and make money mining an alt coin while waiting for the bitcoin difficulty to drop for 2 weeks
the main problem is coordination between miners - but if a few of the largest pools unite they might actually be able to do that
But i am still not sure if its profitable
if the hashrate drops to 1THash/sec for 2 weeks, will the difficulty drop by a factor of the for the whole next 2 weeks? i.e. will a block will be generated every minute for 2 weeks if a day after the difficulty change the hashrate jumps to 10Thash/s? (meaning a step function is not linear)


Title: Re: Miners work together to keep the difficulty low
Post by: Costia on January 21, 2012, 11:48:38 PM
What I was/am missing is the formula that says how the next target is calculated.
I tried the wiki but didnt find it :(
did you take the calculation from the source code?


Title: Re: Miners work together to keep the difficulty low
Post by: Meni Rosenfeld on January 22, 2012, 06:10:24 AM
What I was/am missing is the formula that says how the next target is calculated.
I tried the wiki but didnt find it :(
did you take the calculation from the source code?
N = New difficulty (at block 2016N)
O = Old difficulty
T2 = timestamp of block 2016N - 1
T1 = timestamp of block 2016N - 2016
N = O * (2 weeks) / (T2-T1)

Of course, in actuality the calculation is based on target, new target = old * (T2-T1) / (2 weeks) and the difficulty derives from it. I didn't see the code for this but I'm guessing first an integer division by 1209600 (seconds in two weeks) is done and then the multiplication. There's also the [1/4, 4] limit.

There's actually a bug in this calculation, it should have used T1 = timestamp of block 2016N - 2017, and this bug makes possible a form of attack. But at this point it is considered not worth correcting it.

It's supposed to be explained at https://en.bitcoin.it/wiki/Difficulty#What_network_hash_rate_results_in_a_given_difficulty.3F but maybe it's not very explicit. Also see http://bitcoin.stackexchange.com/questions/855/what-keeps-the-average-block-time-at-10-minutes.

EDIT: Here's the relevant piece of code (from main.cpp). It appears the bignum used can handle doing the multiplication first and then division:
Code:
static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
static const int64 nTargetSpacing = 10 * 60;
static const int64 nInterval = nTargetTimespan / nTargetSpacing;

...

    // Go back by what we want to be 14 days worth of blocks
    const CBlockIndex* pindexFirst = pindexLast;
    for (int i = 0; pindexFirst && i < nInterval-1; i++)
        pindexFirst = pindexFirst->pprev;
    assert(pindexFirst);

    // Limit adjustment step
    int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
    printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
    if (nActualTimespan < nTargetTimespan/4)
        nActualTimespan = nTargetTimespan/4;
    if (nActualTimespan > nTargetTimespan*4)
        nActualTimespan = nTargetTimespan*4;

    // Retarget
    CBigNum bnNew;
    bnNew.SetCompact(pindexLast->nBits);
    bnNew *= nActualTimespan;
    bnNew /= nTargetTimespan;


Title: Re: Miners work together to keep the difficulty low
Post by: Costia on January 22, 2012, 06:34:32 AM
thanks.
so this is impossible
the decay is much slower than the rising of the difficulty

I cant think of an attack that can exploit the -2016 instead of -2017, its just a 1 block index
since the actual rate is random there always might be shared blocks in 2 adjacent 2 week estimates
there are way more than 2017 blocks - so no negative numbers\overflows
If an attack wanted to delay a block it wont matter much either
I would actually move it 120 blocks back to -121 and -2137 - so only confirmed blocks are used
only thing is if the total hashrate is constant - the difficulty will slowly drift up(?)


Title: Re: Miners work together to keep the difficulty low
Post by: film2240 on January 23, 2012, 02:50:38 PM
I'd like to see difficulty drop again soon unless someone can help me reach above 400MHash/s on my HD6950 to eek out the most performance out of it (probably best to direct me to a thread that covers this already).

I think that we should work together to force difficulty to drop again when the trends show rises in difficulty.


Title: Re: Miners work together to keep the difficulty low
Post by: DeathAndTaxes on January 23, 2012, 05:25:33 PM
I'd like to see difficulty drop again soon unless someone can help me reach above 400MHash/s on my HD6950 to eek out the most performance out of it (probably best to direct me to a thread that covers this already).

I think that we should work together to force difficulty to drop again when the trends show rises in difficulty.

There is no working together.  We all share the same pie.  If you drop out well that is a bigger slice for me. :)

Gimmicks and half baked ideas of "cheating" the protocol don't address the reality that mining is a zero sum competitive game.


Title: Re: Miners work together to keep the difficulty low
Post by: Meni Rosenfeld on January 23, 2012, 05:34:43 PM
I'd like to see difficulty drop again soon unless someone can help me reach above 400MHash/s on my HD6950 to eek out the most performance out of it (probably best to direct me to a thread that covers this already).

I think that we should work together to force difficulty to drop again when the trends show rises in difficulty.

There is no working together.  We all share the same pie.  If you drop out well that is a bigger slice for me. :)

Gimmicks and half baked ideas of "cheating" the protocol don't address the reality that mining is a zero sum competitive game.
I don't know why I didn't mention this earlier given the topic of the OP. But the attack that involves the off-by-one bug in the difficulty adjustment is one where someone with >50% of the hashrate can mess with the timestamps to artificially decrease the difficulty, so instead of generating the total prescribed 7200 BTC per day, they are generated much more rapidly. So if all miners collude, they can game the system to increase the pie.

But you wouldn't do that, right? :)

See also ArtForz's original post about the attack (https://bitcointalk.org/index.php?topic=43692.msg521772#msg521772) and this StackExchange question (http://bitcoin.stackexchange.com/questions/1511/gaming-the-off-by-one-bug-difficulty-re-target-based-on-2015-instead-of-2016/1588#1588).


Title: Re: Miners work together to keep the difficulty low
Post by: Brunic on January 23, 2012, 05:50:40 PM
Quote
I'd like to see difficulty drop again soon unless someone can help me reach above 400MHash/s on my HD6950 to eek out the most performance out of it (probably best to direct me to a thread that covers this already).

400 MHash? You're going to kill your card. I've got 6 of them, and the max I went was 380 MHash before I was afraid of blowing it up.


Quote
I think that we should work together to force difficulty to drop again when the trends show rises in difficulty.

The only way to drop it is to quit the market. If you find a way to convince miners who invested thousand of dollars in mining equipment to quit the market, go for it.