Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4066c5e
Add back in the in sync check in ScraperGetNeuralContract
jamescowens Jun 28, 2019
442f23b
Change type of AlignScraperFileManifestEntries to void
jamescowens Jun 29, 2019
c2e9b15
Primitive first cut of native SB serialization
jamescowens Jun 30, 2019
278aed9
Change (Un)SerializeSuperblock() for comparison purposes
jamescowens Jul 1, 2019
32abe1e
Add testnewsb temporary rpc function
jamescowens Jul 2, 2019
21a9244
Move superblock code to neuralnet directory
cyrossignol Jul 2, 2019
72fc52d
Move Superblock class into NN namespace
cyrossignol Jul 2, 2019
c539bf7
Refactor experimental SB serialization with compact integers
cyrossignol Jul 2, 2019
8e3a7bb
Merge pull request #24 from cyrossignol/integrated_scraper_2
jamescowens Jul 3, 2019
5de2528
Optimize NN::Cpid less than and greater than operators
cyrossignol Jul 3, 2019
352a51e
Merge branch 'development' into integrated_scraper_2
jamescowens Jul 3, 2019
0a69807
Merge pull request #25 from cyrossignol/integrated_scraper_2
jamescowens Jul 3, 2019
ae0b2fb
Add forgotten v11 condition for removing old RR signals
jamescowens Jul 6, 2019
9443c0d
Port VARINT encoding from Bitcoin
cyrossignol Jul 12, 2019
450bf16
Flesh out Superblock draft into full class
cyrossignol Jul 4, 2019
64c8ec7
Add tests for superblock classes
cyrossignol Jul 4, 2019
05cd455
Remove Compact<T> class used for serialization experiments
cyrossignol Jul 12, 2019
b09e21d
Remove redundant magnitude bounds in Superblock::PackLegacy
cyrossignol Jul 12, 2019
d9481d2
Switch superblock rounding from half-even to half-away-from-zero
cyrossignol Jul 14, 2019
301a66f
Add total credit to superblock project stats
cyrossignol Jul 14, 2019
24fd015
Update testnewsb RPC method
cyrossignol Jul 14, 2019
9599456
Merge pull request #26 from cyrossignol/integrated_scraper_2
jamescowens Jul 15, 2019
199dfed
Initial pass at wiring up new Superblock class
jamescowens Jul 15, 2019
87c24ea
Change superblock to variable assignment from FromStats
jamescowens Jul 15, 2019
8067e7d
Provide for keying std::unordered_map with NN::QuorumHash objects
cyrossignol Jul 17, 2019
e467f03
Merge pull request #27 from cyrossignol/integrated_scraper_2
jamescowens Jul 17, 2019
abf5bd0
Implement string parsing for NN::QuorumHash
cyrossignol Jul 17, 2019
14212c0
Merge pull request #28 from cyrossignol/integrated_scraper_2
jamescowens Jul 18, 2019
6c6cc89
Change delimiter for team whitelist string and file
jamescowens Jul 26, 2019
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
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ GRIDCOIN_CORE_H = \
compat/endian.h \
contract/polls.h \
contract/contract.h \
contract/superblock.h \
crypter.h \
db.h \
fwd.h \
Expand All @@ -95,6 +94,7 @@ GRIDCOIN_CORE_H = \
neuralnet/neuralnet_stub.h \
neuralnet/project.h \
neuralnet/researcher.h \
neuralnet/superblock.h \
netbase.h \
net.h \
pbkdf2.h \
Expand Down Expand Up @@ -135,7 +135,6 @@ GRIDCOIN_CORE_CPP = addrman.cpp \
checkpoints.cpp \
contract/polls.cpp \
contract/contract.cpp \
contract/superblock.cpp \
crypter.cpp \
db.cpp \
gridcoin.cpp \
Expand All @@ -151,6 +150,7 @@ GRIDCOIN_CORE_CPP = addrman.cpp \
neuralnet/cpid.cpp \
neuralnet/project.cpp \
neuralnet/researcher.cpp \
neuralnet/superblock.cpp \
netbase.cpp \
net.cpp \
noui.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ GRIDCOIN_TESTS =\
test/neuralnet/cpid_tests.cpp \
test/neuralnet/project_tests.cpp \
test/neuralnet/researcher_tests.cpp \
test/neuralnet/superblock_tests.cpp \
test/rpc_tests.cpp \
test/script_P2SH_tests.cpp \
test/script_tests.cpp \
test/serialize_tests.cpp \
test/sigopcount_tests.cpp \
test/test_gridcoin.cpp \
test/transaction_tests.cpp \
Expand Down
100 changes: 0 additions & 100 deletions src/contract/superblock.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions src/contract/superblock.h

