Known Issues

# Issue #1852: Gas pricing discrepancy

# Issue Tracking (opens new window)

# Description

We're aware of an issue where certain opcodes are not being priced in the same way that they would be on Ethereum. Specifically, opcodes that touch state (SSTORE, SLOAD, etc.) are being charged at the "cold" storage cost, even when the state has already been touched and therefore should be charged at the "warm" storage cost. This can cause issues with some contracts.

For instance, this transaction (opens new window) triggers a TransparentUpgradeableProxy (opens new window) to make a withdrawal from the pre-deployed WETH9 contract (opens new window). The WETH9 contract attempts to send ETH to the proxy contract with the following function call:


Solidity passes along a stipend of 2300 gas when you use the msg.sender.transfer and msg.sender.send functions to transfer someone ETH (opens new window). This transfer triggers a call to the proxy's fallback function, which then triggers a call to the implementation. Normally these calls will both fit under the 2300 gas stipend because of the "warm" cost mechanism. However, because Optimism is charging the "cold" cost in all cases, this call fails and the proxy is unable to withdraw from the WETH contract.

# Impact

Certain contract interactions that work on Ethereum may not work as expected on Optimism until this issue is fixed. The most common failure case is a msg.sender.transfer to a proxy contract, as shown above. You may find similar failures when making function calls to other contracts with a fixed amount of gas.

For instance, the following call that provides a fixed amount of gas could succeed on Ethereum but fail on Optimism because the target uses slightly more gas than expected:{gas: 5000}("<your input data here>");

You should not be impacted if you do not provide a fixed amount of gas, as Solidity will by default pass all available gas into the function call (opens new window).

You will be able to catch this failure by testing your contracts on Optimism Kovan. We highly recommend testing all contracts on Optimism Kovan before deploying to the Optimism mainnet in order to catch this issue.

# Workarounds

Workarounds usually exist for this issue, but the exact workaround is typically dependent on the specifics of your contract. Please feel free to hop into the #dev-support channel on the Optimism discord (opens new window) for assistance if you run into this issue.

# Resolution

We're planning to deploy a release a fix for this issue in the near future. Please keep an eye on the GitHub issue (opens new window) for additional information and status updates.