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

Check Chainstart Before Processing Messages In Pubsub #7494

Merged
merged 5 commits into from
Oct 15, 2020
Merged

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Oct 10, 2020

What type of PR is this?

Feature Addition

What does this PR do? Why is it needed?

  • Prevents gossip messages from being relayed before chainstart.
  • Add unit test for gossip.

Which issues(s) does this PR fix?

N.A

Other notes for review

@nisdas nisdas requested a review from a team as a code owner October 10, 2020 11:52
@nisdas nisdas added the Ready For Review A pull request ready for code review label Oct 10, 2020
@@ -277,6 +277,11 @@ func (s *Service) registerHandlers() {
}
}

// marks the chain as having started.
func (s *Service) markForChainStart() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (s *Service) markForChainStart() {
func (s *Service) setChainStart() {

Sounds better?

@@ -277,6 +277,11 @@ func (s *Service) registerHandlers() {
}
}

// marks the chain as having started.
func (s *Service) markForChainStart() {
s.chainStarted = true
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to add a lock ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method can only be called once and that too from a single routine. I don't think a lock is necessary here

@prestonvanloon
Copy link
Member

@nisdas there might be some overlap here with #7496. Let me know if you think so and how to proceed with these two PRs.

@nisdas
Copy link
Member Author

nisdas commented Oct 14, 2020

This PR mostly does a defensive check during genesis to make sure that we dont receive any messages before chainstart. It's different from #7496, which does a specific subscription check for each topic. @prestonvanloon

@nisdas nisdas merged commit 0b64a33 into master Oct 15, 2020
@delete-merged-branch delete-merged-branch bot deleted the checkChainstart branch October 15, 2020 14:03
// Reject any messages received before chainstart.
if !s.chainStarted {
messageFailedValidationCounter.WithLabelValues(topic).Inc()
return pubsub.ValidationReject
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not a good choice. ValidationReject affects peer scoring, we should use ValidationIgnore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants