Skip to content
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

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

nicholaspai
Copy link
Member

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

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
Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app-frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 0:26am
sepolia-frontend-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 0:26am

@@ -1975,6 +1976,7 @@ export function getCachedFillGasUsage(
buildDepositForSimulation(deposit),
overrides?.relayerAddress,
{
gasPrice,
Copy link
Member Author

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

Copy link
Member Author

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

@nicholaspai nicholaspai marked this pull request as draft January 9, 2025 20:22
@nicholaspai nicholaspai marked this pull request as ready for review January 9, 2025 22:58
@nicholaspai nicholaspai changed the title improve(API): Pass gasPrice into relayerFeeDetails call improve(API): Pass gasPrice into relayerFeeDetails call + add OP_STACK_L1_DATA_FEE_MARKUP Jan 9, 2025
@@ -70,50 +71,32 @@ const handler = async (
const relayerFeeCalculatorQueries = getRelayerFeeCalculatorQueries(
Number(chainId)
);
const opStackL1GasCostMultiplier = getGasMarkup(
Copy link
Member Author

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))) {
Copy link
Member Author

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:
Copy link
Member Author

@nicholaspai nicholaspai Jan 10, 2025

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
Copy link
Member Author

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

Copy link
Contributor

@dohaki dohaki left a 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

api/_cache.ts Show resolved Hide resolved
@nicholaspai nicholaspai merged commit 44a2298 into master Jan 10, 2025
9 checks passed
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.

2 participants