mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
Merge branch 'main' into beta-v3
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,20 @@ class GovernanceManager {
|
||||
return status;
|
||||
}
|
||||
|
||||
async reportDudHost(dudHostAddress, hostClient) {
|
||||
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);
|
||||
}
|
||||
finally {
|
||||
await hostClient.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
getConfig() {
|
||||
return JSON.parse(fs.readFileSync(this.#cfgPath).toString());
|
||||
}
|
||||
@@ -156,17 +170,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 +206,10 @@ class GovernanceManager {
|
||||
const status = await mgr.getStatus(hostClient);
|
||||
console.log(JSON.stringify(status, null, 2));
|
||||
}
|
||||
else if (args.length === 1 && command === 'report') {
|
||||
const id = await mgr.reportDudHost(args[0], hostClient);
|
||||
console.log(`Successfully proposed the dud host candidate ${id}.`);
|
||||
}
|
||||
else {
|
||||
throw "Invalid args.";
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user