Ethereum

I. Overview

1. An upgraded version of the Bitcoin blockchain, for the application of blockchain 2.0. Ethereum has a built-in currency called ether, which is necessary to pay for contract execution. The things recorded in the Ethereum blockchain are called contracts. The so-called contract is a low-level binary code and a Turing-complete language. Essentially, a contract is a program that runs on each node in the Ethereum system. These programs can store data, pay and receive, store ether, and perform an infinite range of (hence Turing-complete) computational behaviors, acting as decentralized autonomous software agents in the system.

2. The python-based implementation mainly includes three parts: Pyethapp is the client part; pyethereum is the core library, which implements functions such as blockchain, Ethereum simulator and mining; pydevp2p is a peer-to-peer network library, which implements node The functions of discovery, contract code transmission, and encrypted signature are combined to form a complete blockchain implementation. The latter two core libraries together form the protocol layer. In addition, go-ethereum is a complete implementation of the go language; Ethereum(J) is a pure Java implementation

3. The generation time of a block is about 17 seconds (Bitcoin is 10 minutes)

4. Development stage currency - "smart contract (value transfer) - "all coordination and confirmation (autonomous society)

5. Smart contracts: A traditional contract refers to an agreement between two or more parties to do or not do something in exchange for something, and each party must trust each other to perform their obligations. And smart contracts do not need to trust each other, because smart contracts are not only defined by code, but also enforced by code, completely automatic and uninterrupted.

6. Features: Avoid being tampered with and replaced; confidentiality; enforcement; blockchain can be used wherever these things are needed.

 

2. Technology

1. Ethereum is a platform and programming language, including the digital currency Ether (Ether) and EtherScript (EtherScript), used to build and publish distributed applications. Ethereum is a basic, open general digital currency platform to implement a Turing-complete virtual machine, which can use any currency, protocol and blockchain.

2. Ethereum has the characteristics of openness and generality. Every node of the network can run the Ethereum virtual machine to publish distributed smart contract programs. Ethereum smart contracts, capable of calling multiple other blockchains, protocols, currencies. As a general distributed application development platform independent of the underlying blockchain and protocols, it has the conditions to become a platform-level product.

3. Ethereum has its own distributed system: including file service Swarm, information transmission Whisper and reputation guarantee. Swarm is a decentralized file service; Whisper is an encrypted communication transmission system; Credit Guarantee provides a system for establishing reputation and reducing discovery in a trustless network, provided by Crypto Schwartz and TrustDavis, among others.

 

3. Consensus Mechanism

1. POW (Proof of Work): Proof of workload, whoever does more work, whoever invests more, and who is lucky, has the right to keep accounts and obtain mining income. Disadvantages: After a long time, there are too few miners to trade; there may be a 51% attack; deflation; waste of electricity; slow convergence. 

2. PoS (Proof of stake) is based on the distribution of the amount of digital currency currently owned by miners, a system that distributes interest based on the amount and time of currency you hold. Your coin age is proportional to the computing power of your computer. According to Buterin, this consensus algorithm will seek to virtually replicate the Bitcoin mining process without wasting electricity.

3. Casper mechanism: pos with punishment mechanism

4. History

1. White paper, protocol, rationale, structure of smart contract. Late 2013 Vitalik Buterin

2. The Yellow Book, the technical implementation specification. April 2014

3. Beta, Frontier. July 30, 2015 

4, the official version, Homestead. February 29, 2016.

Purple Book's New Consensus Mechanism

5. Metropolis

6. Serenity (casper-based consensus mechanism)

 

5. Distributed

1. The Byzantine Generals Problem: The Byzantine Empire wanted to attack a powerful enemy and sent 10 armies to surround the enemy. This enemy, although no bigger than the Byzantine Empire, was enough to defend against simultaneous attacks by 5 regular Byzantine armies. For some reasons, these 10 armies cannot be united to make a single point breakthrough and must attack simultaneously in separate encirclement states. Any one of their armies alone has no chance of winning, unless at least 6 armies attack at the same time to take down the enemy country. They are scattered around the enemy country, relying on the signal soldiers to communicate with each other to negotiate the intention and timing of the attack. The problem that plagued these generals was that they weren't sure if there were traitors among them, and traitors could change the intention or timing of the attack without authorization. In this state, could the Byzantine generals find a distributed protocol that would allow them to negotiate remotely to win the battle? (Assuming the channel is reachable, the core is consistency and correctness. Allowing loyal generals to reach agreements of action without provocation by spies.)

2, CAP theory.

Consistency: Whether the same data has the same value at the same time on all nodes in the cluster.

Availability: After some nodes in the cluster fail, whether the cluster as a whole can still process update requests from clients.

Partition tolerance: Whether to allow data partitioning, partitioning means whether to allow the nodes in the cluster to fail to communicate. The internal network is down: whether to allow access.

P must be satisfied (the network jitter is certain), generally choose A, and satisfy C to a certain extent.

 

6. Client use (go client)

1. The default directory C:\Users\weitm\AppData\Roaming\Ethereum\geth

/root/.ethereum/geth

geth account new

geth account list

geth wallet import Path where the pre-sale wallet file is located

 

{

  "config": {

        "chainId": 0,

        "homesteadBlock": 0,

        "eip155Block": 0,

        "eip158Block": 0

    },

  "alloc": {

    "0x0000000000000000000000000000000000000001": {"balance": "111111111"},

    "0x0000000000000000000000000000000000000002": {"balance": "222222222"},

    "0x0000000000000000000000000000000000000003": {"balance": "333333333"}

    },

  "coinbase"   : "0x0000000000000000000000000000000000000000",

  "difficulty" : "0x20000",

  "extraData" : ""

  "gasLimit"   : "0x2fefd8",

  "nonce"      : "0x0000000000000142",

  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",

  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",

  "timestamp"  : "0x00"

}

 

2、 ./geth init genesis.json

3、./geth --rpc --rpcaddr="0.0.0.0" --rpccorsdomain="*" --unlock '0' --password ./password.txt   --nodiscover --maxpeers '5' --networkid '1234574'  console

4. The api of the console's internal js

 

web3.fromWei(eth.getBalance(eth.coinbase), "ether")

personal.listAccounts

personal.unlockAccount('0xb35ef67b5f4316d4fa852f9c00aba78bd49d73fb', 'xxx', 3000)

 

eth.sendTransaction({from: '0xb35ef67b5f4316d4fa852f9c00aba78bd49d73fb', to: '0xb35ef67b5f4316d4fa852f9c00aba78bd49d73fb', value: web3.toWei(1, "ether")})

5. web3 is the root, and the core modules include:

admin debug eth miner net personal rpc txpool

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326432822&siteId=291194637