iov-core
iov-core copied to clipboard
Ethereum: find a way to differentiate between 0 balance and account does not exist
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
.
@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
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.
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.
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