Bitcoin Forum

Bitcoin => Electrum => Topic started by: cryptocyprus on August 11, 2013, 01:38:28 PM



Title: Electrum 1.8.1 Stuck on Block 251526
Post by: cryptocyprus on August 11, 2013, 01:38:28 PM
As per the title, no matter what server I reconnect to, it will not go past block 251526

I have tried all the servers
Deleted the contents of /appdata/Roaming/Electrum
Recovered the wallet using my seed & resynced

All to no avail, It will not let me send my balance out of the wallet giving the error -22

Any help is appreciated.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: DigitalHermit on August 11, 2013, 05:18:34 PM
As per the title, no matter what server I reconnect to, it will not go past block 251526

I have tried all the servers
Deleted the contents of /appdata/Roaming/Electrum
Recovered the wallet using my seed & resynced

All to no avail, It will not let me send my balance out of the wallet giving the error -22

Any help is appreciated.

It is not your wallet that is the problem; The problem is on the Electrum Server(s)... this will need to be fixed in order to make Electrum clients functional again.

The exception we are seeing server-side is:
Code:
[11/08/2013-12:06:38] hist [('0000000000000050efb2e0ea17635fa1c2bd8da1e7864ecc0695f2565643989e', 251526, 0)]
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 755, in run
    self.function(*self.args, **self.kwargs)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/blockchain_processor.py", line 67, in <lambda>
    threading.Timer(0, lambda: self.catch_up(sync=False)).start()
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/blockchain_processor.py", line 675, in catch_up
    self.import_block(next_block, next_block_hash, self.height+1, sync)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/blockchain_processor.py", line 391, in import_block
    tx_hashes, txdict = self.deserialize_block(block)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/blockchain_processor.py", line 366, in deserialize_block
    tx = deserialize.parse_Transaction(vds, is_coinbase)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/deserialize.py", line 291, in parse_Transaction
    o = parse_TxOut(vds, i)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/deserialize.py", line 271, in parse_TxOut
    d['address'] = extract_public_key(scriptPubKey)
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/deserialize.py", line 379, in extract_public_key
    decoded = [ x for x in script_GetOp(bytes) ]
  File "/home/electrum/src/electrum-20130112/server/backends/bitcoind/deserialize.py", line 335, in script_GetOp
    opcode |= ord(bytes[i])
IndexError: string index out of range



Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: cryptocyprus on August 11, 2013, 05:42:59 PM
Thank you DigitalHermit, thought I would ask in here once I discovered a problem.
Hopefully it can be resolved quickly.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: DigitalHermit on August 11, 2013, 06:18:31 PM
Code:
def script_GetOp(bytes):
  i = 0
  while i < len(bytes):
    vch = None
    opcode = ord(bytes[i])
    i += 1
    if opcode >= opcodes.OP_SINGLEBYTE_END:
      opcode <<= 8
      opcode |= ord(bytes[i])

Apparently there is an issue in script_GetOp(bytes) (deserialize.py) for this particular block that makes the electrum server code read off the end of the byte array when trying to read the operation. I don't know if this is an issue with the format of this specific block or with the python code. If it's an issue with the block format I'm surprised it has gone undetected this long - apparently bitcoind code permitted/accepted this block.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: cryptocyprus on August 11, 2013, 06:32:36 PM
I am just surprised I hadn't read more people in the same situation.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Tuxavant on August 11, 2013, 07:08:56 PM
Checking in as this was starting to effect me and was wondering what's going on. Thanks OP.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: CryptCard on August 11, 2013, 07:35:48 PM
Is it possible to use the bitcoins at this moment? How long do you think does it take until this issues are fixxed?


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: cp1 on August 11, 2013, 07:40:32 PM
Export your private key to another wallet client.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: kangasbros on August 11, 2013, 07:41:20 PM
Are their some servers already which have fixxed the problem? A lot of bitcoins are now on bitcoin addresses on which I have no access!
I need the bitcoins AT THIS MOMENT.

