From 128ffc020cf0af609f7afdee0e365779d4cd3809 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Sat, 16 Mar 2024 04:29:20 -0500 Subject: [PATCH] fix: handle total distance comparison bug, reduce log noise --- .../ceremony/ceremony_data_clock_consensus_engine.go | 9 +++++++-- node/consensus/ceremony/consensus_frames.go | 6 +----- .../intrinsics/ceremony/ceremony_execution_engine.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go index 2632472..033f46a 100644 --- a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go +++ b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go @@ -451,8 +451,13 @@ func (e *CeremonyDataClockConsensusEngine) runLoop() { panic(err) } + if latestFrame != nil && + dataFrame.FrameNumber > latestFrame.FrameNumber { + latestFrame = dataFrame + } + go func() { - e.frameChan <- dataFrame + e.frameChan <- latestFrame }() if bytes.Equal( @@ -460,7 +465,7 @@ func (e *CeremonyDataClockConsensusEngine) runLoop() { e.provingKeyAddress, ) { var nextFrame *protobufs.ClockFrame - if nextFrame, err = e.prove(dataFrame); err != nil { + if nextFrame, err = e.prove(latestFrame); err != nil { e.logger.Error("could not prove", zap.Error(err)) e.state = consensus.EngineStateCollecting continue diff --git a/node/consensus/ceremony/consensus_frames.go b/node/consensus/ceremony/consensus_frames.go index 9193660..1245c7f 100644 --- a/node/consensus/ceremony/consensus_frames.go +++ b/node/consensus/ceremony/consensus_frames.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "io" - "math/big" "time" "source.quilibrium.com/quilibrium/monorepo/node/config" @@ -167,10 +166,7 @@ func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer() ( _, ok := e.uncooperativePeersMap[string(v.peerId)] if v.maxFrame > max && v.timestamp > config.GetMinimumVersionCutoff().UnixMilli() && - bytes.Compare(v.version, config.GetMinimumVersion()) >= 0 && - new(big.Int).SetBytes( - v.totalDistance, - ).Cmp(e.dataTimeReel.GetTotalDistance()) < 0 && !ok { + bytes.Compare(v.version, config.GetMinimumVersion()) >= 0 && !ok { peer = v.peerId max = v.maxFrame } diff --git a/node/execution/intrinsics/ceremony/ceremony_execution_engine.go b/node/execution/intrinsics/ceremony/ceremony_execution_engine.go index d4913d0..2fa14f7 100644 --- a/node/execution/intrinsics/ceremony/ceremony_execution_engine.go +++ b/node/execution/intrinsics/ceremony/ceremony_execution_engine.go @@ -472,7 +472,7 @@ func (e *CeremonyExecutionEngine) ProcessMessage( message *protobufs.Message, ) ([]*protobufs.Message, error) { if bytes.Equal(address, e.GetSupportedApplications()[0].Address) { - e.logger.Info("processing execution message") + e.logger.Debug("processing execution message") any := &anypb.Any{} if err := proto.Unmarshal(message.Payload, any); err != nil { return nil, errors.Wrap(err, "process message")