Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • crown-core crown-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 75
    • Issues 75
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Crown
  • crown-corecrown-core
  • Issues
  • #97

Closed
Open
Created Dec 29, 2017 by Ashot@ashotMaintainer

Current implementation of superblock fail-safe will always fail

Function CBudgetManager::FillBlockPayee() first finds highest proposal vote count (nHighestCount) and if the count is bigger then zero it pays to proposal otherwise it pays to dev fund.

if(nHighestCount > 0){
    ...
} else {
    // Pay dev fund
}

But after payment in main.cpp it checks if it was correct payment

        if(!IsBlockPayeeValid(block.vtx[0], nHeight))
        {
            mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime()));
            return state.DoS(100, error("CheckBlock() : Couldn't find masternode/budget payment"));
        }

IsBlockPayeeValid calls budget.IsTransactionValid(txNew, nBlockHeight) where the same nHighestCount is calculated and the following condition is checked

if(nHighestCount < mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) {
    return false;
} else if (IsDevTransactionValid(txNew, nBlockHeight)) {
    return true;
}

But because nHighestCount was zero this condition will never return true.

Why payment to dev fund worked successfully in testnet

In testnet we didn't have any proposal so nHighestCount was equal to 0 and miner paid to dev fund. After that it checked if transaction was valid.

if(nHighestCount < mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) {
   ...
}

Here if the count of total masternodes is less then 20 then the second part of the condition will equal to zero 18/20 = 0

And because (0 < 0) is false the above condition will return true.

We would see the issue in testnet if the condition was less or equal, so I would suggest to change the condition

if(nHighestCount <= mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) {
Edited Jan 04, 2018 by Ashot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking