navcoin / navcoin-core

bitcoin-core 0.13 fork ported for NavCoin
MIT License
123 stars 92 forks source link

Community fund: Can not accept proposal on latest aguycalled/cfund-db branch #296

Closed ggorjup closed 6 years ago

ggorjup commented 6 years ago

Using the aguycalled/cfund-db branch, NAVCoin Core version v4.4.0.0-194c8ed-dirty, I am not able to accept a created proposal (first found by marcus290). The proposal status goes from "accepted waiting for end of voting period" to "pending" at the end of a voting period, even though all the votes were "yes".

I am attaching a log file of the issue. cfund_accept_proposal.log

ggorjup commented 6 years ago

I think I found why this is happening:

In commit: adjust cycle offset the nBlockOffset assignment was changed from auto nBlockOffset = fUndo ? 2 : 1; to auto nBlockOffset = fUndo ? 1 : 0; while adjusting the cycle offset. The nCurrentCycle was also modified accordingly by removing the +1 in the numerator.

But the nBlockOffset is also present in lines 3744 and 3813, at the beginning of state computation procedures for payment requests and proposals. So I think what happens is that the voting period progresses one block before the procedures get a chance to switch the state.

I tried changing the line back to auto nBlockOffset = fUndo ? 2 : 1; and I was able to accept proposals again. But I'm not sure which parts need to be modified to properly fix it and not break the cycle offset or anything else.

marcus290 commented 6 years ago

I found the same thing happens with rejected proposals. At the end of the voting cycle, instead of being rejected, they revert back to pending.

Also, I didn't experience this problem last Monday, so it seems like the change was introduced from last week's commits.

aguycalled commented 6 years ago

Can you confirm if b9e090a fixes the issue

ggorjup commented 6 years ago

Yes, the proposal status now changes on the last block of a voting cycle. And the proposal votingCycle increments on the first block of the next voting cycle.

Although the cfund-proposal-state-accept test fails for me: proposaltests.log

EDIT: That's only because there is not enough coins in fund, so it does the correct thing and moves to state 4.