This commit is contained in:
Cassandra Heart 2024-03-09 23:45:12 -06:00 committed by GitHub
parent ee1ebcce80
commit 1fc27018b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 72 additions and 24 deletions

View File

@ -1589,7 +1589,7 @@ func (bs *BlossomSubRouter) heartbeat() {
}) })
for _, p := range plst { 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) graftPeer(p)
} }
} }

View File

@ -981,7 +981,7 @@ func (p *PubSub) notifySubs(msg *Message) {
case f.ch <- msg: case f.ch <- msg:
default: default:
p.tracer.UndeliverableMessage(msg) 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)
} }
} }
} }

View File

@ -887,11 +887,11 @@ func logoVersion(width int) string {
out += " ''---.. ...---'' ##\n" out += " ''---.. ...---'' ##\n"
out += " ''----------''\n" 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 += " \n"
out += " DB Console\n" out += " DB Console\n"
} else { } else {
out = "Quilibrium Node - v1.4.4 Sunset - DB Console\n" out = "Quilibrium Node - v1.4.5 Sunset - DB Console\n"
} }
return out return out
} }

View File

@ -51,13 +51,13 @@ type DataConsensusEngine interface {
} }
func GetMinimumVersionCutoff() time.Time { 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 { func GetMinimumVersion() []byte {
return []byte{0x01, 0x04, 0x04} return []byte{0x01, 0x04, 0x05}
} }
func GetVersion() []byte { func GetVersion() []byte {
return []byte{0x01, 0x04, 0x04} return []byte{0x01, 0x04, 0x05}
} }

View File

@ -523,5 +523,5 @@ func printLogo() {
func printVersion() { func printVersion() {
fmt.Println(" ") fmt.Println(" ")
fmt.Println(" Quilibrium Node - v1.4.4 Sunset") fmt.Println(" Quilibrium Node - v1.4.5 Sunset")
} }

View File

@ -22,6 +22,8 @@ import (
"github.com/libp2p/go-libp2p/core/protocol" "github.com/libp2p/go-libp2p/core/protocol"
"github.com/libp2p/go-libp2p/p2p/discovery/routing" "github.com/libp2p/go-libp2p/p2p/discovery/routing"
"github.com/libp2p/go-libp2p/p2p/discovery/util" "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/mr-tron/base58"
"github.com/pkg/errors" "github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
@ -58,7 +60,27 @@ var BITMASK_ALL = []byte{
// While we iterate through these next phases, we're going to aggressively // While we iterate through these next phases, we're going to aggressively
// enforce keeping updated. This will be achieved through announce strings // enforce keeping updated. This will be achieved through announce strings
// that will vary with each update // 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( func NewBlossomSub(
p2pConfig *config.P2PConfig, p2pConfig *config.P2PConfig,
@ -70,6 +92,44 @@ func NewBlossomSub(
libp2p.ListenAddrStrings(p2pConfig.ListenMultiaddr), 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 var privKey crypto.PrivKey
if p2pConfig.PeerPrivKey != "" { if p2pConfig.PeerPrivKey != "" {
peerPrivKey, err := hex.DecodeString(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())) 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) routingDiscovery := routing.NewRoutingDiscovery(kademliaDHT)
util.Advertise(ctx, routingDiscovery, ANNOUNCE) util.Advertise(ctx, routingDiscovery, ANNOUNCE)
@ -285,20 +345,8 @@ func initDHT(
p2pConfig *config.P2PConfig, p2pConfig *config.P2PConfig,
logger *zap.Logger, logger *zap.Logger,
h host.Host, h host.Host,
isBootstrapPeer bool,
) *dht.IpfsDHT { ) *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") logger.Info("establishing dht")
var kademliaDHT *dht.IpfsDHT var kademliaDHT *dht.IpfsDHT
var err error var err error
@ -516,7 +564,7 @@ func discoverPeers(
logger.Info("initiating peer discovery") logger.Info("initiating peer discovery")
discover := func() { discover := func() {
peerChan, err := routingDiscovery.FindPeers(ctx, string(BITMASK_ALL)) peerChan, err := routingDiscovery.FindPeers(ctx, ANNOUNCE)
if err != nil { if err != nil {
logger.Error("could not find peers", zap.Error(err)) logger.Error("could not find peers", zap.Error(err))
} }