From 8fadd3e3a7c3abba38fcb189ce633a5ecdae94cb Mon Sep 17 00:00:00 2001 From: Dulana Peiris <57042272+du1ana@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:54:15 +0530 Subject: [PATCH 1/3] Added dud host reporting (#275) --- installer/setup.sh | 1 + mb-xrpl/lib/governance-manager.js | 32 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/installer/setup.sh b/installer/setup.sh index d5191be..9d2d9a3 100755 --- a/installer/setup.sh +++ b/installer/setup.sh @@ -1319,6 +1319,7 @@ elif [ "$mode" == "governance" ]; then \nvote [candidateId] - Vote for a governance candidate. \nunvote [candidateId] - Remove vote from voted governance candidate. \nstatus - Get governance info of this host. + \nreport [dudHostAddress] - Report a dud host. \nhelp - Print help." && exit 0 ! MB_DATA_DIR=$MB_XRPL_DATA node $MB_XRPL_BIN ${*:1} && exit 1 diff --git a/mb-xrpl/lib/governance-manager.js b/mb-xrpl/lib/governance-manager.js index e2b8daf..2ffc681 100644 --- a/mb-xrpl/lib/governance-manager.js +++ b/mb-xrpl/lib/governance-manager.js @@ -135,12 +135,12 @@ class GovernanceManager { await hostClient.connect(); const candidate = await hostClient.getCandidateByOwner(); const dudHostCandidates = await hostClient.getDudHostCandidatesByOwner(); - + if (candidate) status = { ...status, candidates: { hook: candidate.uniqueId } }; if (dudHostCandidates && dudHostCandidates.length > 0) - status.candidates = { ...(status.candidates ?? {}), dudHosts: dudHostCandidates.map(dh => dh.uniqueId)} - } catch(e) { + status.candidates = { ...(status.candidates ?? {}), dudHosts: dudHostCandidates.map(dh => dh.uniqueId) } + } catch (e) { throw (typeof e == 'object' ? (e.code || 'ERROR_IN_COLLECTING_CANDIDATES') : e); } finally { @@ -149,6 +149,18 @@ class GovernanceManager { return status; } + async reportDudHost(dudHostAddress, hostClient) { + try { + await hostClient.connect(); + await hostClient.reportDudHost(dudHostAddress); + } catch (e) { + throw (typeof e == 'object' ? (e.code || 'ERROR_IN_REPORTING_DUD_HOST') : e); + } + finally { + await hostClient.disconnect(); + } + } + getConfig() { return JSON.parse(fs.readFileSync(this.#cfgPath).toString()); } @@ -156,17 +168,17 @@ class GovernanceManager { static async handleCommand(command, ...args) { let hostClient = null; - // Secret is needed for propose and withdraw in order to send the transaction. + // Secret is needed for propose, withdraw, and report in order to send the transaction. // Root access is needed in order to access the secret config. // Vote and unvote need write access for the governance config. - if ((command == 'propose' || command === 'withdraw' || command === 'vote' || command === 'unvote') && process.getuid() !== 0) + if ((command == 'propose' || command === 'withdraw' || command === 'vote' || command === 'unvote' || command === 'report') && process.getuid() !== 0) throw "Please run with root privileges (sudo)."; // Host client is only needed for some commands. - if (command == 'propose' || command === 'withdraw' || command === 'vote' || command === 'status') { - // Secret is needed for propose and withdraw in order to send the transaction + if (command == 'propose' || command === 'withdraw' || command === 'vote' || command === 'status' || command === 'report') { + // Secret is needed for propose, withdraw, and report in order to send the transaction const sashiMBConfig = ConfigHelper.readConfig(appenv.CONFIG_PATH, - (command == 'propose' || command === 'withdraw') ? appenv.SECRET_CONFIG_PATH : null); + (command == 'propose' || command === 'withdraw' || command === 'report') ? appenv.SECRET_CONFIG_PATH : null); setEvernodeDefaults(sashiMBConfig.xrpl.governorAddress, sashiMBConfig.xrpl.rippledServer); hostClient = new evernode.HostClient(sashiMBConfig.xrpl.address, sashiMBConfig.xrpl.secret); } @@ -192,6 +204,10 @@ class GovernanceManager { const status = await mgr.getStatus(hostClient); console.log(JSON.stringify(status, null, 2)); } + else if (args.length === 1 && command === 'report') { + await mgr.reportDudHost(args[0], hostClient); + console.log(`Successfully reported the dud host ${args[0]}.`); + } else { throw "Invalid args."; } From 416572c7d475cae26e28b026b51897678f433a1b Mon Sep 17 00:00:00 2001 From: Dulana Peiris <57042272+du1ana@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:35:37 +0530 Subject: [PATCH 2/3] Minor changes in Dud Host Reporting (#276) --- mb-xrpl/lib/governance-manager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mb-xrpl/lib/governance-manager.js b/mb-xrpl/lib/governance-manager.js index 2ffc681..e591b7b 100644 --- a/mb-xrpl/lib/governance-manager.js +++ b/mb-xrpl/lib/governance-manager.js @@ -153,6 +153,8 @@ class GovernanceManager { try { await hostClient.connect(); await hostClient.reportDudHost(dudHostAddress); + const id = evernode.StateHelpers.getDudHostCandidateId(dudHostAddress); + return id; } catch (e) { throw (typeof e == 'object' ? (e.code || 'ERROR_IN_REPORTING_DUD_HOST') : e); } @@ -205,8 +207,8 @@ class GovernanceManager { console.log(JSON.stringify(status, null, 2)); } else if (args.length === 1 && command === 'report') { - await mgr.reportDudHost(args[0], hostClient); - console.log(`Successfully reported the dud host ${args[0]}.`); + const id = await mgr.reportDudHost(args[0], hostClient); + console.log(`Successfully proposed the dud host candidate ${id}.`); } else { throw "Invalid args."; From d27a4e3ecb1b0e1e8cc1561ae5602682d2375736 Mon Sep 17 00:00:00 2001 From: Chalith Desaman Date: Fri, 18 Aug 2023 10:00:17 +0530 Subject: [PATCH 3/3] Updated the sashimono version (#277) --- mb-xrpl/lib/appenv.js | 2 +- src/version.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mb-xrpl/lib/appenv.js b/mb-xrpl/lib/appenv.js index cd0188b..1f02532 100644 --- a/mb-xrpl/lib/appenv.js +++ b/mb-xrpl/lib/appenv.js @@ -28,7 +28,7 @@ appenv = { ORPHAN_PRUNE_SCHEDULER_INTERVAL_HOURS: 4, SASHIMONO_SCHEDULER_INTERVAL_SECONDS: 2, SASHI_CLI_PATH: appenv.IS_DEV_MODE ? "../build/sashi" : "/usr/bin/sashi", - MB_VERSION: '0.6.5', + MB_VERSION: '0.6.6', TOS_HASH: '757A0237B44D8B2BBB04AE2BAD5813858E0AECD2F0B217075E27E0630BA74314' // This is the sha256 hash of TOS text. } Object.freeze(appenv); diff --git a/src/version.hpp b/src/version.hpp index 72c9775..99dbf2b 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -6,7 +6,7 @@ namespace version { // Sashimono agent version. Written to new configs. - constexpr const char *AGENT_VERSION = "0.6.5"; + constexpr const char *AGENT_VERSION = "0.6.6"; // Minimum compatible config version (this will be used to validate configs). constexpr const char *MIN_CONFIG_VERSION = "0.5.0";