Skip to content

Commit

Permalink
Remove header gossip from p2p module (cosmos#964)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Closes: cosmos#965 

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [x] New and updated code has appropriate documentation
- [x] New and updated code has new and/or updated testing
- [x] Required CI checks are passing
- [x] Visual proof for any user facing features like CLI or
documentation updates
- [x] Linked issues closed with keywords
  • Loading branch information
Manav-Aggarwal authored May 30, 2023
1 parent 35d9071 commit 6e7d3a6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test-unit-race:
@go test -race -count=1 `go list ./...`
.PHONY: test-unit-race

### test-all: Run tests with and without data race
## test-all: Run tests with and without data race
test-all:
@$(MAKE) test-unit
@$(MAKE) test-unit-race
Expand Down
1 change: 0 additions & 1 deletion node/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func newLightNode(
}

node.P2P.SetTxValidator(node.falseValidator())
node.P2P.SetHeaderValidator(node.falseValidator())

node.BaseService = *service.NewBaseService(logger, "LightNode", node)

Expand Down
28 changes: 0 additions & 28 deletions p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ const (

// txTopicSuffix is added after namespace to create pubsub topic for TX gossiping.
txTopicSuffix = "-tx"

// headerTopicSuffix is added after namespace to create pubsub topic for block header gossiping.
headerTopicSuffix = "-header"
)

// Client is a P2P client, implemented with libp2p.
Expand All @@ -62,9 +59,6 @@ type Client struct {
txGossiper *Gossiper
txValidator GossipValidator

headerGossiper *Gossiper
headerValidator GossipValidator

// cancel is used to cancel context passed to libp2p functions
// it's required because of discovery.Advertise call
cancel context.CancelFunc
Expand Down Expand Up @@ -156,7 +150,6 @@ func (c *Client) Close() error {

return multierr.Combine(
c.txGossiper.Close(),
c.headerGossiper.Close(),
c.dht.Close(),
c.host.Close(),
)
Expand All @@ -173,17 +166,6 @@ func (c *Client) SetTxValidator(val GossipValidator) {
c.txValidator = val
}

// GossipSignedHeader sends the block header to the P2P network.
func (c *Client) GossipSignedHeader(ctx context.Context, headerBytes []byte) error {
c.logger.Debug("Gossiping block header", "len", len(headerBytes))
return c.headerGossiper.Publish(ctx, headerBytes)
}

// SetHeaderValidator sets the callback function, that will be invoked after block header is received from P2P network.
func (c *Client) SetHeaderValidator(validator GossipValidator) {
c.headerValidator = validator
}

// Addrs returns listen addresses of Client.
func (c *Client) Addrs() []multiaddr.Multiaddr {
return c.host.Addrs()
Expand Down Expand Up @@ -372,12 +354,6 @@ func (c *Client) setupGossiping(ctx context.Context) error {
}
go c.txGossiper.ProcessMessages(ctx)

c.headerGossiper, err = NewGossiper(c.host, c.ps, c.getHeaderTopic(), c.logger, WithValidator(c.headerValidator))
if err != nil {
return err
}
go c.headerGossiper.ProcessMessages(ctx)

return nil
}

Expand Down Expand Up @@ -415,7 +391,3 @@ func (c *Client) getNamespace() string {
func (c *Client) getTxTopic() string {
return c.getNamespace() + txTopicSuffix
}

func (c *Client) getHeaderTopic() string {
return c.getNamespace() + headerTopicSuffix
}

0 comments on commit 6e7d3a6

Please sign in to comment.