Skip to content

Gas limit set too high when dapp specifies a gasPrice on a transaction, and user has insufficient funds #9967

@Gudahtt

Description

@Gudahtt

Describe the bug
When a dapp sends a transaction, and specifies the gasPrice but not the gas, we will sometimes set the gas property to the block gas limit internally. I believe this happens when the total cost of the transaction (considering the cost of gas as well, using the estimated gas usage and the suggested gas price) exceeds the users current balance.

This inflated gas limit is then shown on the transaction confirmation screen. The block gas limit is much higher than most transactions require, so this results in transaction confirmations with huge gas costs.

This is caused by our use of eth_estimateGas, which fails if a gasPrice is given and the transaction exceeds the user's current balance.

Steps to reproduce (REQUIRED)

  1. Switch to an account with no balance
  2. Navigate to a dapp and connect the empty account
  3. Open Dev Tools, and run this in the dev console:
await window.ethereum.request({ method: 'eth_sendTransaction', params: [{ from: window.ethereum.selectedAddress, gasPrice: '0x1000' }] })
  1. See that the gas limit on the confirmation screen is very high

Expected behavior
The suggested gas price should not affect the suggested gas limit. We should estimate the gas usage irrespective of the gas price suggested. If the user has insufficient funds, we have a warning message for that already on the confirmation screen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sev2-normalNormal severity; minor loss of service or inconvenience.type-bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions