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
Xsigns and broadcasts TXAfor a max possible valueY(value + gasPrice * gasLimit) whereY < X. - Before that tx is mined, the user impatiently signs and broadcasts TX
B, with an incremented nonce, for max possible valueZwhereZ < 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
Ais valid, and is mined. - Transaction
Bhas 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 balanceQ > 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
Xfor max possible valueYwhereY > 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.