add new bootstrap peers, adjust some of the peering params, also peer selection for version (#45)

This commit is contained in:
Cassandra Heart 2024-02-15 02:08:44 -06:00 committed by GitHub
parent 515c4748f7
commit ac5c393745
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 11 deletions

View File

@ -73,6 +73,9 @@ func LoadConfig(configPath string, proverKey string) (*Config, error) {
bootstrapPeers := []string{
"/dns/bootstrap.quilibrium.com/udp/8336/quic/p2p/QmUhm9iZVruSxyavjoPLCfuoRG94SGQEkfxEEoukEZmD5B",
"/dns/quaalude.quilibrium.com/udp/8336/quic/p2p/QmcKQjpQmLpbDsiif2MuakhHFyxWvqYauPsJDaXnLav7PJ",
"/dns/quecifer.quilibrium.com/udp/8336/quic/p2p/QmQkyqziNCycUDdeBypkikMZWH2bBmmxfK7cbJFJmyyQdQ",
"/dns/quantum.quilibrium.com/udp/8336/quic/p2p/QmXaSyf9Gaq5ddcHysefDpuE7SJqzdg1surQ5wac55ysJV",
"/ip4/204.186.74.47/udp/8317/quic/p2p/Qmd233pLUDvcDW3ama27usfbG1HxKNh1V9dmWVW1SXp1pd",
"/ip4/204.186.74.46/udp/8316/quic/p2p/QmeqBjm3iX7sdTieyto1gys5ruQrQNPKfaTGcVQQWJPYDV",
"/ip4/186.233.184.181/udp/8336/quic/p2p/QmW6QDvKuYqJYYMP5tMZSp12X3nexywK28tZNgqtqNpEDL",
@ -198,7 +201,11 @@ func LoadConfig(configPath string, proverKey string) (*Config, error) {
config.Engine.GenesisSeed = genesisSeed
}
if len(config.P2P.BootstrapPeers) == 0 {
// Slight trick here to get people on the latest bootstrap list
// if it's empty, always use latest, if it has the Q bootstrap node, always
// use latest.
if len(config.P2P.BootstrapPeers) == 0 ||
config.P2P.BootstrapPeers[0] == bootstrapPeers[0] {
config.P2P.BootstrapPeers = bootstrapPeers
}

View File

@ -1,6 +1,7 @@
package ceremony
import (
"bytes"
"context"
"io"
"time"
@ -155,7 +156,8 @@ func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer() (
for _, v := range e.peerMap {
_, ok := e.uncooperativePeersMap[string(v.peerId)]
if v.maxFrame > max &&
v.timestamp > consensus.GetMinimumVersionCutoff().UnixMilli() && !ok {
v.timestamp > consensus.GetMinimumVersionCutoff().UnixMilli() &&
bytes.Compare(v.version, consensus.GetMinimumVersion()) >= 0 && !ok {
peer = v.peerId
max = v.maxFrame
}
@ -330,14 +332,8 @@ func (e *CeremonyDataClockConsensusEngine) collect(
e.syncingStatus = SyncStatusNotSyncing
}
// With large networks and slow syncing machines, this can lead to an
// infinite loop if the list is refreshing fast enough, so make the size
// of the map the maximum loop case:
e.peerMapMx.Lock()
size := len(e.peerMap)
e.peerMapMx.Unlock()
for i := 0; i < size; i++ {
// With the increase of network size, constrain down to top thirty
for i := 0; i < 30; i++ {
peerId, maxFrame, err := e.GetMostAheadPeer()
if err != nil {
e.logger.Warn("no peers available, skipping sync")

View File

@ -344,7 +344,9 @@ func initDHT(
go func() {
for {
time.Sleep(30 * time.Second)
if len(h.Network().Peers()) == 0 {
// try to assert some stability, never go below min peers for data
// consensus:
if len(h.Network().Peers()) < 3 {
logger.Info("reconnecting to peers")
reconnect()
}