Skip to content

Commit

Permalink
Merge branch 'development' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Jul 4, 2023
2 parents d970d9c + dad1bd2 commit 64e81b6
Show file tree
Hide file tree
Showing 67 changed files with 6,927 additions and 1,770 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 5)
define(_CLIENT_VERSION_MINOR, 4)
define(_CLIENT_VERSION_REVISION, 5)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_BUILD, 2)
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
8 changes: 7 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ GRIDCOIN_CORE_H = \
gridcoin/contract/handler.h \
gridcoin/contract/message.h \
gridcoin/contract/payload.h \
gridcoin/contract/registry.h \
gridcoin/contract/registry_db.h \
gridcoin/cpid.h \
gridcoin/gridcoin.h \
gridcoin/magnitude.h \
gridcoin/mrc.h \
gridcoin/project.h \
gridcoin/protocol.h \
gridcoin/quorum.h \
gridcoin/researcher.h \
gridcoin/scraper/fwd.h \
gridcoin/scraper/http.h \
gridcoin/scraper/scraper.h \
gridcoin/scraper/scraper_net.h \
gridcoin/scraper/scraper_registry.h \
gridcoin/staking/chain_trust.h \
gridcoin/staking/difficulty.h \
gridcoin/staking/exceptions.h \
Expand Down Expand Up @@ -237,22 +241,24 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
crypter.cpp \
dbwrapper.cpp \
fs.cpp \
gridcoin/appcache.cpp \
gridcoin/backup.cpp \
gridcoin/beacon.cpp \
gridcoin/boinc.cpp \
gridcoin/claim.cpp \
gridcoin/contract/contract.cpp \
gridcoin/contract/message.cpp \
gridcoin/contract/registry.cpp \
gridcoin/cpid.cpp \
gridcoin/gridcoin.cpp \
gridcoin/mrc.cpp \
gridcoin/project.cpp \
gridcoin/protocol.cpp \
gridcoin/quorum.cpp \
gridcoin/researcher.cpp \
gridcoin/scraper/http.cpp \
gridcoin/scraper/scraper.cpp \
gridcoin/scraper/scraper_net.cpp \
gridcoin/scraper/scraper_registry.cpp \
gridcoin/staking/difficulty.cpp \
gridcoin/staking/exceptions.cpp \
gridcoin/staking/kernel.cpp \
Expand Down
6 changes: 4 additions & 2 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TEXT_TEST_FILES = \
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(BINARY_TEST_FILES:.bin=.bin.h) $(TEXT_TEST_FILES:.txt=.txt.h)

# test_n binary #

