mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
Merge branch 'release' into host-retry
This commit is contained in:
@@ -57,7 +57,7 @@ async function main() {
|
||||
hpc.on(HotPocket.events.contractOutput, (r) => {
|
||||
|
||||
r.outputs.forEach(output => {
|
||||
// If bson.deserialize error occured it'll be caught by this try catch.
|
||||
// If bson.deserialize error occurred it'll be caught by this try catch.
|
||||
try
|
||||
{
|
||||
const result = bson.deserialize(output);
|
||||
|
||||
@@ -63,6 +63,34 @@ const funcs = {
|
||||
return { success: false, result: "Account not found." };
|
||||
|
||||
await hostClient.connect();
|
||||
|
||||
if (validateFor === "register" || validateFor === "re-register") {
|
||||
// Check whether is there any missed NFT sell offers
|
||||
try {
|
||||
const registryAcc = new evernode.XrplAccount(hostClient.config.registryAddress, null);
|
||||
const regUriToken = await hostClient.getRegistrationUriToken();
|
||||
|
||||
if (!regUriToken) {
|
||||
const regInfo = await hostClient.getHostInfo(accountAddress);
|
||||
|
||||
if (regInfo) {
|
||||
const sellOffer = (await registryAcc.getURITokens()).find(o => o.index == regInfo.uriTokenId && o.Amount);
|
||||
|
||||
if (sellOffer) {
|
||||
await hostClient.disconnect();
|
||||
await xrplApi.disconnect();
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
await hostClient.disconnect();
|
||||
await xrplApi.disconnect();
|
||||
return { success: false, result: 'Error occurred in missed sell offers check.' };
|
||||
}
|
||||
}
|
||||
|
||||
const registered = await hostClient.isRegistered();
|
||||
// For register validation the host should not be registered in evernode.
|
||||
// For other validations host should be registered in evernode.
|
||||
|
||||
@@ -24,6 +24,7 @@ tls_cabundle_file=${17}
|
||||
description=${18}
|
||||
ipv6_subnet=${19}
|
||||
ipv6_net_interface=${20}
|
||||
extra_txn_fee=${21}
|
||||
|
||||
script_dir=$(dirname "$(realpath "$0")")
|
||||
desired_slirp4netns_version="1.2.1"
|
||||
@@ -262,7 +263,7 @@ if [ "$NO_MB" == "" ]; then
|
||||
stage "Configuring host Xahau account"
|
||||
echo "Using registry: $EVERNODE_REGISTRY_ADDRESS"
|
||||
|
||||
! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN new $xrpl_account_address $xrpl_account_secret_path $EVERNODE_GOVERNOR_ADDRESS $inetaddr $lease_amount $rippled_server $ipv6_subnet $ipv6_net_interface $NETWORK && echo "XRPLACC_FAILURE" && rollback
|
||||
! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN new $xrpl_account_address $xrpl_account_secret_path $EVERNODE_GOVERNOR_ADDRESS $inetaddr $lease_amount $rippled_server $ipv6_subnet $ipv6_net_interface $NETWORK $extra_txn_fee && echo "XRPLACC_FAILURE" && rollback
|
||||
doreg=1
|
||||
fi
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ if [ -f $SASHIMONO_BIN/docker-registry-uninstall.sh ]; then
|
||||
fi
|
||||
|
||||
# Delete binaries except message board and sashimnono uninstall script.
|
||||
# We keep uninstall script so user can uninstall again if error occured at later steps.
|
||||
# We keep uninstall script so user can uninstall again if error occurred at later steps.
|
||||
# We'll remove these after deregistration.
|
||||
echo "Deleting binaries..."
|
||||
find $SASHIMONO_BIN -mindepth 1 ! \( -regex "^$MB_XRPL_BIN\(/.*\)?" -o -path $SASHIMONO_BIN/sashimono-uninstall.sh \) -delete
|
||||
|
||||
@@ -737,6 +737,21 @@ function set_lease_amount() {
|
||||
lease_amount=$amount
|
||||
}
|
||||
|
||||
function set_extra_fee() {
|
||||
local fee=0
|
||||
if confirm "Do you want to set an extra transaction fee to consider in case of network congestion?" "n" ; then
|
||||
while true ; do
|
||||
read -ep "Specify the affordable extra transaction fee (in XAH Drops): " fee </dev/tty
|
||||
! validate_positive_decimal $fee && echo "Extra fee amount should be a numerical value greater than zero." || break
|
||||
done
|
||||
|
||||
echo -e "Affordable extra transaction fee is set as $fee XAH Drops.\n"
|
||||
|
||||
else
|
||||
extra_txn_fee=$fee
|
||||
fi
|
||||
}
|
||||
|
||||
function set_email_address() {
|
||||
|
||||
local emailAddress=""
|
||||
@@ -1121,7 +1136,7 @@ function install_evernode() {
|
||||
# If STAGE log contains -p arg, move the cursor to previous log line and overwrite the log.
|
||||
! UPGRADE=$upgrade EVERNODE_REGISTRY_ADDRESS=$registry_address OPERATION=$operation ./sashimono-install.sh $inetaddr $init_peer_port $init_user_port $countrycode $alloc_instcount \
|
||||
$alloc_cpu $alloc_ramKB $alloc_swapKB $alloc_diskKB $lease_amount $rippled_server $xrpl_account_address $xrpl_account_secret_path $email_address \
|
||||
$tls_key_file $tls_cert_file $tls_cabundle_file $description $ipv6_subnet $ipv6_net_interface 2>&1 \
|
||||
$tls_key_file $tls_cert_file $tls_cabundle_file $description $ipv6_subnet $ipv6_net_interface $extra_txn_fee 2>&1 \
|
||||
| tee -a $logfile | stdbuf --output=L grep "STAGE\|ERROR" \
|
||||
| while read line ; do [[ $line =~ ^STAGE[[:space:]]-p(.*)$ ]] && echo -e \\e[1A\\e[K"${line:9}" || echo ${line:6} ; done \
|
||||
&& remove_evernode_alias && install_failure
|
||||
@@ -1364,7 +1379,7 @@ function reconfig_sashi() {
|
||||
function reconfig_mb() {
|
||||
echomult "Configuaring message board...\n"
|
||||
|
||||
! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN reconfig $lease_amount $alloc_instcount $rippled_server $ipv6_subnet $ipv6_net_interface &&
|
||||
! sudo -u $MB_XRPL_USER MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN reconfig $lease_amount $alloc_instcount $rippled_server $ipv6_subnet $ipv6_net_interface $extra_txn_fee &&
|
||||
echo "There was an error in updating message board configuration." && return 1
|
||||
return 0
|
||||
}
|
||||
@@ -1381,6 +1396,7 @@ function config() {
|
||||
rippled_server='-'
|
||||
ipv6_subnet='-'
|
||||
ipv6_net_interface='-'
|
||||
extra_txn_fee='-'
|
||||
|
||||
local saconfig="$SASHIMONO_DATA/sa.cfg"
|
||||
local max_instance_count=$(jq '.system.max_instance_count' $saconfig)
|
||||
@@ -1391,6 +1407,7 @@ function config() {
|
||||
local mbconfig="$MB_XRPL_DATA/mb-xrpl.cfg"
|
||||
local cfg_lease_amount=$(jq '.xrpl.leaseAmount' $mbconfig)
|
||||
local cfg_rippled_server=$(jq -r '.xrpl.rippledServer' $mbconfig)
|
||||
local cfg_extra_txn_fee=$(jq '.xrpl.affordableExtraFee' $mbconfig)
|
||||
|
||||
local cfg_ipv6_subnet=$(jq -r '.networking.ipv6.subnet' $mbconfig)
|
||||
local cfg_ipv6_net_interface=$(jq -r '.networking.ipv6.interface' $mbconfig)
|
||||
@@ -1563,8 +1580,23 @@ function config() {
|
||||
echomult "Invalid arguments.\n Usage: evernode config instance [ipv6]\n" && exit 1
|
||||
fi
|
||||
|
||||
elif [ "$sub_mode" == "extrafee" ] ; then
|
||||
|
||||
local fee=${2} # Affordable extra transaction fee to consider in txn failures.
|
||||
[ -z $fee ] && echomult "Your affordable extra transaction fee: $cfg_extra_txn_fee XAH Drops.\n" && exit 0
|
||||
|
||||
! validate_positive_decimal $fee &&
|
||||
echomult "Invalid fee amount.\n Usage: evernode config extrafee | evernode config extrafee <fee amount in XAH Drops>\n" &&
|
||||
exit 1
|
||||
extra_txn_fee=$fee
|
||||
[[ $cfg_extra_txn_fee == $extra_txn_fee ]] && echomult "Affordable extra transaction fee is already configured!\n" && exit 0
|
||||
|
||||
echomult "Using affordable extra transaction fee $extra_txn_fee XAH Drops."
|
||||
|
||||
update_mb=1
|
||||
|
||||
else
|
||||
echomult "Invalid arguments.\n Usage: evernode config [resources|leaseamt|rippled|email|instance] [arguments]\n" && exit 1
|
||||
echomult "Invalid arguments.\n Usage: evernode config [resources|leaseamt|rippled|email|instance|extrafee] [arguments]\n" && exit 1
|
||||
fi
|
||||
|
||||
local mb_user_id=$(id -u "$MB_XRPL_USER")
|
||||
@@ -1685,6 +1717,8 @@ if [ "$mode" == "install" ]; then
|
||||
set_lease_amount
|
||||
echo -e "Lease amount set as $lease_amount EVRs per Moment.\n"
|
||||
|
||||
set_extra_fee
|
||||
|
||||
# TODO - CHECKPOINT - 02
|
||||
set_host_xrpl_account $operation
|
||||
echo -e "\nAccount setup is complete."
|
||||
|
||||
@@ -25,7 +25,7 @@ async function main() {
|
||||
const network = process.argv.length > 11 ? process.argv[11] : appenv.NETWORK;
|
||||
const affordableExtraFee = process.argv.length > 12 ? process.argv[12] : 0;
|
||||
const setup = new Setup();
|
||||
setup.newConfig(accountAddress, accountSecretPath, governorAddress, parseFloat(leaseAmount), rippledServer, ipv6Subnet, ipv6NetInterface, network, affordableExtraFee);
|
||||
setup.newConfig(accountAddress, accountSecretPath, governorAddress, parseFloat(leaseAmount), rippledServer, ipv6Subnet, ipv6NetInterface, network, parseInt(affordableExtraFee));
|
||||
|
||||
if (appenv.IS_DEV_MODE) {
|
||||
await setup.prepareHostAccount(domain);
|
||||
@@ -50,12 +50,13 @@ async function main() {
|
||||
else if (process.argv.length >= 3 && process.argv[2] === 'upgrade') {
|
||||
await new Setup().upgrade();
|
||||
}
|
||||
else if ((process.argv.length === 8) && process.argv[2] === 'reconfig') {
|
||||
else if ((process.argv.length === 9) && process.argv[2] === 'reconfig') {
|
||||
if (process.argv[5] == '-') process.argv[5] = null;
|
||||
if (process.argv[6] == '-') process.argv[6] = null;
|
||||
if (process.argv[7] == '-') process.argv[7] = null;
|
||||
if (process.argv[8] == '-') process.argv[8] = null;
|
||||
|
||||
await new Setup().changeConfig(process.argv[3], process.argv[5], process.argv[4], process.argv[6], process.argv[7]);
|
||||
await new Setup().changeConfig(process.argv[3], process.argv[5], process.argv[4], process.argv[6], process.argv[7], process.argv[8]);
|
||||
}
|
||||
else if (process.argv.length === 4 && process.argv[2] === 'delete') {
|
||||
await new Setup().deleteInstance(process.argv[3]);
|
||||
|
||||
@@ -198,7 +198,7 @@ class Setup {
|
||||
await hostClient.disconnect();
|
||||
}
|
||||
catch {
|
||||
throw 'Error occured when retrieving account info.';
|
||||
throw 'Error occurred when retrieving account info.';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ class Setup {
|
||||
}
|
||||
|
||||
// Change the message board configurations.
|
||||
async changeConfig(leaseAmount, rippledServer, totalInstanceCount, ipv6Subnet, ipv6NetInterface) {
|
||||
async changeConfig(leaseAmount, rippledServer, totalInstanceCount, ipv6Subnet, ipv6NetInterface, affordableExtraFee) {
|
||||
|
||||
// Update the configuration.
|
||||
const cfg = this.#getConfig();
|
||||
@@ -327,16 +327,21 @@ class Setup {
|
||||
throw 'Provided Rippled Server is invalid';
|
||||
else if (totalInstanceCount && isNaN(totalInstanceCount))
|
||||
throw 'Maximum instance count should be a number';
|
||||
else if (affordableExtraFee && isNaN(affordableExtraFee))
|
||||
throw 'Affordable txn fee should be a number';
|
||||
|
||||
const leaseAmountParsed = leaseAmount ? parseFloat(leaseAmount) : 0;
|
||||
const totalInstanceCountParsed = totalInstanceCount ? parseInt(totalInstanceCount) : 0;
|
||||
const affordableExtraFeeParsed = affordableExtraFee ? parseInt(affordableExtraFee) : 0;
|
||||
|
||||
|
||||
// Return if not changed.
|
||||
if (!totalInstanceCount &&
|
||||
(!leaseAmount || cfg.xrpl.leaseAmount == leaseAmount) &&
|
||||
(!rippledServer || cfg.xrpl.rippledServer == rippledServer) &&
|
||||
(!ipv6Subnet) &&
|
||||
(!ipv6NetInterface))
|
||||
(!ipv6NetInterface) &&
|
||||
(!affordableExtraFee || cfg.xrpl.affordableExtraFee == affordableExtraFee))
|
||||
return;
|
||||
|
||||
await this.recreateLeases(leaseAmountParsed, totalInstanceCountParsed, rippledServer, ipv6Subnet, ipv6NetInterface, cfg);
|
||||
@@ -345,6 +350,8 @@ class Setup {
|
||||
cfg.xrpl.leaseAmount = leaseAmountParsed;
|
||||
if (rippledServer)
|
||||
cfg.xrpl.rippledServer = rippledServer;
|
||||
if (affordableExtraFeeParsed)
|
||||
cfg.xrpl.affordableExtraFee = affordableExtraFeeParsed;
|
||||
this.#saveConfig(cfg);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace sqlite
|
||||
char *err_msg;
|
||||
if (sqlite3_exec(db, sql.data(), callback, (callback != NULL ? (void *)callback_first_arg : NULL), &err_msg) != SQLITE_OK)
|
||||
{
|
||||
LOG_ERROR << "SQL error occured: " << err_msg;
|
||||
LOG_ERROR << "SQL error occurred: " << err_msg;
|
||||
sqlite3_free(err_msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ if [ $mode == "reconfig" ]; then
|
||||
fi
|
||||
|
||||
if ! sshskp $sshuser@$hostaddr $command ; then
|
||||
printf "$PRINTFORMAT" "$nodeno" "Error occured reconfiguring sashimono."
|
||||
printf "$PRINTFORMAT" "$nodeno" "Error occurred reconfiguring sashimono."
|
||||
else
|
||||
# Remove host info if reinstall.
|
||||
if [ ! -z $reinstall ] && [ $reinstall == "R" ]; then
|
||||
@@ -402,7 +402,7 @@ if [ $mode == "docker-pull" ]; then
|
||||
|
||||
command="$contractpath && $user && $dpull"
|
||||
if ! sshskp $sshuser@$hostaddr $command 1>/dev/null; then
|
||||
printf "$PRINTFORMAT" "$nodeno" "Error occured pulling $image."
|
||||
printf "$PRINTFORMAT" "$nodeno" "Error occurred pulling $image."
|
||||
else
|
||||
printf "$PRINTFORMAT" "$nodeno" "Successfully pulled $image."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user