Explanation of blockchain related terms

cnstartech 2022-04-03 20:11:15 阅读数:889

explanation blockchain related terms

The parameters of Chuangshi block are as follows:

{
"config": {
"chainId": 10,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc" : {}
}

 

{
"alloc": {
"0000000000000000000000000000000000000001": { "balance": "1" }
},
"nonce": "0x0000000000000042",
"difficulty": "0x000002",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x4c4b40"
}


Parameter name Parameters to describe
mixhash And nonce It is used for mining , Generated by a part of the previous block hash. Pay attention to him and me nonce The setting of needs to meet Ethereum's Yellow paper, 4.3.4. Block Header Validity, (44) The conditions described in the chapter .
nonce nonce It's just one. 64 Bit random number , For mining , Pay attention to him and me mixhash The setting of needs to meet Ethereum's Yellow paper, 4.3.4. Block Header Validity, (44) The conditions described in the chapter .
difficulty The current difficulty of setting blocks , If it's too difficult ,cpu Mining is hard , It's a little bit more difficult here
alloc Used to preset the account number and the number of ethers in the account , Because private chain mining is easier , So we don't need to preset an account with currency , You can create it yourself when you need it .
coinbase Miner's account number , Random filling
timestamp Set the timestamp of the creation block
parentHash Of the last block hash value , Because it's genesis , So this value is 0
extraData Additional information , Random filling , You can fill in your personal information
gasLimit This value is set for GAS The total consumption limit of , Used to limit the total amount of transaction information a block can contain , Because we're private chains , So fill in the maximum .
Difficulty value :

Hexadecimal ( Difficulty value ) Decimal system Block generation speed
0x99999 629145 1 second 1 individual
5ffffa 6291450 1 minute 5 individual
2ffffd 3145725 1 minute 5 A to 10 individual
bffff4 12582900 6 minute 8 individual
3bfffc4 62914500 hundredfold Two in six minutes
12bffed4 314572500 Five hundred times  
77fff88 125829000 Two hundred times Two in ten minutes
The speed of mining can be adjusted automatically by algorithm , Keep the speed equal to the difficulty value we set , However, the difficulty values of the following blocks are related to the difficulty values set in the initial block , So only the difficulty value of the initial block determines the speed of the whole chain . 
This is the yellow book about the difficulty value setting algorithm  

 Picture description here

geth Parameters

 

--lightserv     value
Set the maximum proportion of request time in light node mode , Because the light node will not synchronize the internal information of the block , When querying block information ( Transaction information , Specific block height information, etc ) It will request data from other nodes in the whole node , Set the maximum request time ratio . The scope is :0-90, The default is 0

--lightpeers     value
Set light node mode , Maximum number of nodes allowed to connect , The default is 20

--lightkdf     Lower the light joint CPU and RAM Occupancy rate

Performance tuning options :
–cache value        Adjust memory allocation Minimum 16MB, Default 128MB
–trie-cache-gens value Number of storage nodes in memory , The default is 120

Account related options :
--unlock     value Specify the account address to be unlocked , If no password file is specified, it is in interactive mode

--password /your/password/file/path      Unlock the corresponding account through the password file , Non interactive mode

API Command line related options :
By default ,geth The node will not start http and weboscket service , And for safety reasons , Not all functions are provided through these interfaces

--rpc     Turn on HTTP-RPC service

--rpcaddr value     Appoint HTTP-RPC Service monitoring address , The default is “localhost”

--rpcport value      Appoint HTTP-RPC Service listening port , The default is 8545

--rpcapi value      Appoint HTTP-RPC Turn on API, The default is “eth,net,web3”

--ws      Turn on WS-RPC service

--wsaddr value      Appoint WS-RPC Service monitoring address , The default is “localhost”

--wsport value      Appoint WS-RPC Service listening port , The default value is :8546

--wsapi value     Appoint WS-RPC Turn on API, The default is “eth,net,web3”

--wsorigins value     Specify that “websockets” Requested address

--ipcdisable      close IPC-RPC service

--ipcapi value      Appoint WS-RPC Turn on API, The default is ”admin,debug,eth,miner,net,personal,shh,txpool,web3″

--ipcpath "geth.ipc"     Appoint IPC Interface

--rpccorsdomain value      Specify that you can access APi Of domain Address , Set to “*” Then any address can access , It's not safe to do this .

--jspath /loadScript/path     Appoint loadScript route , The default is ”.”

--exec value     JavaScript Interpreter , explain Js sentence , Only with console/attach Use at the same time
e.g:
geth --jspath "/tmp" --exec 'loadScript("checkbalances.js")' attach

--preload value      Customize JavaScript Load the file into the console , This can be used to load commonly used functions , Such as setting web3 etc. .
e.g:
geth --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js"console

Network related options :
--bootnodes value       Add connection nodes manually , It doesn't work on the private chain .

e.g:
geth --bootnodes enode://[email protected]:port1,enode://[email protected]:port2,enode://[email protected]:port3

--port value        Specify the Ethernet listening port , The default is : 30303.

--maxpeers value        Set the maximum number of nodes allowed to connect , The default is 25

--maxpendpeers value       Set the maximum number of pending connection nodes , The default is 0

--nat value
Provides access to the universal network port mapping protocol
(any|none|upnp|pmp|extip:), Default : “any”

--nodiscover        Turn off auto connect node , But you can add nodes manually , When building a private chain , To prevent other nodes from connecting to the private chain , You can use this command .

--v5disc       Start experimental RLPx V5 Mechanism ( Haven't studied )

--nodekey value        introduce P2P Node key file

--nodekeyhex value        Hexadecimal P2P Node key , For testing




Consensus mechanism :

First , No consensus mechanism is perfect , Each consensus mechanism has its advantages and disadvantages , Some consensus mechanisms are designed to solve specific problems .
1.pow( Proof of Work) Proof of workload   The highest cost attack    tps: 5/s
One sentence introduction : The more you do , The more you collect .
Rely on the machine to do mathematical operations to obtain the right to keep accounts , Resource consumption is higher than other consensus mechanisms 、 Weak regulatory , At the same time, every time we reach a consensus, we need the whole network to participate in the calculation , Low performance and efficiency , In terms of fault tolerance, the whole network is allowed 50% Node error .
advantage :
1) Method is simple , Easy to implement ;
2) There is no need to exchange additional information between nodes to reach a consensus ;
3) It costs a lot to destroy the system ;
shortcoming :
1) Waste energy ;
2) It is difficult to shorten the confirmation time of blocks ;
3) The new blockchain must find a different hash algorithm , Otherwise, it will face the computing power attack of bitcoin ;
4) It's easy to split , Need to wait for more than one confirmation ;
5) There will never be finality , A checkpoint mechanism is needed to compensate for finality ;
2.POS Proof of Stake, Proof of interest Bookkeeping   Low attack cost And may become more centralized   tps: 25/s
One sentence introduction : The more you hold , The more you get .
The main idea is that the difficulty of obtaining the accounting right of the node is inversely proportional to the equity held by the node , be relative to PoW, Reduce the resource consumption caused by mathematical operation to a certain extent , The performance has also been improved , But it is still the way to obtain accounting right based on hash operation competition , Weak regulatory . The consensus mechanism has fault tolerance and PoW identical . It is Pow An upgraded consensus mechanism , According to the proportion and time of each node , Reduce the difficulty of mining in equal proportion , To speed up the search for random numbers
advantage : To a certain extent, it shortens the time for consensus ; No more energy intensive mining .
shortcoming : Or mining , In essence, there is no solution to the pain point of commercial application ; All confirmation is just a probability expression , It's not a matter of certainty , In theory, there may be other attack effects . for example , Ethereal DAO The attack caused Ethereum hard bifurcation , and ETC This event occurred , In fact, it proves the failure of this hard bifurcation .
DPOS And POS The same principle , Just selected some “ Deputies to the National People's Congress ”. ( The election )   tps: Ten thousand times /s   Suitable for enterprise class
BitShares The community first proposed DPoS Mechanism .
And PoS The main difference is that nodes elect several agents , Verification and bookkeeping by agent . Its compliance regulation 、 performance 、 Resource consumption and fault tolerance PoS be similar . It's like a board vote , The coin holder throws a certain number of nodes , Acting on their behalf for verification and bookkeeping .
DPoS The working principle of is :

Decentralization means that each shareholder has influence according to its shareholding ratio ,51% The result of shareholder voting will be irreversible and binding . The challenge is to achieve... In a timely and efficient way 51% approval . To achieve this goal , Each shareholder may delegate one vote . The top with the most votes 100 Delegates take turns to produce blocks according to the established schedule . Each delegate is assigned a time period to produce blocks . All representatives will receive a fee equal to the transaction fee contained in an average block 10% As a reward . If an average block contains 100 Shares as transaction fee , A representative will receive 1 Shares in return .
Network delays may prevent some delegates from broadcasting their blocks in time , And this will lead to the bifurcation of the blockchain . However , This is unlikely to happen , Because the representative of the manufacturing block can establish a direct connection with the representative of the block before and after manufacturing . Establish this relationship with your future representatives ( Maybe the next representative ) To make sure you get paid directly .
This mode can be used every 30 A new block is generated in seconds , And under normal network conditions, the possibility of blockchain bifurcation is extremely small , Even if it happens, it can be solved in a few minutes .
To be the representative :
Become a representative , You must register your public key on the network , And then assign it to a 32 Unique identifier of bit . The identifier is then used by each transaction data “ Head ” quote .
Authorized votes :
Each wallet has a parameter setting window , In this window, the user can select one or more representatives , And grade it . Once set , Every transaction made by the user will change the votes from “ Input represents ” Transfer to “ The output represents ”. In general , Users do not create transactions specifically for voting purposes , Because it will cost them a transaction fee . But in an emergency , Some users may find it worthwhile to change their vote by paying a fee in a more positive way .
Be honest :
Each wallet will display a status indicator , Let users know how their representatives behave . If they miss too many blocks , Then the system will recommend the user to change a new representative . If any representative is found to have issued an invalid block , Then all standard wallets will ask for a new representative before each wallet makes more transactions .
Resist the attack :
In resisting attack , Because of the former 100 The power gained by representatives is the same , Each delegate has an equal vote . therefore , Cannot get more than 1% And concentrate power on a single representative . Because only 100 Name stands for , Imagine an attacker performing a denial of service attack on each delegate whose turn it is to produce a block . Fortunately, , Because in fact, the identity of each representative is its public key, not IP Address , The threat of this particular attack can easily be mitigated . This will make sure DDOS It's more difficult to attack the target . And the potential direct connection between representatives , Will make it more difficult to prevent them from producing blocks .

