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

Multiple state sync commitments per epoch #1083

Merged

Conversation

goran-ethernal
Copy link
Collaborator

@goran-ethernal goran-ethernal commented Dec 28, 2022

Description

Implemented multiple commitments per epoch feature, as per RFC-178. Wrote appropriate UTs, and a e2e test (TestE2E_Bridge_MultipleCommitmentsPerEpoch).

Process of building commitments is as follows:

  1. Using the event tracker, listen for state sync events, and store them in db.
  2. At the beginning of an epoch, check if we have enough events to build a commitment (minimum size of commitment at least, which is 2 events).
    a. If we have, build a commitment, sign it, and gossip a vote.
    b. If we do not have enough state sync events, wait until we have enough.
  3. If we gossiped a commitment which did not have a full size (10 events), on every state sync event that was received in the meantime, create a new commitment (with number of events of the old gossiped commitment, plus the new state syncs), sign it and gossip it.
  4. At every sprint block, check which of the gossiped commitments have quorum of votes, find the largest commitment that has quorum, and submit it.
  5. Once the block is finalized, check it to see if any was submit commitment transaction occurred.
    a. If there is, create a merkle tree, build state sync proofs, and save them to boltDb. Also, discard any cached commitment,
    since a new one will be built in the next block.
    b. If there isn’t, wait until some proposer submits the largest commitment with quorum.
  6. Once the epoch ends, and a new epoch is started, discard any pending commitments (that were built in the previous epoch, and are waiting for quorum of messages), since the validator set changes (we need to rebuild the last pending checkpoint in the new epoch).

commitmentsBuild

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

@codecov
Copy link

codecov bot commented Dec 28, 2022

Codecov Report

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

@@                 Coverage Diff                  @@
##             feature/v3-parity    #1083   +/-   ##
====================================================
  Coverage                     ?   54.51%           
====================================================
  Files                        ?      173           
  Lines                        ?    23033           
  Branches                     ?        0           
====================================================
  Hits                         ?    12557           
  Misses                       ?     9491           
  Partials                     ?      985           

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

@goran-ethernal goran-ethernal marked this pull request as ready for review December 28, 2022 13:53
Base automatically changed from feature/state-sync-manager to feature/v3-parity January 3, 2023 09:09
@goran-ethernal goran-ethernal force-pushed the EVM-341-Multiple-commitments-per-epoch branch from 57eb5ea to 4bf52d0 Compare January 9, 2023 08:27
@0xPolygon 0xPolygon deleted a comment from CLAassistant Jan 9, 2023
Copy link
Collaborator

@Stefan-Ethernal Stefan-Ethernal left a comment

Choose a reason for hiding this comment

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

Generally looks good, but leaving a couple of comments to consider.

consensus/polybft/consensus_runtime.go Outdated Show resolved Hide resolved
consensus/polybft/consensus_runtime.go Show resolved Hide resolved
consensus/polybft/state_sync_manager.go Outdated Show resolved Hide resolved
consensus/polybft/state_sync_manager.go Outdated Show resolved Hide resolved
consensus/polybft/state_sync_manager.go Outdated Show resolved Hide resolved
consensus/polybft/state_sync_manager.go Outdated Show resolved Hide resolved
consensus/polybft/state.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@Stefan-Ethernal Stefan-Ethernal left a comment

Choose a reason for hiding this comment

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

Generally looks good, but leaving a couple of comments to consider.

Copy link
Contributor

@ferranbt ferranbt left a comment

Choose a reason for hiding this comment

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

Some general comments.

Copy link
Collaborator

@Stefan-Ethernal Stefan-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/state_sync_manager.go Outdated Show resolved Hide resolved
@goran-ethernal goran-ethernal force-pushed the EVM-341-Multiple-commitments-per-epoch branch from 9087bc8 to a5b995f Compare January 9, 2023 13:12
@Stefan-Ethernal Stefan-Ethernal changed the title EVM-341-Multiple-commitments-per-epoch Multiple state sync commitments per epoch Jan 10, 2023
@goran-ethernal goran-ethernal force-pushed the EVM-341-Multiple-commitments-per-epoch branch from 4deeb56 to 486c05c Compare January 11, 2023 07:54
@goran-ethernal goran-ethernal merged commit 9e9bd63 into feature/v3-parity Jan 11, 2023
@goran-ethernal goran-ethernal deleted the EVM-341-Multiple-commitments-per-epoch branch January 11, 2023 08:23
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2023
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