mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-21 07:19:28 +00:00
ensure that CodeChange tracer hooks don't get called for noop cases where the cur and prev code is the same
This commit is contained in:
parent
fbe136a45e
commit
58eac317b1
2 changed files with 16 additions and 3 deletions
|
|
@ -314,6 +314,13 @@ func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) {
|
||||||
}
|
}
|
||||||
prevCodeHash := s.inner.GetCodeHash(addr)
|
prevCodeHash := s.inner.GetCodeHash(addr)
|
||||||
prevCode := s.inner.GetCode(addr)
|
prevCode := s.inner.GetCode(addr)
|
||||||
|
|
||||||
|
// don't record a code change if its a selfdestructing initcode
|
||||||
|
// ^ TODO: I assume that this is the only case where this can occur but should double-check
|
||||||
|
// just to be totally sure
|
||||||
|
if prevCodeHash == types.EmptyCodeHash {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if s.hooks.OnCodeChangeV2 != nil {
|
if s.hooks.OnCodeChangeV2 != nil {
|
||||||
s.hooks.OnCodeChangeV2(addr, prevCodeHash, prevCode, types.EmptyCodeHash, nil, tracing.CodeChangeSelfDestruct)
|
s.hooks.OnCodeChangeV2(addr, prevCodeHash, prevCode, types.EmptyCodeHash, nil, tracing.CodeChangeSelfDestruct)
|
||||||
} else if s.hooks.OnCodeChange != nil {
|
} else if s.hooks.OnCodeChange != nil {
|
||||||
|
|
|
||||||
|
|
@ -616,16 +616,22 @@ func (st *stateTransition) applyAuthorization(auth *types.SetCodeAuthorization)
|
||||||
st.state.AddRefund(params.CallNewAccountGas - params.TxAuthTupleGas)
|
st.state.AddRefund(params.CallNewAccountGas - params.TxAuthTupleGas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevDelegation, isDelegated := types.ParseDelegation(st.state.GetCode(authority))
|
||||||
|
|
||||||
// Update nonce and account code.
|
// Update nonce and account code.
|
||||||
st.state.SetNonce(authority, auth.Nonce+1, tracing.NonceChangeAuthorization)
|
st.state.SetNonce(authority, auth.Nonce+1, tracing.NonceChangeAuthorization)
|
||||||
if auth.Address == (common.Address{}) {
|
if auth.Address == (common.Address{}) {
|
||||||
// Delegation to zero address means clear.
|
// Delegation to zero address means clear.
|
||||||
st.state.SetCode(authority, nil, tracing.CodeChangeAuthorizationClear)
|
if isDelegated {
|
||||||
|
st.state.SetCode(authority, nil, tracing.CodeChangeAuthorizationClear)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise install delegation to auth.Address.
|
// install delegation to auth.Address if the delegation changed
|
||||||
st.state.SetCode(authority, types.AddressToDelegation(auth.Address), tracing.CodeChangeAuthorization)
|
if !isDelegated || auth.Address != prevDelegation {
|
||||||
|
st.state.SetCode(authority, types.AddressToDelegation(auth.Address), tracing.CodeChangeAuthorization)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue