fix comments

This commit is contained in:
fryorcraken 2024-10-14 16:14:52 +11:00
parent 5337e9a2d3
commit 1c2b6f1ee3
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
4 changed files with 31 additions and 113 deletions

View File

@ -60,7 +60,7 @@ You can either run a script that will estimate and set a good value:
Or select your own value. For example, `50GB`:
```shell
echo "export STORAGE_SIZE=50GB" >> .env
echo "STORAGE_SIZE=50GB" >> .env
```
### 🖥️ 3. Start your node
@ -69,7 +69,7 @@ Start all processes: nwaku node, database and grafana for metrics. Your [RLN](ht
```console
docker-compose up -d
```
⚠️ The node might take ~5s the very first time it runs because it needs to build locally the RLN community membership tree.
⚠️ The node might take a few minutes the very first time it runs because it needs to build locally the RLN community membership tree.
###🏄🏼‍♂️ 4. Interact with your nwaku node
@ -127,6 +127,15 @@ Updating the node is as simple as running the following:
3. `git pull origin master`
4. `docker-compose up -d`
### Set size
To improve storage on the network, you can increase the allocated space for the database.
To do so, you can simply run:
```
./set_storage_retention.sh
```
### Check
Once done, check your node is healthy:

View File

@ -1,23 +1,23 @@
#!/bin/sh
# args <available space on disk MB> <size of existing postgresql dir MB> <leeway MB> <min storage size MB> <max storage size MB>
# args <available space on disk MB> <size of existing postgresql dir MB> <margin MB> <min storage size MB> <max storage size MB>
# set SELECTED_STORAGE_SIZE_MB
select_store_size()
{
_AVAIL_SPACE_MB=$1
_PGSQL_SIZE_MB=$2
_LEEWAY_MB=$3
_MARGIN_MB=$3
_MIN_SIZE_MB=$4
_MAX_SIZE_MB=$5
unset SELECTED_STORAGE_SIZE_MB
if [ -z "$_AVAIL_SPACE_MB" ] || [ -z "$_PGSQL_SIZE_MB" ] || [ -z "$_LEEWAY_MB" ] || [ -z "$_MIN_SIZE_MB" ] || [ -z "$_MAX_SIZE_MB" ]; then
if [ -z "$_AVAIL_SPACE_MB" ] || [ -z "$_PGSQL_SIZE_MB" ] || [ -z "$_MARGIN_MB" ] || [ -z "$_MIN_SIZE_MB" ] || [ -z "$_MAX_SIZE_MB" ]; then
>&2 echo "Internal error, not enough arguments passed to select_store_size"
fi
_USABLE_SPACE_MB=$(( _AVAIL_SPACE_MB + _PGSQL_SIZE_MB ))
# Give all the available space to the DB, minus what is already used and 3GB for logs etc
_TARGET_MB=$(( _USABLE_SPACE_MB - _LEEWAY_MB))
_TARGET_MB=$(( _USABLE_SPACE_MB - _MARGIN_MB))
if [ $_TARGET_MB -lt $_MIN_SIZE_MB ]; then
>&2 echo "Flooring storage retention to ${_MIN_SIZE_MB}MB"
@ -34,7 +34,7 @@ select_store_size()
if [ "$1" = "test" ]; then
echo "Running tests"
i=0
# avail pgdir leew min max
# avail pgdir marg min max
echo "test $i"; i=$(( i + 1)); select_store_size 10000 0 1000 1000 20000; [ "$SELECTED_STORAGE_SIZE_MB" -eq 9000 ] || echo "fail: $SELECTED_STORAGE_SIZE_MB"
echo "test $i"; i=$(( i + 1)); select_store_size 5000 5000 1000 1000 20000; [ "$SELECTED_STORAGE_SIZE_MB" -eq 9000 ] || echo "fail: $SELECTED_STORAGE_SIZE_MB"
echo "test $i"; i=$(( i + 1)); select_store_size 30000 10000 1000 1000 20000; [ "$SELECTED_STORAGE_SIZE_MB" -eq 20000 ] || echo "fail: $SELECTED_STORAGE_SIZE_MB"
@ -68,11 +68,15 @@ if [ -d "./postgresql" ]; then
SUDO="sudo"
fi
PGSQL_SIZE_MB=$($SUDO du -sBM "./postgresql" | awk '{ print $1 }' | sed 's/^\([0-9]\+\)M$/\1/')
PGSQL_SIZE_MB=$($SUDO du -sm "./postgresql" | awk '{ print $1 }' | sed 's/^\([0-9]\+\)M$/\1/')
fi
AVAIL_SPACE_MB=$(df -BM . | tail -1 | awk '{ print $4 }' | sed 's/^\([0-9]\+\)M$/\1/')
AVAIL_SPACE_MB=$(df -m . | tail -1 | awk '{ print $4 }' | sed 's/^\([0-9]\+\)M$/\1/')
# Select a store size with the following constraints:
# - Margin: 1GB - 1GB will be left over for the system and logs
# - Min: 1GB - The minimum allocated space will be 1GB (old default)
# - Max: 30GB - The maximum allocated space will be 30GB
select_store_size $AVAIL_SPACE_MB $PGSQL_SIZE_MB 1024 1024 $(( 30 * 1024 ))
if [ -z "$SELECTED_STORAGE_SIZE_MB" ]; then

View File

@ -1,18 +1,22 @@
#!/bin/sh
if [ -f ./.env ] \
|| [ -f keystore/keystore.json ] ; then
echo "Artefacts already existing, exiting wizard"
if [ -f ./.env ] ; then
echo "'./.env\` already exists, exiting wizard"
exit 1
fi
if [ -f keystore/keystore.json ] ; then
echo "'keystore/keystore.json\` already exists, exiting wizard"
exit 1
fi
if [ -z "$(which docker 2>/dev/null)" ]; then
echo "Ensure that 'docker' is installed and PATH"
echo "Ensure that 'docker\` is installed and in \$PATH"
exit 1
fi
if [ -z "$(which docker-compose 2>/dev/null)" ]; then
echo "Ensure that 'docker-compose' is installed and PATH"
echo "Ensure that 'docker-compose' is installed and in \$PATH"
exit 1
fi

View File

@ -1,99 +0,0 @@
#!/bin/sh
if [ -f ./.env ] \
|| [ -f keystore/keystore.json ] ; then
echo "Artefacts already existing, exiting wizard"
exit 1
fi
if [ -z "$(which docker 2>/dev/null)" ]; then
echo "Ensure that 'docker' is installed and PATH"
exit 1
fi
if [ -z "$(which docker-compose 2>/dev/null)" ]; then
echo "Ensure that 'docker-compose' is installed and PATH"
exit 1
fi
echocol()
{
COL='\033[0;32m'
NC='\033[0m'
printf "$COL${1}${NC}\n"
}
echocol "##############################"
echocol "#### nwaku-compose wizard ####"
echocol "##############################"
echocol "First, you need a RPC HTTP endpoint for Ethereum Sepolia"
echocol "If you don't have one, try out https://www.infura.io/"
echocol "Expected format is https://sepolia.infura.io/v3/<api key>:"
read -r RLN_RELAY_ETH_CLIENT_ADDRESS
if [ -z "$RLN_RELAY_ETH_CLIENT_ADDRESS" ] \
|| [ $(echo "$RLN_RELAY_ETH_CLIENT_ADDRESS" | grep -c "^https:") -eq 0 ]; then
echo "Invalid value, received '$RLN_RELAY_ETH_CLIENT_ADDRESS'"
exit 1
fi
echocol "...."
echocol "Double check you have some Eth Sepolia, at least 0.01Eth."
echocol "If not, you can use this faucet: https://www.infura.io/faucet/sepolia"
echocol "Now enter your SEPOLIA TESTNET private key in hex format 0a...1f without 0x prefix"
read ETH_TESTNET_KEY
if [ -z "$ETH_TESTNET_KEY" ] \
|| [ $(echo -n "$ETH_TESTNET_KEY" | grep -c '^[0-9a-fA-F]\{64\}$' ) -ne 1 ]; then
echo "Invalid value, received '$ETH_TESTNET_KEY'"
exit 1
fi
echocol "...."
echocol "Generating a password for the RLN membership keystore file..."
RLN_RELAY_CRED_PASSWORD=$(< /dev/urandom tr -dc ',/.;:<>?!@#$%^&*()+\-_A-Z-a-z-0-9' | head -c${1:-16};echo;)
echocol "...."
echocol "Selecting a size for DB..."
STORAGE_SIZE=$(./set_storage_retention.sh echo-value)
if [ -z "$STORAGE_SIZE" ]; then
echo "Error encountered when estimating storage size, exiting"
exit 1
fi
echocol "...."
echocol "The following parameters will be saved to your .env file. Press ENTER to confirm or quit with CONTROL-C to abort:"
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
STORAGE_SIZE=$STORAGE_SIZE"
read foo
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
STORAGE_SIZE=$STORAGE_SIZE" > ./.env
SUDO=""
if ! docker info > /dev/null 2>&1; then
echocol "...."
echocol "'sudo' seems to be needed to run docker, your unix password will be asked"
SUDO="sudo"
fi
echocol "...."
echocol "Registering an RLN membership..."
if ! $SUDO ./register_rln.sh; then
echocol "###"
echocol "Failed to register RLN membership, usually due to high gas fee"
echocol "Double check you have enough Sepolia eth and run the following command:"
echocol "$SUDO ./register_rln.sh"
echocol "###"
exit 1
fi
echocol "...."
echocol "Starting your nwaku node... your password may be needed for sudo"
$SUDO docker-compose up -d