MetacoSA / NBitcoin.Indexer

Scalable and fault-tolerant block chain indexer for Azure cloud platform.
MIT License
28 stars 21 forks source link

NBitcoin.Indexer.Console Hang #3

Closed bijakatlykkex closed 8 years ago

bijakatlykkex commented 8 years ago

It seems there is an issue with processing transactions in block 22131 or 22132 of segnet testnet. When I issue the command "NBitcoin.Indexer.Console -t --From 22131 --TO 22132" it hangs and also it seems the https://segnet.metaco.com/blocks/tip reports the tip block to be 22131 which at the time of writing is 22502 (seems to me the same problem).

NicolasDorier commented 8 years ago

Interesting thanks for reporting the issue, I'm looking that out.

NicolasDorier commented 8 years ago

mmmh my segnet bitcoin node is itself stuck at 22131.

I don't think this is a indexer prroblem, but a bitcoin node problem... I'm investigating that.

NicolasDorier commented 8 years ago

mmh another block explorer is also stuck https://segnet.smartbit.com.au/

bijakatlykkex commented 8 years ago

Isn't it built on yours Indexer?

NicolasDorier commented 8 years ago

smartbit no. http://api.qbit.ninja/ http://tapi.qbit.ninja/ http://segnet.metaco.com/ are. (QBitNinja is the user friendly REST layer on top of the indexer)

Smartbit has the same bitcoind binaries (I gave it to them) so maybe an incompatible stuff happened. I'm recompiling bitcoind with segwit and will try to update my node to see how it goes.

bijakatlykkex commented 8 years ago

If it helps. I am able to index blocks up to the end, this just happens for transactions.

NicolasDorier commented 8 years ago

I'm trying first to recompile bitcoind, install the new version and see how it goes. Compiling for windows take a while, so I'll keep you updated tomorrow.

bijakatlykkex commented 8 years ago

Thanks. More about my configuration; in my installation I have <add key="BlockDirectory" value=xxx"/>in LocalSettings.config and I have built my own segwit bitcoind using https://github.com/phelix/easywinbuilder on windows.

NicolasDorier commented 8 years ago

is your node stuck ?

NicolasDorier commented 8 years ago

or only indexer ?

bijakatlykkex commented 8 years ago

The node works well and gets blocks (It is now on 22526). Indexer.Console with --ALL switch hanged, so I first indexed blocks and then started to index transactions 2000, 3000 numbers each time and half ed the interval each time when I get the hang again until I found the small interval in the first post.

bijakatlykkex commented 8 years ago

Also I copied much of blocks from a Linux machine running segwit code (I think the blocks mentioned in first post is copied from the Linux machine).

And thank you very much for your efforts on bringing Bitcoin to .Net.

NicolasDorier commented 8 years ago

Thanks ! mmmh I have problem for compiling the windows binaires on linux right now... I have some work to do until friday, so I can't get a look before easily.

If you can send me the problematic block (where it hangs) in hex, I can probably check what is going wrong with it though.

bijakatlykkex commented 8 years ago

Attached are the blocks 22131 and 22132. I am not sure which block is the source of the problem, but I think it should be the latter one since I think I am able to index 22131: "NBitcoin.Indexer Information: 0 : Checkpoint default/transactions loaded at 22131"

The method I used to get these blocks was: (on Windows machine): 1- bitcoin-cli -conf=[confFile] getblockhash 22132 2- bitcoin-cli -conf=[confFile] getblock 0000000040721249c0e56bef4aacd0ecb418c0cf6816afa3fb32b1c06ce82247 false > 22132.txt

Thank you for your attention.

22131.txt 22132.txt

bijakatlykkex commented 8 years ago

It is interesting for me to see the 22132 is larger than 1 Megabyte although it seems because of segwit.

NicolasDorier commented 8 years ago

@bijakatlykkex I think your node is wacky. I just updated my bitcoind, and I am at block https://segnet.metaco.com/blocks/tip (22145) It is strange that you are in 22502. I don't think NBitcoin.Indexer is stalling also. If this is a big block, and your VM is not in Azure (I recommend having your vm hosted in azure colocated with your storage), then a big block can take a while.

NicolasDorier commented 8 years ago

https://segnet.smartbit.com.au/ is same as me.

NicolasDorier commented 8 years ago

oook so a strange thing is happening, you seems to be forked of segnet since your block... I'm trying to gather more info about why your block is rejected by the network but accepted by your node.

bijakatlykkex commented 8 years ago

In my Linux machine I have gen=1 in the configuration file, may it be related? Is it normal not to have new blocks for some days as in your case?

NicolasDorier commented 8 years ago

I don't know. This is very strange, as smartbit, myself, and @CodeShark noticed that blocks suddenly stopped being mined. My biggest question is why are you on block 22502. Did you mined all of that ? if yes, you seems to be isolated from the network now. Can you give me the ip of your node so I see if I can sync with it ? (and verify you have inbound connection)

NicolasDorier commented 8 years ago

Also when is the last time your built bitcoind ?

bijakatlykkex commented 8 years ago

The linux ip is 40.115.30.61 , probably all ports closed with firewall except 8332 for RPC. I am not sure how bitcoin works on low level.

NicolasDorier commented 8 years ago

Can you open the 28333 ? This is the port for segnet normally. (protocol, not rpc)

bijakatlykkex commented 8 years ago

My getpeerinfo returns 104.243.38.34 and 119.246.245.241

bijakatlykkex commented 8 years ago

My linux machine port in now open.

NicolasDorier commented 8 years ago

image

Definitively something wrong with your node

bijakatlykkex commented 8 years ago

Can you explain what is this command line?

NicolasDorier commented 8 years ago

I tried add your node to the connected node of my bitcoind. It rejected your node because one of your header is invalid. I'm trying to checkout why.

bijakatlykkex commented 8 years ago

My source code is from https://github.com/sipa/bitcoin/tree/segwit

NicolasDorier commented 8 years ago

when did you compiled it ?

bijakatlykkex commented 8 years ago

I am not sure, I have 2, one for windows, one for Linux, at most 10 or 15 days ago (the earliest) time; the latest commit is for 29 days ago so makes no difference I think. But instead of zip with link on Github page I may used the .tar.gz (https://github.com/sipa/bitcoin/archive/segwit.tar.gz) I think the archive is built on fly.

NicolasDorier commented 8 years ago

I checked your chain. Our last common block is https://segnet.metaco.com/blocks/22131 I'm trying to find out why your 22132 get rejected now...

bijakatlykkex commented 8 years ago

My Linux source is the zip file for Feb 27.

bijakatlykkex commented 8 years ago

Can the situation be two different isolated networks?

NicolasDorier commented 8 years ago

I don't know... trying to submit your block manually through command line but it is too big. Trying to find a way.

bijakatlykkex commented 8 years ago

In block 22310 I have received 0.5 BTC from segwit faucet https://segwit.greenaddress.it/faucet/

NicolasDorier commented 8 years ago

The problem was I had a old client and it forked me off segnet. Block 22132 is not stalling, it just take time to index. You should always index on a box in azure collocated with the storage or it can take ages.

Proof, my explorer got synched automatically when reindexing the blocks of my node: https://segnet.metaco.com/blocks/22132

bijakatlykkex commented 8 years ago

Thanks. I am running against local "Azure Storage Emulator" and after nearly a day it has not yet imported that 22132 single block. segnet.metaco.com seems to be update to the latest block.

NicolasDorier commented 8 years ago

A day ?! yes this sounds like a problem. But might be the Azure Storage Emulator problem also. I always tested on real storage. Can you try to index on a real one and tell me how it goes ?

bijakatlykkex commented 8 years ago

Yes. It worked with real Azure queue as expected.

bijakatlykkex commented 8 years ago

But Azure Storage Emulator is OK with regtest mode.

bijakatlykkex commented 8 years ago

Thanks for your attention.

NicolasDorier commented 8 years ago

Btw, the indexer has a bunch of unit tests, by changing the LocalSettings.config to match the storage emulator you can run them. You will probably discover what crash, as the tests try lots of edge cases I encountered in the wild.