Skip to content

Commit 1099c56

Browse files
committed
debug log
1 parent f734928 commit 1099c56

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/state/state_sizer.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ type SizeStats struct {
8181
ContractCodeBytes int64 // Total size of all contract code (in bytes)
8282
}
8383

84+
func (s SizeStats) String() string {
85+
return fmt.Sprintf("Block: %d Root: %s, Accounts: %d (%s), Storages: %d (%s), AccountTrienodes: %d (%s), StorageTrienodes: %d (%s), ContractCodes: %d (%s)",
86+
s.BlockNumber, s.StateRoot.Hex(),
87+
s.Accounts, common.StorageSize(s.AccountBytes),
88+
s.Storages, common.StorageSize(s.StorageBytes),
89+
s.AccountTrienodes, common.StorageSize(s.AccountTrienodeBytes),
90+
s.StorageTrienodes, common.StorageSize(s.StorageTrienodeBytes),
91+
s.ContractCodes, common.StorageSize(s.ContractCodeBytes),
92+
)
93+
}
94+
8495
// add applies the given state diffs and produces a new version of the statistics.
8596
func (s SizeStats) add(diff SizeStats) SizeStats {
8697
s.StateRoot = diff.StateRoot
@@ -375,7 +386,7 @@ wait:
375386
}
376387
done = make(chan buildResult)
377388
go t.build(entry.root, entry.blockNumber, done)
378-
log.Info("Measuring persistent state size", "root", root, "number", entry.blockNumber)
389+
log.Info("Measuring persistent state size", "root", root.Hex())
379390

380391
case result := <-done:
381392
if result.err != nil {
@@ -405,6 +416,7 @@ wait:
405416
if err := apply(result.root, result.stat); err != nil {
406417
return nil, err
407418
}
419+
log.Info("Init state size", "stat", result.stat)
408420
log.Info("Measured persistent state size", "root", result.root, "number", result.blockNumber, "elapsed", common.PrettyDuration(result.elapsed))
409421
return stats, nil
410422

@@ -552,6 +564,7 @@ func (t *SizeTracker) iterateTable(closed chan struct{}, prefix []byte, name str
552564
}
553565

554566
func (t *SizeTracker) upload(stats SizeStats) {
567+
log.Info("Update state size", "stat", stats)
555568
blockInfoGauge.Update(metrics.GaugeInfoValue{
556569
"number": hexutil.Uint64(stats.BlockNumber).String(),
557570
"hash": stats.StateRoot.Hex(),

0 commit comments

Comments
 (0)