Post
Topic
Board Announcements (Altcoins)
Re: keeping miners from ignoring PoS blocks discussion
by
senj
on 05/10/2015, 15:44:37 UTC
GetNextTargetRequired method is used to generate nBits (target in compact format) twice:

1. when creating new block
2. when checking if nBits of a block (could be any block in a tree) conforms to algorithm


When creating PoW block (1), pIndexPrev is a pointer to last PoW block in best chain. If there is PoW block at the tip of the chain, then pIndexPrev = pIndexLast, otherwise we have to search for it backwards with GetLastBlockIndex method. pIndexPrevPrev is a pointer to PoW block preceeding pIndexPrev.


When checking if nBits of a PoW block conforms to block generation rule (2) then pIndexPrev is a pointer to PoW block preceeding it. And as before, pIndexPrevPrev is a pointer to PoW block preceeding pIndexPrev.


The same principle is used for PoS blocks. Just replace all occurences of PoW with PoS in text above.



What "(60 seconds)*(1 + pindexLast->nHeight - pindexPrev->nHeight)" does in case of proof-of-work blocks, it multiplies number of PoS blocks between last PoW block and the one before with 1 minute. If there are no PoS blocks between, then
pindexLast = pindexPrev and height difference in equation equals 0. PoW target spacing is then set to 1 minute.


Yacoin has 1 minute PoS block target spacing.
But PoW block target spacing always was dynamic and it get's wider (PoW difficulty gets higher) in proportion to PoS blocks between last two PoW blocks. It stops growing when 12 sequential PoS blocks are let in.

After PoS block is accepted, target of next PoW block gets adjusted towards 2 minute. Change in difficulty is incremental (exponential retargeting). Nevertheless, selfish miner can mine on lower PoW difficulty if he ignores PoS blocks.


Overall, setting block spacing is only one part of operation. In essence it prescribes block targets for a valid branch.
Currently there are bigger problems with chaintrust calculation - giving correct score to multiple valid branchees thus making possible for peers to choose the best one.