core: force add new delegation to accesslist

This commit is contained in:
lightclient 2024-09-07 09:50:44 -06:00
parent 75a43aed6c
commit 183e7b702a
No known key found for this signature in database
GPG key ID: 75C916AFEE20183E
3 changed files with 11 additions and 5 deletions

View file

@ -1409,10 +1409,12 @@ 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 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
}
for _, addr := range precompiles {

View file

@ -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))
}

View file

@ -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
}