chore: add commit and calc root num log

This commit is contained in:
joeylichang 2024-09-26 16:25:32 +08:00
parent 3dc1030979
commit 5018895927

@ -23,6 +23,7 @@ import (
"runtime"
"sort"
"sync"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/common"
@ -1216,6 +1217,7 @@ func (s *StateDB) AccountsIntermediateRoot() {
}()
}
var calcStateObjectCount atomic.Int64
// Although naively it makes sense to retrieve the account trie and then do
// the contract storage and account updates sequentially, that short circuits
// the account prefetcher. Instead, let's process all the storage updates
@ -1226,7 +1228,7 @@ func (s *StateDB) AccountsIntermediateRoot() {
wg.Add(1)
tasks <- func() {
obj.updateRoot()
calcStateObjectCount.Add(1)
// Cache the data until commit. Note, this update mechanism is not symmetric
// to the deletion, because whereas it is enough to track account updates
// at commit time, deletions need tracking at transaction boundary level to
@ -1240,6 +1242,7 @@ func (s *StateDB) AccountsIntermediateRoot() {
}
}
wg.Wait()
log.Info("versa calc root state object", "count", calcStateObjectCount.Load(), "version", s.db.GetVersion()+1)
}
func (s *StateDB) StateIntermediateRoot() common.Hash {
@ -1620,6 +1623,7 @@ func (s *StateDB) Commit(block uint64, failPostCommitFunc func(), postCommitFunc
}()
}
var committedStateObjectNum atomic.Int64
for addr := range s.stateObjectsDirty {
if obj := s.stateObjects[addr]; !obj.deleted {
tasks <- func() {
@ -1629,6 +1633,7 @@ func (s *StateDB) Commit(block uint64, failPostCommitFunc func(), postCommitFunc
taskResults <- taskResult{err, nil}
return
} else {
committedStateObjectNum.Add(1)
taskResults <- taskResult{nil, set}
}
} else {
@ -1711,6 +1716,7 @@ func (s *StateDB) Commit(block uint64, failPostCommitFunc func(), postCommitFunc
}
}
wg.Wait()
log.Info("versa commit state object", "count", committedStateObjectNum.Load(), "version", s.db.GetVersion()+1)
return nil
}()