@@ -163,10 +163,12 @@ type StateDB struct {
163
163
SnapshotCommits time.Duration
164
164
TrieDBCommits time.Duration
165
165
166
- AccountUpdated int
167
- StorageUpdated atomic.Int64
168
- AccountDeleted int
169
- StorageDeleted atomic.Int64
166
+ AccountLoaded int // Number of accounts retrieved from the database during the state transition
167
+ AccountUpdated int // Number of accounts updated during the state transition
168
+ AccountDeleted int // Number of accounts deleted during the state transition
169
+ StorageLoaded int // Number of storage slots retrieved from the database during the state transition
170
+ StorageUpdated atomic.Int64 // Number of storage slots updated during the state transition
171
+ StorageDeleted atomic.Int64 // Number of storage slots deleted during the state transition
170
172
}
171
173
172
174
// New creates a new state from a given trie.
@@ -601,6 +603,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject {
601
603
s .SnapshotAccountReads += time .Since (start )
602
604
if err == nil {
603
605
if acc == nil {
606
+ s .AccountLoaded ++
604
607
return nil
605
608
}
606
609
data = & types.StateAccount {
@@ -629,6 +632,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject {
629
632
return nil
630
633
}
631
634
if data == nil {
635
+ s .AccountLoaded ++
632
636
return nil
633
637
}
634
638
}
@@ -643,6 +647,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject {
643
647
// Insert into the live set
644
648
obj := newObject (s , addr , data )
645
649
s .setStateObject (obj )
650
+ s .AccountLoaded ++
646
651
return obj
647
652
}
648
653
@@ -1286,6 +1291,8 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1286
1291
if err := workers .Wait (); err != nil {
1287
1292
return nil , err
1288
1293
}
1294
+ accountReadMeters .Mark (int64 (s .AccountLoaded ))
1295
+ storageReadMeters .Mark (int64 (s .StorageLoaded ))
1289
1296
accountUpdatedMeter .Mark (int64 (s .AccountUpdated ))
1290
1297
storageUpdatedMeter .Mark (s .StorageUpdated .Load ())
1291
1298
accountDeletedMeter .Mark (int64 (s .AccountDeleted ))
@@ -1294,7 +1301,10 @@ func (s *StateDB) commit(deleteEmptyObjects bool) (*stateUpdate, error) {
1294
1301
accountTrieDeletedMeter .Mark (int64 (accountTrieNodesDeleted ))
1295
1302
storageTriesUpdatedMeter .Mark (int64 (storageTrieNodesUpdated ))
1296
1303
storageTriesDeletedMeter .Mark (int64 (storageTrieNodesDeleted ))
1297
- s .AccountUpdated , s .AccountDeleted = 0 , 0
1304
+
1305
+ // Clear the metric markers
1306
+ s .AccountLoaded , s .AccountUpdated , s .AccountDeleted = 0 , 0 , 0
1307
+ s .StorageLoaded = 0
1298
1308
s .StorageUpdated .Store (0 )
1299
1309
s .StorageDeleted .Store (0 )
1300
1310
0 commit comments