iov-core icon indicating copy to clipboard operation
iov-core copied to clipboard

Ethereum: find a way to differentiate between 0 balance and account does not exist

Open webmaster128 opened this issue 6 years ago • 4 comments

eth_getBalance gives us 0x0 for existing and non-existing accounts. We should be able to differentate this somehow to properly represent as BcpAccount | undefined.

webmaster128 avatar Jan 10 '19 16:01 webmaster128

@LucasIsasmendi @ethanfrey do you think it is practically possible to clear a once used Ethereum account to 0 wei? With the gas system, some wei should always be left in an account, right? This would allow a very simple and fast implementation: balance 0 -> account never used

webmaster128 avatar Feb 23 '19 20:02 webmaster128

If you are smart, you can make it 0. Especially if such "smart" usage can trigger un-tested edge case -> possible exploit.

I mean, sending wei to another account has a known gas cost (42k I believe). Offer a high gas Price (eg. 10Gwei) and then deduct the predicatible fee from total balance and send it to a second account you control.

I mean, if you use the current gas calculation in iov-wallet, it is not practical, but most more advanced gas handling solutions would let you do this quite easily.

ethanfrey avatar Feb 25 '19 11:02 ethanfrey

https://github.com/iov-one/iov-core/pull/774 now moves the workaround from the wallet into IOV-Core.

I'll let this ticket open since I'm not convinced what the final answer will be. Scanning for transactions is a very expensive operation (extra request and parsing) and adds the dependency on a scraper to a simple operation like get balance.

webmaster128 avatar Feb 25 '19 16:02 webmaster128

I'll let this ticket open since I'm not convinced what the final answer will be. Scanning for transactions is a very expensive operation (extra request and parsing) and adds the dependency on a scraper to a simple operation like get balance.

Fair enough, very hard to do correctly. I'm happy with a simple solution for now, leaving the open issue for the correct solution

ethanfrey avatar Feb 25 '19 17:02 ethanfrey