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

Parse optimism gas parameters for receipts in jsonrpcs #225

Merged

Conversation

mininny
Copy link
Member

@mininny mininny commented Oct 10, 2024

In erigon, getReceipts retrieves receipts in the following order:

  1. from the memory cache
  2. from the database
  3. from re-executing transactions to produce a receipt

For optimism, we need to apply L1 gas fields like L1GasPrice with the receipt. We are applying the l1 gas fields when we are getting the receipt from the database, but not when we're re-executing transactions.

This PR adds the logic to apply optimism gas fields after re-executing transactions.

You can compare the new logic with the existing logic on how to apply the optimism gas params:

if config.IsOptimismBedrock(number) && len(txs) >= 2 { // need at least an info tx and a non-info tx
gasParams, err := opstack.ExtractL1GasParams(config, time, txs[0].GetData())
if err != nil {
return err
}
for i := 0; i < len(r); i++ {
if txs[i].Type() == DepositTxType {
continue
}
r[i].L1GasPrice = gasParams.L1BaseFee.ToBig()
l1Fee, l1GasUsed := gasParams.CostFunc(txs[i].RollupCostData())
r[i].L1Fee = l1Fee.ToBig()
r[i].L1GasUsed = l1GasUsed.ToBig()
r[i].FeeScalar = gasParams.FeeScalar
r[i].L1BlobBaseFee = gasParams.L1BlobBaseFee.ToBig()
r[i].L1BaseFeeScalar = u32ptrTou64ptr(gasParams.L1BaseFeeScalar)
r[i].L1BlobBaseFeeScalar = u32ptrTou64ptr(gasParams.L1BlobBaseFeeScalar)
}
}

Closes #222

@mininny mininny marked this pull request as ready for review October 14, 2024 18:02
@mininny mininny merged commit 33d30df into op-erigon Oct 14, 2024
7 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.

RPC method eth_getTransactionReceipt crashing
2 participants