2

In addition to my prev question...

So i want to get data from my local chain. For that i use example form wanderer.github.io. I open my chain and get raw data, so this data, according to example - just raw node from chain. Next i need to see value of keys in that node. To do that i understood: all keys hidden in the bottom of a merkle-patricia-tree.

Let's speak about my problem. I want to do like in github: open my local wallet and look info about it, for that i looked at example:

//the genesis state root
var root = '12582945fc5ad12c3e7b67c4fc37a68fc0d52d995bb7f7291ff41a2739a7ca16';
var trie = new Trie(db, root);

//gav's address
var gav = new Buffer('8a40bfaa73256b60764c1bf40675a99083efb075', 'hex');

trie.get(gav, function (err, val) {
  var decoded = rlp.decode(val);
  console.log(decoded);
});

and wrote my own code with the fixes problem Invalid root length. Roots are 32 bytes:

var root = new Buffer('e5be92145a301820111f91866566e3e99ee344d155569e4556a39bc71238f3bc', 'hex'), 
    wallet = new Buffer('234132b22de7037e50b9fc4ebd7476315647869e', 'hex');

// work normally and get tree
var trie = new Trie(db, root);

trie.get(

    // what need to view
    wallet,

    // function which work with wallet info
    function (err, value)
    {
        console.log(err);
        console.log(value);

        var decoded = rlp.decode(value);
        console.log(decoded);
    }
);

It's work, but not get info. I didn't find root in my local chain like in example:

//the genesis state root
var root = '12582945fc5ad12c3e7b67c4fc37a68fc0d52d995bb7f7291ff41a2739a7ca16';
var trie = new Trie(db, root);

Anybody, let's help Dora to find the right root of local chain which be correct. Here my 0, 1 and last blocks from chain - maybe it will help you:

debug.printBlock(0)

"Block(#0): Size: 507.00 B { MinerHash: e521eab0c63dfd8bc7c6007e8b2ce954a66f9df3ab72ccf059e5aa49aeb149d8 Header(e5be92145a301820111f91866566e3e99ee344d155569e4556a39bc71238f3bc):[ParentHash: 0000000000000000000000000000000000000000000000000000000000000000 UncleHash: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 Coinbase:0000000000000000000000000000000000000000 Root: 9178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4e TxSha 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 ReceiptSha: 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 Bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Difficulty:131072 Number:0 GasLimit:4712388 GasUsed:0 Time:0 Extra: MixDigest: 0000000000000000000000000000000000000000000000000000000000000000 Nonce:000000000000002a] Transactions:[] Uncles:[] }"

debug.printBlock(1)

"Block(#1): Size: 536.00 B {MinerHash: d8cebba1edfdd6f0364183ace1c5bdd8b5efb2999068aa8084c84043c4a5eb5e Header(3ab5cb6c29e583c50b90e413dca4a6df802d87dd0eb9569dff926f856d011375):[ParentHash: e5be92145a301820111f91866566e3e99ee344d155569e4556a39bc71238f3bc UncleHash: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 Coinbase: 234132b22de7037e50b9fc4ebd7476315647869e Root: 9c12c460f11fcf78d993119e08727e3e45266b3287e68fd42ef90bc730d275f6 TxSha 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 ReceiptSha: 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 Bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Difficulty: 131072 Number: 1 GasLimit: 4712388 GasUsed: 0 Time: 1511614605 Extra: \u0603\x01\a\x02�geth�go1.9.2�darwin MixDigest: 1d51851bf1fca11a0e670fb359b7420f1393074c8c2f1760edfa3a638652a7f7 Nonce: 33c0052eafe0f837] Transactions:[] Uncles:[]}"

> debug.printBlock(81)

"Block(#81): Size: 536.00 B { MinerHash: 5fc817cc85c1ca755186f81e7a96699b68e43e53dc834a529de53bb8adcccaad Header(0dc9b40ee5b8039f2caad3542289000b22319aba762ae854208e3c73c7a31954): [ ParentHash: d9e010a5154b44cd18706decb2d47b739c71d83e4b9b53d2d14d19b6aa423001 UncleHash: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 Coinbase: 234132b22de7037e50b9fc4ebd7476315647869e Root: 2aeb24f3daa4f2ed2accc00ca9af287784cc9f7292bb1bc42641490f56e235e2 TxSha 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 ReceiptSha: 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 Bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Difficulty: 132928 Number: 81 GasLimit: 4712388 GasUsed: 0 Time: 1511643645 Extra: \u0603\x01\a\x02�geth�go1.9.2�darwin MixDigest: 486a097820216125cfe87aa9e8f67b7f64b51591026db5e205aec9e8bf4f1d5e Nonce: 21ac7e333ca8a7c4 ] Transactions: [] Uncles: [] } "

I tried to use genesis as root, but that not work:

"0xe5be92145a301820111f91866566e3e99ee344d155569e4556a39bc71238f3bc"

14
  • Hmm. Try d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544 as the genesis state root, and see if that works. Commented Nov 26, 2017 at 19:04
  • Tried: it must be 32 bytes: AssertionError: Invalid root length. Roots are 32 bytes. Where did you get it?
    – Gudsaf
    Commented Nov 26, 2017 at 19:13
  • also can give you my local chain if it need
    – Gudsaf
    Commented Nov 26, 2017 at 19:21
  • Hold on - are you using the public chaindata, or is it a private network? Commented Nov 26, 2017 at 19:22
  • 1
    Okay, I think you can use Geth's dump feature, and pipe it to head. So something like geth dump 0 | head Commented Nov 26, 2017 at 19:59

1 Answer 1

1

You can use Geth's dump command to grab block 0, and then grab the top part of the output:

$ geth  dump  0  | head
INFO [11-26|19:58:18] Allocated cache and file handles         database=/home/richard/.ethereum/geth/chaindata cache=128 handles=1024
INFO [11-26|19:58:18] Disk storage enabled for ethash caches   dir=/home/richard/.ethereum/geth/ethash count=3
INFO [11-26|19:58:18] Disk storage enabled for ethash DAGs     dir=/home/richard/.ethash               count=2
INFO [11-26|19:58:18] Loaded most recent local header          number=18048 hash=a57baa…6c2b4d td=8705769076450279
INFO [11-26|19:58:18] Loaded most recent local full block      number=0     hash=d4e567…cb8fa3 td=17179869184
INFO [11-26|19:58:18] Loaded most recent local fast block      number=18048 hash=a57baa…6c2b4d td=8705769076450279
{
    "root": "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544",
    "accounts": {
        "000d836201318ec6899a67540690382780743280": {
            "balance": "200000000000000000000",
            "nonce": 0,
            "root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
            "codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
            "code": "",
            "storage": {}

The first root should be the hash of the state root.

(If your chaindata is in a non-standard place you'll need to use the --datadir flag as well.)

1
  • Got it, and looked info in local private chain. So this accounts = local wallets, but if look at Mist number of wallet != account hash. for example i has wallet 0xf032868db0633790166e3d6282914e48E4d908c7 with 12 eth, i got it after mining, i want to look that wallet in dump, but not see it, just wallet "9d373a0f53648a114f3fbc92ce8d144d05f71ab0": { "balance": "12000000000000000000", "root": "56e81f.." } why that?
    – Gudsaf
    Commented Nov 26, 2017 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.