fix: stop trying to sync with uncooperative peers

This commit is contained in:
Cassandra Heart 2023-10-05 15:17:06 -05:00
parent 53a19f3f23
commit b4ad1aed18
No known key found for this signature in database
GPG Key ID: 6352152859385958
3 changed files with 21 additions and 11 deletions

View File

@ -158,6 +158,10 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
e.peerMapMx.Lock() e.peerMapMx.Lock()
for _, p := range announce.PeerList { for _, p := range announce.PeerList {
if _, ok := e.uncooperativePeersMap[string(p.PeerId)]; ok {
continue
}
if bytes.Equal(p.PeerId, e.pubSub.GetPeerID()) { if bytes.Equal(p.PeerId, e.pubSub.GetPeerID()) {
continue continue
} }

View File

@ -87,6 +87,7 @@ type CeremonyDataClockConsensusEngine struct {
peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce
peerMap map[string]*peerInfo peerMap map[string]*peerInfo
activeChannelsMap map[string]ChannelServer activeChannelsMap map[string]ChannelServer
uncooperativePeersMap map[string]*peerInfo
fullResync bool fullResync bool
} }
@ -146,17 +147,18 @@ func NewCeremonyDataClockConsensusEngine(
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}, },
lastFrameReceivedAt: time.Time{}, lastFrameReceivedAt: time.Time{},
frameProverTrie: &tries.RollingFrecencyCritbitTrie{}, frameProverTrie: &tries.RollingFrecencyCritbitTrie{},
frameSeenProverTrie: &tries.RollingFrecencyCritbitTrie{}, frameSeenProverTrie: &tries.RollingFrecencyCritbitTrie{},
pendingCommits: make(chan *anypb.Any), pendingCommits: make(chan *anypb.Any),
pendingCommitWorkers: engineConfig.PendingCommitWorkers, pendingCommitWorkers: engineConfig.PendingCommitWorkers,
prover: qcrypto.DefaultKZGProver(), prover: qcrypto.DefaultKZGProver(),
stagedKeyCommits: make(InclusionMap), stagedKeyCommits: make(InclusionMap),
stagedKeyPolynomials: make(PolynomialMap), stagedKeyPolynomials: make(PolynomialMap),
syncingStatus: SyncStatusNotSyncing, syncingStatus: SyncStatusNotSyncing,
peerAnnounceMap: map[string]*protobufs.CeremonyPeerListAnnounce{}, peerAnnounceMap: map[string]*protobufs.CeremonyPeerListAnnounce{},
peerMap: map[string]*peerInfo{}, peerMap: map[string]*peerInfo{},
uncooperativePeersMap: map[string]*peerInfo{},
} }
logger.Info("constructing consensus engine") logger.Info("constructing consensus engine")

View File

@ -892,6 +892,10 @@ func (e *CeremonyDataClockConsensusEngine) collect(
"could not establish direct channel", "could not establish direct channel",
zap.Error(err), zap.Error(err),
) )
e.peerMapMx.Lock()
e.uncooperativePeersMap[string(peerId)] = e.peerMap[string(peerId)]
delete(e.peerMap, string(peerId))
e.peerMapMx.Unlock()
} else { } else {
from := latest.FrameNumber from := latest.FrameNumber
if from == 0 { if from == 0 {