Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] WIP QML Generate Snapshot Signet #446

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ QT_MOC_CPP = \
qml/models/moc_peerdetailsmodel.cpp \
qml/models/moc_peerlistsortproxy.cpp \
qml/models/moc_transaction.cpp \
qml/models/moc_snapshotqml.cpp \
qml/models/moc_walletlistmodel.cpp \
qml/models/moc_walletqmlmodel.cpp \
qml/moc_appmode.cpp \
Expand Down Expand Up @@ -132,6 +133,7 @@ BITCOIN_QT_H = \
qml/models/peerdetailsmodel.h \
qml/models/peerlistsortproxy.h \
qml/models/transaction.h \
qml/models/snapshotqml.h \
qml/models/walletlistmodel.h \
qml/models/walletqmlmodel.h \
qml/appmode.h \
Expand Down Expand Up @@ -329,6 +331,7 @@ BITCOIN_QML_BASE_CPP = \
qml/models/peerdetailsmodel.cpp \
qml/models/peerlistsortproxy.cpp \
qml/models/transaction.cpp \
qml/models/snapshotqml.cpp \
qml/models/walletlistmodel.cpp \
qml/models/walletqmlmodel.cpp \
qml/imageprovider.cpp \
Expand All @@ -353,12 +356,15 @@ QML_RES_ICONS = \
qml/res/icons/check.png \
qml/res/icons/copy.png \
qml/res/icons/coinbase.png \
qml/res/icons/circle-file.png \
qml/res/icons/circle-green-check.png \
qml/res/icons/cross.png \
qml/res/icons/error.png \
qml/res/icons/export.png \
qml/res/icons/flip-vertical.png \
qml/res/icons/gear.png \
qml/res/icons/gear-outline.png \
qml/res/icons/green-check.png \
qml/res/icons/hidden.png \
qml/res/icons/info.png \
qml/res/icons/minus.png \
Expand Down Expand Up @@ -393,6 +399,8 @@ QML_RES_QML = \
qml/components/NetworkIndicator.qml \
qml/components/ProxySettings.qml \
qml/components/Separator.qml \
qml/components/SnapshotGenSettings.qml \
qml/components/SnapshotSettings.qml \
qml/components/StorageLocations.qml \
qml/components/StorageOptions.qml \
qml/components/StorageSettings.qml \
Expand Down Expand Up @@ -450,6 +458,8 @@ QML_RES_QML = \
qml/pages/settings/SettingsDeveloper.qml \
qml/pages/settings/SettingsDisplay.qml \
qml/pages/settings/SettingsProxy.qml \
qml/pages/settings/SettingsSnapshot.qml \
qml/pages/settings/SettingsSnapshotGen.qml \
qml/pages/settings/SettingsStorage.qml \
qml/pages/settings/SettingsTheme.qml \
qml/pages/wallet/Activity.qml \
Expand Down
12 changes: 12 additions & 0 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <net_types.h> // For banmap_t
#include <netaddress.h> // For Network
#include <netbase.h> // For ConnectionDirection
#include <node/utxo_snapshot.h> // For SnapshotMetadata
#include <support/allocators/secure.h> // For SecureString
#include <util/translation.h>

Expand Down Expand Up @@ -208,6 +209,9 @@ class Node
//! List rpc commands.
virtual std::vector<std::string> listRpcCommands() = 0;

//! Load UTXO Snapshot.
virtual bool loadSnapshot(AutoFile& afile, const node::SnapshotMetadata& metadata, bool in_memory) = 0;

//! Set RPC timer interface if unset.
virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) = 0;

Expand Down Expand Up @@ -243,6 +247,14 @@ class Node
using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>;
virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;

//! Register handler for snapshot load progress.
using SnapshotLoadProgressFn = std::function<void(double progress)>;
virtual std::unique_ptr<Handler> handleSnapshotLoadProgress(SnapshotLoadProgressFn fn) = 0;

//! Register handler for rewind progress messages.
using RewindProgressFn = std::function<void(double progress)>;
virtual std::unique_ptr<Handler> handleRewindProgress(RewindProgressFn fn) = 0;

