Skip to content

Instantly share code, notes, and snippets.

@danfinlay
Last active October 5, 2017 20:26
Show Gist options
  • Select an option

  • Save danfinlay/d24557fb9c41808135f3d0ab13992f61 to your computer and use it in GitHub Desktop.

Select an option

Save danfinlay/d24557fb9c41808135f3d0ab13992f61 to your computer and use it in GitHub Desktop.
Insufficient Balance on-chain error EIP

Currently, a signed transaction that sends more ether than an account has is considered an invalid transaction, and is not mined.

This can cause a dangerous situation where a user sends funds they didn't mean to, and can be completely avoided by allowing miners to process "insufficient balance" as an on-chain error.

Reproduction steps:

  • A user with balance X signs and broadcasts TX A for a max possible value Y (value + gasPrice * gasLimit) where Y < X.
  • Before that tx is mined, the user impatiently signs and broadcasts TX B, with an incremented nonce, for max possible value Z where Z < X && Z + Y > X.
  • Because each of these transactions are less than the user's current balance, they are both added to miner mempools.
  • Transaction A is valid, and is mined.
  • Transaction B has undefined behavior. Some nodes may forget it, but it may be passed among peers and remembered at any time.
  • The user forgets about the whole thing, doesn't think about the 2nd "retry" transaction.
  • The user sends ether to account X, funding its balance so that its new balance Q > Z.
  • A miner processes transaction B.
  • The user is shocked to find their ether was "spontaneously" sent away.

Fix idea:

  • If a miner receives a Transaction from an account with balance X for max possible value Y where Y > X, miners should be able to process that transaction on-chain, spending its gas, to prevent the transaction from being accidentally valid in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment