Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

New Node registering to Network can cause other Nodes to reject Blocks #14

Open
michelbarnich opened this issue Dec 14, 2022 · 4 comments
Assignees
Labels
bug Something isn't working test-network Issue appears in the test-network branch

Comments

@michelbarnich
Copy link
Contributor

When a new Node registers to the Network, there is a chance that Nodes already registered to the Network will reject the next Block. The blocks are usually rejected with validity code 11:

Cypher/src/blockchain.js

Lines 397 to 398 in a48b1f4

if(Object.keys(block.validators).length != validators.length)
return 11;

This means that the number of validators listed in the Block does not match the expected number of validators. I currently dont know what causes this.

@michelbarnich michelbarnich added bug Something isn't working test-network Issue appears in the test-network branch labels Dec 14, 2022
@michelbarnich michelbarnich self-assigned this Dec 14, 2022
@michelbarnich
Copy link
Contributor Author

After some testing, this is my current theory as to what is going on:

When a Node registers, it might delay processing of incoming traffic. This could result in an incoming block being processed, after the TransactionQueue.worker() has already called Consensus.pickValidators(). Because of that, Networking.validators has already a new set of validators, and the delayed Block might get checked against these validators, and consequently fail.

This could be prevented, by having another object store the previous validators, or delay the call Consensus.pickValidators(). The first option seems safer to me.

@michelbarnich
Copy link
Contributor Author

I created a quick dirty fix, so we can test my theory. It is not perfect, the checks could later be implemented in Blockchain.validateBlock() itself, but this should be good enough for testing.

@michelbarnich
Copy link
Contributor Author

The fix seems to improve overall stability but not completely fix the issue, or maybe there is another de-sync occurring somewhere.

@michelbarnich
Copy link
Contributor Author

During testing for #16, I found out that, if a Node registers between the voting on a Block and sharing of an accepted Block, the newly registered Node will reject said Block, and later cause a desync in the Blockchain. #16 may fix the desync, because the newly registered Node will eventually be rejected by the Network, thus recovering.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working test-network Issue appears in the test-network branch
Projects
None yet
Development

No branches or pull requests

1 participant