0 foreword

For me, the most efficient way to learn about a product is to read the instructions. After reading the Ethereum white paper, I found that many of the concepts were obscure and difficult to read without actual development experience. So I’m going to separate out the important and difficult parts to help you understand the Ethereum whitepaper.

1 Bitcoin solves the Byzantine generals problem

1.1 The Question of the Byzantine generals

The main stumbling block for all of bitcoin’s previous electronic currency protocols is that, despite years of work on how to create secure Byzantine fault-tolerant multi-consensus systems, these protocols address only half the problem. These protocols assume that all actors in the system are known and produce security boundaries in the form of “the system can tolerate N/4 malicious actors if there are N parties participating in the system.” The problem with this assumption, however, is that in the case of anonymity, the system’s security boundaries are vulnerable to witch attacks, because an attacker can create thousands of nodes on a server or botnet to unilaterally ensure a majority.

— Ethereum White paper

One of the concepts mentioned here is the Byzantine problem of fault tolerance. Also known as the Byzantine Generals Problem, it is a fault tolerance Problem for distributed peer-to-peer communication proposed by Leslie Lambert in his thesis of the same name.

A group of Byzantine generals led a separate army to besiege a city. To simplify matters, the operational strategy of each army was limited to attack or withdrawal. Because a partial attack and a partial withdrawal could be disastrous, the generals had to vote to agree on a strategy of all attacking together or all withdrawing together. Since the generals were on different sides of the city, they could only communicate with each other by Courier. During the voting process, each general sends his or her vote for attack or retreat to all the other generals by Courier, so that each general can decide on a strategy based on his or her vote and the information sent by all the other generals.

The problem with the system is that there may be defectors among the generals, who may not only vote for the worse strategies, but may also selectively send voting messages. Let’s say seven generals vote, and one of them is a traitor. Out of six loyal generals, three voted for the attack and three voted for withdrawal. At this point, the traitor may deliberately send letters to the three generals who voted for the attack to vote for the attack, and to the three generals who voted for the withdrawal to vote for the withdrawal. So from the point of view of the three generals who voted to attack, the vote was four to attack; In the opinion of three generals who voted to leave, four voted to leave. Thus the unity of the armies was destroyed.

Byzantine general problem in essence is a matter of trust, the currency before the electronic currency can be tolerated N / 4 malicious participants, namely the system appear less than N / 4 traitors can still run normally, but use the witch attacks (similar to the amount of using multiple IP brush behavior) can create a large number of nodes to malicious tampering with the voting results.

1.2 The emergence of Bitcoin solved the Byzantine general problem

Nakamoto’s innovation was to introduce the idea of combining a very simple node-based decentralized consensus protocol with a proof-of-work mechanism. Nodes gain access to the system through a proof-of-work mechanism, packaging transactions into “blocks” every ten minutes to create a growing blockchain. Nodes with lots of computing power have more influence, but getting more computing power than an entire network is much harder than creating a million nodes. While the Bitcoin blockchain model is rudimentary, it has proved useful enough that it will become the cornerstone of more than 200 currencies and protocols around the world in the next five years.

— Ethereum White paper

Bitby’s solution to the Byzantine generals was to have the generals work out a complicated but easily verifiable mathematical problem before making a decision, which would vary depending on the general’s decision.

The general who calculates first announces the results of his calculations and the instructions to attack or retreat. The other generals verify the result first, execute the command if it is correct, and do not execute the command if it is incorrect.

This is bitcoin’s POW (proof of work) mechanism, which computes a value (nonce) so that the Hash value of the contents of the transaction data meets a specified upper limit (computational math problem). After the node successfully finds the Hash value, the whole network will immediately broadcast the packaged block (publish the calculation result), and the node of the network will immediately verify the broadcast packaged block (other general verification).

If the verification passes, it indicates that there has been a node successfully decrypted, they will no longer compete for the current block package, but choose to accept this block, record in their own ledger, and then the next block competition guessing. Only the fastest part of the network will be added to the ledger, and other nodes will be copied, thus ensuring the uniqueness of the entire ledger.

If there is any cheating nodes, can lead to the development of the network node authentication is not through, directly discarded its packing blocks, the blocks will not be able to record to the total books, cheating node cost is wasted, so under the huge cost of mining, also makes the miners abide by the consensus of the currency system of voluntary agreement, also can ensure the safety of the whole system.

1.3 Account Model and UTXO

The “state” of the bitcoin system is the collection of all the unspent Bitcoins (technically called “unspent Transaction outputs, unspent Transaction, or UTXO”) that have been mined.

— Ethereum White paper

To understand this passage, we need to know what UTXO is. In fact, Account Model and UTXO (Unspent Transaction Outputs) are two ways to store transaction records in the current blockchain world.

1.3.1 Account Model

Ethereum’s Account Model is easy to understand, as if everyone has their own Account. In the Ethereum world, balances are stored directly in the account address, making it very intuitive to query the details of each transaction using a blockchain browser;

Outputs 1.3.2 UTXO (Unspent Transaction)

However, when we look at Bitcoin’s transfer records in the blockchain browser, it’s always confusing.

The data sourcebtc.com

Compared to Ethereum, bitcoin transfer records suddenly have many more inputs and outputs. This is difficult to read because bitcoin uses the UTXO model. In the bitcoin world, account balances are not recorded, and are determined by reviewing all previous transfers to calculate the balance; (This sounds silly)

The UTXO model as a whole ensures that input == output

For example, If Joe transfers to Eury 3BTC and Eric transfers to Eury 2BTC, Eury gets two UTXOs amounting to 5BTC. Eury needs to transfer 4.5BTC to Judy, but in order to satisfy input == output, there is a difference of 0.5bTC between 4.5BTC and Eury’s UTXO 5BTC, so Eury needs to issue two transactions to satisfy the input == output condition:

  • Eury –> Judy 4.5bTC
  • Eury –> Eury 0.5btc

UTXO is so cumbersome to use, so why use it?

This is because UTXO effectively protects against Double Spending attacks. What miners want to verify is whether a particular UTXO was sent during the transaction. Then unspent transaction is certainly not unspent. Verification will fail, and a mole will terminate the deal.

In addition, UTXO can conceal its transaction purpose, which has certain anonymity compared with Account Model.

However, UTXO has a fatal disadvantage: Stateless, which makes it extremely expensive and inefficient to build applications on Bitcoin. The purpose of the Ethereum white paper’s proposed UTXO mode for Bitcoin is to point out the shortcomings of bitcoin’s scripting and highlight that it solves the problem of running scripts on the blockchain.

2 Principle of Ethereum

2.1 Ethereum is like a computer renter

Ethereum aims to integrate and improve on the concepts of scripting, competitive coins, and on-chain meta-protocol, enabling developers to create arbitrary consensus-based, extensible, standardized, feature-rich, easy-to-develop, and collaborative applications.

— Ethereum White paper

What ethereum does is it allows developers to create applications on the Ethereum platform using a simple development language.

It’s like ethereum’s blockchain has several computers waiting to be rented, and we can publish the written code to the computer to run. Publishing is the equivalent of renting a computer on Ethereum, but costs a fee, which depends on how much performance the published code takes to execute. We rent computers on demand, and the money that runs them is what the miners get from digging.

For example, this is the LORDLESS LESS Token ERC20 smart contract I created in May 2018. It is equivalent to renting a computer on Ethereum to run the ERC20 contract code I wrote. Release fee is 0.009080855 ETH, contract code click to view;

So in the Ethereum world, developers can “rent computers” to publish their smart contract code, which is then “deployed on computers” waiting to be called. And the way to invoke smart contract is very simple, as long as you know the address of the published smart contract, and know the method in the contract can be invoked.

Below is using the balanceOf method in the 0 x35d415bf0e6bbf8e10eba814e10325c46a2cf009 LESS scrip balance; Query page click direct

2.2 Ethereum Account

In the Ethereum system, states are made up of objects called “accounts” (each account consists of a 20-byte address) and state transitions that transfer value and information between the two accounts.

— Ethereum White paper

To expand, there are two types of accounts in Ethereum

  • In the past decades, the farms and farms of the World have an EOA (External Owned Account)
  • Account of the contract

EOA is the wallet address that we use, the contract account and the smart contract address that we publish. These two addresses are formally the same, starting with 0x and 20 bytes long.

EOA wallet address
0x35d415bF0E6bbf8e10ebA814e10325c46a2CF009

# Smart contract address
0x7ca121b093e2fbd4bb9a894bd5ff487d16f1f83b
Copy the code

