Help & Support

Running a Lens Archive Node

Learn how to run a Lens Archive node. Is an Archive Node the right choice for you? If you need a node with the entire rollup history, using a Postgres dump is the only option, and pruning should be disabled.

System Requirements

The following are minimal requirements:

  • CPU: A relatively modern CPU is recommended, with approximately 16 cores.

  • RAM: 256GB for running the node (Temporarily 1TB during setup if you require the zks_getProof method).

  • Storage:
    • Mainnet Nodes: 2 TB, with the state growing.

  • Network: 100 Mbps connection (1 Gbps+ recommended)

Setup Instructions

If you require the zks_getProof method, ensure you have the necessary system resources before proceeding. External node rebuilds the tree when it launches for the first time. Batch 0 on the Lens chain is extremely large. For bootstrap roughly 1TB RAM is required to fit that all in. That much memory is required only once, to generate Rocks DB state. After that you can cut it back down to a normal spec.

If you do not require the zks_getProof method, you can skip the tree rebuild and therefore avoid the need for a large amount of RAM during the initial setup. See Restoring without the Merkle tree below for more details.

1

Clone the Lens Node Repository

git clone https://github.com/lens-protocol/lens-chain-node && cd lens-chain-node

2

Disable the s3 snapshot restore and disable pruning

EN_SNAPSHOTS_RECOVERY_ENABLED: "false"EN_PRUNING_ENABLED: "false"

3

Download the latest database dump

curl -O https://lens-chain-db-dump.s3.us-east-1.amazonaws.com/endb.dump

4

Add the database dump to the docker volume mounts

volumes:  - mainnet-postgres:/db  - /path/to/endb.dump:/host/endb.dump:ro

5

Start Postgres

docker compose --file mainnet-external-node.yml up -d postgres

6

Restore the database dump to postgres

docker exec -u postgres lens-chain-node-postgres-1 pg_restore \  -v -C --no-owner --no-privileges -d postgres "/host/endb.dump"

The restore process can take a few hours, resource dependent.

7

Start the External Node

docker compose --file mainnet-external-node.yml up -d external-node

The matterlabs/external-node:2.0-v26.7.1_lens_custom_genesis image is a custom build for the external node which optimizes query performance for the merkle tree rebuild, it is imperitive that this is used for the initial setup, or you are likely to experience errors in the merkle tree rebuild.

The process to rebuild the merkle tree takes approximately 3-4 hours and uses a significant amount of RAM ~1TB Once the merkle tree is rebuilt, and the node is synced, you can scale back the RAM attached to the node to the standard configuration.

8

OPTIONAL: Starting the External Node without the Merkle Tree (AKA Treeless Mode)

This option is useful for environments with limited resources or when the zks_getProof method is not required. Full Documentation on Treeless Mode can be found here. First we disable the merkle tree rebuild:

command: ["--components=core,api,da_fetcher,tree_fetcher"]

Then we start the node:

docker compose --file mainnet-external-node.yml up -d external-node

Additional Documentation

Additional documentation can be found in the ZkSync Era Repository