Ethereum
Notes on this
In ethereum there are two type of accounts.
Externally owned accounts, which are owned by private keys and have no code associated with them.
Contract accounts which are controlled by their contract code and have code associated with them.
A message between two externally owned accounts is simply a value transfer.
A message from an externally owned account and a a contract account activates the contract account’s code allowing it to perform various actions.
e.g. transfer tokens, write to internal storage, mint new tokens, perform some calculation, create new contracts.
Unlike externally owned accounts contract accounts can’t initiate new transactions on their own. instead they can only fire transcations in response to other transcations they have received.
An account state consits of four components, which are present regardless of the type of account.
- nonce: If the transaction is an externally owned account, this represents the number of transactions sent from the account’s address. If the account is a contract account, the nonce is the number of contracts created by the account.
- balance: balance: the number of wei owned by this account.
- storage root: A hash of the root node of the merkle patricia tree. This tree encodes the hash of the storage contents of the account and is empty by default.
- codeHash: The hash of the EVM code of this account. For externally owned accounts the codeHash field is the hash of the empty string.
Ethereum’s global state consits of a mapping between account addresses and account states. The data is stored in a data structure known as a Merkle Patricia tree.
Block Header
The block header is the portion of the block consisting of:
- parentHash: A hash of the parent block’s header
- ommersHash: A hash of the current block’s list of ommers
- beneficiary: The account address that receives the fees for mining the block.
- stateRoot: The hash of the root node of the Merkle tree.
- transactionsRoot: The hash of the root node of the trie that contains all transactions listed in this block.
- receiptsRoot: The hash of the root node of the trie that contains the receipts of all transactions listed in this block.
- logsBloom: A bloom filter that consists of a log of information.
- Difficulty: The difficulty level of this block.
- number: The count of the current block. Starting at 0 with the genesis block.
- gasLimit: The current gas limit per block.
- gasUsed: The sum of the total gas used by transactions in the block.
- timestamp: The unix timestamp of this block’s inception.
- extraData: Extra data related to this block.
- mixHash: A hash that when combined with the nonce, proves that this block has carried out enough computation.
- nonce: A hash that when combined with the mixHash, proves that this block has carried out enough computation.
A contract can explicitly generate a log by defining events that it wants to log.
A log entry contains:
- the logger’s account address.
- A series of topics that represent various events carried out by this transaction.
- Any data associated with these events.
A transactionr receipt contains certain information about a transaction:
- the block number
- block hash
- transaction hash
- gas used by current transaction
- cumulative gas used in the current block after the current transaction has executed.
- logs created when executing the current transaction.
Block Difficulty
The difficulty of a block is used to enforce consistency in the time it takes to validate blocks.
The expected time to find a solution is proportional to the diffuculty.
Recall the inputs includes the outputs of the transcations were spending bitcoins from. Recall the inputs includes the outputs of the transcations were spending bitcoins from.Recall the inputs includes the outputs of the transcations were spending bitcoins from. Recall the inputs includes the outputs of the transcations were spending bitcoins from.
L(σ)