forEveryChain

Come Visit with Us for a While

Have you ever had the desire to look at every trace of every transaction of every block on every blockchain? Yes? Well, pull up a chair.

It’s a Multi-Chain World

If you know me, you know I’m a decentralization maximalist. That’s why it’s always perplexed me how the above multi-chain world can possibly ever remain decentralized.

This week we took a stab at answering that question by adding a new feature to TrueBlocks that we call multi-chain support. This feature seems relatively simple on its face — a user only has to add --chain <whatever> to his/her chifra command lines — but it opens up a whole new world of possibilities (and headaches) — and…

IT WORKS ON A DESKTOP (← this should be our new logo!)

In this article, I want to show you an example of one of the new possibilities.

I’ll start by explaining an existing bit of example code from the TrueBlocks repo called forEveryTrace.

This example visits every block in the Ethereum Mainnet, and from there every transaction in every block, and finally every trace in every transaction in every block.

I’ll conclude the article by talking about a new peice of code called forEveryChain which came into existance literally ten minutes ago and inspired this post.

forEveryTrace

In our repo there’s a folder called ./examples and in that folder, there’s an example called ./forEvery. Here’s the contents of the code in the folder:

Source code for forEveryTrace

If you’re familiar with C++ code at all, you’ll notice the main function at line 34 is really simple. Initialize the library, call a single function, and clean up.

While simple, that one function packs a wallop. It does exactly as it says, it visits every block in the entire blockchain it’s configured for. (By default this means Ethereum Mainnet, but we’ll get back to this in a minute.)

What line 38 does is:

For every block in the current blockchain, call the function visitBlock (line 29) and pass it a pointer to counter.

What does the visitBlock function do?

For every transaction in the current block, call the function visitTransaction (line 24) passing in the same pointer.

What does the function visitTransaction do?

For every trace in the current transaction call the function visitTrace (line 16) passing in the same pointer.

And finally, what does visitTrace do?

It keeps a count of the total number of traces in the entire blockchain and prints out each trace.

An Aside on the Concept of ON THE DESKTOP

We’re not extracting any permanent data from the chain.

While TrueBlocks provides for a binary cache that speeds up processing many times over raw node queries, the cache is optional. The cache is only employed if the end-user instructs us to use the cache.

We leave the decision of whether or not to cache to you. This is markedly different from any other solution we’re aware of and it’s why we still work on a desktop.

If you want to cache the entire blockchain because that’s your requirement — the first thing you have to do is get a really, really large hard drive — and then alter the above code to write each block, transaction, or trace to either our cache or your database.

This is the exact problem we have with solutions such as Amber Data and EtherScan. They’ve chosen to extract and cache every single piece of data on the entire blockchain prior to the developer’s decision if it’s pertinent. This creates many, many Terabytes of data which means their solutions will never work on a desktop and therefore will never be truly decentralized. Enough soapbox — back to the point.

For Every Trace on Any Chain in the Visible Universe

I was inspired to write this post because I thought of the following modification to the above example.

What does this actually do?

It visits every trace in every transaction in every block on any EVM-based blockchain ON A FUCKING DESKTOP.

Support Our Work

And you!

If you like this article and wish to support please donate to our GitCoin grant https://gitcoin.co/grants/184/trueblocks. Donate during the next matching round, and we get the added benefit of the matching grants. Even small amounts have a big impact.

If you’d rather, feel free to send ETH or any other token to us directly at trueblocks.eth or 0xf503017d7baf7fbc0fff7492b751025c6a78179b.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thomas Jay Rush

Blockchain Enthusiast, Founder TrueBlocks, LLC and Philadelphia Ethereum Meetup, MS Computer Science UPenn