From 11a357518a135cb893d5ba1b15e00db8b76ef0d8 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Sun, 20 Oct 2024 23:45:16 -0500 Subject: [PATCH] fix: announce peer based on leading frame, not initial frame; fix: looping bug --- node/consensus/data/consensus_frames.go | 4 ++-- node/consensus/data/data_clock_consensus_engine.go | 3 ++- node/consensus/time/data_time_reel.go | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/node/consensus/data/consensus_frames.go b/node/consensus/data/consensus_frames.go index 60d303e..969145d 100644 --- a/node/consensus/data/consensus_frames.go +++ b/node/consensus/data/consensus_frames.go @@ -302,11 +302,11 @@ func (e *DataClockConsensusEngine) sync( } func (e *DataClockConsensusEngine) collect( - currentFramePublished *protobufs.ClockFrame, + enqueuedFrame *protobufs.ClockFrame, ) (*protobufs.ClockFrame, error) { e.logger.Info("collecting vdf proofs") - latest := currentFramePublished + latest := enqueuedFrame for { peerId, maxFrame, err := e.GetMostAheadPeer(latest.FrameNumber) diff --git a/node/consensus/data/data_clock_consensus_engine.go b/node/consensus/data/data_clock_consensus_engine.go index 9ae4f65..f79ea6a 100644 --- a/node/consensus/data/data_clock_consensus_engine.go +++ b/node/consensus/data/data_clock_consensus_engine.go @@ -330,7 +330,8 @@ func (e *DataClockConsensusEngine) Start() <-chan error { panic(err) } - if frame.FrameNumber >= nextFrame.FrameNumber || frame.FrameNumber == 0 { + if frame.FrameNumber >= nextFrame.FrameNumber || + nextFrame.FrameNumber == 0 { time.Sleep(30 * time.Second) continue } diff --git a/node/consensus/time/data_time_reel.go b/node/consensus/time/data_time_reel.go index 7b0cb0a..6324a11 100644 --- a/node/consensus/time/data_time_reel.go +++ b/node/consensus/time/data_time_reel.go @@ -606,7 +606,10 @@ func (d *DataTimeReel) setHead(frame *protobufs.ClockFrame, distance *big.Int) { d.headDistance = distance go func() { - d.newFrameCh <- frame + select { + case d.newFrameCh <- frame: + default: + } }() } @@ -906,7 +909,10 @@ func (d *DataTimeReel) forkChoice( ) go func() { - d.newFrameCh <- frame + select { + case d.newFrameCh <- frame: + default: + } }() }