-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Problem
With the introduction of surge pricing on the Flow network (see FLIP-337), the EVM Gateway (EVM GW) encounters several challenges that directly impact its reliability and economics:
COA Deficit for Gateway Operators:
Surge pricing increases the cost of Cadence transactions that wrap EVM calls. If the gas price encoded in the EVM transaction is too low, it may not cover the surged Flow cost. This leads to a cost over-absorption (COA deficit) for EVM GW operators. This is especially problematic since EVM gas prices are fixed at transaction construction time, while Flow fees can change dynamically. Currently, the gateway takes on the economic risk of these mismatches. Over time, this could disincentivize gateway operators or lead to hidden costs for users.
Transaction Failures and UX Regressions:
Due to Flow’s time-to-seal potentially stretching under load, transactions submitted at a lower surge factor (e.g. 1x) might be executed at a higher one (e.g. 1.2x). If the surged cost exceeds the encoded maxFeePerGas multiplied by gasLimit in the EVM transaction, the transaction fails in-flight. This degrades UX for dApps and wallets like MetaMask.
High-Level Solution Strategy
This Epic introduces a multi-pronged approach to align EVM Gateway functionality with Flow's dynamic surge pricing model:
1. Real-Time Surge Awareness in Gateway:
The EVM GW must track the current surge multiplier via event subscriptions or a new Access Node API. It uses this to decide whether to accept or reject EVM transactions.
2. Price Reflection in JSON-RPC APIs:
The eth_gasPrice and eth_feeHistory responses from the EVM Gateway will incorporate the current surge multiplier. This ensures tools like MetaMask can adjust their fee suggestions accordingly, keeping user expectations aligned.
3. Configurable Surge Tolerance and Fail-Safe Execution Protection:
The EVM Gateway will tolerate surge pricing increases up to a configurable threshold (for example, no more than 10%). This threshold will be set by the gateway operator via a command-line argument. If the current surge factor exceeds this limit, the gateway will reject the incoming EVM transaction outright.
In addition, the gateway will include an optional surge ceiling field in the Cadence wrapper transaction it submits to Flow. This ensures that if the surge factor increases after submission but before execution, the Cadence transaction will fail gracefully rather than executing at an unprofitable rate. Together, these safeguards ensure the EVM Gateway avoids large deficits due to volatile fee changes.
4. Long-Term Protocol Improvements (Changes to flow-go, out of scope for EVM GW):
- Add a
maxSurgeFactorfield in the Cadence transaction, similar to maxFeePerGas, allowing native integration of surge awareness. This is will be implemented on the flow-go side. - Bind surge pricing to the reference block instead of the execution block for predictability.