Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisions for setting up a full node #232

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b6f464f
Editing Set Up a Full Node page
Jul 2, 2024
d17e2a6
edits
Jul 2, 2024
61cb299
edits
Jul 2, 2024
caa297b
self review
Jul 2, 2024
c745dae
clarifying
Jul 2, 2024
2ae3e55
self-review
Jul 2, 2024
c14cf06
edit word
Jul 2, 2024
02d09f7
add blank line to maybe trigger staging webhooks
Jul 2, 2024
c109f01
update title
Jul 2, 2024
6d78819
fix bash example
Jul 2, 2024
c863457
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 8, 2024
38fa49a
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 8, 2024
bc832b3
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 8, 2024
bc99d68
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 8, 2024
5977cb0
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 8, 2024
231c1d6
edits
Jul 8, 2024
163de39
feedback cont
Jul 8, 2024
f9f9ec9
feedback cont
Jul 8, 2024
776e9af
feedback cont
Jul 8, 2024
c5a6010
test different formatting
Jul 8, 2024
4f7b11c
extra step, formatting
Jul 8, 2024
d114232
reviews, formatting
Jul 8, 2024
8131cb2
fix example
Jul 8, 2024
bc0a8b6
signed
Jul 8, 2024
67f893f
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 10, 2024
b524349
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 10, 2024
d4ead16
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 10, 2024
dfbbf36
Update pages/infrastructure_providers-validators/how_to_set_up_full_n…
zachfc Jul 10, 2024
97d0301
fixes
Jul 8, 2024
84d0232
revisions
zachfc Jul 11, 2024
322d8d2
revisions cont
zachfc Jul 11, 2024
b26456d
wip
zachfc Jul 11, 2024
ab4aa36
stopping
zachfc Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pages/infrastructure_providers-validators/_meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"hardware_requirements": "Hardware Requirements",
"required_node_configs": "Required Node Configs",
"how_to_set_up_full_node": "How to set up a full node",
"how_to_set_up_full_node": "Set Up a Full Node",
"running_full_node": "Running a Full Node",
"running_a_validator": "Running a Validator",
"snapshots": "Snapshots",
Expand Down
198 changes: 128 additions & 70 deletions pages/infrastructure_providers-validators/how_to_set_up_full_node.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,128 @@
# How to set up a full node

## Pre-requisite
1. Linux (Ubuntu Server 22.04.3 recommended)
2. 8-cpu (ARM or x86_64), 64 GB RAM, 500 GB SSD NVME Storage

## Get the dydxprotocold binary and initialize the data directory
> **Note:** the example values below align with the **deployment by DYDX token holders**. For alternatives, please visit the [Network Constants page](../infrastructure_providers-network/network_constants.mdx).

1. From https://github.com/dydxprotocol/v4-chain/releases/ | Look for the `protocol` assets.
2. For example, as of `10/19/2023`, this was the correct binary to use:
![dYdX Protocol Binary](../../artifacts/how_to_set_up_full_node_binary_download.png)
3. Download, extract, and rename the binary to `dydxprotocold`. Move it to a directory in your `$PATH`. Now, initialize the data directory (create the directory first if it doesn’t exist).
```bash
CHAIN_ID=dydx-mainnet-1
DYDX_HOME=/home/vmware/.dydx-mainnet-1
NODE_NICKNAME=mydydxfullnode

dydxprotocold init --chain-id=$CHAIN_ID --home=$DYDX_HOME $NODE_NICKNAME
```

## Get the latest applicable genesis.json file and install
> **Note:** the example values below align with the **deployment by DYDX token holders**. For alternatives, please visit the [Network Resources page](../infrastructure_providers-network/resources.mdx).

1. Use
```bash
curl https://dydx-ops-rpc.kingnodes.com/genesis | python3 -c 'import json,sys;print(json.dumps(json.load(sys.stdin)["result"]["genesis"], indent=2))' > genesis.json
```
to get the applicable Genesis state of the network.

