Skip to content

Commit

Permalink
5.2.1.0, 2021-03-07, leisure
Browse files Browse the repository at this point in the history
Added
 - voting: Add wait warning to voting tab loading message #2039 (@cyrossignol)
 - rpc: Adds transaction hash and fees paid to consolidateunspent #2040 (@jamescowens)

Changed
- gui, voting: Make some minor adjustments for VotingDialog flow #2041 (@jamescowens)

Fixed
 - beacon, util, gui: Fix small error in beacon db for renewals and fix snapshot download functionality #2036 (@jamescowens)
  • Loading branch information
jamescowens committed Mar 8, 2021
2 parents 454f103 + f436052 commit 90d00b6
Show file tree
Hide file tree
Showing 21 changed files with 188 additions and 31 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [5.2.1.0] 2021-03-07, leisure
### Added
- voting: Add wait warning to voting tab loading message #2039 (@cyrossignol)
- rpc: Adds transaction hash and fees paid to consolidateunspent #2040 (@jamescowens)

### Changed
- gui, voting: Make some minor adjustments for VotingDialog flow #2041 (@jamescowens)

### Fixed
- beacon, util, gui: Fix small error in beacon db for renewals and fix snapshot download functionality #2036 (@jamescowens)

## [5.2.0.0] 2021-03-01, mandatory, "Hilda"
### Added
- gui: Add RAC column to wizard summary page projects table #1951 (@cyrossignol)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 5)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2021)
Expand Down
5 changes: 5 additions & 0 deletions src/gridcoin/accrual/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,11 @@ class AccrualSnapshotRepository
return m_registry.Deregister(height);
}

bool CloseRegistryFile()
{
return m_registry.Close();
}

