Crown v0.13 sync problem

walkjivefly
Apr 15 · 5 min read

A version of this article was first published on 5 April. This version was updated on 1 May, 2019, with details of the latest bootstrap.

Since the release of Crown version 0.13.0.0 (“Jade”) on 28 March, most of the network has upgraded. Some users have experienced problems syncing their wallets and/or nodes.

Symptoms

The wallet or node appears to hang. A resource monitor tends to show low CPU usage and there are long pauses between new messages in the debug.log

What is being done about it?

A patch is under review for inclusion in the next release. In the meantime there are some workarounds, some combination of which have helped all the reported cases so far.

What causes it?

There are 2 known factors:

1. Insufficient memory

This is more likely to be a factor for newly installed nodes on cheap (low resource) VPSes. Some of these have as little as 512MB of available memory and that’s simply not enough for a node to sync reliably. Additionally, some users had not run their wallets in a long time and had quite a lot of catching up to do to get synced. Syncing is a memory intensive process and the more catching up a wallet or node has to do, the more memory it needs.

2. Too many peers

When a wallet or node reaches a certain number of peers it can get overwhelmed and stop syncing. This is currently the main area of development research.

A slight diversion: bootstrap

If you are syncing from scratch, or are a long way behind because you haven’t opened your wallet for many weeks or months, you can consider using a bootstrap. This is generally considered bad practice because it breaks the “verify, don’t trust” crypto mantra. When you use a bootstrap your wallet or node will verify that the blocks follow the consensus rules, but you have to trust that the bootstrap was built by an honest actor from the correct blockchain.

Crown team members built an updated bootstrap on 28 April 2019. It includes blocks as high as 2350100 and is available for download from Nextcloud. If you choose to use it you should:

  • Download the bootstrap.zip file from the given link.
  • CAUTION: if you’re using it on your wallet machine backup your wallet.dat and the backups directory from your datadir. Also backup the masternode.dat and systemnode.dat files if they exist, and the crown.conf file. Just in case.
  • Shutdown the wallet or node.
  • Delete or rename the blocks and chainstate directories from your datadir.
  • unzip the bootstrap.zip into the datadir (it will unzip to bootstrap.dat).
  • Start the wallet or node.
  • When the bootstrap has been processed the file will be renamed to bootstrap.dat.old and the sync will continue by getting newer blocks from the network. Processing the bootstrap typically takes up to about an hour, but could take more or less time. Doing so uses the same amount of memory as pulling the blocks from the network. You may need to address the insufficient memory scenario.

Using a bootstrap on a machine with limited disk space risks running out of storage. Ideally, you would delete the bootstrap.zip and bootstrap.dat.old only after the chain is fully synced but this entails having 3 copies of the blockchain on disk simultaneously. Given one of them is zipped this works out to over 11GB. Deleting the bootstrap.zip after unzipping it will save you almost 2GB.

You can delete the bootstrap.dat.old as soon as the bootstrap.dat is renamed.

What are the workarounds?

1. Insufficient memory

Available memory can be checked in different ways on each platform.

Linux

For linux users the command to use is free. This produces one line of output for each source of available memory, for example:

mark@x230:~$ free
total used free shared buff/cache available
Mem: 16097832 11044316 618580 761824 4434936 3961064
Swap: 16777212 564736 16212476

The “Mem” line refers to physical memory. There will be a “Swap” line for each swap area defined. If the sum of all the free amounts when Crown is not running is less than 1GB then you should define (additional) swap. There are many tutorials on the web which explain in great detail how to do this. At least one community member successfully used this one.

Briefly, assuming you have root access through sudo you can

sudo mkdir -p /var/cache/swap/
sudo dd if=/dev/zero of=/var/cache/swap/myswap bs=1M count=1024
sudo chmod 600 /var/cache/swap/myswap
sudo mkswap /var/cache/swap/myswap
sudo swapon /var/cache/swap/myswap
sudo echo "/var/cache/swap/myswap none swap sw 0 0" >>/etc/fstab

This defines and activates a 1GB swap file and ensures it will still be available after the next reboot.

Windows

On Windows you can use Task Manager to see how much memory is available. Windows generally does automatic swapping and on a reasonably modern machine (say >4GB RAM) shouldn’t require any tweaking. The simplest way to free up memory on Windows is to close unnecessary applications. More than that is beyond the scope of this author.

Mac

On Mac I have no idea at all other than it should be something linux-like.

2. Too many peers

When a syncing wallet or node reaches a certain number of peers it can become overwhelmed and stop processing.

A simple workaround is to stop and restart the wallet or node. It will run for a while and either complete syncing or get stuck again. The workaround can be used as many times as necessary to complete syncing.

A more reliable workaround is to configure the wallet or node to only talk to one or more known synced peers. This can be done using the connect=directive in crown.conf. The procedure is:

  • If you don’t have one yourself you can find suitable peers from the output of
crown-cli masternodelist full 70055
  • Randomly pick 1 or a few nodes which are ENABLED and where the last number on the line is not 0. Make a note of the IP address and port number for each.
  • Stop the wallet or node.
  • Edit the crown.conf. Remove or comment out (by placing a # at the start of the line) any addnode= directives. Add 1 or more lines of
connect=IPaddress:port
  • Save your changes.
  • Start the wallet or node.
  • IMPORTANT: After it completes the sync remove or comment out the connect= directive(s) and restart the wallet or node. If you don’t restart it will forever only talk to the configured nodes, which detracts from the network strength.

Summary

Make sure you have sufficient free memory.

Possibly use the bootstrap.

Use connects instead of addnodes.

Crown Platform

Crown is a digital token and blockchain platform enabling independence serving individuals & businesses. We are focused on legal compliance and transparency utilizing our decentralized governance model.

walkjivefly

Written by

Crown Platform

Crown is a digital token and blockchain platform enabling independence serving individuals & businesses. We are focused on legal compliance and transparency utilizing our decentralized governance model.