Skip to content

Commit d2c940b

Browse files
committed
Add diagnostic test for reasonable ETTS
If the wallet is configured as a researcher wallet, this test checks the ETTS. It uses the ETTS function with the parameter set to ignoring whether the wallet is actively staking or not. If the result is > 90 days, then the test is failed (red). If the result is 45 days < result <= 90 days, then the test is warning (yellow). If the result is <= 45 days, then the test is passed (green). The idea behind this is to alert people who have decided to solo mine but have insufficient balance to ensure that they stake before the 180 limit expires.
1 parent 6f3a0bf commit d2c940b

File tree

2 files changed

+87
-49
lines changed

2 files changed

+87
-49
lines changed

src/qt/diagnosticsdialog.cpp

+57-31
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ bool DiagnosticsDialog::VerifyCPIDHasRAC()
287287
return (racValue >= 1) ? true : false;
288288
}
289289

290-
double VerifyETTSReasonable()
290+
double DiagnosticsDialog::VerifyETTSReasonable()
291291
{
292292
// We are going to compute the ETTS with ignore_staking_status set to true
293293
// and also use a 960 block diff as the input, which smooths out short
@@ -357,6 +357,11 @@ void DiagnosticsDialog::on_testButton_clicked()
357357
ui->verifyCPIDIsInNNResultLabel->setText(tr("N/A"));
358358
ui->verifyCPIDIsInNNResultLabel->setStyleSheet("color:black;background-color:grey");
359359
UpdateTestStatus("verifyCPIDIsInNN", completed);
360+
361+
ui->checkETTSResultLabel->setText(tr("N/A"));
362+
ui->checkETTSResultLabel->setStyleSheet("color:black;background-color:grey");
363+
UpdateTestStatus("checkETTS", completed);
364+
360365
}
361366
else
362367
{
@@ -444,6 +449,57 @@ void DiagnosticsDialog::on_testButton_clicked()
444449
UpdateTestStatus("verifyCPIDIsInNN", completed);
445450
UpdateOverallDiagnosticResult(failed);
446451
}
452+
453+
// verify reasonable ETTS
454+
// This is only checked if wallet is a researcher wallet because the purpose is to
455+
// alert the owner that his stake time is too long and therefore there is a chance
456+
// of research rewards loss between stakes due to the 180 day limit.
457+
ui->checkETTSResultLabel->setStyleSheet("");
458+
ui->checkETTSResultLabel->setText(tr("Testing..."));
459+
UpdateTestStatus("checkETTS", pending);
460+
461+
double ETTS = VerifyETTSReasonable() / (24.0 * 60.0 * 60.0);
462+
463+
std::string rounded_ETTS;
464+
465+
//round appropriately for display.
466+
if (ETTS >= 100)
467+
{
468+
rounded_ETTS = RoundToString(ETTS, 0);
469+
}
470+
else if (ETTS >= 10)
471+
{
472+
rounded_ETTS = RoundToString(ETTS, 1);
473+
}
474+
else
475+
{
476+
rounded_ETTS = RoundToString(ETTS, 2);
477+
}
478+
479+
if (ETTS > 90.0 || ETTS == 0.0)
480+
{
481+
ui->checkETTSResultLabel->setText(tr("Failed: ETTS = %1 > 90 days")
482+
.arg(QString(rounded_ETTS.c_str())));
483+
ui->checkETTSResultLabel->setStyleSheet("color:white;background-color:red");
484+
UpdateTestStatus("checkETTS", completed);
485+
UpdateOverallDiagnosticResult(failed);
486+
}
487+
else if (ETTS > 45.0 && ETTS <= 90.0)
488+
{
489+
ui->checkETTSResultLabel->setText(tr("Warning: 45 days < ETTS = %1 <= 90 days")
490+
.arg(QString(rounded_ETTS.c_str())));
491+
ui->checkETTSResultLabel->setStyleSheet("color:black;background-color:yellow");
492+
UpdateTestStatus("checkETTS", completed);
493+
UpdateOverallDiagnosticResult(warning);
494+
}
495+
else
496+
{
497+
ui->checkETTSResultLabel->setText(tr("Passed: ETTS = %1 <= 45 days")
498+
.arg(QString(rounded_ETTS.c_str())));
499+
ui->checkETTSResultLabel->setStyleSheet("color:white;background-color:green");
500+
UpdateTestStatus("checkETTS", completed);
501+
UpdateOverallDiagnosticResult(passed);
502+
}
447503
}
448504

