Skip to content

Commit

Permalink
fix(sdk): bug in L1 gas cost estimation (#8836)
Browse files Browse the repository at this point in the history
Fixes a bug in L1 gas cost estimation where not all properties from the
input transaction were being used. This meant that certain properties
like access lists or transaction value weren't included in the
calculation. Resulting estimates were wrong.
  • Loading branch information
smartcontracts authored Jan 4, 2024
1 parent 9278f94 commit 6ec80fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-otters-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/sdk': patch
---

Fixes a bug in l1 gas cost estimation.
20 changes: 8 additions & 12 deletions packages/sdk/src/l2-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ export const estimateL1Gas = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1GasUsed(
serialize({
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: await getNonceForTx(l2Provider, tx),
...tx,
nonce: tx.nonce
? BigNumber.from(tx.nonce).toNumber()
: await getNonceForTx(l2Provider, tx),
})
)
}
Expand All @@ -96,12 +94,10 @@ export const estimateL1GasCost = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1Fee(
serialize({
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: await getNonceForTx(l2Provider, tx),
...tx,
nonce: tx.nonce
? BigNumber.from(tx.nonce).toNumber()
: await getNonceForTx(l2Provider, tx),
})
)
}
Expand Down

0 comments on commit 6ec80fd

Please sign in to comment.