4

I've just imported two private keys with both, geth and the zcash-cli. While the zcash-cli (a public t.* address) took more than 15 minutes* (I guess it scanned the whole blockchain), geth was finished importing almost instantly.

My question is: What goes on under the hood? Why is geth so much faster?

This answer suggests that other nodes in the network are queried for the balance?

Thanks!

*I left the computer to be honest, so this is only a rough estimate.

5

I guess the speed comparison is against importing a Bitcoin private key. If so, the cause of the difference is due to

  • Bitcoin is based on unspent transaction outputs (UTXO). Each bitcoin transaction consumes previous UTXOs and outputs new ones. The "balance" is essentially a derived concept, based on the sum of a wallet's UTXOs. As it's not "native", the sum has to be calculated by traversing all the way down from the genesis block, due to the fact that there could be an old old UTXO that pays into the imported private key. The chain-traversal can only be optimised if the private key's creation time is known (so the UTXOs before that can be skipped). The traversal takes time, thus the slowness.
  • In comparison, "balance" is relatively more "native" to Ethereum. Ethereum transactions is about accounts' state transition. "Balance" is part of an account's state (e.g. a transaction is moving balance between accounts). Thus, as Hari's answer above, an in-sync node always knows every "state", thus every account's balance.

See also: What are the pros and cons of Ethereum balances vs. UTXOs?

|improve this answer|||||
1

If geth was synced, it already had the balance (and every balance in the network)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.