Recommended configuration for mainnet, can appropriately downgrade for testnet.
For mainnet: Ensure Docker's home directory is set to the maximum available disk space and configure disk usage alerts.
For mainnet: Choose the Singapore region as the deployment location for your synchronization nodes.
Please ensure that time synchronization is enabled and set to UTC+0 on all deployment-related servers.
Server
Components
Recommended hardware
Comments
Database
Sync Server
state-db, prover-db
sync, prover
CPU: 64VCORE, >= 3050MHZ
RAM: 128G
DISK: 2000GB, NVMe SSD
Synchronize the L2 state from master node and L1, only one can run at a time.
RPC Server(s)
json-rpc, prover
CPU: 64VCORE, >= 3050MHZ
RAM: 128G
DISK: 2000GB, NVMe SSD
Provide access entry for external requests, can run multiple instances.
Deployment Steps
Prepare configuration files
docker-compose.yml
If you have modified the default configuration of the database container [merlin-state-db], please synchronize this configuration with [StateDB] in node.config.toml and databaseURL in prover.config.json.
# Install dependencysudoaptinstallgnupg2wgetvim-y# Enable official package reposudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import GPG signing keywget-qO-https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudotee/etc/apt/trusted.gpg.d/pgdg.asc&>/dev/null# Update system packagessudoaptupdate-y# Install postgres clientsudoaptinstallpostgresql-client-15-y
Download recovery database snapshot
# Confirm the creation date of below downloaded files; they must be on the same day.# Testnetwgethttps://rpc-snapshot.merlinchain.io/testnet_state_db.sql.tar.gzwgethttps://rpc-snapshot.merlinchain.io/testnet_prover_db.sql.tar.gz# Mainnetwgethttps://rpc-snapshot.merlinchain.io/state_db.sql.tar.gzwgethttps://rpc-snapshot.merlinchain.io/prover_db.sql.tar.gz
Prepare recovery script
gitclonehttps://github.com/0xPolygon/cdk-validium-node.gitcdcdk-validium-node# Recommend using Go 1.21 or a later versiongobuild-o./build./cmd
Prepare recovery configuration
# touch a config file named "snapshot_restore.toml"vimsnapshot_restore.toml
# update the database connection info based on your "docker-compose.yml"[Log]Environment="production"# "production" or "development"Level="debug"# "info"Outputs= ["stderr"][StateDB]User="state_user"Password="state_password"Name="state_db"Host="127.0.0.1"Port="5432"EnableLog= falseMaxConns= 200[HashDB]User="prover_user"Password="prover_password"Name="prover_db"Host="127.0.0.1"Port="5432"EnableLog= falseMaxConns= 200
# Add a logic host to /etc/hosts127.0.0.1zkevm-state-db## change ip to your database IP
Execute recovery
# Assuming you are currently under previous Git directory, and the snapshot recovery file you downloaded is also in the current directory (or you can manually specify the location), execute the following command for recovery:
./buildrestore--cfg./snapshot_restore.toml-is./state_db.sql.tar.gz-ih./prover_db.sql.tar.gz
Add extra index for state db
CREATEINDEXIFNOTEXISTS l2block_block_hash_idx ON state.l2block (block_hash);CREATEINDEXIFNOTEXISTS l2block_created_at_idx ON state.l2block (created_at);CREATEINDEXIFNOTEXISTS log_log_index_idx ON state.log (log_index);CREATEINDEXIFNOTEXISTS log_topic0_idx ON state.log (topic0);CREATEINDEXIFNOTEXISTS log_topic1_idx ON state.log (topic1);CREATEINDEXIFNOTEXISTS log_topic2_idx ON state.log (topic2);CREATEINDEXIFNOTEXISTS log_topic3_idx ON state.log (topic3);CREATEINDEXIFNOTEXISTS idx_receipt_tx_index ON state.receipt (block_num, tx_index);CREATEINDEXIFNOTEXISTS receipt_block_num_idx ON state.receipt USING btree (block_num);
The expected result should be a valid block number:
{"jsonrpc":"2.0","id":1,"result":"0x2855"}
Troubleshooting
Please note that there should be no indication of port occupation when checking the port mappings for Docker.
Ensure that in all your configuration files, the databases have the correct host / user / password value. You can test connectivity using the command line before proceeding with the installation.
Commercial RPC nodes
For reference, you can also subscribe to the following third-party RPC vendors.