DEV Community

Alex Dovzhanyn
Alex Dovzhanyn

Posted on

Building a Blockchain - What I've learned over the past few months

7 months ago, when I first embarked on the journey of creating a new blockchain, I was inspired by the thought of changing the internet -- of being on the front lines of innovation, developing bleeding-edge technology, and pushing the boundaries of how we interact. I was deeply intrigued by blockchain technology and it's ability to change the world for the better, to make the internet into the decentralized and uncontrolled networking system that it was meant to be.

I noticed a few gaps in the blockchain community at the time, for example: all cryptocurrencies/blockchains fit into a maximum of 2 of the following categories:

  1. Fast
  2. Anonymous
  3. More than just internet money

A blockchain that was both fast and anonymous was meant to be a currency, an anonymous blockchain that was more than just internet money was not fast, etc. As an engineer, I thought to myself, "why not combine all three?". If we're going to build a decentralized internet, we can't settle for something that doesn't satisfy all of the things we do on the internet today: shop, use web apps, and manage banking accounts (hopefully securely). This led me to creating Elixium (@ElixiumNetwork, /r/elixium): a fast, anonymous, and scriptable blockchain network.

Elixium allows developers to create decentralized applications written in Javascript, removing the barrier of needing to learn a new language in order to write dApps.

Here are a few thing I learned in the process:

1. Distributed Computing is Hard

Finding a way to allow people to write applications in javascript, and making it fair to the miners is a difficult problem to solve. Javascript is a turing-complete language, which means it is impossible to parse through it's code and determine whether or not it will run forever (e.g. contains an infinite loop). I spent hours trying to figure out a good way to do this, and finally came up with the following solution, based on Ethereum's model:

  1. Parse the javascript into it's abstract syntax tree (AST) representation
  2. Sanitize the javascript, making sure all variables are namespaced, in order to minimize interference with any other code that would be interacting with the contract
  3. Calculate costs based on the computational complexity of a line of code.

This allows miners/nodes on the network who are running the code of the contract to charge a small fee to the developer of the contract for running the code (similar to how hosting services charge money to host your website, or how AWS charges for usage of their servers).

This also solved the issue of infinite loops: eventually the funder of the contract would run out of funds to run it, and the contract execution would stop (even if there was an infinite loop)

2. Networking is really cool

I used to take the convenience of HTTP for granted, but after writing a communication protocol on top of TCP that fit the specific needs of the Elixium network, I realized how crucial it is to understand the way that internet communication works. The tentatively-named Ghost protocol is built on top of TCP and uses an SRP protocol layer to establish a handshake between peers, allowing for end-to-end encryption.

Writing a communication protocol isn't actually too hard - you all should give it a try!

3. Nothing is set in stone

Since blockchain is such a new field of technology, there really aren't that many standards set in place, as you might expect there to be if you come from a web development background. In web development, there's usually one or two different ways of accomplishing a goal that have been standardized, and those standards are relatively easy to spot, e.g. using bcrypt for password authentication, or using Ajax to make XHR requests, or manipulating DOM elements.

In the world of blockchain, it's a lot more open. At first, this felt weird, because I was used to knowing what the "right" way of doing something was, and if I couldn't find the "right" way, it felt weird to me. Slowly I realized that there is no tried and true way of doing many blockchain related things, like which hashing algorithms to use, the proper way to set up a consensus algorithm, or even how to store data! This allows you to be really creative in the way you solve problems, and although it first felt taboo, it's actually really liberating.

Oh, and by the way, Elixium is open source and looking for contributors, so hop on GitHub and help us make a better internet!

Top comments (2)

alexdovzhanyn profile image
Alex Dovzhanyn

That's a really great question, but currently, we don't have a solution in mind, as we haven't reached that point in development as of yet. We've been focusing on having contract code work seamlessly with the blockchain + peer to peer network.

I'll make sure to update this post + tag you in a comment once we reach the point where we've thought it out and figured out a good solution! And at that point it would be great to have you poke some holes in our implementation if you're willing, it's always good to have more eyes on the code!

alexdovzhanyn profile image
Alex Dovzhanyn

It's good for pretty much anything that might need decentralization, anything that currently requires trusting a 3rd party (such as voting, property management, banking, etc). It's really a way to allow transparency in a system and remove the need for an intermediary