Skip to content

fix: prevent block-gas-limit fallback for EIP-7702 batch gas estimates#8710

Draft
matthewwalsh0 wants to merge 1 commit intomainfrom
fix/pay-batch-7702-gas-fallback
Draft

fix: prevent block-gas-limit fallback for EIP-7702 batch gas estimates#8710
matthewwalsh0 wants to merge 1 commit intomainfrom
fix/pay-batch-7702-gas-fallback

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

Explanation

When transaction-pay-controller builds a quote, it calls TransactionController:estimateGasBatch to size the on-chain submission. For the EIP-7702 batch path, estimateGasBatch delegates to estimateGas. On simulation failure, estimateGas silently substitutes a fraction of the block gas limit (or, on chains that configure it, a fixed value) into its returned estimatedGas. The 7702 branch of estimateGasBatch then surfaced that value as totalGasLimit with no failure indicator, so callers could not tell a successful estimate from a fallback.

In estimateQuoteGasLimitsBatch this was treated as a real estimate, multiplied by the configured gas buffer, and used both as the EIP-7702 batch gas limit (gasLimit7702) and as the basis for fiat fee calculation in calculateGasCost. On chains without a fixed fallback, that produced a number on the order of 0.35 * blockGasLimit * gasBuffer — tens of millions of gas — surfaced to the user as the quote gas estimate.

The single-transaction estimation path already handles this correctly: estimateGasLimit returns usedFallback: true and substitutes relayFallbackGas from transaction-pay-controller's feature flags. The batch path had no equivalent.

This change makes the batch path symmetric:

  1. transaction-controller's EstimateGasBatchResult now exposes simulationFails. The 7702 branch detects when estimateGas failed and replaces the unsafe estimatedGas value with sum(per-tx gas hints) + getGasEstimateFallback(chainId) — applied once for the unsimulated portion. Per-transaction gas hints (e.g. those Relay returns alongside its quote steps) are preserved rather than discarded.
  2. transaction-pay-controller's estimateQuoteGasLimitsBatch now accepts the same fallbackGas and fallbackOnSimulationFailure options as the single-transaction path, threaded through from estimateQuoteGasLimits. When simulationFails is set:
    • If fallbackOnSimulationFailure is not set, it throws (mirrors the single path).
    • Otherwise, it logs and substitutes fallbackGas ?? getFallbackGas(messenger) (i.e. relayFallbackGas), applies the gas buffer, and preserves the existing 7702 single-bucket result shape so the is7702 discriminator stays correct.

For non-7702 batches that fail simulation, the fallback is fanned out per transaction. For 7702 batches the fallback is a single bucket, matching how the success path returns a single combined gas limit.

The relay-quotes strategy already passes fallbackOnSimulationFailure: true, so the relay submission flow now sees the configured fallback values instead of the block-gas-limit-derived figure.

References

N/A.

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant