mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-09 16:31:35 +00:00
core/state: change BAL plain-int counter fields from int64 to int
This commit is contained in:
parent
cd8ce62b40
commit
eb4d17595f
1 changed files with 14 additions and 15 deletions
|
|
@ -42,14 +42,14 @@ type BALStateTransition struct {
|
||||||
deletions map[common.Address]struct{}
|
deletions map[common.Address]struct{}
|
||||||
|
|
||||||
// Storage counters use atomic.Int64 because they're written from per-address
|
// Storage counters use atomic.Int64 because they're written from per-address
|
||||||
// goroutines (lines 440, 444). The other counters are written single-threaded
|
// goroutines. The others are written single-threaded inside IntermediateRoot's
|
||||||
// inside IntermediateRoot's serial mutation loop, so plain int64 is race-free.
|
// serial mutation loop, so plain int matches StateCounts' int fields.
|
||||||
accountDeleted int64
|
accountDeleted int
|
||||||
accountUpdated int64
|
accountUpdated int
|
||||||
storageDeleted atomic.Int64
|
storageDeleted atomic.Int64
|
||||||
storageUpdated atomic.Int64
|
storageUpdated atomic.Int64
|
||||||
codeUpdated int64
|
codeUpdated int
|
||||||
codeUpdateBytes int64
|
codeUpdateBytes int
|
||||||
|
|
||||||
// Read-time accumulators for state-root recomputation reads. Atomic
|
// Read-time accumulators for state-root recomputation reads. Atomic
|
||||||
// because s.reader.Account/Storage is called from per-address goroutines.
|
// because s.reader.Account/Storage is called from per-address goroutines.
|
||||||
|
|
@ -71,16 +71,15 @@ func (s *BALStateTransition) Metrics() *BALStateTransitionMetrics {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteCounts returns the state-mutation counts tracked during the parallel
|
// WriteCounts returns the state-mutation counts tracked during the parallel
|
||||||
// state-root computation: account update/delete, storage update/delete (atomic
|
// state-root computation.
|
||||||
// loads), and code update count/bytes.
|
|
||||||
func (s *BALStateTransition) WriteCounts() StateCounts {
|
func (s *BALStateTransition) WriteCounts() StateCounts {
|
||||||
return StateCounts{
|
return StateCounts{
|
||||||
AccountUpdated: int(s.accountUpdated),
|
AccountUpdated: s.accountUpdated,
|
||||||
AccountDeleted: int(s.accountDeleted),
|
AccountDeleted: s.accountDeleted,
|
||||||
StorageUpdated: s.storageUpdated.Load(),
|
StorageUpdated: s.storageUpdated.Load(),
|
||||||
StorageDeleted: s.storageDeleted.Load(),
|
StorageDeleted: s.storageDeleted.Load(),
|
||||||
CodeUpdated: int(s.codeUpdated),
|
CodeUpdated: s.codeUpdated,
|
||||||
CodeUpdateBytes: int(s.codeUpdateBytes),
|
CodeUpdateBytes: s.codeUpdateBytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -373,9 +372,9 @@ func (s *BALStateTransition) CommitWithUpdate(block uint64, deleteEmptyObjects b
|
||||||
return common.Hash{}, nil, err
|
return common.Hash{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
accountUpdatedMeter.Mark(s.accountUpdated)
|
accountUpdatedMeter.Mark(int64(s.accountUpdated))
|
||||||
storageUpdatedMeter.Mark(s.storageUpdated.Load())
|
storageUpdatedMeter.Mark(s.storageUpdated.Load())
|
||||||
accountDeletedMeter.Mark(s.accountDeleted)
|
accountDeletedMeter.Mark(int64(s.accountDeleted))
|
||||||
storageDeletedMeter.Mark(s.storageDeleted.Load())
|
storageDeletedMeter.Mark(s.storageDeleted.Load())
|
||||||
accountTrieUpdatedMeter.Mark(int64(accountTrieNodesUpdated))
|
accountTrieUpdatedMeter.Mark(int64(accountTrieNodesUpdated))
|
||||||
accountTrieDeletedMeter.Mark(int64(accountTrieNodesDeleted))
|
accountTrieDeletedMeter.Mark(int64(accountTrieNodesDeleted))
|
||||||
|
|
@ -534,7 +533,7 @@ func (s *BALStateTransition) IntermediateRoot(_ bool) common.Hash {
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
s.codeUpdated++
|
s.codeUpdated++
|
||||||
s.codeUpdateBytes += int64(len(code))
|
s.codeUpdateBytes += len(code)
|
||||||
}
|
}
|
||||||
if err := s.stateTrie.UpdateAccount(mutatedAddr, acct, len(code)); err != nil {
|
if err := s.stateTrie.UpdateAccount(mutatedAddr, acct, len(code)); err != nil {
|
||||||
s.setError(err)
|
s.setError(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue