Skip to content

Commit 4c345bd

Browse files
authored
Merge pull request #1680 from keep-network/channel-forwarder-tweaks
Broadcast channel forwarder tweaks Current settings of the channel forwarder can cause an uncontrolled message propagation because forwarders live for 1 hour and libp2p pubsub cache holds seen messages only for 2 minutes. Because of that, a message can continuously flow in the network even if it is no longer relevant for anyone. If we have a significant number of keep-core clients in the network and there is a high rate of messages in general, the network can be congested. As a consequence, clients will experience resource usage peaks which can be deadly in certain environments. To prevent such problems we: - remove broadcast channel messages forwarding for DKG - reduce broadcast channel messages forwarders TTL for relay entries from 1 hour to 90 seconds
2 parents 8bd2632 + 50a5643 commit 4c345bd

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

pkg/beacon/relay/node.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,11 @@ func (n *Node) JoinGroupIfEligible(
139139
)
140140
}()
141141
}
142-
} else {
143-
go n.forwardDKGMessages(channelName)
144142
}
145143

146144
return
147145
}
148146

149-
// ForwardDKGMessages enables the ability to forward DKG messages
150-
// to other nodes even if this node has not been selected to the group.
151-
func (n *Node) forwardDKGMessages(name string) {
152-
n.netProvider.BroadcastChannelForwarderFor(name)
153-
}
154-
155147
// ForwardSignatureShares enables the ability to forward signature shares
156148
// messages to other nodes even if this node is not a part of the group which
157149
// signs the relay entry.

pkg/net/libp2p/libp2p.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ func (p *provider) BroadcastChannelForwarderFor(name string) {
116116
logger.Infof("requested message forwarder for channel: [%v]", name)
117117

118118
// TTL for a single message forwarder should be limited to avoid unnecessary
119-
// resource consumption. One hour seems to be a reasonable value as no
120-
// single protocol execution will exceed this time.
121-
ttl := 1 * time.Hour
119+
// resource consumption. This value should not exceed libp2p time-cache
120+
// duration which holds seen messages, to prevent an uncontrolled
121+
// message propagation.
122+
ttl := 90 * time.Second
122123

123124
if err := p.broadcastChannelManager.newForwarder(name, ttl); err != nil {
124125
logger.Warningf(

0 commit comments

Comments
 (0)