Bitcoin Forum
May 10, 2024, 04:57:06 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: A Possible Explanation on the BTC Withdrawal Delays at MtGox  (Read 1731 times)
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
January 29, 2014, 10:44:59 AM
Last edit: January 29, 2014, 03:24:29 PM by thecomputerscientist
 #1

Myself, and many others I know, know that BTC withdrawals from MtGox can get stuck. It appears to be quite random. You can withdraw 10 BTC just fine (they immediately show up in blockchain) and when you withdraw another 10 BTC they get stuck in limbo. So what the heck is going on?  Well, I _think_ I know the answer, but it is going to be quite technical.

Most Bitcoin exchange software is based on the original software (Github bitcoin.org). I bet this includes MtGox. It is quite complicated to write a client from scratch and whenever changes are made on the main trunk, you want to be able to merge those changes into your own custom branch. This is the reason why most people use the original client as a starting point.

The first thing you need to do with the original client is to replace the wallet code. That code isn't well suited for a full blown exchange/wallet because it uses a rather primitive database. Most companies want to use SQL or MongoDB to store their wallets in. Therefore, you basically replace most of the code in wallet.cpp with a custom version.

In the original client the wallet code is quite robust. All the transactions to/from the wallet are guarded by mutex code so that no race conditions can occur. For those with programming skills can take a look at CWallet::CreateTransaction and see "LOCK2(cs_main, cs_wallet)". However, the original client is quite complicated when it comes to select which outputs from transactions to use as funds for a transaction. This happens in a sub-function called SelectCoins() which stochastically choose random transaction outputs until the desired sum is reached.

When changing this code base to use a real database it is extremely important that that the operation SelectCoins() is atomic, or otherwise a race condition will occur and there’s a danger that two or more persons making BTC withdrawals at the same time will end up using the same transaction outputs.

Fortunately, the blockchain is all about preventing double spending, which means that only the first transaction will go through and the rest will be stuck in limbo. The only way to resolve this is to cancel those transactions, which MtGox presumably does manually. Once the transactions are cancelled, they will retry transferring the funds, but the same problem can happen again, which implies that they may have to cancel those transactions as well, etc.

However, if many are doing withdrawals, the greater the chance for these race conditions. MtGox MUST solve this problem ASAP or the technical support tickets being created will go to the roof and the user confidence will quickly evaporate into quantum foam.

Are there any bitcoin developers out there that could chime in on my theory?

UPDATE: It is likely that these race conditions started to occur when they upgraded hardware from one server to many for load balancing. (This happened approximately one year ago.)
1715317026
Hero Member
*
Offline Offline

Posts: 1715317026

View Profile Personal Message (Offline)

Ignore
1715317026
Reply with quote  #2

1715317026
Report to moderator
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715317026
Hero Member
*
Offline Offline

Posts: 1715317026

View Profile Personal Message (Offline)

Ignore
1715317026
Reply with quote  #2

1715317026
Report to moderator
DieJohnny
Legendary
*
Offline Offline

Activity: 1639
Merit: 1006


View Profile
January 29, 2014, 10:47:42 AM
 #2

MtGox MUST solve this problem ASAP or the technical support tickets being created will go to the roof and the user confidence will quickly evaporate into quantum foam.

Did you mean to post this topic last February?Huh??

Those who hold and those who are without property have ever formed distinct interests in society
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
January 29, 2014, 10:57:06 AM
 #3

Did you mean to post this topic last February?Huh??

What do you mean?

I only started to look at this problem when it happened to myself (and some of my friends).
When I did some research I saw that others had this problem as well, so I started to dig deeper into this.

The problem is much worse now than in February, because the BTC outflow from MtGox is much higher now, so the problem is very frequent. Most likely, it happens to all MtGox users (once in a while).
mailaddy
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
January 29, 2014, 09:51:42 PM
 #4

I suggested it sounded like a race condition several days ago in https://bitcointalk.org/index.php?topic=429769.msg4738455#msg4738455 - this was dropped into #mtgox and also sent to MagicalTux, but nobody got in touch.

Obviously we have no idea how their code is working though, and i would think that they know about race conditions and how to fix them anyway, because their trade matching engine needs to have locking.
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
January 29, 2014, 10:33:56 PM
 #5

I suggested it sounded like a race condition several days ago in https://bitcointalk.org/index.php?topic=429769.msg4738455#msg4738455 - this was dropped into #mtgox and also sent to MagicalTux, but nobody got in touch.

Obviously we have no idea how their code is working though, and i would think that they know about race conditions and how to fix them anyway, because their trade matching engine needs to have locking.

Ah, at least someone else observing the same thing with the same conclusion! Thanks for notifying! I'm pretty convinced it has to be a race condition in their code and it is most likely the SelectCoins() function that is not properly guarded.
mailaddy
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
January 29, 2014, 11:06:09 PM
 #6

Yes but others have said they think it's related to dust transactions and TX sizes.  I don't understand how it would take more than a day to find the problem and resolve it, whatever it is.  I was affected by this at the end of last year also, but the transaction was resent and made good within 12 hours.. it is now 6 days for this one and nothing.  I directly lost probably $2k because of this.
tvbcof
Legendary
*
Offline Offline

Activity: 4592
Merit: 1276


View Profile
January 30, 2014, 12:02:57 AM
 #7


Looks like you guys were not around when Mt.Gox tossed some bunch of BTC into the ether never to be seen again via a fuck-up to the scripting engine.  In short, it's not big news that Mark (or someone of questionable competence) has puttered around with the code.

I never ran across any convincing arguments of what Mt.Gox was trying to achieve with their re-write, but also never really looked that hard.  Could have been just a fun side project and one which the implementer doesn't want to let go of.

I was also wondering recently if there could be some sort of an exploit/inside job against Gox's stash which manifested itself as a lot of double-spends.  Or similarly, if strategic double-spends in conjunction with an information stream to mining pool might be a way to steer mining profits toward a co-conspirator.


sig spam anywhere and self-moderated threads on the pol&soc board are for losers.
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
January 30, 2014, 08:37:54 AM
 #8


Looks like you guys were not around when Mt.Gox tossed some bunch of BTC into the ether never to be seen again via a fuck-up to the scripting engine.  In short, it's not big news that Mark (or someone of questionable competence) has puttered around with the code.

I never ran across any convincing arguments of what Mt.Gox was trying to achieve with their re-write, but also never really looked that hard.  Could have been just a fun side project and one which the implementer doesn't want to let go of.

I was also wondering recently if there could be some sort of an exploit/inside job against Gox's stash which manifested itself as a lot of double-spends.  Or similarly, if strategic double-spends in conjunction with an information stream to mining pool might be a way to steer mining profits toward a co-conspirator.



No, I was not around at that time. I joined Bitcoin around January 2013 (although I read about in 2011). If they implemented the scripting instructions themselves (and how they are assembled for transactions), it is likely that MtGox has written the entire client from scratch. It seems rather complicated though, because you would like to merge with the latest changes from the official client, especially when there are hard forks.

Trying to exploit double spends is a dead end though. I doubt that the double spends are intentional.
tvbcof
Legendary
*
Offline Offline

Activity: 4592
Merit: 1276


View Profile
January 30, 2014, 08:54:42 AM
 #9

If they implemented the scripting instructions themselves (and how they are assembled for transactions), it is likely that MtGox has written the entire client from scratch. It seems rather complicated though, because you would like to merge with the latest changes from the official client, especially when there are hard forks.

I'm not so sure it would be that problematic to perform the necessary merging.  The scripts should be largely forward compatible, and if one is just running some core business function a lot of the extensions would be unnecessary.  IOW, I would think that a simple script engine would require very few updates, and they would be of the type which would be fairly straightforward to add for the guy who did the initial implementation.

Again, it would be interesting to know what Mark (or whoever) was trying to achieve...but not actually interesting enough to spend much time trying to find out.  Back before Mark was on my shit-list for ripping me off for $5k, I though perhaps he was trying to do some transaction optimizations to benefit the network.  There is no reason why him ripping me off should change my estimate of Mt. Gox's care about the network health, but I cannot help it.


sig spam anywhere and self-moderated threads on the pol&soc board are for losers.
xorred
Full Member
***
Offline Offline

Activity: 166
Merit: 100


View Profile
February 03, 2014, 11:03:53 PM
 #10

same situation here. Hash and address return 0 in blockchain. this sucks, these were ALL my coins!!!!!!!!!!!
skyrunner
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
February 04, 2014, 12:32:28 AM
 #11

So any conclusion? Is Gox fucking with us or there might be a technical problem
tvbcof
Legendary
*
Offline Offline

Activity: 4592
Merit: 1276


View Profile
February 11, 2014, 03:40:28 AM
 #12

...
I was also wondering recently if there could be some sort of an exploit/inside job against Gox's stash which manifested itself as a lot of double-spends.  ...


I ponder no longer.

I had imagined that Gox was taking their own database as a source of truth for accounting purposes and that was probably at the root of the problem.  This seems to be true.

Looks like it probably was not an inside job as I had hypothesized although the potential exists for insiders to have been re-issue payments even after understanding that it would cause a loss.  That's not necessary to explain the observations though.

It would be fun to know how much Mt. Gox (and probably others) lost to this simplistic form of attack.

One way or another, it is pretty sleazy for Karpeles to try to blame the issue on the Bitcoin protocol when they tried to write a processor client without even troubling themselves to ponder the information described on the wiki page.


sig spam anywhere and self-moderated threads on the pol&soc board are for losers.
Pages: [1]
  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!