diff --git a/config/example_config.toml b/config/example_config.toml index b8342ea36..43f4916e6 100644 --- a/config/example_config.toml +++ b/config/example_config.toml @@ -82,10 +82,6 @@ # Default is `true`. ## node_network = true - # `node_gossip_experimental` indicates whether the node participates in the gossiping protocol. - # Default is `false`. - ## node_gossip_experimental = false - # `sync.firewall` contains configuration options for the sync firewall. [sync.firewall] # `enable` indicates whether the firewall should be enabled or not. diff --git a/network/config.go b/network/config.go index 9081a92df..014e77103 100644 --- a/network/config.go +++ b/network/config.go @@ -27,7 +27,6 @@ type Config struct { DefaultRelayAddrStrings []string `toml:"-"` DefaultBootstrapAddrStrings []string `toml:"-"` IsBootstrapper bool `toml:"-"` - IsGossiper bool `toml:"-"` } func DefaultConfig() *Config { @@ -46,7 +45,6 @@ func DefaultConfig() *Config { ForcePrivateNetwork: false, DefaultPort: 21888, IsBootstrapper: false, - IsGossiper: false, } } diff --git a/network/dht.go b/network/dht.go index fe84cac57..a90a562d9 100644 --- a/network/dht.go +++ b/network/dht.go @@ -20,7 +20,7 @@ func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore. conf *Config, log *logger.SubLogger, ) *dhtService { mode := lp2pdht.ModeAuto - if conf.IsBootstrapper || conf.IsGossiper { + if conf.IsBootstrapper { mode = lp2pdht.ModeServer } opts := []lp2pdht.Option{ diff --git a/network/gossip.go b/network/gossip.go index a5fc7acbd..be53f6f37 100644 --- a/network/gossip.go +++ b/network/gossip.go @@ -3,6 +3,7 @@ package network import ( "context" "sync" + "time" lp2pps "github.com/libp2p/go-libp2p-pubsub" lp2pcore "github.com/libp2p/go-libp2p/core" @@ -22,20 +23,35 @@ type gossipService struct { } func newGossipService(ctx context.Context, host lp2phost.Host, eventCh chan Event, - _ *Config, log *logger.SubLogger, + conf *Config, log *logger.SubLogger, ) *gossipService { opts := []lp2pps.Option{ + lp2pps.WithFloodPublish(true), lp2pps.WithMessageSignaturePolicy(lp2pps.StrictNoSign), lp2pps.WithNoAuthor(), lp2pps.WithMessageIdFn(MessageIDFunc), + lp2pps.WithPeerOutboundQueueSize(600), } - pubsub, err := lp2pps.NewFloodSub(ctx, host, opts...) + if conf.IsBootstrapper { + // enable Peer eXchange on bootstrappers + opts = append(opts, lp2pps.WithPeerExchange(true)) + } + + gsParams := lp2pps.DefaultGossipSubParams() + if conf.IsBootstrapper { + gsParams.Dhi = 12 + gsParams.D = 8 + gsParams.Dlo = 6 + gsParams.HeartbeatInterval = 700 * time.Millisecond + } + opts = append(opts, lp2pps.WithGossipSubParams(gsParams)) + + pubsub, err := lp2pps.NewGossipSub(ctx, host, opts...) if err != nil { log.Panic("unable to start Gossip service", "error", err) return nil } - return &gossipService{ ctx: ctx, host: host, diff --git a/network/network.go b/network/network.go index 1043de504..e7a9b2d0c 100644 --- a/network/network.go +++ b/network/network.go @@ -249,8 +249,7 @@ func newNetwork(conf *Config, log *logger.SubLogger, opts []lp2p.Option) (*netwo n.logger.Info("network setup", "id", n.host.ID(), "name", conf.NetworkName, "address", conf.ListenAddrStrings, - "bootstrapper", conf.IsBootstrapper, - "gossiper", conf.IsGossiper) + "bootstrapper", conf.IsBootstrapper) return n, nil } diff --git a/node/node.go b/node/node.go index 0726f9bdc..2cf7ec5cb 100644 --- a/node/node.go +++ b/node/node.go @@ -48,7 +48,6 @@ func NewNode(genDoc *genesis.Genesis, conf *config.Config, "version", version.Version(), "network", genDoc.ChainType()) - conf.Network.IsGossiper = conf.Sync.NodeGossip net, err := network.NewNetwork(conf.Network) if err != nil { return nil, err diff --git a/sync/config.go b/sync/config.go index 4d495ae36..faa6b0134 100644 --- a/sync/config.go +++ b/sync/config.go @@ -12,7 +12,6 @@ type Config struct { Moniker string `toml:"moniker"` SessionTimeout time.Duration `toml:"session_timeout"` NodeNetwork bool `toml:"node_network"` - NodeGossip bool `toml:"node_gossip_experimental"` Firewall *firewall.Config `toml:"firewall"` // Private configs @@ -25,7 +24,6 @@ func DefaultConfig() *Config { return &Config{ SessionTimeout: time.Second * 10, NodeNetwork: true, - NodeGossip: false, BlockPerMessage: 60, MaxSessions: 8, LatestBlockInterval: 720, @@ -48,8 +46,5 @@ func (conf *Config) Services() service.Services { if conf.NodeNetwork { s.Append(service.Network) } - if conf.NodeGossip { - s.Append(service.Gossip) - } return s } diff --git a/sync/sync.go b/sync/sync.go index fe6e32a68..a9194c2a7 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -572,27 +572,10 @@ func (sync *synchronizer) prepareBlocks(from, count uint32) [][]byte { // weAreInTheCommittee checks if one of the validators is a member of the committee // at the current height. -func (sync *synchronizer) weAreInTheCommittee() bool { - return sync.consMgr.HasActiveInstance() +func (sync *synchronizer) shouldPropagateGeneralMessage(_ *network.GossipMessage) bool { + return true } -func (sync *synchronizer) shouldPropagateMessage(msg *network.GossipMessage) bool { - // Propagate our messages - if msg.From == sync.SelfID() { - return true - } - - if sync.config.NodeGossip { - return true - } - - return sync.weAreInTheCommittee() -} - -func (sync *synchronizer) shouldPropagateGeneralMessage(msg *network.GossipMessage) bool { - return sync.shouldPropagateMessage(msg) -} - -func (sync *synchronizer) shouldPropagateConsensusMessage(msg *network.GossipMessage) bool { - return sync.shouldPropagateMessage(msg) +func (sync *synchronizer) shouldPropagateConsensusMessage(_ *network.GossipMessage) bool { + return true }