I guess with some code wizardy you can export the private keys to bitcoind or multibit.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: CryptCard on August 11, 2013, 07:43:17 PM
I didn't know that electrum is that awesome! :)

It takes some hours until I finished the download of the blockchain.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: EagleTM on August 11, 2013, 07:44:02 PM
Looks like we got caught off-guard on a Sunday. Rest assured we're working on getting this fixed asap. The coins are safe. Just seeing new tx and spending coins is not possible at this time.

To Server operators:

The dumps at http://electrum-foundry.no-ip.org/leveldb-dump/?C=M;O=D  generated this morning around midnight have a clean, uncorrupted database to use once we have a fix to get past offending block 251526.
See also http://electrum-foundry.no-ip.org/


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: DigitalHermit on August 11, 2013, 08:07:15 PM
I didn't know that electrum is that awesome! :)

It takes some hours until I finished the download of the blockchain.

You can create a wallet at blockchain.info and import the private keys from your electrum wallet if you need access to your funds immediately. Otherwise, sadly yes you will have to wait for a fix.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: EagleTM on August 11, 2013, 10:01:25 PM
Servers electrum.be and electrum.no-ip.org are fixed and up to date.

Thanks to DigitalHermit for the fix, which is pushed to electrum-server on github (https://github.com/spesmilo/electrum-server/). We're urging all server operators to apply the fix. If you want to make sure your server database has a correct block 251526 indexed please re-index from a backup (i.e. from the foundry linked above). We're still researching how unpatched servers handled 251526...


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: EagleTM on August 11, 2013, 10:29:57 PM
I did some simple tests with tx from block 251526 and they are indexed just fine on a crashed server after the fix is applied. Unless the server throws "LevelDBError: Corruption" on startup as has been reported but might be unrelated it's sufficient to stop the server, pull git head and start the server.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: stepkrav on August 12, 2013, 12:19:18 AM
electrum.stepkrav.pw up n running.  :)


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Jaxkr on August 12, 2013, 03:53:10 AM
electrum.stepkrav.pw up n running.  :)
Thanks. Switched there, and everything's working! :)


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: yxt on August 12, 2013, 09:19:05 AM
Thanks for the fast solution  :)


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: gmaxwell on August 12, 2013, 10:50:06 AM
Transaction ID: 77822fd6663c665104119cb7635352756dfc50da76a92d417ec1a12c518fad69 contains the patch for the second bug:

Code:
From a3a61fef43309b9fb23225df7910b03afc5465b9 Mon Sep 17 00:00:00 2001
From: Satoshi Nakamoto <satoshin@gmx.com>
Date: Mon, 12 Aug 2013 02:28:02 -0200
Subject: [PATCH] Remove (SINGLE|DOUBLE)BYTE

I removed this from Bitcoin in f1e1fb4bdef878c8fc1564fa418d44e7541a7e83
in Sept 7 2010, almost three years ago. Be warned that I have not
actually tested this patch.
---
 backends/bitcoind/deserialize.py |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/backends/bitcoind/deserialize.py b/backends/bitcoind/deserialize.py
index 6620583..89b9b1b 100644
--- a/backends/bitcoind/deserialize.py
+++ b/backends/bitcoind/deserialize.py
@@ -280,10 +280,8 @@ opcodes = Enumeration("Opcodes", [
     "OP_WITHIN", "OP_RIPEMD160", "OP_SHA1", "OP_SHA256", "OP_HASH160",
     "OP_HASH256", "OP_CODESEPARATOR", "OP_CHECKSIG", "OP_CHECKSIGVERIFY", "OP_CHECKMULTISIG",
     "OP_CHECKMULTISIGVERIFY",
-    ("OP_SINGLEBYTE_END", 0xF0),
-    ("OP_DOUBLEBYTE_BEGIN", 0xF000),
     "OP_PUBKEY", "OP_PUBKEYHASH",
-    ("OP_INVALIDOPCODE", 0xFFFF),
+    ("OP_INVALIDOPCODE", 0xFF),
 ])
 
 
@@ -293,10 +291,6 @@ def script_GetOp(bytes):
         vch = None
         opcode = ord(bytes[i])
         i += 1
-        if opcode >= opcodes.OP_SINGLEBYTE_END and i < len(bytes):
-            opcode <<= 8
-            opcode |= ord(bytes[i])
-            i += 1
 
         if opcode <= opcodes.OP_PUSHDATA4:
             nSize = opcode
--
1.7.9.4

I guess this was code monkey-copied from abe?  I suppose someone should go fix that too.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Aleksei Richards on August 12, 2013, 01:16:27 PM
You can also use your electrum passphrase at carbon wallet. http://carbonwallet.com/


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: ThomasV on August 12, 2013, 04:36:42 PM
Servers electrum.be and electrum.no-ip.org are fixed and up to date.

Thanks to DigitalHermit for the fix, which is pushed to electrum-server on github (https://github.com/spesmilo/electrum-server/). We're urging all server operators to apply the fix. If you want to make sure your server database has a correct block 251526 indexed please re-index from a backup (i.e. from the foundry linked above). We're still researching how unpatched servers handled 251526...

thank you guys for the quick fix!


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: dserrano5 on August 12, 2013, 04:56:31 PM
What's this?

Code:
From a3a61fef43309b9fb23225df7910b03afc5465b9 Mon Sep 17 00:00:00 2001
From: Satoshi Nakamoto <satoshin@gmx.com>
Date: Mon, 12 Aug 2013 02:28:02 -0200
Subject: [PATCH] Remove (SINGLE|DOUBLE)BYTE

I removed this from Bitcoin in f1e1fb4bdef878c8fc1564fa418d44e7541a7e83
in Sept 7 2010, almost three years ago. Be warned that I have not
actually tested this patch.

More specifically:

Code:
From: Satoshi Nakamoto <satoshin@gmx.com>
Date: Mon, 12 Aug 2013 02:28:02 -0200

It's been several hours since this was posted and I don't see the entire net screaming "Satoshi is alive!!!" all around, so I guess I must be the only one drawing the wrong conclusion from those two lines. Someone willing to state that obvious thing that I fail to see?


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: tigereye on August 12, 2013, 06:39:23 PM
I can write an email with "From: Satoshi Nakamoto <satoshin@gmx.com>" in the header too, and embed it in the blockchain.

What would you like your letter from Satoshi to say?


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: cryptasm on August 12, 2013, 07:16:53 PM
Can't send anything from my electrum wallet, tried using electrum.be and electrum.no-ip.org, no joy. Keep seeing that error -22 message. Any ideas what I can do? thanks

EDIT: All sorted now  ;D


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Mahn on August 12, 2013, 08:11:38 PM
Transaction ID: 77822fd6663c665104119cb7635352756dfc50da76a92d417ec1a12c518fad69 contains the patch for the second bug:

Code:
From a3a61fef43309b9fb23225df7910b03afc5465b9 Mon Sep 17 00:00:00 2001
From: Satoshi Nakamoto <satoshin@gmx.com>
Date: Mon, 12 Aug 2013 02:28:02 -0200
Subject: [PATCH] Remove (SINGLE|DOUBLE)BYTE

I removed this from Bitcoin in f1e1fb4bdef878c8fc1564fa418d44e7541a7e83
in Sept 7 2010, almost three years ago. Be warned that I have not
actually tested this patch.
---
 backends/bitcoind/deserialize.py |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/backends/bitcoind/deserialize.py b/backends/bitcoind/deserialize.py
index 6620583..89b9b1b 100644
--- a/backends/bitcoind/deserialize.py
+++ b/backends/bitcoind/deserialize.py
@@ -280,10 +280,8 @@ opcodes = Enumeration("Opcodes", [
     "OP_WITHIN", "OP_RIPEMD160", "OP_SHA1", "OP_SHA256", "OP_HASH160",
     "OP_HASH256", "OP_CODESEPARATOR", "OP_CHECKSIG", "OP_CHECKSIGVERIFY", "OP_CHECKMULTISIG",
     "OP_CHECKMULTISIGVERIFY",
-    ("OP_SINGLEBYTE_END", 0xF0),
-    ("OP_DOUBLEBYTE_BEGIN", 0xF000),
     "OP_PUBKEY", "OP_PUBKEYHASH",
-    ("OP_INVALIDOPCODE", 0xFFFF),
+    ("OP_INVALIDOPCODE", 0xFF),
 ])
 
 
@@ -293,10 +291,6 @@ def script_GetOp(bytes):
         vch = None
         opcode = ord(bytes[i])
         i += 1
-        if opcode >= opcodes.OP_SINGLEBYTE_END and i < len(bytes):
-            opcode <<= 8
-            opcode |= ord(bytes[i])
-            i += 1
 
         if opcode <= opcodes.OP_PUSHDATA4:
             nSize = opcode
--
1.7.9.4

I guess this was code monkey-copied from abe?  I suppose someone should go fix that too.

So, is this him? Anyone can write something with a header saying from "From: Satoshi Nakamoto <satoshin@gmx.com>", but I can't picture someone searching through the entire commits history of bitcoin to find the relevant commit that matches what he's talking about (f1e1fb4bdef878c8fc1564fa418d44e7541a7e83, which does indeed exist and it is a commit by Satoshi). Satoshi, if you are reading this, add your digital signature next time, even if you are trying to be extra cautious it can't possibly do much harm.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: kayrice on August 12, 2013, 08:22:16 PM
I think he did include a git signature:

a3a61fef43309b9fb23225df7910b03afc5465b9


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Peter Todd on August 12, 2013, 08:53:18 PM
So, is this him? Anyone can write something with a header saying from "From: Satoshi Nakamoto <satoshin@gmx.com>", but I can't picture someone searching through the entire commits history of bitcoin to find the relevant commit that matches what he's talking about (f1e1fb4bdef878c8fc1564fa418d44e7541a7e83, which does indeed exist and it is a commit by Satoshi)

Note that I mentioned (https://bitcointalk.org/index.php?topic=255145.msg2766532#msg2766532) double-byte opcodes a few weeks ago on the forums; there's lots of people who know about this stuff and could have made that transaction.

I should also point out that the transaction appears to not only include a patch to fix Electrum, but at the same time also triggers the bug it patches. I think what happens is that the OP_INVALIDOPCODE triggers the broken double-wide code to advance a byte, ORing that byte with OP_INVALIDOPCODE << 8. Unfortunately that character is a PUSHDATA, which means that Electrum now processes the data as though it were opcodes. The next byte is 0x4e, or OP_PUSHDATA4, followed by the length of the data to be pushed, 0xffffffff=2^32 bytes. Of course there aren't 4GiB of data in the script, so it fails and Electrum gets stuck.

I think the OP_IF/OP_ENDIF was meant so that the transaction could be spent, but whomever did so forgot that PUSHDATA's > 520 bytes make a transaction invalid. Thus unless we change that limit - a hard-fork - the 15mBTC will be unspendable forever. (invalid opcodes are legal in an un-executed IF/ELSE/ENDIF branch, but oversized pushdata's are not)

I rather doubt that Satoshi would have made that mistake.  ;)

