Skip to content

Instantly share code, notes, and snippets.

@deepakraous
Last active January 13, 2022 13:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakraous/d35635acc6d645494dba7203f1b525b5 to your computer and use it in GitHub Desktop.
Save deepakraous/d35635acc6d645494dba7203f1b525b5 to your computer and use it in GitHub Desktop.
Recap Part[1-6] of Medium Post

Introduction

  • Ethereum is a world computer.
  • Ethereum is a combination of A Singular World State+ A Virtual Machine.
  • World State is a collection of all States.
  • A State is a collection of Blocks.
  • The World State is stored as a Patricia Merkle Trie as per Recursive Length Prefix(RLP) spec in a mini Database.
  • Only a Virtual Machine can add a new State.
  • The Virtual Machine needs fuel to execute instructions and the fuel is ‘Ether’ to prevent rogue actions.

Recursive Length Prefix-E(Encoding)

  • RLP-E is a set of rules to encode a item or a list of items.
  • RLP-E has different set of rules based on the size of the payload.
  • Strings are denoted as byte arrays.
  • Empty strings, lists have a predefined value.
  • RLP-E is used due its capability to compact data and is simple.
  • Encoding "dog" with RLP-E will be [ 83 64 6F 67 ]. 80->: String,length = 83-80

Recursive Length Prefix-D(Decoding)

  • RLP-D is the opposite of Encoding.
  • RLP-D converts RLP-E to its original.
  • [ 83, 64, 6F, 67 ] -> "dog".

Key, Values

  • Key in ethereum can be thought of as a map .
  • Follow the path layed out by the Key to get to a Value.
  • Key Value pair can be represented as { k, v }.
  • E.g: { a77712345, 0.02 }, where k->: "a77712345" and v->: "0.02"

Trie

  • Trie is a data structure used by Ethereum.
  • Value(RLP-E) is stored as Trie for faster retrieval and search.
  • Real life use case for Trie is Auto-Lookup or Auto-Correct feature.
  • Ethereum uses a specilized Trie like datastructure called Patricia Merkle Trie(PMT).
  • Think of PMT as special and powerful version of Trie.

Hashing

  • Hashing is ideal for speed and uses low disk space.
  • { key, value } table search using a hash function is faster and uses less disk space.
  • A cryptographic hash function is a particular type of hash function.
  • Ethereum currently implements the “Keccak” Cryptographic hash function.
  • Keccak is a sponge-like function with Absorb and Release features.

Blocks

  • A block is a data structure comprised of {Block Header, Transaction List, Ommers List}.
  • A Block header is comprised of of 15 fields,some being { ParentHash,Root of {state,txns,recipts} }.
  • The root fields e.g: stateRoot is a trie data structure.
  • The root field is a 256 byte Keccak hash.
  • A series of blocks creates a Blockchain.

Blocks-2

  • LogsBloom is a Block Header field.
  • LogsBloom field is a global event indicator for the Block Header.
  • Bloom Filter algorithm is the mechanism for the LogsBloom field.
  • Ethereum specifies a specialized Bloom Filter algorithm.
  • A Genesis Block is the Block 0 state of the Blockchain.
  • Genesis Block has pre-defined values, agreed by the ecosystem.

Transactions

  • A Transaction in Ethereum has sender and reciever.
  • Transaction Trie root points to all the transactions in that Block.
  • Transactions fields v,r,s identify the sender address.
  • A transaction has sender and reciever.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment