Scaling Ethereum - A short summary

This post will provide you with a short introduction of the future of ethereum with regards to it’s scalability.

The problem statement

  • Transaction throughput is constantly hitting limit at ~ 15 transaction / second
  • Gas usage and price are increasing at at time skyrocketing especially during ICOs or hyped games like cryptokittens
  • Gas limits are a limiting factor on what kind of transaction can be mined. Large computation are expensive if not impossible to be included on ethereum blockchain
  • Latency and confirmation times are a limiting factor for some use-cases. Imagine waiting 3min everytime you buy a cup of coffee.
  • PoW is highly inefficient in terms of computer hardware & electricity costs. Only a very small percentage of total network computational power are needed to process all transaction

Metropolis & Sharding

Metropolis

Metropolis is a planned development phase for ethereum. It will include proof-of-stake which is a pre-requisite for many important scaling solutions like sharding. The proof of stake implementation of ethereum is called Casper. It consist of two hard forks, Byzantium (Implemented) & Constantinople.

Constantinople is rumored to include Casper and is expected to be released in 2018 to complete the Metropolis phase.

More info on Metropolis

Sharding

It works by basically splitting the chain into smaller pieces, allowing more transaction to be processed by different shards at the same time while still maintaining the security and transparency nature of the blockchain
More transactions can be validated at once in parallel, and shard nodes only need to store certain segments of the blockchain
Sharing in PoW is technically possible but carry a high risk of smaller pool overtaken due to lower hashrate hence, it will only be implemented after proof of stake aka Casper

Validator Manager Contract

Validator Manager Contract is an special contract that helps join sharding network into mainchain
It is a proof of stake system where ether is deposited into this contract as collateral & validators’ stake may be slashed if they misbehaved.
It uses pseudorandomness sampling. One shard chain validator would be sampled from validators pool list, and become the collator of the specific shards in specific “period” to make it impossible for any bad actor from predicting which validator will create blocks
It has collation header validation which the VMC provides on-chain verification immediately
By utilizing UTXO model, the user can deposit ether on a specific shard via transaction call and create a receipt (with a receipt ID) on main chain. The shard chain user can create a receipt-consuming transaction with the given receipt ID to spend this receipt to achieve cross-shard communication.
It is also a on-chain governance system where VMC acts as the parliament to enable validators to vote on-chain.

More info on Sharding

Plasma

Framework of incentivized and enforced execution of smart contracts which is scalable to a significant amount of state updates per second
A set of smart contracts that allows for private chains or transaction with periodic synchronisation with the main chain
Each “private blockchain” can be purpose fitted depending on use case. dex, social networks, microtransaction
Allows for unlimited scalability with enforceable state transition via proof of fraud
Nested blockchains
Block rollback upon proof of fraud

Plasma whitepaper
OmiseGO - First plasma project construction post
First plasma POC demo by Bankex

State channels & Raiden

It is for blockchain interactions which could occur on the blockchain but are done off chain

How it works :

  • State is locked (could be eth) with multisig/smart contract
  • Only a specific set of participants must completely agree with each other to update it.
  • Signing and transaction happens as usual but off chain. Each new update “overrides” previous updates.
  • Prevent malicious actor eg submitting earlier state before Alice sent money to Bob so Alice can “pretend” didn’t pay
  • Submit the state back to the blockchain, which closes the state channel and unlocks the state again

Note that the maximum amount of ether that can be transacted is the total amount locked when opening the channel

Raiden

It is similar to bitcoin’s Lightning where it is a off-chain scaling solution, enabling near-instant, low-fee and scalable payments
Raiden allow for multi-hops to find payment channel instead of creation n-to-n channels

Think of it as transacting cheques as “real money” and Ethereum as the bank to deposit & withdraw. There is also no need to write direct recipient and fees apply only when cheque is “cashed in”.

µRaiden is a subset of Raiden technology for simpler applications which will be cheaper & easier to use. It supports many-to-one payment setups, like users interacting with a Dapp. It does not support multihop transfer fees, and therefore only allows to send tokens unidirectionally to predetermined receivers.

More on raiden

Truebit

Bridging computation on-offchain by doing offchain computation and provides onchain dispute handling
Unanimous consensus protocol meaning even if 1 participant dispute on the result, the verification layer kicks in :

  • Onchain code checks the disputed line of code onchain (it defeats the purpose to compute the entire problem on the blockchain) and punishes the error
  • Validator takes the reward for resolving errors if error is found
  • Participant’s stake is slashed if dispute proved to be false

There is also a forced Error Mechanism to keep validators from leaving the network when all solution are accurate without errors. It works by having system generated error every x block as incentive to keep validators validating every solution submitted to the network

