diff --git a/core/state/access_witness.go b/core/state/access_witness.go index 276485e2dd25..152c47cf3df0 100644 --- a/core/state/access_witness.go +++ b/core/state/access_witness.go @@ -144,12 +144,7 @@ func (aw *AccessWitness) TouchTxOriginAndComputeGas(originAddr []byte) { func (aw *AccessWitness) TouchTxTarget(targetAddr []byte, sendsValue bool) { aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BasicDataLeafKey, sendsValue, nil) - // Note that we do a write-event in CodeHash without distinguishing if the tx target account - // exists or not. Pre-7702, there's no situation in which an existing codeHash can be mutated, thus - // doing a write-event shouldn't cause an observable difference in gas usage. - // TODO(7702): re-check this in the spec and implementation to be sure is a correct solution after - // EIP-7702 is implemented. - aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, true, nil) + aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, false, nil) } func (aw *AccessWitness) TouchSlotAndChargeGas(addr []byte, slot common.Hash, isWrite bool, useGasFn UseGasFn, warmCostCharging bool) bool { diff --git a/core/state_transition.go b/core/state_transition.go index 89424cf455fd..9f35b8d3a94a 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -397,6 +397,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { if msg.To != nil { st.evm.Accesses.TouchTxTarget(targetAddr.Bytes(), msg.Value.Sign() != 0) + if !st.state.Exist(*targetAddr) { + st.evm.Accesses.TouchCodeHash(targetAddr.Bytes(), true, nil, false) + } // ensure the code size ends up in the access witness st.evm.StateDB.GetCodeSize(*targetAddr)