ethereumjs / merkle-patricia-tree

Project is in active development and has been moved to the EthereumJS VM monorepo.

Home Page:https://github.com/ethereumjs/ethereumjs-monorepo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to read stream from the latest Ethereum mainnet

xiaoyao1991 opened this issue · comments

Hi,

I was trying to iterate a readStream to loop through all accounts in the latest Ethereum mainnet. I ran a script like the following:

var Trie = require('merkle-patricia-tree/secure');
var levelup = require('levelup');
var leveldown = require('leveldown');
var RLP = require('rlp');

//Connecting to the leveldb database
var db = levelup(leveldown('/data3/data/geth/chaindata/'));
var root = '0x6e18ee7df9043dad34470e71729a14ba946750e017e523815478ff11d3bbaccc';    // block 5676026

var trie = new Trie(db, root);

//get a read stream object
var stream = trie.createReadStream();

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

stream.on('end', function (val) {
  console.log('done');
});

The script works on small private nets I set up for other experiments, however, when I try to run it against the fast-sync'd mainnet geth, there seems to have no data event at all. The script ended printing "done" immediately.

Did you solve your issue? This should actually work. Make sure that you are using the correct levelup version from package.json. Also maybe trie different block numbers (e.g. the latest on your sync) and maybe check what happens on a full-sync-started DB into a custom folder on one of the first blocks.