42

Have a Geth 1.5.5 node running on a raspberry pi 3. When I type in

sudo systemctl status geth

I'll get ever changing time and block information. Neat, but how do I know when I am synced up? Is there another sudo command I should do?

6 Answers 6

59

Continuing to research, need to enter the geth node console to enter special commands. The following works:

geth attach

Sends user to the geth node console.

eth.syncing

Produces a result like current block: 82,100; highest block 2,910,032.

exit

To go back to Pi prompt.

7
  • 9
    when I am typing eth.syncing just getting false printed Commented Jun 24, 2017 at 3:45
  • 1
    @Coren you can wait forever Commented Sep 14, 2017 at 16:21
  • 2
    geth syntax for windows: geth attach ipc:\\.\pipe\geth.ipc Commented Jun 30, 2018 at 16:06
  • 3
    @sreginogemoh false means you are fully synced already (technically just means that it is not syncing actually so I suppose maybe it could also mean you aren't syncing for some reason other than being fully sync'd ... hmmmm) Commented Dec 4, 2020 at 3:47
  • 1
    @sreginogemoh false is good. It means you are up to date with the latest block and fully synched. It's stupidly counterintuitive as a user message but literally true: You are not syncing, you are synched.
    – brianfit
    Commented Feb 22, 2021 at 10:12
49

After running your normal geth --fast command you can open a new window and run the "geth attach" command as this will attach you to the javascript interface

$ geth attach

Then you can use this script to have a nice output of what is happening. It is very rudimentary but works really well to give you an idea of how long you will still need to wait. First wait 10 seconds (as the first ETA is incorrect) then after the second display of estimates you will start to see the actual numbers.

var lastPercentage = 0;var lastBlocksToGo = 0;var timeInterval = 10000;
setInterval(function(){
    var percentage = eth.syncing.currentBlock/eth.syncing.highestBlock*100;
    var percentagePerTime = percentage - lastPercentage;
    var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
    var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
    var etas = 100 / percentagePerTime * (timeInterval / 1000)

    var etaM = parseInt(etas/60,10);
    console.log(parseInt(percentage,10)+'% ETA: '+etaM+' minutes @ '+bps+'bps');

    lastPercentage = percentage;lastBlocksToGo = blocksToGo;
},timeInterval);

This will give you an output similar to this:

85% ETA: 573 minutes @ 134.4bps
86% ETA: 533 minutes @ 144.3bps
86% ETA: 442 minutes @ 173.9bps
6
  • 2
    Hello, this helps me a lot to see the ETAs being continuously printed in the terminal. I would choose this as the answer if I were to ask the question.
    – Arefe
    Commented Dec 20, 2017 at 2:19
  • 3
    Or like this: 99% ETA: 399672 minutes @ 0.2bps 99% ETA: 399672 minutes @ 0.2bps 99% ETA: 399672 minutes @ 0.2bps 99% ETA: 399672 minutes @ 0.2bps 99% ETA: 399672 minutes @ 0.2bps Ethereum is dead to me.
    – Dagelf
    Commented Dec 25, 2017 at 18:58
  • 2
    @Dagelf you're probably "stuck" on state trie syncing. read more about in this issue github.com/ethereum/go-ethereum/issues/… (find comments by maintainer karalabe) Commented Jun 30, 2018 at 16:43
  • This works well, but I've noticed that block sync times vary a lot. I've synced multiple times in parity and while for a long time block times were at around 1-2blocks per second for multiple hours (ETA of 100 days), but then it finished over night anyways
    – phiresky
    Commented Feb 23, 2020 at 21:14
  • its gives me an empty set {}
    – alper
    Commented Nov 30, 2020 at 12:47
4

Firstly you will need to connect to the running geth process from a second terminal

$ geth attach

As the other answers have stated the structure you are interested is eth.syncing

To see the remaining blocks you could do

> eth.syncing.highestBlock - eth.syncing.currentBlock

And for the remaining states

> eth.syncing.knownStates - eth.syncing.pulledStates
3

While running geth sync process, I used geth attach and then used eth.syncing on geth console.

eth.syncing on "geth attach" console.

I could get block info. And if you're just after running geth command itself, you need to wait until geth starts "real" syncing process. Otherwise you'll see false.

geth version result

Geth
Version: 1.7.2-stable
Git Commit: 1db4ecdc0b9e828ff65777fb466fc7c1d04e0de9
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.1
Operating System: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.9.1/libexec
0

You can use web3.eth.syncing, i.e.:

server:~# geth attach
> web3.eth.syncing
{
  currentBlock: 4504031,
  highestBlock: 4660759,
  knownStates: 31357681,
  pulledStates: 31357680,
  startingBlock: 4504031
}

Or the same as above but async using getSyncing:

web3.eth.getSyncing(callback(error, result){ ... })
-1

Eth syncing percent:

eth.syncing.currentBlock * 100 / eth.syncing.highestBlock
1
  • 2
    That formula works when you are syncing in full mode. In fast mode a large part is downloading states and the formula doesn't take that into account.
    – Ismael
    Commented Jul 7, 2019 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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