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

Istanbul message handler checks whether the sender is a member of the committee #545

Merged
merged 4 commits into from
Jun 17, 2020

Conversation

aidan-kwon
Copy link
Member

@aidan-kwon aidan-kwon commented Jun 16, 2020

Proposed changes

AS-IS
Istanbul message handler checks whether the sender is a validator.
However, it doesn't check whether the sender is a member of the committee.

*Committee is a subset of validators and composed by the block number and the round number.

TO-BE
Istanbul message handler checks whether the sender is a member of the committee.

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

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If a validator is not a member of the committee, he/she doesn't propagate prepare/commit/roundChange messages, but he/she sends them to eventMux of its Istanbul core. It may result in the mismatch of message count among validators and prevent achieving a consensus.

This issue can be mitigated with this PR by validating the sender in the receiver side. Moreover, we can validate the sender in the sender side also before it sends messages. It will be handled in the following PR.

@@ -71,6 +71,9 @@ func (c *core) handleCommit(msg *message, src istanbul.Validator) error {
}

//logger.Error("receive handle commit","num", commit.View.Sequence)
if !c.valSet.CheckInSubList(msg.Hash, commit.View, src.Address()) {
return errNotFromCommittee
}

if err := c.checkMessage(msgCommit, commit.View); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to call CheckInSubList inside checkMessage? Don't we need to check if the sender is in the committee for preprepare or processBacklog?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need to check preprepare message since it only has one valid sender(proposer) at a time and is checked with its own routine.
Because CheckInSubList is not a common routine for all Istanbul message, I think it is better to place CheckInSubList in the current position.

@@ -202,12 +202,7 @@ func (sb *backend) Gossip(valSet istanbul.ValidatorSet, payload []byte) error {

// checkInSubList checks if the node is in a sublist
func (sb *backend) checkInSubList(prevHash common.Hash, valSet istanbul.ValidatorSet) bool {
Copy link
Contributor

@KimKyungup KimKyungup Jun 17, 2020

Choose a reason for hiding this comment

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

More clear?

Suggested change
func (sb *backend) checkInSubList(prevHash common.Hash, valSet istanbul.ValidatorSet) bool {
func (sb *backend) checkInCommittee(prevHash common.Hash, valSet istanbul.ValidatorSet) bool {

Copy link
Member Author

Choose a reason for hiding this comment

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

"SubList" is commonly used in overall code instead of "Committee".
I will consider changing all of them later.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about remove func (sb *backend) checkInSubList and use valSet.CheckInSubList directly on line 243?

Copy link
Member Author

Choose a reason for hiding this comment

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

@laggu Good suggestion. I will consider it later.

Copy link
Contributor

@KimKyungup KimKyungup left a comment

Choose a reason for hiding this comment

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

LGTM

@KimKyungup KimKyungup requested a review from laggu June 17, 2020 01:54
@KimKyungup
Copy link
Contributor

@andybclee @laggu Please take a look. :)

Copy link
Contributor

@andybclee andybclee 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

@laggu laggu left a comment

Choose a reason for hiding this comment

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

LGTM

@aidan-kwon aidan-kwon merged commit 1c78be7 into klaytn:dev Jun 17, 2020
@aidan-kwon aidan-kwon deleted the 0611-istanbul branch June 17, 2020 04:37
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