Crypto Exchange Crypto Exchange
Ctrl+D Crypto Exchange
ads
Home > UNI > Info

What is the impact of the Berlin hard fork on Gas?

Author:

Time:

The Berlin hard fork was launched on the mainnet on April 14, introducing four EIPs. Two of them (EIP-2929   EIP-2930) have an impact on the gas cost of the transaction. This article will explain how some gas costs were calculated before Berlin, how it will change after EIP-2929 is added, and how to use access lists introduced by EIP-2930. This post is long, here's the synopsis: Berlin hard fork changes gas cost of some opcodes. If the value of the gas fee is hardcoded in a dapp or a smart contract, they may abort. If this happens, and the smart contract is not updatable, consumers will need access lists from EIP-2930 to use that part of the opcode. Access lists can be used to reduce gas costs by a small amount, but in practice they can increase overall gas consumption in some cases. geth  added a new RPC method called eth_createAccessList  to simplify the creation of access lists. Every opcode executed by the EVM has an associated gas cost. Most of them have a fixed cost: PUSH1 always consumes 3 units of gas, MUL 5, etc. Others vary: for example  SHA3  opcode cost depends on its input size. We mainly discuss the opcodes  SLOAD  and  SSTORE, as they are the ones most affected by the Berlin hard fork. We will discuss address-specific opcodes later, such as all of the  EXT*  and  CALL* , as their gas costs have also changed. The gas cost of the former SLOAD in Berlin The latest version of the Ethereum client Geth has supported all the improvement proposals for the next hard fork "Berlin": On June 8, the official Ethereum client Geth released the latest version 1.9.15, except for regular fixes In addition to vulnerabilities, all the improvement proposals planned for the next hard fork upgrade "Berlin" have been implemented in this update, and the temporary test network Yolo for these EIPs has been launched. [2020/6/8] Before EIP-2929, the gas consumption of SLOAD was simple: it always consumed 800 gas. So there is (for now) nothing to say. Gas cost of SSTORE before Berlin In terms of gas consumption, SSTORE  is probably the most complex opcode, because its cost depends on things like the current value of the storage slot, the new value, and whether it has been modified before. We only analyze some cases to get a basic understanding; if you want to know more, please read the EIP link at the end of the article. If the value of the storage slot changes from 0 to 1 (or any non-zero value), the gas consumption is 20000. If the value of the storage slot changes from 1 to 2 (or any other non-zero value), the gas consumption is 5000. If the value of the storage slot changes from 1 (or any non-zero value) to 0, the gas consumption is also 5000, but you will get 1 gas fee refund at the end of the transaction. This article will not discuss gas refunds, as they were not affected in the Berlin hard fork. If the value of the storage slot is modified in the same previous transaction, the gas consumption of all subsequent  SSTORE  will be 800. The details of this part are not interesting, the important thing is that SSTORE is expensive, and its consumption depends on several factors. EIP-2929 affects the gas consumption of all the above opcodes. But before we dive into these changes, we need to talk about an important concept introduced by this EIP: accessed addresses and accessed storage keys. News | Coinbase opens new office in Dublin: According to Coincryptorama, Coinbase said on Tuesday that the company has opened a new office in Dublin to expand its business in Europe. As the U.K. moves closer to leaving the European Union, Coinbase has chosen Ireland as the location for its second European base as part of contingency plans for the U.K. to remain in the bloc after Brexit. Zeeshan Feroz, CEO of Coinbase UK, said the expansion in the Irish capital was about "finding ways to better serve our customers". [2018/10/16] An address or a storage key is considered "visited" if they have been "used" in a previous transaction. For example, when you CALL (call) another contract, the address of the contract will be marked as "accessed (visited)". Likewise, when you SLOAD (load) or SSTORE (store) some slots, other parts of the transaction are also considered visited. It doesn't matter which opcode executes it: if a  SLOAD  reads a slot, the following  SLOAD  and SSTORE  will all be considered visited. It's worth noting here that storage keys are "built in" to some addresses. As explained in this EIP: When executing a transaction, maintain a set of  accessed_addresses: Set[Address]  and accessed_storage_keys: Set[Tuple[Address, Bytes32]] That is to say, when we say that a storage slot is accessed Alright, we're actually talking about a pair  (address, storageKey)  being accessed. Next, let’s talk about the new gas consumption. News | EOS Dublin announces support for WORBLI: According to IMEOS reports, since EOS New York announced the cooperation with WORBLI, EOS Dublin announced that it will become one of the first BPs of the WORBLI blockchain. [2018/9/1] SLOAD after Berlin Before the Berlin hard fork, SLOAD consumed 800 gas. Now, it depends on whether the storage slot has been accessed or not. If it has not been accessed, the gas consumption is 2100; if it has been accessed, it is 100. Therefore, if the slot is in the list of accessed storage keys, the gas consumption of SLOAD  will be less than 2000. SSTORE after Berlin Let us revisit the previous  SSTORE  example in the context of EIP-2929: If the value of the storage slot changes from 0 to 1 (or any non-zero value), the gas consumption is: The key has not been accessed, 22100 if it has been accessed, 20000 if the value of the storage slot has changed from 1 to 2 (or any other non-zero value), the gas consumption is: if the storage key has not been accessed, 5000 if Has been accessed, 2900 If the value of the storage slot changes from 1 (or any non-zero value) to 0, the gas consumption is the same as the previous case, plus the return. If the value of the storage slot is modified in the same previous transaction, the gas consumption of all subsequent  SSTORE  will be 100. As you can see, the first SSTORE  consumes less than 2100 gas if the slot being modified by the SSTORE  is visited before. Berlin International Tourism Exhibition pays attention to blockchain technology: According to Xinhua News Agency, at the 52nd Berlin International Tourism Exhibition, the application prospect of blockchain technology in the tourism industry has become a hot topic. Tourism technology business executives and experts generally believe that blockchain technology has broad prospects for application in the tourism industry, but it is still in its infancy. Norm Rosin, president of the American Travel Technology Consulting Company, believes that the impact of blockchain technology on the tourism industry is mainly related to transparency and loyalty. Enterprises can apply blockchain and cryptocurrency technology to their projects such as points for members. Rossing said that blockchain technology has the potential to revolutionize distribution, payment and authentication platforms, but it will take three to five years to take shape. Michael Calhern, CEO of American company TripX, believes that payment transactions are one of the most suitable fields for applying blockchain technology. Jillian Tans, CEO of Booking.com, a global online hotel booking website, said that there are currently many discussions on the development potential and application of blockchain technology in the tourism industry. It is still in its infancy, but there are many interesting ones. Ideas and business models are under constant discussion and development. [2018/3/10] The following table compares the above values: Note that in the last line it is not necessary to talk about whether the slot has been visited, because if it has been written to before, then it has been visited. The other EIP we mentioned at the beginning is EIP-2930. This EIP adds a new transaction type, which can add an access list to the transaction. This means that you can declare in advance which addresses and slots should be considered visited before transaction execution begins. For example, a  SLOAD  of an unvisited slot needs to consume 2100 gas, but if the slot is added to the transaction access list, the same opcode only consumes 100 gas. But if already visited addresses or stored keys cost less gas, does that mean we can add everything to the transaction access list to reduce gas consumption? Great! No more gas fees! However, this is not always the case, as you still need to pay the gas fee every time you add an address and store a key. A cafe in Berlin, Germany accepts ETH and LTC payments: A cafe called Crypto Cafe in Berlin, Germany has accepted ETH and LTC payments, which is also the first cafe in Berlin to accept digital currency payments. [2018/2/14] Let's look at an example. If we are sending a transaction to contract A, the access list might be as follows: If we send a transaction with this access list, the first opcode using slot 0x0  is SLOAD, which consumes 100 instead of 2100 gas. This reduces gas by 2000. But every time the storage key is added to the access list of the transaction, it will consume 1900 gas. So we only save 100 gas. (If the first opcode to access the slot is  SSTORE instead of  SLOAD, we can save 2100 gas, which means that if we consider the consumption of the storage key, we save a total of 200 gas.) This Does it mean that as long as we use transaction access lists, we can save gas? No, because we also need to pay the gas for adding the address to the access list (ie  "<address of A>"  in our example). So far we've only discussed the opcodes  SLOAD  and  SSTORE, but these aren't the only opcodes that have changed after the Berlin upgrade. For example, the fixed cost before opcode  CALL  is 700. But after EIP-2929, if the address is not in the access list, its consumption becomes 2600, if it is, it is 100. Also, like stored keys that have been accessed, no matter what opcode was accessed before (for example, if EXTCODESIZE  is called for the first time, then this opcode will consume 2600 gas, and any subsequent use of the same address  EXTCODESIZE,  CALL  or STATICCALL only consume 100 gas). How does this affect transactions with access lists? For example, if we send a transaction to contract A, and the contract calls another contract B, then we can add such a list: We will need to pay 2400 gas to add this access list to the transaction, but then use  The first opcode at address B  only consumes 100 gas, not 2600. Therefore, we save 100 gas by doing this. If B uses its storage in a certain way, and we know which keys are used, then we can also add them to the access list, which can save 100~200 gas per key (depending on depending on whether your first opcode was  SLOAD  or  SSTORE ). But why are we talking about another contract? What about the contract we are calling? Why not do these operations on this contract? We can do this, but it is not cost-effective, because EIP-2929 clearly stipulates that the address of the contract being called (ie tx.to) will be added to the  accessed_addresses  list by default. So we don't have to pay the extra 2400 gas. Let's analyze the previous example again: Unless we want to add a few more storage keys, this is actually a waste.

Tags:

UNI
CFTC COT Bitcoin Holdings Weekly Report: Institutions have missed out, and large investors have become the only accurate "prediction" account for this round of callbacks

On April 17, CFTC announced the latest CME Bitcoin Futures Weekly Report (April 7-April 13). During the latest statistical period, BTC prices resumed their upward trend. During the statistical period.

WeStarter reached a strategic cooperation with Dora Factory

WeStarter, an initial exchange platform for cross-chain tokens, has reached a strategic cooperation with DAO-as-a-Service infrastructure Dora Factory. In this cooperation.

It's boiling, Bitcoin has reached a new high, 130,000 people have liquidated their positions, and Tesla's beautiful pictures have made a lot of money

Original title-zce "Boiling! Bitcoin reached a new high, 130,000 people broke their positions, but these two companies made a lot of money! A $100 Billion Cryptocurrency Exchange Is Listed Today »On April 13.

What is the impact of the Berlin hard fork on Gas?

The Berlin hard fork was launched on the mainnet on April 14.

Coinbase Apocalypse The American Dream of Cryptocurrency Starting from Eleven Pages PPT

A moment in history is coming, Coinbase will be listed on NASDAQ (code COIN) on Wednesday (14th), becoming a milestone in the cryptocurrency world. According to Bloomberg.

Count those financial institutions and companies that hold a large amount of Bitcoin

The "big dive" that started over the weekend seems to be still in shock. The biggest drop was nearly 17% on Sunday and 6% on Monday. Bitcoin fell 5.5% in 24 hours before the press release today, and it is now at $54.

Stop starting a company and start a DAO

DAO does not specifically refer to an industry or field, it is an organizational governance structure, just like a limited liability company can engage in various businesses, DAO can not only manage assets.

ads