Skip to content

Commit

Permalink
Pocket Network Update (#426)
Browse files Browse the repository at this point in the history
* Rename pokt_network to pokt-network

* Update pocket network deployment details
  • Loading branch information
Olshansk authored Aug 1, 2023
1 parent 48dd7d1 commit c3658cb
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 275 deletions.
131 changes: 131 additions & 0 deletions pokt-network/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# POKT Network node on Akash Network <!-- omit in toc -->

- [Resources](#resources)
- [Развертка ноды POKT Network на Akash Network](#развертка-ноды-pokt-network-на-akash-network)
- [Ресурсы](#ресурсы)

<!-- TODO(@Olshansk, @kdas): Move over the notes related to testing & TLS from https://www.notion.so/pocketnetwork/Akash-Pocket-Network-9e63cc6c1275448f914c14ed31886d9e?pvs=4 -->

Fill in the variables in the [SDL file](/pokt_network/deploy.yml):

| Variable | Description |
| :--------------: | :-------------------------------------------------------------------------------------------------------------------------: |
| `SSH_PASS` | Password to connect to the node via SSH (root user). |
| `VERSION` | Set actual version POKT Network. |
| `CHAIN` | Set POKT chain, **mainnet** or **testnet**. |
| `KEYFILE_BASE64` | Encrypted contents of the keyfile.json file using BASE64. |
| `KEY_PASS` | Password to keyfile.json. |
| `ADDRESS` | Account address. |
| `CHAINS_LINK` | Link to download chains.json file, or use CHAINS_BASE64 to transfer the contents of the chains.json file in encrypted form. |
| `SEEDS` | Set seeds [address](https://docs.pokt.network/node/seeds/) . |

## Resources

- If you want use **ephimeral** storage (_WARNING! Data will be lost when the container is restarted!_):

```yaml
profiles:
compute:
app:
resources:
cpu:
units: 4.0
memory:
size: 24Gi
storage:
size: 500Gi
```
- If you want use **persistens** storage:
1. Uncomment in `app` section:

```yaml
params:
storage:
data:
mount: /root/
```

2. Uncomment in `profiles` section:

```yaml
profiles:
compute:
app:
resources:
cpu:
units: 4.0
memory:
size: 16Gi
storage:
size: 10Gi
- name: data
size: 500Gi
attributes:
persistent: true
class: beta3
```

## Развертка ноды POKT Network на Akash Network

Заполните переменные в [SDL файле](/pokt_network/deploy.yml):

| Переменная | Описание |
| :--------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| `SSH_PASS` | Пароль, для подключения к контейнеру по протоколу SSH (пользователь root). |
| `VERSION` | Установите актуальную версию POKT Network. |
| `CHAIN` | Установите нужную цепочку, **mainnet** или **testnet**. |
| `KEYFILE_BASE64` | Зашифрованное содержимое файла keyfile.json с помощью BASE64. |
| `KEY_PASS` | Пароль от keyfile.json. |
| `ADDRESS` | Адрес аккаунта. |
| `CHAINS_LINK` | Ссылка для скачивания файла chains.json file, или используйте CHAINS_BASE64 для доставки содержимого chains.json внутрь контейнера в зашифрованном ввиде с помощью BASE64 . |
| `SEEDS` | Установите перечени SEED нод, [доступно на сайте](https://docs.pokt.network/node/seeds/). |

### Ресурсы

- Если вы хотите использовать **эфимерное** хранилище (_ПРЕДУПРЕЖДЕНИЕ! При перезагрузке контейнера данные будут сброщшены!_):

```yaml
profiles:
compute:
app:
resources:
cpu:
units: 8
memory:
size: 24Gi
storage:
- size: 300Gi
```

- Если вы хотите использовать **постоянное** хранилище:

1. Раскомментируйте в секции `app`:

```yaml
params:
storage:
data:
mount: /root/
```

2. Раскомментируйте в секции `profiles`:

```yaml
profiles:
compute:
app:
resources:
cpu:
units: 4.0
memory:
size: 24Gi
storage:
size: 10Gi
- name: data
size: 500Gi
attributes:
persistent: true
class: beta3
```
56 changes: 56 additions & 0 deletions pokt-network/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
version: "2.0"
services:
app:
image: ubuntu:22.04
env:
- "SSH_PASS=" # If you need SSH access to the container(user root), set this variable;
- "VERSION=RC-0.10.4" # Set actual version POKT;
- "CHAIN=" #Set POKT chain, mainnet or testnet;
- "KEYFILE_BASE64=" # Encrypted contents of the keyfile.json file using BASE64;
- "KEY_PASS=" # Password to keyfile.json;
- "ADDRESS=" # Account address;
- "CHAINS_LINK=" # Link to download chains.json file, or use CHAINS_BASE64 to transfer the contents of the chains.json file in encrypted form;
- "SEEDS=7c0d7ec36db6594c1ffaa99724e1f8300bbd52d0@seed1.mainnet.pokt.network:26662,cdcf936d70726dd724e0e6a8353d8e5ba5abdd20@seed2.mainnet.pokt.network:26663,74b4322a91c4a7f3e774648d0730c1e610494691@seed3.mainnet.pokt.network:26662,b3235089ff302c9615ba661e13e601d9d6265b15@seed4.mainnet.pokt.network:26663" # Set seeds address https://docs.pokt.network/node/seeds/ ;
command:
- bash
- "-c"
args: # Make sure this gist does not mention a "revision" (hash) of the gist so the next time the container boots it can get newer version of the script. This field is immutable.
- >-
apt-get update && apt-get upgrade -yqq; apt-get install -yqq curl; curl -s
https://raw.githubusercontent.com/akash-network/awesome-akash/master/pokt_network/main.sh | bash
expose:
- port: 8081
to:
- global: true
as: 80
# # If you wish to bring your own domain, uncomment the following line and replace the domain name with your own.
# accept:
# - poktonakt.spankpool.com
- port: 26656
to:
- global: true
- port: 22
to:
- global: true
profiles:
compute:
pokt-node:
resources:
cpu:
units: 8
memory:
size: 24Gi
storage:
- size: 300Gi
placement:
akash:
pricing:
pokt-node:
denom: uakt
amount: 10000
deployment:
pokt-node:
akash:
profile: pokt-node
count: 1
File renamed without changes.
114 changes: 114 additions & 0 deletions pokt-network/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash
TZ=Europe/London && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
apt-get install -y -qq wget gcc make git nvme-cli nano unzip runit pv aria2 lz4
runsvdir -P /etc/service &
if [[ -n $SSH_PASS ]]
then
apt-get install -y ssh
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && (echo $SSH_PASS; echo $SSH_PASS) | passwd root && service ssh restart
fi

if ! [ -x "$(command -v go)" ]; then
wget https://go.dev/dl/go1.20.1.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.1.linux-amd64.tar.gz
PATH=$PATH:/usr/local/go/bin && echo $PATH
go version && echo 'export PATH='$PATH:/usr/local/go/bin >> /root/.bashrc
fi

mkdir -p /root/.pocket/config

if [ ! -d "pocket-core" ]; then
git clone https://github.com/pokt-network/pocket-core.git
fi

cd pocket-core

# Fetch all tags from the remote
git fetch --tags

# If the current checked out tag isn't the specified version, switch to it
CURRENT_TAG=$(git describe --tags)
if [ "$CURRENT_TAG" != "$VERSION" ]; then
git checkout tags/$VERSION
# Build the binary for the new tag
go build -o /usr/bin/pocket /pocket-core/app/cmd/pocket_core/main.go && pocket version
fi

# ============================= Setting a custom keyfile.json =======================
if [[ -n $KEYFILE_BASE64 ]]
then
echo $KEYFILE_BASE64 | base64 -d > /tmp/keyfile.json
apt-get install -y expect
cat > /root/import <<EOF
#!/usr/bin/expect -f
spawn pocket accounts import-armored /tmp/keyfile.json
expect "Enter decrypt pass"
send "$KEY_PASS\r"
expect "Enter decrypt pass"
send "$KEY_PASS\r"
expect eof
EOF
chmod +x /root/import && /root/import

cat > /root/create_validator <<EOF
#!/usr/bin/expect -f
spawn pocket accounts set-validator $ADDRESS
expect "Enter the password:"
send "$KEY_PASS\r"
expect eof
EOF
chmod +x /root/create_validator && /root/create_validator
pocket accounts get-validator
rm /root/create_validator /root/import /tmp/keyfile.json
fi
# =================================================================================
if [[ -n $CHAINS_LINK ]]
then
wget -O /root/.pocket/config/chains.json $CHAINS_LINK
fi
if [[ -n $CHAINS_BASE64 ]]
then
echo $CHAINS_BASE64 | base64 -d > /root/.pocket/config/chains.json
fi
mkdir -p $HOME/.pocket/config

# This errors due to missing GENESIS_LINK envar, but this doesn't seem to be needed for the mainnet?
curl -o $HOME/.pocket/config/genesis.json $GENESIS_LINK

echo "== Downloading snapshot =="

mkdir -p $HOME/.pocket/data
if [ ! "$(ls -A $HOME/.pocket/data)" ]; then
echo "No data in $HOME/.pocket/data. Downloading..."
latestFile=$(curl https://pocket-snapshot.liquify.com/files/pruned/latest.txt)
echo "Downloading the snapshot"
curl -s "https://pocket-snapshot.liquify.com/files/pruned/$latestFile" | tar xf - -C "$HOME/.pocket"
else
echo "Data exists in $HOME/.pocket/data. Skipping download."
fi

echo "== Finished Downloading snapshot =="

echo "=== Run node ==="
mkdir -p /root/pocket/log
cat > /root/pocket/run <<EOF
#!/bin/bash
exec 2>&1
exec pocket start --simulateRelay --seeds="$SEEDS" --$CHAIN
EOF
mkdir /tmp/log/
cat > /root/pocket/log/run <<EOF
#!/bin/bash
exec svlogd -tt /tmp/log/
EOF
chmod +x /root/pocket/log/run /root/pocket/run
ln -s /root/pocket /etc/service && ln -s /tmp/log/current /LOG

sleep 20
for ((;;))
do
tail -100 /LOG && sleep 5m
done
fi
fred-icon
AskFred
dragger-icon
Loading

0 comments on commit c3658cb

Please sign in to comment.