optimism icon indicating copy to clipboard operation
optimism copied to clipboard

sender address missing in sdk for deposit and withdrawal gas estimation

Open bb111189 opened this issue 1 year ago • 6 comments

Describe the bug A clear and concise description of what the bug is. https://github.com/ethereum-optimism/optimism/blob/034a993e4e3662a8a7625f0492fcf0b7b21d68e8/packages/sdk/src/cross-chain-messenger.ts#L2042 Gas estimation for deposit and withdrawal of ETH and ERC20 do not consider the sender's address. It uses default which is 0x0, which can cause wrong estimation or error.

In the case for OP Sepolia 0x0 address only has 1 wei. Hence, when trying to deposit any amount bigger than 1 wei from any EOA, gas estimation will fail with the following error insufficient funds for gas * price + value: address 0x0000000000000000000000000000000000000000 have 1 want 10000000000000000 (supplied gas 30000000

This is because gas estimation is trying to compute the gas cost of transferring 1 wei from 0x0 to recipient instead of the actual sender to recipient.

For deposit and withdrawal of ETH or ERC20, sender address should be used in the gas estimate.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'

  2. Click on '....'

  3. Scroll down to '....'

  4. See error

  5. Setup a OP Stack (L3) on top of OP Sepolia

  6. Try bridging operation using the sdk

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

System Specs:

  • OS:
  • Package Version (or commit hash): OP SDK version 3.1.2

Additional context Add any other context about the problem here.

bb111189 avatar Jan 11 '24 07:01 bb111189

You should consider migrating to viem as the sdk is going to be phased out eventually. viem natively supports op stack chains

tynes avatar Jan 12 '24 16:01 tynes

You should consider migrating to viem as the sdk is going to be phased out eventually. viem natively supports op stack chains

Do you have a rough timeline on when the SDK will be phased out?

bb111189 avatar Jan 16 '24 04:01 bb111189

@bb111189 no rough timeline at the moment. Which function are you using that triggers the issue?

smartcontracts avatar Feb 05 '24 00:02 smartcontracts

@bb111189 no rough timeline at the moment. Which function are you using that triggers the issue?

I'm having this issue when calling await crossChainMessenger.estimateGas.withdrawETH(amount) with any amount larger than 1

gndelia avatar Mar 09 '24 20:03 gndelia

if I forcefully override the from address like this

await crossChainMessenger.estimateGas.withdrawETH(amount, { overrides: { from: address } })

it works. However, this is not needed for DepositETH for example, so it is a bit inconsistent

gndelia avatar Mar 09 '24 21:03 gndelia

if I forcefully override the from address like this

await crossChainMessenger.estimateGas.withdrawETH(amount, { overrides: { from: address } })

it works. However, this is not needed for DepositETH for example, so it is a bit inconsistent

I have the same problem. If I override the from address it works, otherwise it returns a insufficient funds error

alessandromazza98 avatar May 07 '24 12:05 alessandromazza98

the sdk has been deprecated

tynes avatar Jun 17 '24 22:06 tynes