dashpay / dash

Dash - Reinventing Cryptocurrency
https://www.dash.org
MIT License
1.49k stars 1.2k forks source link

Help Understanding IsBlockPayeeValid #965

Closed crowning- closed 7 years ago

crowning- commented 8 years ago

https://github.com/dashpay/dash/blob/master/src/masternode-payments.cpp#L228-234

bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight)
{
    if(!masternodeSync.IsSynced()) { //there is no budget data to use to check anything -- find the longest chain
        LogPrint("mnpayments", "Client not synced, skipping block payee checks\n");
        return true;
    }

Why does a not fully synced node return the same state as the various successful tests?

tgflynn commented 8 years ago

The problem is that you receive blocks and need to validate them before syncing the masternode information. When the masternode data isn't available you don't have sufficient information to determine if budget payments are valid or not. So the workaround is to return true here. It shouldn't be a problem as long as the vast majority of nodes are synced but it's not a perfect solution and I hope we can find something better for 0.12.1.

EDIT: We also have to be very careful about how any changes to block validation logic are rolled out, to prevent forking. We've already seen how changes to this logic in some 0.12.1 commits have caused forking on testnet.