2023-08-16 19:27:31 +02:00
|
|
|
// Copyright (c) 2011-2020 The Bitcoin Core developers
|
2022-06-08 01:36:46 +02:00
|
|
|
// Copyright (c) 2014-2022 The Dash Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <qt/clientmodel.h>
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <qt/bantablemodel.h>
|
|
|
|
#include <qt/guiconstants.h>
|
|
|
|
#include <qt/guiutil.h>
|
|
|
|
#include <qt/peertablemodel.h>
|
2011-05-22 17:19:43 +02:00
|
|
|
|
2021-04-16 05:41:16 +02:00
|
|
|
#include <evo/deterministicmns.h>
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <clientversion.h>
|
Qt: Adds Governance tab (#4351)
* Qt: Adds settings option to showGovernanceTab
* Qt: Adds not-yet-functional Governance tab to UI
* library: adds hook into governance rom node interface
* Qt: WIP: puts CGovernanceObject hashes on Governance tab
WIP: basically ready to be filled out, most of the infra in place
now.
* Qt: Populates Governance table values
Governance table now contains real values for current columns. Display
columns may potentially change.
- want url in table if right click option opens url?
- What set of cols wanted? Show yes/no votes?
- Decide refresh functionality.
- Do we even want filter func? (checkbox show: proposal, trigger, active coming)
* qt: Shows Voting Status on Governance page
Towards DMT like Governance page, now shows voting status, but needs to
look at super blocks to determine if proposal period has passed and show
final funded or unfunded for past proposals.
* Qt: refactor governance tab to use Model-View arch
Refactors the QT Governance tab to use a Model-View architecture. The
list of Proposals is stored in a QAbstractItemModel, and a QTableView is
used to display.
This makes a much cleaner separation of concerns in the implementation.
Also, can now use the QSortFilterProxyModel to get responsive filtering.
Less internal state inside the GovernanceList, critical sections
removed.
- Needs update loop implemented.
- Needs Proposal detail widget implemented.
* qt: adds periodic update to gov proposal list
Periodically update list of governance related proposals.
* qt: populates governancelist voting status column
* qt: governancelist Porposal shows extra info on doubleClick
* qt: governancelist: reorder .cpp impl to match .h
* qt: governancelist: fixup based on CI
- Adds LOCK(cs_main) for call to pGovObj->IsValidLocally.
- retab, removes trailing whitespace in governancelist.{cpp,h}
* qt: clang-format for governancelist
* Fixes
- drop unused include
- use proper univalue "get_" functions
- shorter/translatable statuses
- shorter dates
- add missing css styles
* qt: addresses governancelist code review items
* qt: use enum to name columns of governancelist
* fix: clear context menu before adding new items
* fix: skip potential nullptr proposals
* improve: show proposal url in context menu
* refactor: tweak enum name, make sure it's int starting from 0, use full name
* fix: column count
* improve: make it sortable, sort by start_date by default
* qt: use full col name in voting status col change signal emit
* better sorting
* use mapToSource to fix data fetching
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-30 03:14:25 +02:00
|
|
|
#include <governance/object.h>
|
2020-10-01 16:05:57 +02:00
|
|
|
#include <interfaces/handler.h>
|
|
|
|
#include <interfaces/node.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <net.h>
|
2018-05-16 10:07:52 +02:00
|
|
|
#include <netbase.h>
|
2021-06-27 08:33:13 +02:00
|
|
|
#include <util/system.h>
|
2020-09-19 09:06:24 +02:00
|
|
|
#include <util/threadnames.h>
|
2020-05-19 14:34:54 +02:00
|
|
|
#include <validation.h>
|
2016-12-20 14:27:59 +01:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <stdint.h>
|
2021-01-26 11:14:06 +01:00
|
|
|
#include <functional>
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2013-09-04 11:52:45 +02:00
|
|
|
#include <QDebug>
|
2019-10-14 21:46:34 +02:00
|
|
|
#include <QThread>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QTimer>
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2017-07-10 16:41:14 +02:00
|
|
|
static int64_t nLastHeaderTipUpdateNotification = 0;
|
2015-11-26 16:39:40 +01:00
|
|
|
static int64_t nLastBlockTipUpdateNotification = 0;
|
2011-05-22 17:19:43 +02:00
|
|
|
|
2020-10-01 16:05:57 +02:00
|
|
|
ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QObject *parent) :
|
2014-06-03 14:42:20 +02:00
|
|
|
QObject(parent),
|
2017-04-17 21:37:36 +02:00
|
|
|
m_node(node),
|
2016-09-23 12:44:09 +02:00
|
|
|
optionsModel(_optionsModel),
|
2019-01-14 15:20:45 +01:00
|
|
|
peerTableModel(nullptr),
|
|
|
|
banTableModel(nullptr),
|
2019-10-14 21:46:34 +02:00
|
|
|
m_thread(new QThread(this))
|
2011-05-22 17:19:43 +02:00
|
|
|
{
|
2017-10-31 21:14:19 +01:00
|
|
|
cachedBestHeaderHeight = -1;
|
|
|
|
cachedBestHeaderTime = -1;
|
2017-04-17 21:57:19 +02:00
|
|
|
peerTableModel = new PeerTableModel(m_node, this);
|
2017-04-17 22:02:44 +02:00
|
|
|
banTableModel = new BanTableModel(m_node, this);
|
2021-04-19 16:52:04 +02:00
|
|
|
mnListCached = std::make_shared<CDeterministicMNList>();
|
2012-05-06 19:40:58 +02:00
|
|
|
|
2019-10-14 21:46:34 +02:00
|
|
|
QTimer* timer = new QTimer;
|
|
|
|
timer->setInterval(MODEL_UPDATE_DELAY);
|
|
|
|
connect(timer, &QTimer::timeout, [this] {
|
|
|
|
// no locking required at this point
|
|
|
|
// the following calls will acquire the required lock
|
|
|
|
Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage());
|
|
|
|
Q_EMIT islockCountChanged(m_node.llmq().getInstantSentLockCount());
|
|
|
|
});
|
|
|
|
connect(m_thread, &QThread::finished, timer, &QObject::deleteLater);
|
|
|
|
connect(m_thread, &QThread::started, [timer] { timer->start(); });
|
|
|
|
// move timer to thread so that polling doesn't disturb main event loop
|
|
|
|
timer->moveToThread(m_thread);
|
|
|
|
m_thread->start();
|
2020-09-19 09:06:24 +02:00
|
|
|
QTimer::singleShot(0, timer, []() {
|
|
|
|
util::ThreadRename("qt-clientmodl");
|
|
|
|
});
|
2019-10-14 21:46:34 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
subscribeToCoreSignals();
|
|
|
|
}
|
|
|
|
|
|
|
|
ClientModel::~ClientModel()
|
|
|
|
{
|
|
|
|
unsubscribeFromCoreSignals();
|
2019-10-14 21:46:34 +02:00
|
|
|
|
|
|
|
m_thread->quit();
|
|
|
|
m_thread->wait();
|
2011-05-22 17:19:43 +02:00
|
|
|
}
|
|
|
|
|
2014-02-16 19:48:27 +01:00
|
|
|
int ClientModel::getNumConnections(unsigned int flags) const
|
2011-05-22 17:19:43 +02:00
|
|
|
{
|
Backport Bitcoin PR#8085: p2p: Begin encapsulation (#1537)
* net: move CBanDB and CAddrDB out of net.h/cpp
This will eventually solve a circular dependency
* net: Create CConnman to encapsulate p2p connections
* net: Move socket binding into CConnman
* net: move OpenNetworkConnection into CConnman
* net: move ban and addrman functions into CConnman
* net: Add oneshot functions to CConnman
* net: move added node functions to CConnman
* net: Add most functions needed for vNodes to CConnman
* net: handle nodesignals in CConnman
* net: Pass CConnection to wallet rather than using the global
* net: Add rpc error for missing/disabled p2p functionality
* net: Pass CConnman around as needed
* gui: add NodeID to the peer table
* net: create generic functor accessors and move vNodes to CConnman
* net: move whitelist functions into CConnman
* net: move nLastNodeId to CConnman
* net: move nLocalHostNonce to CConnman
This behavior seems to have been quite racy and broken.
Move nLocalHostNonce into CNode, and check received nonces against all
non-fully-connected nodes. If there's a match, assume we've connected
to ourself.
* net: move messageHandlerCondition to CConnman
* net: move send/recv statistics to CConnman
* net: move SendBufferSize/ReceiveFloodSize to CConnman
* net: move nLocalServices/nRelevantServices to CConnman
These are in-turn passed to CNode at connection time. This allows us to offer
different services to different peers (or test the effects of doing so).
* net: move semOutbound and semMasternodeOutbound to CConnman
* net: SocketSendData returns written size
* net: move max/max-outbound to CConnman
* net: Pass best block known height into CConnman
CConnman then passes the current best height into CNode at creation time.
This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.
This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.
This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
* net: pass CClientUIInterface into CConnman
* net: Drop StartNode/StopNode and use CConnman directly
* net: Introduce CConnection::Options to avoid passing so many params
* net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::Options
* net: move vNodesDisconnected into CConnman
* Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting
* Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead
* net: move MAX_FEELER_CONNECTIONS into connman
2017-07-21 11:35:19 +02:00
|
|
|
CConnman::NumConnections connections = CConnman::CONNECTIONS_NONE;
|
|
|
|
|
|
|
|
if(flags == CONNECTIONS_IN)
|
|
|
|
connections = CConnman::CONNECTIONS_IN;
|
|
|
|
else if (flags == CONNECTIONS_OUT)
|
|
|
|
connections = CConnman::CONNECTIONS_OUT;
|
|
|
|
else if (flags == CONNECTIONS_ALL)
|
|
|
|
connections = CConnman::CONNECTIONS_ALL;
|
|
|
|
|
2017-04-17 21:37:36 +02:00
|
|
|
return m_node.getNodeCount(connections);
|
2011-05-22 17:19:43 +02:00
|
|
|
}
|
|
|
|
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
void ClientModel::setMasternodeList(const CDeterministicMNList& mnList, const CBlockIndex* tip)
|
2019-02-12 20:51:03 +01:00
|
|
|
{
|
|
|
|
LOCK(cs_mnlinst);
|
2021-04-16 05:41:16 +02:00
|
|
|
if (mnListCached->GetBlockHash() == mnList.GetBlockHash()) {
|
2019-02-12 20:51:03 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-04-16 05:41:16 +02:00
|
|
|
mnListCached = std::make_shared<CDeterministicMNList>(mnList);
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
mnListTip = tip;
|
2019-02-12 20:51:03 +01:00
|
|
|
Q_EMIT masternodeListChanged();
|
|
|
|
}
|
|
|
|
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
std::pair<CDeterministicMNList, const CBlockIndex*> ClientModel::getMasternodeList() const
|
2015-02-24 14:24:42 +01:00
|
|
|
{
|
2019-02-12 20:51:03 +01:00
|
|
|
LOCK(cs_mnlinst);
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
return {*mnListCached, mnListTip};
|
2019-02-12 20:51:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientModel::refreshMasternodeList()
|
|
|
|
{
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
auto [mnList, tip] = m_node.evo().getListAtChainTip();
|
|
|
|
|
2019-02-12 20:51:03 +01:00
|
|
|
LOCK(cs_mnlinst);
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
setMasternodeList(mnList, tip);
|
2015-02-24 14:24:42 +01:00
|
|
|
}
|
|
|
|
|
2017-09-09 09:04:02 +02:00
|
|
|
int ClientModel::getHeaderTipHeight() const
|
|
|
|
{
|
2017-10-31 21:14:19 +01:00
|
|
|
if (cachedBestHeaderHeight == -1) {
|
|
|
|
// make sure we initially populate the cache via a cs_main lock
|
|
|
|
// otherwise we need to wait for a tip update
|
2017-04-17 21:37:36 +02:00
|
|
|
int height;
|
|
|
|
int64_t blockTime;
|
|
|
|
if (m_node.getHeaderTip(height, blockTime)) {
|
|
|
|
cachedBestHeaderHeight = height;
|
|
|
|
cachedBestHeaderTime = blockTime;
|
2017-10-31 21:14:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return cachedBestHeaderHeight;
|
2017-09-09 09:04:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t ClientModel::getHeaderTipTime() const
|
|
|
|
{
|
2017-10-31 21:14:19 +01:00
|
|
|
if (cachedBestHeaderTime == -1) {
|
2017-04-17 21:37:36 +02:00
|
|
|
int height;
|
|
|
|
int64_t blockTime;
|
|
|
|
if (m_node.getHeaderTip(height, blockTime)) {
|
|
|
|
cachedBestHeaderHeight = height;
|
|
|
|
cachedBestHeaderTime = blockTime;
|
2017-10-31 21:14:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return cachedBestHeaderTime;
|
2017-09-09 09:04:02 +02:00
|
|
|
}
|
|
|
|
|
2022-08-26 23:52:53 +02:00
|
|
|
void ClientModel::getAllGovernanceObjects(std::vector<CGovernanceObject> &obj)
|
Qt: Adds Governance tab (#4351)
* Qt: Adds settings option to showGovernanceTab
* Qt: Adds not-yet-functional Governance tab to UI
* library: adds hook into governance rom node interface
* Qt: WIP: puts CGovernanceObject hashes on Governance tab
WIP: basically ready to be filled out, most of the infra in place
now.
* Qt: Populates Governance table values
Governance table now contains real values for current columns. Display
columns may potentially change.
- want url in table if right click option opens url?
- What set of cols wanted? Show yes/no votes?
- Decide refresh functionality.
- Do we even want filter func? (checkbox show: proposal, trigger, active coming)
* qt: Shows Voting Status on Governance page
Towards DMT like Governance page, now shows voting status, but needs to
look at super blocks to determine if proposal period has passed and show
final funded or unfunded for past proposals.
* Qt: refactor governance tab to use Model-View arch
Refactors the QT Governance tab to use a Model-View architecture. The
list of Proposals is stored in a QAbstractItemModel, and a QTableView is
used to display.
This makes a much cleaner separation of concerns in the implementation.
Also, can now use the QSortFilterProxyModel to get responsive filtering.
Less internal state inside the GovernanceList, critical sections
removed.
- Needs update loop implemented.
- Needs Proposal detail widget implemented.
* qt: adds periodic update to gov proposal list
Periodically update list of governance related proposals.
* qt: populates governancelist voting status column
* qt: governancelist Porposal shows extra info on doubleClick
* qt: governancelist: reorder .cpp impl to match .h
* qt: governancelist: fixup based on CI
- Adds LOCK(cs_main) for call to pGovObj->IsValidLocally.
- retab, removes trailing whitespace in governancelist.{cpp,h}
* qt: clang-format for governancelist
* Fixes
- drop unused include
- use proper univalue "get_" functions
- shorter/translatable statuses
- shorter dates
- add missing css styles
* qt: addresses governancelist code review items
* qt: use enum to name columns of governancelist
* fix: clear context menu before adding new items
* fix: skip potential nullptr proposals
* improve: show proposal url in context menu
* refactor: tweak enum name, make sure it's int starting from 0, use full name
* fix: column count
* improve: make it sortable, sort by start_date by default
* qt: use full col name in voting status col change signal emit
* better sorting
* use mapToSource to fix data fetching
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-30 03:14:25 +02:00
|
|
|
{
|
2022-08-26 23:52:53 +02:00
|
|
|
m_node.gov().getAllNewerThan(obj, 0);
|
Qt: Adds Governance tab (#4351)
* Qt: Adds settings option to showGovernanceTab
* Qt: Adds not-yet-functional Governance tab to UI
* library: adds hook into governance rom node interface
* Qt: WIP: puts CGovernanceObject hashes on Governance tab
WIP: basically ready to be filled out, most of the infra in place
now.
* Qt: Populates Governance table values
Governance table now contains real values for current columns. Display
columns may potentially change.
- want url in table if right click option opens url?
- What set of cols wanted? Show yes/no votes?
- Decide refresh functionality.
- Do we even want filter func? (checkbox show: proposal, trigger, active coming)
* qt: Shows Voting Status on Governance page
Towards DMT like Governance page, now shows voting status, but needs to
look at super blocks to determine if proposal period has passed and show
final funded or unfunded for past proposals.
* Qt: refactor governance tab to use Model-View arch
Refactors the QT Governance tab to use a Model-View architecture. The
list of Proposals is stored in a QAbstractItemModel, and a QTableView is
used to display.
This makes a much cleaner separation of concerns in the implementation.
Also, can now use the QSortFilterProxyModel to get responsive filtering.
Less internal state inside the GovernanceList, critical sections
removed.
- Needs update loop implemented.
- Needs Proposal detail widget implemented.
* qt: adds periodic update to gov proposal list
Periodically update list of governance related proposals.
* qt: populates governancelist voting status column
* qt: governancelist Porposal shows extra info on doubleClick
* qt: governancelist: reorder .cpp impl to match .h
* qt: governancelist: fixup based on CI
- Adds LOCK(cs_main) for call to pGovObj->IsValidLocally.
- retab, removes trailing whitespace in governancelist.{cpp,h}
* qt: clang-format for governancelist
* Fixes
- drop unused include
- use proper univalue "get_" functions
- shorter/translatable statuses
- shorter dates
- add missing css styles
* qt: addresses governancelist code review items
* qt: use enum to name columns of governancelist
* fix: clear context menu before adding new items
* fix: skip potential nullptr proposals
* improve: show proposal url in context menu
* refactor: tweak enum name, make sure it's int starting from 0, use full name
* fix: column count
* improve: make it sortable, sort by start_date by default
* qt: use full col name in voting status col change signal emit
* better sorting
* use mapToSource to fix data fetching
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-30 03:14:25 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 19:38:45 +02:00
|
|
|
int ClientModel::getNumBlocks() const
|
|
|
|
{
|
|
|
|
if (m_cached_num_blocks == -1) {
|
|
|
|
m_cached_num_blocks = m_node.getNumBlocks();
|
|
|
|
}
|
|
|
|
return m_cached_num_blocks;
|
|
|
|
}
|
|
|
|
|
2023-04-10 21:16:08 +02:00
|
|
|
uint256 ClientModel::getBestBlockHash()
|
|
|
|
{
|
2020-06-01 14:04:36 +02:00
|
|
|
uint256 tip{WITH_LOCK(m_cached_tip_mutex, return m_cached_tip_blocks)};
|
|
|
|
|
|
|
|
if (!tip.IsNull()) {
|
|
|
|
return tip;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lock order must be: first `cs_main`, then `m_cached_tip_mutex`.
|
|
|
|
// The following will lock `cs_main` (and release it), so we must not
|
|
|
|
// own `m_cached_tip_mutex` here.
|
|
|
|
tip = m_node.getBestBlockHash();
|
|
|
|
|
2023-04-10 21:16:08 +02:00
|
|
|
LOCK(m_cached_tip_mutex);
|
2020-06-01 14:04:36 +02:00
|
|
|
// We checked that `m_cached_tip_blocks` is not null above, but then we
|
|
|
|
// released the mutex `m_cached_tip_mutex`, so it could have changed in the
|
|
|
|
// meantime. Thus, check again.
|
2023-04-10 21:16:08 +02:00
|
|
|
if (m_cached_tip_blocks.IsNull()) {
|
2020-06-01 14:04:36 +02:00
|
|
|
m_cached_tip_blocks = tip;
|
2023-04-10 21:16:08 +02:00
|
|
|
}
|
|
|
|
return m_cached_tip_blocks;
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:07:14 +02:00
|
|
|
void ClientModel::updateNumConnections(int numConnections)
|
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT numConnectionsChanged(numConnections);
|
2012-05-05 16:07:14 +02:00
|
|
|
}
|
|
|
|
|
2017-09-11 15:38:14 +02:00
|
|
|
void ClientModel::updateNetworkActive(bool networkActive)
|
|
|
|
{
|
|
|
|
Q_EMIT networkActiveChanged(networkActive);
|
|
|
|
}
|
|
|
|
|
2016-03-21 12:54:28 +01:00
|
|
|
void ClientModel::updateAlert()
|
2012-05-05 16:07:14 +02:00
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT alertsChanged(getStatusBarWarnings());
|
2011-05-30 20:20:12 +02:00
|
|
|
}
|
|
|
|
|
2012-10-21 21:23:13 +02:00
|
|
|
enum BlockSource ClientModel::getBlockSource() const
|
2012-09-13 14:33:52 +02:00
|
|
|
{
|
2017-04-17 21:37:36 +02:00
|
|
|
if (m_node.getReindex())
|
2020-06-09 05:44:04 +02:00
|
|
|
return BlockSource::REINDEX;
|
2017-04-17 21:37:36 +02:00
|
|
|
else if (m_node.getImporting())
|
2020-06-09 05:44:04 +02:00
|
|
|
return BlockSource::DISK;
|
2013-04-10 15:45:49 +02:00
|
|
|
else if (getNumConnections() > 0)
|
2020-06-09 05:44:04 +02:00
|
|
|
return BlockSource::NETWORK;
|
2013-04-10 15:45:49 +02:00
|
|
|
|
2020-06-09 05:44:04 +02:00
|
|
|
return BlockSource::NONE;
|
2012-09-13 14:33:52 +02:00
|
|
|
}
|
|
|
|
|
2011-12-13 20:00:21 +01:00
|
|
|
QString ClientModel::getStatusBarWarnings() const
|
|
|
|
{
|
2020-06-10 15:50:50 +02:00
|
|
|
return QString::fromStdString(m_node.getWarnings().translated);
|
2011-12-13 20:00:21 +01:00
|
|
|
}
|
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
OptionsModel *ClientModel::getOptionsModel()
|
|
|
|
{
|
2011-06-03 21:03:20 +02:00
|
|
|
return optionsModel;
|
|
|
|
}
|
|
|
|
|
2014-05-23 19:09:59 +02:00
|
|
|
PeerTableModel *ClientModel::getPeerTableModel()
|
|
|
|
{
|
|
|
|
return peerTableModel;
|
|
|
|
}
|
|
|
|
|
2015-06-20 20:27:03 +02:00
|
|
|
BanTableModel *ClientModel::getBanTableModel()
|
|
|
|
{
|
|
|
|
return banTableModel;
|
|
|
|
}
|
|
|
|
|
2011-07-01 17:06:36 +02:00
|
|
|
QString ClientModel::formatFullVersion() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(FormatFullVersion());
|
|
|
|
}
|
2012-04-07 02:06:53 +02:00
|
|
|
|
2015-08-06 15:40:50 +02:00
|
|
|
QString ClientModel::formatSubVersion() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(strSubVersion);
|
|
|
|
}
|
|
|
|
|
2012-10-24 21:47:07 +02:00
|
|
|
bool ClientModel::isReleaseVersion() const
|
|
|
|
{
|
|
|
|
return CLIENT_VERSION_IS_RELEASE;
|
|
|
|
}
|
|
|
|
|
2012-05-21 23:05:54 +02:00
|
|
|
QString ClientModel::formatClientStartupTime() const
|
2012-05-12 00:28:58 +02:00
|
|
|
{
|
2017-06-27 11:33:32 +02:00
|
|
|
return QDateTime::fromTime_t(GetStartupTime()).toString();
|
2012-05-12 00:28:58 +02:00
|
|
|
}
|
2012-05-06 19:40:58 +02:00
|
|
|
|
2017-09-09 09:04:02 +02:00
|
|
|
QString ClientModel::dataDir() const
|
|
|
|
{
|
2016-11-07 14:16:54 +01:00
|
|
|
return GUIUtil::boostPathToQString(GetDataDir());
|
2017-09-09 09:04:02 +02:00
|
|
|
}
|
|
|
|
|
2018-10-18 12:31:15 +02:00
|
|
|
QString ClientModel::blocksDir() const
|
|
|
|
{
|
|
|
|
return GUIUtil::boostPathToQString(GetBlocksDir());
|
|
|
|
}
|
|
|
|
|
2015-06-20 20:27:03 +02:00
|
|
|
void ClientModel::updateBanlist()
|
|
|
|
{
|
|
|
|
banTableModel->refresh();
|
|
|
|
}
|
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
// Handlers for core signals
|
2014-05-23 18:04:09 +02:00
|
|
|
static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress)
|
2012-05-06 19:40:58 +02:00
|
|
|
{
|
2014-05-23 18:04:09 +02:00
|
|
|
// emits signal "showProgress"
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "showProgress", Qt::QueuedConnection,
|
2014-05-23 18:04:09 +02:00
|
|
|
Q_ARG(QString, QString::fromStdString(title)),
|
|
|
|
Q_ARG(int, nProgress));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2012-05-06 19:40:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
|
|
|
|
{
|
2015-01-08 11:44:25 +01:00
|
|
|
// Too noisy: qDebug() << "NotifyNumConnectionsChanged: " + QString::number(newNumConnections);
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
|
2012-05-06 19:40:58 +02:00
|
|
|
Q_ARG(int, newNumConnections));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2012-05-06 19:40:58 +02:00
|
|
|
}
|
|
|
|
|
2017-09-11 15:38:14 +02:00
|
|
|
static void NotifyNetworkActiveChanged(ClientModel *clientmodel, bool networkActive)
|
|
|
|
{
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", Qt::QueuedConnection,
|
2017-09-11 15:38:14 +02:00
|
|
|
Q_ARG(bool, networkActive));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2017-09-11 15:38:14 +02:00
|
|
|
}
|
|
|
|
|
2016-03-21 12:54:28 +01:00
|
|
|
static void NotifyAlertChanged(ClientModel *clientmodel)
|
2012-05-06 19:40:58 +02:00
|
|
|
{
|
2016-03-21 12:54:28 +01:00
|
|
|
qDebug() << "NotifyAlertChanged";
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection);
|
|
|
|
assert(invoked);
|
2012-05-06 19:40:58 +02:00
|
|
|
}
|
|
|
|
|
2015-06-20 20:27:28 +02:00
|
|
|
static void BannedListChanged(ClientModel *clientmodel)
|
|
|
|
{
|
2015-06-23 21:10:42 +02:00
|
|
|
qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__);
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection);
|
|
|
|
assert(invoked);
|
2015-06-20 20:27:28 +02:00
|
|
|
}
|
|
|
|
|
2020-05-19 14:34:54 +02:00
|
|
|
static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, interfaces::BlockTip tip, double verificationProgress, bool fHeader)
|
2015-11-26 16:39:40 +01:00
|
|
|
{
|
2017-10-31 21:14:19 +01:00
|
|
|
if (fHeader) {
|
|
|
|
// cache best headers time and height to reduce future cs_main locks
|
2023-04-10 21:16:08 +02:00
|
|
|
clientmodel->cachedBestHeaderHeight = tip.block_height;
|
|
|
|
clientmodel->cachedBestHeaderTime = tip.block_time;
|
2018-08-01 19:38:45 +02:00
|
|
|
} else {
|
2023-04-10 21:16:08 +02:00
|
|
|
clientmodel->m_cached_num_blocks = tip.block_height;
|
|
|
|
WITH_LOCK(clientmodel->m_cached_tip_mutex, clientmodel->m_cached_tip_blocks = tip.block_hash;);
|
2017-10-31 21:14:19 +01:00
|
|
|
}
|
2020-02-13 08:47:56 +01:00
|
|
|
|
2020-05-19 14:34:54 +02:00
|
|
|
// Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex.
|
|
|
|
const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX;
|
|
|
|
const int64_t now = throttle ? GetTimeMillis() : 0;
|
|
|
|
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
|
|
|
if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
|
|
|
|
return;
|
2015-11-26 16:39:40 +01:00
|
|
|
}
|
2020-05-19 14:34:54 +02:00
|
|
|
|
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
|
|
|
Q_ARG(int, tip.block_height),
|
|
|
|
Q_ARG(QDateTime, QDateTime::fromTime_t(tip.block_time)),
|
|
|
|
Q_ARG(QString, QString::fromStdString(tip.block_hash.ToString())),
|
|
|
|
Q_ARG(double, verificationProgress),
|
|
|
|
Q_ARG(bool, fHeader),
|
|
|
|
Q_ARG(SynchronizationState, sync_state));
|
|
|
|
assert(invoked);
|
|
|
|
nLastUpdateNotification = now;
|
2019-04-25 17:38:49 +02:00
|
|
|
}
|
2019-02-12 20:51:03 +01:00
|
|
|
|
2021-08-10 21:41:00 +02:00
|
|
|
static void NotifyChainLock(ClientModel *clientmodel, const std::string& bestChainLockHash, int bestChainLockHeight)
|
|
|
|
{
|
|
|
|
// emits signal "chainlockChanged"
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "chainLockChanged", Qt::QueuedConnection,
|
2021-08-10 21:41:00 +02:00
|
|
|
Q_ARG(QString, QString::fromStdString(bestChainLockHash)),
|
|
|
|
Q_ARG(int, bestChainLockHeight));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2021-08-10 21:41:00 +02:00
|
|
|
}
|
|
|
|
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
static void NotifyMasternodeListChanged(ClientModel *clientmodel, const CDeterministicMNList& newList, const CBlockIndex* pindex)
|
2019-04-25 17:38:49 +02:00
|
|
|
{
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
clientmodel->setMasternodeList(newList, pindex);
|
2015-11-26 16:39:40 +01:00
|
|
|
}
|
|
|
|
|
2016-02-19 19:09:54 +01:00
|
|
|
static void NotifyAdditionalDataSyncProgressChanged(ClientModel *clientmodel, double nSyncProgress)
|
|
|
|
{
|
2019-07-09 11:47:55 +02:00
|
|
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "additionalDataSyncProgressChanged", Qt::QueuedConnection,
|
2016-02-19 19:09:54 +01:00
|
|
|
Q_ARG(double, nSyncProgress));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2016-02-19 19:09:54 +01:00
|
|
|
}
|
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
void ClientModel::subscribeToCoreSignals()
|
|
|
|
{
|
|
|
|
// Connect signals to client
|
2021-08-17 22:31:09 +02:00
|
|
|
m_handler_show_progress = m_node.handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
|
|
|
|
m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(std::bind(NotifyNumConnectionsChanged, this, std::placeholders::_1));
|
|
|
|
m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(std::bind(NotifyNetworkActiveChanged, this, std::placeholders::_1));
|
|
|
|
m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this));
|
|
|
|
m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this));
|
2023-04-10 21:16:08 +02:00
|
|
|
m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, false));
|
2021-08-17 22:31:09 +02:00
|
|
|
m_handler_notify_chainlock = m_node.handleNotifyChainLock(std::bind(NotifyChainLock, this, std::placeholders::_1, std::placeholders::_2));
|
2023-04-10 21:16:08 +02:00
|
|
|
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, true));
|
fix: possible assert call if nHeight in CDeterministicMNList is higher then Tip (#5590)
## Issue being fixed or feature implemented
fix: possible assert call if nHeight in CDeterministicMNListDiff is
higher than Tip
Example of new log:
```
2023-09-28T17:35:50Z GetProjectedMNPayeesAtChainTip WARNING pindex is nullptr due to height=914160 chain height=914159
```
instead assert call:
```
...
#6 0x00007ffff7a33b86 in __assert_fail (assertion=0x55555783afd2 "pindex", file=0x5555577f2ed8 "llmq/utils.cpp", line=730,
function=0x5555577f2448 "bool llmq::utils::IsMNRewardReallocationActive(const CBlockIndex*)") at ./assert/assert.c:101
#7 0x0000555555ab7daf in llmq::utils::IsMNRewardReallocationActive (pindex=<optimized out>) at llmq/utils.cpp:730
#8 0x00005555559458ad in CDeterministicMNList::GetProjectedMNPayees (this=this@entry=0x7fffffffc690, pindex=0x0, nCount=<optimized out>, nCount@entry=2147483647)
at evo/deterministicmns.cpp:231
#9 0x000055555594614f in CDeterministicMNList::GetProjectedMNPayeesAtChainTip (this=this@entry=0x7fffffffc690, nCount=nCount@entry=2147483647) at evo/deterministicmns.cpp:216
#10 0x00005555558c9f51 in MasternodeList::updateDIP3List (this=this@entry=0x55555908cfd0) at qt/masternodelist.cpp:194
#11 0x00005555558ca9a0 in MasternodeList::updateDIP3ListScheduled (this=0x55555908cfd0) at qt/masternodelist.cpp:157
#12 0x000055555684a60f in void doActivate<false>(QObject*, int, void**) ()
#13 0x00005555568525b1 in QTimer::timerEvent(QTimerEvent*) ()
#14 0x0000555556844ce5 in QObject::event(QEvent*) ()
#15 0x0000555556ac3252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
#16 0x000055555681e6b8 in QCoreApplication::sendEvent(QObject*, QEvent*) ()
#17 0x000055555686de2a in QTimerInfoList::activateTimers() ()
#18 0x000055555686be84 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#19 0x00005555569bf8a2 in QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#20 0x000055555681caf6 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
#21 0x0000555556825f8a in QCoreApplication::exec() ()
...
```
## What was done?
ClientModel returns now a pair: MNList and CBlockIndex; so, we always
know the which one has been used even if current chain is switched.
## How Has This Been Tested?
Run on my localhost from `c034ff0c2606142ba3e8894bc74f693b87374e5c` -
aborted with backtrace like above.
With both of commit - no assert more.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
---------
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-10-28 02:53:27 +02:00
|
|
|
m_handler_notify_masternodelist_changed = m_node.handleNotifyMasternodeListChanged(std::bind(NotifyMasternodeListChanged, this, std::placeholders::_1, std::placeholders::_2));
|
2021-08-17 22:31:09 +02:00
|
|
|
m_handler_notify_additional_data_sync_progess_changed = m_node.handleNotifyAdditionalDataSyncProgressChanged(std::bind(NotifyAdditionalDataSyncProgressChanged, this, std::placeholders::_1));
|
2012-05-06 19:40:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientModel::unsubscribeFromCoreSignals()
|
|
|
|
{
|
|
|
|
// Disconnect signals from client
|
2017-04-17 21:37:36 +02:00
|
|
|
m_handler_show_progress->disconnect();
|
|
|
|
m_handler_notify_num_connections_changed->disconnect();
|
|
|
|
m_handler_notify_network_active_changed->disconnect();
|
|
|
|
m_handler_notify_alert_changed->disconnect();
|
|
|
|
m_handler_banned_list_changed->disconnect();
|
|
|
|
m_handler_notify_block_tip->disconnect();
|
2021-08-10 21:41:00 +02:00
|
|
|
m_handler_notify_chainlock->disconnect();
|
2017-04-17 21:37:36 +02:00
|
|
|
m_handler_notify_header_tip->disconnect();
|
|
|
|
m_handler_notify_masternodelist_changed->disconnect();
|
|
|
|
m_handler_notify_additional_data_sync_progess_changed->disconnect();
|
2012-05-06 19:40:58 +02:00
|
|
|
}
|
2018-05-16 10:07:52 +02:00
|
|
|
|
|
|
|
bool ClientModel::getProxyInfo(std::string& ip_port) const
|
|
|
|
{
|
|
|
|
proxyType ipv4, ipv6;
|
|
|
|
if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) {
|
|
|
|
ip_port = ipv4.proxy.ToStringIPPort();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|