remove missing gap check

This commit is contained in:
Cassandra Heart 2026-01-27 02:35:22 -06:00
parent 4b1adde2e6
commit 5c97e8d619
No known key found for this signature in database
GPG Key ID: 371083BFA6C240AA

View File

@ -157,8 +157,6 @@ type GlobalConsensusEngine struct {
lastRejectFrame atomic.Uint64
proverRootVerifiedFrame atomic.Uint64
proverRootSynced atomic.Bool
lastMaterializedFrame atomic.Uint64
hasFrameGapSinceSync atomic.Bool
lastProposalFrameNumber atomic.Uint64
lastFrameMessageFrameNumber atomic.Uint64
@ -1632,19 +1630,6 @@ func (e *GlobalConsensusEngine) materialize(
var appliedCount atomic.Int64
var skippedCount atomic.Int64
// Check for frame gaps: if this frame is not contiguous with the last
// materialized frame, mark that we've had gaps since sync
lastMaterialized := e.lastMaterializedFrame.Load()
if lastMaterialized > 0 && frameNumber > lastMaterialized+1 {
e.logger.Info(
"frame gap detected",
zap.Uint64("last_materialized", lastMaterialized),
zap.Uint64("current_frame", frameNumber),
zap.Uint64("gap_size", frameNumber-lastMaterialized-1),
)
e.hasFrameGapSinceSync.Store(true)
}
_, err := e.hypergraph.Commit(frameNumber)
if err != nil {
e.logger.Error("error committing hypergraph", zap.Error(err))
@ -1657,8 +1642,6 @@ func (e *GlobalConsensusEngine) materialize(
// Check prover root BEFORE processing transactions. If there's a mismatch,
// we need to sync first, otherwise we'll apply transactions on top of
// divergent state and then sync will delete the newly added records.
// However, only sync if we've also had frame gaps since last successful
// sync - contiguous frames should not trigger sync even if root mismatches.
if len(expectedProverRoot) > 0 {
localProverRoot, localRootErr := e.computeLocalProverRoot(frameNumber)
if localRootErr != nil {
@ -1671,34 +1654,20 @@ func (e *GlobalConsensusEngine) materialize(
updatedProverRoot := localProverRoot
if localRootErr == nil && len(localProverRoot) > 0 {
hasGap := e.hasFrameGapSinceSync.Load()
rootMismatch := !bytes.Equal(localProverRoot, expectedProverRoot)
if rootMismatch {
if hasGap {
e.logger.Info(
"prover root mismatch with frame gap detected, syncing",
zap.Uint64("frame_number", frameNumber),
zap.String("expected_root", hex.EncodeToString(expectedProverRoot)),
zap.String("local_root", hex.EncodeToString(localProverRoot)),
)
// Perform blocking hypersync before continuing
result := e.performBlockingProverHypersync(
proposer,
expectedProverRoot,
)
if result != nil {
updatedProverRoot = result
}
// Reset gap tracking after sync
e.hasFrameGapSinceSync.Store(false)
} else {
e.logger.Debug(
"prover root mismatch but no frame gap, skipping sync",
zap.Uint64("frame_number", frameNumber),
zap.String("expected_root", hex.EncodeToString(expectedProverRoot)),
zap.String("local_root", hex.EncodeToString(localProverRoot)),
)
if !bytes.Equal(localProverRoot, expectedProverRoot) {
e.logger.Info(
"prover root mismatch detected before processing frame, syncing first",
zap.Uint64("frame_number", frameNumber),
zap.String("expected_root", hex.EncodeToString(expectedProverRoot)),
zap.String("local_root", hex.EncodeToString(localProverRoot)),
)
// Perform blocking hypersync before continuing
result := e.performBlockingProverHypersync(
proposer,
expectedProverRoot,
)
if result != nil {
updatedProverRoot = result
}
}
}
@ -1724,9 +1693,6 @@ func (e *GlobalConsensusEngine) materialize(
}
}
// Update last materialized frame
e.lastMaterializedFrame.Store(frameNumber)
var state state.State
state = hgstate.NewHypergraphState(e.hypergraph)
@ -1978,28 +1944,16 @@ func (e *GlobalConsensusEngine) verifyProverRoot(
}
if !bytes.Equal(localRoot, expected) {
hasGap := e.hasFrameGapSinceSync.Load()
e.logger.Warn(
"prover root mismatch",
zap.Uint64("frame_number", frameNumber),
zap.String("expected_root", hex.EncodeToString(expected)),
zap.String("local_root", hex.EncodeToString(localRoot)),
zap.String("proposer", hex.EncodeToString(proposer)),
zap.Bool("has_frame_gap", hasGap),
)
e.proverRootSynced.Store(false)
e.proverRootVerifiedFrame.Store(0)
// Only trigger sync if we've had frame gaps since last successful sync.
// Contiguous frames should not trigger sync even if root mismatches.
if hasGap {
e.triggerProverHypersync(proposer, expected)
} else {
e.logger.Debug(
"skipping sync trigger - no frame gap since last sync",
zap.Uint64("frame_number", frameNumber),
)
}
e.triggerProverHypersync(proposer, expected)
return false
}
@ -2038,8 +1992,6 @@ func (e *GlobalConsensusEngine) triggerProverHypersync(proposer []byte, expected
L2: intrinsics.GLOBAL_INTRINSIC_ADDRESS,
}
e.syncProvider.HyperSync(ctx, proposer, shardKey, nil, expectedRoot)
// Reset gap tracking after sync completes
e.hasFrameGapSinceSync.Store(false)
if err := e.proverRegistry.Refresh(); err != nil {
e.logger.Warn(
"failed to refresh prover registry after hypersync",