2. Copy the applicable `genesis.json` file to the data directory’s `config/` directory
3. (Alternatives): If the RPC endpoint above does not work, there are these alternatives:
- https://dydx-dao-rpc.polkachu.com/genesis
- https://dydx-mainnet-full-rpc.public.blastapi.io/genesis
- Also check [Full node endpoints → RPC](../infrastructure_providers-network/resources.mdx#full-node-endpoints)

## Install Bware’s snapshot (optional but saves days)
> **Note:** the example values below align with the **deployment by DYDX token holders**. For alternatives, please visit the [Network Resources page](../infrastructure_providers-network/resources.mdx).

1. From https://bwarelabs.com/snapshots/dydx
2. Download and extract (using `lz4 -dc < snapshotfile.tar.lz4 | tar xf -`) the snapshot contents in the data directory (make sure you are in the data directory before running the tar command). Important: The home directory (`$DYDX_HOME` or `/home/vmware/.dydx-mainnet-1` in our example) contains another `data/` directory.
3. (Alternatives): If the above is not available, there are these alternatives:
- https://polkachu.com/tendermint_snapshots/dydx
- https://dydx-archive-snapshot.kingnodes.com/
- Also check [Snapshot service](../infrastructure_providers-network/resources.mdx#snapshot-service)

## Start the full node
> **Note:** the example values below align with the **deployment by DYDX token holders**. For alternatives, please visit the [Network Resources page](../infrastructure_providers-network/resources.mdx).

1. Start the full node. Note that you may need to change the `--p2p.seeds` parameter depending on the applicable v4 software blockchain network – you can find an example on [Resources page under “Seed nodes”](../infrastructure_providers-network/resources.mdx#seed-nodes)
```bash
DYDX_HOME=/home/vmware/.dydx-mainnet-1

nohup dydxprotocold start --p2p.seeds="ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@seeds.polkachu.com:23856,65b740ee326c9260c30af1f044e9cda63c73f7c1@seeds.kingnodes.net:23856,f04a77b92d0d86725cdb2d6b7a7eb0eda8c27089@dydx-mainnet-seed.bwarelabs.com:36656,20e1000e88125698264454a884812746c2eb4807@seeds.lavenderfive.com:23856,c2c2fcb5e6e4755e06b83b499aff93e97282f8e8@tenderseed.ccvalidators.com:26401,4f20c3e303c9515051b6276aeb89c0b88ee79f8f@seed.dydx.cros-nest.com:26656,a9cae4047d5c34772442322b10ef5600d8e54900@dydx-mainnet-seednode.allthatnode.com:26656,802607c6db8148b0c68c8a9ec1a86fd3ba606af6@64.227.38.88:26656,4c30c8a95e26b07b249813b677caab28bf0c54eb@rpc.dydx.nodestake.top:666,ebc272824924ea1a27ea3183dd0b9ba713494f83@dydx-mainnet-seed.autostake.com:27366" --home=$DYDX_HOME --non-validating-full-node=true > /tmp/fullnode.log 2>&1 &
```
2. You can tail the log to see the progress.
```bash
tail -f /tmp/fullnode.log
```
3. The full node is now syncing. To determine whether the full node is caught up with the chain head, please check the applicable block explorer to determine when it reaches the current block – an example block explorer is shown on https://www.mintscan.io/dydx

## Things you can do with the full node
GET CURRENT BLOCK: You can get the current block with this program https://github.com/chiwalfrm/dydxexamples/blob/1d46b7a75499205d9c1c1986ae4ae8f21b6c1385/v4block_subscribe.py

Run it with the full node IP address and port `26657`:
```bash
python3 v4block_subscribe.py ws://<IPADDRESS>:26657
```
Where `<IPADDRESS>` is the IP address of your full node.
![Full node usage example](../../artifacts/how_to_set_up_full_node_usage_example.png)
# Set Up a Full Node

> Code snippets on this page use example values. Replace them with your own. See the [Network Configuration](../infrastructure_providers-network/network_constants.mdx) section of the documentation for network constants and other resources you need to configure a full node.

## System requirements
To run a full node, the system that hosts the node must meet the following minimum requirements:

- Linux (Ubuntu Server 22.04.3 or later recommended)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Linux the only OS this works on? Asking because there's a .zip and .tar.gz source code download

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope you can run this on any ARM or AMD64 servers, which should cover newer Macs and AMD based windows too

- 8-core CPU (ARM or x86_64 architecture)
- 64 GB RAM
- 500 GB SSD NVMe Storage

## Install `dydxprotocold`

The `dydxprotocold` binary contains the software you need to operate a full node. You must use the same version of the software as the network to which you want to connect.

To install the appropriate `dydxprotocold` binary:

1. Find the current version of the dYdX network.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we explain how to figure this out? IMO, there's a pretty good chance users on this site don't know how to do this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely -- I don't know how to do it and need to find out. Do you know what the best way or best options are?


To determine the network's current block, you can use a block explorer such as [mintscan.io](https://www.mintscan.io/dydx).

2. Find the matching release protocol version and download the compressed `dydxprotocold` file for your system.

**Option 1**: Find and download the protocol binary from the [v4 Chain Releases](https://github.com/dydxprotocol/v4-chain/releases/) page.

> For example, for protocol version 5.0.5 on an AMD system, download `dydxprotocold-v5.0.5-linux-amd64.tar.gz`.

**Option 2**: Specify the protocol binary and download it with `curl -L -O`. Use the base URL `https://github.com/dydxprotocol/v4-chain/releases/download/protocol/`
and append the binary information in the following format:
`[v0.0.0]/dydxprotocold-[v0.0.0]-[architecture].tar.gz`

> For example, for protocol version 5.0.5 on an AMD system, run:

```
curl -L -O https://github.com/dydxprotocol/v4-chain/releases/download/protocol/v5.0.5/dydxprotocold-v5.0.5-linux-amd64.tar.gz
```

3. Extract the binary.

Extract the `.tar.gz` file that you downloaded. Rename the extracted file or create a symbolic link to the file. Add the directory with the executable or symbolic link to your system's `$PATH`.

**Option 1:** Rename the extracted file. Edit the filename from `dydxprotocold-[version]-[architecture]` to simply `dydxprotocold`. For example:

```bash
mv /path/to/dydxprotocold-[version]-[architecture] dydxprotocold
```

**Option 2:** Create a symbolic link to the extracted file using the name `dydxprotocold`. For example:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add the example command like the following?

mv dydxprotocold-v5.0.6-linux-arm64 dydxprotocold

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll add this and start doing that with each step that calls for it

I do think using example values is clearer, like mv dydxprotocold-<version>-<architecture> dydxprotocold. They call attention to custom attributes and stop the user from trying to run a command as-is

```bash
ln -s /path/to/dydxprotocold-[version]-[architecture] dydxprotocold
```

4. Add the directory that contains the `dydxprotocold` executable to your system's `$PATH`.

5. Initialize your data directory.

First, make sure that your data directory is empty. In the example below, `DYDX_HOME` contains the path to the directory that must be empty.

Then, run the `dydxprotocold init` command, supplying a chain ID, a path to a data directory, and a moniker for your node:

```bash
# Example values
CHAIN_ID=my-dydx-deployment
DYDX_HOME=/path/to/your/data/directory
Comment on lines +65 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the doc states: "Examples on this page are for mainnet deployments by dYdX token holders." Should we use this as the example?

Suggested change
CHAIN_ID=my-dydx-deployment
DYDX_HOME=/path/to/your/data/directory
CHAIN_ID=dydx-mainnet-1
DYDX_HOME=~/.dydxprotocold

Copy link
Contributor Author

@zachfc zachfc Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. My first thought is that it would be better to change that line about examples to something like "Code snippets on this page use example values. Replace them with your own." or something along those lines

  1. I think new users could have a hard time distinguishing an example value like "mainnet-1" from a value that we're telling them to use, like "dydxprotocold". Consistently using a format like "my-software," or "example-value" I think is often clearer when configuring something
  2. I still need to meet with legal so please correct me, but it sounded best to abstract examples away from mainnet deployments

NODE_MONIKER=my-dydx-fullnode

dydxprotocold init --chain-id=$CHAIN_ID --home=$DYDX_HOME $NODE_MONIKER
```

The `dydxprotocold` executable is now installed. Your system can now host a full node using `dydxprotocold` to interface with a dYdX chain deployment from your command line. To connect to a chain, you must first sync your node with that chain's history. dYdX recommends doing this by using a snapshot.

## Initialize your node's state using a snapshot
Using snapshots to restore or sync your full node's state saves time and effort. Using a snapshot avoids replaying all the blocks from genesis (height = 0) and does not require multiple binary versions for network upgrades. Instead, your node reads most of the chain's history directly from the snapshot.

To install a dYdX snapshot:

1. Download the latest snapshot contents from a [snapshot service](/infrastructure_providers-network/resources#snapshot-service).

> For example, you can download the history to date of the mainnet dYdX chain from [Bware Labs](https://bwarelabs.com/snapshots/dydx).

2. Extract the snapshot to your data directory.

To extract the snapshot content and move it to your node's data directory, run the following command:

```bash
# Example value
SNAPSHOT_FILENAME=dydx2024example

lz4 -dc < $SNAPSHOT_FILENAME.tar.lz4 | tar xf - $DYDX_HOME/data
```

The snapshot is installed. When you start your full node, it automatically uses the snapshot in its data directory to begin syncing your full node's state with the network.

## Start your full node
When you start your full node it must sync with the history of the network. If you initialized your full node using a snapshot, your node must update its state only with blocks created after the snapshot was taken. If your node's state is empty, it must sync with the entire history of the network.

1. Configure parameters in your command line. Use the following syntax:

```bash
# Example values
SEED_LIST="123@seeds.polkachu.com:123,123@seeds.kingnodes.net:123"
DYDX_HOME=/path/to/your/data/directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already set this above, so rm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave it for quick reference since it's a variable in that example as well and users may be referencing specific steps. It could be confusing if they need to scroll back up to find that info


dydxprotocold start
--p2p.seed=$SEED_LIST
--home=$DYDX_HOME
--non-validating-full-node=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should highlight this flag. this is very important for starting a "full node" aka non-validating node

```

- Using the `--p2p.seeds` command line flag, provide a comma-separated list of node URIs in the blockchain network that you are connecting to. For a list of node URIs, see the Resources page section for [Seed Nodes](../infrastructure_providers-network/resources.mdx#seed-nodes).

- Using the `--home` command line flag, provide the path to your data directory.

- You must include the flag `--non-validating-full-node=true` to start a full node.

2. Confirm that your full node has finished syncing by comparing its current block to the dYdX chain. The full node is caught up with the dYdX chain head when it reaches the dYdX chain's current block.

- To determine the network's current block, you can use a block explorer such as [mintscan.io](https://www.mintscan.io/dydx).

- To determine your full node's height, query your node with the following command:

```bash
curl localhost:26657/status
```

When your full node is up to date with the network, you can use it to read live data and configure additional settings. Learn more on the [Running a Full Node](../infrastructure_providers-validators/running_full_node) page.
2 changes: 1 addition & 1 deletion pages/introduction-onboarding_faqs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

- Running a full node will eliminate the latency between placing an order and when the actual order is gossiped throughout the network. Without your own node, your order will need to first be relayed to the nearest geographic node, which will then propagate it throughout the network for you. With your own node, your order will directly be gossiped.
- Additionally, running a full node allows you to use [full node streaming](./infrastructure_providers-validators/full_node_streaming.md), a feature that aims to provide real-time, accurate orderbook updates and fills.
- Instructions on how to set up a full node can be found [here](./infrastructure_providers-validators/how_to_set_up_full_node.md).
- Instructions on setting up a full node can be found [here](./infrastructure_providers-validators/how_to_set_up_full_node.md).

</details>

Expand Down