Bitcoin Forum
June 23, 2024, 11:25:40 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Bug in Bitcoin Discovered by PMC Community - Altcoins Affected As Well  (Read 2633 times)
SlidingHorn (OP)
Full Member
***
Offline Offline

Activity: 196
Merit: 100

★Bitvest.io★ Play Plinko or Invest!


View Profile
March 01, 2014, 08:05:23 PM
 #1

Full Disclosure:  The blog is my own, so I'll link at the very bottom and put the TL/DR here:

Essentially there's a bug in Bitcoin that, after all coins are mined, will reset the block rewards to their original state at the beginning.  I was told this will occur at or around block 13,440,000.

I'm not a developer & I didn't find this bug; I'm just writing up on it so people can see and fix it. Smiley  Anyway, feel free to discuss - or just talk trash about me - below.  I know I have a lot of work to do on the blog itself, lol

http://www.ryblog.com/index.php?/archives/7-Did-PMC-Save-Bitcoin-Users-Billions.html

Johanakerblom
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
March 01, 2014, 08:54:33 PM
 #2

Well, i think every coin can never be mined because the reward halves every 4 year.

Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term

It states that new coins can be mined even in the year 2140.
Nullu
Hero Member
*****
Offline Offline

Activity: 532
Merit: 500


View Profile
March 01, 2014, 08:55:42 PM
 #3

This is a great find by the Premine community. Hopefully the word will get to Bitcoin developers so they can address the issue.

Because PMC is essentially how Bitcoin will look in the future, it's an excellent way to spot these issues down the road for Bitcoin.

BTC - 14kYyhhWZwSJFHAjNTtyhRVSu157nE92gF
odolvlobo
Legendary
*
Offline Offline

Activity: 4354
Merit: 3274



View Profile
March 01, 2014, 09:01:33 PM
 #4

Well, i think every coin can never be mined because the reward halves every 4 year.
Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term
It states that new coins can be mined even in the year 2140.

Johanakerblom, when the block reward is 1 satoshi and it is halved, it will go to 0 satoshis. No more bitcoins will be created at that point.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
CJYP
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
March 01, 2014, 09:06:21 PM
 #5

Well, i think every coin can never be mined because the reward halves every 4 year.

Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term

It states that new coins can be mined even in the year 2140.
If I'm understanding this correctly, the problem is that after a specific block, this will happen. So it's not when the reward is 0, It's when it's sufficiently close to 0.
SlidingHorn (OP)
Full Member
***
Offline Offline

Activity: 196
Merit: 100

★Bitvest.io★ Play Plinko or Invest!


View Profile
March 01, 2014, 09:07:38 PM
 #6

Well, i think every coin can never be mined because the reward halves every 4 year.

Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term

It states that new coins can be mined even in the year 2140.
If I'm understanding this correctly, the problem is that after a specific block, this will happen. So it's not when the reward is 0, It's when it's sufficiently close to 0.

This was the direct quote from my talk w/ the Premine DEV:

Quote
So the reward will be resetted (sic) at block 13440000, when the number of the block divided by 210000 will be 64

Johanakerblom
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
March 01, 2014, 09:09:09 PM
 #7

Well, i think every coin can never be mined because the reward halves every 4 year.
Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term
It states that new coins can be mined even in the year 2140.

Johanakerblom, when the block reward is 1 satoshi and it is halved, it will go to 0 satoshis. No more bitcoins will be created at that point.

I belive Satoshish are divisable.

I read this:

"The current level selected in the code (by Satoshi) is 8 decimal places (1 satoshi = 0.00000001 BTC) hence the nickname for the smallest unit currently possible for bitcoin today.

As a thought exercise, if a consensus of the network (miners, but also clients and server applications for compatibility reasons) decides to update to a version of the protocol that includes 16 decimal places inspired by your post, we could end up with a new base unit (1 satoshi = 100,000,000 gracchi) as well as nanobitcoins (nBTC), picobitcoins (pBTC), and even femtobitcoins (fBTC, 10 gracchi)"

Here:

http://bitcoin.stackexchange.com/questions/19661/how-is-bitcoin-infinitely-divisible
minerapia
Full Member
***
Offline Offline