I think he did include a git signature:

a3a61fef43309b9fb23225df7910b03afc5465b9

That's just a reference to the previous commit ID the patch is meant to apply too. If you save that patch to a file you can apply it with git am patch.diff, it was probably created with git format-patch from the looks of it.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: EagleTM on August 12, 2013, 09:48:45 PM
Transaction ID: 77822fd6663c665104119cb7635352756dfc50da76a92d417ec1a12c518fad69 contains the patch for the second bug:

Thx for posting this!
How is "second bug" meant? How do you read the patch? It's still the same issue? I guess I'm missing something?

Quote
I guess this was code monkey-copied from abe?  I suppose someone should go fix that too.

abe was fairly quick:

commit 2b721e1df441396d04cea8b34ebe7b77488ddf52
Author: John Tobey <John.Tobey...mail>
Date:   Mon Aug 12 13:44:39 2013 -0400

    Merge bitcointools upstream changes and update callers.


If I read the timestamp right that's less than 2 hours after the fix got included in the blockchain. That's rather quick and the change fixes other things with it. Too quick, but maybe he got a PM around the time it was accepted in the mempool at Eligius :)?


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: dashingriddler on August 13, 2013, 04:40:06 PM
My Abe got struck at 251526. Updating of Abe from github resolved the issue and the scanning went ahead :)


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: EagleTM on August 13, 2013, 05:11:43 PM
There appears to be a bug (regression) with servers not connected to IRC and Electrum > 1.7 . The client only shows the one server you're connected to, which is a problem if this is a server still stuck on 251526. It should show a list of built in servers.

