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

Updated istanbul consensus engine to verify headers synchronously #957

Merged
merged 5 commits into from
May 17, 2021

Conversation

jeongkyun-oh
Copy link
Contributor

@jeongkyun-oh jeongkyun-oh commented May 7, 2021

Proposed changes

  • UPDATE: The addresses cache is updated. Previously, the ecrecover method used an ARU cache with block hash as a key, but we need to cache all the addresses recovered from committed seals of a block. So, 65-bytes signatures are used as keys. Furthermore, the size of the cache is increased to 2048 * 30 (max number of downloaded blocks * approximate sub group size of validators).

  • After the PR Updated minimum staking related logic #920, the Refresh method must be called all the time to refresh proposer candidates as well as validators.

  • The Refresh method wasn't always called before because the header verification concurrently occurs while downloading a batch of blocks. (If the header does not exist, it ignores to refresh)

  • The Refresh method didn't work properly since it was failed to get staking information to verify headers. (It tries to call a contract method on a specific block which is not yet inserted)

  • This PR updates the header verification synchronously, while the computation of addresses will be processed concurrently to prevent download performance.

  • The simple synchronous verification performs poorly as below panel, so extracting the pub key from seals handled concurrently.
    image

  • The comparision sync test is attached.
    EN0 : master branch (Klaytn v1.6.1+f695312c38)
    EN1 : After this PR (Klaytn v1.6.1+d76876935e)
    EN2 : Before this PR (Klaytn v1.6.1+37b05fe791)

screencapture-54-180-156-230-3000-d-KnJhY-iWz-klaytn-main-overview-2021-05-17-09_20_39

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@ehnuje ehnuje left a comment

Choose a reason for hiding this comment

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

LGTM except for minor comments.

consensus/clique/clique.go Outdated Show resolved Hide resolved
consensus/consensus.go Outdated Show resolved Hide resolved
consensus/istanbul/backend/engine.go Outdated Show resolved Hide resolved
consensus/istanbul/backend/engine.go Outdated Show resolved Hide resolved
@jeongkyun-oh jeongkyun-oh force-pushed the KLT-754-sync-verify-header branch 2 times, most recently from 7912509 to 010bf47 Compare May 7, 2021 04:51
Copy link
Member

@aidan-kwon aidan-kwon left a comment

Choose a reason for hiding this comment

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

LGTM

@jeongkyun-oh jeongkyun-oh requested a review from ehnuje May 11, 2021 01:45
@jeongkyun-oh
Copy link
Contributor Author

@ehnuje @winnie-byun @yoomee1313 Please take a look.

Copy link
Contributor

@yoomee1313 yoomee1313 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@joowon-byun joowon-byun left a comment

Choose a reason for hiding this comment

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

It would be nice to put explanation. Nice work:)
EN0 : master branch (Klaytn v1.6.1+f695312c38)
EN1 : After this PR (Klaytn v1.6.1+d76876935e)
EN2 : Before this PR (Klaytn v1.6.1+37b05fe791)

@jeongkyun-oh jeongkyun-oh merged commit 75a15ac into klaytn:dev May 17, 2021
@jeongkyun-oh jeongkyun-oh deleted the KLT-754-sync-verify-header branch May 17, 2021 00:26
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.

None yet

6 participants