Skip to content

Commit

Permalink
core: force add new delegation to accesslist
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Sep 7, 2024
1 parent 75a43ae commit 183e7b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 0 additions & 2 deletions core/vm/operations_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 183e7b7

Please sign in to comment.