> For the complete documentation index, see [llms.txt](https://gameluk.gitbook.io/gameluk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gameluk.gitbook.io/gameluk/full-node/run-a-gameluk-node/join-a-network.md).

# Join a Network

To quickly stand up a fresh full node and join in the network, it's recommended to sync through **state sync.**&#x20;

## Install GameID Binary

To stand up a Gameluk node, the first step is to download and install GameID on your machine.

The source code can be found in <https://github.com/GameLuk/gameluk-core>

Make sure you checkout and install the same version as the chain you want to join.

```
export VERSION=v3.0.9
export CHAIN_ID="atlantic-2"
export MONIKER="replace-with-your-moniker-name"

git clone https://github.com/gameluk-protocol/gameluk-chain.git
git checkout $VERSION
cd gameluk-chain
make install
gameid init --chain-id "$CHAIN_ID" "$MONIKER"
```

## State Sync

**State sync** allows a new node to join a network by fetching a snapshot of the application state at a recent height instead of fetching and replaying all historical blocks. This can reduce the time needed to sync with the network from days to minutes.&#x20;

### Clean Up

If you are not starting a node from fresh, then you need to do some backups and clean ups.&#x20;

```
# Assuming your gameluk home directory is /root/.gameluk
# backup priv_validator_state.json
cp /root/.gameluk/data/priv_validator_state.json /root/priv_validator_state.json
# backup priv_validator_key.json
cp /root/.gameluk/config/priv_validator_key.json /root/priv_validator_key.json
# backup genesis.json
cp /root/.gameluk/config/genesis.json /root/genesis.json
rm -rf /root/.gameluk/data/*
rm -rf /root/.gameluk/wasm
rm -rf /root/.gameluk/config/priv_validator_key.json
rm -rf /root/.gameluk/config/genesis.json
```

Note: this step is not needed for fresh nodes

### Update Configurations

1. Set up rpc servers for primary and secondary endpoints. You can use one of the RPC endpoint as primary and secondary in Resources page

```
# Example: Set polkachu rpc as rpc-servers
PRIMARY_ENDPOINT=https://gameluk-testnet-rpc.polkachu.com:443
sed -i.bak -e "s|^rpc-servers *=.*|rpc-servers = \"$PRIMARY_ENDPOINT,$PRIMARY_ENDPOINT\"|" ~/.gameluk/config/config.toml
```

2. Set up trust height and trust hash. Each snapshot is created at a certain block height, and best practice here is to set the trust height to be earlier than the latest snapshot block height to avoid backward verifications.

```
# Example: set trust height and hash to be the block height 10,000 earlier
PRIMARY_ENDPOINT=https://gameluk-testnet-rpc.polkachu.com:443
TRUST_HEIGHT_DELTA=10000
LATEST_HEIGHT=$(curl -s "$PRIMARY_ENDPOINT"/block | jq -r ".block.header.height")
if [[ "$LATEST_HEIGHT" -gt "$TRUST_HEIGHT_DELTA" ]]; then
  SYNC_BLOCK_HEIGHT=$(($LATEST_HEIGHT - $TRUST_HEIGHT_DELTA))
else
  SYNC_BLOCK_HEIGHT=$LATEST_HEIGHT
fi
# Get trust hash
SYNC_BLOCK_HASH=$(curl -s "$PRIMARY_ENDPOINT/block?height=$SYNC_BLOCK_HEIGHT" | jq -r ".block_id.hash")
# Override configs
sed -i.bak -e "s|^trust-height *=.*|trust-height = $SYNC_BLOCK_HEIGHT|" ~/.gameluk/config/config.toml
sed -i.bak -e "s|^trust-hash *=.*|trust-hash = \"$SYNC_BLOCK_HASH\"|" ~/.gameluk/config/config.toml
```
