# Deploy an erigon rpc for testnet

## Deployment Overview

* Erigon RPC can be deployed independently without relying on other testnet RPC components (CDK / Prover / Database). You can choose to deploy it together with JSON-RPC or separately.
* Erigon RPC depends on a JSON-RPC and an upstream DataStreamer.
* 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
    volumes:
      - ./erigon_config/config-rpc.yaml:/usr/src/app/config.yaml
      - ./erigon_config/dynamic-merlintestnet-allocs.json:/usr/src/app/dynamic-merlintestnet-allocs.json
      - ./erigon_config/dynamic-merlintestnet-chainspec.json:/usr/src/app/dynamic-merlintestnet-chainspec.json
      - ./erigon_config/dynamic-merlintestnet-conf.json:/usr/src/app/dynamic-merlintestnet-conf.json
      - ./erigon_config/dynamic-merlintestnet-block.json:/usr/src/app/dynamic-merlintestnet-block.json
      - ./erigon_data/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-merlintestnet
http: true
private.api.addr: localhost:9098
torrent.port: 42070
authrpc.port: 8552
zkevm.l2-chain-id: 686868
zkevm.l2-sequencer-rpc-url: http://testnet-datastreamer.merlinchain.io:2081
zkevm.l2-datastreamer-url: testnet-datastreamer.merlinchain.io:2080
zkevm.l1-chain-id: 55555
zkevm.l1-rpc-url: https://testnet-l1.merlinchain.io

zkevm.address-sequencer: "0xDCdB53f6633c9D290971Af961689c96B73B79c75"
zkevm.address-zkevm: "0x8173da1A9d41287158E9b6E38Ca9CDabBAE6bb6B"
zkevm.address-admin: "0x74c4A7265Ac6B8a8AD3Ab99071B63c007616Fb33"
zkevm.address-rollup: "0xAefb2f4db0766F0D76c47d0dbc0A712D653cace6"
zkevm.address-ger-manager: "0x07eb659bd996Ac74c154dfe86Ea875570647961C"

zkevm.l1-rollup-id: 1
zkevm.l1-first-block: 24925
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.rebuild-tree-after: 100000

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
ws: true
ws.addr: 0.0.0.0
ws.port: 8124
db.read.concurrency: 20000
txpool.globalslots: 100000
networkid: 686868
```

#### Static configurations

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

### Snapshot

#### Download erigon data snapshot

```shell
wget https://rpc-snapshot.merlinchain.io/erigon/testnet_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-testnet.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.
