From 1fc27018b5e378340f7f7ab2d70dad5db4d88c96 Mon Sep 17 00:00:00 2001 From: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com> Date: Sat, 9 Mar 2024 23:45:12 -0600 Subject: [PATCH] v1.4.5 (#113) --- go-libp2p-blossomsub/blossomsub.go | 2 +- go-libp2p-blossomsub/pubsub.go | 2 +- node/app/db_console.go | 4 +- node/consensus/consensus_engine.go | 6 +-- node/main.go | 2 +- node/p2p/blossomsub.go | 80 ++++++++++++++++++++++++------ 6 files changed, 72 insertions(+), 24 deletions(-) diff --git a/go-libp2p-blossomsub/blossomsub.go b/go-libp2p-blossomsub/blossomsub.go index b4ae879..3792156 100644 --- a/go-libp2p-blossomsub/blossomsub.go +++ b/go-libp2p-blossomsub/blossomsub.go @@ -1589,7 +1589,7 @@ func (bs *BlossomSubRouter) heartbeat() { }) for _, p := range plst { - log.Debugf("HEARTBEAT: Opportunistically graft peer %s on bitmask %s", p, bitmask) + log.Debugf("HEARTBEAT: Opportunistically graft peer %s on bitmask %x", p, bitmask) graftPeer(p) } } diff --git a/go-libp2p-blossomsub/pubsub.go b/go-libp2p-blossomsub/pubsub.go index 60d91f3..caa883b 100644 --- a/go-libp2p-blossomsub/pubsub.go +++ b/go-libp2p-blossomsub/pubsub.go @@ -981,7 +981,7 @@ func (p *PubSub) notifySubs(msg *Message) { case f.ch <- msg: default: p.tracer.UndeliverableMessage(msg) - log.Infof("Can't deliver message to subscription for bitmask %s; subscriber too slow", bitmask) + log.Infof("Can't deliver message to subscription for bitmask %x; subscriber too slow", bitmask) } } } diff --git a/node/app/db_console.go b/node/app/db_console.go index 30ceeaa..417cc1f 100644 --- a/node/app/db_console.go +++ b/node/app/db_console.go @@ -887,11 +887,11 @@ func logoVersion(width int) string { out += " ''---.. ...---'' ##\n" out += " ''----------''\n" out += " \n" - out += " Quilibrium Node - v1.4.4 – Sunset\n" + out += " Quilibrium Node - v1.4.5 – Sunset\n" out += " \n" out += " DB Console\n" } else { - out = "Quilibrium Node - v1.4.4 – Sunset - DB Console\n" + out = "Quilibrium Node - v1.4.5 – Sunset - DB Console\n" } return out } diff --git a/node/consensus/consensus_engine.go b/node/consensus/consensus_engine.go index b810fef..a0d99e9 100644 --- a/node/consensus/consensus_engine.go +++ b/node/consensus/consensus_engine.go @@ -51,13 +51,13 @@ type DataConsensusEngine interface { } func GetMinimumVersionCutoff() time.Time { - return time.Date(2024, time.March, 10, 2, 0, 0, 0, time.UTC) + return time.Date(2024, time.March, 10, 5, 30, 0, 0, time.UTC) } func GetMinimumVersion() []byte { - return []byte{0x01, 0x04, 0x04} + return []byte{0x01, 0x04, 0x05} } func GetVersion() []byte { - return []byte{0x01, 0x04, 0x04} + return []byte{0x01, 0x04, 0x05} } diff --git a/node/main.go b/node/main.go index 88f9def..a876022 100644 --- a/node/main.go +++ b/node/main.go @@ -523,5 +523,5 @@ func printLogo() { func printVersion() { fmt.Println(" ") - fmt.Println(" Quilibrium Node - v1.4.4 – Sunset") + fmt.Println(" Quilibrium Node - v1.4.5 – Sunset") } diff --git a/node/p2p/blossomsub.go b/node/p2p/blossomsub.go index 7e9257a..5c84db7 100644 --- a/node/p2p/blossomsub.go +++ b/node/p2p/blossomsub.go @@ -22,6 +22,8 @@ import ( "github.com/libp2p/go-libp2p/core/protocol" "github.com/libp2p/go-libp2p/p2p/discovery/routing" "github.com/libp2p/go-libp2p/p2p/discovery/util" + rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager" + "github.com/libp2p/go-libp2p/p2p/net/connmgr" "github.com/mr-tron/base58" "github.com/pkg/errors" "go.uber.org/zap" @@ -58,7 +60,27 @@ var BITMASK_ALL = []byte{ // While we iterate through these next phases, we're going to aggressively // enforce keeping updated. This will be achieved through announce strings // that will vary with each update -var ANNOUNCE = "quilibrium-1.4.4-sunset-horizon" +var ANNOUNCE = "quilibrium-1.4.5-sunset-mirage" + +func getPeerID(p2pConfig *config.P2PConfig) peer.ID { + peerPrivKey, err := hex.DecodeString(p2pConfig.PeerPrivKey) + if err != nil { + panic(errors.Wrap(err, "error unmarshaling peerkey")) + } + + privKey, err := crypto.UnmarshalEd448PrivateKey(peerPrivKey) + if err != nil { + panic(errors.Wrap(err, "error unmarshaling peerkey")) + } + + pub := privKey.GetPublic() + id, err := peer.IDFromPublicKey(pub) + if err != nil { + panic(errors.Wrap(err, "error getting peer id")) + } + + return id +} func NewBlossomSub( p2pConfig *config.P2PConfig, @@ -70,6 +92,44 @@ func NewBlossomSub( libp2p.ListenAddrStrings(p2pConfig.ListenMultiaddr), } + isBootstrapPeer := false + peerId := getPeerID(p2pConfig) + + for _, peerAddr := range p2pConfig.BootstrapPeers { + peerinfo, err := peer.AddrInfoFromString(peerAddr) + if err != nil { + panic(err) + } + + if bytes.Equal([]byte(peerinfo.ID), []byte(peerId)) { + isBootstrapPeer = true + break + } + } + + if isBootstrapPeer { + limits := rcmgr.DefaultLimits + libp2p.SetDefaultServiceLimits(&limits) + limits.SystemBaseLimit.ConnsInbound = 2048 + limits.SystemBaseLimit.StreamsInbound = 2048 + rmgr, err := rcmgr.NewResourceManager( + rcmgr.NewFixedLimiter(limits.AutoScale()), + ) + if err != nil { + panic(err) + } + + mgr, err := connmgr.NewConnManager(512, 2048) + if err != nil { + panic(err) + } + + opts = append(opts, + libp2p.ResourceManager(rmgr), + libp2p.ConnectionManager(mgr), + ) + } + var privKey crypto.PrivKey if p2pConfig.PeerPrivKey != "" { peerPrivKey, err := hex.DecodeString(p2pConfig.PeerPrivKey) @@ -100,7 +160,7 @@ func NewBlossomSub( logger.Info("established peer id", zap.String("peer_id", h.ID().String())) - kademliaDHT := initDHT(ctx, p2pConfig, logger, h) + kademliaDHT := initDHT(ctx, p2pConfig, logger, h, isBootstrapPeer) routingDiscovery := routing.NewRoutingDiscovery(kademliaDHT) util.Advertise(ctx, routingDiscovery, ANNOUNCE) @@ -285,20 +345,8 @@ func initDHT( p2pConfig *config.P2PConfig, logger *zap.Logger, h host.Host, + isBootstrapPeer bool, ) *dht.IpfsDHT { - isBootstrapPeer := false - for _, peerAddr := range p2pConfig.BootstrapPeers { - peerinfo, err := peer.AddrInfoFromString(peerAddr) - if err != nil { - panic(err) - } - - if bytes.Equal([]byte(peerinfo.ID), []byte(h.ID())) { - isBootstrapPeer = true - break - } - } - logger.Info("establishing dht") var kademliaDHT *dht.IpfsDHT var err error @@ -516,7 +564,7 @@ func discoverPeers( logger.Info("initiating peer discovery") discover := func() { - peerChan, err := routingDiscovery.FindPeers(ctx, string(BITMASK_ALL)) + peerChan, err := routingDiscovery.FindPeers(ctx, ANNOUNCE) if err != nil { logger.Error("could not find peers", zap.Error(err)) }