Full Node
1.About¶
Full node stores the full world state on disk and is capable of:
- handle new transactions and produce new blocks, can be used as a validator node.
- execute and validate newly received blocks.
- verify the states of every account, as it has the full world state.
Currently, there are 3 different clients to run a BSC full:
- Geth: https://github.com/bnb-chain/bsc
- Reth: https://github.com/bnb-chain/reth
- Erigon: https://github.com/node-real/bsc-erigon
Only Geth and Reth will be covered in this page, as Erigon is mainly to support archive mode, pls refer archive_node.md for its usage.
Tip
If you want high performance and care little about state consistency, you can run a fast node, which is a full node with the flag --tries-verify-mode none
set.
Check here for full details on running a fast node.
./geth --config ./config.toml --datadir <datadir> --cache 8000 --tries-verify-mode none
2.Run BSC Full Node: Geth¶
2.1.Supported Platforms¶
We support running a full node on Mac OS X, Linux, and Windows.
2.2.Steps¶
There are 2 approaches to setup a BSC full node from scratch:
-
By Snapshot(Recommend): download the latest snapshot and sync based on it.
-
From Genesis(Not Recommend): sync the whole BSC chain from genesis block.
Tip
As of Nov-2024, the latest block height of BSC mainnet is over 40M, it would need a more powerful hardware and take a great of time to sync from genesis, so it is suggested to setup a BSC full node based the snapshot.
a.By Snapshot¶
-
Download the pre-build binaries from the release page or follow the instructions below
# Linux wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep geth_linux |cut -d\" -f4) mv geth_linux geth chmod -v u+x geth # MacOS wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep geth_mac |cut -d\" -f4) mv geth_mac geth chmod -v u+x geth
-
Download the config files
Download genesis.json and config.toml by:
# mainnet wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4) unzip mainnet.zip # testnet wget $(curl -s https://api.github.com/repos/bnb-chain/bsc/releases/latest |grep browser_ |grep testnet |cut -d\" -f4) unzip testnet.zip
-
Download snapshot Download latest chaindata snapshot from here. Follow the guide to structure your files.
-
Start a full node
## pls replace <datadir> with your local path to datadir. ./geth --config ./config.toml --datadir <datadir> --cache 8000
-
Monitor node status
You can monitor the log from ./<datadir>/bsc.log by default. When your node has started syncing, you should be able to see the following output:
t=2022-09-08T13:00:27+0000 lvl=info msg="Imported new chain segment" blocks=1 txs=177 mgas=17.317 elapsed=31.131ms mgasps=556.259 number=21,153,429 hash=0x42e6b54ba7106387f0650defc62c9ace3160b427702dab7bd1c5abb83a32d8db dirty="0.00 B" t=2022-09-08T13:00:29+0000 lvl=info msg="Imported new chain segment" blocks=1 txs=251 mgas=39.638 elapsed=68.827ms mgasps=575.900 number=21,153,430 hash=0xa3397b273b31b013e43487689782f20c03f47525b4cd4107c1715af45a88796e dirty="0.00 B" t=2022-09-08T13:00:33+0000 lvl=info msg="Imported new chain segment" blocks=1 txs=197 mgas=19.364 elapsed=34.663ms mgasps=558.632 number=21,153,431 hash=0x0c7872b698f28cb5c36a8a3e1e315b1d31bda6109b15467a9735a12380e2ad14 dirty="0.00 B"
b.From Genesis¶
## start a full node from genesis with by one command
## pls replace <datadir> with your local path to datadir.
./geth --config ./config.toml --datadir <datadir> --cache 8000
2.3.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 execute 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 execute all the blocks since genesis. But it is not recommended, since the amount of historical data is too large. Instead, you can download a snapshot from the official repo and start full sync from the snapshot.
If the flag –syncmode is not provided, the default sync mode will depend on the state of the data folder. It will be snap mode if you sync from genesis or full mode if you start from a snapshot.
2.4.Others¶
a.Greenfield Peers¶
Opting for full sync mode means your node will only need block headers and bodies from other network peers. To expedite this process, consider utilizing the Greenfield Peer
.
This data seed, offered by Greenfield, allows for a more efficient synchronization. Configure your BSC node to connect with the Greenfield Light Peer by modifying your configuration file settings. For comprehensive instructions, see Light Peer.
b.Local Private Network¶
Please refer to BSC-Deploy Tools to setup a local private network.
c.Node Maintenance¶
Please read this guide
d.Upgrade Geth¶
Please read this guide
3.Run BSC Full Node: Reth¶
BSC Reth is a cutting-edge Rust client developed in collaboration with Paradigm, designed to provide seamless support for BNB Smart Chain (BSC). It aims to enhance client diversity on the BNB Chain by offering a secure and efficient execution client.
3.1.Hardware Specifications¶
To run BSC Reth effectively, ensure your system meets the following hardware requirements:
- CPU with 16+ cores
- 128GB RAM
- High-performance NVMe SSD with at least 4TB of free space for a full node and 8TB for an archive node
- Broadband internet connection with upload/download speeds of 25 MB/s
3.2.Running BSC Reth¶
-
Download source code and build binary.
git clone https://github.com/bnb-chain/reth.git cd reth make build-bsc
-
Start the reth node, it will run in archive mode by default. You can add the
--full
flag to start a full node.# for mainnet export network=bsc # for testnet # export network=bsc-testnet ./target/release/bsc-reth node \ --datadir=./datadir \ --chain=${network} \ --http \ --http.api="eth, net, txpool, web3, rpc" \ --log.file.directory ./datadir/logs
-
Optionally, you can run the reth node with docker.
# for mainnet export network=bsc # for testnet # export network=bsc-testnet # check this for version of the docker image, https://github.com/bnb-chain/reth/pkgs/container/bsc-reth export version=latest # the directory where reth data will be stored export data_dir=/xxx/xxx docker run -d -p 8545:8545 -p 30303:30303 -p 30303:30303/udp -v ${data_dir}:/data \ --name bsc-reth ghcr.io/bnb-chain/bsc-reth:${version} node \ --datadir=/data \ --chain=${network} \ --http \ --http.api="eth, net, txpool, web3, rpc" \ --log.file.directory /data/logs
3.3.Snapshot¶
To synchronize a BSC reth node from scratch to the current block height can be a time-consuming process. As We benchmark Reth(v1.0.0) on AWS lm4gn.8xlarge(32 core 128G) with 2 x 7500 NVMe SSD for BSC mainnet. It may take approximately 30 days to sync the latest block on BSC mainnet for an archive node and 24 days for a full node.
Given the extended duration required for stage synchronization of the BSC network, the BNB Chain team is developing a segmented snapshot download solution, scheduled for release in the near future. Currently, developers seeking to expedite the process can obtain archive node snapshots from community-maintained repositories. These snapshots offer a faster alternative to syncing from genesis, allowing for quicker node setup and network participation.