@@ -424,7 +424,7 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev,
424
424
for (const auto & contract : tx.GetContracts ()) {
425
425
if (contract.m_type == GRC::ContractType::MRC) {
426
426
// If we have reached the MRC output limit then don't include transactions with MRC contracts in the
427
- // mrc_tx_map . The intended foundation sidestake (if active) is excluded from the output limit here,
427
+ // mrc_map . The intended foundation sidestake (if active) is excluded from the output limit here,
428
428
// because that slot will be used in a sidestake of the fees to the foundation rather than an MRC
429
429
// transaction output. Note that the transaction processing for the MRC that is not included still
430
430
// occurs; it simply will not be paid out.
@@ -435,15 +435,18 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev,
435
435
// This check as to whether CpidOption actually points to a valid Cpid should not be
436
436
// strictly necessary, but is included here anyway for safety.
437
437
if (const GRC::CpidOption mrc_cpid = mrc.m_mining_id .TryCpid ()) {
438
- // The MRC should have already been checked in accept to mempool, but check again here?
439
- // TODO: Think about the use of pindexPrev here. If another block goes by and a straggler MRC
440
- // transaction is still in the memory pool, the validation will fail for that MRC here, because
441
- // the pindex recorded in the MRC will not match pindexPrev here.
438
+ // The MRC should have already been checked in accept to mempool, but we will check again here.
442
439
//
443
- // To insert an mrc onto the claim mrc_tx_map, the mrc_cpid must be a cpid, the mrc_cpid must
444
- // not be the same as the stakers cpid and the MRC must validate. This prevents the situation
440
+ // To insert an mrc into the claim mrc_map, the mrc_cpid must be a cpid, the mrc_cpid must
441
+ // not be the same as the stakers cpid, the cpid must be unique (i.e. the same cpid cannot
442
+ // have more than one MRC per block, and the MRC must validate. This prevents the situation
445
443
// where a researcher is staking and trying to process an MRC sent from themselves just before.
446
- // the researcher staker's MRC transaction will be expended just like other that are overflow.
444
+ // the researcher staker's MRC transaction will be expended just like other that are overflow,
445
+ // and ensures that only the highest priority mrc in the mempool gets processed for a unique
446
+ // cpid. Note that the other mrc transactions will be bound to the mempool, but will be ignored,
447
+ // so the mrc requester will lose the burn fees for the extra mrc requests. Note that the
448
+ // production createmrcrequest will prevent more than one mrc in the mempool at a time for a
449
+ // unique cpid, but it is also enforced here, because the sender could be modified.
447
450
if ((!cpid || (mrc_cpid && cpid && *mrc_cpid != *cpid)) && ValidateMRC (pindexPrev, mrc)) {
448
451
// Here the insert form instead of [] is used, because we want to use the first
449
452
// mrc transaction in the mempool for a given cpid in order or priority, not the last
@@ -709,7 +712,9 @@ void SplitCoinStakeOutput(CBlock &blocknew, int64_t &nReward, bool &fEnableStake
709
712
// The maximum number of outputs allowed on the coinstake txn is 3 for block version 9 and below and
710
713
// 8 for 10 and above (excluding MRC outputs). The first one must be empty, so that gives 2 and 7 usable ones,
711
714
// respectively. MRC outputs are excluded here. They are above and beyond the below and addressed in CreateMRC.
712
- unsigned int nMaxOutputs = GetCoinstakeOutputLimit (blocknew.nVersion ) - GetMRCOutputLimit (blocknew.nVersion );
715
+ // Unlike in other areas, the foundation sidestake IS COUNTED in the GetMRCOutputLimit because it is a sidestake, but
716
+ // handled in the CreateMRCRewards function and not here.
717
+ unsigned int nMaxOutputs = GetCoinstakeOutputLimit (blocknew.nVersion ) - GetMRCOutputLimit (blocknew.nVersion , true );
713
718
// Set the maximum number of sidestake outputs to two less than the maximum allowable coinstake outputs
714
719
// to ensure outputs are reserved for the coinstake output itself and the empty one. Any sidestake
715
720
// addresses and percentages in excess of this number will be ignored.
@@ -1077,11 +1082,15 @@ bool CreateMRCRewards(CBlock &blocknew, std::map<GRC::Cpid, std::pair<uint256, G
1077
1082
CAmount rewards = 0 ;
1078
1083
CAmount staker_fees = 0 ;
1079
1084
CAmount foundation_fees = 0 ;
1085
+
1086
+ // Note that GetMRCOutputLimit handles the situation where FoundationSideStakeAllocation.IsNonZero is false or true.
1080
1087
unsigned int output_limit = GetMRCOutputLimit (blocknew.nVersion , false );
1081
1088
1082
1089
if (output_limit > 0 ) {
1083
1090
Fraction foundation_fee_fraction = FoundationSideStakeAllocation ();
1084
1091
1092
+ LogPrintf (" INFO: %s: output_limit = %u" , __func__, output_limit);
1093
+
1085
1094
// We do not need to validate the MRCs here because that was already done in CreateRestOfTheBlock. This also means
1086
1095
// that the mrc tx hashes have been validated and the mrc_last_pindex matches the pindexPrev here (the head of the
1087
1096
// chain from the miner's point of view).
0 commit comments