


























Bitcoin is a replicated state machine, the system moves within S States with I inputs producing O outputs. For Bitcoin, S is the set of UTXOs. For Namecoin, the state consists (name, value).
Ethereum’s goal was to implement this functionality in a general way by building a “consensus computer” expressed in a Turing-complete language.
State: Great arbitrary storage space, arbitrary code (isolated memory space), and account balance. Inputs: (address, input data) Transition: update storage and change account balance
Issues: process isolation ensured via signatures and resource consumption limits ensured by requiring a payment for everything.
An Ethereum block consists of merkle-like trees hashes - a tree hash of state (code, account balance, nonce, and storage) - a tree hash for updates which is a collection of transactions. Each transactions has a sender, money, Pid, and code. - a tree hash of receipts. Each transaction has a corresponding receipt. A receipt contains the final state, gas used, and log data. - Just like Bitcoin, all storage is public.
Ethereum has (externally owned) accounts controlled by a private key and contracts (Dapp).
Address of account = SHA3(public key)[:20] Address of dapp = SHA3(creator's address, nonce)
Both have account balance and a nonce. EOA has public key, Dapp don’t. Dapp has code, EOA don’t.
(to, from, value, data, start gas, gas price)
Three important message types:
Note: Nonce goes up every sent transaction to prevent replay attack.
Code is written in Ethereum Virtual Machine (EVM) bytecode - RAM is 32-bytes (256-bit), and persistent storage is 32-bytes addressable (2256 bytes). All memory is initialized to 0. Ethereum call stack size is limited to 1024. Storage can be word-addresssable, each key is 256-bits in size. Features: crypto (SHA3), interaction with blockchain, send messages, logging/output. Missing features: No RNG or else txns are not reproducible. No floating points.
No one writes EVM code directly. Solidity (Javascript-like) is more popular now. Serpent (Python-like) is less popular. Mutan (C/Go-like) is under development, Visual Basic is under development as well.
Every message specifies STARTGAS and GASPRICE.
Current gas price is about 30 billion wei (3* 10e-8 ether).
You pay start gas * gas price, deducted at the start.
If you are out of gas, execution halts, state reverts but miner keeps the gas as the fee.
| |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。