Author

Topic: Debugging getblocks on initial chain download (Read 996 times)

newbie
Activity: 29
Merit: 0
December 20, 2011, 12:55:25 AM
#3
I figured it out!!

I was constructing the getblocks wrong (hashes were encoded in the wrong endian).  The initial response of 500 blocks was giving me a false sense that I had it constructed correctly, but I realized it would just respond from the genesis if it didn't understand my request.

Basically, just stared at this for a while:
https://en.bitcoin.it/wiki/Protocol_specification#getblocks

Anyway, on to the next bug!
newbie
Activity: 29
Merit: 0
December 19, 2011, 10:21:45 PM
#2
Darn - anyone have any theories on this?  I'm still stumped.

This caught my eye:

https://en.bitcoin.it/wiki/Satoshi_Client_Block_Exchange

"The code attempts to limit redundant requests to every 2 minutes for the same block by using a map called mapAlreadyAskedFor to delay the message if necessary."

Maybe my request is being viewed as a duplicate somehow and being delayed for 2 minutes?  Or do nodes tend to limit getblocks requests in any other way?  I'm only connecting to one node right now.
newbie
Activity: 29
Merit: 0
December 17, 2011, 08:04:26 PM
#1
Hi, I'm trying to figure out what's happening with some custom client code I'm writing.  This is for the initial blockchain download.

When I start up I send the first getblocks with just two hashes (genesis, and zeroes):

000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
0000000000000000000000000000000000000000000000000000000000000000

This works fine and the client sends me an inv and I download and store those 500 blocks.  It then sends me the latest block it knows about (at the time of this writing block 157940).

I save it as an orphan and then send the following hashes in my next getblocks *but I get no response from the peer*.

500   000000004ff664bfa7d217f6df64c1627089061429408e1da5ef903b8f3c77db
499   00000000806df68baab17e49e567d4211177fef4849ffd8242d095c6a1169f45
498   00000000693a6d6b068cab3e207d570764f6bad293e3e98920246eeda81c496a
497   00000000c39ea29ad310c1f80409e24b3fbfd671c0b3599198b7cfdebf790bde
496   00000000b0c5a240b2a61d2e75692224efd4cbecdf6eaf4cc2cf477ca7c270e7
495   00000000e47349de5a0193abc5a2fe0be81cb1d1987e45ab85f3289d54cddc4d
494   000000004fb61ae8e99040c4e1e3b4d333dbe867f97f63ab4238cba80f59204a
493   0000000008884067dbe80128da09a16315bb208a69e9894287a3c9e0fb671f8b
492   000000008d9b5010b996bbab558e88e9fe8a8b42751dfcaa79217f9a66642e65
491   00000000244c1b0da1196b989d7557168c5e1b4253f253f2aa8bffd05c7f67b4
489   000000007f20688b2b5c654489c4d3b69196eba0129a364f89b97ae8e4cb0e33
485   00000000754312ec7235128b6e6e3539c760f61c1988e4728a5aa1dcd9cbcbde
477   00000000e15bee1a653b171741fdd792b4936a22990c7a08764349f06239001e
461   000000002082739d0e82596fb69243b1ca9db66db623d3fdcf283f18486cdbaf
429   000000008e5da1aa58d17da1bbc95e9b032714e7ea7831e82f2830bf97dc38e7
365   00000000c256b2fa2ac9936f8f78dc8a0d88320a6bb0803ae30f82406af13955
237   000000003ee212a38ae0326c5982e3012754bb6a730f885bd955673982df83ca
0     000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
na   00000000000002938b9efb41656dd6858a55521b0c25dca3f99b44bc29b68015

I'm showing the height of the block on the left here just for clarity, obviously my getblocks is only sending the hashes as normal.
The last one (height NA) is the prev_block for the orphan I just saved.  I tried putting all zeros here also which should also work, but no matter what I try the peer won't send me the next 500 blocks.  (have tried this with multiple peers multiple times so I don't think it's a bad peer).

I believe I'm formatting it correctly - after 10 latest blocks, it jumps back 2, then 4, then 8 etc.

Does anyone see what I might be messing up here?  Thanks for the help!  I really appreciate it.
Jump to: