Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rykcod/massa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: DEVN.28.1
Choose a base ref
...
head repository: rykcod/massa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
40 changes: 40 additions & 0 deletions .github/workflows/docker-image-devn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Massa

on:
push:
tags:
- DEVN.*

jobs:

build:
runs-on: ubuntu-latest

env:
VERSION: ${{ github.ref_name }}

steps:
- name: Checkout the source code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
build-args: VERSION=${{ env.VERSION }}
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ github.repository }}:${{ env.VERSION }}

Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@ name: Massa
on:
push:
tags:
- TEST.*
- DEVN.*
- MAIN.*

jobs:

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/Paris"
# Update and install packages dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt install -y curl wget screen procps python3-pip netcat \
&& apt install -y curl wget screen procps python3 \
&& apt autoclean -y

# Download the Massa package
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Dockyr

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Massa node + Massa-guard #
**Last build for Massa Securenet 27.6**
**Last build for Massa Mainnet 2.4**

![alt text](https://d33wubrfki0l68.cloudfront.net/7df7d7a57a8dda3cc07aab16121b3e3990cf0893/16ccd/portfolio/massa.png)

@@ -10,31 +10,35 @@ Build a massa-node container wich include some automation features from a commun
This image include a script named "**/massa-guard/massa-guard.sh**" to:
- [GENERAL]
- Enable/Disable all massa-guard features (Except keys creations) with the "MASSAGUARD" setting in config.ini
- Link node storage files to massa_mount
- [AUTOBUY/AUTOSELL]
- Autobuy 1 roll when your node failed and lost his "Active rolls".
- Autobuy X rolls when your MAS amount greater than 200 MAS and if "Active rolls" dont exceed "TARGET_ROLL_AMOUNT" set in /massa_mount/config/config.ini (If set).
- Autosell X rolls when "Active rolls" exceed "TARGET_ROLL_AMOUNT" set in /massa_mount/config/config.ini (If set).
- Autobuy X rolls when your MAS amount greater than 100 MAS and if "Active rolls" dont exceed "TARGET_ROLL_AMOUNT", if value set in /massa_mount/config/config.ini.
- Autosell X rolls when "Active rolls" exceed "TARGET_ROLL_AMOUNT", if value set in /massa_mount/config/config.ini.
- [WATCHDOG]
- Restart node when hang or when ram consumption exceed 90% (Value can be adjust)
- You host your node under a dynamical IP? massa-guard will watch IP change and update your config.toml and push IP updates to massabot.
- Logs his actions over /massa_mount/logs/ and backup node logs before restart if necessary.
- [STARTING]
- Logs actions over /massa_mount/logs/ and backup node logs before restart if necessary.
- Push events over discord Webhook
- [STARTING FROM SCRATCH]
- Massa-guard will auto create wallet + nodekey + stacke privkey; all with default password "**MassaToTheMoon2022**".
- Massa-guard auto create your config.toml with your public IP.

### [RELEASE NOTES] ###
- 20240102 - Securenet - v27.6.0 - Securenet - v27.6 + Cleanup deprecated feature.
- 20231202 - Testnet 27 - v27.4.0 - Testnet 27 - v27.6 Ready
- 20230908 - Testnet 26 - v26.1.1 - Testnet 26 - Solve backup/Restore new wallet format
- 20230616 - Testnet 23 - v23.2.0 - Testnet 23 - Add disable logs Feature with NODE_LOGS settings.
- 20230309 - Testnet 20 - v20.2.0 - Testnet 20 - v20.2 Ready! Please note you will need to create a new wallet for this Testnet.
- 20230210 - Testnet 19 - v19.3.0 - Testnet 19 - v19.3 Ready! Somes modications after massa testnet 19.0 cmd updates.
- 20221123 - Testnet 16 - v16.1.0 - Testnet 16 - v16.1 Ready! Remove deprecated [BOOTSTRAPFINDER] features
- 20241124 - Mainnet - v2.4 - Mainnet - Update to mainnet 2.4
- 20240717 - Mainnet - v2.3 - Mainnet - Update to mainnet 2.3
- 20240622 - Mainnet - v2.2 - Mainnet - Update to mainnet 2.2
- 20240517 - Mainnet - v2.1.1 - Mainnet - Add 0.01 MAS for buy and sell rolls action
- 20240124 - Mainnet - v2.1.0 - Mainnet - v2.1 Ready + Add multiwallets availability + Discord webhook Push logs feature + Deport node storage to massa_mount
- 20240110 - Mainnet - v2.0.0 - Mainnet - v2.0 Ready + Remove useless dependencies + Add multi wallet autobuy features
- 20240105 - Mainnet - v1.0.0 - Mainnet - v1.0 Ready !!! + Change [network] label to [protocol] into new config.toml + ADD RESCUE_MAS_AMOUNT setting into config.ini
- 20240103 - Devnet - v28.2.0 - Devnet - v28.2 Ready

## [HOWTO] ##
### [SETUP] ###
#### [PREPARE] ####
Create an empty folder to mount in our container /massa_mount path or store your wallet /nodekey/stacking_key/config.toml into this folder if you have it:
Just create an empty folder to mount into our container /massa_mount path and run!
Or restore your wallet(s) and/or nodekey and/or config.toml into this folder if you have it:
- wallet_%%%.dat
- config.toml
- node_privkey.key
@@ -78,11 +82,12 @@ __[OPTION] To enable or update features after container creation just edit /mass
* Set your ''TARGET_ROLL_AMOUNT'' value to enable roll amount target to stake for your node (Integer value)
* Set your ''MASSAGUARD'' value to enable or disable massa-guard features 0=Disable 1=Enable (Enable by default)
* Set your ''NODE_LOGS'' value to disable logs files (0=Disable 1=Enable). Default value 1.
* Set your ''RESCUE_MAS_AMOUNT'' value to save capacity to buy a roll if your node going to disqualify. Default value 0.
* Set your ''DISCORD_WEBHOOK'' to push log events to Discord channel with webhook. Default value 0.

### [HELP] ###
- Massa client is running over a "screen" named "massa-client"
- Massa node is running over a "screen" named "massa-node"
- To get your discord token, refer to https://shufflegazine.com/get-discord-token/

#### [LOGS PATH] ####
- Massa-guard actions and events are logs into %MountPoint%/logs/massa-guard/%DATE%-massa_guard.txt
@@ -111,5 +116,5 @@ For more informations and sources - https://github.com/rykcod/massa/
#### [VIDEO TUTORIAL][FR] ####
https://youtu.be/IzeRq43DBSQ

## [THANKS] ##
Thanks to **fsidhoum** for help
#### [THANKS FOR YOUR SUPPORT] ####
MASSA Address - AU1eNMGrjLTrUoQAhGNqr1ehwhdMCg5L9T3Bjcvfh3D9pswKsDAx
8 changes: 4 additions & 4 deletions config/default_config.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##################################################
##### System conf parameters of massa-guard ######
##################################################
# Chemin de base
# Main path
PATH_MASSA=/massa
# Mount path
PATH_MOUNT=/massa_mount
@@ -13,11 +13,11 @@ PATH_LOGS_MASSANODE="$PATH_MOUNT"/logs/massa-node
PATH_LOGS_MASSAGUARD="$PATH_MOUNT"/logs/massa-guard
# Conf custom massa-guard path
PATH_CONF_MASSAGUARD="$PATH_MOUNT"/config
# Chemin ou se trouve les sources de massa-client
# Path where find massa-client
PATH_CLIENT="$PATH_MASSA"/massa-client
# Chemin ou se trouve les sources de massa-node
# Path where find massa-node
PATH_NODE="$PATH_MASSA"/massa-node
# Chemin ou se trouve les sources de configuration de massa-node
# # Path where find config.toml
PATH_NODE_CONF="$PATH_NODE"/config
# Chemin ou se trouve la version compilee de massa-client
PATH_TARGET=.
6 changes: 5 additions & 1 deletion config/default_config_template.ini
Original file line number Diff line number Diff line change
@@ -14,4 +14,8 @@ DYN_PUB_IP=0
# Node password (If ENV not set, default value is MassaToTheMoon2022)
NODE_PWD="MassaToTheMoon2022"
# Wallet password (If ENV not set, default value is MassaToTheMoon2022)
WALLET_PWD="MassaToTheMoon2022"
WALLET_PWD="MassaToTheMoon2022"
# Set rescue MAS amount to buy new roll if node disqualified (Due disconnected or server hang)
RESCUE_MAS_AMOUNT=0
# Set Discord webhook to push events. Example DISCORD_WEBHOOK="https://discord.com/api/webhooks/XXXXXXXXXXXXXXX"
DISCORD_WEBHOOK=0
46 changes: 37 additions & 9 deletions massa-guard.sh
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ WaitBootstrap
#====================== Check and load ==========================#
# Load Wallet and Node key or create it and stake wallet
CheckOrCreateWalletAndNodeKey
# Get stacking address
WalletAddress=$(GetWalletAddress)
# Get stacking addresses
WalletAddresses=($(GetWalletAddresses))

#==================== Massa-guard circle =========================#
# Infinite check
@@ -36,12 +36,30 @@ do
CheckAndReloadNode "$NodeRam" "$NodeResponsive"
if [ $? -eq 0 ]
then
# Get candidate rolls
CandidateRolls=$(GetCandidateRoll "$WalletAddress")
# Get MAS amount
MasBalance=$(GetMASAmount "$WalletAddress")
# Buy max roll or 1 roll if possible when candidate roll amount = 0
BuyOrSellRoll "$CandidateRolls" "$MasBalance" "$WalletAddress"
# If new day log file get wallets balance
if [ ! -e $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt ]
then
# Create log file of the day
touch $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
# For every wallets
for WalletAddress in "${WalletAddresses[@]}"; do
# Get candidate rolls
CandidateRolls=$(GetCandidateRoll "$WalletAddress")
# Get MAS amount
MasBalance=$(GetMASAmount "$WalletAddress")
# Log Wallet balance
LogWalletsBalance "$CandidateRolls" "$MasBalance" "$WalletAddress"
done
fi
# For each wallet addresses
for WalletAddress in "${WalletAddresses[@]}"; do
# Get candidate rolls
CandidateRolls=$(GetCandidateRoll "$WalletAddress")
# Get MAS amount
MasBalance=$(GetMASAmount "$WalletAddress")
# Buy max roll or 1 roll if possible when candidate roll amount = 0
BuyOrSellRoll "$CandidateRolls" "$MasBalance" "$WalletAddress"
done

# If logs are disable
if ([ $NODE_LOGS -eq 0 ] && [ -e $PATH_LOGS_MASSANODE/current.txt ])
@@ -63,9 +81,19 @@ do
then
CheckAndUpdateNode
fi

# Backup new wallet if new exist
BackupNewWallets

# Log events
if [ ! ${#Events[@]} -eq 0 ]
then
LogEvents "${Events[@]}"
unset Events
fi
fi
# Wait before next loop
sleep 2m
# Refresh configuration value
source <(grep = $PATH_CONF_MASSAGUARD/config.ini)
done
done
28 changes: 18 additions & 10 deletions sources/init_copy_host_files.sh
Original file line number Diff line number Diff line change
@@ -19,18 +19,18 @@ fi
if [ ! -e $PATH_CONF_MASSAGUARD/config.ini ]
then
mkdir -p $PATH_LOGS_MASSAGUARD
echo "[$(date +%Y%m%d-%HH%M)][INFO][INIT]CREATE $PATH_LOGS_MASSAGUARD folder" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][INIT]CREATE $PATH_LOGS_MASSAGUARD folder")
mkdir -p $PATH_LOGS_MASSANODE
echo "[$(date +%Y%m%d-%HH%M)][INFO][INIT]CREATE $PATH_LOGS_MASSANODE folder" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][INIT]CREATE $PATH_LOGS_MASSANODE folder")
mkdir -p /massa_mount/config
echo "[$(date +%Y%m%d-%HH%M)][INFO][INIT]CREATE /massa_mount/config folder" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][INIT]CREATE /massa_mount/config folder")
cp /massa-guard/config/default_config_template.ini $PATH_CONF_MASSAGUARD/config.ini
if [ $DYNIP ]; then python3 $PATH_SOURCES/set_config.py "DYN_PUB_IP" "$DYNIP" $PATH_CONF_MASSAGUARD/config.ini ; fi
if [ $NODEPWD ]; then python3 $PATH_SOURCES/set_config.py "NODE_PWD" \"$NODEPWD\" $PATH_CONF_MASSAGUARD/config.ini ; fi
if [ $WALLETPWD ]; then python3 $PATH_SOURCES/set_config.py "WALLET_PWD" \"$WALLETPWD\" $PATH_CONF_MASSAGUARD/config.ini ; fi
if [ $MASSAGUARD ]; then python3 $PATH_SOURCES/set_config.py "MASSAGUARD" \"$MASSAGUARD\" $PATH_CONF_MASSAGUARD/config.ini ; fi
if [ $AUTOUPDATE ]; then python3 $PATH_SOURCES/set_config.py "AUTOUPDATE" \"$AUTOUPDATE\" $PATH_CONF_MASSAGUARD/config.ini ; fi
echo "[$(date +%Y%m%d-%HH%M)][INFO][INIT]COPY default config.ini" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=('[INFO][INIT]COPY default config.ini')
fi
# Load config.ini
source <(grep = $PATH_CONF_MASSAGUARD/config.ini)
@@ -43,7 +43,7 @@ BackupLogsNode
if [ -e $PATH_MOUNT/config.toml ]
then
cp $PATH_MOUNT/config.toml $PATH_NODE_CONF/config.toml
echo "[$(date +%Y%m%d-%HH%M)][INFO][LOAD]LOAD $PATH_MOUNT/config.toml as ref" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][LOAD]Load $PATH_MOUNT/config.toml as ref")
# If ref config.toml dont exist in massa_mount
else
if [ $IP ]
@@ -52,33 +52,41 @@ else
else
myIP=$(GetPublicIP)
fi
echo "[network]" > $PATH_MOUNT/config.toml
echo "[protocol]" > $PATH_MOUNT/config.toml
echo "routable_ip = \"$myIP\"" >> $PATH_MOUNT/config.toml
echo -e "\n[execution]\n # path to the hard drive cache storage\n hd_cache_path = \"/massa_mount/storage/cache/rocks_db\"\n\n[ledger]\n # path to the disk ledger db directory\n disk_ledger_path = \"/massa_mount/storage/ledger/rocks_db\"" >> $PATH_MOUNT/config.toml
cp $PATH_MOUNT/config.toml $PATH_NODE_CONF/config.toml

echo "[$(date +%Y%m%d-%HH%M)][INFO][INIT]Create your default config.toml with $myIP as routable IP" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][INIT]Create your default config.toml with $myIP as routable IP")
fi
# Wallet to use
if [ $(ls $PATH_MOUNT/wallet_* 2>/dev/null | wc -l) -gt 0 ]
then
mkdir $PATH_CLIENT/wallets > /dev/null 2&>1
rm $PATH_CLIENT/wallets/wallet_* > /dev/null 2&>1
cp $PATH_MOUNT/wallet_* $PATH_CLIENT/wallets/
echo "[$(date +%Y%m%d-%HH%M)][INFO][LOAD]LOAD MOUNTED WALLET as ref" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=('[INFO][LOAD]Load mounted wallets as ref')
fi
# Node private key to use
if [ -e $PATH_MOUNT/node_privkey.key ]
then
# Delete default node_privkey and load ref node_privkey
if [ -e $PATH_NODE_CONF/node_privkey.key ]; then rm $PATH_NODE_CONF/node_privkey.key; fi
cp $PATH_MOUNT/node_privkey.key $PATH_NODE_CONF/node_privkey.key
echo "[$(date +%Y%m%d-%HH%M)][INFO][LOAD]LOAD $PATH_MOUNT/node_privkey.key as ref" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][LOAD]Load $PATH_MOUNT/node_privkey.key as ref")
fi
# Wallet to use to stacke
if [ $(ls $PATH_MOUNT/wallet_* 2>/dev/null | wc -l) -gt 0 ]
then
mkdir $PATH_NODE_CONF/staking_wallets > /dev/null 2&>1
rm $PATH_NODE_CONF/staking_wallets/wallet_* > /dev/null 2&>1
cp $PATH_MOUNT/wallet_* $PATH_NODE_CONF/staking_wallets/
echo "[$(date +%Y%m%d-%HH%M)][INFO][LOAD]LOAD MOUNTED WALLET as ref to stacke" |& tee -a $PATH_LOGS_MASSAGUARD/$(date +%Y%m%d)-massa_guard.txt
Events+=("[INFO][LOAD]Load mounted wallets as ref to stacke")
fi

# Log events
if [ ! ${#Events[@]} -eq 0 ]
then
LogEvents "${Events[@]}"
unset Events
fi
Loading