//! Register handler for wallet loader constructed messages.
using InitWalletFn = std::function<void()>;
virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ class SigNetParams : public CChainParams {

vFixedSeeds.clear();

m_assumeutxo_data = MapAssumeutxo{
{
160000,
{AssumeutxoHash{uint256S("0x5225141cb62dee63ab3be95f9b03d60801f264010b1816d4bd00618b2736e7be")}, 1278002},
},
};

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
Expand Down
3 changes: 3 additions & 0 deletions src/kernel/notifications_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class Notifications

[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; }
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
virtual void blockTipDisconnected(SynchronizationState state, CBlockIndex& index) {}
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
virtual void snapshotLoadProgress(double progress) {}
virtual void rewindProgress(double progress) {}
virtual void warning(const bilingual_str& warning) {}

//! The flush error notification is sent to notify the user that an error
Expand Down
10 changes: 9 additions & 1 deletion src/node/interface_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ struct UISignals {
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
boost::signals2::signal<CClientUIInterface::SnapshotLoadProgressSig> SnapshotLoadProgress;
boost::signals2::signal<CClientUIInterface::RewindProgressSig> RewindProgress;
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
boost::signals2::signal<CClientUIInterface::NotifyBlockDisconnectedSig> NotifyBlockDisconnected;
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
};
static UISignals g_ui_signals;
Expand All @@ -43,8 +46,10 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
ADD_SIGNALS_IMPL_WRAPPER(ShowProgress);
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockDisconnected);
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);

ADD_SIGNALS_IMPL_WRAPPER(SnapshotLoadProgress);
ADD_SIGNALS_IMPL_WRAPPER(RewindProgress);
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
Expand All @@ -53,8 +58,11 @@ void CClientUIInterface::NotifyNumConnectionsChanged(PeersNumByType newNumConnec
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
void CClientUIInterface::SnapshotLoadProgress(double progress) { return g_ui_signals.SnapshotLoadProgress(progress); }
void CClientUIInterface::RewindProgress(double progress) { return g_ui_signals.RewindProgress(progress); }
void CClientUIInterface::NotifyBlockTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(s, i); }
void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, int64_t height, int64_t timestamp, bool presync) { return g_ui_signals.NotifyHeaderTip(s, height, timestamp, presync); }
void CClientUIInterface::NotifyBlockDisconnected(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockDisconnected(s, i); }
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }

bool InitError(const bilingual_str& str)
Expand Down
9 changes: 9 additions & 0 deletions src/node/interface_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,21 @@ class CClientUIInterface
*/
ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible);

/** Snapshot load progress. */
ADD_SIGNALS_DECL_WRAPPER(SnapshotLoadProgress, void, double progress);

/** Rewind progress. */
ADD_SIGNALS_DECL_WRAPPER(RewindProgress, void, double progress);

/** New block has been accepted */
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex*);

/** Best header has changed */
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, int64_t height, int64_t timestamp, bool presync);

/** Block disconnected */
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockDisconnected, void, SynchronizationState, const CBlockIndex*);

/** Banlist did change. */
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
};
Expand Down
15 changes: 14 additions & 1 deletion src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <node/context.h>
#include <node/interface_ui.h>
#include <node/transaction.h>
#include <node/utxo_snapshot.h>
#include <policy/feerate.h>
#include <policy/fees.h>
#include <policy/policy.h>
Expand Down Expand Up @@ -378,6 +379,14 @@ class NodeImpl : public Node
{
return MakeSignalHandler(::uiInterface.ShowProgress_connect(fn));
}
std::unique_ptr<Handler> handleSnapshotLoadProgress(SnapshotLoadProgressFn fn) override
{
return MakeSignalHandler(::uiInterface.SnapshotLoadProgress_connect(fn));
}
std::unique_ptr<Handler> handleRewindProgress(RewindProgressFn fn) override
{
return MakeSignalHandler(::uiInterface.RewindProgress_connect(fn));
}
std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) override
{
return MakeSignalHandler(::uiInterface.InitWallet_connect(fn));
Expand Down Expand Up @@ -417,6 +426,10 @@ class NodeImpl : public Node
{
m_context = context;
}
bool loadSnapshot(AutoFile& afile, const node::SnapshotMetadata& metadata, bool in_memory) override
{
return chainman().ActivateSnapshot(afile, metadata, in_memory);
}
ArgsManager& args() { return *Assert(Assert(m_context)->args); }
ChainstateManager& chainman() { return *Assert(m_context->chainman); }
NodeContext* m_context{nullptr};
Expand Down Expand Up @@ -532,7 +545,7 @@ class RpcHandlerImpl : public Handler
class ChainImpl : public Chain
{
public:
explicit ChainImpl(NodeContext& node) : m_node(node) {}
explicit ChainImpl(node::NodeContext& node) : m_node(node) {}
std::optional<int> getHeight() override
{
const int height{WITH_LOCK(::cs_main, return chainman().ActiveChain().Height())};
Expand Down
10 changes: 10 additions & 0 deletions src/node/kernel_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ void KernelNotifications::progress(const bilingual_str& title, int progress_perc
uiInterface.ShowProgress(title.translated, progress_percent, resume_possible);
}

void KernelNotifications::snapshotLoadProgress(double progress)
{
uiInterface.SnapshotLoadProgress(progress);
}

void KernelNotifications::rewindProgress(double progress)
{
uiInterface.RewindProgress(progress);
}

void KernelNotifications::warning(const bilingual_str& warning)
{
DoWarning(warning);
Expand Down
4 changes: 4 additions & 0 deletions src/node/kernel_notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class KernelNotifications : public kernel::Notifications

void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override;

void snapshotLoadProgress(double progress) override;

void rewindProgress(double progress) override;

void warning(const bilingual_str& warning) override;

void flushError(const std::string& debug_message) override;
Expand Down
8 changes: 8 additions & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<file>components/ProxySettings.qml</file>
<file>components/StorageLocations.qml</file>
<file>components/Separator.qml</file>
<file>components/SnapshotGenSettings.qml</file>
<file>components/SnapshotSettings.qml</file>
<file>components/StorageOptions.qml</file>
<file>components/StorageSettings.qml</file>
<file>components/ThemeSettings.qml</file>
Expand All @@ -27,6 +29,7 @@
<file>controls/LabeledTextInput.qml</file>
<file>controls/ExternalLink.qml</file>
<file>controls/FocusBorder.qml</file>
<file>controls/GreenCheckIcon.qml</file>
<file>controls/Header.qml</file>
<file>controls/Icon.qml</file>
<file>controls/InformationPage.qml</file>
Expand Down Expand Up @@ -71,6 +74,8 @@
<file>pages/settings/SettingsDeveloper.qml</file>
<file>pages/settings/SettingsDisplay.qml</file>
<file>pages/settings/SettingsProxy.qml</file>
<file>pages/settings/SettingsSnapshotGen.qml</file>
<file>pages/settings/SettingsSnapshot.qml</file>
<file>pages/settings/SettingsStorage.qml</file>
<file>pages/settings/SettingsTheme.qml</file>
<file>pages/wallet/Activity.qml</file>
Expand Down Expand Up @@ -101,12 +106,15 @@
<file alias="check">res/icons/check.png</file>
<file alias="copy">res/icons/copy.png</file>
<file alias="coinbase">res/icons/coinbase.png</file>
<file alias="circle-file">res/icons/circle-file.png</file>
<file alias="circle-green-check">res/icons/circle-green-check.png</file>
<file alias="cross">res/icons/cross.png</file>
<file alias="error">res/icons/error.png</file>
<file alias="export">res/icons/export.png</file>
<file alias="flip-vertical">res/icons/flip-vertical.png</file>
<file alias="gear">res/icons/gear.png</file>
<file alias="gear-outline">res/icons/gear-outline.png</file>
<file alias="green-check">res/icons/green-check.png</file>
<file alias="hidden">res/icons/hidden.png</file>
<file alias="info">res/icons/info.png</file>
<file alias="minus">res/icons/minus.png</file>
Expand Down
61 changes: 61 additions & 0 deletions src/qml/components/ConnectionSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,68 @@ import "../controls"
ColumnLayout {
id: root
signal next
signal gotoSnapshot
signal gotoGenerateSnapshot
property bool snapshotImportCompleted: chainModel.isSnapshotActive
property bool onboarding: false
property bool generateSnapshot: false
property bool isSnapshotGenerated: nodeModel.isSnapshotGenerated

spacing: 4
Setting {
id: gotoGenerateSnapshot
visible: !root.onboarding
Layout.fillWidth: true
header: qsTr("Generate snapshot")
description: qsTr("Speed up the setup of other nodes")
actionItem: Item {
width: 26
height: 26
CaretRightIcon {
anchors.centerIn: parent
color: gotoGenerateSnapshot.stateColor
}
}
onClicked: {
if (!nodeModel.isSnapshotFileExists()) {
root.generateSnapshot = true
root.gotoGenerateSnapshot()
} else {
root.gotoGenerateSnapshot()
}
}
}
Separator {
visible: !root.onboarding
Layout.fillWidth: true
}
Setting {
id: gotoSnapshot
visible: !root.onboarding
Layout.fillWidth: true
header: qsTr("Load snapshot")
description: qsTr("Instant use with background sync")
actionItem: Item {
width: 26
height: 26
CaretRightIcon {
anchors.centerIn: parent
visible: !snapshotImportCompleted
color: gotoSnapshot.stateColor
}
GreenCheckIcon {
anchors.centerIn: parent
visible: snapshotImportCompleted
color: Theme.color.transparent
size: 30
}
}
onClicked: root.gotoSnapshot()
}
Separator {
visible: !root.onboarding
Layout.fillWidth: true
}
Setting {
Layout.fillWidth: true
header: qsTr("Enable listening")
Expand Down
Loading
Loading