BNB Chain Erigon full node snapshot available for download

Trading Strategy hosts a BNB Chain snapshot for those who are looking to sync new BNB Chain full nodes. Using the snapshot will sync your node in a few hours instead of weeks.

What is a chain snapshot?

A chain snapshot is a file system dump of the chain data files. By downloading these files, you can bring your blockchain

The snapshot may be

Different snapshots offer different security guarantees. For example, when downloading a snapshot from a Polygon manually hosted snapshot repository, you trust that the admins of this repository have not modified the current historical blockchain state. The built-in Ethereum Snapshot Protocol verifies from the peer-to-peer network that the snap state is correct.

What is BNB  Chain?

BNB Chain is an EVM-Compatible blockchain from the Binance cryptocurrency exchange.

BNB Chain is a direct fork of Ethereum.

BNB Chain offers good interaction with the Binance cryptocurrency exchange (CEX), making it attractive for the users of this exchange. As of the writing of this, Binance has a 70% market share of the cryptocurrency trading volume, making it very dominant in the blockchain industry.

What is Erigon?

Erigon is an implementation of Ethereum written in Go, designed to run archive nodes that manage large amounts of on-chain data. It is a decentralized blockchain node provider that provides a secure, private, and scalable blockchain infrastructure. If you want to host your own JSON-RPC API access to raw EVM blockchain data, Erigon is a good option.

Erigon is one of the two most popular Ethereum clients, alongside GoEthereum. The benefits of Erigon over GoEthereum include better disk space usage and performance due to more advanced database structures. Internally Erigon uses Lightning Memory-Mapped Database Manager (LMDB).

Erigon supports some alternative blockchains to Ethereum mainnet,
like Polygon and BNB Chain. Erigon is not available for all EVM-compatible networks, as the project was started many years after GoEthereum, which had become the de facto standard EVM implementation at that point.

When self-hosting a blockchain node is a good option

If you are in a blockchain or cryptocurrency business, you likely want to host your node instead of using any of the centralised software-as-a-service alternatives.

  • You make so many JSON-API requests a month that commercial API services, limited by request count and request throttling, become painful to use.
  • You want to ensure the minimum latency and maximum uptime for your blockchain data feeds, making your server-side applications faster,
  • You understand that hosting your own blockchain nodes is the ethos of the decentralisation movement.
  • You are enthusiastic, or a professional who needs higher quality service and customisations than free or software-as-a-service offerings can give.
  • You are a heavy user of a blockchain service, and you do not want to be tracked and have your private information leaked.
  • You want to stake with your validator node and earn by providing security for the network.

The issues with long blockchain sync durations

Currently, none of the Ethereum and EVM implementations is well-optimised for syncing. Erigon is no different. Its internal fast sync can take you only so far. The BNB Chain sync took more than three weeks for us for the beefiest available AMD Ryzen dedicated server.

Three weeks is too long a time to wait for any normal day-to-day work scenarios and is becoming the bottleneck for decentralisation. Fewer people will run their own nodes because of too long sync times and too high hardware requirements. Unless sync time problems are fixed long-term, this will eventually lead to blockchains that are too difficult to verify from scratch, undermining the value promise where any third party could verify the correctness of blockchain transactions.

The current snapshot contents

To make the work easier for the next project to sync its own BNB Chain, Trading Strategy is hosting a dump of files for the BNB Chain Erigon synced up to block 25M.

The snapshot provided by Trading Strategy is designed for the use case where

  • You want to get BNB Chain Erigon full node up faster than three weeks
  • You trust Trading Strategy not to manipulate the data

