Hot answers tagged

11

Let's start with having a look at what we get in geth console for block number 40. Now let's consider a Go program. I Explained everything in code comments about how it is constructing keys and accessing values from Leveldb. package main import ( "github.com/syndtr/goleveldb/leveldb" "fmt" "encoding/binary" "github.com/ethereum/go-...


9

Can't really say what could have gone wrong, but your database is corrupted at the LevelDB storage engine level. Something seems to have modified the flat data files that leveldb uses to store its stuff in. There isn't much you can do to recover them I'm afraid. You should be able to fast sync back to the network fairly quickly. It usually takes about half ...


6

account is a local object to easily track changes on the accounts (with a StateObject db). The size depends on the nbr of transactions you execute with this account. An unused account should be less than 1kB. The maximum theoretical size for a contract is beyond technology limits, and actually around 90kB. The block.Body contains Transactions. The minimum ...


4

The contents of the database are blob-ified, so you'll have to de-blobbify them to get anything human-readable. The layout can be found in database.go: // Schema layout for the node database var ( nodeDBVersionKey = []byte("version") // Version of the database to flush if changes nodeDBItemPrefix = []byte("n:") // Identifier to prefix node ...


4

You can find the block header's structure in the Yellow paper, 4.4 (page 5). I don't have time to go through eveyrthing, but if I do not make any mistake, for example, you could bind the following: cd7bd64fba4cc782fe5474d3640882afece5887180591e72f80ce6916cf73526 --> Parent hash 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 --> ...


3

I don't think that is possible, because it will completely break the goal of the ethereum network and may (and should) break the integrity and network validation of transactions and stored data on the blockchain. Making nodes share the same data, would make it absurd to pass transactions along the network for validation since all nodes have the same shared ...


3

Pull request for the fix https://github.com/ethereumjs/merkle-patricia-tree/pull/38 Previous answer I'm not 100% sure but I think the problem lies in using the async.forEachOf() for traversing the children of a node in baseTrie.js in the processNode function https://github.com/ethereumjs/merkle-patricia-tree/blob/dc436426d717fed408f4d46fed23f6d26d03d39d/...


3

I had the same issue. It looks like the database layer in pyethereum has been abstracted out such that databases other than leveldb can be used. The challenge is that even if you pass a leveldb object into the db parameter of trie.Trie(db, root_hash) you are going to have issues with the way it calls the get put and delete methods. Leveldb uses upper case ...


3

(This isn't a full answer - as I'm not familiar with how Pythereum does things - but might be a potential starting point.) Have a look at the State() class in state.py. This appears to have some code for the following: Loading a state trie from a given root (line 138); Getting data from the trie for a specific address (line 175); Decoding that data from ...


3

...or a Go API library, or to explain me what part of Geth accesses the chain files, for being able to develop it myself? Have a look at Geth's database.go, which is part of the ethdb package. For the actual interface that's provided, check interface.go: type Database interface { Put(key []byte, value []byte) error Get(key []byte) ([]byte, error)...


3

Doing this using web3 over RPC will take forever, as you've found. Reading the .ldb files is the way to go, and is something that's come up in similar questions before. I don't know of any working, up-to-date, .ldb parser, though there must be some in existence, so I'll defer to other more knowledgeable answers you might get. In the meantime... See: LDB ...


2

Note: I've run fsck on the (unmounted) disk without finding any problems. fsck is a good tool to check for filesystem level problems, but not hardware level. I'd always start at the hardware level and move up from there. Have you checked the SMART status on your hard drives recently? http://www.howtogeek.com/134735/how-to-see-if-your-hard-drive-is-dying/ ...


2

There are inherent limitations of this approach: You can't get the world state from the underlying database since all keys are hashed there. It includes: accounts and their balances contract storage You can't get internal transactions since it requires executing block transactions. The only data that you can get is blocks and transactions. And yes it ...


2

Geth does three operations on the database that you should consider when trying to find alternatives. Geth loads the entire database in levelDB (what I believe you want to do). Geth then deciphers all (or required) key-value pairs using RLP. Geth then takes these key-value pairs (which are nodes on a merle patricia trie) and creates merkle patricia tries`...


2

I am not an expert, but let me share my understanding. Also, please check this question: Ethereum Merkle Patricia Trie and Hashes The trie is stored as key value pairs in levelDB. Each hash (256-bit integer) allows you to access a node. The value corresponds to a RLP encoded node (see Appendix D in yellow paper for different node types). If you want to ...


1

You can get the Ether balance of a smart contract at any block using the Web3 JSON RPC which is exposed through Web3 libraries like Web3.js: getBalance web3.eth.getBalance(address [, defaultBlock] [, callback]) As you can see, this function call supports a "block" input, which can be used to get the Ether balance of the specified address at a certain ...


1

Instructions that store and retrieve data are: SLOAD: { execute: opSload, gasCost: gasSLoad, validateStack: makeStackFunc(1, 1), valid: true, }, SSTORE: { execute: opSstore, gasCost: gasSStore, validateStack: makeStackFunc(2, 0), valid: true, ...


1

You can get the balance of any account using web3.js using web3.eth.hetBalance('eth_address') A sample code be something like this: custom_func.prototype.GETBALANCE=function(address){ return new Promise(function(fullfill,reject){ web3.eth.getBalance(address).then(function(ethBal){ if(ethBal){ console.log("balance of ...


1

You can query contract bytecode in this public BigQuery dataset https://medium.com/@medvedev1088/more-blockchain-analysis-on-bigquery-92a863137f01. Additionally you can query blocks, transactions, receipts, logs, erc20_transfers: ### contracts.csv Column | Type | -----------------------------|-------------| contract_address ...


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 ...


1

Problem was, that i had to use this: var level = require('level') var db = level('/Users/User/WebstormProjects/untitled/bin/chaindata') instead var levelup = require('levelup'); var db = levelup('/Users/User/WebstormProjects/untitled/bin/chaindata'); Also can read about it in: github issues


1

Looking at the LevelDB code, that error appears to be returned if the passed in DB is either empty or invalid. You'll need to check your copy is intact and that there's actually something in it (by letting Geth run for a while). Using the following code on Geth chaindata for the public chain... var levelup = require('levelup'); var db = levelup('chaindata')...


1

I think keys are needed to organize tree - to know how to move nodes in trie without knowledge of stored information, read about Patricia-Tree. In examples, they use keys to organize trie.


1

The issue was the Dain's levelDB only uses .sst files, please use fusesource's levelDB library.


1

You could also read data via a localhost IPC api, which is much faster than the RPC http endpoint.


1

It seems that the web3.db had been removed in geth 1.4, I personally met the same problem before > web3.db { getHex: function(), getString: function(), putHex: function(), putString: function() } > web3.db.putString('testDB', 'key', 'myString') Error: The method db_putString does not exist/is not available at web3.js:3104:20 at web3.js:...


1

Short answer: No, LevelDB is designed to be single threaded.


1

The easiest way is to use the official NodeJS library, write a few lines of JavaScript to scan all of the blocks, and optionally all transactions in each block. Start at block 0 and keep scanning until it returns null. You can do that with far less code than it would take to read/parse, and it would have the added benefit of never needing an upgrade just ...


Only top voted, non community-wiki answers of a minimum length are eligible