diff --git a/core/mkalloc.go b/core/mkalloc.go index e1c7fbf691..73eaaada27 100644 --- a/core/mkalloc.go +++ b/core/mkalloc.go @@ -52,7 +52,8 @@ func makelist(g *core.Genesis) allocList { if len(account.Storage) > 0 || len(account.Code) > 0 || account.Nonce != 0 { panic(fmt.Sprintf("can't encode account %x", addr)) } - a = append(a, allocItem{addr.Big(), account.Balance}) + bigAddr := new(big.Int).SetBytes(addr.Bytes()) + a = append(a, allocItem{bigAddr, account.Balance}) } sort.Sort(a) return a diff --git a/core/state/statedb.go b/core/state/statedb.go index 28a96f0a87..a5941cf8f7 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -585,13 +585,13 @@ func (s *StateDB) updateStateObject(obj *stateObject) { } // deleteStateObject removes the given object from the state trie. -func (s *StateDB) deleteStateObject(stateObject *stateObject) { +func (s *StateDB) deleteStateObject(obj *stateObject) { // Track the amount of time wasted on deleting the account from the trie if metrics.EnabledExpensive { defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now()) } //stateObject.deleted = true - addr := stateObject.Address() + addr := obj.Address() if err := s.trie.TryDelete(addr[:]); err != nil { s.setError(fmt.Errorf("deleteStateObject (%x) error: %v", addr[:], err)) } @@ -611,7 +611,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject { // nil for a deleted state object, it returns the actual object with the deleted // flag set. This is needed by the state journal to revert to the correct s- // destructed object instead of wiping all knowledge about the state object. -func (s *StateDB) getDeletedStateObject(addr common.Address) (stateObject *stateObject) { +func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject { // Prefer 'live' objects. if obj := s.stateObjects[addr]; obj != nil { return obj @@ -628,7 +628,6 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) (stateObject *state var acc *snapshot.Account if acc, err = s.snap.Account(crypto.Keccak256Hash(addr.Bytes())); err == nil { if acc == nil { - log.Trace("acc is nil", "addr", addr) return nil } data.Nonce, data.Balance, data.CodeHash, data.Upload, data.Num = acc.Nonce, acc.Balance, acc.CodeHash, acc.Upload, acc.Num @@ -640,9 +639,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) (stateObject *state data.Root = emptyRoot } } - log.Trace("Snap account is not nil", "addr", addr, "nonce", data.Nonce, "balance", data.Balance, "upload", data.Upload, "num", data.Num, "err", err) } - // Load the object from the database. // If snapshot unavailable or reading from it failed, load from the database if s.snap == nil || err != nil { if metrics.EnabledExpensive { @@ -660,7 +657,6 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) (stateObject *state log.Error("Failed to decode state object", "addr", addr, "err", err) return nil } - log.Trace("snap show is nul", "addr", addr, "err", err) } // Insert into the live set. obj := newObject(s, addr, data) @@ -685,6 +681,7 @@ func (s *StateDB) GetOrNewStateObject(addr common.Address) *stateObject { // the given address, it is overwritten and returned as the second return value. func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) { prev = s.getStateObject(addr) + var prevdestruct bool if s.snap != nil && prev != nil { _, prevdestruct = s.snapDestructs[prev.addrHash] @@ -897,6 +894,7 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { if len(s.stateObjectsPending) > 0 { s.stateObjectsPending = make(map[common.Address]struct{}) } + // Track the amount of time wasted on hashing the account trie if metrics.EnabledExpensive { defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now()) } diff --git a/whisper/whisperv6/gen_criteria_json.go b/whisper/whisperv6/gen_criteria_json.go index 54d1a6265b..b55386eb05 100644 --- a/whisper/whisperv6/gen_criteria_json.go +++ b/whisper/whisperv6/gen_criteria_json.go @@ -10,7 +10,7 @@ import ( var _ = (*criteriaOverride)(nil) -// MarshalJSON marshals type Criteria to a json string +// MarshalJSON marshals as JSON. func (c Criteria) MarshalJSON() ([]byte, error) { type Criteria struct { SymKeyID string `json:"symKeyID"` @@ -30,7 +30,7 @@ func (c Criteria) MarshalJSON() ([]byte, error) { return json.Marshal(&enc) } -// UnmarshalJSON unmarshals type Criteria to a json string +// UnmarshalJSON unmarshals from JSON. func (c *Criteria) UnmarshalJSON(input []byte) error { type Criteria struct { SymKeyID *string `json:"symKeyID"` diff --git a/whisper/whisperv6/gen_message_json.go b/whisper/whisperv6/gen_message_json.go index e2608bc5bd..2a01e87e40 100644 --- a/whisper/whisperv6/gen_message_json.go +++ b/whisper/whisperv6/gen_message_json.go @@ -10,7 +10,7 @@ import ( var _ = (*messageOverride)(nil) -// MarshalJSON marshals type Message to a json string +// MarshalJSON marshals as JSON. func (m Message) MarshalJSON() ([]byte, error) { type Message struct { Sig hexutil.Bytes `json:"sig,omitempty"` @@ -36,7 +36,7 @@ func (m Message) MarshalJSON() ([]byte, error) { return json.Marshal(&enc) } -// UnmarshalJSON unmarshals type Message to a json string +// UnmarshalJSON unmarshals from JSON. func (m *Message) UnmarshalJSON(input []byte) error { type Message struct { Sig *hexutil.Bytes `json:"sig,omitempty"` diff --git a/whisper/whisperv6/gen_newmessage_json.go b/whisper/whisperv6/gen_newmessage_json.go index e279a35062..7993e24a34 100644 --- a/whisper/whisperv6/gen_newmessage_json.go +++ b/whisper/whisperv6/gen_newmessage_json.go @@ -10,7 +10,7 @@ import ( var _ = (*newMessageOverride)(nil) -// MarshalJSON marshals type NewMessage to a json string +// MarshalJSON marshals as JSON. func (n NewMessage) MarshalJSON() ([]byte, error) { type NewMessage struct { SymKeyID string `json:"symKeyID"` @@ -38,7 +38,7 @@ func (n NewMessage) MarshalJSON() ([]byte, error) { return json.Marshal(&enc) } -// UnmarshalJSON unmarshals type NewMessage to a json string +// UnmarshalJSON unmarshals from JSON. func (n *NewMessage) UnmarshalJSON(input []byte) error { type NewMessage struct { SymKeyID *string `json:"symKeyID"`