Activity: 168
Merit: 100


View Profile
March 01, 2014, 09:14:52 PM
 #8

Yup, its compiler specific how operator ">>=" is implemented, so maybe lil bit more accurate defining is needed.

donations -> btc: 1M6yf45NskQxWXknkMTzQ8o6wShQcSY4EC
                   ltc: LeTpCd6cQL26Q1vjc9kJrTjjFMrPhrpv6j
odolvlobo
Legendary
*
Offline Offline

Activity: 4354
Merit: 3274



View Profile
March 01, 2014, 09:15:43 PM
Last edit: March 01, 2014, 09:29:28 PM by odolvlobo
 #9

Full Disclosure:  The blog is my own, so I'll link at the very bottom and put the TL/DR here:
Essentially there's a bug in Bitcoin that, after all coins are mined, will reset the block rewards to their original state at the beginning.  I was told this will occur at or around block 13,440,000.
I'm not a developer & I didn't find this bug; I'm just writing up on it so people can see and fix it. Smiley  Anyway, feel free to discuss - or just talk trash about me - below.  I know I have a lot of work to do on the blog itself, lol
http://www.ryblog.com/index.php?/archives/7-Did-PMC-Save-Bitcoin-Users-Billions.html

This is a known bug. It was discussed here: https://bitcointalk.org/index.php?topic=130614.0

Even though this bug was already found, the work by Premine is still appreciated.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Johanakerblom
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
March 01, 2014, 09:26:02 PM
 #10

I guess i was wrong, there will only ever be 20,999,999.999999999496 bitcoins.

Source: https://en.bitcoin.it/wiki/FAQ#How_long_will_it_take_to_generate_all_the_coins.3F
odolvlobo
Legendary
*
Offline Offline

Activity: 4354
Merit: 3274



View Profile
March 01, 2014, 09:26:50 PM
 #11

Well, i think every coin can never be mined because the reward halves every 4 year.
Check this out: https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term
It states that new coins can be mined even in the year 2140.
Johanakerblom, when the block reward is 1 satoshi and it is halved, it will go to 0 satoshis. No more bitcoins will be created at that point.
I belive Satoshish are divisable.
I read this:
"The current level selected in the code (by Satoshi) is 8 decimal places (1 satoshi = 0.00000001 BTC) hence the nickname for the smallest unit currently possible for bitcoin today.
As a thought exercise, if a consensus of the network (miners, but also clients and server applications for compatibility reasons) decides to update to a version of the protocol that includes 16 decimal places inspired by your post, we could end up with a new base unit (1 satoshi = 100,000,000 gracchi) as well as nanobitcoins (nBTC), picobitcoins (pBTC), and even femtobitcoins (fBTC, 10 gracchi)"
Here:
http://bitcoin.stackexchange.com/questions/19661/how-is-bitcoin-infinitely-divisible

The standard for computing the block reward is to use integral satoshis as the units. A block reward of less than a satoshi is not currently possible.

In the current bitcoin standard, the satoshi is the smallest unit and cannot be sub-divided. Amounts are stored as satoshis in integer form in the block chain and elsewhere. It is possible to change this standard in the future, but changing the computation of the block reward would be a separate change.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
RWatts
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
March 01, 2014, 09:32:14 PM
 #12

Title is a little alarmist. The bug is not really a problem right now. We don't know if Bitcoin is going to be here 2 years from now, let alone when the block reward gets to zero in a hundred years.
alexeft
Legendary
*
Offline Offline

Activity: 854
Merit: 1000


View Profile
March 01, 2014, 09:37:52 PM
 #13

Title is a little alarmist. The bug is not really a problem right now. We don't know if Bitcoin is going to be here 2 years from now, let alone when the block reward gets to zero in a hundred years.


Indeed, very title, much scary!!!  Tongue

Actually, the problem will occur in 140 years!!!
Skybuck
Full Member
***
Offline Offline

Activity: 384
Merit: 110


View Profile
March 01, 2014, 09:49:22 PM
Last edit: March 01, 2014, 10:15:06 PM by Skybuck
 #14

(from older bitcoin code: bitcoin-0.5.1-win32-original):

main.cpp

