mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-27 05:17:27 +08:00
qol: additional logging for diagnostics, also testnet/devnet handling for confirmations
This commit is contained in:
parent
f59eb4ba0a
commit
866f08ccf8
@ -3,6 +3,7 @@ package provers
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -1437,6 +1438,7 @@ func (r *ProverRegistry) processProverChange(
|
||||
|
||||
// Find the prover this allocation belongs to
|
||||
if proverInfo, exists := r.proverCache[string(proverRef[32:])]; exists {
|
||||
found := false
|
||||
for i, allocation := range proverInfo.Allocations {
|
||||
if bytes.Equal(allocation.ConfirmationFilter, confirmationFilter) {
|
||||
proverInfo.Allocations[i].Status = mappedStatus
|
||||
@ -1456,26 +1458,30 @@ func (r *ProverRegistry) processProverChange(
|
||||
leaveRejectFrameNumber
|
||||
proverInfo.Allocations[i].LastActiveFrameNumber =
|
||||
lastActiveFrameNumber
|
||||
found = true
|
||||
}
|
||||
}
|
||||
proverInfo.Allocations = append(
|
||||
proverInfo.Allocations,
|
||||
consensus.ProverAllocationInfo{
|
||||
Status: mappedStatus,
|
||||
ConfirmationFilter: confirmationFilter,
|
||||
RejectionFilter: rejectionFilter,
|
||||
JoinFrameNumber: joinFrameNumber,
|
||||
LeaveFrameNumber: leaveFrameNumber,
|
||||
PauseFrameNumber: pauseFrameNumber,
|
||||
ResumeFrameNumber: resumeFrameNumber,
|
||||
KickFrameNumber: kickFrameNumber,
|
||||
JoinConfirmFrameNumber: joinConfirmFrameNumber,
|
||||
JoinRejectFrameNumber: joinRejectFrameNumber,
|
||||
LeaveConfirmFrameNumber: leaveConfirmFrameNumber,
|
||||
LeaveRejectFrameNumber: leaveRejectFrameNumber,
|
||||
LastActiveFrameNumber: lastActiveFrameNumber,
|
||||
},
|
||||
)
|
||||
|
||||
if !found {
|
||||
proverInfo.Allocations = append(
|
||||
proverInfo.Allocations,
|
||||
consensus.ProverAllocationInfo{
|
||||
Status: mappedStatus,
|
||||
ConfirmationFilter: confirmationFilter,
|
||||
RejectionFilter: rejectionFilter,
|
||||
JoinFrameNumber: joinFrameNumber,
|
||||
LeaveFrameNumber: leaveFrameNumber,
|
||||
PauseFrameNumber: pauseFrameNumber,
|
||||
ResumeFrameNumber: resumeFrameNumber,
|
||||
KickFrameNumber: kickFrameNumber,
|
||||
JoinConfirmFrameNumber: joinConfirmFrameNumber,
|
||||
JoinRejectFrameNumber: joinRejectFrameNumber,
|
||||
LeaveConfirmFrameNumber: leaveConfirmFrameNumber,
|
||||
LeaveRejectFrameNumber: leaveRejectFrameNumber,
|
||||
LastActiveFrameNumber: lastActiveFrameNumber,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Update tries based on allocation status
|
||||
if mappedStatus == consensus.ProverStatusActive &&
|
||||
@ -1721,6 +1727,12 @@ func (r *ProverRegistry) GetAllActiveAppShardProvers() (
|
||||
// Check if this prover has any active allocations (app shard provers)
|
||||
hasActiveAllocation := false
|
||||
for _, allocation := range proverInfo.Allocations {
|
||||
r.logger.Debug(
|
||||
"checking allocation status",
|
||||
zap.String("address", hex.EncodeToString(proverInfo.Address)),
|
||||
zap.String("filter", hex.EncodeToString(allocation.ConfirmationFilter)),
|
||||
zap.Uint32("status", uint32(allocation.Status)),
|
||||
)
|
||||
if allocation.Status == consensus.ProverStatusActive &&
|
||||
len(allocation.ConfirmationFilter) > 0 {
|
||||
hasActiveAllocation = true
|
||||
@ -1730,6 +1742,10 @@ func (r *ProverRegistry) GetAllActiveAppShardProvers() (
|
||||
|
||||
// Only include provers with active allocations
|
||||
if hasActiveAllocation {
|
||||
r.logger.Debug(
|
||||
"copying prover info for status",
|
||||
zap.String("address", hex.EncodeToString(proverInfo.Address)),
|
||||
)
|
||||
// Make a copy to avoid external modification
|
||||
proverCopy := &consensus.ProverInfo{
|
||||
PublicKey: make([]byte, len(proverInfo.PublicKey)),
|
||||
@ -1750,6 +1766,14 @@ func (r *ProverRegistry) GetAllActiveAppShardProvers() (
|
||||
|
||||
// Copy allocations
|
||||
for i, allocation := range proverInfo.Allocations {
|
||||
r.logger.Debug(
|
||||
"copying prover allocation for status",
|
||||
zap.String("address", hex.EncodeToString(proverInfo.Address)),
|
||||
zap.String(
|
||||
"filter",
|
||||
hex.EncodeToString(allocation.ConfirmationFilter),
|
||||
),
|
||||
)
|
||||
proverCopy.Allocations[i] = consensus.ProverAllocationInfo{
|
||||
Status: allocation.Status,
|
||||
ConfirmationFilter: make(
|
||||
|
||||
@ -485,7 +485,7 @@ func (p *ProverConfirm) Verify(frameNumber uint64) (bool, error) {
|
||||
joinFrame := binary.BigEndian.Uint64(joinFrameBytes)
|
||||
|
||||
// Check timing constraints
|
||||
if joinFrame < 252840 {
|
||||
if joinFrame < 252840 && joinFrame >= 244100 {
|
||||
if frameNumber < 252840 {
|
||||
// If joined before frame 252840, cannot confirm until frame 252840
|
||||
return false, errors.Wrap(
|
||||
@ -503,8 +503,10 @@ func (p *ProverConfirm) Verify(frameNumber uint64) (bool, error) {
|
||||
}
|
||||
|
||||
// For joins before 252840, once we reach frame 252840, they can confirm
|
||||
// immediately, for joins after 252840, normal 360 frame wait applies
|
||||
if joinFrame >= 252480 {
|
||||
// immediately, for joins after 252840, normal 360 frame wait applies.
|
||||
// If the join frame precedes the genesis frame (e.g. not mainnet), we
|
||||
// ignore the topic altogether
|
||||
if joinFrame >= 252480 || joinFrame <= 244100 {
|
||||
framesSinceJoin := frameNumber - joinFrame
|
||||
if framesSinceJoin < 360 {
|
||||
return false, errors.Wrap(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user