62

I'm running a geth node on slow hardware. At the current rate of progress it could be several days before I can download all the blockchain. Is there a way to get it to synchronise more quickly?

5 Answers 5

63

Don't forget to use an SSD

If you're able to, using an NVMe SSD is even better.

If you have limited space on SSD see Can chaindata be split across two (or more) locations?

That said, the Ethereum state is large and getting larger. Be patient and it will be worth it.


Prior answer

Don't forget --cache

Everyone mentions --fast but you probably also need --cache=1024. Without it, you are running with the default which is --cache=128 (Geth 1.6.7).

A 50% speed increase is possible just by increasing the cache.

If you are starting from the beginning, use: geth --fast --cache=1024

If you already have some of the blockchain, use: geth --cache=1024

Depending on your RAM, you can also try with higher values, like --cache=2048.

Source

If you are using the geth client, there are some things you can do to speed up the time it takes to download the Ethereum blockchain. If you choose to use the --fast flag to perform an Ethereum fast sync, you will not retain past transaction data.

Note

You cannot use this flag after performing all or part of a normal sync operation, meaning you should not have any portion of the Ethereum blockchain downloaded before using this command. See this Ethereum Stack.Exchange answer for more information.

Below are some flags to use when you want to sync your client more quickly.

--fast

This flag enables fast syncing through state downloads rather than downloading the full block data. This will also reduce the size of your blockchain dramatically. NOTE: --fast can only be run if you are syncing your blockchain from scratch and only the first time you download the blockchain for security reasons. See this Reddit post for more information.

--cache=1024

Megabytes of memory allocated to internal caching (min 16MB / database forced). Default is 16MB, so increasing this to 256, 512, 1024 (1GB), or 2048 (2GB) depending on how much RAM your computer has should make a difference.

3
  • 4
    Since Geth version 1.6.0, use of --fast flag has become deprecated, you should now use --syncmode=fast Commented Mar 28, 2019 at 22:38
  • @BarneyChambers, blockwala, and others: Thank you. This has also been converted to a wiki to make it easier for anyone to update.
    – eth
    Commented Apr 20, 2019 at 7:02
  • 1
    If anyone is referencing this in the year of the Corona, the default syncmode is now fast, and the default cache value is 1024.
    – Justin
    Commented Sep 29, 2020 at 15:40
18

The --fast command line option will sync more quickly. You have to use it from scratch though, you can't use it if the blockchain has been downloaded already. If you have a node which is already synced then you can use the Javascript interface and the exportChain and importChain commands to sync your node.

6
  • 7
    For --fast it needs to be done before anything has been synced.
    – eth
    Commented Feb 15, 2016 at 9:44
  • 4
    geth removedb can be used to nuke the database. It shouldn't affect the keystore, but make a backup of the data directory first anyway Commented Mar 5, 2016 at 2:43
  • In my case, -fast appears to have no consequences and geth complains: I0508 13:29:49.476026 30960 handler.go:92] blockchain not empty, fast sync disabled
    – bortzmeyer
    Commented May 8, 2016 at 11:32
  • Have you done geth removedb to empty the database? Commented May 9, 2016 at 16:00
  • Is there an official torrent or similar with an updated chain to import speedily?
    – Vesa
    Commented May 29, 2016 at 9:25
11

There are 2 ways using geth, that i am aware of

1. sync with the --fast you can start with geth --fast which Enables fast syncing through state downloads

2. use import command in geth to do this, you need an already synced blockchain from geth and it has to be exported with geth export filename, which can be imported to geth import filename

9

To synchronize geth the fastest way, i recommand to use geth 1.4.6. Older versions are way slower.

Spoiler: HDD synch is very slow.

There are two modes for synchronization:

  • geth --fast --cache 1024 --jitvm: this method is very fast on powerful computer (25min on my system i7 quad core 16Go, SSD and Gbit/s bandwidth). It uses 4.5GB on disk
  • geth --cache 1024 --jitvm: this method is slower (3h on my system i7 quad core 16Go, SSD and Gbit/s bandwidth). It uses 21GB on disk

Tip 1: If you have already a geth synchronized on a computer, you could backup the chaindata directory and copy it for another computer. I check on OS X, Linux and Windows (all in 64bits version).

Tip 2: The export/import method works. The import duration is very long because it checks all transactions.

Tip 3: If you have enough RAM and no SSD, use your RAM as ramdisk and select your ramdisk with the --datadir option. You need 4.2GB for a fast synch. When the synch is completed, copy the directory chaindata on its original place:

  • ~/.ethereum on linux
  • ~/Library/Ethereum on os x
  • %APPDATA%\Ethereum on Windows

I have made many benchmarks on different versions for this question: How much faster is it to sync with --jitvm?

Note 1: if you use a HDD, it seems that the synchronization is slower. The fast method was 4h on my system.

Note 2: RAMDiskCreator on OS X is a freeware to create a RAM Disk.

jitvm and cache options have a minor impact on my bench

2
  • in Geth 1.7.3, --fast is deprecated and --jitvm is removed. Do we need alternative flags?
    – Raptor
    Commented Jan 19, 2018 at 9:17
  • The --fast is replaced by --syncmode fast, so it's not really deprecated to use it, just need to convert it to the new parameter.
    – Matt
    Commented Jun 15, 2019 at 0:37
7

3. sync on a fast machine and copy chaindata directory to your slow machine The chaindata is portable across architectures. So, sync, stop the node cleanly, transfer the chaindata directory (replacing your old one), and start the node on another machine. To minimize risk, use identical versions of geth on both machines. (I did this for x86_64 -> armv7h successfully with Geth 1.4.5, others did too.)

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