Cointime

Download App
iOS & Android

Pricing Gas in Polygon zkEVM

Validated Project

The final Polygon zkEVM testnet, which launched last year, has seen a surge of developers and users eager to experience the future of Ethereum scaling.

The years-long technical achievements to get to this point have been enormous. Researchers working on zero-knowledge (ZK) to scale Ethereum have had to answer and address a bevy of design questions at every turn.

One interesting question that arises for all zkEVMs: how do you price gas?

In the Ethereum Virtual Machine (EVM), gas keeps the network secure by setting an economic fee for every computation. Malicious behaviors, like Denial of Service (DoS) attacks, are muted by setting a price to execute transactions. Gas limits define the total number of computational steps a transaction can execute.

So why is figuring out how to price gas in zkEVMs an interesting problem?

Because gas is supposed to reflect resource consumption for nodes (bandwidth/storage/compute), but when generating zkEVM proofs, some EVM opcodes are relatively more expensive to prove than to re-execute on a CPU.

In other words, some computations that require low gas fees in the EVM might become prohibitively expensive and slow down the network when proved in zkEVM. 

What does this mean? Solidity, the programming language for the EVM, is compiled into opcodes, which run on the blockchain. Each opcode does something simple, and each requires gas to execute. 

To translate gas pricing into zkEVM for these opcodes, there are three options, each of which requires different considerations: 

  1. Keep the gas schedule the same as in the EVM
  2. Reprice opcodes
  3. Keep the gas schedule, but also introduce a mechanism for DoS mitigation

We’ll walk through each option and explain the best design choice for Polygon zkEVM.

Keep the gas schedule? Or reprice opcodes?

Keeping the regular EVM gas fee schedule for Polygon zkEVM seems attractive enough, because existing contract behavior in the EVM would remain unchanged. This is ideal for developers who can easily and seamlessly deploy Ethereum dApps in a zkEVM environment, and a huge upside for EVM-equivalency. 

But maintaining gas fees without modification actually introduces a new vector for potential DDoS attacks. 

There are computations in the EVM which require low gas fees, but which in the context of a zkEVM become very expensive to prove. Cram enough opcodes into one block that are low-cost in EVM, but high-cost in zkEVM, and the network can experience serious lag. 

An example? Keccak hashes are expensive to prove in a zkEVM environment. Filling a block with the opcode “EXTCODESIZE” would only cost 100 gas, but cause a type-1 zkEVM to perform an unwieldy number of Keccak hashes–leading to a potential DoS vector.

So a 1:1 pricing scheme looks like it might cause some trouble.

Why not reprice opcodes, then, in order to reflect the proving cost in a zkEVM? (This is option two above.)

The problem is that some contracts rely on the current gas schedule to function as intended – opcodes like “GASLEFT,” for example, or “CALLSTIPEND.” Repricing opcodes for Polygon zkEVM might actually introduce unexpected behavior into dApps, causing developers unnecessary headaches. 

So that leads us to the best option for Polygon zkEVM…

Keep the gas schedule, but also introduce DoS mitigation

With its fast prover, Polygon zkEVM is able to keep the EVM gas schedule, but also introduces a mechanism by which DDoS attacks can be mitigated. In other words, contract functionality can be preserved without sacrificing the security and reliability of the network. 

How does Polygon zkEVM do it? 

First, the gas schedule remains the same. Opcodes are priced the same in Polygon zkEVM as they are in the EVM. 

Second, and most importantly, Polygon zkEVM introduces quotas to identify pathological transactions, like filling an entire block with EXTCODESIZE. Think of it like an extra security reflex. Only a certain number of Keccak hashes can be included in a block. Polygon zkEVM scans for malicious blocks that breach this quota, helping to ensure that expensive and network-slowing spam does not occur.

Due to the extremely fast Polygon zkEVM prover, the differences in compute cost between the L1 gas schedule and actual resource consumption in Polygon zkEVM remains marginal.

It’s the best of all worlds: seamless design integration coupled with a mechanism to prevent spam.

Read more: https://polygon.technology/blog/pricing-gas-in-polygon-zkevm

Comments

All Comments

Recommended for you

  • BTC breaks through $92,000

     the market shows BTC breaking through $92,000, currently at $92,023.91, with a 24-hour decline of 0.13%. The market is highly volatile, please manage your risk accordingly.

  • WLFI launches lending marketplace powered by Dolomite

     WLFI launches a lending market supported by Dolomite.

  • Spot gold rose more than $300 in January.

     spot gold has risen above $4620/oz, with a daily increase of 2.44%, accumulating a rise of over $300 in the first month of the new year.

  • Hassett: Still interested in a Fed position

    White House National Economic Council Director Hassett: Still interested in the Federal Reserve position. It is unknown whether U.S. President Trump has approved an investigation into the Federal Reserve. Federal Reserve Chairman Powell is a good person.

  • BTC falls below $91,000

     the market shows BTC fell below $91,000, currently at $90,997.44, with a 24-hour increase of 0.26%. The market is highly volatile, please manage your risks accordingly.

  • The US spot Ethereum ETF saw a net outflow of $68.57 million last week.

    according to SoSoValue data, during the trading days last week (January 5 to January 9, Eastern US time), the US spot Ethereum ETF had a net outflow of 68.57 million USD.

  • BTC breaks through $92,000

    the market shows BTC breaking through $92,000, currently at $92,041.92, with a 24-hour increase of 1.49%. The market is volatile, please manage your risk accordingly.

  • Japanese Prime Minister considers dissolving the House of Representatives; USD/JPY rises sharply.

    Japanese Prime Minister is considering dissolving the House of Representatives. The USD/JPY exchange rate quickly rose by 0.66% to 157.95, hitting a new one-year high. 

  • a16z announced the completion of a $15 billion funding round, which will focus on investments in AI and crypto.

    a16z has just completed raising over $15 billion in funds. This batch of funds includes: American Dynamism Fund ($1.176 billion), Apps Fund ($1.7 billion), Bio + Health Fund ($700 million), Infrastructure Fund ($1.7 billion), Growth Fund ($6.75 billion), and other venture capital strategy funds ($3 billion). The announcement states that its mission is to ensure the United States wins the technology competition in the next 100 years, focusing on winning key infrastructures such as AI and crypto. In addition, it will promote the application of related technologies in fields such as biology, health, defense, public safety, education, and entertainment.

  • BTC falls below $90,000

     market shows BTC fell below 90,000 USD, currently at 89,996.08 USD, 24-hour decline reached 0.43%, market volatility is high, please manage risk properly.