Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/state/state_sizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func calSizeStats(update *stateUpdate) (SizeStats, error) {
// this deviation is negligible and acceptable for measurement purposes.
for _, code := range update.codes {
stats.ContractCodes += 1
stats.ContractCodeBytes += codeKeySize + int64(len(code.blob))
stats.ContractCodeBytes += codeKeySize + int64(len(code))
}
return stats, nil
}
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,8 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool, noStorag
// Commit dirty contract code if any exists
if db := s.db.TrieDB().Disk(); db != nil && len(ret.codes) > 0 {
batch := db.NewBatch()
for _, code := range ret.codes {
rawdb.WriteCode(batch, code.hash, code.blob)
for hash, code := range ret.codes {
rawdb.WriteCode(batch, hash, code)
}
if err := batch.Write(); err != nil {
return nil, err
Expand Down
12 changes: 6 additions & 6 deletions core/state/stateupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ type stateUpdate struct {
storagesOrigin map[common.Address]map[common.Hash][]byte
rawStorageKey bool

codes map[common.Address]contractCode // codes contains the set of dirty codes
nodes *trienode.MergedNodeSet // Aggregated dirty nodes caused by state changes
codes map[common.Hash][]byte // codes contains the set of dirty codes
nodes *trienode.MergedNodeSet // Aggregated dirty nodes caused by state changes
}

// empty returns a flag indicating the state transition is empty or not.
Expand All @@ -99,11 +99,11 @@ func (sc *stateUpdate) empty() bool {
// the hash of the slot key for constructing state update object.
func newStateUpdate(rawStorageKey bool, originRoot common.Hash, root common.Hash, blockNumber uint64, deletes map[common.Hash]*accountDelete, updates map[common.Hash]*accountUpdate, nodes *trienode.MergedNodeSet) *stateUpdate {
var (
accounts = make(map[common.Hash][]byte)
accountsOrigin = make(map[common.Address][]byte)
accounts = make(map[common.Hash][]byte, len(updates)+len(deletes))
accountsOrigin = make(map[common.Address][]byte, len(updates)+len(deletes))
storages = make(map[common.Hash]map[common.Hash][]byte)
storagesOrigin = make(map[common.Address]map[common.Hash][]byte)
codes = make(map[common.Address]contractCode)
codes = make(map[common.Hash][]byte)
)
// Since some accounts might be destroyed and recreated within the same
// block, deletions must be aggregated first.
Expand All @@ -125,7 +125,7 @@ func newStateUpdate(rawStorageKey bool, originRoot common.Hash, root common.Hash
// Aggregate dirty contract codes if they are available.
addr := op.address
if op.code != nil {
codes[addr] = *op.code
codes[op.code.hash] = op.code.blob
}
accounts[addrHash] = op.data

Expand Down