GambleCoin-Project / GambleCoin

GambleCoin (GMCN) Official Core Project
http://www.gamblecoin-info.com/
MIT License
5 stars 6 forks source link

[Supply] Fix one behind issue with calls to GetBlockValue() #30

Closed CaveSpectre11 closed 5 years ago

CaveSpectre11 commented 5 years ago

Describe the issue

FillBlockPayee() uses the height of the last block to get the blockValue; which will be one behind what it should be. Doesn't make a difference, except on halving events; where it will pay the higher amount even though it shouldn't.

    CAmount blockValue = GetBlockValue(pindexPrev->nHeight);
    CAmount masternodePayment = GetMasternodePayment(pindexPrev->nHeight, blockValue);

This is exacerbated by the fact that consensus also has the same problem; and validates that it matches the expected for the previous block, not the current block:

CAmount nExpectedMint = GetBlockValue(pindex->pprev->nHeight);

It cleared IsTransactionValid because the drift doesn't care if you overpay the masternode.

e.g. GetBlockValue(previous) = 30 GetBlockValue(current) = 15

At a 30% seesaw; Masternode Payment minimum is 8.85 (15.59); and the masternode is being paid 17.7 (30.59).

So consensus passes the blockValue of 30, because it's also looking one block behind. Masternode Payment is acceptable because consensus only cares that the minter doesn't shortchange the masternode.