3

I'd like to download some recent version of the Ethereum State Trie. I read here that geth --syncmode light downloads the current state. But does that only encompass the most recent blocks or also a recent version of the State Trie?

When I started my node, geth said it added a trusted checkpoint for block 5734399. So I figured, it downloaded the state trie from a peer for that block. So I tried to access the leveldb files directly using the state root of block 5734399 following this tutorial. However, there was no trie data available for the state root of that block in the leveldb. Does geth maybe download the State Trie of some other block? Or does it not download any State Trie at all?

Here is my nodejs code for reading the leveldb:

var level = require('level');
var rlp = require('rlp');
var Trie = require('merkle-patricia-tree/secure');

var root = "0x35cabdf547eeddccbc9d2df11e3c8b3e0254144b57ec33560c446d8dccfbdf78"; // block 5734399

var db = level('/media/sdc1/.ethereum_light/geth/lightchaindata');
var trie = new Trie(db, root);

var stream = trie.createReadStream();

stream.on('data', function (data){
        console.log(data.key);
});
3

The light client does not download state data. It downloads the header chain, and verifies the proof-of-work but not the transactions themselves. Each block includes a state root, which allows it to verify state data against the block without having to verify the transactions. When you make an RPC call against a light client, it requests the state data from its peers. The peers provide a merkle proof, which can be verified against the state root, ensuring that the peers cannot have provided false information. But if you don't have any peers, you can't get any information from a light client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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