Not only are they formally the same, but different types of accounts can also send transactions to each other.

EOA –> EOA, which is our usual ETH transfer

EOA –> Contract –> EOA, the most typical scenario is the ERC20 transfer. Note here that ERC20 is essentially an EOA account calling the Tranfer or transferFrom method of the smart contract.

Calling contracts is also a common usage.

For example, we complete orders in a decentralized exchange, which is the exchange’s order contract call

2.3 trade

A “transaction” in Ethereum is a signed packet that stores messages sent from an external account. The transaction contains the receiver of the message, the signature used to confirm the sender, the ethereum account balance, the data to be sent, and two numeric values called STARTGAS and GASPRICE. To prevent exponential explosions and infinite loops of code, each transaction needs to limit the number of computation steps that are triggered by executing the code, both the initial message and all messages that are triggered during execution. STARTGAS is the limit, and GASPRICE is the cost of paying miners for each calculation step. If, during the execution of the transaction, the gas “runs out”, all states are changed and restored to their original states, but the transaction fee paid is not recoverable. If gas is left at the time of execution of the trade abort, it is returned to the sender. Creating a contract has a separate transaction type and corresponding message type; The address of the contract is calculated based on the random number of the account and the hash of the transaction data.

— Ethereum White paper

A “transaction” in Ethereum is a signed packet that stores messages sent from an external account. This sentence is important and is key to understanding ethereum trading.

The so-called transactions in Ethereum are not exchanges as we normally understand them, such as barter or money for money, but rather packets of signed messages that are stored from external accounts. Ethereum’s smart contracts are used in many scenarios, such as gambling, auction, airdrop, and so on. Ethereum transactions, on the other hand, record EOA–>EOA, EOA–>Contract–>EOA, etc., on the blockchain.

For example, the following figure shows the pass directionAirdrop ContractsendTransactionTo claim LESS Token:

You can see that every ethereum transaction contains:

  • The Block height into which the Block is packed
  • Timestamp block time
  • From Tx Indicates the sender address
  • To Tx Indicates the destination ADDRESS
  • Value transactions contain the amount of Ethereum
  • Transaction Fee
  • Gas Limit Maximum Gas consumption
  • Gas Used by Transaction Indicates the Gas consumed in this Transaction
  • Gas Price The unit Price of a single Gas
  • Nonce A number that increases with the number of transactions to prevent a double-flower attack
  • The data carried by the input Date transaction is used to call the methods in the smart contract, as in this exampleAirdropThe contractcalimTo pick up the airdropLESS.

The sequence of contract calls to receive LESS is shown as follows: The whole call process is shown in the figure

Account1–>Airdrop Countract –> LESS Contract–>Account1

The whole process is a Transaction, are recorded on a 0 xe3950daee51dd77059f3b1d2fab05fd871ad664e2d6ccbcfbff8e2840295cb48 this Transaction.

Now do you understand that “transactions” in Ethereum are signed packets that store messages sent from external accounts. The meaning of this sentence.

The whitepaper also explains why STARTGAS and GASPRICE exist, because there is a fee to “rent a computer” on Ethereum, in case the user makes a mistake, such as an infinite loop. Therefore, two parameters, STARTGAS and GASPRICE, must be set during Transaction sending.

  • STARTGASRepresents the maximum amount of GAS that can be consumed in this transaction
  • GASPRICEIndicate the unit price of GAS you are willing to pay the miners

If the STARTGAS upper limit is reached and the transaction is still not completed, then all the states on the chain are reset, but the miner’s fee STARTGAS * GASPRICE is still generated according to the GAS consumed, that is, it is a waste of money. However, if the transaction is completed before STARTGAS is reached, the remaining unconsumed fees are refunded, which is actually a protection measure for the user.

2.4 Ethereum state machine

Ethereum’s state transition function: APPLY(S,TX) -> S’, can be defined as follows:

1. Check whether the format of the transaction is correct (that is, it has the correct value), whether the signature is valid and whether the random number matches the random number of the sender’s account. If no, an error is returned.

2. Calculate transaction fee :fee=STARTGAS * GASPRICE and determine sender’s address from signature. Subtract the transaction fee from the sender’s account and increase the sender’s random number. If the account balance is insufficient, an error is returned.

3. Set the initial value GAS = STARTGAS and subtract a certain amount of GAS based on the number of bytes in the transaction.

4. Transfer value from the sender’s account to the recipient’s account. If the receiving account does not already exist, create it. If the receiving account is a contract, run the contract code until the code runs out or the gas runs out.

5. If the value transfer fails because the sender account does not have enough money or the code execution runs out of gas, the original state is restored, but a transaction fee is paid, which is added to the miner account.

6. Otherwise, all remaining gas is returned to the sender and the consumed gas is sent to the miner as a transaction fee. For example, suppose the code for the contract is as follows

— Ethereum White paper

To understand the content of this paragraph, we need to understand the blockchain as a distributed state machine, all nodes in accordance with the same rules, the same operation sequence (add, delete, change) constantly change, to achieve all nodes after the implementation of the same numbered block Transactions, the state is completely consistent.

It is clear that the white paper listed above is the control flow of the ethereum update state machine. After interpretation, the picture is as follows:

Please read this diagram carefully, understanding the control flow of the state machine will help us learn the development of Ethereum later.

Application and future of Ethereum

The application areas mentioned in the white paper in this chapter are too broad, and I want to talk about my own thoughts;

3.1 The best teams have chosen Ethereum

According to the current performance of Ethereum (POW), the application field is limited due to the limitation of concurrency and handling fee. However, I still recommend you to learn Ethereum instead of EOS, TRON and other so-called high-performance public chains.

The reason is that I think the Ethereum team not only has the technical strength but also the innovation gene.

  • Github’s code is always iterated methodically, and the community’s enthusiasm for technology has nothing to do with price.
  • The infrastructure for Metamask, Infura, Truffle, Web3.js, etc., is so well built that developers don’t have to reinvent the wheel.
  • With the emergence of secondary markets such as DDEX and Opensea, both the development of ERC20 Token and ERC721 non-Fungible Token can have a platform to cater to more users
  • Most of the technical holes in the Ethereum community have been filled in after 5 years of sedimentation, and a Google search during development can locate the problems
  • EIPs (Ethereum Improvement Proposal) has proved the innovation ability of Ethereum. The latest concepts such as ERC20, ERC721 and ERC1155 born on EIPs have produced many high-quality DApps. Other public chains have had to copy ethereum’s EIPs concept and come up with TRC20 clones.

It is because of the ethereum community above that the best teams have chosen Ethereum and all the great dapps have been developed on Ethereum. Cryptokitties, Fomo3d, etc.

Of course, from the perspective of business model, Cryptokitties and Fomo3d are both games of beating the drum and spreading the flowers. It is not worth encouraging to magnify human greed by taking advantage of the transparent, open and untampered characteristics of blockchain.

But from a technical point of view, they are all high quality products of code, especially the Fomo3D team’s code is very Cool to learn, click to see Fomo3D code.

/ * * * ┴ ┴ └ ─ └ ─ ┘ ─ ┴ ┘ └ ─ ┘ └ ─ ┘ ┴ (_ /. -, - ` ` - * = = = = = = = =, -,. = = = = = = = = = = = = = = = = = = = = = = _____ = = = = = = = = = = = = = = = = = = = = = = = = = = / / '. = = = = = = =, -, = = = =, * * ', '|,' `. /.. /; . '. '` \ *, -.' |, -, - + -,. '_ |, -. \ ` ` \. ` -', - '\ * | |.' ', '\, - + -.; , | | ', '\, -- -- -- -. \ ___ \ / \ : | |. ` \ | * : : : / / | -.' | | | | | /, '. '| \ : | : |' | * : | | -,.; . : | | ', | |,.; ,. :, - '| / / / |' '; : * | :; / / | '| | : : | | | | --' '| | : : | |.' \ \ \ '|; . * | | |. '|.; : | : | |, '|'.; ___ / : : : |. '| | | : |' * ': | : | |. | | / | | ` -' / / / / : : | /; * | | | \ \ / | | | ` - '\ \, / /, /', -. | | '`, / * | : \ ` -' |; / '----' \ '\; ; : .' *====| | ,'=============='---'==========(long version)===========\ \ .'===| ,.'======* * `----' `--`-,,-' '---' * ╔ ═ ╗ ┌ ─ ┐ ┌ ─ ┐ ┬ ┌ ─ ┐ ┬ ┌ ─ ┐ ┬ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ╦ ╦ ┌ ─ ┐ ┌ ┐ ╔ ═ ╗ ┬ ┌ ┬ ┐ ┌ ─ ┐ * ║ ║ ├ ┤ ├ ┤ │ │ │ ├ ─ ┤ │ │ │ https://exitscam.me ║ ║ ║ ├ ┤ ├ ┴ ┐ ╚ ═ ╗ │ │ ├ ┤ * ╚ ═ ╝ └ └ ┴ └ ─ ┘ ┴ ┴ ┴ ┴ ─ ┘ └ ─ ┬ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┬ ─ ┘ ╚ ╩ ╝ └ ─ ┘ └ ─ ┘ ╚ ═ ╝ ┴ ┴ └ ─ ┘ * ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ * │ ╔ ═ ╗ ┌ ─ ┐ ┬ ┬ ┌ ┬ ┐ ┬ ┌ ┬ ┐ ┬ ┬ ╔ ╦ ╗ ┌ ─ ┐ ┌ ─ ┐ ┬ ┌ ─ ┐ ┌ ┐ ┌ ╦ ┌ ┐ ┌ ┌ ┬ ┐ ┌ ─ ┐ ┬ ─ ┐ ┌ ─ ┐ ┌ ─ ┐ ┌ ─ ┐ ┌ ─ ┐ ╔ ═ ╗ ┌ ┬ ┐ ┌ ─ ┐ ┌ ─ ┐ ┬ ┌ ─ │ * │ ╚ ═ ╗ │ │ │ │ │ │ │ │ └ ┬ ┘ ═ ║ ║ ├ ┤ └ ─ ┐ │ │ ┬ │ │ │ ═ ║ │ │ │ │ ├ ┤ ├ ┬ ┘ ├ ┤ ├ ─ ┤ │ ├ ┤ ═ ╚ ═ ╗ │ ├ ─ ┤ │ ├ ┴ ┐ │ x │ ╚ ═ ╝ └ ─ ┘ ┴ ─ ┘ ┴ ─ ┴ ┘ ┴ ┴ ┴ ═ ╩ ╝ └ ─ ┘ └ ─ ┘ ┴ └ ─ ┘ ┘ └ ┘ ╩ ┘ └ ┘ ┴ └ ─ ┘ ┴ └ ─ └ ┴ ┴ └ ─ ┘ └ ─ ┘ ╚ ═ ╝ ┴ ┴ ┴ └ ─ ┘ ┴ ┴ │ x │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ * └ ─ ─ ─ ─ ┤ Inventor ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤ Justo ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤ Sumpunk ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤ Mantso ├ ─ ─ ┘ * └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ └ ─ ─ ─ ─ ─ ─ ─ ┘ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ └ ─ ─ ─ ─ ─ ─ ─ ─ ┘ * /Copy the code

3.2 Ethereum is the local of the local

Li Xiaolai wrote in his book “Casting changes Destiny” :

The right way is always “local local”

– smile to lee

I agree with him, but there is a difference

  • Li Xiaolai thinks that the local part isEOS;
  • I think the local part isEthereum;

We all agree that blockchain is the future, the fastest growing industry, the first part; Our point of disagreement is in the second part, EOS or Ethereum?

The reason why we disagree is really because we have different aims

  • Part of what Li xiaolai said is EOS, which aims at higher investment returns.
  • And I think part of it is Ethereum, which is all about technology learning and getting the technology right.

EOS is a team that focuses on business model. I am not as good as Li Xiaolai for investment. I trust his judgment. But when it comes to the technology itself, I believe that people who have done blockchain development, potholes late at night, and smart contracts have unique technical insights. I think part of the future blockchain must be Ethereum;

The success of Ethereum 1.0 has given us great expectations for Ethereum 2.0:

Let’s look at the specs for Ethereum 2.0: eth2.0-Specs

Ethereum 2.0 will introduce many new technologies, such as sharding technology, zero-knowledge proof technology, anti-quantum attack technology and so on. The feasibility of these problems has been proved, the remaining problem is just the implementation of engineering.

The launch of Ethereum 2.0 will directly affect the development trend of blockchain in the next 5-10 years. I hope we will not miss this technological revolution.

  • This article from: 1 day, read the etheric lane white paper | 5 days to master the etheric fang dApp development
  • Author’s blog: Eurychen records the growth