[Episode 3] Mastering Ethereum : A short summarised story

We will cover various ethereum clients like GETH, Parity in this episode. We will see how to setup a full node and what are remote ethereum clients

[Episode 3] Mastering Ethereum : A short summarised story

In this episode we will see various ethereum clients and discuss about them.

So, Lets get started.

What is Ethereum Client


Ethereum client is a software application that implements the Ethereum specification and communicates over the peer-to-peer network with other Ethereum clients.

There are many ethereum clients out there written in different programming languages but they all sit under one roof and speak the same protocol and follow same rules.

Ethereum is developed by open source community, and the source code for all the major clients is available under open source licenses.

Unlike Bitcoin, Ethereum's specification is documented in the “Yellow Paper” which is periodically updated upon major changes. Due to this many interoperable Ethereum client were developed and this diversity have proven defensive against attacks. How? While one particular client software is patching the exploit, other clients keep the network running almost unaffected.

Ethereum Networks


Ethereum-based networks are Ethereum, Ethereum Classic, Ella, Expanse, Ubiq, Musicoin, and many others. These may or may not interoperate with each other. So every version of ethereum client software cannot run every ethereum-based blockchain.

Six main Implementations of Ethereum protocol :

Ethereum ClientLanguage
ParityRust
GethGo
cpp-ethereum C++
pyethereumPython
MantisScala
HarmonyJava

Should I Run a Full Node?


Independently operated and geographically dispersed full nodes are strength of a blockchain. But incur a cost in hardware resources and bandwidth. The data download size is > 100 GB and keeps on increasing as new blocks are added.

Various types of Ethereum Clients :


Ethererum Client.png

1. A full node running on Mainnet.
2. A testnet Node running on public test networks
3. Local Private blockchain like Ganache
4. Cloud based ethereum Client like Infura
5. Light Client
6. Remote Ethereum Client

Lets see each of them in detail.

Light Client :


  • Validates block headers and use Merkle proofs to validate the inclusion of transactions in the blockchain and determine their effects. Still in development phase.

Full Node :


Full node are full fledged ethereum clients running the blockchain network and participating in operation** of the networks like keeping copy of blockchain data, mining blocks, or validating transactions etc., but also incurs some mild to moderate costs** for you.

Advantages                             
---------------------------------------------------------------------
1. Supports the resilience and censorship resistance of the network
2. Validates all transactions of Ethereum-based networks
3. Deploy and interact with any contract without intermediary
4. Query the blockchain data (accounts, contracts, etc.) even offline 

Disadvantages
---------------------------------------------------------------------
1. Requires high hardware and bandwidth resources
2. Need days to fully sync when first started
3. Must be maintained, upgraded, and kept online to remain synced

Testnet Node


Testnets are public blockchains with many other users and contracts, running “live” and uses fake ethers to simulate a test environment just like mainnet.

Advantages
----------------------------------------------------------------------
1. Sync and store much less data (about 10GB) and can fully sync 
    in few hours
2. Requires test ether, which has no value and can be acquired free 
     from “faucets”

Disadvantages
----------------------------------------------------------------------
1. Test ethers can’t test security against real adversaries
2. Testnets do not experience network congestion like the public 
    mainnet sometimes does so realistic tests are not possible

Local Blockchain simulation


For quick testing purposes, the best option is having single-instance private blockchain running of on your system. Ganache is the most popular one.

Advantages
----------------------------------------------------------------------------
1. No data to sync as you mine the first block yourself
2. No need to obtain test ether, you award yourself mining rewards
3. Just you and your deployed contracts. Nothing else on the chain.

Disadvantages
------------------------------------------------------------------------------
1. It doesn’t behave the same as a public blockchain as you are the
    only user. Mining is more predictable as you are the only miner. 
2. Real scenarios like public blockchain cant be simulated.
3. You have to deploy everything that you want to test, including 
    dependencies and contract libraries.
4. Cant use any public contracts and their addresses to test some 
    scenarios (e.g., the DAO contract).

Running an Ethereum Client


Hardware requirement for full node

RequiredRecommended
CPU2+ cores4+ cores
RAM8GB+ HDD16 GB+ SSD
Hard DriveHDD with 80GB storageFast SSD with 500 GB storage
Internet Speed8 MBit/sec25+ MBit/se
  • Blockchain’s size keeps on increasing as new blocks are added to the chain continuously, so more disk space will be required, so it’s recommended to check the blockchain’s latest size before you start syncing.

Full “archival”(all state kept on disk) node requires more than 1 TB of disk space than “pruned”(old state removed) node.

Software requirement for running a full node

You can choose any client software from the clients list and follow their github repo for installation. Here we will only discuss about Parity and Geth client software.

Required softwares:

  • Ubuntu GNU/Linux operating system
  • Git
  • Golang(For Geth)
  • Rust(For Parity)

Parity


Parity is developed by Parity Tech, a UK company, and is released under the GPLv3 free software license and written in rust.

Steps:

  • Install software libraries, such as OpenSSL and libudev
    bash $ sudo apt-get install openssl libssl-dev libudev-dev cmake
  • Clone the source code from GitHub
    $ git clone https://github.com/paritytech/parity
  • Install packages using cargo
    cargo install
  • Check the parity version to confirm its installation
    $ parity --version
  • you can now sync the blockchain and get started with some basic command-line options.

Geth


Geth is “official” implementation of the Ethereum client developed by Ethereum Foundation and written in Go. Every Ethereum-based blockchain will have its own Geth implementation. So grab your correct version.

Steps:

  • Clone the source code from GitHub
    $ git clone <Repository Link>
  • Install packages using make
    $ make geth
  • Check the geth version to confirm its installation
    $ ./build/bin/geth version

The First Synchronization of Ethereum-Based Blockchains


Many Ethereum-based blockchains faced denial-of-service attacks in end of 2016 that resulted in > 1 min validation time per block.

Ethereum faced DoS attack starting from Block#2,283,397(Sept 18, 2016) to Block#2,700,031(Nov 26, 2016). Ethereum then implemented a series of upgrades, using hard forks and also cleaned up the blockchain by removing some 20 million empty accounts created by spam transactions.

If you are syncing affected blockchains with full validation, your client will slow down to validate the affected blocks. Choose “fast” synchronization option to skip the full validation of transactions until it has synced to the tip of the blockchain, then resumes full validation.

Parity does fast synchronization by default. For Geth, use flag --fast for faster sync

The JSON-RPC Interface


Ethereum clients offer API and a set of RPC commands encoded as JSON called JSON-RPC API. This interface allows us to write programs on Ethereum blockchain using Ethereum client as gateway.

RPC interface is offered as an HTTP service on port 8545 and restricted to localhost for security reasons.

To access the JSON-RPC API, you can use a specialized library or HTTP client like curl.

Lets see an example of curl request :

$ curl -X POST -H "Content-Type: application/json" --data \
'{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' \
http://localhost:8545

Each request contains four elements:

  • jsonrpc : Version of the JSON-RPC protocol. This MUST be exactly "2.0" .
  • method: The name of the method to be invoked.
  • params : parameter values to be used
  • id : When making multiple requests in a single JSON-RPC call, response can be mapped with request using id

Lets see response of above request :

{"jsonrpc":"2.0","id":1,
"result":"Geth/v1.8.0-unstable-02aeb3d7/linux-amd64/go1.8.3"}

Remote Ethereum Clients


Remote clients offer a subset of the functionality of a full client. They dont take part in validating or mining blocks and do not even store copy of blockchain data.

These clients typically provide the ability to do one or more of the following:

AbilityDescription
WalletManage private keys and Ethereum addresses in a wallet.
TransactionsCreate, sign, and broadcast transactions.
InteractionInteract with smart contracts, using the data payload.
DappsBrowse and interact with DApps.
ExplorerOffer links to external services such as block explorers.
ConversionConvert ether units and retrieve exchange rates from external sources.
Inject ProviderInject a web3 instance into the web browser as a JavaScript object.
Use ProviderUse a web3 instance provided/injected into the browser by another client.
RPC AccessAccess RPC services on a local or remote Ethereum node.

Remote clients provide above features by connecting to an existing full node running elsewhere(Own or third party).

So Wallets like Metamask, Emerald Wallet, MyEtherWallet, MyCrypto, etc. are not just Wallets. They are Remote ethereum clients. They entirely trust a full client to give them access to the blockchain, and hence lose significant security and anonymity guarantees.

Mobile Wallets

WalletDescription
Jaxxmulticurrency mobile wallet based on BIP-39 mnemonic seeds
StatusA mobile wallet and DApp browser, with support for a variety of tokens and popular DApps
TrustSupports ERC20 and ERC223 tokens
CipherFull-featured mobile DApp browser and wallet integrated with Ethereum apps and tokens.

Browser Wallets

WalletDescription
MetamaskVersatile browser-based wallet, RPC client and basic contract explorer connecting to various ethereum blockchains. Also injects a web3 instance into the browser JavaScript context, acting as an RPC client
JaxxAlso availabile as browser wallet
My Ether walletJavascript based wallet that Bridge to hardware wallets, act as RPC client and web3 interface
MyCryptoopen source fork of my ether wallet
MistWas the first Ethereum-enabled browser, built by the Ethereum Foundation which introduced camelCase checksum (EIP-55)

Fabian Vogelsteller, author of ERC20, was also the main developer of Mist. Mist runs a full node, and offers a full DApp browser with support for Swarm-based stor‐ age and ENS addresses.