mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-24 15:45:18 +00:00
qol: small fix-ups to make stuck frame nodes move faster (#153)
This commit is contained in:
parent
0e089d5899
commit
52a197368e
@ -15,13 +15,6 @@ import (
|
||||
func (e *CeremonyDataClockConsensusEngine) handleMessage(
|
||||
message *pb.Message,
|
||||
) error {
|
||||
e.logger.Debug(
|
||||
"received message",
|
||||
zap.Binary("data", message.Data),
|
||||
zap.Binary("from", message.From),
|
||||
zap.Binary("signature", message.Signature),
|
||||
)
|
||||
|
||||
go func() {
|
||||
e.messageProcessorCh <- message
|
||||
}()
|
||||
|
@ -170,12 +170,6 @@ func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer(
|
||||
if v.maxFrame > max &&
|
||||
v.timestamp > config.GetMinimumVersionCutoff().UnixMilli() &&
|
||||
bytes.Compare(v.version, config.GetMinimumVersion()) >= 0 && !ok {
|
||||
manifest := e.peerInfoManager.GetPeerInfo(v.peerId)
|
||||
if manifest == nil || manifest.Bandwidth == 0 {
|
||||
e.logger.Debug("peer manifest not found or bandwidth zero")
|
||||
continue
|
||||
}
|
||||
|
||||
peer = v.peerId
|
||||
max = v.maxFrame
|
||||
}
|
||||
@ -274,11 +268,9 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
if err != nil {
|
||||
e.logger.Info("no peers available for sync, waiting")
|
||||
time.Sleep(5 * time.Second)
|
||||
} else if maxFrame-2 > latest.FrameNumber {
|
||||
} else if maxFrame > latest.FrameNumber {
|
||||
latest, err = e.sync(latest, maxFrame, peerId)
|
||||
if err != nil {
|
||||
time.Sleep(30 * time.Second)
|
||||
} else {
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -291,6 +291,10 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFrameData(
|
||||
return errors.Wrap(err, "handle clock frame data")
|
||||
}
|
||||
|
||||
if e.latestFrameReceived > frame.FrameNumber {
|
||||
return nil
|
||||
}
|
||||
|
||||
addr, err := poseidon.HashBytes(
|
||||
frame.GetPublicKeySignatureEd448().PublicKey.KeyValue,
|
||||
)
|
||||
@ -343,6 +347,6 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFrameData(
|
||||
}
|
||||
}()
|
||||
}
|
||||
e.dataTimeReel.Insert(frame, isSync)
|
||||
e.dataTimeReel.Insert(frame, e.latestFrameReceived < frame.FrameNumber)
|
||||
return nil
|
||||
}
|
||||
|
@ -164,6 +164,19 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
|
||||
for {
|
||||
select {
|
||||
case newFrame := <-e.frameValidationCh:
|
||||
head, err := e.masterTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if head.FrameNumber > newFrame.FrameNumber || newFrame.FrameNumber-head.FrameNumber > 128 {
|
||||
e.logger.Debug(
|
||||
"frame out of range, ignoring",
|
||||
zap.Uint64("number", newFrame.FrameNumber),
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := e.frameProver.VerifyMasterClockFrame(newFrame); err != nil {
|
||||
e.logger.Error("could not verify clock frame", zap.Error(err))
|
||||
continue
|
||||
|
@ -252,6 +252,7 @@ func (m *MasterTimeReel) processPending() {
|
||||
for pending, ok := m.pending[m.head.FrameNumber+1]; ok; pending,
|
||||
ok = m.pending[m.head.FrameNumber+1] {
|
||||
|
||||
prev := m.head
|
||||
for _, frame := range pending {
|
||||
frame := frame
|
||||
parent := new(big.Int).SetBytes(frame.ParentSelector)
|
||||
@ -295,7 +296,11 @@ func (m *MasterTimeReel) processPending() {
|
||||
break
|
||||
}
|
||||
|
||||
delete(m.pending, m.head.FrameNumber+1)
|
||||
if m.head.FrameNumber != prev.FrameNumber {
|
||||
delete(m.pending, m.head.FrameNumber)
|
||||
} else {
|
||||
delete(m.pending, m.head.FrameNumber+1)
|
||||
}
|
||||
}
|
||||
deletes := []uint64{}
|
||||
for number := range m.pending {
|
||||
|
Loading…
Reference in New Issue
Block a user