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

feat(p2p): moving gossiped blocks reception from validator to p2p client #811

Merged

Conversation

srene
Copy link
Contributor

@srene srene commented May 6, 2024

PR Standards

This PR decouples p2p gossip blocks validation from blocks reception. By doing that we avoid any interference of block store application in block propagation.

Opening a pull request should be able to meet the following requirements


Close #802

<-- Briefly describe the content of this pull request -->

For Author:

  • Targeted PR against correct branch
  • included the correct type prefix in the PR title
  • Linked to Github issue with discussion and accepted design
  • Targets only one github issue
  • Wrote unit and integration tests
  • All CI checks have passed
  • Added relevant godoc comments

For Reviewer:

  • confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • confirmed all author checklist items have been addressed

After reviewer approval:

  • In case targets main branch, PR should be squashed and merged.
  • In case PR targets a release branch, PR should be rebased.

@srene srene requested a review from a team as a code owner May 6, 2024 15:31
@srene srene marked this pull request as draft May 6, 2024 15:32
@srene srene marked this pull request as ready for review May 6, 2024 15:37
p2p/validator.go Outdated
Comment on lines 85 to 89
/*err := v.localPubsubServer.PublishWithEvents(context.Background(), gossipedBlock, map[string][]string{EventTypeKey: {EventNewGossipedBlock}})
if err != nil {
v.logger.Error("publishing event", "err", err)
return false
}
}*/
Copy link
Contributor

Choose a reason for hiding this comment

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

@srene supposed to be commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but i forgot to remove it. done

@srene srene force-pushed the srene/822-separate-gossip-block-received-from-validation branch from 117f052 to 808af10 Compare May 7, 2024 09:57
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

So I understand it's a simple change to move the local gossip part out of the validator, and into the message handler?
Looks good but I requested some renames

p2p/validator.go Outdated Show resolved Hide resolved
p2p/gossip.go Outdated
@@ -22,6 +22,8 @@ type GossipMessage struct {
// GossiperOption sets optional parameters of Gossiper.
type GossiperOption func(*Gossiper) error

type NewMessage func(msg *GossipMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename this GossipMessageHandler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

p2p/gossip.go Outdated
ps *pubsub.PubSub
topic *pubsub.Topic
sub *pubsub.Subscription
msgReceiver NewMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename to msgHandler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

p2p/gossip.go Outdated
}

// NewGossiper creates new, ready to use instance of Gossiper.
//
// Returned Gossiper object can be used for sending (Publishing) and receiving messages in topic identified by topicStr.
func NewGossiper(host host.Host, ps *pubsub.PubSub, topicStr string, logger types.Logger, options ...GossiperOption) (*Gossiper, error) {
func NewGossiper(host host.Host, ps *pubsub.PubSub, topicStr string, msgReceiver NewMessage, logger types.Logger, options ...GossiperOption) (*Gossiper, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename msgHandler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@srene srene requested a review from danwt May 7, 2024 11:58
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

great work!

@mtsitrin mtsitrin merged commit 0215717 into main May 8, 2024
4 checks passed
@mtsitrin mtsitrin deleted the srene/822-separate-gossip-block-received-from-validation branch May 8, 2024 12:52
omritoptix pushed a commit that referenced this pull request May 18, 2024
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.

decouple p2p validation from block reception and application
3 participants