A Deep Dive into Ethereum

A low level understanding of how Ethereum works in flight.

A Deep Dive into Ethereum
  1. Ethereum State: Contains a key-value mapping of addresses to account objects.

  2. State: Contains the current information of an Ethereum network, including

    1. Account Balances

    2. Nonce

    3. Contract code

    4. contract storage

  3. History: Contains past events of an Ethereum network, including

    1. Transactions

    2. Receipts

  4. Storage Tree Root: Refers to the complete set of storage data in an Ethereum network.

  5. Types of Accounts: Ethereum has two types of accounts:

    1. User Account with a private key

    2. Accounts controlled by code (smart contracts)

  6. Gas Fee: An algorithm that prevents a program from running forever by charging a fee per computational fee.

  7. Gas Limit: If a transaction exceeds the gas limit, the miner will revert the transaction, consuming the gas fee. This is done to prevent transactions from being only partially executed, which is a vulnerability point for smart contracts.

  8. V, R, S (ECDSA Signature Values): Used in Ethereum transactions to provide security and proof of ownership.

  9. Receipts: Objects that get hashed into the Ethereum blockchain network and include:

    1. Intermediate State Root: A hash that represents the entire state after a transaction has taken place.

    2. Cumulative Gas Used: The total amount of gas used in a block until now, including the current transaction.

    3. Logs: Data storage is generated after every transaction and stored in a block. They are used for efficient light client access to transaction records and are append-only and not readable by smart contracts.

  10. EVM (Ethereum Virtual Machine): Stack-based architecture that includes:

    1. Stack

    2. Memory and storage

    3. Environment variables, provide complete data about a transaction, such as a block number, block hash, previous hash, block time, mining difficulty, etc.

    4. Logs

    5. Sub-calling

  11. Application Binary Interface: Every function call is compiled into transaction data, with the first 4 bytes being the function ID and the next 32 bytes being the first argument, followed by another 32 bytes for the second argument.

  12. Recursive Length Prefix Encoding (RLPE): The serialization protocol used in Ethereum, which is the process of saving an object's state to a sequence of bytes and then storing them in a file.

  13. Ethereum Mining: Focuses on memory access and uses multi-level DAG construction. The process involves creating a cache through a memory-hard function, creating a dataset, and then running an algorithm to turn the mining data into a seed and grab 64 random nodes from the available pieces of data sets.

  14. Fast Blocks and High Transaction Load: An increase in stale rate and drop in miners can lead to a 51% attack. The UNCLES solution aims to break this attack.

  15. Merkle Trees: Compact, efficiently verifiable proofs used in Ethereum for efficient light client usage in verification.

  16. Merkle Trees in Ethereum: Used for:

    1. Transactions data

    2. State route data, which includes a root hash and a tree generated through route hash containing hashes of hashes of hashes, representing the states of every account in the Ethereum network, with account objects as the bottom leaves of the trees

    3. Receipts

  17. Creating a Blockchain Network: Involves:

    1. Consensus mechanism

    2. State transitioning system

    3. Scalability

  18. Scalability is a crucial aspect of Ethereum and there are various approaches to enhance it:

    1. Sharding: It's a method of breaking down the entire network into smaller and more manageable pieces, allowing multiple nodes to process transactions and smart contracts in parallel.

    2. State Channels: It's a mechanism that allows users to transact with each other off-chain, reducing the load on the Ethereum network.

    3. Rollups: They are a layer 2 scaling solution that bundle multiple transactions into a single transaction, thereby reducing the load on the Ethereum network.

    4. Side chains: They are separate chains that run alongside the main Ethereum network, enabling users to perform transactions and execute smart contracts without affecting the main network.

    5. Plasma: It's a scalable and secure off-chain solution for Ethereum that enables fast and efficient transactions.

Blockchain vs Cloud Computing

  1. Blockchain and cloud computing are two distinct technologies that have their own advantages and disadvantages. While cloud computing is a centralized solution that provides on-demand access to shared computing resources, blockchain is a decentralized solution that enables secure and transparent transactions without the need for intermediaries.

Private Mining

  1. Private mining refers to the practice of setting up a private blockchain network for mining new blocks.

    1. Hardware Mining: It involves the use of specialized mining hardware to mine new blocks on the network.

    2. Using other services and high encryption: Some users opt to use other services or use high-end encryption methods such as homomorphic encryption or indistinguishability obfuscation for computations to mine blocks privately.

Cryptographic Operations for High-end Privacy

  1. Some cryptographic operations can be used to enhance privacy in blockchain networks:

    1. Ring Signatures: They allow a group of users to sign a message in a way that conceals the identity of the actual signer.

    2. Curve Pairings: They are mathematical operations that enable secure communication and transactions in blockchain networks.

    3. Zk-proofs: They are zero-knowledge proofs that allow users to verify the authenticity of transactions without revealing the underlying data.

Conclusion

  1. Running a blockchain network is a combination of cryptography, mathematical proofs, and economic game theory. The entire computation in a blockchain can be defined by a tuple that contains the block state, transaction, message, code, memory, stack, program counter, and gas. The block state contains all the accounts on the blockchain network, including the account balances.

  2. Mining, validation, and smart contract execution are interrelated processes in a blockchain network, with miners playing a crucial role in maintaining the network's efficiency.

  3. Deploying a smart contract involves converting the smart contract code into byte code using a compiler such as solc, followed by an ABI call and EVM processing that pushes the contract to the Ethereum blockchain.

  4. The block state is a global state that contains all the accounts, including the account balances, present on the blockchain network.

  5. The difference between mining, validation, and smart contract running is that mining is the process of adding new blocks to the blockchain network, validation is the process of checking the validity of a block, and smart contract running is the process of executing the code of a smart contract. Inefficiency in miners can occur when there is a mismatch between the computational power required for a task and the computational power of the miner.

  6. A smart contract gets deployed by converting the smart contract code into byte code using a compiler such as solc, calling the ABI (Application Binary Interface), processing the EVM (Ethereum Virtual Machine), and finally pushing the smart contract to the blockchain network. The following path represents the process :

smart contract > byte code conversion using solc > Application binary Interface call > Ethereum virtual machine processing > Ethereum virtual machine pushes the smart contract to the blockchain