mx-chain-go
mx-chain-go copied to clipboard
Feat/optimise consensus sigcheck
Description of the reasoning behind the pull request
This PR brings several changes on the way block signatures are handler during consensus in order to optimize the CPU usage. Each signature share used in the aggregation of signatures for the block consensus proof, was previously individually verified. Assuming all validators are honest, the verification takes ~3ms per signature. In metachain, each block accumulates ~400 signatures which is individually checked by all participants in consensus, taking a cumulative ~1.2s CPU time for each block that passes consensus.
Proposed Changes
This 1.2 seconds for metachain and ~200 ms for shards each round (for the synchronized nodes) can be optimized out, if instead the aggregation is done assuming all signature shares are valid, and verification is done on the aggregation instead. The cost of the verification of the aggregated signature was optimized by the previous PR #4314 down to ~3ms as well. This however can only be saved if all aggregated signatures are valid, otherwise, if the aggregated signature does not verify we will have an extra cost of 3ms, as the leader will aggregate first the signatures and then verify the aggregated signature. If the aggregated signature does not verify, the leader will have to check the signatures individually. In order to avoid the increase and instead always have this optimization, a penalty for providing invalid signatures will be implemented which we call a pseudo slashing, that should provide enough disincentive.
The pseudo slashing is implementing through the addition of an extra message with the proof for received invalid signatures, sent on the consensus. This message is not mandatory to be sent during a consensus round, but if it is sent, the proof will be verified and used by nodes listening to the consensus messages to temporarily blacklist the misbehaving nodes. While blacklisted, the messages from the nodes in the blacklist will be dropped and this will cause rating drop and the eventual jailing, that penalize the node through the unjailing fee, missing block rewards/fees and queue time for becoming eligible for consensus again.