diff --git a/core/state/statedb.go b/core/state/statedb.go index 65131de9d0a6..dd88ba9799d6 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1409,9 +1409,11 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d al.AddAddress(sender) if dst != nil { al.AddAddress(*dst) - // TODO: is this right? - if addr, ok := types.ParseDelegation(s.GetCode(*dst)); ok { - al.AddAddress(addr) + if rules.IsPrague { + // Add delegation target + if addr, ok := types.ParseDelegation(s.GetCode(*dst)); ok { + al.AddAddress(addr) + } } // If it's a create-tx, the destination will be added inside evm.create } diff --git a/core/state_transition.go b/core/state_transition.go index e3c519e1f90c..31764f435694 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -495,6 +495,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { if exists := st.state.Exist(authority); exists { st.state.AddRefund(params.CallNewAccountGas - params.TxAuthTupleGas) } + // Special case, when msg.To is to an authority being set in the tx, we + // need to add it to the access list. Usually this happens in StateDB + // Prepare(..). + if st.msg.To != nil && *st.msg.To == authority { + st.state.AddAddressToAccessList(auth.Address) + } st.state.SetNonce(authority, auth.Nonce+1) st.state.SetCode(authority, types.AddressToDelegation(auth.Address)) } diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go index 3be0dbf505c8..f5ed13f55b25 100644 --- a/core/vm/operations_acl.go +++ b/core/vm/operations_acl.go @@ -328,12 +328,10 @@ func gasEip7702CodeCheck(evm *EVM, contract *Contract, stack *Stack, mem *Memory if evm.StateDB.AddressInAccessList(addr) { cost += params.WarmStorageReadCostEIP2929 } else { - // fmt.Println("adding ", addr, "to acl") evm.StateDB.AddAddressToAccessList(addr) cost += params.ColdAccountAccessCostEIP2929 } } - // fmt.Println("cost is", cost) return cost, nil }