LiskArchive / lisk-sdk

🔩 Lisk software development kit
https://lisk.com
Apache License 2.0
2.72k stars 456 forks source link

Dpos.getRoundDelegates returns outdated list #4147

Closed lsilvs closed 5 years ago

lsilvs commented 5 years ago

Expected behavior

I expect to get the correct list of delegates when calling Dpos.getRoundDelegates after a new round is reverted and previous round changes the delegate list.

Actual behavior

It always uses the cached list ignoring possible changes on the list when a block is reverted.

Steps to reproduce

  1. Call Dpos.getRoundDelegates(R2) where R2 is the beginning of a new round
  2. Revert the last blocks so that we return to the previous round (R1)
  3. Unvote an active delegate and vote for a new one during the previous round (R1)
  4. Call Dpos.getRoundDelegates(R2) again in the beginning of the next round (R2)

Because Dpos.getRoundDelegates caches every new list and never clears it, it returns an outdated list ignoring the changes made after the last block of the round is reverted.

Step 4 should return a new delegate list including the new voted delegate and excluding the unvoted delegate.

Which version(s) does this affect? (Environment, OS, etc...)

feature/introduce_bft_consensus

lsilvs commented 5 years ago

Please, unskip these test as part this issue: https://github.com/LiskHQ/lisk-sdk/pull/4154/commits/b185320b3e1f5ac5a90057175db43b0b7d9ba319

yatki commented 5 years ago

@lsilvs seems like processor is not using dpos.undo for deleting the block. That's why those 2 tests are still failing. @shuse2 should I create an issue for unskipping these tests when undo is implemented?

shuse2 commented 5 years ago

I think we can add back those 2 test on dpos.undo issue