advantage : Greatly reduce the number of nodes participating in verification and accounting , It can achieve consensus verification in seconds .
shortcoming : The whole consensus mechanism still depends on token , A lot of commercial applications don't need tokens .
3.PBFT :Practical Byzantine Fault Tolerance, Practical Byzantine fault tolerance
Introduce : To ensure activity and safety (liveness & safety) The premise of providing (n-1)/3 Fault tolerance .
On Distributed Computing , Different computers exchange information through , Try to reach a consensus ; But sometimes , The system coordinates the computer (Coordinator / Commander) Or member computers (Member /Lieutanent) May be due to system error and exchange wrong messages , Lead to impact on the final system consistency .
The Byzantine general's problem depends on the number of wrong computers , Look for possible solutions , There is no absolute answer , But it can only be used to verify the effectiveness of a mechanism .
The possible solution to the Byzantine problem is :
stay N ≥ 3F + 1 Consistency is possible to solve . among ,N Is the total number of computers ,F Total number of computers with problems . After information is exchanged between computers , Each computer lists all the information it gets , Take most of the results as the solution .
1) The system can operate without the existence of money ,pbft Algorithm consensus that each node is composed of business participants or regulators , Security and stability are guaranteed by business stakeholders .

2) The delay of consensus is about 2~5 Second , It basically meets the requirements of commercial real-time processing .

3) Consensus is efficient , It can meet the demand of high frequency trading volume .
shortcoming :
1) When there is 1/3 Or after the bookkeeper stops working , The system will not be able to provide services ;
2) When there is 1/3 Or a combination of the above bookkeepers , And the other two islands are divided into two separate networks , Malicious bookkeepers can cause the system to bifurcate , But it will leave behind cryptographic evidence ;

Let's talk about two domestic ~
4.dBFT: delegated BFT Authorized Byzantine fault tolerance algorithm

Introduce : Used by small ants dBFT Mechanism , The bookkeeper is selected by equity , Then the bookkeepers reach a consensus through Byzantine fault-tolerant algorithm .

This algorithm is in PBFT On this basis, the following improvements have been made :
take C/S Request response pattern of architecture , Improved to fit P2P Peer to peer mode of network ;
The static consensus participating node is improved to be dynamically accessible 、 Exit the dynamic consensus participating node ;
A voting mechanism based on the proportion of equity held is designed for the generation of consensus participation nodes , Decide the consensus participation node by voting ( Bookkeeping node );
Introducing digital certificates into blockchain , It solves the problem of authentication of the real identity of accounting nodes in voting .
advantage :
1) Professional bookkeeper ;
2) Can tolerate any type of error ;
3) Bookkeeping is done by multiple people , Each block has finality , It won't fork ;
4) The reliability of the algorithm has strict mathematical proof ;
shortcoming :
1) When there is 1/3 Or after the bookkeeper stops working , The system will not be able to provide services ;
2) When there is 1/3 Or a combination of the above bookkeepers , And the other two islands are divided into two separate networks , Malicious bookkeepers can cause the system to bifurcate , But it will leave behind cryptographic evidence ;
To sum up ,dBFT The core of the mechanism , Is to ensure the finality of the system to the greatest extent , Make blockchain applicable to real financial application scenarios .

5.POOL Validation pool
Based on traditional distributed consistency technology , Plus data validation mechanism .
advantage : It works without a token , In the mature distributed consistency algorithm (Pasox、Raft) On the basis of , Second level consensus verification .
shortcoming : The degree of decentralization is not as good as bictoin; More suitable for multi center business model with multi participation .

The operation of blockchain must rely on mining (POW) Mechanism ?

  

author : Jiangchuan
link :https://www.zhihu.com/question/266459002/answer/309925648
source : You know
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .

1. " Blockchain " Not necessarily dependent on Mining , But I think " Public chain " Mining must be done , Best choice POW dig ,POW The workload of mining constructs the token computing power barrier and background value , This is also BTC One of the main values of .

2. Consensus algorithm except POW, Common ones are POS、DPOS、PBFT,google There are very detailed instructions below , We will not discuss the underlying technology here . We understand the consensus mechanism of blockchain from a more abstract level .

as everyone knows , The biggest value of blockchain lies in “ De centralization ”, All data over a period of time ( transaction ) Packed into blocks , Synchronize to all nodes , A small number of nodes ( To adopt POW Of BTC, No more than 50% Calculate the force ) Can't construct dishonest data , Trusted data that affects the entire network . There are two problems to be solved :

A. How to ensure enough nodes ( The miners ) Continuous online , Validate transactions ?

B. These nodes ( The miners ) in , Who is responsible for packing , For other nodes to synchronize ?

dig , The most direct is to solve B problem : Delegation of bookkeeping rights .

So-called “ dig ”, about POW, Will consume CPU、 The graphics card 、 Memory and power , Solve specific mathematical problems ; about POS and DPOS You need to keep the node online , And hold a certain amount of tokens , Determine the bookkeeping right according to certain rules .“ dig ” Need to consume certain resources .

So-called “ mine ”, Usually refers to , To encourage miners to work , Rewards and fees for miners who get the right to keep accounts .

obviously , Dug up “ mine ” It will attract more nodes to join the network , More nodes , It means a more robust and secure network , This solves the problem at the same time A problem .

Reward mechanism for miners , Is Nakamoto's greatest innovation , Cryptography in blockchain 、P2P Technology, etc. , In fact, it has developed for many years , Towards maturity . It is this economic incentive , Make the blockchain vibrant .

3. Consensus algorithm , In essence, it is power governance , It's an economic problem , Or political issues , There is no optimum , Only suitable or not .

Introduce the mainstream consensus algorithm in one sentence :

POW: Free competition governance , Who's good at calculation and who's good at listening to , However, freedom ends only with oligarchs or giants , Now power is concentrated in the ore pool .

POS: Who has the money ( Tokens, ) Listen to who .

DPOS: Parliamentary system , Voting represents the power of governance .

PBFT: Node autonomy , Adopt the most credible results on your own .


4. PBFT Consensus does not require token incentives , More suitable for use in the alliance chain , If it is directly applied to the public chain, I'm afraid there are no miners .





版权声明:本文为[cnstartech]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2022/04/202204030744567612.html