mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
only include code hash for contracts
This commit is contained in:
parent
40968d8b13
commit
651229775e
2 changed files with 22 additions and 9 deletions
|
|
@ -17,7 +17,7 @@ func (a account) MarshalJSON() ([]byte, error) {
|
|||
type account struct {
|
||||
Balance *hexutil.Big `json:"balance,omitempty"`
|
||||
Code hexutil.Bytes `json:"code,omitempty"`
|
||||
CodeHash common.Hash `json:"codeHash,omitempty"`
|
||||
CodeHash *common.Hash `json:"codeHash,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ func (a *account) UnmarshalJSON(input []byte) error {
|
|||
a.Code = *dec.Code
|
||||
}
|
||||
if dec.CodeHash != nil {
|
||||
a.CodeHash = *dec.CodeHash
|
||||
a.CodeHash = dec.CodeHash
|
||||
}
|
||||
if dec.Nonce != nil {
|
||||
a.Nonce = *dec.Nonce
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ type stateMap = map[common.Address]*account
|
|||
type account struct {
|
||||
Balance *big.Int `json:"balance,omitempty"`
|
||||
Code []byte `json:"code,omitempty"`
|
||||
CodeHash common.Hash `json:"codeHash,omitempty"`
|
||||
CodeHash *common.Hash `json:"codeHash,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||
empty bool
|
||||
|
|
@ -258,9 +258,18 @@ func (t *prestateTracer) processDiffState() {
|
|||
modified = true
|
||||
postAccount.Nonce = newNonce
|
||||
}
|
||||
if newCodeHash != t.pre[addr].CodeHash {
|
||||
prevCodeHash := common.Hash{}
|
||||
if t.pre[addr].CodeHash != nil {
|
||||
prevCodeHash = *t.pre[addr].CodeHash
|
||||
}
|
||||
// Empty code hashes are excluded from the prestate. Normalize
|
||||
// the empty code hash to a zero hash to make it comparable.
|
||||
if newCodeHash == types.EmptyCodeHash {
|
||||
newCodeHash = common.Hash{}
|
||||
}
|
||||
if newCodeHash != prevCodeHash {
|
||||
modified = true
|
||||
postAccount.CodeHash = newCodeHash
|
||||
postAccount.CodeHash = &newCodeHash
|
||||
}
|
||||
if !t.config.DisableCode {
|
||||
newCode := t.env.StateDB.GetCode(addr)
|
||||
|
|
@ -310,7 +319,11 @@ func (t *prestateTracer) lookupAccount(addr common.Address) {
|
|||
Balance: t.env.StateDB.GetBalance(addr).ToBig(),
|
||||
Nonce: t.env.StateDB.GetNonce(addr),
|
||||
Code: t.env.StateDB.GetCode(addr),
|
||||
CodeHash: t.env.StateDB.GetCodeHash(addr),
|
||||
}
|
||||
codeHash := t.env.StateDB.GetCodeHash(addr)
|
||||
// If the code is empty, we don't need to store it in the prestate.
|
||||
if codeHash != (common.Hash{}) && codeHash != types.EmptyCodeHash {
|
||||
acc.CodeHash = &codeHash
|
||||
}
|
||||
if !acc.exists() {
|
||||
acc.empty = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue