Merge branch 'main' into release

This commit is contained in:
cdesaman
2024-10-02 14:23:24 +05:30
11 changed files with 98 additions and 34 deletions

View File

@@ -11,8 +11,6 @@ instance_name=$6
prefix="sashi"
max_kill_attempts=5
# Check whether this is a valid sashimono username.
[ ${#user} -lt 24 ] || [ ${#user} -gt 32 ] || [[ ! "$user" =~ ^$prefix[0-9]+$ ]] && echo "ARGS,UNINST_ERR" && exit 1
@@ -35,6 +33,15 @@ cleanup_script=$user_dir/uninstall_cleanup.sh
gp_udp_port_count=2
gp_tcp_port_count=2
function cgrulesengd_servicename() {
# Find the cgroups rules engine service.
local cgrulesengd_filepath=$(grep "ExecStart.*=.*/cgrulesengd$" /etc/systemd/system/*.service | head -1 | awk -F : ' { print $1 } ')
if [ -n "$cgrulesengd_filepath" ]; then
local cgrulesengd_filename=$(basename $cgrulesengd_filepath)
echo "${cgrulesengd_filename%.*}"
fi
}
echo "Uninstalling user '$user'."
echo "Stopping and cleaning hpfs systemd services."
@@ -150,7 +157,13 @@ rm -r /home/"${user:?}"
# Even though we are creating a group specifically,
# It'll be automatically deleted when we delete the user.
cgrulesengd_service=$(cgrulesengd_servicename)
if [ ! -z "$cgrulesengd_service" ]; then
echo "Restarting the '$cgrulesengd_service' service..."
systemctl restart $cgrulesengd_service
fi
[ -d /home/"$user" ] && echo "NOT_CLEAN,UNINST_ERR" && exit 1
echo "UNINST_SUC"
exit 0
exit 0

View File

@@ -6,7 +6,7 @@
"": {
"name": "evernode-setup-helper",
"dependencies": {
"evernode-js-client": "0.6.58",
"evernode-js-client": "0.6.60",
"ip6addr": "0.2.5",
"ripple-keypairs": "1.3.1"
}
@@ -405,9 +405,9 @@
}
},
"node_modules/evernode-js-client": {
"version": "0.6.58",
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.6.58.tgz",
"integrity": "sha512-kPapQWgZenrTFFIzHFrKFuugNUqSWjh7AZGNeZKPRTnLjMsvmujsNVGcdPm7nhsFIzp1La3O0ePnS3lZ4h1SgQ==",
"version": "0.6.60",
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.6.60.tgz",
"integrity": "sha512-nw7DxGLEHthy/dneQkQgi4o4Yu6sb09OjTPcHwhD5vnVDiOjDkUm8fshmIcjnwIW2Nhq0atGblSRq+UYvPkblQ==",
"dependencies": {
"elliptic": "6.5.4",
"libsodium-wrappers": "0.7.10",

View File

@@ -4,7 +4,7 @@
"build": "ncc build index.js --minify -o dist"
},
"dependencies": {
"evernode-js-client": "0.6.58",
"evernode-js-client": "0.6.60",
"ip6addr": "0.2.5",
"ripple-keypairs": "1.3.1"
}

View File

@@ -190,6 +190,27 @@ function set_cpu_info() {
[ -z $cpu_mhz ] && cpu_mhz=$(lscpu | grep -i "^CPU MHz:" | sed 's/CPU MHz://g' | sed 's/\.[0-9]*//g' | xargs)
}
function setup_certbot_renewal() {
# We need to place our script in certbook deploy hooks dir.
local deploy_hooks_dir="/etc/letsencrypt/renewal-hooks/deploy"
[ "$UPGRADE" == "0" ] && ! [ -d $deploy_hooks_dir ] && echo "$deploy_hooks_dir not found" && return 1
# Setup deploy hook (update contract certs on certbot SSL auto-renewal)
local deploy_hook="/etc/letsencrypt/renewal-hooks/deploy/sashimono-$inetaddr.sh"
if [ "$UPGRADE" == "0" ] || [ -f $deploy_hook ]; then
echo "Setting up certbot deploy hook $deploy_hook"
echo "#!/bin/sh
# This script is placed by Sashimono for automatic updataing of contract SSL certs.
# Domain name: $inetaddr
certname=\$(basename \$RENEWED_LINEAGE)
[ \"\$certname\" = \"$inetaddr\" ] && evernode applyssl \$RENEWED_LINEAGE/privkey.pem \$RENEWED_LINEAGE/cert.pem \$RENEWED_LINEAGE/fullchain.pem" >$deploy_hook
chmod +x $deploy_hook
fi
return 0
}
function setup_certbot() {
stage "Setting up letsencrypt certbot"
@@ -220,24 +241,14 @@ function setup_certbot() {
ufw allow http comment sashimono-certbot
# Setup the certificates. If there're already certificates skip this.
if [ ! -f /etc/letsencrypt/live/$inetaddr/privkey.pem ] || [ ! -f /etc/letsencrypt/live/$inetaddr/fullchain.pem ]; then
if [ ! -f /etc/letsencrypt/live/$inetaddr/privkey.pem ] || [ ! -f /etc/letsencrypt/live/$inetaddr/fullchain.pem ] || [ ! -f /etc/letsencrypt/live/$inetaddr/cert.pem ]; then
echo "Running certbot certonly"
call_third_party "certbot certonly -n -d $inetaddr --agree-tos --email $email_address --standalone" "setup certificates" || return 1
fi
# We need to place our script in certbook deploy hooks dir.
local deploy_hooks_dir="/etc/letsencrypt/renewal-hooks/deploy"
! [ -d $deploy_hooks_dir ] && echo "$deploy_hooks_dir not found" && return 1
setup_certbot_renewal || return 1
# Setup deploy hook (update contract certs on certbot SSL auto-renewal)
local deploy_hook="/etc/letsencrypt/renewal-hooks/deploy/sashimono-$inetaddr.sh"
echo "Setting up certbot deploy hook $deploy_hook"
echo "#!/bin/sh
# This script is placed by Sashimono for automatic updataing of contract SSL certs.
# Domain name: $inetaddr
certname=\$(basename \$RENEWED_LINEAGE)
[ \"\$certname\" = \"$inetaddr\" ] && evernode applyssl \$RENEWED_LINEAGE/privkey.pem \$RENEWED_LINEAGE/fullchain.pem" >$deploy_hook
chmod +x $deploy_hook
return 0
}
function setup_tls_certs() {
@@ -247,7 +258,8 @@ function setup_tls_certs() {
! setup_certbot && echo "Error when setting up letsencrypt SSL certificate." && abort
cp /etc/letsencrypt/live/$inetaddr/privkey.pem $SASHIMONO_DATA/contract_template/cfg/tlskey.pem
cp /etc/letsencrypt/live/$inetaddr/fullchain.pem $SASHIMONO_DATA/contract_template/cfg/tlscert.pem
cp /etc/letsencrypt/live/$inetaddr/cert.pem $SASHIMONO_DATA/contract_template/cfg/tlscert.pem
cat /etc/letsencrypt/live/$inetaddr/fullchain.pem >>$SASHIMONO_DATA/contract_template/cfg/tlscert.pem
elif [ "$tls_key_file" == "self" ]; then
# If user has not provided certs we generate self-signed ones.
@@ -484,6 +496,9 @@ chmod -R +x $SASHIMONO_BIN
# Setup tls certs used for contract instance websockets.
[ "$UPGRADE" == "0" ] && setup_tls_certs
# Update renewal of tls certs used for contract instance websockets.
[ "$UPGRADE" == "1" ] && setup_certbot_renewal
# Copy Blake3 and update linker library cache.
[ ! -f /usr/local/lib/libblake3.so ] && cp "$script_dir"/libblake3.so /usr/local/lib/ && ldconfig

View File

@@ -28,7 +28,7 @@
root_user="root"
repo_owner="EvernodeXRPL"
repo_name="evernode-test-resources"
repo_name="evernode-resources"
desired_branch="main"
# Reputation modes : 0 - "none", 1 - "OneToOne", 2 - "OneToMany"
@@ -1593,6 +1593,9 @@ WantedBy=timers.target" >/etc/systemd/system/$EVERNODE_AUTO_UPDATE_SERVICE.timer
if [ "$latest_installer_script_version" != "$current_installer_script_version" ]; then
# This is added temporary to remove auto updater. This can later be removed.
remove_evernode_auto_updater
inetaddr=$(jq -r ".hp.host_address | select( . != null )" "$SASHIMONO_CONFIG")
install_evernode 1
fi

View File

@@ -45,7 +45,7 @@ appenv = {
ORPHAN_PRUNE_SCHEDULER_INTERVAL_HOURS: 2,
SASHIMONO_SCHEDULER_INTERVAL_SECONDS: 2,
SASHI_CLI_PATH: appenv.IS_DEV_MODE ? "../build/sashi" : "/usr/bin/sashi",
MB_VERSION: '0.12.0',
MB_VERSION: '0.12.1',
TOS_HASH: '0801677EBCB2F76EF97D531549D8B27DB2C7A4A8EE7F60032AE40184247F0810', // This is the sha256 hash of EVERNODE-HOSTING-PRINCIPLES.pdf.
NETWORK: 'mainnet',
REPUTATIOND_CONFIG_PATH: path.join(appenv.DATA_DIR, '../') + "reputationd/reputationd.cfg",

View File

@@ -678,7 +678,7 @@ class MessageBoard {
await this.#queueAction(async (submissionRefs) => {
submissionRefs.refs ??= [{}];
// Check again wether the transaction is validated before retry.
// Check again whether the transaction is validated before retry.
const txHash = submissionRefs?.refs[0]?.submissionResult?.result?.tx_json?.hash;
if (txHash) {
const txResponse = await this.hostClient.xrplApi.getTransactionValidatedResults(txHash);
@@ -1160,7 +1160,40 @@ class MessageBoard {
}
}
else {
console.log("No relevant instance was found to perform the lease termination");
const uriInfo = evernode.UtilHelpers.decodeLeaseTokenUri(hostingToken.URI);
await this.#queueAction(async (submissionRefs) => {
submissionRefs.refs ??= [{}];
// Check again wether the transaction is validated before retry.
const txHash = submissionRefs?.refs[0]?.submissionResult?.result?.tx_json?.hash;
if (txHash) {
const txResponse = await this.hostClient.xrplApi.getTransactionValidatedResults(txHash);
if (txResponse && txResponse.code === "tesSUCCESS") {
console.log('Transaction is validated and success, Retry skipped!')
return;
}
}
console.log(`Expire the terminated instance ${hostingToken.index} lease.`);
await this.hostClient.expireLease(hostingToken.index, { submissionRef: submissionRefs?.refs[0] });
});
await this.#queueAction(async (submissionRefs) => {
submissionRefs.refs ??= [{}];
// Check again wether the transaction is validated before retry.
const txHash = submissionRefs?.refs[0]?.submissionResult?.result?.tx_json?.hash;
if (txHash) {
const txResponse = await this.hostClient.xrplApi.getTransactionValidatedResults(txHash);
if (txResponse && txResponse.code === "tesSUCCESS") {
console.log('Transaction is validated and success, Retry skipped!')
return;
}
}
console.log(`Re-created lease offer for the terminated instance ${hostingToken.index}.`);
await this.hostClient.offerLease(uriInfo.leaseIndex,
uriInfo.leaseAmount,
appenv.TOS_HASH,
uriInfo.outboundIP, { submissionRef: submissionRefs?.refs[0] });
});
}
}
else {
@@ -1195,7 +1228,7 @@ class MessageBoard {
async recreateLeaseOffer(uriTokenId, leaseIndex, outboundIP, noLeaseRecord = false) {
await this.#queueAction(async (submissionRefs) => {
submissionRefs.refs ??= [{}, {}];
// Check again wether the transaction is validated before retry.
// Check again whether the transaction is validated before retry.
const txHash1 = submissionRefs?.refs[0]?.submissionResult?.result?.tx_json?.hash;
let retry = true;
if (txHash1) {

View File

@@ -6,7 +6,7 @@
"": {
"name": "mb-xrpl",
"dependencies": {
"evernode-js-client": "0.6.59",
"evernode-js-client": "0.6.60",
"ip6addr": "0.2.5",
"sqlite3": "5.1.7"
},
@@ -1115,9 +1115,9 @@
}
},
"node_modules/evernode-js-client": {
"version": "0.6.59",
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.6.59.tgz",
"integrity": "sha512-IXT5T2fAG//Z9kHlSp/wZyWjvfs7+bmJVTCkD3RfLbZjqIviB/ydigGtf631Js5Q1jyIMu5F+EFpd08XS8S4jw==",
"version": "0.6.60",
"resolved": "https://registry.npmjs.org/evernode-js-client/-/evernode-js-client-0.6.60.tgz",
"integrity": "sha512-nw7DxGLEHthy/dneQkQgi4o4Yu6sb09OjTPcHwhD5vnVDiOjDkUm8fshmIcjnwIW2Nhq0atGblSRq+UYvPkblQ==",
"dependencies": {
"elliptic": "6.5.4",
"libsodium-wrappers": "0.7.10",

View File

@@ -5,7 +5,7 @@
"build": "npm run lint && ncc build app.js --minify -o dist"
},
"dependencies": {
"evernode-js-client": "0.6.59",
"evernode-js-client": "0.6.60",
"ip6addr": "0.2.5",
"sqlite3": "5.1.7"
},

View File

@@ -6,7 +6,7 @@
namespace version
{
// Sashimono agent version. Written to new configs.
constexpr const char *AGENT_VERSION = "0.12.0";
constexpr const char *AGENT_VERSION = "0.12.1";
// Minimum compatible config version (this will be used to validate configs).
constexpr const char *MIN_CONFIG_VERSION = "0.5.0";