From 948ba5d4faa7471af3f527cf8d76f5ef16b0cd01 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 3 Sep 2023 13:17:36 -0400 Subject: [PATCH 1/3] Improve state sync logging --- snow/engine/snowman/syncer/state_syncer.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/snow/engine/snowman/syncer/state_syncer.go b/snow/engine/snowman/syncer/state_syncer.go index 67d29d43250c..b2e5b2459d56 100644 --- a/snow/engine/snowman/syncer/state_syncer.go +++ b/snow/engine/snowman/syncer/state_syncer.go @@ -234,6 +234,11 @@ func (ss *stateSyncer) AcceptedStateSummary(ctx context.Context, nodeID ids.Node ss.pendingVoters.Remove(nodeID) weight := ss.StateSyncBeacons.GetWeight(nodeID) + ss.Ctx.Log.Debug("adding weight to summaries", + zap.Stringer("nodeID", nodeID), + zap.Stringers("summaryIDs", summaryIDs), + zap.Uint64("weight", weight), + ) for _, summaryID := range summaryIDs { ws, ok := ss.weightedSummaries[summaryID] if !ok { @@ -248,12 +253,21 @@ func (ss *stateSyncer) AcceptedStateSummary(ctx context.Context, nodeID ids.Node newWeight, err := math.Add64(weight, ws.weight) if err != nil { ss.Ctx.Log.Error("failed to calculate the Accepted votes", + zap.Stringer("summaryID", summaryID), + zap.Uint64("height", ws.summary.Height()), zap.Uint64("weight", weight), zap.Uint64("previousWeight", ws.weight), zap.Error(err), ) newWeight = stdmath.MaxUint64 } + + ss.Ctx.Log.Debug("adding weight to summary", + zap.Stringer("summaryID", summaryID), + zap.Uint64("height", ws.summary.Height()), + zap.Uint64("previousWeight", ws.weight), + zap.Uint64("newWeight", newWeight), + ) ws.weight = newWeight } @@ -270,6 +284,8 @@ func (ss *stateSyncer) AcceptedStateSummary(ctx context.Context, nodeID ids.Node if ws.weight < ss.Alpha { ss.Ctx.Log.Debug("removing summary", zap.String("reason", "insufficient weight"), + zap.Stringer("summaryID", summaryID), + zap.Uint64("height", ws.summary.Height()), zap.Uint64("currentWeight", ws.weight), zap.Uint64("requiredWeight", ss.Alpha), ) From f606a610c2c276e902915687e2bd492ca44ceb29 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 5 Sep 2023 17:54:57 -0400 Subject: [PATCH 2/3] nits --- snow/engine/snowman/syncer/state_syncer.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/snow/engine/snowman/syncer/state_syncer.go b/snow/engine/snowman/syncer/state_syncer.go index b2e5b2459d56..8716cf1033c4 100644 --- a/snow/engine/snowman/syncer/state_syncer.go +++ b/snow/engine/snowman/syncer/state_syncer.go @@ -233,36 +233,38 @@ func (ss *stateSyncer) AcceptedStateSummary(ctx context.Context, nodeID ids.Node // Mark that we received a response from [nodeID] ss.pendingVoters.Remove(nodeID) - weight := ss.StateSyncBeacons.GetWeight(nodeID) + nodeWeight := ss.StateSyncBeacons.GetWeight(nodeID) ss.Ctx.Log.Debug("adding weight to summaries", zap.Stringer("nodeID", nodeID), zap.Stringers("summaryIDs", summaryIDs), - zap.Uint64("weight", weight), + zap.Uint64("nodeWeight", nodeWeight), ) for _, summaryID := range summaryIDs { ws, ok := ss.weightedSummaries[summaryID] if !ok { ss.Ctx.Log.Debug("skipping summary", - zap.String("reason", "received a vote from validator for unknown summary"), + zap.String("reason", "received a vote for an unknown summary"), zap.Stringer("nodeID", nodeID), zap.Stringer("summaryID", summaryID), ) continue } - newWeight, err := math.Add64(weight, ws.weight) + newWeight, err := math.Add64(nodeWeight, ws.weight) if err != nil { - ss.Ctx.Log.Error("failed to calculate the Accepted votes", + ss.Ctx.Log.Error("failed to calculate new summary weight", + zap.Stringer("nodeID", nodeID), zap.Stringer("summaryID", summaryID), zap.Uint64("height", ws.summary.Height()), - zap.Uint64("weight", weight), + zap.Uint64("nodeWeight", nodeWeight), zap.Uint64("previousWeight", ws.weight), zap.Error(err), ) newWeight = stdmath.MaxUint64 } - ss.Ctx.Log.Debug("adding weight to summary", + ss.Ctx.Log.Verbo("updating summary weight", + zap.Stringer("nodeID", nodeID), zap.Stringer("summaryID", summaryID), zap.Uint64("height", ws.summary.Height()), zap.Uint64("previousWeight", ws.weight), From 50e1a2a49795efeb40cdcd3402f122bfe23f6a00 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 5 Sep 2023 17:56:20 -0400 Subject: [PATCH 3/3] nit --- snow/engine/snowman/syncer/state_syncer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snow/engine/snowman/syncer/state_syncer.go b/snow/engine/snowman/syncer/state_syncer.go index 8716cf1033c4..1f7fc092a293 100644 --- a/snow/engine/snowman/syncer/state_syncer.go +++ b/snow/engine/snowman/syncer/state_syncer.go @@ -243,7 +243,7 @@ func (ss *stateSyncer) AcceptedStateSummary(ctx context.Context, nodeID ids.Node ws, ok := ss.weightedSummaries[summaryID] if !ok { ss.Ctx.Log.Debug("skipping summary", - zap.String("reason", "received a vote for an unknown summary"), + zap.String("reason", "unknown summary"), zap.Stringer("nodeID", nodeID), zap.Stringer("summaryID", summaryID), )