To resolve this you manually have to enter one of the servers like:

electrum.be SSL 50002
electrum.no-ip.org SSL 50002
electrum.pdmc.net SSL 50002



Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: sovereignlife on August 14, 2013, 12:46:59 AM
That was a really helpful post as I experienced this problem today when attempting to send out some BTC. The strange thing was on my first attempt the funds actually arrived, but didn't show up on my transaction history - and other attempts to send failed, as per above comments. Changing the server fixed the problem - so thanks!

Servers electrum.be and electrum.no-ip.org are fixed and up to date.

Thanks to DigitalHermit for the fix, which is pushed to electrum-server on github (https://github.com/spesmilo/electrum-server/). We're urging all server operators to apply the fix. If you want to make sure your server database has a correct block 251526 indexed please re-index from a backup (i.e. from the foundry linked above). We're still researching how unpatched servers handled 251526...


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: ksteve96 on August 14, 2013, 05:54:39 PM
I was wondering what was going on.  I'm connected to electrum.be now, but still not seeing a sent transaction in the blockchain, even unconfirmed.  Transaction shows in the electrum client as pending since about an hour ago.   I'm at 252,151 blocks right now.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: tnkflx on August 15, 2013, 08:30:22 AM
I was wondering what was going on.  I'm connected to electrum.be now, but still not seeing a sent transaction in the blockchain, even unconfirmed.  Transaction shows in the electrum client as pending since about an hour ago.   I'm at 252,151 blocks right now.

Do you have the transactiond id?


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: ksteve96 on August 15, 2013, 08:28:10 PM
I was wondering what was going on.  I'm connected to electrum.be now, but still not seeing a sent transaction in the blockchain, even unconfirmed.  Transaction shows in the electrum client as pending since about an hour ago.   I'm at 252,151 blocks right now.

Do you have the transactiond id?

I went to bed and when I looked again that one finally was OK.  But I just sent 1 BTC somewhere else 20 minutes ago and it's not showing up in the chain yet.  A few other transactions were pretty slow yesterday too, but I can't get a fix on if it was electrum or the sender, or both.

As for todays transaction, I'll PM you the ID. 


Well, as I was writing that, there were 2 confirmations  I opened and closed the client during that time.  Now I'm just wondering about the delays in general, previously, transactions would generally show up in the blockchain almost immediately, although unconfirmed.  Been slower since the stuck block it seems.  I'll keep monitoring it.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: gominoa on September 30, 2013, 09:32:25 PM
This appears to be happening again. I cant send. TX rejected code -22.


Title: Re: Electrum 1.8.1 Stuck on Block 251526
Post by: Tachikoma on October 01, 2013, 08:46:37 AM
Try a different server and make sure you included enough fees.