Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to parse chainstate #1

Closed
amanusk opened this issue Oct 21, 2017 · 10 comments
Closed

Need help to parse chainstate #1

amanusk opened this issue Oct 21, 2017 · 10 comments

Comments

@amanusk
Copy link

amanusk commented Oct 21, 2017

Hi, and thanks for creating the tool.
I am trying to run the example shown on the readme page to parse the UTXO database.
Unfortunately, I was getting empty files as results. I was only able to get something in the file utxos.txt after changing prefix=b'c' to prefix=b'C' in this line in utils.py

After that, the file utxos.txt looks like this:

{"value": "81e14332003bf58224ccd41bd4c94bf0d4a711fc4e1187887c", "key": "4300000136ea56f3b0ee8fbb13059cbd4521ba38074fd9832a86f4335cd7d2267c00"}
{"value": "bf8d427b007ce9617e10685f9aa2f11d19272b0692c425bc83", "key": "43000007608f08c437696f0e12bc50927ac343e48c51f4b9c4a52a484998ad188902"}
{"value": "efd20680e52900df59f7cfb19c60b7e7d4087b15ca5612523d5c53", "key": "43000009c5d6812fe6fd011c921e566bc396d840293efc1c570777d95359fca78400"}
{"value": "d7ae4807016afa6ce4bcea3bfdb9cdcc1818fdf272e695854f", "key": "4300000b99fb3d107e8573bfad3d28b52087e6fb685b156777c73157fa452ba96000"}
{"value": "989160808027000b4d2d0c2252ede24fd76f0d242903d5758697b8", "key": "430000104fbfb34ef6c699cf1ec1f0f8e8da9c6bb71d81ca1c2e449529c86b815c00"}

Does this make sense?

When I later try to run utxo_dump(f_utxos, f_parsed_utxos) on this file, I get the error:

Traceback (most recent call last):
  File "leveldb_dump.py", line 10, in <module>
    utxo_dump(f_utxos, f_parsed_utxos)
  File "/home/amanusk/Code/bitcoin_tools/bitcoin_tools/analysis/leveldb/data_dump.py", line 48, in utxo_dump
    utxo = decode_utxo(data["value"])
  File "/home/amanusk/Code/bitcoin_tools/bitcoin_tools/analysis/leveldb/utils.py", line 201, in decode_utxo
    data, offset = parse_b128(utxo, offset)
  File "/home/amanusk/Code/bitcoin_tools/bitcoin_tools/analysis/leveldb/utils.py", line 112, in parse_b128
    more_bytes = int(data, 16) & 0x80  # MSB b128 Varints have set the bit 128 for every byte but the last one,
ValueError: invalid literal for int() with base 16: ''

This happens even if I try to parse a single line of the file

I am running the latest version of bitcoin-core (Perhaps an older version is needed for the tools to work?). Is there anything special that needs to be done when starting bitcoind?
Any help is appreciated.

@sr-gi
Copy link
Owner

sr-gi commented Oct 21, 2017

The LevelDB structure was changed on v 0.15, so the parser won't work for the latest bitcoin-core version. I'm planning to update the parser soon, though.

@amanusk
Copy link
Author

amanusk commented Oct 21, 2017

Got it. What is the last version you know to work?

@sr-gi
Copy link
Owner

sr-gi commented Oct 21, 2017

Changes where made in 0.15, so any 0.14.x should work.

@amanusk amanusk closed this as completed Oct 22, 2017
@sr-gi
Copy link
Owner

sr-gi commented Nov 4, 2017

@amanusk Just letting you know that the decoder for 0.15 is now available in dev branch. It will be merged to main ASAP (during next week most likely).

@jhdscript
Copy link

how to install bitcoin 0.14x ?

@sr-gi
Copy link
Owner

sr-gi commented Nov 9, 2017

@jhdscript You can find all the versions history at bitcoin.org

@jhdscript
Copy link

ok thanx i m trying it. I think my version doesn t work with nw chainstate format

@sr-gi
Copy link
Owner

sr-gi commented Nov 9, 2017

The code in main branch only works versions 0.8-0.14 format. The code in dev branch include the parsers for both the 0.8-0.14 format and the new 0.15 one. However, we are redesigning some details on dev branch before merging it to master, so parts of the code may change.

@jhdscript
Copy link

arf i delete all my blocks from 8.15

Main branch works with 14.2 too ?

@sr-gi
Copy link
Owner

sr-gi commented Nov 9, 2017

Sure, any 0.14x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants