core: refactor non-create processing flow

This commit is contained in:
lightclient 2024-12-05 18:41:28 -05:00
parent 9ee0d10421
commit f4b5798ba3
No known key found for this signature in database
GPG key ID: 75C916AFEE20183E

View file

@ -464,12 +464,15 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
// - reset transient storage(eip 1153)
st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, vm.ActivePrecompiles(rules), msg.AccessList)
if !contractCreation {
var (
ret []byte
vmerr error // vm errors do not effect consensus and are therefore not assigned to err
)
if contractCreation {
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value)
} else {
// Increment the nonce for the next transaction.
// Note: EIP-7702 authorizations can also modify the nonce. We perform
// this update first to ensure correct validation of authorization nonces.
st.state.SetNonce(msg.From, st.state.GetNonce(msg.From)+1)
}
// Apply EIP-7702 authorizations.
if msg.AuthList != nil {
@ -479,24 +482,16 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
}
}
if !contractCreation {
if addr, ok := types.ParseDelegation(st.state.GetCode(*msg.To)); ok {
// Perform convenience warming of sender's delegation target. Although the
// sender is already warmed in Prepare(..), it's possible a delegation to
// the account was deployed during this transaction. To handle correctly,
// wait until the final state of delegations is determined before
// simply wait until the final state of delegations is determined before
// performing the resolution and warming.
if addr, ok := types.ParseDelegation(st.state.GetCode(*msg.To)); ok {
st.state.AddAddressToAccessList(addr)
}
}
var (
ret []byte
vmerr error // vm errors do not effect consensus and are therefore not assigned to err
)
if contractCreation {
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value)
} else {
// Execute the transaction's call.
ret, st.gasRemaining, vmerr = st.evm.Call(sender, st.to(), msg.Data, st.gasRemaining, value)
}