Skip to content

Commit

Permalink
update BSC archive node client (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
STdevK authored Mar 7, 2024
1 parent 9bf2a93 commit f144cb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
17 changes: 16 additions & 1 deletion docs/BSC-FAQs-general.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,19 @@ case $CMD in
echo "Usage: chaind.sh -start | -stop | -restart .Or use systemctl start | stop | restart bsc.service "
;;
esac
```
```

### How to enable periodic log deletion function in config.toml?

From config.toml, add MaxBackups in Node.LogConfig. MaxBackups means the log file that would be retained, by default it would be 0, which means there is no limitation. If set MaxBackups = 240, only logs of the most recent 240 hours(10 days) would be kept, since the default rotate time is 1 hour. [Reference](https://github.com/bnb-chain/bsc/pull/2186)

Example
```
[Node.LogConfig]
FileRoot = ""
FilePath = "bsc.log"
MaxBytesSize = 10485760
Level = "info"
MaxBackups = 240
```

32 changes: 2 additions & 30 deletions docs/archivenode.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,11 @@ Archive nodes are used by various applications on the blockchain for challenging

## Suggested Requirements

Running an archive node will take a high cost as it includes all the block and state change data. First of all it needs the disk with sufficient capacity; besides this, the CPU and disk performance should be good enough to catch up with the latest block height.
Running an archive node will take a high cost as it includes all the block and state change data. First of all it needs the disk with sufficient capacity; besides this, the CPU and disk performance should be good enough to catch up with the latest block height. You can refer to the [suggested hardware requirements](https://github.com/node-real/bsc-erigon?tab=readme-ov-file#system-requirements).

## How to run an archive node for BSC mainnet?

### 1. (Deprecated) Run with a Geth client

#### 1.1 (Deprecated) Run one segment archive node with a snapshot
A segment archive node is a node which has all the data from one starting block height to one ending block height, such as [19000000, latest]. To create such one archive node, you need a snapshot with starting block number, less than 19000000.

You can get snapshot from BNB Chain official documentation:
- [BNB Chain Chaindata Snapshot](https://docs.bnbchain.org/docs/validator/snapshot)
- [BNB Chain Snapshot Repo](https://github.com/bnb-chain/bsc-snapshots).

* Command to run:

```
./geth --config local_config_dir/config.toml --datadir local_data_dir --pprof.addr 0.0.0.0 --rpc.allow-unprotected-txs --rpccorsdomain * --light.serve 50 --cache 5000 --metrics --snapshot=true --rangelimit --gcmode archive --txlookuplimit 0 --syncmode full --pprof
```

#### 1.2 (Deprecated) Build one full archive node with segmented archive nodes

Instead of putting all archive data on a single Geth instance, it is suggested to create multiple segment instances, each of them only serving part of the chain. To get better performance, it is suggested that each segment's size is better to control under 4TB. There will be around 40TB data in all(up to March, 2023). For all BSC snapshots you can refer to [Free public BNB Smart Chain Archive Snapshot](https://github.com/allada/bsc-archive-snapshot). The owner has put all BSC archive snapshots on S3. As described this path is public but is configured as requester-pays. This means you'll need an AWS account in order to download them. After having all the segments, you need one proxy to dispatch the requests to the right segment. And thanks the owner, one proxy was also implemented. Please follow the owner's guide to build.

### 2. Run with an Erigon client
### Run with an Erigon client

[Erigon](https://github.com/node-real/bsc-erigon) has supported BSC mainnet. You can also refer to [Free public BNB Smart Chain Archive Snapshot](https://github.com/allada/bsc-archive-snapshot) for the guide to run a BSC archive node with an Erigon client. The owner has switched to using an Erigon client for a BSC archive node recently. You can download the archive snapshot which is a tarball from aws s3. The s3 path is "s3://public-blockchain-snapshots/bsc/erigon-latest.tar.zstd". This path is public, but is configured as requester-pays. Also this means you'll need an AWS account in order to download it.

Expand All @@ -63,12 +44,3 @@ tar --use-compress-program=unzstd -xvf erigon-latest.tar.zstd

The known Issue with an Erigon client is that it does not really keep up with the latest blocks as mentioned in the Github. If you want to keep up with the latest blocks it is suggested to run a BSC archive node with high performance disk such as NVME, or run a BSC full node with a Geth client at the same time which means you need one proxy that will ask Erigon if it has the block height and if not forward it to the Geth client.

## Comparison between Geth and Erigon

* **Data size:** Up to now(June, 2022), the whole data size is about 35TB with Geth client while it is about 6TB with Erigon client, much smaller.

* **Maturity:** Erigon is new and not yet battle tested while Geth has been running a long time, more stable. Archive nodes with Geth client can support all RPC APIs while some of them are not supported well by Erigon client such as eth_getProof.

* **Complexity:** It is easier to run one BSC archive node with an Erigon client than that with a Geth client. And it is nearly the same complexity if you want to keep up the latest blocks with a Erigon archive node & a Geth full node at the same time.

All in all, people can choose one of the methods above to run a BSC archive node based on their own requirements.

0 comments on commit f144cb2

Please sign in to comment.