Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the concepts of blockchain fallibility?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "what are the concepts of blockchain fallibility", so the editor summarizes the following contents, with detailed contents and clear steps, which can be used for reference. I hope you can gain something after reading this article. Let's take a look at this "what are the concepts of blockchain fallibility"?

What is an account?

External ownership account vs contract account

There are two kinds of accounts in Tai Tai Fong:

External ownership account (EOA)

Contract account

This distinction will be abstracted in the upcoming Mets upgrade.

External ownership account

An externally owned account has the following characteristics:

There is an etheric balance.

You can send a transaction (Ethernet currency transfer or activate contract code)

Controlled by private key

There is no associated code

Contract account

A contract account has the following features:

There is an etheric balance.

There is associated code

Code execution is activated through a call sent by a transaction or other contract

When executed-- running at random complexity (Turing completeness)-- can only operate on specific storage it owns, such as having its permanent state-- can call other contracts.

All actions on the ethernet block chain are activated by transactions sent by each account. Every time a contract account receives a transaction, the parameters included in the transaction will run as the input value of the code. The contract code will be run by the ethernet virtual machine (EVM) on each node participating in the network as a verification of their new block.

What are deals and messages?

Trade

The term "transaction" is used in Ethernet Square to refer to the process by which a signed packet used to store messages is sent from one external owning account to another on the block chain.

Transactions include:

The recipient of this message

A signature that proves that the sender intends to send a message to the receiver through the block chain

Value domain-number of wei (ether/ 10 ^ 18) transferred from sender to recipient

An optional data field to store messages sent to the contract

A GASLIMIT value that represents the most permissible calculation steps for the execution of this transaction

A GASPRICE value that represents the gas fee that the transaction sender is willing to pay. A unit of gas represents the execution of a basic instruction, such as a calculation step

Message

Contracts have the ability to send "messages" to other contracts. A message is a virtual object that is never serial and exists only in the Ethernet Square execution environment. They can be understood as function calls calls.

One message includes:

Clear message sender

The recipient of the message

An optional data field, which is the actual input data for the contract

A GASLIMIT value that limits the maximum number of gas available for code execution from this message

In general, a message is like a transaction, except that it is not generated by an external account, but by a contract account. A message is generated when the CALL or DELEGATECALL commands are run in the code that the contract is executing. Messages are sometimes called "insider trading". Similar to a transaction, a message directs the receiving account to run its code. As a result, contract accounts can have relationships with other contract accounts, just like external accounts. Many people misuse the word transaction to refer to news, so it is possible that the word message has gradually disappeared from everyone's view and is no longer used because of the consensus of the community.

What is gas?

Ethernet Fong implements a running environment on the block chain, which is called Ethernet Fong Virtual Machine (EVM). Each node participating in the network will run EVM as part of the block authentication protocol. They validate each transaction covered in the block and run the exchange-triggered code in the EVM. All nodes in each network perform the same calculation and store the same value. The fact that contract execution is repeated many times in all nodes makes contract execution expensive, so it encourages people not to put all the operations that can be done down the chain on the block chain. There is a specific consumption for each command executed, counted in units of gas. Each command that can be used by a contract has a corresponding gasvalue.

Gas and gas consumed by transactions

Each transaction is required to include a gas limit (sometimes called startGas) and a fee that a transaction is willing to pay per unit gas. Miners can optionally package these transactions and charge these fees. In reality, all transactions today are ultimately chosen by miners, but the transaction fees that users choose to pay will affect how long it takes for the transaction to be packaged. If the amount of gas required for the transaction is less than or equal to the set gas limit due to calculation, including the original message and some other triggered messages, the transaction will be processed.

If the total gas consumption exceeds gas limit, then all operations will be restored, but the transaction is established and the transaction fee will be charged by the miner. The blockchain will show that the transaction was completed, but all contract orders were restored because not enough gas was provided. So the excess gas that is not used in the transaction will be called back to the initiator in the form of Taiyuan. Because gas consumption is generally only a rough estimate, many users overpay gas to ensure that their transactions are accepted. This is no problem, because the extra gas will be returned to you.

Estimate transaction consumption

The transaction fee for a transaction consists of two factors:

GasUsed: total number of gas consumed by this transaction

GasPrice: the price of unit gas in this transaction (calculated in Taiyuan)

Transaction fee = gasUsed * gasPrice

GasUsed

The commands in each EVM are set to the corresponding gas consumption value. GasUsed is the sum of the gas consumption values of all executed commands.

If you want to estimate the gasUsed, you can use the API of this estimateGas

GasPrice

A user can build and sign a transaction, but each user can set the gasPrice he or she wants to use, or even zero. However, the Frontier version of the Ethernet Fong client has a default gasPrice, 50 billion wei. In order to maximize their returns, if a large number of transactions use the default gasPrice, that is, 50 billion wei, then it is basically difficult for miners to accept a low gasPrice trade, let alone 0 gasPrice trade.

Transaction fee case

The MyEtherWallet team has a small page that allows you to convert etheric coins into small gas counting units.

You can think of gasLimit as the upper limit of your car's fuel tank. At the same time, gasPrice is understood as oil price.

