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

gui: Build onboarding/beacon wizard #1739

Merged
merged 22 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e9021c5
Remove the legacy "new user wizard"
cyrossignol Jun 17, 2020
88b5100
Create default configuration file on init
cyrossignol Jun 17, 2020
63089ba
Move non-developer DNS seeds to default config addnodes
cyrossignol Jun 17, 2020
5f813eb
Move Quorum::MyMagnitude() method to Researcher API
cyrossignol Jun 17, 2020
5b47b46
Add Tally API for direct accrual calculation
cyrossignol Jun 17, 2020
e226003
Refactor GUI researcher data presentation into a proper view model
cyrossignol Jun 17, 2020
ef87b55
Tweak design and layout of sections on GUI overview page
cyrossignol Jun 17, 2020
b585be9
Add pending research reward accrual to GUI overview page
cyrossignol Jun 17, 2020
2c1d1f6
Fix GUI button focus state styles for light/dark themes
cyrossignol Jun 17, 2020
93d859d
Add API for updating a researcher's email address
cyrossignol Jun 17, 2020
dbb34a8
Optimize researcher context refresh hook
cyrossignol Jun 17, 2020
4ea7f53
Improve local BOINC project to whitelist matching
cyrossignol Jun 17, 2020
86b66c4
Skip beacon advertisement when already pending
cyrossignol Jun 17, 2020
e42efc1
Optimize and refactor explain magnitude
cyrossignol Jun 17, 2020
3fca883
Improve local pending beacon tracking
cyrossignol Jun 17, 2020
9f17e0d
Create GUI researcher configuration wizard
cyrossignol Jun 17, 2020
76c4327
Add researcher wizard to settings and tray icon menus
cyrossignol Jun 17, 2020
5655210
Show researcher wizard by clicking beacon status icon
cyrossignol Jun 17, 2020
0eaa971
Fix the awful light/dark GUI theme tab styles
cyrossignol Jun 17, 2020
402edba
Fix segfault in accrual age calculation
cyrossignol Jun 17, 2020
0d0ee04
Tweak wizard page descriptions from review suggestions
cyrossignol Jun 18, 2020
549868e
Serialize beacon public key for self-service deletion
cyrossignol Jun 19, 2020
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
22 changes: 22 additions & 0 deletions gridcoinresearch.pro
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qu

DEPENDPATH += src src/json src/qt
HEADERS += src/qt/bitcoingui.h \
src/qt/researcher/projecttablemodel.h \
src/qt/researcher/researchermodel.h \
src/qt/researcher/researcherwizard.h \
src/qt/researcher/researcherwizardauthpage.h \
src/qt/researcher/researcherwizardbeaconpage.h \
src/qt/researcher/researcherwizardemailpage.h \
src/qt/researcher/researcherwizardprojectspage.h \
src/qt/researcher/researcherwizardsummarypage.h \
src/qt/transactiontablemodel.h \
src/qt/addresstablemodel.h \
src/qt/optionsdialog.h \
Expand Down Expand Up @@ -265,6 +273,14 @@ HEADERS += src/qt/bitcoingui.h \


SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/researcher/projecttablemodel.cpp \
src/qt/researcher/researchermodel.cpp \
src/qt/researcher/researcherwizard.cpp \
src/qt/researcher/researcherwizardauthpage.cpp \
src/qt/researcher/researcherwizardbeaconpage.cpp \
src/qt/researcher/researcherwizardemailpage.cpp \
src/qt/researcher/researcherwizardprojectspage.cpp \
src/qt/researcher/researcherwizardsummarypage.cpp \
src/qt/transactiontablemodel.cpp \
src/qt/addresstablemodel.cpp \
src/qt/optionsdialog.cpp \
Expand Down Expand Up @@ -354,6 +370,12 @@ RESOURCES += \

FORMS += \
src/qt/forms/coincontroldialog.ui \
src/qt/forms/researcherwizard.ui \
src/qt/forms/researcherwizardauthpage.ui \
src/qt/forms/researcherwizardbeaconpage.ui \
src/qt/forms/researcherwizardemailpage.ui \
src/qt/forms/researcherwizardprojectspage.ui \
src/qt/forms/researcherwizardsummarypage.ui \
src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/addressbookpage.ui \
src/qt/forms/signverifymessagedialog.ui \
Expand Down
37 changes: 34 additions & 3 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ QT_FORMS_UI = \
qt/forms/addressbookpage.ui \
qt/forms/editaddressdialog.ui \
qt/forms/overviewpage.ui \
qt/forms/researcherwizard.ui \
qt/forms/researcherwizardauthpage.ui \
qt/forms/researcherwizardbeaconpage.ui \
qt/forms/researcherwizardemailpage.ui \
qt/forms/researcherwizardprojectspage.ui \
qt/forms/researcherwizardsummarypage.ui \
qt/forms/sendcoinsdialog.ui \
qt/forms/transactiondescdialog.ui \
qt/forms/askpassphrasedialog.ui \
qt/forms/sendcoinsentry.ui

QT_MOC_CPP = \
qt/moc_aboutdialog.cpp \
qt/moc_addressbookpage.cpp \
Expand Down Expand Up @@ -124,7 +130,15 @@ QT_MOC_CPP = \
qt/moc_transactiontablemodel.cpp \
qt/moc_transactionview.cpp \
qt/moc_votingdialog.cpp \
qt/moc_walletmodel.cpp
qt/moc_walletmodel.cpp \
qt/researcher/moc_projecttablemodel.cpp \
qt/researcher/moc_researchermodel.cpp \
qt/researcher/moc_researcherwizard.cpp \
qt/researcher/moc_researcherwizardauthpage.cpp \
qt/researcher/moc_researcherwizardbeaconpage.cpp \
qt/researcher/moc_researcherwizardemailpage.cpp \
qt/researcher/moc_researcherwizardprojectspage.cpp \
qt/researcher/moc_researcherwizardsummarypage.cpp

GRIDCOIN_MM = \
qt/macdockiconhandler.mm \
Expand Down Expand Up @@ -169,6 +183,14 @@ GRIDCOINRESEARCH_QT_H = \
qt/qtipcserver.h \
qt/qvalidatedlineedit.h \
qt/qvaluecombobox.h \
qt/researcher/projecttablemodel.h \
qt/researcher/researchermodel.h \
qt/researcher/researcherwizard.h \
qt/researcher/researcherwizardauthpage.h \
qt/researcher/researcherwizardbeaconpage.h \
qt/researcher/researcherwizardemailpage.h \
qt/researcher/researcherwizardprojectspage.h \
qt/researcher/researcherwizardsummarypage.h \
qt/rpcconsole.h \
qt/sendcoinsdialog.h \
qt/sendcoinsentry.h \
Expand Down Expand Up @@ -212,6 +234,14 @@ GRIDCOINRESEARCH_QT_CPP = \
qt/qtipcserver.cpp \
qt/qvalidatedlineedit.cpp \
qt/qvaluecombobox.cpp \
qt/researcher/projecttablemodel.cpp \
qt/researcher/researchermodel.cpp \
qt/researcher/researcherwizard.cpp \
qt/researcher/researcherwizardauthpage.cpp \
qt/researcher/researcherwizardbeaconpage.cpp \
qt/researcher/researcherwizardemailpage.cpp \
qt/researcher/researcherwizardprojectspage.cpp \
qt/researcher/researcherwizardsummarypage.cpp \
qt/rpcconsole.cpp \
qt/sendcoinsdialog.cpp \
qt/sendcoinsentry.cpp \
Expand Down Expand Up @@ -277,6 +307,7 @@ RES_ICONS = \
qt/res/icons/tx_output.svg \
qt/res/icons/tx_por_ss.svg \
qt/res/icons/tx_por.svg \
qt/res/icons/warning.svg \
qt/res/icons/white_and_red_x.svg \
qt/res/icons/www.png \
qt/res/icons/icons_native/overview.svg \
Expand Down Expand Up @@ -409,7 +440,7 @@ CLEANFILES += $(CLEAN_QT)
gridcoinresearch_clean: FORCE
rm -f $(CLEAN_QT) $(qt_gridcoinresearch_OBJECTS) qt/gridcoinresearch$(EXEEXT)

gridcoinresearch:
gridcoinresearch:
@echo "$(ZIP_LIBS)"
qt/gridcoinresearch$(EXEEXT)

Expand Down
3 changes: 2 additions & 1 deletion src/contract/polls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "neuralnet/contract/contract.h"
#include "neuralnet/contract/message.h"
#include "neuralnet/quorum.h"
#include "neuralnet/researcher.h"
#include "neuralnet/superblock.h"
#include "neuralnet/tally.h"

Expand Down Expand Up @@ -174,7 +175,7 @@ std::pair<std::string, std::string> CreateVoteContract(std::string sTitle, std::
const std::string primary_cpid = NN::GetPrimaryCpid();

std::string GRCAddress = DefaultWalletAddress();
double dmag = NN::Quorum::MyMagnitude().Floating();
double dmag = NN::Researcher::Get()->Magnitude().Floating();
double poll_duration = PollDuration(sTitle) * 86400;

// Prevent Double Voting
Expand Down
31 changes: 26 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ bool static Bind(const CService &addr, bool fError = true) {
return true;
}

static void CreateNewConfigFile()
{
fsbridge::ofstream myConfig;
myConfig.open(GetConfigFile());

myConfig
<< "addnode=addnode-us-central.cycy.me\n"
<< "addnode=ec2-3-81-39-58.compute-1.amazonaws.com\n"
<< "addnode=gridcoin.crypto.fans\n"
<< "addnode=gridcoin.ddns.net\n"
<< "addnode=london.grcnode.co.uk\n"
<< "addnode=nuad.de\n"
<< "addnode=seeds.gridcoin.ifoggz-network.xyz\n"
<< "addnode=www.grcpool.com\n";
}

// Core-specific options shared between UI and daemon
std::string HelpMessage()
{
Expand Down Expand Up @@ -493,11 +509,17 @@ bool AppInit2(ThreadHandlerPtr threads)
// ********************************************************* Step 2: parameter interactions


// Gridcoin - Check to see if config is empty?
if (IsConfigFileEmpty())
{
uiInterface.ThreadSafeMessageBox(
"Configuration file empty. \n" + _("Please wait for new user wizard to start..."), "", 0);
try
{
CreateNewConfigFile();
ReadConfigFile(mapArgs, mapMultiArgs);
}
catch (const std::exception& e)
{
LogPrintf("WARNING: failed to create configuration file: %s", e.what());
}
}

//6-10-2014: R Halford: Updating Boost version to 1.5.5 to prevent sync issues; print the boost version to verify:
Expand Down Expand Up @@ -1113,8 +1135,7 @@ bool AppInit2(ThreadHandlerPtr threads)

NN::ReplayContracts(pindexBest);

uiInterface.InitMessage(_("Finding first applicable Research Project..."));
NN::Researcher::Reload();
NN::Researcher::Initialize();

if (!pwalletMain->IsLocked())
NN::Researcher::Get()->ImportBeaconKeysFromConfig(pwalletMain);
Expand Down
7 changes: 2 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,8 @@ void GetGlobalStatus()
GlobalStatusStruct.netWeight = RoundToString(GetEstimatedNetworkWeight() / 80.0,2);
//todo: use the real weight from miner status (requires scaling)
GlobalStatusStruct.coinWeight = sWeight;
GlobalStatusStruct.magnitude = NN::Quorum::MyMagnitude().ToString();
GlobalStatusStruct.cpid = NN::GetPrimaryCpid();
GlobalStatusStruct.poll = std::move(current_poll);

GlobalStatusStruct.status = msMiningErrors;

unsigned long stk_dropped;

{
Expand Down Expand Up @@ -2616,7 +2612,7 @@ class ClaimValidator
int64_t research_owed = 0;

if (const NN::CpidOption cpid = m_claim.m_mining_id.TryCpid()) {
research_owed = NN::Tally::GetComputer(*cpid, m_block.nTime, m_pindex)->Accrual();
research_owed = NN::Tally::GetAccrual(*cpid, m_block.nTime, m_pindex);
}

int64_t out_stake_owed;
Expand Down Expand Up @@ -2747,6 +2743,7 @@ bool GridcoinConnectBlock(
}

NN::Tally::RecordRewardBlock(pindex);
NN::Researcher::Refresh();

return true;
}
Expand Down
3 changes: 0 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ struct globalStatusType
std::string difficulty;
std::string netWeight;
std::string coinWeight;
std::string magnitude;
std::string cpid;
std::string status;
std::string poll;
std::string errors;
};
Expand Down
3 changes: 1 addition & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,7 @@ bool CreateGridcoinReward(
index.nVersion = blocknew.nVersion;
index.nHeight = pindexPrev->nHeight + 1;

const NN::AccrualComputer calc = NN::Tally::GetComputer(*cpid, blocknew.nTime, &index);
claim.m_research_subsidy = calc->Accrual();
claim.m_research_subsidy = NN::Tally::GetAccrual(*cpid, blocknew.nTime, &index);

// If no pending research subsidy value exists, build an investor claim.
// This avoids polluting the block index with non-research reward blocks
Expand Down
6 changes: 2 additions & 4 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,9 @@ void MapPort()
// The first name is used as information source for addrman.
// The second name should resolve to a list of seed addresses.
static const char *strDNSSeed[][2] = {
{"node.gridcoin.us", "node.gridcoin.us"},
{"london.grcnode.co.uk", "london.grcnode.co.uk"},
{"gridcoin.crypto.fans", "gridcoin.crypto.fans"},
{"addnode-us-central.cycy.me", "addnode-us-central.cycy.me"},
{"ec2-3-81-39-58.compute-1.amazonaws.com", "ec2-3-81-39-58.compute-1.amazonaws.com"},
{"node.grcpool.com", "node.grcpool.com"},
{"nuad.de", "nuad.de"},
{"seeds.gridcoin.ifoggz-network.xyz", "seeds.gridcoin.ifoggz-network.xyz"},
{"", ""},
};
Expand Down
10 changes: 6 additions & 4 deletions src/neuralnet/accrual/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ class SnapshotAccrualComputer : public IAccrualComputer, SnapshotCalculator
// a superblock after contract improvements for more accurate age.
//
if (m_account.IsNew()) {
const int64_t beacon_time = GetBeaconRegistry().Try(m_cpid)->m_timestamp;
if (const BeaconOption beacon = GetBeaconRegistry().Try(m_cpid)) {
const int64_t beacon_time = beacon->m_timestamp;

if (beacon_time <= 0) {
return 0;
if (beacon_time > 0) {
return m_payment_time - beacon_time;
}
}

return m_payment_time - beacon_time;
return 0;
}

return SnapshotCalculator::AccrualAge(m_account);
Expand Down
52 changes: 30 additions & 22 deletions src/neuralnet/beacon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,18 @@ BeaconPayload::BeaconPayload()
{
}

BeaconPayload::BeaconPayload(const Cpid cpid, Beacon beacon)
: m_cpid(cpid)
BeaconPayload::BeaconPayload(const uint32_t version, const Cpid cpid, Beacon beacon)
: m_version(version)
, m_cpid(cpid)
, m_beacon(std::move(beacon))
{
}

BeaconPayload::BeaconPayload(const Cpid cpid, Beacon beacon)
: BeaconPayload(CURRENT_VERSION, cpid, std::move(beacon))
{
}

BeaconPayload BeaconPayload::Parse(const std::string& key, const std::string& value)
{
const CpidOption cpid = MiningId::Parse(key).TryCpid();
Expand All @@ -181,13 +187,8 @@ BeaconPayload BeaconPayload::Parse(const std::string& key, const std::string& va
return BeaconPayload();
}

Beacon beacon = Beacon::Parse(value);

if (!beacon.WellFormed()) {
return BeaconPayload();
}

return BeaconPayload(*cpid, std::move(beacon));
// Legacy beacon payloads always parse to version 1:
return BeaconPayload(1, *cpid, Beacon::Parse(value));
}

bool BeaconPayload::Sign(CKey& private_key)
Expand Down Expand Up @@ -262,6 +263,26 @@ BeaconOption BeaconRegistry::TryActive(const Cpid& cpid, const int64_t now) cons
return nullptr;
}

std::vector<const PendingBeacon*> BeaconRegistry::FindPending(const Cpid cpid) const
{
// TODO: consider adding a lookup table for pending beacons keyed by CPID.
// Since the protocol just needs to look up pending beacons by public key,
// we just do a search here. Informational RPCs or local beacon management
// only need to call this occasionally.

std::vector<const PendingBeacon*> found;

for (const auto& pending_beacon_pair : m_pending) {
const PendingBeacon& beacon = pending_beacon_pair.second;

if (beacon.m_cpid == cpid) {
found.emplace_back(&beacon);
}
}

return found;
}

bool BeaconRegistry::ContainsActive(const Cpid& cpid, const int64_t now) const
{
if (const BeaconOption beacon = Try(cpid)) {
Expand All @@ -276,19 +297,6 @@ bool BeaconRegistry::ContainsActive(const Cpid& cpid) const
return ContainsActive(cpid, GetAdjustedTime());
}

std::vector<CKeyID> BeaconRegistry::FindPendingKeys(const Cpid& cpid) const
{
std::vector<CKeyID> found;

for (const auto& beacon_pair : m_pending) {
if (beacon_pair.second.m_cpid == cpid) {
found.emplace_back(beacon_pair.first);
}
}

return found;
}

void BeaconRegistry::Add(Contract contract)
{
BeaconPayload payload = contract.CopyPayloadAs<BeaconPayload>();
Expand Down
Loading