Skip to content

Commit

Permalink
add develop docs deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
wanwiset25 committed Oct 2, 2024
1 parent 571fb16 commit 7c85207
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 260 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/docusaurus-deploy-develop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- main
- develop

jobs:
deploy:
Expand All @@ -14,11 +14,15 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 18

- name: Install dependencies
run: npm install

- name: reconfig docusaurus baseUrl
run: |
sed -i 's|baseUrl: '\''/xdc-subnet-docs/'\''|baseUrl: '\''/xdc-subnet-docs/develop/'\''|' docusaurus.config.js
- name: Build site
run: npm run build

Expand All @@ -27,4 +31,5 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
publish_branch: gh-pages
publish_branch: gh-pages
destination_dir: develop
7 changes: 3 additions & 4 deletions .github/workflows/docusaurus-deploy-main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- develop
- main

jobs:
deploy:
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 18

- name: Install dependencies
run: npm install
Expand All @@ -27,5 +27,4 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
publish_branch: gh-pages
destination_dir: develop
publish_branch: gh-pages
68 changes: 35 additions & 33 deletions docs/deployment/1_launch_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,60 @@ sidebar_position: 1

# Launch a Subnet

## Overview
For the convenience of deploying Subnet, we have provided the Subnet Deployment Generator. The Subnet Deployment Generator is configuration generator for all components of subnet deployment. It generates all the necessary files and configs from a simple initial docker.env file. The required parameters are

1. How many machines will you use to deploy subnet?
2. How many subnet nodes will you deploy in total?
3. IP address of the main machine
4. Parentchain wallet with funds

In this setup the main machine (machine1) will host all the subnet services(relayer, stats, frontend) while the subnet miner nodes will be spread out among all machines.

The IP address of the main machine is needed for subnet connectivity, this is the IP that is known to all other machines, could be private or public (preferrably private)

Once generated, the commands to startup the subnet is also provided as a generated `commands.txt` file.

The deployment is docker based, the main deployment file is `docker-compose.yml`. The `docker-compose.env` is the injection point to all configs. Then, ENVs for the services and subnet nodes are in `*.env` files. Other files include `genesis.json` file to initialize subnet chain, `deployment.json` to deploy the checkpoint smartcontract, and `keys.json` the keypairs for subnet nodes + grandmaster node. Again, these files will be generated by the Subnet Deployment Generator (SDG).

## Requirements
- OS: Linux. Only Linux is supported for full deployment.
- OS: Linux. Only Linux is supported for full deployment.

- OS: Mac is only supported for single machine testing environment. Specify MacOS with 'OS=mac' in 'docker.env' file. Please also refer [common issues](./2_debug_guide.md#common-issues).
- OS: Mac is only supported for single machine testing environment.

- docker, docker compose V2. For manual installation of docker compose V2 please refer to: https://docs.docker.com/compose/install/linux/

## Steps
1. Create a `docker.env` file with parameters similar to [`docker.env.example`](https://github.com/XinFinOrg/XinFin-Node/blob/master/subnet/deployment-generator/script/docker.env.example). Detailed parameters explanation [here](./3_configs_explanation.md).
- Recommended Hardware (per single Subnet node):
- CPU: 2 Core
- Memory: 4 GB

2. Pull the `generator.sh` script from the generator Github repo
- Web3 wallet with funds. For testing we have faucets provided:
- https://faucet.apothem.network/
- https://faucet.blocksscan.io/

## Generate Subnet Configs With UI

1. Pull `generator.sh` script from the generator Github repo
```
curl -O https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/subnet/deployment-generator/script/generate.sh
curl -O https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/generator-ui-concept/subnet/deployment-generator/scripts/generate.sh
```

3. Generate configurations, this will create a new `generated` directory
2. Run the configuration generator, this will start a local webserver
```
chmod +x generate.sh
./generate.sh
cd generated
```

4. follow the generated instructions in `commands.txt` to start Subnet Nodes and [make sure they are mining](./2_debug_guide.md#subnet-nodes).
3. Go to [http://localhost:3000/](http://localhost:3000) in your browser. If you are running the generator on a remote server you can first use ssh tunnel: `ssh -N -L localhost:3000:localhost:3000 <username>@<ip_address> -i <private_key_file>`

4. Config the Subnet options per your requirement.
![UI](./img/ui.png)

5. follow the generated instructions in `commands.txt` to deploy the upgradable Checkpoint Smart Contract(CSC). If CSC deployment was successful, you should see CSC addresses in `common.env`, the added ENVs include `PROXY_GATEWAY`, `FULL_CSC`, `LITE_CSC`, `CHECKPOINT_CONTRACT`.
5. follow the generated instructions in `commands.txt`. In general, the steps are:
- start Subnet Nodes
- deploy CSC
- deploy XDC-Zero (optional)
- start Subnet Services (relayer, stats-server, frontend)

6. follow the generated instructions in `commands.txt` to start the Subnet Services (relayer, stats-server, frontend)
6. Once successfully deployed, you can check out [UI usage guide](./../usage/1_homepage.md)

7. Check out the Subnet UI at `<MAIN_IP>:5555`
## Removing Subnet

### Removing Subnet
1. Change the commands in `commands.txt` to `docker compose ... down`
### Shutdown Subnet
Under `generated` directory
```
docker compose --env-file docker-compose.env --profile <profile_name> down
docker compose --env-file docker-compose.env --profile services down
docker compose --env-file docker-compose.env --profile machine1 down
```

2. Repeat 1. for every docker `--profile` that was started.

3. Inside `generated` directory, remove `bootnodes`, `stats-service`, and `xdcchain*` directories
### Deleting Subnet
Remove `xdcchain*`, `bootnodes`, and `stats-service` directories
Warning: this cannot be undone
```
rm -rf xdcchain* bootnodes stats-service
```
94 changes: 0 additions & 94 deletions docs/deployment/2_debug_guide.md

This file was deleted.

7 changes: 7 additions & 0 deletions docs/deployment/2_faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_label: "2. FAQ"
sidebar_position: 2
---

# FAQ
## WIP
90 changes: 0 additions & 90 deletions docs/deployment/3_configs_explanation.md

This file was deleted.

16 changes: 16 additions & 0 deletions docs/deployment/3_troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
sidebar_label: "3. Troubleshooting"
sidebar_position: 3
---

# Debug guide (how to know if my subnet is running?)
## Common Issues

1. Subnet node does not boot with error log `Fatal: Error starting protocol stack: listen unix /work/xdcchain/XDC.ipc: bind: invalid argument`

This is due to the volume mount path being too long. The mounth path is your current directory (also can check with `pwd` command). Please move the `generated` folder to a shorter path and try again.

2. Docker image startup fails with `SIGKILL` or `Error code: 137` found in logs. (Issue found in Frontend image)

This error occurs because Docker ran Out Of Memory (OOM). You can increase the memory limit in [Docker settings](https://docs.docker.com/desktop/settings/mac/#:~:text=lower%20the%20number.-,Memory,-.%20By%20default%2C%20Docker)

Loading

0 comments on commit 7c85207

Please sign in to comment.