Skip to content

Commit 48d2841

Browse files
committed
Add GUI changes
Add newer checkpoint New checkpoint Add tests Fix whitespace Set correct permissions Adjust test positon and fix num nodes
1 parent ee0e546 commit 48d2841

File tree

7 files changed

+173
-7
lines changed

7 files changed

+173
-7
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@ static MapCheckpoints mapCheckpoints = {
182182
{3014000, uint256S("78ad99b7225f73c42238bd7ca841ff700542b92bba75a0ef2ed351caa560f87f")}, //!< PIVX v5.3.0 enforced
183183
{3024000, uint256S("be4bc75afcfb9136924810f7483b2695089a366cc4ee27fd6dc3ecd5396e1f0f")}, //!< Superblock
184184
{3715200, uint256S("a676b9a598c393c82b949c37dd35013aeda55f5d18ab062349db6a8235972aaa")}, //!< Superblock for 5.5.0 mainnet rewards changeover
185+
{3780000, uint256S("2667fa1d552999aca930ced7fd3902ae5721e5c256a607049e3c47a3137a18ee")}, //!< Fri, 10 Mar 2023 rewindblockindex testing
185186
};
186187

187188
static const CCheckpointData data = {
188189
&mapCheckpoints,
189-
1591401645, // * UNIX timestamp of last checkpoint block
190-
5607713, // * total number of transactions between genesis and last checkpoint
190+
1678401150, // * UNIX timestamp of last checkpoint block
191+
8716106, // * total number of transactions between genesis and last checkpoint
191192
// (the tx=... number in the UpdateTip debug.log lines)
192193
3000 // * estimated number of transactions per day after checkpoint
193194
};

src/qt/pivx/qtutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const QString ZAPTXES2("-zapwallettxes=2");
2929
const QString UPGRADEWALLET("-upgradewallet");
3030
const QString REINDEX("-reindex");
3131
const QString RESYNC("-resync");
32+
const QString REWIND("-rewindblockindex");
3233

3334
extern Qt::Modifier SHORT_KEY;
3435

src/qt/pivx/settings/forms/settingswalletrepairwidget.ui

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
<property name="geometry">
6666
<rect>
6767
<x>0</x>
68-
<y>0</y>
69-
<width>398</width>
70-
<height>620</height>
68+
<y>-57</y>
69+
<width>383</width>
70+
<height>677</height>
7171
</rect>
7272
</property>
7373
<property name="autoFillBackground">
@@ -584,11 +584,88 @@
584584
</item>
585585
</layout>
586586
</item>
587+
<item>
588+
<spacer name="verticalSpacer_8">
589+
<property name="orientation">
590+
<enum>Qt::Vertical</enum>
591+
</property>
592+
<property name="sizeType">
593+
<enum>QSizePolicy::Fixed</enum>
594+
</property>
595+
<property name="sizeHint" stdset="0">
596+
<size>
597+
<width>20</width>
598+
<height>20</height>
599+
</size>
600+
</property>
601+
</spacer>
602+
</item>
603+
<item>
604+
<layout class="QHBoxLayout" name="horizontalRewind" stretch="1,1">
605+
<property name="spacing">
606+
<number>20</number>
607+
</property>
608+
<property name="bottomMargin">
609+
<number>0</number>
610+
</property>
611+
<item>
612+
<layout class="QVBoxLayout" name="verticalRewind" stretch="0">
613+
<property name="spacing">
614+
<number>0</number>
615+
</property>
616+
<property name="rightMargin">
617+
<number>0</number>
618+
</property>
619+
<property name="bottomMargin">
620+
<number>0</number>
621+
</property>
622+
<item>
623+
<widget class="QPushButton" name="pushButtonRewind">
624+
<property name="minimumSize">
625+
<size>
626+
<width>0</width>
627+
<height>40</height>
628+
</size>
629+
</property>
630+
<property name="maximumSize">
631+
<size>
632+
<width>16777215</width>
633+
<height>40</height>
634+
</size>
635+
</property>
636+
<property name="focusPolicy">
637+
<enum>Qt::NoFocus</enum>
638+
</property>
639+
<property name="text">
640+
<string>Rewind blockchain</string>
641+
</property>
642+
</widget>
643+
</item>
644+
</layout>
645+
</item>
646+
<item>
647+
<widget class="QLabel" name="labelMessageRewind">
648+
<property name="text">
649+
<string>Rewind blockchain to last checkpoint</string>
650+
</property>
651+
<property name="alignment">
652+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
653+
</property>
654+
<property name="wordWrap">
655+
<bool>true</bool>
656+
</property>
657+
</widget>
658+
</item>
659+
</layout>
660+
</item>
587661
<item>
588662
<spacer name="verticalSpacer_7">
589663
<property name="orientation">
590664
<enum>Qt::Vertical</enum>
591665
</property>
666+
<property name="sizeType">
667+
<enum>QSizePolicy::Expanding</enum>
668+
</property>
592669
<property name="sizeHint" stdset="0">
593670
<size>
594671
<width>20</width>

src/qt/pivx/settings/settingswalletrepairwidget.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ SettingsWalletRepairWidget::SettingsWalletRepairWidget(PIVXGUI* _window, QWidget
2626
// Labels
2727
setCssProperty({ui->labelMessageSalvage, ui->labelMessageRescan, ui->labelMessageRecover1,
2828
ui->labelMessageRecover2, ui->labelMessageUpgrade, ui->labelMessageRebuild,
29-
ui->labelMessageDelete}, "text-main-settings");
29+
ui->labelMessageDelete, ui->labelMessageRewind}, "text-main-settings");
3030

