# Deploy an erigon rpc for mainnet

## Deployment Overview

* Recommend using a dedicated server to separate from the fork9 JSON-RPC server.
* Recommended configuration: CPU: 4 vCores, RAM: 32GB, Disk: 1TB, NVMe SSD. Higher IOPS and throughput performance will yield better results. It is recommended to have 250,000 IOPS and 1000 MiB/s throughput.

## Deployment Steps

### Prepare configuration files

#### docker compose file

```yaml
version: "3.5"
networks:
  default:
    name: cdk-erigon
services:
  cdk-erigon-rpc:
    container_name: cdk-erigon-rpc
    image: merlinadmin/cdk-erigon:v2.0.3
    stop_grace_period: 600s
    restart: always
    environment:
      - CDK_ERIGON_SEQUENCER=0
    ports:
      - 9123:8123
      - 7990:6990
      - 9124:8124
    volumes:
      - ./erigon_config/config-rpc.yaml:/usr/src/app/config.yaml
      - ./erigon_config/dynamic-merlinmainnet-allocs.json:/usr/src/app/dynamic-merlinmainnet-allocs.json
      - ./erigon_config/dynamic-merlinmainnet-chainspec.json:/usr/src/app/dynamic-merlinmainnet-chainspec.json
      - ./erigon_config/dynamic-merlinmainnet-conf.json:/usr/src/app/dynamic-merlinmainnet-conf.json
      - ./erigon_data:/usr/src/app/data
    command: >
      --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml
    logging:
        options:
          max-size: "1g"
          max-file: "3"
```

#### config-rpc.yaml

```yaml
datadir: /usr/src/app/data/
chain: dynamic-merlinmainnet
http: true
private.api.addr: localhost:9098
torrent.port: 42070
authrpc.port: 8552
zkevm.l2-chain-id: 4200
zkevm.l2-sequencer-rpc-url: http://mainnet-public-datastreamer.merlinchain.io:2081
zkevm.l2-datastreamer-url: mainnet-public-datastreamer.merlinchain.io:2080
zkevm.l1-chain-id: 202401
zkevm.l1-rpc-url: https://mainnet-l1.merlinchain.io

zkevm.address-sequencer: "0x1B46c54ebE88F22cBFf2Bd4eB4545C47Bb2f3017"
zkevm.address-zkevm: "0xBf4B031eb29fc34E2bCb4327F9304BED3600cc46"
zkevm.address-admin: "0x6229976bf881Ee0e2499e8bDbDFd44E396b2aE7d"
zkevm.address-rollup: "0x68DdbE6638d7514a9Ed0B9B2980B65970e532cdB"
zkevm.address-ger-manager: "0x8b97BF5C42739C375a2db080813E9b4C9A4a2c9A"

zkevm.l1-rollup-id: 1
zkevm.l1-first-block: 85544
zkevm.l1-block-range: 20000
zkevm.l1-query-delay: 6000
zkevm.l1-highest-block-type: latest
zkevm.rpc-ratelimit: 300
zkevm.datastream-version: 2
zkevm.increment-tree-always: false
zkevm.rebuild-tree-after: 500000

log.console.verbosity: 3

zkevm.executor-urls: ""
zkevm.executor-strict: false
zkevm.witness-full: true

zkevm.sequencer-block-seal-time: "3s"
zkevm.sequencer-batch-seal-time: "10s"

zkevm.data-stream-host: "localhost"
zkevm.data-stream-port: 6990
zkevm.data-stream-writeTimeout: "100s"
zkevm.default-gas-price: 1000000000
zkevm.max-gas-price: 0
zkevm.gas-price-factor: 0.000001
externalcl: true
http.api: [eth, debug, net, trace, web3, erigon, txpool, zkevm]
http.addr: 0.0.0.0
http.port: 8123
http.vhosts: any
http.corsdomain: any
http.trace: false
rpc.evmtimeout: "30s"
ws: true
ws.addr: 0.0.0.0
ws.port: 8124
db.read.concurrency: 20000
txpool.globalslots: 100000
networkid: 4200
```

#### Static configurations

```shell
wget https://rpc-snapshot.merlinchain.io/erigon/dynamic-merlinmainnet-allocs.json
wget https://rpc-snapshot.merlinchain.io/erigon/dynamic-merlinmainnet-chainspec.json
wget https://rpc-snapshot.merlinchain.io/erigon/dynamic-merlinmainnet-conf.json
```

### Snapshot

#### Download erigon data snapshot

```shell
wget https://rpc-snapshot.merlinchain.io/erigon/erigon_data.tar.gz
```

#### Launch erigon

* Ensure that the erigon-config and erigon-data directories are consistent with the volumes configuration in docker-compose.yml.

```shell
docker compose up -d cdk-erigon-rpc
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.merlinchain.io/merlin-docs/developers/run-a-merlin-node/deployment-and-configuration/deploy-an-erigon-rpc-for-mainnet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
