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

consensus, contract, mining, researcher, rpc, staking, gui: Implementation of MRC - baseline functionality #2425

Merged
merged 125 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
503665b
Initial changes to miner to support MRC
jamescowens Jan 9, 2022
ca70146
Initial rough-in of MRC class and associated miner functions
jamescowens Jan 9, 2022
7f6cff6
Correct error in MRC output adds and block version condition
jamescowens Jan 9, 2022
8c683a8
Changes to MRC class to remove unnecessary stuff
jamescowens Jan 9, 2022
c4af8b3
Changes to accomodate change from block version v11 to v12
jamescowens Jan 9, 2022
4cbfc66
Additional changes to mrc class
jamescowens Jan 9, 2022
3cf6b2f
Changes to miner to adjust to MRC signature
jamescowens Jan 9, 2022
249aaac
Implement GetMRCOutputLimit
jamescowens Jan 9, 2022
3fda5d8
Change int to unsigned int for output limit functions in miner
jamescowens Jan 9, 2022
8d3b7dc
Correct spelling on GetCoinstakeOutputLimit
jamescowens Jan 9, 2022
6c30af9
Get ConnectBlock to use GetCoinstakeOutputLimit instead of hard-code
jamescowens Jan 9, 2022
fac1bf6
Add MRC contract to contract.cpp
jamescowens Jan 9, 2022
6eea7fc
Add missing return true on CreateMRC
jamescowens Jan 9, 2022
ba08fb1
Modify claim_tests.cpp to deal with up to v 3 claims only
jamescowens Jan 9, 2022
5fc3c13
Add in stubs for MRC fee computation
jamescowens Jan 9, 2022
5986f6b
Implement rough-out of ComputeMRCFee and make minor adjustments to MR…
jamescowens Jan 10, 2022
8cdf015
Implement ValidateMRC and other associated changes
jamescowens Jan 10, 2022
a3fd87b
Rough-out CreateMRCRewards
jamescowens Jan 11, 2022
ef4941e
Implement CheckMRCRewards, fill out CreateMRCRewards and other changes
jamescowens Jan 11, 2022
890d93d
Make changes to address straggler MRCs
jamescowens Jan 11, 2022
d9060ce
Implement stub FoundationSideStakeAddress
jamescowens Jan 11, 2022
10640dc
Improve CheckMRCRewards and other fine tuning to ClaimValidator class
jamescowens Jan 12, 2022
7704349
Implement MRCContractHandler, tweak ValidateMRC
jamescowens Jan 12, 2022
06dc3e5
Eliminate two loop levels inside CreateMRCRewards
jamescowens Jan 13, 2022
66acc1b
Implement AddMRCResearcherContext in CBlockIndex and wire into Gridco…
jamescowens Jan 13, 2022
c0ee237
Detect incorrect mrc staker fee allocation in Validator class
jamescowens Jan 14, 2022
c3ed6d3
Implement Fraction class and change FoundationFeeAllocation to that
jamescowens Jan 15, 2022
f2f0d0f
Augment Tally:RecordRewardBlock and ForgetRewardBlock to handle MRCs
jamescowens Jan 15, 2022
3be97f0
Fix spelling mistake in miner comments
jamescowens Jan 15, 2022
846a2ee
Change pindex to pindex->pprev in Record/ForgetRewardBlock for MRCs
jamescowens Jan 16, 2022
3faebb6
mrc: CreateMRC: move to src/gridcoin/mrc
div72 Jan 15, 2022
0946209
mrc: CreateMRC: fix typo in doc
div72 Jan 15, 2022
91c4aa3
mrc: CreateMRC: directly pass the contract instead of a tx
div72 Jan 15, 2022
b9deac1
rpc: add createmrcrequest
div72 Jan 15, 2022
a087d79
mrc: CreateMRC: set hash before ComputeMRCFee
div72 Jan 16, 2022
0d24834
rpc: createmrcrequest: display units in GRC
div72 Jan 16, 2022
b13e2e3
Change call to ValidateMRC in CreateRestOfBlock to use pindexPrev-pprev
jamescowens Jan 16, 2022
018634f
Make small optimization in ComputeMRCFee
jamescowens Jan 16, 2022
f16c2dc
Implement temporary argument driven blockv12height override for testing
jamescowens Jan 16, 2022
7da0379
Implement temporary argument based foundation address override for te…
jamescowens Jan 16, 2022
8b5978d
Fix serialization of mrc and add temporary logging to Validate
jamescowens Jan 16, 2022
c26a991
rpc: show MRC contracts
div72 Jan 16, 2022
522c5b7
Add more logging for testing/troubleshooting
jamescowens Jan 16, 2022
ee25a1d
Correct logic error in Fraction.IsNonZero()
jamescowens Jan 16, 2022
55a9b21
Adjustments to CreateRestOfTheBlock after mrc troubleshooting
jamescowens Jan 17, 2022
c48c2a0
Don't add foundation sidestake with zero value
jamescowens Jan 17, 2022
803a30a
Implement InitialMRCFeeFractionPostZeroInterval and MRCZeroPaymentInt…
jamescowens Jan 17, 2022
0bbb2cf
Change ComputeMRCFee to respect new chainparams
jamescowens Jan 17, 2022
64995ec
Change createmrcrequest help to indicate optionality on parameters
jamescowens Jan 17, 2022
09a6212
Reverse the dry_run and force parameters in createrpcrewards
jamescowens Jan 18, 2022
f68e454
Remove default for GetMRCOutputLimit and update comments
jamescowens Jan 18, 2022
165a0a3
Loosen validation requirements in MRCContraactHandler::Validate slightly
jamescowens Jan 19, 2022
8985cf6
Add check for !pindexBest->m_mrc_researchers.empty() to DisconnectBlo…
jamescowens Jan 20, 2022
af0b8cd
Additional CheckMRCRewards integrity checks
jamescowens Jan 20, 2022
e2552ab
Loosen incoming contract validation in AcceptToMemoryPool
jamescowens Jan 22, 2022
0b55119
Move CreateMRCRewards to anonymous namespace, update/remove some TODOs
jamescowens Jan 22, 2022
b2080bd
Update comments on CheckMRCRewards
jamescowens Jan 22, 2022
664c1af
Correct UI display/categorization of MRC payments
jamescowens Jan 23, 2022
0a92125
Remove stray version = 1 check carried over from claim to mrc class
jamescowens Jan 23, 2022
a3d7f45
Change array style lookup for map to find
jamescowens Jan 23, 2022
214112d
Add missing serialization of m_mrc_researchers to CBlockIndex
jamescowens Jan 24, 2022
9e64147
Extend auditsnapshotaccrual to show mrc payments
jamescowens Jan 24, 2022
600ea04
Correct Tally:RecordRewardBlock and ForgetRewardBlock behavior
jamescowens Jan 25, 2022
af54872
Adjust mrc code documentation
jamescowens Jan 25, 2022
e481969
Remove pindex nullptr assert from Forget(MRC)RewardBlock
jamescowens Jan 26, 2022
1c56e46
Correct call to Record/ForgetMRCRewardBlock to refer to pindex
jamescowens Jan 26, 2022
1f67362
Correct Record/ForgetMRCRewardBlock
jamescowens Jan 27, 2022
0dc0cef
Remove unused MRC:HasResearchReward()
jamescowens Jan 30, 2022
0078018
Add mrc object json dump to createmrcrequest console output.
jamescowens Jan 30, 2022
282a1dd
Tweak MRC::WellFormed()
jamescowens Jan 30, 2022
2b853c2
Change FindLastRewardBlock to stop at pindex->ppprev for MRC case
jamescowens Jan 30, 2022
7732bd8
Change account.m_last_block_ptr in ForgetMRCRewardBlock to pindex fro…
jamescowens Jan 30, 2022
3a6ad5c
Adjust code comments on FindLastRewardBlock
jamescowens Jan 30, 2022
269ef45
Augment CheckReward to do a direct check of the foundation sidestake
jamescowens Jan 30, 2022
22220e3
Track non-zero mrc reward outputs
jamescowens Jan 30, 2022
2b972d4
Minor cleanup in Validator class
jamescowens Jan 31, 2022
3e02ffe
Add missing RecordMRCRewardBlock in ActivateSnapshotAccrual
jamescowens Jan 31, 2022
ab78b52
Track down and handle duplicate calls to AddMRCResearcherContext
jamescowens Jan 31, 2022
e56647e
Clear m_mrc_researchers in CBlockIndex::SetNull()
jamescowens Feb 1, 2022
91ccdd9
Tweak MRCToJSON
jamescowens Feb 4, 2022
4e378b1
Correct/optimize MRC transaction loop in GridcoinConnectBlock
jamescowens Feb 4, 2022
a612b1a
tally: add functions to create and remove accounts
div72 Jan 26, 2022
ed4d131
test: mrc: add initial unit tests
div72 Jan 26, 2022
c5bb76e
test: mrc: add more request validity checks
div72 Jan 27, 2022
bdbaddf
test: mrc: add tests for CreateMRC
div72 Jan 28, 2022
7c4b014
test: mrc: add tests for block creation logic
div72 Jan 28, 2022
fa7eb01
test: mrc: implement proper cleanup
div72 Jan 29, 2022
a4ce9e0
test: mrc, tally: add test case for record/forget
div72 Jan 30, 2022
ae1be52
test: mrc: reset beacon registry before tests
div72 Feb 1, 2022
c467b97
Raise non-MRC part of coinstake output limit by 2
jamescowens Feb 6, 2022
7df2c65
Change logging in RecordRewardBlock to follow TALLY LogFlag
jamescowens Feb 6, 2022
6ee90b5
Restore partial validation of MRC contracts in the contract handler
jamescowens Feb 6, 2022
0dd93f6
Implement duplicate MRC check in mempool for the same CPID in AcceptT…
jamescowens Feb 6, 2022
3ecf219
Improve logging in ValidateMRC
jamescowens Feb 6, 2022
0c72d76
Coniinue to refine ValidateMRC
jamescowens Feb 7, 2022
94e16f2
Fix arguments for LogPrintfs in ValidateMRC
jamescowens Feb 7, 2022
cfd4628
Ensure cs_main is locked in mrc_tests.cpp
jamescowens Feb 13, 2022
3f8ed03
Raise block v12 MRC output limit to 10
jamescowens Feb 17, 2022
5080db1
Refine block size calculations in CreateRestOfTheBlock
jamescowens Feb 17, 2022
1421209
mempool, miner, gui: remove tx prioritisation and free txs
div72 Feb 18, 2022
1dc2fc2
miner: use MRC fee in fee rate calculation
div72 Feb 18, 2022
5675868
mempool: use a bloom filter for MRC
div72 Feb 18, 2022
f990a96
rpc: createmrcrequest: report position
div72 Feb 18, 2022
2bdf02b
wallet: do not relay mrc transactions if they are not valid
div72 Feb 18, 2022
ccb2ece
Add reject_payment_interval to the tx validation version of ValidateMRC
jamescowens Feb 20, 2022
ac67282
Add missing vContracts empty guard in stale MRC check for mempool
jamescowens Feb 20, 2022
703c06d
Missing test for empty vContracts in CreateRestOfTheBlock
jamescowens Feb 20, 2022
c31f71f
Remove stale MRC transactions from wallet and mempool in GridcoinConn…
jamescowens Feb 21, 2022
712799c
Implement CWalletTx::RevalidateTransaction
jamescowens Feb 21, 2022
26e2134
Remove tx version 1 conditional code from RelayWalletTransaction
jamescowens Feb 21, 2022
daf3ea9
Fix createmrcrequest for default no fee provided
jamescowens Feb 21, 2022
5bb83f7
Update comments in CreateRestOfTheBlock to align with modified behavior
jamescowens Feb 21, 2022
00701da
Move stale mempool MRC transaction check to ConnectBlock
jamescowens Feb 21, 2022
3485cda
wallet: CWallet::EraseFromWallet: properly signal removal
div72 Feb 20, 2022
b37d6f2
rpc: createmrcrequest: more information
div72 Feb 20, 2022
0ea0b5f
mrc: allow fees higher than calculated
div72 Feb 18, 2022
dbebd8e
Silence success logging of CheckReward unless VERBOSE logging is true
jamescowens Feb 22, 2022
38d811b
Silence success logging of CheckInvestorClaim unless VERBOSE logging …
jamescowens Feb 22, 2022
f32e973
Add block v12 check to createmrcrequest
jamescowens Feb 23, 2022
3028c47
Change MRC output limit from 10 to 3 for testnet to facilitate testing
jamescowens Feb 23, 2022
eae4081
Change behavior of miner for mrc trasnactions
jamescowens Mar 4, 2022
985b289
Clean up spent outputs after deleting stale mempool MRC txns
jamescowens Mar 7, 2022
66143eb
Add mrc fee to mrc hash
jamescowens Mar 12, 2022
94ee7fe
fix mrc tests to account for mrc fee in mrc hash
jamescowens Mar 13, 2022
5b924ef
Implement -foundationsidestakeallocation for testing
jamescowens Mar 14, 2022
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
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ GRIDCOIN_CORE_H = \
gridcoin/cpid.h \
gridcoin/gridcoin.h \
gridcoin/magnitude.h \
gridcoin/mrc.h \
gridcoin/project.h \
gridcoin/quorum.h \
gridcoin/researcher.h \
Expand Down Expand Up @@ -223,6 +224,7 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
gridcoin/contract/message.cpp \
gridcoin/cpid.cpp \
gridcoin/gridcoin.cpp \
gridcoin/mrc.cpp \
gridcoin/project.cpp \
gridcoin/quorum.cpp \
gridcoin/researcher.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ RES_ICONS = \
qt/res/icons/transaction0.png \
qt/res/icons/transaction2.svg \
qt/res/icons/tx_contract_beacon.svg \
qt/res/icons/tx_contract_mrc.svg \
qt/res/icons/tx_contract_voting.svg \
qt/res/icons/tx_inout.svg \
qt/res/icons/tx_input.svg \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ GRIDCOIN_TESTS =\
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/researcher_tests.cpp \
test/gridcoin/superblock_tests.cpp \
Expand Down
10 changes: 10 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class CMainParams : public CChainParams {
consensus.BlockV9TallyHeight = 1144120;
consensus.BlockV10Height = 1420000;
consensus.BlockV11Height = 2053000;
consensus.BlockV12Height = std::numeric_limits<int>::max();
// 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;
// "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 @@ -149,6 +154,11 @@ class CTestNetParams : public CChainParams {
consensus.BlockV9TallyHeight = 399120;
consensus.BlockV10Height = 629409;
consensus.BlockV11Height = 1301500;
consensus.BlockV12Height = std::numeric_limits<int>::max();
// 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;
// Equivalent to ~arith_uint256() >> 16 or 1f00ffff in compact notation.
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

Expand Down
11 changes: 11 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "consensus/params.h"
#include "protocol.h"

// system.h included only for temporary V12 fork point overrides for testing.
#include "util/system.h"

#include <memory>
#include <vector>

Expand Down Expand Up @@ -131,6 +134,14 @@ inline bool IsV11Enabled(int nHeight)
return nHeight >= Params().GetConsensus().BlockV11Height;
}

inline bool IsV12Enabled(int nHeight)
{
// Temporary override for testing. Cf. Corresponding code in init.cpp
int BlockV12Height = gArgs.GetArg("-blockv12height", Params().GetConsensus().BlockV12Height);

return nHeight >= BlockV12Height;
}

inline int GetSuperblockAgeSpacing(int nHeight)
{
return (fTestNet ? 86400 : (nHeight > 364500) ? 86400 : 43200);
Expand Down
11 changes: 11 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define BITCOIN_CONSENSUS_PARAMS_H

#include "uint256.h"
#include "util.h"

namespace Consensus {

Expand All @@ -30,6 +31,16 @@ struct Params {
int BlockV10Height;
/** Block height at which v11 blocks are created */
int BlockV11Height;
/** Block height at which v12 blocks are created */
int BlockV12Height;
/** The fraction of rewards taken as fees in an MRC after the zero payment interval. Only consesnus critical
* at BlockV12Height or above.
*/
Fraction InitialMRCFeeFractionPostZeroInterval;
/** The amount of time from the last reward payment to a researcher where submitting an MRC will resort in 100%
* forfeiture of fees to the staker and/or foundation. Only consensus critical at BlockV12Height or above.
*/
int64_t MRCZeroPaymentInterval;

uint256 powLimit;
};
Expand Down
1 change: 1 addition & 0 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ bool CTxDB::LoadBlockIndex()
pindexNew->nBits = diskindex.nBits;
pindexNew->nNonce = diskindex.nNonce;
pindexNew->m_researcher = diskindex.m_researcher;
pindexNew->m_mrc_researchers = diskindex.m_mrc_researchers;

nBlockCount++;
// Watch for genesis block
Expand Down
2 changes: 1 addition & 1 deletion src/gridcoin/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ResearchAccount
//! \return A block height of zero if the account never earned a research
//! reward before.
//!
uint32_t LastRewardHeight() const
int32_t LastRewardHeight() const
{
if (const BlockPtrOption pindex = LastRewardBlock()) {
return (*pindex)->nHeight;
Expand Down
6 changes: 3 additions & 3 deletions src/gridcoin/beacon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ bool Beacon::Expired(const int64_t now) const
// Temporary transition to version 2 beacons after the block version 11
// hard-fork:
//
if (m_timestamp <= g_v11_timestamp) {
return now - g_v11_timestamp > 14 * 86400;
}
// if (m_timestamp <= g_v11_timestamp) {
// return now - g_v11_timestamp > 14 * 86400;
// }

return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/gridcoin/block_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class ResearcherContext
Cpid m_cpid;
int64_t m_research_subsidy;
double m_magnitude;

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(m_cpid);
READWRITE(m_research_subsidy);
READWRITE(m_magnitude);
}
};

//!
Expand Down
8 changes: 8 additions & 0 deletions src/gridcoin/claim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ uint256 GetClaimHash(

if (claim.m_version >= 3) {
hasher << coinstake_tx;

if (claim.m_version >= 4) {
hasher << claim.m_mrc_tx_map;
}
}

return hasher.GetHash();
Expand Down Expand Up @@ -173,6 +177,10 @@ bool Claim::WellFormed() const
return false;
}

// Note: It is appealing to check the size of m_mrc to ensure within limit of number of MRC outputs; however,
// the limit of the number of MRC outputs is a function of the block version as well as the claim version, so
// this is done exterior to this class in block level validation.

return true;
}

Expand Down
19 changes: 18 additions & 1 deletion src/gridcoin/claim.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Claim : public IContractPayload
//! ensure that the serialization/deserialization routines also handle all
//! of the previous versions.
//!
static constexpr uint32_t CURRENT_VERSION = 3;
static constexpr uint32_t CURRENT_VERSION = 4;

//!
//! \brief The maximum length of a serialized client version in a claim.
Expand Down Expand Up @@ -187,6 +187,19 @@ class Claim : public IContractPayload
//!
SuperblockPtr m_superblock;

//!
//! \brief A map of mrc transactions keyed by CPID. There can be only one MRC per CPID
//! in the claim.
//!
std::map<Cpid, uint256> m_mrc_tx_map;
denravonska marked this conversation as resolved.
Show resolved Hide resolved

//!
//! \brief This represents the fees taken from the MRC research subsidies that are awarded to the staker.
//! This must be tracked because this value is added to coinstake award for the staker and must be
//! included in the claim validation.
//!
CAmount m_mrc_fees_to_staker;

//!
//! \brief Initialize an empty, invalid reward claim object.
//!
Expand Down Expand Up @@ -394,6 +407,10 @@ class Claim : public IContractPayload
{
READWRITE(m_superblock);
}

if (m_version >= 4) {
READWRITE(m_mrc_tx_map);
}
}
}; // Claim
}
Expand Down
11 changes: 11 additions & 0 deletions src/gridcoin/contract/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "main.h"
#include "gridcoin/appcache.h"
#include "gridcoin/claim.h"
#include "gridcoin/mrc.h"
#include "gridcoin/contract/contract.h"
#include "gridcoin/contract/handler.h"
#include "gridcoin/beacon.h"
Expand Down Expand Up @@ -304,6 +305,7 @@ class Dispatcher

private:
AppCacheContractHandler m_appcache_handler; //<! Temporary.
MRCContractHandler m_mrc_contract_handler; //<! Simple wrapper to do context validation on MRC transactions.
UnknownContractHandler m_unknown_handler; //<! Logs unknown types.

//!
Expand All @@ -324,6 +326,7 @@ class Dispatcher
case ContractType::PROTOCOL: return m_appcache_handler;
case ContractType::SCRAPER: return m_appcache_handler;
case ContractType::VOTE: return GetPollRegistry();
case ContractType::MRC: return m_mrc_contract_handler;
default: return m_unknown_handler;
}
}
Expand Down Expand Up @@ -765,6 +768,7 @@ Contract::Type Contract::Type::Parse(std::string input)
// Ordered by frequency:
if (input == "claim") return ContractType::CLAIM;
if (input == "beacon") return ContractType::BEACON;
if (input == "mrc") return ContractType::MRC;
if (input == "vote") return ContractType::VOTE;
if (input == "poll") return ContractType::POLL;
if (input == "project") return ContractType::PROJECT;
Expand All @@ -780,6 +784,7 @@ std::string Contract::Type::ToString() const
switch (m_value) {
case ContractType::BEACON: return "beacon";
case ContractType::CLAIM: return "claim";
case ContractType::MRC: return "mrc";
case ContractType::MESSAGE: return "message";
case ContractType::POLL: return "poll";
case ContractType::PROJECT: return "project";
Expand Down Expand Up @@ -856,6 +861,9 @@ ContractPayload Contract::Body::ConvertFromLegacy(const ContractType type) const
// Claims can only exist in a coinbase transaction and have no
// legacy representation as a contract:
assert(false && "Attempted to convert legacy claim contract.");
case ContractType::MRC:
// MRCs have no legacy representation as a contract.
assert(false && "Attempted to convert non-existent legacy MRC contract.");
denravonska marked this conversation as resolved.
Show resolved Hide resolved
case ContractType::MESSAGE:
// The contract system does not map legacy transaction messages
// stored in the CTransaction::hashBoinc field:
Expand Down Expand Up @@ -891,6 +899,9 @@ void Contract::Body::ResetType(const ContractType type)
case ContractType::CLAIM:
m_payload.Reset(new Claim());
break;
case ContractType::MRC:
m_payload.Reset(new MRC());
break;
case ContractType::MESSAGE:
m_payload.Reset(new TxMessage());
break;
Expand Down
3 changes: 2 additions & 1 deletion src/gridcoin/contract/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ enum class ContractType
{
UNKNOWN, //!< An invalid, non-standard, or empty contract type.
BEACON, //!< Beacon advertisement or deletion.
CLAIM, //!< Gridcoin block reward claim context.
CLAIM, //!< Gridcoin block reward claim context (also includes bound MRCs paid as a delegated stake).
MESSAGE, //!< A user-supplied string. No associated protocol behavior.
POLL, //!< Submission of a new poll.
PROJECT, //!< Project whitelist addition or removal.
PROTOCOL, //!< Network control message or configuration directive.
SCRAPER, //!< Scraper node authorization grants and revocations.
VOTE, //!< A vote cast by a wallet for a poll.
MRC, //!< A manual rewards claim (MRC) request to pay rewards
OUT_OF_BOUND, //!< Marker value for the end of the valid range.
};

Expand Down
Loading