# Mainnet Node Launch

### [#](#configuration-choices) Configuration choices <a href="#configuration-choices" id="configuration-choices"></a>

#### Hardware requirements <a href="#hardware-requirements" id="hardware-requirements"></a>

Replicas need to store the transaction history of Patex and to run Geth. They need to be relatively powerful machines (real or virtual). We recommend at least 16 GB RAM, and an SSD drive with at least 500 GB free (for the production network).

#### Source of synchronization <a href="#source-of-synchronization" id="source-of-synchronization"></a>

The`patex-chain` component synchronizes from both other [Patex Nodes](https://github.com/patex-ecosystem/patex-network/blob/main/specs/exec-engine.md#happy-path-sync), meaning L2, and L1 Ethereum if necessary.

To synchronize only from L1, you edit the [pt-node configuration (opens new window)](https://github.com/patex-ecosystem/patex-network/blob/main/specs/exec-engine.md#worst-case-sync) to set `OP_NODE_P2P_DISABLE` to `true`.

When you use RPC to get block information (<https://github.com/patex-ecosystem/patex-network/blob/main/specs/rollup-node.md#l2-output-rpc-method>), you can specify one of four options for `blockNumber`:

* an actual block number
* **pending**: Latest L2 block
* **latest**: Latest block written to L1
* **finalized**: Latest block fully finalized on L1 (a process that takes 12 minutes with Proof of Stake)

### [#](#docker-configuration) Docker configuration <a href="#docker-configuration" id="docker-configuration"></a>

The recommended method to create a replica node is to use [Docker (opens new window)](https://www.docker.com/) and the [Mainnet RPC node Docker deploy script we provide](https://github.com/patex-ecosystem/patex-network/blob/main/ops-bedrock/mainnet/rpc-node/node-up.sh). It include all the configuration settings for run the node. This is the recommended method because it is what we use for our own systems. As such, the docker images go through a lot more tests than any other configuration.

#### Configuring and running the node <a href="#configuring-and-running-the-node" id="configuring-and-running-the-node"></a>

Everything you need just clone the [Patex network](https://github.com/patex-ecosystem/patex-network.git) repository and run a script on [Docker](https://www.docker.com/) pre-installed OS:

```
cd ~
git clone https://github.com/patex-ecosystem/patex-network.git
cd patex-network
./ops-bedrock/mainnet/rpc-node/node-up.sh
```

The Docker node exposed RPC port 9545. After containers is deployed and have running status, you can make RPC requests. Example `eth_blockNumber` api:

```
curl --location --request POST 'http://localhost:9545' --header 'x-api-key: YOUR-API-KEY' --header 'Content-Type: application/json' --data-raw '{"jsonrpc": "2.0","method": "eth_blockNumber","params": [],"id": ""}'
```

### [#](#non-docker-configuration) Non-docker configuration <a href="#non-docker-configuration" id="non-docker-configuration"></a>

Here are the instructions if you want to build your own read-only replica without relying on our images. These instructions were generated on an Ubuntu 20.04 box, but they should work with other systems too.

**Note:** This is *not* the recommended configuration. While we did QA on these instructions and they work, the QA that the docker images undergo is much more extensive.

#### Build the Patex repository <a href="#build-the-optimism-monorepo" id="build-the-optimism-monorepo"></a>

1. Clone the [Patex network](https://github.com/patex-ecosystem/patex-network.git) repository (opens new window).

   ```
   cd ~
   git clone https://github.com/patex-ecosystem/patex-network.git
   ```
2. Build the various packages inside of the Patex Network repository.

   ```
   cd patex-network
   make pt-node
   ```

#### Build patex-chain <a href="#build-op-geth" id="build-op-geth"></a>

1. Clone [patex-chain](https://github.com/patex-ecosystem/patex-chain):

   ```
   cd ~
   git clone https://github.com/patex-ecosystem/patex-chain.git
   ```
2. Build `patex-chain`:

   ```
   cd patex-chain
   make geth
   ```

#### Get the data dir <a href="#get-the-data-dir" id="get-the-data-dir"></a>

The next step is to download the data directory for `patex-chain`.

1. Download the correct data directory snapshot.
   * [Patex Mainnet](https://mainnet.patex.io/snapshots/mainnet.tar) (download file)
2. Create the data directory in`patex-chain` and fill it. Note that these directions assume the data directory snapshot is at `~`, the home directory. Modify if needed.

   ```
   cd ~/patex-chain
   tar xvf ~/mainnet.tar
   ```
3. Create a shared secret with `pt-node`:

   ```
   cd ~/patex-chain
   openssl rand -hex 32 > jwt.txt
   cp jwt.txt ~/patex-network/pt-node
   ```
4. Download rollup.json config for `pt-node:`

   ```
   cd ~/patex-network
   wget https://mainnet.patex.io/rollup.json $PWD/rollup.json
   ```

#### Scripts to start the different components <a href="#scripts-to-start-the-different-components" id="scripts-to-start-the-different-components"></a>

#### **`patex-chain`**

```
#! /usr/bin/bash

cd ~/patex-chain

./build/bin/geth \
  --ws \
  --ws.port=8546 \
  --ws.addr=0.0.0.0 \
  --ws.origins="*" \
  --http \
  --http.port=8545 \
  --http.addr=0.0.0.0 \
  --http.vhosts="*" \
  --http.corsdomain="*" \
  --authrpc.addr=localhost \
  --authrpc.jwtsecret=./jwt.txt \
  --authrpc.port=8551 \
  --authrpc.vhosts="*" \
  --verbosity=3 \
  --rollup.disabletxpoolgossip=true \
  --nodiscover \
  --syncmode=full \
  --maxpeers=0 \
  --datadir ./datadir
```

#### **`pt-node`**

```
#! /usr/bin/bash

cd ~/patex-network/pt-node
./bin/pt-node \
        --l2=http://localhost:8551 \
        --l2.jwt-secret=./jwt.txt \
        --rpc.addr=0.0.0.0 \
        --rpc.port=8547 \
	--rollup.config=./rollup.json \
        --l1=<< URL TO L1 >>       
```

Make sure to change `<< URL to L1 >>` to a service provider's URL for the L1 network ( L1 Ethereum Mainnet).

#### Operations <a href="#operations" id="operations"></a>

It is best to start `patex-chain` first and shut it down last.
