Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion f3-sidecar/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/libp2p/go-libp2p-kad-dht v0.33.1
github.com/libp2p/go-libp2p-pubsub v0.14.0
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.39.0
)

require (
Expand Down Expand Up @@ -135,7 +136,6 @@ require (
go.uber.org/mock v0.5.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.41.0 // indirect
Expand Down
14 changes: 14 additions & 0 deletions f3-sidecar/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/libp2p/go-libp2p"
dht "github.com/libp2p/go-libp2p-kad-dht"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/protocol"
"golang.org/x/crypto/blake2b"
)

const ListenAddr = "/ip4/127.0.0.1/tcp/0"
Expand Down Expand Up @@ -51,10 +53,22 @@ func createP2PHost(ctx context.Context, networkName string) (*P2PHost, error) {
ps, err := pubsub.NewGossipSub(ctx, host,
pubsub.WithPeerExchange(true),
pubsub.WithFloodPublish(true),
pubsub.WithMessageIdFn(hashMsgId),
// Bump the validation queue to accommodate the increase in gossipsub message
// exchange rate as a result of f3. The size of 4096 should offer enough headroom
// for slower F3 validation while avoiding: 1) avoid excessive memory usage, 2)
// dropped consensus related messages and 3) cascading effect among other topics
// since this config isn't topic-specific.
pubsub.WithValidateQueueSize(4096),
pubsub.WithPeerScore(PubsubPeerScoreParams, PubsubPeerScoreThresholds))
if err != nil {
return nil, err
}

return &P2PHost{host, hostDHT, backupHostDHT, ps}, nil
}

func hashMsgId(m *pubsub_pb.Message) string {
hash := blake2b.Sum256(m.Data)
return string(hash[:])
}
Loading