For a car, the oil price may be 2.5 oil with a mistake in the formula = $25. Similarly, 21000 20 GWei gas = 0.00042 ETH.

Therefore, the total transaction fee will be 0.00042 Ether dollars.

Sending tokens usually consumes about 50 to 100000 gas, so the total transaction fee increases by 0.001 to 0.002 ETH.

What is "Block gas limit"?

Chunk gas limit is the maximum amount of gas allowed in a single chunk, which can be used to determine how many transactions can be packaged in a single chunk. For example, we have five transactions with gas limit of 10, 20, 30, 40 and 50. If the block gas limit is 100, then the first four transactions can be successfully packaged into the block. Miners have the right to decide which deals to package into blocks. So another miner can choose to package the last two transactions into the block (50-40), and then package the first deal (10). If you try to package a deal that will use more than the current block gas limit, the deal will be rejected by the network, and your Ethernet Square client will reply that the error "transaction exceeds block gas limit".

The current gas limit of the block is 4712357 gas, and the data is from ethstats.net, which means that about 224 transfer transactions (gas limit is 21000) can be crammed into a block (the block time fluctuates between 15 and 20 seconds). This agreement allows miners in each block to adjust block gas limit by arbitrarily adding or subtracting 1max 2024 (0.0976%).

Who will decide?

The gas limit of the block is determined by the miners on the network. Unlike the adjustable Block gas limit protocol, there is a default mining policy, that is, the default minimum block gas limit for most clients is 4712388.

How does Block gas limit change

The miners in Ether Square need to use a mining software, such as ethminer. It connects to a geth or Parity ethernet client. Both Geth and Pairty have options that allow miners to change the configuration. Here are the geth mining command line options and the options for Parity.

What is the "DoS" attack on the Ethernet Fong network?

Recently, there have been some comments that the ethernet network is slowly slowing down, becoming congested or even unusable. These comments refer to the deceleration process as a "DoS" attack on the ethernet network. The so-called DoS situation occurs when there are continuous full blocks on the ethernet network and there are a large number of transactions waiting to be processed on the network. At the same time, miners have the right to choose which transactions to package according to transaction fees. If there were thousands of transactions in the queue (in the trading pool) waiting to be packaged, it could cause abnormal transaction delays of several hours. DDoS may be malicious or non-malicious.

Malicious DoS

Last fall, Etay Fong was attacked by someone or a group, trading in large quantities of rubbish. This attack is described in the following blog (https://ethstats.net/):

Attackers make it difficult for clients to process these calculations by repeatedly calling certain commands in their smart contracts, but these commands consume only a small amount of gas, so they are very cheap to call.

In this attack, miners were asked to lower their gas limit to 1.5 million, which was later changed to 2 million in another incident. There have also been several other incidents that require miners to lower block gas limit when the network is attacked.

Harmless DoS

Non-malicious DoS actually means that when the network is faced with a large number of transactions, it takes more time than usual to process a transaction. Recently, due to the popularity of ICO, the ethernet network has been filled with transactions many times. Friends of Infura have written a technical analysis article (https://blog.infura.io/when-there-are-too-many-pending-transactions-8ec1a88bc87e) related to this.

Why doesn't the block gas limit adjust automatically when the block is filled?

The main reason: the miners did not use the dynamic adjustment function of gas limit.

There is a mechanism in the Etay Fong agreement that allows miners to vote to determine gas limit, so the block capacity can be adjusted without hard bifurcations. Initially, this mechanism was tied to another default strategy, that is, miners voted by default to make block gas limit at least 4.7 million, and tended to use 1.5 times more gas than the last 1024 blocks. This allows block capacity to rise automatically according to demand, and there is also a limit that can be used to defend against junk trading.

As mentioned in the "malicious DoS" section, there have been several times in history that miners have had to use non-default settings to help reduce the impact of attacks. But the problem now is that the pool did not change the settings back to the default settings after the attack. About a month ago, miners were asked to change the gas limit and gas price settings to add the gas limit dynamic adjustment function again. Because of the recent boom in token sales, many blocks have been filled and blockages have been blocked.

ETH Gas Station is a website where people can check out the latest block gas limit settings.

What do miners need to do to fix the problem?

Miners can restart dynamic gas limit adjustments by changing settings in the Geth or Parity client. Note: these settings are found in this Reddit post and can actually be set higher (see this post).

Geth

Recommended settin

-gasprice 4000000000-targetgaslimit 4712388

explain

-targetgaslimit Target gaslimit sets the artificial targetgas floor for the blocks to mine (default: "4712388")-gasprice Minimal gasprice to accept for mining a transactions (default: "20000000000"). Note: gasprice is listed in wei.

Parity

Recommended settin

-gas-floor-target 4712388-gas-cap 9000000-gasprice 4000000000

explain

-gas-floor-target Amount of gas per block to target when sealing a new block (default: 4700000).

-gas-cap A cap on how large we will raise the gas limit per block due to transaction volume (default: 6283184).

-- gasprice Minimum amount of Wei per GAS to be paid for a transaction to be accepted for mining. Note: gasprice is listed in wei. Note 2:-- gasprice is a "Legacy Option"

The above is the content of this article on "what are the concepts of blockchain fallibility". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report