int64 static GetBlockValue(int nHeight, int64 nFees)
{
    int64 nSubsidy = 50 * COIN;

    // Subsidy is cut in half every 4 years
    nSubsidy >>= (nHeight / 210000);

    return nSubsidy + nFees;
}

(from newest bitcoin code: 1 march 2014):

int64_t GetBlockValue(int nHeight, int64_t nFees)
{    
   int64_t nSubsidy = 50 * COIN;    
   
   // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.    
   nSubsidy >>= (nHeight / Params().SubsidyHalvingInterval());    
   
   return nSubsidy + nFees;
}


So code seems to be something like:

Reward = Reward >> SomeValue; // de-obfuscated Smiley

What will happen depends on how this will be compiled to instructions and how those instructions behave.

For now x86 and x64/amd64 is popular so a good guess is intel's instruction manual.

Two possible instructions are likely chosen by a C compiler:

1. shld
2. shr

shld may produce undefined results so the reward could be even higher than the default.

however shr is probably chosen by compilers, and shld will probably also behave as if the shift value was masked.

And that is what happens for both instructions, the shift value is masked by 5 bits or 6 bits all being 1's depending on if it's 32 bit or 64 bit mode.

However I think bitcoin is probably compiled to run on 32 bit operating systems as well, which might mean that shld was used or perhaps some compiler specific 64 bit software implementation of shr.

One would have to look at the instructions generated for this specific function to be sure what's going to happen... but since it was tested... we kinda know.

Theoretically at least the shifter is wrapping back as follows:

64 mod 64 = 0  so no shift happens.

Which is the same as
64 and 111111b  

This explains the reward of 50 * COIN

So to calculate when this wrap around of the shift value would happen requires this to be solved:

nHeight / 210000 = 64

which leads to:

nHeight = 64 * 210000

which gives:

13440000

^ the block count/number mentioned.

nHeight is probably the block number and each block is generated every 10 minutes.

The 210k is not exactly 4 years so that a bit sloppy.

Anyway one year is: 365.25 * 24 * 60 / 10 = 52596 blocks.

So this block number will be reached from genesis at:

13440000 / 52596 = 255.5 years.

4 years is: 210384

Perhaps 210k was chosen a bit sloppy to offset that blocks are found a bit faster than 10 minutes, probably not the reason though... just sloppy.

In reality this block number will be reached a bit faster probably because of investments in new hardware and so forth... though nobody can predict the future lol.

Now for some interesting questions... how to fix this ?

There are supposed to be only 21 million coins or something... so that means:

21.000.000 / 50 = 420000 blocks. though... the number of blocks will be much higher because rewards will be cut in half and so forth... each 4 years...

So this makes it a bit more difficult but still kinda easy to calculate:

First 210k blocks: 50 coins
Second 210k blocks: 25 coins
Third 210k blocks: 12.5 coins
Fourth 210k blocks:  6.25 coins
Fiveth 210k blocks: 3.125 coins
Sixth 210k blocks: 1.5625 coins.

So let's start:
210.000 x 50 = 21000000 - 10500000 = 10500000
210.000 x 25 = 10500000 - 5250000 = 5250000
210.000 x 12.5 = 5250000 - 2625000 = 2625000
210.000 x 6.25 = 2625000 - 1312500 = 1312500
and so forth...

So what we need to calculate now is the number of times this 21m number can be halved.

Which is log10(21m) / log10(2) = 24.323885992102934376117624838116

So that's roughly:
24.32 * 210k blocks = 5108016.0583416162189847012160044 blocks.

5.1m blocks will be mined and then the rewards should go to zero.

Putting this back into the function gives:

5108016.0583416162189847012160044 / 210000 = 24.323885992102934376117624838116

The shift value of 24 is therefore well in range of the 0 to 31 or 63 bit value range.

However... just because no more rewards are given out doesn't actually stop the block number from going up...
blocks will still be mined just no more rewards given... so that is indeed a bit of a problem.

After 255 years... a bit of a lol there... suddenly rewards would be given out which would be funny... or perhaps even unspecified ammounts of rewards.

Anyway a simple sloppy fix could be something like:

if nHeight <= 5109017 then
  // calculate reward