This file was deleted.

5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#include "neuralnet/cpid.h"
#include "neuralnet/neuralnet.h"
#include "neuralnet/researcher.h"
#include "neuralnet/superblock.h"
#include "backup.h"
#include "appcache.h"
#include "tally.h"
#include "contract/contract.h"
#include "contract/superblock.h"
#include "scraper_net.h"

#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -1880,7 +1880,8 @@ int64_t GetProofOfStakeReward(uint64_t nCoinAge, int64_t nFees, std::string cpid
}

int64_t nTotalSubsidy = nSubsidy + nFees;
if (nBoinc > 1)
// This rule does not apply in v11
if (nBoinc > 1 && pindexLast->nVersion <= 10)
{
std::string sTotalSubsidy = RoundToString(CoinToDouble(nTotalSubsidy)+.00000123,8);
if (sTotalSubsidy.length() > 7)
Expand Down
16 changes: 16 additions & 0 deletions src/neuralnet/cpid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ bool Cpid::operator!=(const Cpid& other) const
return m_bytes != other.m_bytes;
}

bool Cpid::operator<(const Cpid& other) const
{
// CONSENSUS: Changing the behavior of this comparison operator will affect
// the sort order of protocol-sensitive maps (for example, superblocks).
//
return m_bytes < other.m_bytes;
}

bool Cpid::operator>(const Cpid& other) const
{
// CONSENSUS: Changing the behavior of this comparison operator will affect
// the sort order of protocol-sensitive maps (for example, superblocks).
//
return m_bytes > other.m_bytes;
}

