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

  • Telegram Renames Gram Wallet to Money and Launches for All Users

    On October 9, Telegram officially renamed its previously limited-access wallet service 'Gram wallet' to 'Money' and launched it to over one billion users across the platform. 'Money' is an integrated wallet for the Gram token, supporting storage, transfers, and purchases of platform gifts and collectible usernames. Additionally, the accompanying trading platform 'Walt' offers services for over 300 assets, including tokenized stocks, precious metals, perpetual contracts, and wealth management projects. Users can make instant transfers from 'Walt' to the 'Money' wallet without incurring network fees. The official statement also cautions that investing in crypto assets carries associated risks.

  • Blockchain.com Seeks Approval for Prediction Markets and Cryptocurrency Derivatives Trading

    On October 9, the crypto asset platform Blockchain.com submitted an application to the U.S. Commodity Futures Trading Commission (CFTC) seeking to obtain licenses for a designated contract market (DCM) and a futures commission merchant (FCM) to offer event contracts (prediction markets) and cryptocurrency derivatives trading services to U.S. users.

  • US May Seize Approximately $1 Billion in Cryptocurrency Related to Iran This Week

    U.S. Treasury Secretary Bencet stated at the NPolicy Summit held by Newsmax in Washington on Thursday that we may seize $1 billion in cryptocurrency this week, adding, "We know where it is, and we are isolating them." Bencet noted that the Trump administration's approach to Iran has shifted from 'maximum pressure' to 'absolute isolation,' with measures including maritime blockades, restrictions on air travel, and the cutting off of land routes. The UAE and Oman are cooperating with the U.S., which is also working with Pakistan and Turkey to cut off all land routes in and out of Iran.

  • Zcash Development Team Plans to Introduce Quantum-Resistant Signatures in January

    The development team of the privacy cryptocurrency Zcash (ZEC) plans to introduce post-quantum signature opcodes to the network in January next year, supporting hash-based signature technology to defend against potential quantum computing attacks. This solution primarily targets the transparent (public) payment pool, where approximately 70% of ZEC is currently stored. Although the developers have set January as the target deadline, the specific network activation time has not yet been finalized. This upgrade aims to prevent attackers from using existing public keys to reverse-engineer private keys and forge payment authorizations. Additionally, the Zcash node validator Zakura has launched a wallet tool based on Private Information Retrieval (PIR), allowing users to query balances across multiple addresses without revealing the correlation between those addresses to the server. Previously, Ethereum researcher Justin Drake warned that artificial intelligence could accelerate the cracking of traditional encryption algorithms and urged cryptocurrency holders to prepare for potential security threats.

  • BTC Surpasses $83,000

    Market data shows that BTC has surpassed $83,000, currently priced at $83,017.3, with a 24-hour increase of 0.66%. The market is highly volatile, so please ensure proper risk management.

  • Central Committee and State Council: Comprehensive Implementation of 'AI+' Initiative

    On October 9, the Central Committee of the Communist Party of China and the State Council issued the 'Opinions on Developing New Quality Productive Forces.' The opinions mention the comprehensive implementation of the 'AI+' initiative. This includes promoting the transformation of traditional industries through artificial intelligence, accelerating the development of new-generation intelligent terminal applications such as smart connected new energy vehicles, AI smartphones and computers, and humanoid robots. It aims to speed up innovation in digital intelligence technologies like artificial intelligence, break through foundational theories and core technologies, and strengthen the efficient supply of computing power, algorithms, and data. The strategy involves tailored approaches based on local conditions and industry-specific policies to layout national pilot bases for AI industry applications and high-value application scenarios, vigorously promoting the application of AI across various sectors. Additionally, it emphasizes the establishment of a technology monitoring, risk warning, and emergency response system to ensure that artificial intelligence is safe, reliable, and controllable.

  • U.S. Government-Related Wallet Deposits 17,733 BTC and 750 WBTC to Coinbase Prime

    On October 9, according to monitoring by Lookonchain, wallets associated with the U.S. government have deposited 17,733 BTC (worth $1.48 billion) and 750 WBTC (worth $62 million) into Coinbase Prime over the past three days. According to tagging data from Arkham, these wallets currently hold cryptocurrency assets valued at $25.4 billion, with Bitcoin alone valued at $25.3 billion.

  • ETH Falls Below $2500

    Market data shows that ETH has fallen below $2500, currently priced at $2499.87, with a 24-hour decline of 2.55%. The market is experiencing significant volatility, so please ensure proper risk management.

  • ETH Surpasses $2500

    Market data shows that ETH has surpassed $2500, currently priced at $2500.13, with a 24-hour decline of 2.21%. The market is experiencing significant volatility, so please ensure proper risk management.

  • BTC Surpasses $82,000

    Market data shows that BTC has surpassed $82,000, currently priced at $82,002.01, with a 24-hour decline of 1.47%. The market is highly volatile, so please ensure proper risk management.