Tips for sync mode of full nodes

There are some flags that need to be set about sync mode when running a full node, and there are multiple options for each flag, so it is confusing sometimes.

Let’s sort it out here and give some recommendations.


Sync Mode

There are two sync modes for running a full node: snap and full which can be specified by flag --syncmode .

The snap sync mode is used for initial sync, which will download the latest states rather than apply the blocks from the genesis. When the initial sync is done, it will switch to full sync automatically.

The full sync mode can also be used to do initial sync, which will apply all the blocks since genesis.

Since the amount of historical data is too large, the initial sync is not recommended for running a full node. Instead, you can download a snapshot from the official repo and start from the snapshot.

Fast Node

To improve the performance further, there is also a fast node introduced by the flag --tries-verify-mode .

There are four options for this flag:

  • local: a normal full node with complete state world(both MPT and snapshot), the merkle state root will be verified against the block header, it is the default option.
  • full: a fast node with only a snapshot state world. Merkle state root is verified by the trustworthy remote verify node by comparing the diff hash(an identity of the diff layer generated by the block) and state root.
  • insecure: same as full mode, except that it can tolerate without verifying the diff hash when verify node does not have it.
  • none: no merkle state root verification at all, there is no need to set up or connect a remote verify node at all, it is lighter compared to full and insecure mode, but get a very little chance that the state is not consistent with other peers.

For regular users, the none option is recommended and it improved a lot of performance.

For details, you can refer to the doc: https://docs.bnbchain.org/docs/BSC-separate-node.

Gc Mode

There are two types of gc mode: full and archive which can be specified by flag --gcmode.

The archive mode will hold onto the states generated when applying blocks. It will cost a lot of space and require higher specs for machines to run an archive node and sometimes unaffordable for regular users.

The full mode will not hold onto the states generated when applying blocks and it is enabled by default. It’s recommended for regular users who want to run a full node.

Diff Sync

Diff sync allows BSC client simply apply the execution result of a block securely without executing the transactions. It can be enabled by flag --diffsync. According to test, fastnode get better performance than diffsync, so diffsync is deprecated.

Recommendations

Download snapshot

It’s recommended for all users who want to run a full node to download a snapshot from the official repo first instead of syncing from the genesis.

You can refer to the doc: https://docs.bnbchain.org/docs/validator/fullnode

Sync mode of full nodes

For users who have better machines to run a full node, it’s recommended to run a full node with full sync mode .

The start command should be like:

./geth --config ./config.toml --datadir ./node --syncmode full --cache 5000 .

Otherwise, if you want better performance, you can start a fast node:

./geth --config ./config.toml --datadir ./node --syncmode full --cache 5000 --tries-verify-mode none