Truebit Whitepaper

Final words

Each technology tackles scalability in its own way and are complementary - a good sign for the future of ethereum
Coming months or years we will see upcoming large scale projects. There are a lots of protocol level projects being developed like loom network, distributed data storage projects and other scalability projects

Excellent read: Making Sense of Ethereum’s Layer 2 Scaling Solutions: State Channels, Plasma, and Truebit

Solidity development with Remix and Metamask

This post aims to familiarise you with the process of deploying & interacting smart contracts. In this post, we will be using remix as the IDE and metamask as the frontend UI to interact with the smart contract.

Enter the Remix

Remix is an online IDE for Solidity with an intergrated debugger & testing environment. It allows developers to compile and deploy smart contracts on a local test environment or public blockchain via metamask. If you haven’t, read the previous post first.

Access the latest version of remix

Some things to note when using remix

  • Ensure the environment is correct
    • Javascript VM option means the blockchain exist only on the remix environment
    • Injected web3 option will use metamask to connect to the ethereum network that metamask is currently on
    • Web3 Provider option allows you to connect to any ethereum node (ganache for example)
  • The details button in Compile tab is useful to get smart contract’s Bytecode or ABI for use in 3rd party tools.
  • When verifying contract source code on etherscan, make sure optimiser is selected

More details & tutorials are available on the official documentation here

Meet the Metamask

Metamask is a chrome extension that acts as a bridge that allows you to run Ethereum dApps right in your browser without running a full Ethereum node.

Install metamask

Some things to note when using metamask

  • Metamask uses Mnemonic phrase as private keys. Meaning, the actual private key is derived from the seed words and you can restore your wallet using it. Keep them safe!
  • Multiple addresses can be generated using wallet (or seed words). This is known as a Deterministic wallet

More info on metamask on their official github page

Deployment

There are several ways to deploy smart contract. The most common ways are via truffle using the truffle migrate/deploy command or using remix. Alternatively, you can also compile the smart contract into bytecode and deploy in any 3rd party tool or via plugins to metamask. However we will only focus on truffle and remix in this blog.

In addition to testing it locally/privately like Ganache-cli, there are 3 public test nets in ethereum that you can use to test the smart contract before deploying on the main net

  • ROPSTEN - Proof Of Work

  • KOVAN - Proof Of Authority

  • RINKEBY - Clique Consensus

We usually use Rinkeby as it is more stable and contains a convenient facuet to get test ethers.

Interacting with smart contracts

After deploying smart contracts, you can interact with smart contracts in 3 main ways

  • Using remix in-built tool under Run tab - It should automatically list the contract you deployed. Alternatively, load a contract address
  • Using 3rd party wallet like myEtherWallet, myCrypto or mist by importing the ABI and contract address
  • Calling web3 javascript directly via interfaces like truffle console or unit tests

Note: To get data or call functions notioned by “view”, meaning that the request does not alter the blockchain state, you do not need to create any transaction in the blockchain.

Getting Started On Blockchain Development

This is not a tutorial on blockchain development. Rather, this article will relay to you what resources you may need to start developing a smart contract. Through our learnings and trials at 2359, we have compiled a list of resources that will save you some time googling and get started on coding in the shortest time possible.

Quick Readings

Getting into blockchain development is different from other platform in a way that it is not technically challenging. However, it requires a lot of domain knowledge and understanding of its core philosophy. Therefore it is important that you read up on the following articles to understand what blockchain is about and the problem it is trying to solve.

Online Courses

Our favourite go to course is CryptoZombies. The course introduces you to Solidity, the programming language for creating smart contracts on Ethereum.

There is also a good course on Udemy which we highly recommend, Become a Blockchain Developer with Ethereum and Solidity.

Tools

Now that we are ready for some development action. You should get acquainted with the tools of the trade.

  • Truffle Framework
    A development environment that helps with testing and deploying of smart contracts.

  • Etherscan
    A website that allows you to get information on a contract or a transaction.

  • Remix
    An online IDE that allows you to compile, run and debug your smart contract.

  • Oracles Combine Solidity
    Solidity allows you to reference other smart contracts through the import statement. However there will be times when you need to flatten your smart contract into one single file. For example when you want to verify your smart contract with Etherscan. Oracles Combine Solidity is the tool right for the job.

  • Ganache-cli
    Run ganache-cli to create your own local testing environment. It will also provide 10 accounts with 100 ether each to play with by default.

Best Practices and Security

  • Smart Contract Best Practices
    This is a comprehensive document that details the best practices you should employ in developing your smart contracts

  • Securify
    A tool that can help to point out security flaws in your smart contract.

References