bnb-chain / bsc

A BNB Smart Chain client based on the go-ethereum fork
GNU Lesser General Public License v3.0
2.73k stars 1.56k forks source link

Tips for sync mode of full nodes #1193

Closed yutianwu closed 11 months ago

yutianwu commented 1 year ago

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:

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

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

DaveWK commented 1 year ago

When extracting, lz4c is faster: https://github.com/pierrec/lz4 dnf install -y golang-github-pierrec-lz4

zzzckck commented 11 months ago

close it, no need to keep Open state