mirror of
				https://source.quilibrium.com/quilibrium/ceremonyclient.git
				synced 2025-11-04 05:57:33 +00:00 
			
		
		
		
	v1.4.9 (#131)
This commit is contained in:
		
							parent
							
								
									60afbb33b6
								
							
						
					
					
						commit
						3001611197
					
				@ -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],
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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))
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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 {
 | 
			
		||||
 | 
			
		||||
@ -136,7 +136,7 @@ func (e *MasterClockConsensusEngine) collect(
 | 
			
		||||
					break
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				e.masterTimeReel.Insert(frame)
 | 
			
		||||
				e.masterTimeReel.Insert(frame, false)
 | 
			
		||||
				latest = frame
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user