next leader can be any leader depending on the gap of the view ID
do not change current pubkey unless leader change succeeded
Signed-off-by: Leo Chen <leo@harmony.one>
[viewchange] encapsulate view ID in the State struct
do NOT ues consensus.current directory to set/get viewID
use the following functions
consensus.SetCurViewID, consensus.SetViewChangingID
consensus.GetCurViewID, consensus.GetViewChangingID
Signed-off-by: Leo Chen <leo@harmony.one>
* [consensus] enable the consensus module can spin up doSync
* [consensus] remove the blockNumLowChan buffer in onCommitted. Move tryCatchup logic before informing blockNumLow
* [sync] Remove an unnecessary time ticker in sync to reduce one sync loop time from 3.5s to 1s (based on testnet)
* [consensus] also spin up state sync at onPrepared
* [consensus] removed onCommitted block number check since redundent
Check the following issue on the detailed explanation of why this commit makes sense.
https://github.com/harmony-one/harmony/issues/3225
The onPrepare and onCommit will do signature verification of the message payload.
So, there is no need to do duplicated sanity check when handling Prepare/Commit messages.
We reserve the signature verification on other messages, as they are not duplicated.
This PR can reduce the CPU load of leader during consensus.
Signed-off-by: Leo Chen <leo@harmony.one>
This is a big PR merged many small commits together.
We add the message validation function in libp2p layer.
In the validation function, we check the following conditions
1) the p2p message is a valid consensus message
2) the p2p message sender has a valid public key
3) the sender's public key is in the current committee
4) log the number of invalid/valid messages
After the validation, the valid messages will be forward to the network,
while the invalid messages will be filtered out.
The messages intended for the validator will be handled in the consensus layer.
Signed-off-by: Leo Chen <leo@harmony.one>