private:
AccrualSnapshotRegistry m_registry; //!< Tracks snapshot files state.
}; // AccrualSnapshotRepository
Expand Down
56 changes: 50 additions & 6 deletions src/gridcoin/beacon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,15 @@ bool BeaconRegistry::TryRenewal(Beacon_ptr& current_beacon_ptr, int& height, con
renewal.m_prev_beacon_hash = current_beacon_ptr->m_hash;

// Put the renewal beacon into the db.
m_beacon_db.update(renewal.m_hash, height, renewal);
if (!m_beacon_db.insert(renewal.m_hash, height, renewal))
{
LogPrint(LogFlags::BEACON, "WARNING: %s: In renewal of beacon for cpid %s, address %s, hash %s, beacon db record "
"already exists.",
__func__,
renewal.m_cpid.ToString(),
renewal.GetAddress().ToString(),
renewal.m_hash.GetHex());
}

// Get the iterator to the renewal beacon.
auto renewal_iter = m_beacon_db.find(renewal.m_hash);
Expand Down Expand Up @@ -989,6 +997,35 @@ int BeaconRegistry::BeaconDB::Initialize(PendingBeaconMap& m_pending, BeaconMap&
{
bool status = true;
int height = 0;
uint32_t version = 0;

// First load the beacon db version from leveldb and check it against the constant in the class.
{
CTxDB txdb("r");

std::pair<std::string, std::string> key = std::make_pair("beacon_db", "version");

bool status = txdb.ReadGenericSerializable(key, version);

if (!status) version = 0;
}

if (version != CURRENT_VERSION)
{
LogPrint(LogFlags::BEACON, "WARNING: %s: Version level of the beacon db stored in leveldb, %u, does not "
"match that required in this code level, version %u. Clearing the leveldb beacon "
"storage and setting version level to match this code level.",
__func__,
version,
CURRENT_VERSION);

clear_leveldb();

LogPrint(LogFlags::BEACON, "INFO: %s: Leveldb beacon area cleared. Version level set to %u.",
__func__,
CURRENT_VERSION);
}


// If LoadDBHeight not successful or height is zero then leveldb has not been initialized before.
// LoadDBHeight will also set the private member variable m_height_stored from leveldb for this first call.
Expand Down Expand Up @@ -1175,6 +1212,9 @@ void BeaconRegistry::ResetInMemoryOnly()
m_beacon_db.clear_in_memory_only();
}

// Required to make the linker happy.
constexpr uint32_t BeaconRegistry::BeaconDB::CURRENT_VERSION;

void BeaconRegistry::BeaconDB::clear_in_memory_only()
{
m_historical.clear();
Expand All @@ -1189,15 +1229,19 @@ bool BeaconRegistry::BeaconDB::clear_leveldb()

CTxDB txdb("rw");

std::string key_type = "beacon_db";
std::string key_type = "beacon";
uint256 start_key_hint_beacon = uint256();

status &= txdb.EraseGenericSerializablesByKeyType(key_type, start_key_hint_beacon);

key_type = "beacon_db";
std::string start_key_hint_beacon_db {};

status &= txdb.EraseGenericSerializablesByKeyType(key_type, start_key_hint_beacon_db);

key_type = "beacon";
uint256 start_key_hint_beacon = uint256();

status &= txdb.EraseGenericSerializablesByKeyType(key_type, start_key_hint_beacon);
// We want to write back into leveldb the revision level of the db in the running code.
std::pair<std::string, std::string> key = std::make_pair(key_type, "version");
status &= txdb.WriteGenericSerializable(key, CURRENT_VERSION);

m_height_stored = 0;
m_recnum_stored = 0;
Expand Down
9 changes: 9 additions & 0 deletions src/gridcoin/beacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,15 @@ class BeaconRegistry : public IContractHandler
class BeaconDB
{
public:
//!
//! \brief Version number of the beacon db.
//!
//! CONSENSUS: Increment this value when introducing a breaking change to the beacon db. This
//! will ensure that when the wallet is restarted, the level db beacon storage will be cleared and
//! reloaded from the contract replay with the correct lookback scope.
//!
static constexpr uint32_t CURRENT_VERSION = 1;

//!
//! \brief Initializes the Beacon Registry map structures from the replay of the beacon states stored
//! in the beacon database.
Expand Down
8 changes: 3 additions & 5 deletions src/gridcoin/contract/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ void GRC::ReplayContracts(const CBlockIndex* pindex_end, const CBlockIndex* pind
// Only apply activations that have not already been stored/loaded into
// the beacon DB. This is at the block level, so we have to be careful here.
// If the pindex->nHeight is equal to the beacon_db_height, then the ActivatePending
// has already been replayed. This is different than below in ApplyContracts, where
// there can be more than one contract in a block, so the condition is subtly different.
// has already been replayed.
if (pindex->nHeight > beacon_db_height)
{
GetBeaconRegistry().ActivatePending(
Expand Down Expand Up @@ -510,9 +509,8 @@ void GRC::ApplyContracts(
{
for (const auto& contract : tx.GetContracts()) {
// Do not (re)apply contracts that have already been stored/loeaded into
// the beacon DB. Note here if pindex->nHeight == beacon_db_height, the contract
// will be replayed. This is because there can be more than one contract per block.
if ((pindex->nHeight < beacon_db_height) && contract.m_type == ContractType::BEACON)
// the beacon DB.
if ((pindex->nHeight <= beacon_db_height) && contract.m_type == ContractType::BEACON)
{
LogPrint(BCLog::LogFlags::CONTRACT, "INFO: %s: ApplyContract tx skipped: "
"pindex->height = %i <= beacon_db_height = %i and "
Expand Down
5 changes: 5 additions & 0 deletions src/gridcoin/gridcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ bool GRC::Initialize(ThreadHandlerPtr threads, CBlockIndex* pindexBest)
return true;
}

void GRC::CloseResearcherRegistryFile()
{
Tally::CloseRegistryFile();
}

void GRC::ScheduleBackgroundJobs(CScheduler& scheduler)
{
scheduler.schedule(CheckBlockIndexJob);
Expand Down
6 changes: 6 additions & 0 deletions src/gridcoin/gridcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ namespace GRC {
//!
bool Initialize(ThreadHandlerPtr threads, CBlockIndex* pindexBest);

//!
//! \brief This closes the underlying research file to support the snapshot update
//! process, which must remove the accrual directory as part of the blockchain cleanup.
//!
void CloseResearcherRegistryFile();

//!
//! \brief Set up Gridcoin-specific background jobs.
//!
Expand Down
10 changes: 10 additions & 0 deletions src/gridcoin/tally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,11 @@ class ResearcherTally

return Initialize(GetStartHeight(), SuperblockPtr::Empty());
}

bool CloseRegistryFile()
{
return m_snapshots.CloseRegistryFile();
}
}; // ResearcherTally

ResearcherTally g_researcher_tally; //!< Tracks lifetime research rewards.
Expand Down Expand Up @@ -1261,3 +1266,8 @@ const CBlockIndex* Tally::GetBaseline()
{
return g_researcher_tally.GetBaseline();
}

void Tally::CloseRegistryFile()
{
g_researcher_tally.CloseRegistryFile();
}
8 changes: 8 additions & 0 deletions src/gridcoin/tally.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,13 @@ class Tally
//!
const static CBlockIndex* GetBaseline();

//!
//! \brief This closes the underlying register file of the researcher repository. It
//! is ONLY used in Shutdown() to release the lock on the registry.dat file
//! so that a snapshot download process cleanup will succeed, since the accrual directory
//! needs to be removed.
//!
static void CloseRegistryFile();

};
}
2 changes: 2 additions & 0 deletions src/gridcoin/upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ bool Upgrade::CleanupBlockchainData()
if (!fs::remove_all(*Iter)) return false;
}
}

continue;
}

Expand All @@ -391,6 +392,7 @@ bool Upgrade::CleanupBlockchainData()
if (!fs::remove(*Iter))
return false;
}

continue;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ void Shutdown(void* parg)
StopNode();
bitdb.Flush(true);
StopRPCThreads();

// This is necessary here to prevent a snapshot download from failing at the cleanup
// step because of a write lock on accrual/registry.dat.
GRC::CloseResearcherRegistryFile();

fs::remove(GetPidFile());
UnregisterWallet(pwalletMain);
delete pwalletMain;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
ui->copyrightLabel->setText("Copyright 2009-2020 The Bitcoin/Peercoin/Black-Coin/Gridcoin developers");
ui->copyrightLabel->setText("Copyright 2009-2021 The Bitcoin/Peercoin/Black-Coin/Gridcoin developers");
}

void AboutDialog::setModel(ClientModel *model)
Expand Down
4 changes: 3 additions & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "util.h"
#include "winshutdownmonitor.h"
#include "gridcoin/upgrade.h"
#include "gridcoin/gridcoin.h"
#include "upgradeqt.h"

#include <QMessageBox>
Expand Down Expand Up @@ -404,7 +405,7 @@ int main(int argc, char *argv[])
//
CTxDB().Close();

if (Snapshot.SnapshotMain())
if (Snapshot.SnapshotMain(app))
LogPrintf("Snapshot: Success!");

else
Expand Down Expand Up @@ -560,6 +561,7 @@ int StartGridcoinQt(int argc, char *argv[], QApplication& app, OptionsModel& opt
threads->removeAll();
threads.reset();


return EXIT_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ void BitcoinGUI::gotoSendCoinsPage()
void BitcoinGUI::gotoVotingPage()
{
votingAction->setChecked(true);
votingPage->resetData();
//votingPage->loadPolls(false);
centralWidget->setCurrentWidget(votingPage);

exportAction->setEnabled(false);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
clientModel(parent),
timer(nullptr)
{
columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
columns << tr("Node ID") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
priv.reset(new PeerTablePriv());

// set up timer for auto refresh
Expand Down
11 changes: 1 addition & 10 deletions src/qt/upgradeqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <QtWidgets>
#include <QProgressDialog>
#include <QMessageBox>
#include <QApplication>
#include <QPixmap>
#include <QIcon>
#include <QString>
Expand All @@ -23,16 +22,8 @@ QString UpgradeQt::ToQString(const std::string& string)
return QString::fromStdString(string);
}

bool UpgradeQt::SnapshotMain()
bool UpgradeQt::SnapshotMain(QApplication& SnapshotApp)
{
// Keep this separate from the main application
int xargc = 1;
char *xargv[] = {(char*)"gridcoinresearch"};

QApplication SnapshotApp(xargc, xargv);

SnapshotApp.setOrganizationName("Gridcoin");
SnapshotApp.setApplicationName("Gridcoin-Qt");
SnapshotApp.processEvents();
SnapshotApp.setWindowIcon(QPixmap(":/images/gridcoin"));

Expand Down
3 changes: 2 additions & 1 deletion src/qt/upgradeqt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <string>
#include <QString>
#include <QApplication>

class UpgradeQt
{
Expand All @@ -20,7 +21,7 @@ class UpgradeQt
//!
//! \return Returns success of snapshot task.
//!
bool SnapshotMain();
bool SnapshotMain(QApplication& SnapshotApp);
//!
//! \brief Function called via thread to download snapshot and provide realtime updates of progress.
//!
Expand Down
Loading

0 comments on commit 90d00b6

Please sign in to comment.