diff --git a/node/config/version.go b/node/config/version.go index 12d90ef..2f54454 100644 --- a/node/config/version.go +++ b/node/config/version.go @@ -14,9 +14,12 @@ func GetMinimumVersion() []byte { } func GetVersion() []byte { - return []byte{0x01, 0x04, 0x08} + return []byte{0x01, 0x04, 0x09} } func GetVersionString() string { - return fmt.Sprintf("%d.%d.%d", GetVersion()[0], GetVersion()[1], GetVersion()[2]) + return fmt.Sprintf( + "%d.%d.%d", + GetVersion()[0], GetVersion()[1], GetVersion()[2], + ) } diff --git a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go index 94a3fd5..070a042 100644 --- a/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go +++ b/node/consensus/ceremony/ceremony_data_clock_consensus_engine.go @@ -471,7 +471,7 @@ func (e *CeremonyDataClockConsensusEngine) runLoop() { e.frameProverTrie.FindNearest(e.provingKeyAddress).External.Key, e.provingKeyAddress, ) { - e.dataTimeReel.Insert(nextFrame) + e.dataTimeReel.Insert(nextFrame, false) if err = e.publishProof(nextFrame); err != nil { e.logger.Error("could not publish", zap.Error(err)) @@ -513,7 +513,7 @@ func (e *CeremonyDataClockConsensusEngine) runLoop() { e.frameProverTrie.FindNearest(e.provingKeyAddress).External.Key, e.provingKeyAddress, ) { - e.dataTimeReel.Insert(nextFrame) + e.dataTimeReel.Insert(nextFrame, false) if err = e.publishProof(nextFrame); err != nil { e.logger.Error("could not publish", zap.Error(err)) diff --git a/node/consensus/ceremony/consensus_frames.go b/node/consensus/ceremony/consensus_frames.go index dda317d..4d27245 100644 --- a/node/consensus/ceremony/consensus_frames.go +++ b/node/consensus/ceremony/consensus_frames.go @@ -445,6 +445,8 @@ func (e *CeremonyDataClockConsensusEngine) sync( e.logger.Error("error while closing connection", zap.Error(err)) } + e.dataTimeReel.Insert(latest, false) + return latest, nil } diff --git a/node/consensus/ceremony/message_handler.go b/node/consensus/ceremony/message_handler.go index 045a740..d46a834 100644 --- a/node/consensus/ceremony/message_handler.go +++ b/node/consensus/ceremony/message_handler.go @@ -331,6 +331,6 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFrameData( zap.Uint64("frame_number", frame.FrameNumber), ) - e.dataTimeReel.Insert(frame) + e.dataTimeReel.Insert(frame, isSync) return nil } diff --git a/node/consensus/master/broadcast_messaging.go b/node/consensus/master/broadcast_messaging.go index 1736b96..015a078 100644 --- a/node/consensus/master/broadcast_messaging.go +++ b/node/consensus/master/broadcast_messaging.go @@ -189,7 +189,7 @@ func (e *MasterClockConsensusEngine) publishProof( zap.Uint64("frame_number", frame.FrameNumber), ) - e.masterTimeReel.Insert(frame) + e.masterTimeReel.Insert(frame, false) peers, err := e.GetMostAheadPeers() if err != nil || len(peers) == 0 { diff --git a/node/consensus/master/consensus_frames.go b/node/consensus/master/consensus_frames.go index f5263f6..7f2926b 100644 --- a/node/consensus/master/consensus_frames.go +++ b/node/consensus/master/consensus_frames.go @@ -136,7 +136,7 @@ func (e *MasterClockConsensusEngine) collect( break } - e.masterTimeReel.Insert(frame) + e.masterTimeReel.Insert(frame, false) latest = frame } } diff --git a/node/consensus/master/master_clock_consensus_engine.go b/node/consensus/master/master_clock_consensus_engine.go index e6c4082..5bd6c7a 100644 --- a/node/consensus/master/master_clock_consensus_engine.go +++ b/node/consensus/master/master_clock_consensus_engine.go @@ -167,7 +167,7 @@ func (e *MasterClockConsensusEngine) Start() <-chan error { continue } - e.masterTimeReel.Insert(newFrame) + e.masterTimeReel.Insert(newFrame, false) case peerId := <-e.bandwidthTestCh: e.performBandwidthTest(peerId) } diff --git a/node/consensus/time/data_time_reel.go b/node/consensus/time/data_time_reel.go index 869c6ff..a8178e5 100644 --- a/node/consensus/time/data_time_reel.go +++ b/node/consensus/time/data_time_reel.go @@ -152,7 +152,7 @@ func (d *DataTimeReel) Head() (*protobufs.ClockFrame, error) { // Insert enqueues a structurally valid frame into the time reel. If the frame // is the next one in sequence, it advances the reel head forward and emits a // new frame on the new frame channel. -func (d *DataTimeReel) Insert(frame *protobufs.ClockFrame) error { +func (d *DataTimeReel) Insert(frame *protobufs.ClockFrame, isSync bool) error { if !d.running { return nil } @@ -179,13 +179,15 @@ func (d *DataTimeReel) Insert(frame *protobufs.ClockFrame) error { d.storePending(selector, parent, distance, frame) - go func() { - d.frames <- &pendingFrame{ - selector: selector, - parentSelector: parent, - frameNumber: frame.FrameNumber, - } - }() + if !isSync { + go func() { + d.frames <- &pendingFrame{ + selector: selector, + parentSelector: parent, + frameNumber: frame.FrameNumber, + } + }() + } return nil } diff --git a/node/consensus/time/data_time_reel_test.go b/node/consensus/time/data_time_reel_test.go index 91efad7..6552d1b 100644 --- a/node/consensus/time/data_time_reel_test.go +++ b/node/consensus/time/data_time_reel_test.go @@ -155,7 +155,7 @@ func TestDataTimeReel(t *testing.T) { frame, err = prover.ProveMasterClockFrame(frame, i+1, 10) assert.NoError(t, err) - err := m.Insert(frame) + err := m.Insert(frame, false) assert.NoError(t, err) } @@ -249,7 +249,7 @@ func TestDataTimeReel(t *testing.T) { i+1, 10, ) - d.Insert(frame) + d.Insert(frame, false) } // 2. z-dist optimal, out of order – proof submission is strictly master-frame @@ -278,7 +278,7 @@ func TestDataTimeReel(t *testing.T) { } for i := 9; i >= 0; i-- { - err := d.Insert(insertFrames[i]) + err := d.Insert(insertFrames[i], false) assert.NoError(t, err) } @@ -303,7 +303,7 @@ func TestDataTimeReel(t *testing.T) { i+1, 10, ) - d.Insert(frame) + d.Insert(frame, false) } masterSelector, err := frames[25].GetSelector() @@ -349,7 +349,7 @@ func TestDataTimeReel(t *testing.T) { } for i := 4; i >= 0; i-- { - err := d.Insert(insertFrames[i]) + err := d.Insert(insertFrames[i], false) assert.NoError(t, err) } @@ -402,7 +402,7 @@ func TestDataTimeReel(t *testing.T) { } for i := 9; i >= 0; i-- { - err := d.Insert(conflictFrames[i]) + err := d.Insert(conflictFrames[i], false) // force linear ordering gotime.Sleep(1 * gotime.Second) assert.NoError(t, err) @@ -410,7 +410,7 @@ func TestDataTimeReel(t *testing.T) { // Someone is honest, but running backwards: for i := 9; i >= 0; i-- { - err := d.Insert(insertFrames[i]) + err := d.Insert(insertFrames[i], false) gotime.Sleep(1 * gotime.Second) assert.NoError(t, err) } diff --git a/node/consensus/time/master_time_reel.go b/node/consensus/time/master_time_reel.go index 28bbc75..0c2be08 100644 --- a/node/consensus/time/master_time_reel.go +++ b/node/consensus/time/master_time_reel.go @@ -114,7 +114,10 @@ func (m *MasterTimeReel) Head() (*protobufs.ClockFrame, error) { // Insert enqueues a structurally valid frame into the time reel. If the frame // is the next one in sequence, it advances the reel head forward and emits a // new frame on the new frame channel. -func (m *MasterTimeReel) Insert(frame *protobufs.ClockFrame) error { +func (m *MasterTimeReel) Insert( + frame *protobufs.ClockFrame, + isSync bool, +) error { go func() { m.frames <- frame }() diff --git a/node/consensus/time/master_time_reel_test.go b/node/consensus/time/master_time_reel_test.go index 142538f..cb4f555 100644 --- a/node/consensus/time/master_time_reel_test.go +++ b/node/consensus/time/master_time_reel_test.go @@ -54,7 +54,7 @@ func TestMasterTimeReel(t *testing.T) { frame, err = prover.ProveMasterClockFrame(frame, i+1, 10) assert.NoError(t, err) - err := m.Insert(frame) + err := m.Insert(frame, false) assert.NoError(t, err) } @@ -69,7 +69,7 @@ func TestMasterTimeReel(t *testing.T) { } for i := 99; i >= 0; i-- { - err := m.Insert(insertFrames[i]) + err := m.Insert(insertFrames[i], false) assert.NoError(t, err) } diff --git a/node/consensus/time/time_reel.go b/node/consensus/time/time_reel.go index e18557d..3f60338 100644 --- a/node/consensus/time/time_reel.go +++ b/node/consensus/time/time_reel.go @@ -7,7 +7,7 @@ import ( type TimeReel interface { Start() error Stop() - Insert(frame *protobufs.ClockFrame) error + Insert(frame *protobufs.ClockFrame, isSync bool) error Head() (*protobufs.ClockFrame, error) NewFrameCh() <-chan *protobufs.ClockFrame BadFrameCh() <-chan *protobufs.ClockFrame