Use chain gas price for L2 cost estimates and funding#5
Open
bxpana wants to merge 1 commit into
Open
Conversation
Pre-signed transactions embed a gas price (e.g. 100 gwei) designed for L1, but L2 chains (especially zkSync-style) have a different gas model where estimateGas returns L2 gas units at much lower prices. Multiplying L2 gas units by the L1 gas price produced wildly inflated estimates (~7 ETH instead of ~0.004 ETH) and caused deploy funding to either over-send or under-send. - Fetch chain's actual gas price via provider.getFeeData() for cost estimates - In deployOnL2, enforce node minimum (gasLimit × txGasPrice) as a floor so deployer funding never drops below what the node requires to accept the tx - Show both tx gas price and chain gas price in --gas-estimate summary Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getFeeData()) instead of the 100 gwei price embedded in pre-signed transactions when computing estimated costs. On L2s (especially zkSync-style chains),estimateGasreturns gas units in the L2's model which must be priced at the L2 gas price — not the L1 gas price baked into the legacy tx.gasLimit × txGasPriceas a floor for deployer funding so the node always accepts the pre-signed transaction, while still allowing the chain gas price to drive the estimate when it produces a higher value.--gas-estimateoutput: Show both the tx-embedded gas price and the chain's actual gas price, and label estimated costs with the pricing source.Test plan
--gas-estimatereports realistic totals (~0.004 ETH vs previous ~7 ETH on local zkSync L2)--dry-runworks unchanged--confirm) successfully funds and publishes all 6 contracts on local L2tsc --noEmit)🤖 Generated with Claude Code