Skip to content

[WIP] Manual Reward Claims

div72 edited this page Feb 21, 2022 · 6 revisions

Reward claim

The user can claim their rewards either from the UI(WIP) or via the RPC command createmrcrequest. The claim itself uses a similar mechanisms as claims are done today when creating a block, with the exception that it is a separate contract that is valid for only a single-block only.

When using the MRC mechanism, the user creates a GRC::MRC contract that is tied with the CPID and the current chain tip hash using a signature. MRC contracts contain the accrual of the user and a fee calculated from that and last payout time. Any MRCs that are claimed before the zero payout interval lose all accrual as fee.

fee = m_research_subsidy * (zero_payout_interval / mrc_payment_interval) * fee_fraction

A coinstake has a certain amount of outputs it will accept for MRC(see below for a more detailed explanation). So the user is allowed to use more fees than the calculated in order to get in to a block faster, but not less.

Please note that MRC fees and MRC contract fees are two different things, the contract still requires some small amount of GRC burnt in order to create and send but the aforementioned fees are taken from accrual when the MRC is paid out.

Reward minting and block creation

When a node stakes, the miner looks for transactions in the memory pool in order to include the transaction to the block. When a transaction with a MRC contract passes by, the miner puts that in a special map in order to process it down the line. The miner then uses outputs in the coinstake transaction for each MRC that will be sent to the beacon address of the CPIDs. The miner also uses a separate output to the foundation address to split the fees gained from MRC. The split percentage and foundation address are determined by protocol entries(see FoundationSideStakeAllocation and FoundationSideStakeAddress). The amount of possible MRC outputs are limited and determined by GetMRCOutputLimit.

The miner will skip transactions with MRC contracts when the outputs are depleted but this not mandated by the protocol and should not be relied upon. Because of this nodes iterate over their memory pools and wallet transactions to clean up stale MRC transactions that are valid for older blocks.

Reward validation

When a new blocks arrive, the nodes check these for MRC payments:

  • MRC outputs must not exceed the limit.
  • All rewards(minus fees) must be paid out to the beacon addresses of the claimers.
  • The Foundation fee must be paid.
  • The staker fee must not exceed total fee minus foundation fee. See ClaimValidator::CheckMRCRewards for more details.

Tally

When the validation is complete and block is accepted, the block is marked to the block index and to the tally system to record the rewards. See CBlockIndex::AddMRCResearcherContext and ResearcherTally::RecordMRCRewardBlock for more details.