Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit bc05f4a

Browse files
committed
Added debug logs when exporting/importing the account ledger and the performance stats
1 parent 51b758e commit bc05f4a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/protocol/engine/accounts/accountsledger/snapshot.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (m *Manager) Import(reader io.ReadSeeker) error {
2727
return ierrors.Wrapf(err, "unable to set account %s", accountData.ID)
2828
}
2929

30-
m.LogDebug("Imported account", "accountID", accountData.ID, "outputID", accountData.OutputID, "credits.value", accountData.Credits.Value, "credits.updateSlot", accountData.Credits.UpdateSlot)
30+
m.LogDebug("Imported account", "accountData", accountData)
3131

3232
return nil
3333
}); err != nil {
@@ -189,6 +189,8 @@ func (m *Manager) readSlotDiffs(reader io.ReadSeeker) error {
189189
accountDiff = model.NewAccountDiff()
190190
}
191191

192+
m.LogDebug("Imported account diff", "slot", slot, "accountID", accountID, "destroyed", destroyed, "accountDiff", accountDiff)
193+
192194
if err := diffStore.Store(accountID, accountDiff, destroyed); err != nil {
193195
return ierrors.Wrapf(err, "unable to store slot diff for accountID %s", accountID)
194196
}
@@ -250,6 +252,8 @@ func (m *Manager) writeSlotDiffs(writer io.WriteSeeker, targetSlot iotago.SlotIn
250252
}
251253
}
252254

255+
m.LogDebug("Exported account diff", "slot", slot, "accountID", accountID, "destroyed", destroyed, "accountDiff", accountDiff)
256+
253257
accountsInDiffCount++
254258

255259
return true

pkg/protocol/sybilprotection/sybilprotectionv1/performance/snapshot.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ func (t *Tracker) importPerformanceFactor(reader io.ReadSeeker) error {
9595
return ierrors.Wrapf(err, "unable to store performance factor for account %s and slot index %d", accountID, slot)
9696
}
9797

98+
t.LogDebug("Importing performance factor", "accountID", accountID, "slot", slot, "performanceFactor", performanceFactor)
99+
98100
return nil
99101
}); err != nil {
100102
return ierrors.Wrapf(err, "unable to read performance factors for slot %d", slot)
@@ -131,6 +133,8 @@ func (t *Tracker) importPoolRewards(reader io.ReadSeeker) error {
131133
return ierrors.Wrapf(err, "unable to read reward for account %s and epoch index %d", accountID, epoch)
132134
}
133135

136+
t.LogDebug("Importing reward", "accountID", accountID, "epoch", epoch, "reward", reward)
137+
134138
if err = rewardsTree.Set(accountID, reward); err != nil {
135139
return ierrors.Wrapf(err, "unable to set reward for account %s and epoch index %d", accountID, epoch)
136140
}
@@ -168,6 +172,8 @@ func (t *Tracker) importPoolsStats(reader io.ReadSeeker) error {
168172
return ierrors.Wrapf(err, "unable to store pool stats for the epoch index %d", epoch)
169173
}
170174

175+
t.LogDebug("Importing pool stats", "epoch", epoch, "poolStats", poolStats)
176+
171177
return nil
172178
}); err != nil {
173179
return ierrors.Wrap(err, "unable to read pool stats collection")
@@ -206,6 +212,8 @@ func (t *Tracker) importCommittees(reader io.ReadSeeker) error {
206212
committee.SetReused()
207213
}
208214

215+
t.LogDebug("Importing committee", "epoch", epoch, "committee", committee)
216+
209217
if err = t.committeeStore.Store(epoch, committee); err != nil {
210218
return ierrors.Wrap(err, "unable to store committee")
211219
}
@@ -247,6 +255,8 @@ func (t *Tracker) exportPerformanceFactor(writer io.WriteSeeker, startSlot iotag
247255
return ierrors.Wrapf(err, "unable to write performance factor for accountID %s and slot index %d", accountID, currentSlot)
248256
}
249257

258+
t.LogDebug("Exporting performance factor", "accountID", accountID, "slot", currentSlot, "performanceFactor", pf)
259+
250260
accountsCount++
251261

252262
return nil
@@ -292,9 +302,12 @@ func (t *Tracker) exportPoolRewards(writer io.WriteSeeker, targetEpoch iotago.Ep
292302
}
293303
// if the map was not present in storage we can skip this epoch
294304
if !rewardsMap.WasRestoredFromStorage() {
305+
t.LogDebug("Skipping epoch", "epoch", epoch, "reason", "not restored from storage")
295306
continue
296307
}
297308

309+
t.LogDebug("Exporting Pool Rewards", "epoch", epoch)
310+
298311
if err := stream.Write(writer, epoch); err != nil {
299312
return 0, ierrors.Wrapf(err, "unable to write epoch index for epoch index %d", epoch)
300313
}
@@ -311,6 +324,8 @@ func (t *Tracker) exportPoolRewards(writer io.WriteSeeker, targetEpoch iotago.Ep
311324
return ierrors.Wrapf(err, "unable to write account rewards for epoch index %d and accountID %s", epoch, key)
312325
}
313326

327+
t.LogDebug("Exporting Pool Reward", "epoch", epoch, "accountID", key, "rewards", value)
328+
314329
accountCount++
315330

316331
return nil
@@ -347,6 +362,7 @@ func (t *Tracker) exportPoolsStats(writer io.WriteSeeker, targetEpoch iotago.Epo
347362

348363
if epoch > targetEpoch {
349364
// continue
365+
t.LogDebug("Skipping epoch", "epoch", epoch, "reason", "epoch is greater than target epoch")
350366
return nil
351367
}
352368

@@ -358,6 +374,8 @@ func (t *Tracker) exportPoolsStats(writer io.WriteSeeker, targetEpoch iotago.Epo
358374
return ierrors.Wrapf(err, "unable to write pools stats for epoch %d", epoch)
359375
}
360376

377+
t.LogDebug("Exporting Pool Stats", "epoch", epoch, "poolStats", lo.Return1(model.PoolsStatsFromBytes(value)))
378+
361379
epochCount++
362380

363381
return nil
@@ -399,6 +417,7 @@ func (t *Tracker) exportCommittees(writer io.WriteSeeker, targetSlot iotago.Slot
399417
// - we were able to rotate a committee, then we export it
400418
// - we were not able to rotate a committee (reused), then we don't export it
401419
if epoch > epochFromTargetSlot && targetSlot < pointOfNoReturn && committee.IsReused() {
420+
t.LogDebug("Skipping committee", "epoch", epoch, "reason", "epoch is greater than target epoch and committee is reused")
402421
return nil
403422
}
404423

@@ -427,6 +446,8 @@ func (t *Tracker) exportCommittees(writer io.WriteSeeker, targetSlot iotago.Slot
427446
return ierrors.Wrapf(err, "unable to write reused flag for epoch %d", epoch)
428447
}
429448

449+
t.LogDebug("Exporting committee", "epoch", epoch, "committee", committee)
450+
430451
epochCount++
431452

432453
return nil

0 commit comments

Comments
 (0)