The public testnet Ropsten with networkid 3 is useful in contract development. Geth is one of the Ethereum client useful for connecting to testnets. This document deals with the tips on how to sync your client with Testnet more quickly.
Below are the steps for setting up Ropsten with Geth version 1.6.5
Download the genesis file for ROPSTEN-Revival.
Here’s a snippet of Geth’s Ropsten genesis file :-
Then initialize a new genesis block and definition for the ROPSTEN network using the following command:
geth --datadir /path/to/testnet/data init genesis.json
The next step is blocks downloading. We can sync to Blockchain via two modes:
- Normal Syncing
- Fast Syncing (using
From the Homestad Guide: The fast 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.
Another flag that can be used along with
--fast to sync your client more quickly is
--cache. The Cache flag can be used to change the default alloted memory for a fast sync.
From the Homestad Guide:
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.
Command for syncing :-
geth --datadir /path/to/testnet/data --networkid=3 –-syncmode=fast –-cache=1024 console
Points to be noted:-
1) If you try to verify the number of blocks downloaded through the console using the command
eth.blockNumber, ‘Loaded most recent local full block’ will always show ‘0’ , which doesn’t mean that your blocks are not being downloaded. It will only show the correct blocks once all the blocks are downloaded.
[06-15|15:54:56] Loaded most recent local header
number=1121759 hash=bdf4d6…ebcdec td=747686182747507INFO
[06-15|15:54:56] Loaded most recent local full block number=0
hash=419410…ca4a2d td=1048576INFO [06-15|15:54:56] Loaded most
recent local fast block number=1121676 hash=80f4d5…3ed841
After the completion of block synchronization you can find the difference.
INFO [06–16|11:00:58] Loaded most recent local header number=1126948 hash=4ae28e…360ad2 td=750432339366550INFO [06–16|11:00:58] Loaded most recent local full block number=1126948 hash=4ae28e…360ad2 td=750432339366550INFO [06–16|11:00:58] Loaded most recent local fast block number=1126948 hash=4ae28e…360ad2 td=750432339366550WARN [06–16|11:00:58] Blockchain not empty, fast sync disabled
Here, you can note the ‘Loaded most recent local full block’ has changed from ‘0’ to the latest block number and also we get one more message regarding fast sync being disabled.
To get the latest block number go for the command