3131
// Buttons
3232
setCssProperty({ui->pushButtonSalvage, ui->pushButtonRescan, ui->pushButtonRecover1,
3333
ui->pushButtonRecover2, ui->pushButtonUpgrade, ui->pushButtonRebuild,
34-
ui->pushButtonDelete}, "btn-primary");
34+
ui->pushButtonDelete, ui->pushButtonRewind}, "btn-primary");
3535

3636
// Wallet Repair Buttons
3737
connect(ui->pushButtonSalvage, &QPushButton::clicked, this, &SettingsWalletRepairWidget::walletSalvage);
@@ -41,6 +41,7 @@ SettingsWalletRepairWidget::SettingsWalletRepairWidget(PIVXGUI* _window, QWidget
4141
connect(ui->pushButtonUpgrade, &QPushButton::clicked, this, &SettingsWalletRepairWidget::walletUpgrade);
4242
connect(ui->pushButtonRebuild, &QPushButton::clicked, this, &SettingsWalletRepairWidget::walletReindex);
4343
connect(ui->pushButtonDelete, &QPushButton::clicked, this, &SettingsWalletRepairWidget::walletResync);
44+
connect(ui->pushButtonRewind, &QPushButton::clicked, this, &SettingsWalletRepairWidget::walletRewind);
4445
}
4546

4647
/** Restart wallet with "-salvagewallet" */
@@ -100,6 +101,25 @@ void SettingsWalletRepairWidget::walletResync()
100101
buildParameterlist(RESYNC);
101102
}
102103

104+
/** Restart wallet with "-rewindblockindex" */
105+
void SettingsWalletRepairWidget::walletRewind()
106+
{
107+
QString rewindWarning = tr("This will rewind your blocks to the most recent checkpoint.<br /><br />");
108+
rewindWarning += tr("Do you want to continue?.<br />");
109+
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm resync Blockchain"),
110+
rewindWarning,
111+
QMessageBox::Yes | QMessageBox::Cancel,
112+
QMessageBox::Cancel);
113+
114+
if (retval != QMessageBox::Yes) {
115+
// Rewind canceled
116+
return;
117+
}
118+
119+
// Restart and rewind
120+
buildParameterlist(REWIND);
121+
}
122+
103123
/** Build command-line parameter list for restart */
104124
void SettingsWalletRepairWidget::buildParameterlist(QString arg)
105125
{

src/qt/pivx/settings/settingswalletrepairwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public Q_SLOTS:
3535
void walletUpgrade();
3636
void walletReindex();
3737
void walletResync();
38+
void walletRewind();
3839

3940
private:
4041
Ui::SettingsWalletRepairWidget *ui;

test/functional/feature_rewind.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2019 The Bitcoin Core developers
3+
# Copyright (c) 2023 The PIVX Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or https://www.opensource.org/licenses/mit-license.php.
6+
7+
"""Test running pivxd with -rewindblockindex option.
8+
9+
- Start 2 Nodes
10+
- Sync both nodes to different chains
11+
- Stop and then start both nodes with -rewindblockindex
12+
13+
"""
14+
15+
from test_framework.test_framework import PivxTestFramework
16+
from test_framework.util import (
17+
assert_equal,
18+
connect_nodes,
19+
)
20+
21+
class RewindBlockIndexCheckpointTest(PivxTestFramework):
22+
def set_test_params(self):
23+
self.num_nodes = 2
24+
self.extra_args = [
25+
['-nuparams=PoS:201', '-nuparams=PoS_v2:201', "-whitelist=127.0.0.1", '-debug=0'], #right chain
26+
['-nuparams=PoS:301', '-nuparams=PoS_v2:301', "-whitelist=127.0.0.1", '-debug=0'] #wrong chain
27+
]
28+
29+
def run_test(self):
30+
self.log.info("Starting nodes")
31+
32+
res0 = self.nodes[0].getblockchaininfo()
33+
res1 = self.nodes[1].getblockchaininfo()
34+
35+
self.nodes[0].generate(1)
36+
self.nodes[1].generate(1)
37+
38+
res0 = self.nodes[0].getblockchaininfo()
39+
res1 = self.nodes[1].getblockchaininfo()
40+
41+
rightChain = res0["bestblockhash"]
42+
wrongChain = res1["bestblockhash"]
43+
44+
assert not rightChain==wrongChain
45+
46+
self.log.info("Restart Node1 (after upgrade window) with forced rewindblockindex")
47+
# restart node1 with right nuparams and rewindblockindex
48+
# on regtest only forced rewinds possible because there are no checkpoints
49+
self.restart_node(1, extra_args=['-nuparams=PoS:201', '-nuparams=PoS_v2:201', '-rewindblockindex', '-debug=0'])
50+
51+
res0 = self.nodes[0].getblockchaininfo()
52+
res1 = self.nodes[1].getblockchaininfo()
53+
54+
connect_nodes(self.nodes[0], 1)
55+
self.sync_blocks([self.nodes[i] for i in [0, 1]], timeout=120)
56+
57+
res0 = self.nodes[0].getblockchaininfo()
58+
res1 = self.nodes[1].getblockchaininfo()
59+
60+
assert_equal(res1["bestblockhash"], rightChain)
61+
62+
self.log.info("Node1 on right chain")
63+
64+
if __name__ == '__main__':
65+
RewindBlockIndexCheckpointTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
# Longest test should go first, to favor running tests in parallel
194194
# vv Tests less than 20m vv
195195
'feature_dbcrash.py',
196+
'feature_rewind.py', # ~ 353 sec
196197
'sapling_fillblock.py', # ~ 780 sec
197198
'feature_fee_estimation.py', # ~ 360 sec
198199
# vv Tests less than 5m vv

0 commit comments

Comments
 (0)