-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve(API): Pass gasPrice into relayerFeeDetails call + add OP_STACK_L1_DATA_FEE_MARKUP #1366
Conversation
We should pass the pre-computed gas price into this call so that we don't query the gas price twice. Additionally, we can use the scaled up gas price value to derive the gas fee totals, which currently are not using the scaled up values
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -1975,6 +1976,7 @@ export function getCachedFillGasUsage( | |||
buildDepositForSimulation(deposit), | |||
overrides?.relayerAddress, | |||
{ | |||
gasPrice, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing this in avoids a redundant SDK.GasPriceOracle.getGasPriceEstimate call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if we don't pass in this gas price, then this function will return gasCosts that we use in the relayerFeeCalculator but it recomputes the gas price without any multipliers. So, the resultant tokenGasCost is likely too low
@@ -70,50 +71,32 @@ const handler = async ( | |||
const relayerFeeCalculatorQueries = getRelayerFeeCalculatorQueries( | |||
Number(chainId) | |||
); | |||
const opStackL1GasCostMultiplier = getGasMarkup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes in this file align it with the /limits implementation for computing gas costs:
making sure for Linea we don't pass in gasPrice and let SDK.getGasCosts estimate gas costs using the unsignedTx from the deposit
// OPStack chains factor in the L1 gas cost of including the L2 transaction in an L1 rollup batch | ||
// into the total gas cost of the L2 transaction. | ||
let opStackL1GasCost: ethers.BigNumber | undefined = undefined; | ||
if (sdk.utils.chainIsOPStack(Number(chainId))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this opStackL1GasCost
recomputation can be replaced because the SDK as of 3.4.8 returns the opStackL1GasCost
@@ -124,12 +107,23 @@ const handler = async ( | |||
Object.keys(chainIdsWithToken).map((chainId, i) => [ | |||
chainId, | |||
{ | |||
gasPrice: gasPrices[i].maxFeePerGas.toString(), | |||
gasPrice: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For linea we can infer the gas fee components trivially because the base is hardcoded at 7
relayer, | ||
gasPrice, | ||
gasCosts?.nativeGasCost, | ||
gasCosts?.tokenGasCost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we are using this tokenGasCost that wasn't dependent on the gasPrice
we computed in the latestGasPriceCache(destinationChainId).get()
call, which means that this tokenGasCost estimate is low
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice this looks good to me
We should pass the pre-computed gas price into this call so that we don't query the gas price twice. Additionally, we can use the scaled up gas price value to derive the gas fee totals, which currently are not using the scaled up values