Convert SQLite from messagepack to json

Please can someone explain in detail how to convert the ledger.block.sqlite database from messagepack to JSON?
This database is downloaded from my archivial node.

Thank you so much for your help, I need it for my University.

Is there really no one who can help me?

Sorry about the delay! To convert between msgpack and json, you can use msgpacktool. I’m pretty sure it gets installed when you install algod,
but if not it’s in the github repo: [https://github.com/algorand/go-algorand/tree/master/cmd/msgpacktool]. (If you do need to build it from source and you run into any issues, post again and either I or someone else should be able to help.)

msgpacktool can decode msgpack (into JSON) with the -d flag and encode JSON into msgpack with the -e flag. It reads from stdin and writes to stdout. So if you’ve dumped the msgpack blob for block 100 into block100.msgpack, you could dump the JSON representation to a file with msgpacktool -d <block100.msgpack >block100.json
There’s also a -b32 flag if you want to print blobs like hashes and addresses in base32 instead of base64.

Rather than extracting each msgpack-encoded block from the ledger sqlite file, you may find it more convenient to use another tool called catchupsrv. (It also should be insalled when you install algod, if I’m not mistaken.) You can use catchupsrv can download all the blocks (and certs) and put each one in a separate file. (The filename for block N will be, for bizarre reasons, N in base 36.) The README has more information: [https://github.com/algorand/go-algorand/tree/master/cmd/catchupsrv]

(If you’re curious, the idea of catchupsrv is that if you had an airgapped machine with algod on it and you wanted to bring its ledger relatively up to date, you could use this tool to download all the blocks using a different machine, transfer them to the airgapped machine, and then let the airgapped algod catch up (and let algod fully validate certificates and everything) using the downloaded blocks.)

Post back if you run into any issues! Sorry again about the delay.

Relatedly: There’s an open github issue to add a goal command to dump a raw block to make this whole process easier: https://github.com/algorand/go-algorand/issues/92

1 Like

Thank you so much for the help, I really need it and thank you very much for the availability and kindness