tpmccallum / ethereum_database_research_and_testing

A repository which provides, information, code examples and step by step instructions on how to explore Ethereum's database infrastructure
Other
44 stars 7 forks source link

Import error in the JS files #4

Open surajsjain opened 1 year ago

surajsjain commented 1 year ago

I tried running the print_state_trie_keys.js file using node print_state_trie_keys.js after installing all the requirements by running the command npm install levelup leveldown rlp merkle-patricia-tree assert --save.

Then, I got the following error saying that secure is not present within merkle-patricia-tree:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'merkle-patricia-tree/secure'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/print_state_trie_keys.js:5:12)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Please help me resolve this

surajsjain commented 1 year ago

Figured it out. Just had to change var Trie = require('merkle-patricia-tree/secure') to var Trie = require('merkle-patricia-tree').SecureTrie;

surajsjain commented 1 year ago

But after that, I am getting the following error with respect to the length of the root's value:

begin
assert.js:339
    throw err;
    ^

AssertionError [ERR_ASSERTION]: Invalid root length. Roots are 32 bytes
    at SecureTrie.set root [as root] (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/node_modules/merkle-patricia-tree/dist/baseTrie.js:46:9)
    at new Trie (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/node_modules/merkle-patricia-tree/dist/baseTrie.js:36:23)
    at new CheckpointTrie (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/node_modules/merkle-patricia-tree/dist/checkpointTrie.js:11:9)
    at new SecureTrie (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/node_modules/merkle-patricia-tree/dist/secure.js:16:9)
    at Object.<anonymous> (/home/web3success/ethereum_database_research_and_testing/leveldb/javascript/print_transaction_trie_keys.js:26:12)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)