From 09b04402dfb8aa8d171d84a8024869b36cf8c01f Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Fri, 28 Jun 2024 20:45:17 -0500 Subject: [PATCH] v1.4.20-p1 --- go-libp2p-blossomsub/blossomsub.go | 4 ++-- node/config/version.go | 2 +- .../master/master_clock_consensus_engine.go | 8 ++++--- node/main.go | 1 + node/p2p/blossomsub.go | 21 +++++++++++++++++-- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/go-libp2p-blossomsub/blossomsub.go b/go-libp2p-blossomsub/blossomsub.go index 0274b5f..43c71df 100644 --- a/go-libp2p-blossomsub/blossomsub.go +++ b/go-libp2p-blossomsub/blossomsub.go @@ -214,7 +214,7 @@ func NewBlossomSubWithRouter(ctx context.Context, h host.Host, rt PubSubRouter, } // NewBlossomSubRouter returns a new BlossomSubRouter with custom parameters. -func NewBlossomSubRouter(h host.Host, params BlossomSubParams) *BlossomSubRouter { +func NewBlossomSubRouter(h host.Host, params BlossomSubParams, addrBook peerstore.AddrBook) *BlossomSubRouter { return &BlossomSubRouter{ peers: make(map[peer.ID]protocol.ID), mesh: make(map[string]map[peer.ID]struct{}), @@ -222,7 +222,7 @@ func NewBlossomSubRouter(h host.Host, params BlossomSubParams) *BlossomSubRouter lastpub: make(map[string]int64), gossip: make(map[peer.ID][]*pb.ControlIHave), control: make(map[peer.ID]*pb.ControlMessage), - cab: pstoremem.NewAddrBook(), + cab: addrBook, backoff: make(map[string]map[peer.ID]time.Time), peerhave: make(map[peer.ID]int), iasked: make(map[peer.ID]int), diff --git a/node/config/version.go b/node/config/version.go index 2a0ea18..92ef409 100644 --- a/node/config/version.go +++ b/node/config/version.go @@ -36,5 +36,5 @@ func FormatVersion(version []byte) string { } func GetPatchNumber() byte { - return 0x00 + return 0x01 } diff --git a/node/consensus/master/master_clock_consensus_engine.go b/node/consensus/master/master_clock_consensus_engine.go index 6b372fc..63874dc 100644 --- a/node/consensus/master/master_clock_consensus_engine.go +++ b/node/consensus/master/master_clock_consensus_engine.go @@ -146,7 +146,7 @@ func NewMasterClockConsensusEngine( report: report, frameValidationCh: make(chan *protobufs.ClockFrame), bandwidthTestCh: make(chan []byte), - verifyTestCh: make(chan verifyChallenge), + verifyTestCh: make(chan verifyChallenge, 120000), engineConfig: engineConfig, } @@ -403,8 +403,10 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { zap.Uint64("current_frame", e.report.MasterHeadFrame), ) - if err := e.publishMessage(e.filter, e.report); err != nil { - e.logger.Debug("error publishing message", zap.Error(err)) + if increment%30 == 0 { + if err := e.publishMessage(e.filter, e.report); err != nil { + e.logger.Debug("error publishing message", zap.Error(err)) + } } } else { skipStore = false diff --git a/node/main.go b/node/main.go index 0f61e3c..5e6264d 100644 --- a/node/main.go +++ b/node/main.go @@ -438,6 +438,7 @@ func main() { } repair(*configDirectory, node) + runtime.GOMAXPROCS(1) if nodeConfig.ListenGRPCMultiaddr != "" { srv, err := rpc.NewRPCServer( diff --git a/node/p2p/blossomsub.go b/node/p2p/blossomsub.go index 97a0322..b129b2a 100644 --- a/node/p2p/blossomsub.go +++ b/node/p2p/blossomsub.go @@ -85,6 +85,16 @@ func getPeerID(p2pConfig *config.P2PConfig) peer.ID { return id } +type realclock struct{} + +func (rc realclock) Now() time.Time { + return time.Now() +} + +func (rc realclock) After(d time.Duration) <-chan time.Time { + return time.After(d) +} + func NewBlossomSub( p2pConfig *config.P2PConfig, peerstore store.Peerstore, @@ -126,7 +136,14 @@ func NewBlossomSub( opts = append(opts, libp2p.Identity(privKey)) } - ps, err := pstoreds.NewPeerstore(ctx, peerstore, pstoreds.DefaultOpts()) + ps, err := pstoreds.NewPeerstore(ctx, peerstore, pstoreds.Options{ + CacheSize: 120000, + MaxProtocols: 1024, + GCPurgeInterval: 2 * time.Hour, + GCLookaheadInterval: 0, + GCInitialDelay: 60 * time.Second, + Clock: realclock{}, + }) if err != nil { panic(err) } @@ -208,7 +225,7 @@ func NewBlossomSub( })) params := mergeDefaults(p2pConfig) - rt := blossomsub.NewBlossomSubRouter(h, params) + rt := blossomsub.NewBlossomSubRouter(h, params, ps) pubsub, err := blossomsub.NewBlossomSubWithRouter(ctx, h, rt, blossomOpts...) if err != nil { panic(err)