fix/mantle lack operator fee#8837
Open
jeremytsng wants to merge 2 commits into
Open
Conversation
…d` is missing `OracleLayer1GasFeeFlow` skipped the operator-fee oracle call whenever `transactionMeta.gasUsed` was unset. Mantle has no value for `gasUsed` during the pre-confirmation lifecycle, so the operator fee silently collapsed to zero and the displayed L1 fee under-reported the actual on-chain cost. Expose a `protected getOperatorFeeGas` hook on the base flow so subclasses can supply a fallback value, and override it in `MantleLayer1GasFeeFlow` to fall back to `txParams.gas` (or `txParams.gasLimit`) when `gasUsed` is not available. Gas limit is an upper bound on actual gas used, so the resulting operator fee over-estimates rather than under-reports.
d661f99 to
08620b9
Compare
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.
Explanation
We observed the confirmation screen showing
0.10 MNTfor a transaction that ended up costing0.12 MNT— the ~0.02 MNT delta is the operator-fee component of Mantle's Arsia gas model, which never reached the displayed total.Root cause is in
OracleLayer1GasFeeFlow.#getOperatorLayer1GasFee: the method skips the operator-fee oracle call whenevertransactionMeta.gasUsedis unset. That field is populated by the transaction simulation backend, and Mantle is not in its supported-networks list —getBalanceChangesthrowsSimulationChainNotSupportedError, the catch returnsgasUsed: undefined, and the operator-fee path silently collapses to zero for the entire pre-confirmation lifecycle (initial render, gas-fee poller re-poll, edit-gas). The UI sumslayer1GasFeestraight into the displayed total inuseFeeCalculations.ts, so the dropped operator fee flows directly to the user.The fix introduces a
protected getOperatorFeeGashook onOracleLayer1GasFeeFlow. The base default returnstransactionMeta.gasUsed, soOptimismLayer1GasFeeFlow,ScrollLayer1GasFeeFlow, and any other current or future subclass keep their existing behaviour.MantleLayer1GasFeeFlowoverrides the hook to fall back totxParams.gas ?? txParams.gasLimitwhengasUsedis unavailable.The transaction's gas limit is an upper bound on actual gas used (it carries the
updateGasbuffer when populated by the controller, and is the caller-supplied value otherwise). Mantle's operator-fee oracle is strictly linear in its input gas (verified on-chain at0x420000000000000000000000000000000000000F—getOperatorFee(21000) = 2.1e14,getOperatorFee(500000) = 5e15, same per-gas rate), so the operator fee returned for a gas-limit input is an upper bound on the realised operator fee. The displayed total will be a hair above the actual on-chain cost rather than under-reporting it. This matches the over-estimate direction already used for the Optimism L1 data fee.Caller coverage with the override in place:
addTransactionflow):updateGaspopulatestxParams.gasin#updateGasPropertiesbeforeupdateTransactionLayer1GasFeeruns in the same method.GasFeePoller10s re-poll: reads the sametxParams.gasfrom state.updateEditableParams(user edits gas): uses the newtxParams.gasafter the edit.bridge-controller'sappendL1GasFeesis allowlisted to Optimism + Base only today, so Mantle quotes don't reach this code. The?? gasLimitarm future-proofs the bridgegetLayer1GasFeecall shape if Mantle is added later.References
Fixes the operator-fee under-reporting flagged by the Mantle team following the Arsia gas model rollout.
Checklist
Note
Low Risk
Low risk: adds an overridable hook to choose the gas value for the operator-fee oracle and updates Mantle to fall back to
txParams.gas/txParams.gasLimit, with focused unit-test coverage.Overview
Fixes Mantle L1 fee under-reporting when simulation data is missing.
OracleLayer1GasFeeFlownow uses a new protectedgetOperatorFeeGashook (defaulting totransactionMeta.gasUsed) to decide whether/what to pass togetOperatorFee.MantleLayer1GasFeeFlowoverrides this hook to fall back totxParams.gas ?? txParams.gasLimitwhengasUsedis unavailable, and the Mantle fee-flow tests are expanded to cover the new fallback/skip behavior. The transaction-controller changelog documents the fix.Reviewed by Cursor Bugbot for commit 5b00cd4. Bugbot is set up for automated code reviews on this repo. Configure here.