bnb-chain / opbnb-node-docker

36 stars 25 forks source link

Op-Geth syncs extremly slow #5

Closed drbenshiller closed 11 months ago

drbenshiller commented 1 year ago

I am trying to sync an openbnb mainnet node. However the logs of op-geth seem to indicate that it is importing blocks very slowly. After 12 hours it is still at block 97000. Peercount seems to fluctuate between 0 and 1. At this rate it will never finish.

I had to use non-custom ports, however those are open according to the firewall rules. Is there any way to speed up syncing, by e.g. increasing peer counts or using a public snapshot ?

The .env file is

###############################################################################
#                                ↓ REQUIRED ↓                                 #
###############################################################################

# L1 node that the op-node will get chain data from
OP_NODE__RPC_ENDPOINT=https://bsc-dataseed1.binance.org/

# replace the p2p private key with yours
# you can generate a new one with `openssl rand -hex 32`
P2P_PRIV_KEY=...

# you can find the correct image tag for the network at https://github.com/bnb-chain/op-geth (for the mainnet, it should be 0.1.2 currently)
OP_GETH_IMAGE_TAG=0.1.2
# you can find the correct image tag for the network at https://github.com/bnb-chain/opbnb (for the mainnet, it should be 0.1.2 currently)
OP_NODE_IMAGE_TAG=0.1.2

###############################################################################
#                                ↓ OPTIONAL ↓                                 #
###############################################################################
PORT__OP_GETH=9545
PORT__OP_NODE=9546
PORT__OP_NODE_P2P=9547

###############################################################################
#                                ↓ DON'T REMOVE ↓                             #
###############################################################################
# Network to run the node on ("testnet" or "mainnet")
NETWORK_NAME=mainnet
owen-reorg commented 11 months ago

There is a public snapshot available that can speed up the process. You can find it at https://github.com/bnb-chain/opbnb-snapshot.

Another option is to enable engine sync. You can find instructions on how to do this at https://docs.bnbchain.org/opbnb-docs/docs/build-on-opbnb/geth-sync.

Before the introduction of the engine sync feature, the sync process was expected to be slow because it scanned all the historical L1 data from the L2 start. Using a public L1 endpoint made it even slower. To improve the speed, you can try the following:

  1. Use a faster and more stable 3rd party service like meganode.
  2. Enable the bsc_fullnode feature. More details can be found in this PR.