2

According to Etherscan i have 7.5 Ether, but when I execute eth.getBalance(eth.accounts[0]) inside the Javascript console it returns always "0"

this is how I am connecting geth to rinkeby (is running for more than 24 hours)

geth  --rinkeby

this is the status of the sync

λ geth --rinkeby attach ipc:\\.\pipe\geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.9.9-stable-01744997/windows-amd64/go1.13.4
coinbase: 0x7f9153e8fe06c4b3eb10e8457c20d0559921de5c
at block: 0 (Wed, 12 Apr 2017 16:59:06 CEST)
 datadir: C:\Users\andre_000\AppData\Local\Ethereum\rinkeby
 modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.syncing
{
  currentBlock: 5746334,
  highestBlock: 5746402,
  knownStates: 32641057,
  pulledStates: 32636964,
  startingBlock: 5746304
}
> eth.getBalance(eth.accounts[0])
  0
> eth.getBalance(eth.coinbase)
  0
> web3.fromWei(eth.getBalance(eth.coinbase)); 
  0
> eth.getBalance("0x7f9153e8fe06c4b3eb10e8457c20d0559921de5c")
  0
> eth.blockNumber
  0

du -h 30G

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Gelso77
  • 1,763
  • 6
  • 30
  • 47

1 Answers1

0

It sounds like geth is not yet synced up.

Please type this into your geth console:

eth.getBlock("latest").number

As of this post, you should get 5757199 or higher.

"Syncing Ethereum is a pain point", as says Péter Szilágyi (team lead of ethereum).

From https://github.com/ethereum/go-ethereum/issues/16875:

The current default mode of sync for Geth is called fast sync. Instead of starting from the genesis block and reprocessing all the transactions that ever occurred (which could take weeks), fast sync downloads the blocks, and only verifies the associated proof-of-works. Downloading all the blocks is a straightforward and fast procedure and will relatively quickly reassemble the entire chain.

Many people falsely assume that because they have the blocks, they are in sync. Unfortunately this is not the case, since no transaction was executed, so we do not have any account state available (ie. balances, nonces, smart contract code and data). These need to be downloaded separately and cross checked with the latest blocks. This phase is called the state trie download and it actually runs concurrently with the block downloads; alas it take a lot longer nowadays than downloading the blocks.

So, what's the state trie? In the Ethereum mainnet, there are a ton of accounts already, which track the balance, nonce, etc of each user/contract. The accounts themselves are however insufficient to run a node, they need to be cryptographically linked to each block so that nodes can actually verify that the account's are not tampered with. This cryptographic linking is done by creating a tree data structure above the accounts, each level aggregating the layer below it into an ever smaller layer, until you reach the single root. This gigantic data structure containing all the accounts and the intermediate cryptographic proofs is called the state trie.

Ok, so why does this pose a problem? This trie data structure is an intricate interlink of hundreds of millions of tiny cryptographic proofs (trie nodes). To truly have a synchronized node, you need to download all the account data, as well as all the tiny cryptographic proofs to verify that noone in the network is trying to cheat you. This itself is already a crazy number of data items. The part where it gets even messier is that this data is constantly morphing: at every block (15s), about 1000 nodes are deleted from this trie and about 2000 new ones are added. This means your node needs to synchronize a dataset that is changing 200 times per second. The worst part is that while you are synchronizing, the network is moving forward, and state that you begun to download might disappear while you're downloading, so your node needs to constantly follow the network while trying to gather all the recent data. But until you actually do gather all the data, your local node is not usable since it cannot cryptographically prove anything about any accounts.

If you see that you are 64 blocks behind mainnet, you aren't yet synchronized, not even close. You are just done with the block download phase and still running the state downloads. You can see this yourself via the seemingly endless Imported state entries [...] stream of logs. You'll need to wait that out too before your node comes truly online.

Diego B
  • 1,256
  • 11
  • 19
  • Hi Diego, thank you so much but after 40 hours the node seems not synced yet and the command that you reccomend returns '0' any idea? – Gelso77 Jan 08 '20 at 19:00
  • Running the command du -h on the rinkeby folder, it says 30G – Gelso77 Jan 08 '20 at 19:04
  • Yess..."Syncing Ethereum is a pain point", as says Péter Szilágyi (lead of ethereum). I updated my answer with a Peter's post in https://github.com/ethereum/go-ethereum/issues/16875 "If you see that you are 64 blocks behind mainnet, you aren't yet synchronized, not even close. You are just done with the block download phase and still running the state downloads. You can see this yourself via the seemingly endless Imported state entries [...] stream of logs. You'll need to wait that out too before your node comes truly online." – Diego B Jan 08 '20 at 19:16
  • 1
    Try with geth --rinkeby --fast – Diego B Jan 08 '20 at 19:18
  • Ok I will let you know soon! – Gelso77 Jan 08 '20 at 19:31
  • after 8 hours, using the command --fast the balance is 0 and eth.getBlock("latest").number is 0 – Gelso77 Jan 09 '20 at 07:10