449505
// Tests that are common to both investor and researcher mode.
@@ -556,36 +612,6 @@ void DiagnosticsDialog::on_testButton_clicked()
556612
UpdateOverallDiagnosticResult(NA);
557613
}
558614

559-
// verify reasonable ETTS
560-
ui->checkETTSResultLabel->setStyleSheet("");
561-
ui->checkETTSResultLabel->setText(tr("Testing..."));
562-
UpdateTestStatus("checkETTS", pending);
563-
double ETTS = VerifyETTSReasonable() / (24.0 * 60.0 * 60.0);
564-
565-
if (ETTS > 90.0)
566-
{
567-
ui->checkETTSResultLabel->setText(tr("Failed: ETTS = %1 > 90 days"));
568-
ui->checkETTSResultLabel->setStyleSheet("color:white;background-color:red");
569-
UpdateTestStatus("checkETTS", completed);
570-
UpdateOverallDiagnosticResult(failed);
571-
}
572-
else if (ETTS > 45.0 && ETTS <= 90.0)
573-
{
574-
ui->checkETTSResultLabel->setText(tr("Warning: 45 days < ETTS = %1 <= 90 days"));
575-
ui->checkETTSResultLabel->setStyleSheet("color:black;background-color:yellow");
576-
UpdateTestStatus("checkETTS", completed);
577-
UpdateOverallDiagnosticResult(warning);
578-
}
579-
else
580-
{
581-
ui->checkETTSResultLabel->setText(tr("Passed: ETTS <= 45 days"));
582-
ui->checkETTSResultLabel->setStyleSheet("color:white;background-color:green");
583-
UpdateTestStatus("checkETTS", completed);
584-
UpdateOverallDiagnosticResult(passed);
585-
}
586-
587-
588-
589615
// client version
590616
ui->checkClientVersionResultLabel->setStyleSheet("");
591617
ui->checkClientVersionResultLabel->setText(tr("Testing..."));

src/qt/forms/diagnosticsdialog.ui

+30-18
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@
7474
<item row="4" column="0">
7575
<widget class="QLabel" name="verifyCPIDIsInNNLabel">
7676
<property name="sizePolicy">
77-
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
77+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
7878
<horstretch>0</horstretch>
7979
<verstretch>0</verstretch>
8080
</sizepolicy>
8181
</property>
8282
<property name="minimumSize">
8383
<size>
84-
<width>240</width>
84+
<width>0</width>
8585
<height>0</height>
8686
</size>
8787
</property>
@@ -90,7 +90,7 @@
9090
</property>
9191
</widget>
9292
</item>
93-
<item row="7" column="1">
93+
<item row="8" column="1">
9494
<widget class="QLabel" name="verifySeedNodesResultLabel">
9595
<property name="sizePolicy">
9696
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -112,7 +112,7 @@
112112
</property>
113113
</widget>
114114
</item>
115-
<item row="5" column="1">
115+
<item row="6" column="1">
116116
<widget class="QLabel" name="verifyWalletIsSyncedResultLabel">
117117
<property name="sizePolicy">
118118
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -134,7 +134,7 @@
134134
</property>
135135
</widget>
136136
</item>
137-
<item row="12" column="0">
137+
<item row="13" column="0">
138138
<widget class="QLabel" name="overallResultLabel">
139139
<property name="font">
140140
<font>
@@ -169,7 +169,7 @@
169169
</property>
170170
</widget>
171171
</item>
172-
<item row="12" column="1">
172+
<item row="13" column="1">
173173
<widget class="QLabel" name="overallResultResultLabel">
174174
<property name="font">
175175
<font>
@@ -212,7 +212,7 @@
212212
</property>
213213
</widget>
214214
</item>
215-
<item row="8" column="1">
215+
<item row="9" column="1">
216216
<widget class="QLabel" name="verifyConnectionsResultLabel">
217217
<property name="sizePolicy">
218218
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -234,14 +234,14 @@
234234
</property>
235235
</widget>
236236
</item>
237-
<item row="9" column="0">
237+
<item row="10" column="0">
238238
<widget class="QLabel" name="verifyTCPPortLabel">
239239
<property name="text">
240240
<string>Verify listen port for full node</string>
241241
</property>
242242
</widget>
243243
</item>
244-
<item row="6" column="0">
244+
<item row="7" column="0">
245245
<widget class="QLabel" name="verifyClockLabel">
246246
<property name="text">
247247
<string>Verify clock</string>
@@ -270,14 +270,14 @@
270270
</property>
271271
</widget>
272272
</item>
273-
<item row="8" column="0">
273+
<item row="9" column="0">
274274
<widget class="QLabel" name="verifyConnectionsLabel">
275275
<property name="text">
276276
<string>Verify connections to network </string>
277277
</property>
278278
</widget>
279279
</item>
280-
<item row="6" column="1">
280+
<item row="7" column="1">
281281
<widget class="QLabel" name="verifyClockResultLabel">
282282
<property name="sizePolicy">
283283
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -306,7 +306,7 @@
306306
</property>
307307
</widget>
308308
</item>
309-
<item row="9" column="1">
309+
<item row="10" column="1">
310310
<widget class="QLabel" name="verifyTCPPortResultLabel">
311311
<property name="sizePolicy">
312312
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -328,14 +328,14 @@
328328
</property>
329329
</widget>
330330
</item>
331-
<item row="11" column="0">
331+
<item row="12" column="0">
332332
<widget class="QLabel" name="checkClientVersionLabel">
333333
<property name="text">
334334
<string>Check client version</string>
335335
</property>
336336
</widget>
337337
</item>
338-
<item row="7" column="0">
338+
<item row="8" column="0">
339339
<widget class="QLabel" name="verifySeedNodesLabel">
340340
<property name="text">
341341
<string>Verify connections to seeds</string>
@@ -364,14 +364,14 @@
364364
</property>
365365
</widget>
366366
</item>
367-
<item row="5" column="0">
367+
<item row="6" column="0">
368368
<widget class="QLabel" name="verifyWalletIsSyncedLabel">
369369
<property name="text">
370370
<string>Verify wallet is synced</string>
371371
</property>
372372
</widget>
373373
</item>
374-
<item row="11" column="1">
374+
<item row="12" column="1">
375375
<widget class="QLabel" name="checkClientVersionResultLabel">
376376
<property name="sizePolicy">
377377
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@@ -393,15 +393,27 @@
393393
</property>
394394
</widget>
395395
</item>
396-
<item row="10" column="0">
396+
<item row="5" column="0">
397397
<widget class="QLabel" name="checkETTSLabel">
398398
<property name="text">
399399
<string>Check estimated time to stake </string>
400400
</property>
401401
</widget>
402402
</item>
403-
<item row="10" column="1">
403+
<item row="5" column="1">
404404
<widget class="QLabel" name="checkETTSResultLabel">
405+
<property name="sizePolicy">
406+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
407+
<horstretch>0</horstretch>
408+
<verstretch>0</verstretch>
409+
</sizepolicy>
410+
</property>
411+
<property name="minimumSize">
412+
<size>
413+
<width>200</width>
414+
<height>0</height>
415+
</size>
416+
</property>
405417
<property name="text">
406418
<string/>
407419
</property>

0 commit comments

Comments
 (0)