Case Study: Delivering an Ethereum client to the market in 7 months
Ethereum is frequently referred to as the second most famous cryptocurrency, after Bitcoin. Though unlike Bitcoin — and most cryptocurrencies — Ethereum is to be much more than just a medium of exchange or a store of value. Instead, Ethereum aims to present itself as a decentralized computing network built on blockchain technology. Here you can read more about the differences between Ethereum and Bitcoin. There is no doubt about the adoption of cryptocurrencies as legal tender in national economies. They can bring solutions to many industries, for example, the art industry.
One of our clients asked us to help them with the development of an Ethereum client because they needed a highly-skilled team, ready to swiftly deliver the Ethereum client to the market. The client was a technology company that builds cryptocurrencies and blockchains for a variety of businesses. Above all, they valued scientific research and formal methods in their work.
What is an Ethereum client?
Ethereum client is a piece of software that enables users to interact with the Ethereum p2p network. This means:
- Downloading the whole blockchain state from other clients in the network
- Sending and receiving Ethereum transactions
- Processing and validating transactions locally, to recreate a blockchain state
- Integrating with various external tools in the Ethereum ecosystem such as Miner or External wallets via a standard set of JSON RPC endpoints.
The most comprehensive overview of the inner workings of Ethereum can be found in the so-called yellow paper.
This is a highly technical document that describes all of the data structures and operations that a fully functioning Ethereum client needs to support.
For anyone interested in just the gist of things, there exists a whitepaper intended for the broader public; https://ethereum.org/en/whitepaper/
Steps in building the Ethereum client
Assembling the team
Our agile team of developers has started the project with two experienced Scala engineers, working in a close partnership with the client’s developers. After successfully reaching the first project goals together as an accelerated team, the team scaled up to four experienced engineers on the Scalac side.
Scala programming language for secure Etherium client
One of the reasons for creating another Ethereum client was the need to diversify the landscape of Ethereum classic clients. Users of Ethereum Classic currency have much less choice than users of its sister currency, called just Ethereum.
Another reason was the choice of the Scala programming language. According to our client;
So, the company decided to develop the Ethereum client functionally. The choice of Scala was a natural consequence of that approach. Furthermore, as Scala works on JVM, it was an easy way to use a significant number of libraries, all ready to use, which would also help to shorten the time to market.
Key features of the Ethereum client
Ethereum Virtual Machine
One of the key features of Ethereum are the so-called “Smart Contracts”, which are pieces of code and state, living on the Ethereum blockchain. These programs make the Ethereum blockchain really flexible and suitable for different sets of applications.
Every Ethereum client must have the ability to execute smart contracts to correctly process transactions. All smart contract executions happen on the Ethereum Virtual Machine, a stack-based virtual machine, with over 140 opcodes (operations)
Merkle Patricia Tree
One of the requirements for a fully functional Ethereum client is the ability to execute transactions contained in blocks, and then validate the resulting world state against the block header.
To make this possible, as with all other Ethereum nodes, we implemented a data structure called the Merkle Patricia Tree. The Merkle Patricia Tree is a cryptographically authenticated data structure used to hold key-value bindings.
It is also fully deterministic, which means that two trees with the same key-value binding will always have the same root hash.
This property is key to Ethereum state validation. It means that each node in the network can execute a set of transactions and be sure to end up in the same state as other nodes.
Ethereum network stack
The node created by Scalc implements all of the necessary features required for successful network communication. The main features are:
- RLP encoding, serialization format used by all of the clients over the network
- A full set of messages supported by all of the clients
- An RLPx transport protocol, an encrypted protocol working over TCP required to communicate between clients. A full specification can be found at; https://github.com/ethereum/devp2p/blob/master/rlpx.md
- A node discovery protocol. As for now, the node does not implement a fully working Kademlia protocol, but rather a simplified protocol minimal enough to discover peers. There are plans to upgrade it to full Kademlia
JSON RPC API
JSON RPC API is a standard way for users to interact with their Ethereum clients. Our node implements a whole set of endpoints defined by Ethereum standards;
Taking into account that every Ethereum client works in a highly adversarial setting in which every vulnerability could be used by malicious actors to steal user funds, each of the components needed to be implemented with great attention to detail.
The initial release of our Ethereum node underwent a security audit by external auditors. The audit didn’t find any critical vulnerabilities, but only 3 medium ones that were quickly resolved or discussed with the auditors.
By using Scala to implement the Ethereum node, the Client was able to deliver a fully working Ethereum client with all its necessary features, in only 7 months, with a small team of developers. This was possible due to the rich JVM ecosystem of libraries that Scala can take advantage of, as well as the general brevity of the language.
After the successful implementation of the Ethereum client, our engineers have since been involved in the development of further blockchain endeavours.