bool Cpid::IsZero() const
{
const auto zero = [](const unsigned char& i) { return i == 0; };
Expand Down
30 changes: 30 additions & 0 deletions src/neuralnet/cpid.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ class Cpid
//!
bool operator!=(const Cpid& other) const;

//!
//! \brief Compare a supplied CPID value for less than other.
//!
//! The comparison checks from left to right with the most significant byte
//! on the left (byte order equivalent to the hex string representation).
//!
//! CONSENSUS: Changing the behavior of this comparison operator will affect
//! the sort order of protocol-sensitive maps (for example, superblocks).
//!
//! \param other A CPID value to check whether current is less than.
//!
//! \return \c true if the supplied CPID's bytes represent a greater number.
//!
bool operator<(const Cpid& other) const;

//!
//! \brief Compare a supplied CPID value for greater than other.
//!
//! The comparison checks from left to right with the most significant byte
//! on the left (byte order equivalent to the hex string representation).
//!
//! CONSENSUS: Changing the behavior of this comparison operator will affect
//! the sort order of protocol-sensitive maps (for example, superblocks).
//!
//! \param other A CPID value to check whether current is greater than.
//!
//! \return \c true if the supplied CPID's bytes represent a lesser number.
//!
bool operator>(const Cpid& other) const;

//!
//! \brief Determine whether the CPID contains only zeros.
//!
Expand Down
21 changes: 21 additions & 0 deletions src/neuralnet/neuralnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "beacon.h"
#include "project.h"
#include "superblock.h"

#include <string>
#include <memory>
Expand Down Expand Up @@ -52,6 +53,16 @@ namespace NN
//!
virtual std::string GetNeuralHash() = 0;

//!
//! \brief Get current superblock hash from scraper.
//!
//! \note This is a synchoronous operation.
//!
//! \return Current superblock hash. This might be empty if it has
//! not been calculated yet.
//!
virtual NN::QuorumHash GetSuperblockHash() = 0;

//!
//! \brief Get the most recently updated neural network contract.
//!
Expand All @@ -62,6 +73,16 @@ namespace NN
//!
virtual std::string GetNeuralContract() = 0;

//!
//! \brief Get the most recently updated superblock contract.
//!
//! Synchronously queries the scraper for the current
//! superblock contract.
//!
//! \return Most recent superblock contract if available.
//!
virtual NN::Superblock GetSuperblockContract() = 0;

//!
//! \brief Synchronize DPOR data.
//!
Expand Down
14 changes: 14 additions & 0 deletions src/neuralnet/neuralnet_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ extern std::string ExplainMagnitude(std::string sCPID);

using namespace NN;

extern Superblock ScraperGetSuperblockContract(bool bStoreConvergedStats = false, bool bContractDirectFromStatsUpdate = false);
extern QuorumHash ScraperGetSuperblockHash();

bool NeuralNetNative::IsEnabled()
{
return GetArgument("disableneuralnetwork", "false") == "false";
Expand All @@ -29,11 +32,21 @@ std::string NeuralNetNative::GetNeuralHash()
return ScraperGetNeuralHash();
}

QuorumHash NeuralNetNative::GetSuperblockHash()
{
return ScraperGetSuperblockHash();
}

std::string NeuralNetNative::GetNeuralContract()
{
return ScraperGetNeuralContract(false, false);
}

Superblock NeuralNetNative::GetSuperblockContract()
{
return ScraperGetSuperblockContract(false, false);
}

// Note that the data argument is still used here for compatibility, but I don't think it will
// actually be used in the scraper. We will see.
bool NeuralNetNative::SynchronizeDPOR(const BeaconConsensus& beacons)
Expand All @@ -50,5 +63,6 @@ int64_t NeuralNetNative::IsNeuralNet()
{
// This is the NN version number. TODO: Consider different number for new NN?
int64_t nNeuralNetVersion = 1999;

return nNeuralNetVersion;
}
2 changes: 2 additions & 0 deletions src/neuralnet/neuralnet_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace NN
bool IsEnabled();
std::string GetNeuralVersion();
std::string GetNeuralHash();
NN::QuorumHash GetSuperblockHash();
std::string GetNeuralContract();
NN::Superblock GetSuperblockContract();
bool SynchronizeDPOR(const BeaconConsensus& beacons);
std::string ExplainMagnitude(const std::string& cpid);
int64_t IsNeuralNet();
Expand Down
16 changes: 16 additions & 0 deletions src/neuralnet/neuralnet_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@ std::string NeuralNetStub::GetNeuralHash()
return std::string();
}

NN::QuorumHash NeuralNetStub::GetSuperblockHash()
{
NN::QuorumHash EmptyQuorumHash;

//Initialize a purposefully empty (invalid) hash.
return EmptyQuorumHash;
}

std::string NeuralNetStub::GetNeuralContract()
{
return std::string();
}

NN::Superblock NeuralNetStub::GetSuperblockContract()
{
NN::Superblock EmptySuperblock;

return EmptySuperblock;
}


bool NeuralNetStub::SynchronizeDPOR(const BeaconConsensus& beacons)
{
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/neuralnet/neuralnet_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace NN
bool IsEnabled();
std::string GetNeuralVersion();
std::string GetNeuralHash();
NN::QuorumHash GetSuperblockHash();
std::string GetNeuralContract();
NN::Superblock GetSuperblockContract();
bool SynchronizeDPOR(const BeaconConsensus& beacons);
std::string ExplainMagnitude(const std::string& data);
int64_t IsNeuralNet();
Expand Down
Loading