Skip to content

Commit

Permalink
v8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
martiliones authored Nov 5, 2023
2 parents 95df4fc + 3c8a50c commit 02adde3
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 172 deletions.
16 changes: 10 additions & 6 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@
"enabled": true,
"list": [
{
"ip": "51.15.221.205",
"port": 36666
},
{
"ip": "51.15.88.53",
"ip": "5.161.68.61",
"port": 36666
},
{
"ip": "5.161.68.61",
"ip": "149.102.157.15",
"port": 36666
},
{
Expand All @@ -67,6 +63,14 @@
{
"ip": "138.201.152.191",
"port": 36666
},
{
"ip": "184.94.215.92",
"port": 45555
},
{
"ip": "207.244.243.23",
"port": 45555
}
],
"access": {
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant",
"version": "0.8.1",
"version": "0.8.2",
"private": true,
"scripts": {
"start": "node app.js",
Expand Down Expand Up @@ -38,18 +38,18 @@
"dependencies": {
"async": "=3.2.4",
"axios": "^0.27.2",
"bignumber.js": "=9.1.0",
"bignumber.js": "=9.1.2",
"bitcore-mnemonic": "=8.25.36",
"body-parser": "=1.20.0",
"body-parser": "=1.20.2",
"bytebuffer": "=5.0.1",
"change-case": "=4.1.2",
"colors": "=1.4.0",
"commander": "=9.4.0",
"compression": "=1.7.4",
"cors": "=2.8.5",
"ejs": "=3.1.8",
"ejs": "=3.1.9",
"execa": "^5.1.1",
"express": "=4.18.1",
"express": "=4.18.2",
"express-domain-middleware": "=0.1.0",
"express-query-int": "=3.0.0",
"express-rate-limit": "=6.5.1",
Expand All @@ -63,40 +63,40 @@
"method-override": "=3.0.0",
"npm": "=8.17.0",
"pg-monitor": "=1.4.1",
"pg-native": "=3.0.0",
"pg-native": "=3.0.1",
"pg-promise": "=10.11.1",
"randomstring": "=1.2.2",
"redis": "=4.2.0",
"randomstring": "=1.3.0",
"redis": "=4.6.10",
"rimraf": "=3.0.2",
"semver": "=7.3.7",
"socket.io": "^4.5.1",
"semver": "=7.5.4",
"socket.io": "^4.7.2",
"sodium": "^3.0.2",
"sodium-browserify-tweetnacl": "*",
"strftime": "=0.10.1",
"unzipper": "^0.10.11",
"strftime": "=0.10.2",
"unzipper": "^0.10.14",
"valid-url": "=1.0.9",
"validator.js": "=2.0.4",
"z-schema": "=5.0.3"
},
"devDependencies": {
"chai": "^4.3.6",
"chai-bignumber": "^3.0.0",
"chai": "^4.3.10",
"chai-bignumber": "^3.1.0",
"eslint-config-google": "^0.14.0",
"eslint-formatter-codeframe": "^7.32.1",
"eslint-plugin-jsdoc": "^39.3.4",
"grunt": "^1.5.3",
"eslint-plugin-jsdoc": "^46.8.2",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-compress": "^2.0.0",
"grunt-contrib-obfuscator": "^8.0.0",
"grunt-eslint": "^24.0.0",
"grunt-eslint": "^24.3.0",
"grunt-exec": "^3.0.0",
"jsdoc": "^3.6.11",
"mocha": "^10.0.0",
"mocha": "^10.2.0",
"moment": "^2.29.4",
"nyc": "^15.1.0",
"nyc-middleware": "^1.0.4",
"sinon": "^14.0.0",
"supertest": "^6.2.4"
"supertest": "^6.3.3"
},
"overrides": {
"grunt-contrib-obfuscator": {
Expand Down
1 change: 1 addition & 0 deletions sql/chats.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var ChatsSql = {
'first("c_type" ORDER BY b_height DESC, t_timestamp DESC) as "c_type",',
'first("t_type" ORDER BY b_height DESC, t_timestamp DESC) as "t_type",',
'first("b_height" ORDER BY b_height DESC, t_timestamp DESC) as "b_height",',
'first("confirmations" ORDER BY b_height DESC, t_timestamp DESC) as "confirmations",',
'first("b_id" ORDER BY b_height DESC, t_timestamp DESC) as "b_id"',
'FROM ( SELECT *, t_timestamp as timestamp, ENCODE("publicKey", \'hex\') as "m_recipientPublicKey"',
'FROM full_blocks_list',
Expand Down
158 changes: 85 additions & 73 deletions tools/install_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,101 @@ databasename="adamant_main"
configfile="config.json"
processname="adamant"
port="36666"

while getopts 'b:n:' OPTION; do
OPTARG=$(echo "$OPTARG" | xargs)
case "$OPTION" in
b)
branch="$OPTARG"
;;
n)
if [ "$OPTARG" == "testnet" ]
then
network="$OPTARG"
username="adamanttest"
databasename="adamant_test"
configfile="test/config.json"
processname="adamanttest"
port="36667"
elif [ "$OPTARG" != "mainnet" ]
then
printf "\nNetwork should be 'mainnet' or 'testnet'.\n\n"
exit 1
fi
;;
*)
printf "\nWrong parameters. Use '-b' for branch, '-t' for network.\n\n"
exit 1
;;
esac
nodejs="hydrogen"

while getopts 'b:n:j:' OPTION; do
OPTARG=$(echo "$OPTARG" | xargs)
case "$OPTION" in
b)
branch="$OPTARG"
;;
n)
if [ "$OPTARG" == "testnet" ]
then
network="$OPTARG"
username="adamanttest"
databasename="adamant_test"
configfile="test/config.json"
processname="adamanttest"
port="36667"
elif [ "$OPTARG" != "mainnet" ]
then
printf "\nNetwork should be 'mainnet' or 'testnet'.\n\n"
exit 1
fi
;;
j)
if [ "$OPTARG" == "16" ] || [ "$OPTARG" == "gallium" ]
then
nodejs="gallium"
elif [ "$OPTARG" != "18" ] && [ "$OPTARG" != "hydrogen" ]
then
printf "\nNodejs should be 'gallium' = '16', or 'hydrogen' = '18'.\n\n"
exit 1
fi
;;
*)
printf "\nWrong parameters. Use '-b' for branch, '-t' for network, '-j' for Nodejs version.\n\n"
exit 1
;;
esac
done

printf "\n"
printf "Welcome to the ADAMANT node installer v2.0.2 for Ubuntu 18, 20, 22. Make sure you got this file from adamant.im website or GitHub.\n"
printf "Welcome to the ADAMANT node installer v2.1.1 for Ubuntu 18, 20, 22. Make sure you got this file from adamant.im website or GitHub.\n"
printf "This installer is the easiest way to run ADAMANT node. We still recommend to consult IT specialist if you are not familiar with Linux systems.\n"
printf "You can see full installation instructions on https://medium.com/adamant-im/how-to-run-your-adamant-node-on-ubuntu-990e391e8fcc\n"
printf "The installer will ask you to set database and user passwords during the installation.\n"
printf "Also, the system may ask to choose some parameters, like encoding, keyboard, and grub. Generally, you can leave them by default.\n\n"

printf "Note: You've choosed '%s' network.\n" "$network"
printf "Note: You've choosed '%s' branch.\n" "$branch"
printf "Note: You've choosed '%s' Nodejs version.\n" "$nodejs"
printf "\n"

read -r -p "WARNING! Running this script is recommended for new droplets. Existing data MAY BE DAMAGED. If you agree to continue, type \"yes\": " agreement
if [[ $agreement != "yes" ]]
then
printf "\nInstallation cancelled.\n\n"
exit 1
printf "\nInstallation cancelled.\n\n"
exit 1
fi

IMAGE=false
if [[ $network == "mainnet" ]]
then
printf "\nBlockchain image saves time on node sync but you must completely trust the image.\n"
printf "If you skip this step, your node will check every single transaction, which takes time (up for several days).\n"
read -r -p "Do you want to use the ADAMANT blockchain image to bootstrap a node? [Y/n]: " useimage
case $useimage in
[yY][eE][sS]|[yY]|[jJ]|'')
IMAGE=true
printf "\nI'll download blockchain image and your node will be on the actual height in a few minutes.\n\n"
;;
*)
printf "\nI'll sync your node from the beginning. It may take several days to raise up to the actual blockchain height.\n\n"
;;
esac
printf "\nBlockchain image saves time on node sync but you must completely trust the image.\n"
printf "If you skip this step, your node will check every single transaction, which takes time (up for several days).\n"
read -r -p "Do you want to use the ADAMANT blockchain image to bootstrap a node? [Y/n]: " useimage
case $useimage in
[yY][eE][sS]|[yY]|[jJ]|'')
IMAGE=true
printf "\nI'll download blockchain image and your node will be on the actual height in a few minutes.\n\n"
;;
*)
printf "\nI'll sync your node from the beginning. It may take several days to raise up to the actual blockchain height.\n\n"
;;
esac
fi

hostname=$(cat "/etc/hostname")
if grep -q "$hostname" "/etc/hosts"
then
printf "Hostname /etc/hosts seems to be good.\n\n"
printf "Hostname /etc/hosts seems to be good.\n\n"
else
printf "File /etc/hosts has no hostname record. I'll fix it.\n\n"
sh -c -e "echo '\n127.0.1.1 $hostname' >> /etc/hosts";
printf "File /etc/hosts has no hostname record. I'll fix it.\n\n"
sh -c -e "echo '\n127.0.1.1 $hostname' >> /etc/hosts";
fi

get_database_password () {
read -r -sp "Set the database password: $(echo $'\n> ')" postgrespwd
read -r -sp "$(echo $'\n')Confirm password: $(echo $'\n> ')" postgrespwdconfirmation
if [[ $postgrespwd = "$postgrespwdconfirmation" ]]
then
echo "$postgrespwd"
else
printf "\nPassword mismatch. Try again.\n\n"
get_database_password
fi
read -r -sp "Set the database password: $(echo $'\n> ')" postgrespwd
read -r -sp "$(echo $'\n')Confirm password: $(echo $'\n> ')" postgrespwdconfirmation
if [[ $postgrespwd = "$postgrespwdconfirmation" ]]
then
echo "$postgrespwd"
else
printf "\nPassword mismatch. Try again.\n\n"
get_database_password
fi
}

DB_PASSWORD="$(get_database_password)"
Expand All @@ -98,9 +110,9 @@ DB_PASSWORD="$(get_database_password)"
printf "\n\nChecking if user '%s' exists…\n\n" "$username"
if [[ $(id -u "$username" > /dev/null 2>&1; echo $?) = 1 ]]
then
printf "Creating system user named '%s'…\n" "$username"
adduser --gecos "" "$username"
printf "User '%s' has been created.\n\n" "$username"
printf "Creating system user named '%s'…\n" "$username"
adduser --gecos "" "$username"
printf "User '%s' has been created.\n\n" "$username"
fi

#Packages
Expand All @@ -126,11 +138,11 @@ su - "$username" <<EOSU
#NodeJS
printf "\n\nInstalling nvm & node.js…\n\n"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
source ~/.nvm/nvm.sh
source ~/.profile
source ~/.bashrc
nvm i --lts=gallium
nvm i --lts=$nodejs
npm i -g pm2
#ADAMANT
Expand All @@ -144,10 +156,10 @@ printf "\n\nSetting node's config…\n\n"
if [[ $configfile == "config.json" ]]
then
cp default.config.json config.json
cp config.default.json config.json
elif [ "$configfile" == "test/config.json" ]
then
cp test/config.default.json test/config.json
cp test/config.default.json test/config.json
fi
rpl -i -q '"password": "password",' "\"password\": \"${DB_PASSWORD}\"," "$configfile"
Expand All @@ -158,30 +170,30 @@ rpl -i -q '"password": "password",' "\"password\": \"${DB_PASSWORD}\"," "$config
# Download actual blockchain image for 'mainnet' network
if [[ $IMAGE = true ]]
then
printf "\n\nDownloading actual blockchain image…\n\n"
wget https://explorer.adamant.im/db_backup.sql.gz
printf "\nUnzipping the blockchain image, it can take a few minutes…\n\n"
gunzip db_backup.sql.gz
printf "\nLoading the blockchain image…\n\n"
psql adamant_main < db_backup.sql
printf "\nDeleting temporary blockchain image file…\n"
rm db_backup.sql
printf "\n\nDownloading actual blockchain image…\n\n"
wget https://explorer.adamant.im/db_backup.sql.gz
printf "\nUnzipping the blockchain image, it can take a few minutes…\n\n"
gunzip db_backup.sql.gz
printf "\nLoading the blockchain image…\n\n"
psql adamant_main < db_backup.sql
printf "\nDeleting temporary blockchain image file…\n"
rm db_backup.sql
fi
printf "\n\nAdding ADAMANT '%s' node to crontab for autostart after system reboot…\n\n" "$network"
if [[ $network == "mainnet" ]]
then
crontab -l | { cat; echo "@reboot cd /home/adamant/adamant && pm2 start --name adamant app.js"; } | crontab -
crontab -l | { cat; echo "@reboot cd /home/adamant/adamant && pm2 start --name adamant app.js"; } | crontab -
else
crontab -l | { cat; echo "@reboot cd /home/adamanttest/adamant && pm2 start --name adamanttest app.js -- --config test/config.json --genesis test/genesisBlock.json"; } | crontab -
crontab -l | { cat; echo "@reboot cd /home/adamanttest/adamant && pm2 start --name adamanttest app.js -- --config test/config.json --genesis test/genesisBlock.json"; } | crontab -
fi
printf "\n\nRunning ADAMANT '%s' node…\n\n" "$network"
if [[ $network == "mainnet" ]]
then
pm2 start --name adamant app.js
pm2 start --name adamant app.js
else
pm2 start --name adamanttest app.js -- --config test/config.json --genesis test/genesisBlock.json
pm2 start --name adamanttest app.js -- --config test/config.json --genesis test/genesisBlock.json
fi
EOSU
Expand Down
Loading

0 comments on commit 02adde3

Please sign in to comment.