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"
d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544
as the genesis state root, and see if that works.AssertionError: Invalid root length. Roots are 32 bytes
. Where did you get it?dump
feature, and pipe it tohead
. So something likegeth dump 0 | head