GRIDCOIN_TESTS =\
test/checkpoints_tests.cpp \
test/dos_tests.cpp \
Expand All @@ -44,17 +45,18 @@ GRIDCOIN_TESTS =\
test/fs_tests.cpp \
test/getarg_tests.cpp \
test/gridcoin_tests.cpp \
test/gridcoin/appcache_tests.cpp \
test/gridcoin/block_finder_tests.cpp \
test/gridcoin/beacon_tests.cpp \
test/gridcoin/block_finder_tests.cpp \
test/gridcoin/claim_tests.cpp \
test/gridcoin/contract_tests.cpp \
test/gridcoin/cpid_tests.cpp \
test/gridcoin/enumbytes_tests.cpp \
test/gridcoin/magnitude_tests.cpp \
test/gridcoin/mrc_tests.cpp \
test/gridcoin/project_tests.cpp \
test/gridcoin/protocol_tests.cpp \
test/gridcoin/researcher_tests.cpp \
test/gridcoin/scraper_registry_tests.cpp \
test/gridcoin/superblock_tests.cpp \
test/key_tests.cpp \
test/merkle_tests.cpp \
Expand Down
8 changes: 8 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ class CMainParams : public CChainParams {
consensus.BlockV10Height = 1420000;
consensus.BlockV11Height = 2053000;
consensus.BlockV12Height = 2671700;
consensus.BlockV13Height = std::numeric_limits<int>::max();
consensus.PollV3Height = 2671700;
consensus.ProjectV2Height = 2671700;
// Immediately post zero payment interval fees 40% for mainnet
consensus.InitialMRCFeeFractionPostZeroInterval = Fraction(2, 5);
// Zero day interval is 14 days on mainnet
consensus.MRCZeroPaymentInterval = 14 * 24 * 60 * 60;
// The "standard" contract replay lookback for those contract types
// that do not have a registry db.
consensus.StandardContractReplayLookback = 180 * 24 * 60 * 60;
// "standard" scrypt target limit for proof of work, results in 0,000244140625 proof-of-work difficulty.
// Equivalent to ~arith_uint256() >> 20 or 1e0fffff in compact notation.
consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
Expand Down Expand Up @@ -176,12 +180,16 @@ class CTestNetParams : public CChainParams {
consensus.BlockV10Height = 629409;
consensus.BlockV11Height = 1301500;
consensus.BlockV12Height = 1871830;
consensus.BlockV13Height = std::numeric_limits<int>::max();
consensus.PollV3Height = 1944820;
consensus.ProjectV2Height = 1944820;
// Immediately post zero payment interval fees 40% for testnet, the same as mainnet
consensus.InitialMRCFeeFractionPostZeroInterval = Fraction(2, 5);
// Zero day interval is 10 minutes on testnet. The very short interval facilitates testing.
consensus.MRCZeroPaymentInterval = 10 * 60;
// The "standard" contract replay lookback for those contract types
// that do not have a registry db.
consensus.StandardContractReplayLookback = 180 * 24 * 60 * 60;
// Equivalent to ~arith_uint256() >> 16 or 1f00ffff in compact notation.
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

Expand Down
11 changes: 10 additions & 1 deletion src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include "consensus/params.h"
#include "protocol.h"

// system.h included only for temporary V12 fork point overrides for testing.
// system.h and extern reference to cs_main included only for temporary V13 fork point overrides for testing.
#include "util/system.h"

#include <memory>
#include <stdexcept>
#include <vector>

extern CCriticalSection cs_main;

typedef std::map<int, uint256> MapCheckpoints;
typedef std::map<int, std::vector<unsigned char>> MapMasterKeys;

Expand Down Expand Up @@ -151,6 +153,13 @@ inline bool IsV12Enabled(int nHeight)
return nHeight >= Params().GetConsensus().BlockV12Height;
}

inline bool IsV13Enabled(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
// The argument driven override temporarily here to facilitate testing.

return nHeight >= gArgs.GetArg("-blockv13height", Params().GetConsensus().BlockV13Height);
}

inline bool IsPollV3Enabled(int nHeight)
{
return nHeight >= Params().GetConsensus().PollV3Height;
Expand Down
4 changes: 4 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ struct Params {
int BlockV11Height;
/** Block height at which v12 blocks are created */
int BlockV12Height;
/** Block height at which v13 blocks are created */
int BlockV13Height;
/** Block height at which poll v3 contract payloads are valid */
int PollV3Height;
/** Block height at which project v2 contracts are allowed */
Expand All @@ -46,6 +48,8 @@ struct Params {
*/
int64_t MRCZeroPaymentInterval;

int64_t StandardContractReplayLookback;

uint256 powLimit;
};
} // namespace Consensus
Expand Down
89 changes: 18 additions & 71 deletions src/gridcoin/appcache.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2021 The Gridcoin developers
// Copyright (c) 2014-2023 The Gridcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.

Expand All @@ -9,17 +9,9 @@
#include <map>
#include <unordered_map>

enum class Section
{
PROTOCOL,
SCRAPER,

// Enum counting entry. Using it will throw.
NUM_CACHES
};

//!
//! \brief An entry in the application cache.
//! \brief An entry in the application cache. This is provided as a legacy shim only and will be replaced by
//! native calls.
//!
struct AppCacheEntry
{
Expand All @@ -28,77 +20,32 @@ struct AppCacheEntry
};

//!
//! \brief Application cache section type.
//! \brief Application cache section type. This is provided as a legacy shim only and will be replaced by
//! native calls.
//!
typedef std::unordered_map<std::string, AppCacheEntry> AppCacheSection;

//!
//! \brief Application cache section sorted by key.
//! \brief Application cache section sorted by key. This is provided as a legacy shim only and will be replaced by
//! native calls.
//!
typedef std::map<std::string, AppCacheEntry> SortedAppCacheSection;

//!
//! \brief Application cache type.
//!
typedef std::unordered_map<std::string, AppCacheSection> AppCache;

//!
//! \brief Write value into application cache.
//! \param section Cache section to write to.
//! \param key Entry key to write.
//! \param value Entry value to write.
//!
void WriteCache(
Section section,
const std::string& key,
const std::string& value,
int64_t locktime);

//!
//! \brief Read values from appcache section.
//! \param section Cache section to read from.
//! \param key Entry key to read.
//! \returns Value for \p key in \p section if available, or an empty string
//! if either the section or the key don't exist.
//!
AppCacheEntry ReadCache(
Section section,
const std::string& key);

//!
//! \brief Read section from cache.
//! \param section Section to read.
//! \returns The data for \p section if available.
//!
AppCacheSection& ReadCacheSection(Section section);

//!
//! \brief Reads a section from cache and sorts it.
//! \param section Section to read.
//! \returns The data for \p section if available.
//!
//! Reads a cache section and transfers it to a sorted map. This can be an
//! expensive operation and should not be used unless there is a need
//! for sorted traversal.
//!
//! \see ReadCacheSection
//!
SortedAppCacheSection ReadSortedCacheSection(Section section);

//!
//! \brief Clear all values in a cache section.
//! \param section Cache section to clear.
//! \note This only clears the values. It does not erase them.
//! \brief Extended AppCache structure similar to those in AppCache.h, except a deleted flag is provided. This
//! is provided as a legacy shim only and will be replaced by native calls.
//!
void ClearCache(Section section);
struct AppCacheEntryExt
{
std::string value; // Value of entry.
int64_t timestamp; // Timestamp of entry/deletion
bool deleted; // Deleted flag.
};

//!
//! \brief Erase key from appcache section.
//! \param section Cache section to erase from.
//! \param key Entry key to erase.
//! \brief Extended AppCache map typedef similar to AppCacheSection, except a deleted flag is provided for use by
//! the scraper. This is provided as a legacy shim only and will be replaced by native calls.
//!
void DeleteCache(Section section, const std::string& key);

Section StringToSection(const std::string& section);
typedef std::unordered_map<std::string, AppCacheEntryExt> AppCacheSectionExt;

#endif // GRIDCOIN_APPCACHE_H
Loading

0 comments on commit 64e81b6

Please sign in to comment.