This commit is contained in:
Cassandra Heart 2024-01-13 00:21:16 -06:00 committed by GitHub
parent 916a1514f1
commit 196588cbe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 151 additions and 12 deletions

View File

@ -818,11 +818,11 @@ func logoVersion(width int) string {
out += " ####################################### ########\n"
out += " ############################# ##\n"
out += " \n"
out += " Quilibrium Node - v1.2.2 Dawn\n"
out += " Quilibrium Node - v1.2.3 Dawn\n"
out += " \n"
out += " DB Console\n"
} else {
out = "Quilibrium Node - v1.2.2 Dawn - DB Console\n"
out = "Quilibrium Node - v1.2.3 Dawn - DB Console\n"
}
return out
}

View File

@ -213,6 +213,17 @@ func (e *CeremonyDataClockConsensusEngine) Start() <-chan error {
panic(err)
}
candidateLatestFrame, err := e.clockStore.GetLatestCandidateDataClockFrame(
e.filter,
)
if err != nil && !errors.Is(err, store.ErrNotFound) {
panic(err)
}
if candidateLatestFrame != nil {
latestFrame = candidateLatestFrame
}
if latestFrame != nil {
e.setFrame(latestFrame)
} else {

View File

@ -972,7 +972,7 @@ func (e *CeremonyDataClockConsensusEngine) sync(
grpc.MaxCallRecvMsgSize(600*1024*1024),
)
if err != nil {
e.logger.Error(
e.logger.Debug(
"received error from peer",
zap.Error(err),
)
@ -1052,7 +1052,7 @@ func (e *CeremonyDataClockConsensusEngine) sync(
}
}
if err != nil && err != io.EOF && !errors.Is(err, ErrNoNewFrames) {
e.logger.Error("error while receiving sync", zap.Error(err))
e.logger.Debug("error while receiving sync", zap.Error(err))
if err := cc.Close(); err != nil {
e.logger.Error("error while closing connection", zap.Error(err))

View File

@ -51,13 +51,13 @@ type DataConsensusEngine interface {
}
func GetMinimumVersionCutoff() time.Time {
return time.Date(2024, time.January, 3, 7, 0, 0, 0, time.UTC)
return time.Date(2024, time.January, 14, 7, 0, 0, 0, time.UTC)
}
func GetMinimumVersion() []byte {
return []byte{0x01, 0x02, 0x00}
return []byte{0x01, 0x02, 0x03}
}
func GetVersion() []byte {
return []byte{0x01, 0x02, 0x02}
return []byte{0x01, 0x02, 0x03}
}

View File

@ -646,8 +646,33 @@ func MaterializeApplicationFromFrame(
roundCount--
}
stateCount := uint64(0)
setCount := false
if len(inProgress.DroppedParticipantAttestations) > 0 {
stateCount = frame.FrameNumber -
inProgress.DroppedParticipantAttestations[len(inProgress.DroppedParticipantAttestations)-1].LastSeenFrame
setCount = true
}
if len(inProgress.LatestSeenProverAttestations) > 0 {
seenCount := frame.FrameNumber -
inProgress.LatestSeenProverAttestations[len(inProgress.LatestSeenProverAttestations)-1].LastSeenFrame
if !setCount || seenCount < stateCount {
stateCount = seenCount
}
}
if len(inProgress.ActiveParticipants) > 0 {
lastStateCount := frame.FrameNumber -
inProgress.ActiveParticipants[len(inProgress.ActiveParticipants)-1].FrameNumber
if !setCount || (lastStateCount < stateCount && lastStateCount > 20) {
stateCount = lastStateCount - 20
}
}
return &CeremonyApplication{
StateCount: 0,
StateCount: stateCount,
RoundCount: uint64(roundCount),
LobbyState: CEREMONY_APPLICATION_STATE_IN_PROGRESS,
NextRoundPreferredParticipants: inProgress.NextRoundParticipants,
@ -667,8 +692,33 @@ func MaterializeApplicationFromFrame(
)
}
stateCount := uint64(0)
setCount := false
if len(finalizing.DroppedParticipantAttestations) > 0 {
stateCount = frame.FrameNumber -
finalizing.DroppedParticipantAttestations[len(finalizing.DroppedParticipantAttestations)-1].LastSeenFrame
setCount = true
}
if len(finalizing.LatestSeenProverAttestations) > 0 {
seenCount := frame.FrameNumber -
finalizing.LatestSeenProverAttestations[len(finalizing.LatestSeenProverAttestations)-1].LastSeenFrame
if !setCount || seenCount < stateCount {
stateCount = seenCount
}
}
if len(finalizing.ActiveParticipants) > 0 {
lastStateCount := frame.FrameNumber -
finalizing.ActiveParticipants[len(finalizing.ActiveParticipants)-1].FrameNumber
if !setCount || (lastStateCount < stateCount && lastStateCount > 200) {
stateCount = lastStateCount - 200
}
}
return &CeremonyApplication{
StateCount: 0,
StateCount: stateCount,
RoundCount: 0,
LobbyState: CEREMONY_APPLICATION_STATE_FINALIZING,
ActiveParticipants: finalizing.ActiveParticipants,

View File

@ -398,6 +398,7 @@ func (e *CeremonyExecutionEngine) RunWorker() {
),
zap.Bool("in_round", inRound),
zap.Uint64("current_sub_round", app.RoundCount),
zap.Uint64("stale_state_count", app.StateCount),
)
shouldConnect := false

View File

@ -249,5 +249,5 @@ func printLogo() {
func printVersion() {
fmt.Println(" ")
fmt.Println(" Quilibrium Node - v1.2.2 Dawn")
fmt.Println(" Quilibrium Node - v1.2.3 Dawn")
}

View File

@ -328,7 +328,7 @@ func initDHT(
go func() {
defer wg.Done()
if err := h.Connect(ctx, *peerinfo); err != nil {
logger.Warn("error while connecting to dht peer", zap.Error(err))
logger.Debug("error while connecting to dht peer", zap.Error(err))
}
logger.Info(
"connected to peer",
@ -517,7 +517,7 @@ func discoverPeers(
logger.Info("found peer", zap.String("peer_id", peer.ID.Pretty()))
err := h.Connect(ctx, peer)
if err != nil {
logger.Warn(
logger.Debug(
"error while connecting to blossomsub peer",
zap.String("peer_id", peer.ID.Pretty()),
zap.Error(err),

View File

@ -34,6 +34,9 @@ type ClockStore interface {
filter []byte,
proverTrie *tries.RollingFrecencyCritbitTrie,
) (*protobufs.ClockFrame, error)
GetLatestCandidateDataClockFrame(
filter []byte,
) (*protobufs.ClockFrame, error)
GetEarliestDataClockFrame(filter []byte) (*protobufs.ClockFrame, error)
GetDataClockFrame(
filter []byte,
@ -324,6 +327,8 @@ const CLOCK_MASTER_FRAME_INDEX_PARENT = 0x30 | CLOCK_MASTER_FRAME_DATA
const CLOCK_DATA_FRAME_INDEX_EARLIEST = 0x10 | CLOCK_DATA_FRAME_DATA
const CLOCK_DATA_FRAME_INDEX_LATEST = 0x20 | CLOCK_DATA_FRAME_DATA
const CLOCK_DATA_FRAME_INDEX_PARENT = 0x30 | CLOCK_DATA_FRAME_DATA
const CLOCK_DATA_FRAME_CANDIDATE_INDEX_LATEST = 0x20 |
CLOCK_DATA_FRAME_CANDIDATE_DATA
//
// DB Keys
@ -384,6 +389,10 @@ func clockDataLatestIndex(filter []byte) []byte {
return clockLatestIndex(filter, CLOCK_DATA_FRAME_INDEX_LATEST)
}
func clockDataCandidateLatestIndex(filter []byte) []byte {
return clockLatestIndex(filter, CLOCK_DATA_FRAME_CANDIDATE_INDEX_LATEST)
}
func clockEarliestIndex(filter []byte, frameType byte) []byte {
key := []byte{CLOCK_FRAME, frameType}
key = append(key, filter...)
@ -801,6 +810,33 @@ func (p *PebbleClockStore) GetLatestDataClockFrame(
return frame, nil
}
func (p *PebbleClockStore) GetLatestCandidateDataClockFrame(
filter []byte,
) (*protobufs.ClockFrame, error) {
idxValue, closer, err := p.db.Get(clockDataCandidateLatestIndex(filter))
if err != nil {
if errors.Is(err, pebble.ErrNotFound) {
return nil, ErrNotFound
}
return nil, errors.Wrap(err, "get latest candidate data clock frame")
}
frameNumber := binary.BigEndian.Uint64(idxValue)
frames, err := p.GetCandidateDataClockFrames(filter, frameNumber)
if err != nil {
return nil, errors.Wrap(err, "get latest candidate data clock frame")
}
closer.Close()
if len(frames) == 0 {
return nil, ErrNotFound
}
return frames[0], nil
}
// GetLeadingCandidateDataClockFrame implements ClockStore.
func (p *PebbleClockStore) GetLeadingCandidateDataClockFrame(
filter []byte,
@ -907,6 +943,29 @@ func (p *PebbleClockStore) PutCandidateDataClockFrame(
return errors.Wrap(err, "put candidate data clock frame")
}
numberBytes, closer, err := p.db.Get(clockDataCandidateLatestIndex(frame.Filter))
if err != nil && !errors.Is(err, pebble.ErrNotFound) {
return errors.Wrap(err, "put candidate data clock frame")
}
existingNumber := uint64(0)
if numberBytes != nil {
existingNumber = binary.BigEndian.Uint64(numberBytes)
closer.Close()
}
if frame.FrameNumber > existingNumber {
frameNumberBytes := make([]byte, 8)
binary.BigEndian.PutUint64(frameNumberBytes, frame.FrameNumber)
if err = txn.Set(
clockDataCandidateLatestIndex(frame.Filter),
frameNumberBytes,
); err != nil {
return errors.Wrap(err, "put candidate data clock frame")
}
}
return nil
}
@ -1685,6 +1744,24 @@ func (p *PebbleClockStore) DeleteCandidateDataClockFrameRange(
return errors.Wrap(err, "delete candidate data clock frame range")
}
func (p *PebbleClockStore) DeleteDataClockFrameRange(
filter []byte,
fromFrameNumber uint64,
toFrameNumber uint64,
) error {
err := p.db.DeleteRange(
clockDataFrameKey(
filter,
fromFrameNumber,
),
clockDataFrameKey(
filter,
toFrameNumber,
),
)
return errors.Wrap(err, "delete data clock frame range")
}
func (p *PebbleClockStore) GetHighestCandidateDataClockFrame(
filter []byte,
) (*protobufs.ClockFrame, error) {