Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Fork cause 5 causing network splits #327

Closed
Isabello opened this issue Dec 1, 2016 · 2 comments
Closed

Fork cause 5 causing network splits #327

Isabello opened this issue Dec 1, 2016 · 2 comments
Assignees

Comments

@Isabello
Copy link
Contributor

Isabello commented Dec 1, 2016

When a node receives a block at the same height it does a simple check here: https://github.com/LiskHQ/lisk/blob/development/modules/blocks.js#L1341

This code basically says take the newest block we have and throw the old block away. This is incorrect. We need to approach this issue with the logic that the old blocks should be kept in every situation, as they will have the most adoption on the network and be forged by the correct delegate.

the revised code would look like this:

if (block.id < __private.lastBlock.id) {
   if (block.timestamp < __private.lastBlock.timestamp) {
   	library.logger.info('Last block loses');
   	return self.deleteLastBlock(cb);
   } else {
   	library.logger.info('Last block should not lose');
   	return setImmediate(cb);
   }
} else {
   library.logger.info('Newly received block wins');
   return setImmediate(cb);
}
@karmacoma karmacoma self-assigned this Dec 1, 2016
@karmacoma karmacoma added ready and removed ready labels Dec 1, 2016
@karmacoma
Copy link
Contributor

The following is a revised strategy courtesy of @4miners and @Isabello.

  • Compare blocks based on timestamp, not block id.
  • Warn when delegate detected forging on multiple nodes.
  • Delete both last block and its parent on fork 1.
  • Immediately receive block on fork 5 resolution.

@Isabello
Copy link
Contributor Author

Actually will reference in new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants