Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consensus extra commit logic to avoid waiting for 100% sigs #4095

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

rlan35
Copy link
Contributor

@rlan35 rlan35 commented Mar 11, 2022

This PR implement the extra commit signature logic which allow leaders to only wait for 2/3 of the commit signature in current block and include the rest of the signatures (extra commit sig) in next block. Specifically, following changes will take effect after the extra commit fork epoch:

  1. ExtraCommitSig and ExtraCommitBitmap field is added to block header v4 which only take effect after ExtraCommitEpoch.
  2. Leaders will immediately finalizing the block once it received more than 2/3 of the voting powers on commit sig.
  3. In the next block, the leader will accept the rest of the commit signatures from the previous block and store it as extra commit signatures in DB and include it in the proposal in the new block.
  4. Validators is allowed to sign commit signature on the previous block so the signature can be included as a extra commit sig even if the validator is slow and didn't make it in the first 2/3 of the signatures.
  5. After the fork epoch, crosslinks and block rewards are calculated by combing the extra commit sig and the normal 2/3 of the sig together. The block reward distribution logic stay the same.

Fully tested this change on local network and was able to see extra commit signature being signed and accepted, crosslinks constructed/accepted and block rewards distributed correctly.

consensus/checks.go Outdated Show resolved Hide resolved
block/v4/header.go Outdated Show resolved Hide resolved
consensus/consensus_v2.go Show resolved Hide resolved
consensus/leader.go Outdated Show resolved Hide resolved
@@ -166,6 +167,7 @@ type BlockChain struct {
futureBlocks *lru.Cache // future blocks are blocks added for later processing
shardStateCache *lru.Cache
lastCommitsCache *lru.Cache
extraCommitsCache *lru.Cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the memory impact of this additional cache need to be assessed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a 10 slot cache, which will be close to nothing to store 10 signatures. So not a concern. But good to check.

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

Successfully merging this pull request may close these issues.

2 participants