The data contains "full node" of BNB Chain with transaction receipts and event logs. This equals to Erigon --prune hc` flags and GoEthereum --txlookuplimit 0 flags. You can query the result of any past transaction from Erigon node bootstrapped with this snapshot. This is not an archive node, with past states, as this would be several more terabytes of storage.

The Docker command used to run Erigon that was used to generate snapshot is:

 erigon ${ERIGON_FLAGS-}
      --private.api.addr=0.0.0.0:9090
      --sentry.api.addr=sentry:9091
      --downloader.api.addr=downloader:9093
      --txpool.disable
      --networkid 56
      --nat any
      --chain=bsc
      --metrics
      --metrics.addr=0.0.0.0
      --metrics.port=6060
      --pprof
      --pprof.addr=0.0.0.0
      --pprof.port=6061
      --authrpc.jwtsecret=/home/erigon/.local/share/erigon/jwt.hex
      --datadir=/home/erigon/.local/share/erigon
      --prune hc

Note that you cannot change Erigon operation mode (full node/archive node) after running the Erigon first time and it having create its databases for you.

In the archive, you can get the Erigon backup folders:

chaindata
bor
nodes
parlia
snapshots

If you want to create your own snapshots, you can find the snapshot scripts in our Github repository.

Using zstd compression for the archive

Zstd is a modern compression algorithm developed by Facebook. It tries
to strike a good balance with speed/compression ratio for modern multithreaded
CPUs.

Blockchain data does not compress well because it is mostly random data like transaction hashes and public keys. Still, there is some room for compression in internal database structures.

With the Zstd compression level eight, we get:

  • Uncompressed snapshot: 4.0 Terabytes
  • Compressed snapshot: 1.2 Terabytes

The 3x level of compression indicates that it might be beneficial to run Erigon on a ZFS file system with built-in Zstd compression to deal with issues of high storage consumption.

Compressing took one and a half hours:

real	89m36.215s
user	1713m9.011s
sys	109m19.815s

Hosting snapshots with Storj

Trading Strategy hosts its chain snapshots on Storj.

Storj is a decentralized cloud storage platform that allows server maintainers to rent out unused hard drive space for digital file storage. It offers zero-trust security and can be used for large file storage, streaming and backups. Storj runs on its own blockchain model, but for the interaction, the user does not need to know about the blockchain at all.

Due to its decentralised mode, Storj storage and egress costs are very competitive compared to centralised cloud offerings such as from Amazon, Microsoft or Google. Especially Storj's pricing for egress traffic is competitive (outbound traffic when others download the snapshot, as the hoster is paying for these.)

You can find our Storj upload scripts here.

How to download and install the BNB Chain snapshot

Storj allows both decentralised and normal link sharing to objects hosted on its storage network. In the case of link sharing, the file is downloaded through one of Storj Edge Gateway servers that are Amazon S3 compatible.

To use Trading Strategy's BNB Chain snapshot.

  1. First, make sure you have at least 8 TB of free NVMe SSD disk space
  2. Install Erigon - e.g. using the premade Docker compose
  3. Install uplink - the command line utility to interact with Storj
  4. Start Erigon to see if it launches correctly and generates its data directory structure
  5. Stop it
  6. Download the snapshot files
  7. Extract the snapshot files to the Erigon data folder
  8. Start Erigon again

Download Trading Strategy's BNB Chain snapshot using Storj's uplink command. First, you need to import the Storj access grant to the bucket sj://bnb-chain-snapshot:

# Get the token that allows you to download the snapshot 
# file from Storj network bucket sj://
uplink access import main 13WaHCYWBYpv6V32UzNDY1goSZCG51RWXfqL6rmurFomX38HDqCVhW83SRRsz7rSBUGze2CCkLfqH5TqUx5sAVCruJYHnEpWz9owPngEmX3qtqGPFcEr9oWiaoR2aebTAepgbdkMjqr9XqGmoKKqVwARJLzfea444hh3hdX3FYSjD7dxcpbgT2gMXhjqiz4PPfbyAVg3nqRhj54tqxmb3ZE4HDCGbBPrRXNfTcxfG7PKek2uPGb91Ed9jxDGiuYavxhN4isGSoMwvTTd6usLZKG2yn68K2PuxdHiFG6MCaL4Uh5xW1gaDSsMkJ3uYFF1eyucWwtcaaXuYNoTNB9bSMh4iaMfvKbor8jAkQXHdZ7kdckBh4XJL73kr54wFM

# View the bucket
uplink ls sj://bnb-chain-snapshot

This will display the available snapshots to download

KIND    CREATED                SIZE             KEY
OBJ     2023-02-20 11:13:36    1314022822416    bnb-chain-snapshot-2023-23.tar.zst

And then, you can copy it locally using uplink's decentralised download. At OVH's server, we are getting 80 MBytes/sec download, likely the saturated bandwidth we have available for the server. The --parallelism 16 option downloads the content from multiple Storj servers at the same time.

uplink cp --parallelism 16 sj://bnb-chain-snapshot/bnb-chain-snapshot-2023-23.tar.zst .

You can also download the BNB Chain snapshot with the following curl example command. Note that this will be much slower than the method above:

curl https://link.storjshare.io/s/juoqe2lpgkd7as6xm75uuo5ea7lq/bnb-chain-snapshot/bnb-chain-snapshot-2023-23.tar.zst --output /bsc/snapshot.tar.zst 

Then to extract the snapshot  (change directories to match your own file system layout):

# Make sure your Linux has zstd command installed
sudo apt install zstd  

# Enter the Erigon's data folder
cd /bsc/data/bsc-erigon/

# Exract the snapshot archive
tar --use-compress-program=unzstd -xvf /bsc/snapshot.tar.zst

Further discussion

If you need help downloading or using the snapshot, please join the Trading Strategy community Discord to ask any questions.

TradingStrategy.ai operated by Trading Strategy Operations Ltd., Victoria, Mahe, Seychelles.