Process synchronization in blockchains

Distributed blockchain technologies such as bitcoin have a consensus mechanism used to synchronize the transaction ledger, but some of the newer chains, such as Ethereum, actually run a turning complete virtual machine on the blockchain, and process synchronization is important to make sure that smart contracts are computed properly. For those of you unfamiliar with Ethereum, the purpose of these smart contracts is to programmatically define the rules of a business contract, whether as a simple exchange of tokens or as more complex operations such as escrow. Last fall, the Ethereum network was brought to its knees by the popularity of a virtual cat breeding application called Cryptokitties, which allowed users to buy, breed, and sell virtual cats. All of the data for the application and all operations were performed and stored on the Ethereum blockchain. Other notable uses for Ethereum include decentralized exchanges, where users can buy and sell Ethereum’s ERC20 tokens with others over order books and transactions that are maintained on-chain.

Ethereum’s main programming language is called Solidity, and it like any functional language it translates high-level human-readable code into bytecode, which in this case is run on the Ethereum Virtual Machine (EVM). Resembling Javascript, Solidity requires deterministic programming functions which must not only be implemented by miners but must also be wholly validated by all other nodes on the network — hence no Random Number Generators. A full explanation of blockchain mining is beyond the scope of this discussion, but suffice to say that each mining node on the network is competing to find a sufficiently small hash of the previous blockchain state, as well as all transactions that have occurred since that last state, along with a random number called a nonce. Once a miner finds the new block, it is distributed to other nodes on the network and independently verified.

When a smart contract is published, it is available for use by the public. Multiple users may access the smart contract and interact with it as desired. Since a finite number of transactions or smart contract operations can be performed in each Ethereum block (generated between 10-19 seconds on average), Ethereum uses a gas system in order to determine which transactions have higher priority. When initiating a transaction, a user — or smart contract — determines the amount of gas to allocate to the transaction. Gas is paid as a fraction of Ether, Ethereum’s currency, and prevents spammers from flooding the network for free.

While these smart contracts are actually processed in serial, there are proposals underway to allow actual parallelization and muti-threading within the blockchain. For now, the synchronization problems inherent to blockchain technology are quite unique. Beyond Ethereum, there are projects in place that are attempting to create supercomputers and artificial intelligence platforms. I haven’t delved into the technical details of these implementations yet, but the whitepapers are available online and GitHub repositories are available for those who wish to deploy test-nets in their own environments.