else
  // no reward.

I am not sure about that fractional part Wink

So just to be fair to whoever mines it last... perhaps one extra block for you... perhaps max will be slightly over 21m or slightly under depending on what you guys would want.
if it must stay under 21m then:

if nHeight <= 5109016 then
  // calculate reward
else
  // no reward.

So from this little inspection there does seem to be a little problem with bitcoin... it won't actually produce 21m bitcoins exactly... but something near it... unless it's somehow solved to give that tiny little fraction to the last block or so... or perhaps it will fit perfect by chance/rounding me not sure... would be nice if someone investigates that further just for the fun of it Smiley

However the future is not certain... perhaps 10 or 20 years from now intel is dead and this code might behave totally different Smiley

Or how about this for something really cool:

if nHeight <= 5109016 then
  // calculate reward
if nHeight = 5109017 then
  // calculate bitcoins remaining of that 21m and give it to the last block, risky but cool Smiley (if calculation fucks up that would be one wealthy block Smiley)
  // probably safest to perform this calculation offline and just put a constant here or so Smiley
else
  // no reward.

I also wonder if old clients that may be used by then would be exploiteable... perhaps they would assume rewards were given out... perhaps there are other checks in bitcoin or perhaps not...

Would be fun for those future programmers/hackers to exploit old clients like that bihihi... some old clients would then maybe accept payments from those blocks Wink

Perhaps some bitcoin vending machines/atms/hardware.. though commercial interests would probably update those... though bitcoin hardware still a good guess... stuffed away somewhere in some bank Smiley

Bye,
  Skybuck.
odolvlobo
Legendary
*
Offline Offline

Activity: 4354
Merit: 3274



View Profile
March 01, 2014, 09:50:16 PM
 #15

Title is a little alarmist. The bug is not really a problem right now. We don't know if Bitcoin is going to be here 2 years from now, let alone when the block reward gets to zero in a hundred years.
Indeed, very title, much scary!!!  Tongue
Actually, the problem will occur in 140 years!!!

The problem occurs when the block reward has been halved 63 or 64 times (including after the reward is already 0). That won't happen for another 200 to 250 years.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Gabi
Legendary
*
Offline Offline

Activity: 1148
Merit: 1008


If you want to walk on water, get out of the boat


View Profile
March 01, 2014, 09:57:50 PM
 #16

Better to fix it today than waiting 200 years and having the whole United Federation of Planets update every client on every planet and every spaceship

alexeft
Legendary
*
Offline Offline

Activity: 854
Merit: 1000


View Profile
March 01, 2014, 10:14:58 PM
 #17

Better to fix it today than waiting 200 years and having the whole United Federation of Planets update every client on every planet and every spaceship


 Cheesy Cheesy Cheesy
serje
Legendary
*
Offline Offline

Activity: 1232
Merit: 1002



View Profile
March 01, 2014, 10:19:20 PM
 #18

Better to fix it today than waiting 200 years and having the whole United Federation of Planets update every client on every planet and every spaceship


 Cheesy Cheesy Cheesy

If we reach that point we won't need new coins because the block will have a pretty big value from fees!

Space for rent if its still trending
alexeft
Legendary
*
Offline Offline

Activity: 854
Merit: 1000


View Profile
March 01, 2014, 10:26:00 PM
 #19

Better to fix it today than waiting 200 years and having the whole United Federation of Planets update every client on every planet and every spaceship


 Cheesy Cheesy Cheesy

If we reach that point we won't need new coins because the block will have a pretty big value from fees!

Ok people, let's speculate what the price will be at that point!

I say $1.000.000.000.000.000 per !
serje
Legendary
*
Offline Offline

Activity: 1232
Merit: 1002



View Profile
March 01, 2014, 10:27:33 PM
 #20

Better to fix it today than waiting 200 years and having the whole United Federation of Planets update every client on every planet and every spaceship


 Cheesy Cheesy Cheesy

If we reach that point we won't need new coins because the block will have a pretty big value from fees!

Ok people, let's speculate what the price will be at that point!

I say $1.000.000.000.000.000 per gracchi!

Corrected it for you! no thanks necessary!

Space for rent if its still trending
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!