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

Checkpoint data signing #840

Merged

Conversation

Stefan-Ethernal
Copy link
Collaborator

@Stefan-Ethernal Stefan-Ethernal commented Oct 26, 2022

Description

This PR introduces new fields to the Header.Extra, which are required for checkpointing mechanism and are part of consensus protocol.

Checkpoint data consists of:

  • BlockRound - round for which we are building block at given height,
  • EpochNumber - denoting current epoch,
  • CurrentValidatorsHash - hash of the current validator set (for the current epoch),
  • NextValidatorsHash - hash of the next validator set (applicable for next epoch, namely epoch ending blocks which contain such information),
  • EventRoot - merkle root hash of all exit events triggered by the appropriate smart contract.

Other than that, checkpoint is described with BlockNumber, BlockHash and ChainID, but we don't write those information into the blockchain, as it would be redundant.

Checkpoint data hash is in the following format:

keccak256(abi.encode(uint256 chainId, uint256 blockNumber, bytes32 blockHash, uint256 blockRound, 
   uint256 epochNumber, bytes32 currentValidatorsHash, bytes32 nextValidatorsHash, bytes32 eventRoot))

Current validators and next validators hash is in the following format:

keccak256(abi.encode(tuple(address _address, uint256[4] blsKey)[]))

Also format of the proposal hash being signed by the validators has changed. Prior to this PR, it was corresponding to BlockHash. However now it is the same as checkpointHash.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@Stefan-Ethernal Stefan-Ethernal self-assigned this Oct 27, 2022
@Stefan-Ethernal Stefan-Ethernal added the feature New update to Polygon Edge label Oct 27, 2022
@codecov
Copy link

codecov bot commented Oct 27, 2022

Codecov Report

❗ No coverage uploaded for pull request base (feature/v3-parity@ac2f523). Click here to learn what that means.
The diff coverage is n/a.

@@                 Coverage Diff                  @@
##             feature/v3-parity     #840   +/-   ##
====================================================
  Coverage                     ?   53.31%           
====================================================
  Files                        ?      161           
  Lines                        ?    21449           
  Branches                     ?        0           
====================================================
  Hits                         ?    11436           
  Misses                       ?     9079           
  Partials                     ?      934           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@goran-ethernal goran-ethernal left a comment

Choose a reason for hiding this comment

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

LGTM

consensus/polybft/extra.go Show resolved Hide resolved
Copy link
Contributor

@b00ris b00ris left a comment

Choose a reason for hiding this comment

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

LGTM

consensus/polybft/polybft_test.go Outdated Show resolved Hide resolved
consensus/polybft/block_builder.go Outdated Show resolved Hide resolved
consensus/polybft/fsm.go Show resolved Hide resolved
@Stefan-Ethernal Stefan-Ethernal force-pushed the feature/EVM-85-checkpoint-data-signing branch from 87de519 to 7647052 Compare October 31, 2022 10:13
@Stefan-Ethernal Stefan-Ethernal merged commit dec0e88 into feature/v3-parity Oct 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2022
@Stefan-Ethernal Stefan-Ethernal deleted the feature/EVM-85-checkpoint-data-signing branch October 31, 2022 12:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New update to Polygon Edge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants