core/vm: put account in BAL before transfer

Might not actually be needed if spec is changed, see https://github.com/ethereum/EIPs/pull/11699
This commit is contained in:
MariusVanDerWijden 2026-05-21 16:15:49 +02:00
parent 6e4f5710f9
commit 05f242939f
No known key found for this signature in database

View file

@ -261,6 +261,12 @@ func (evm *EVM) Call(caller common.Address, addr common.Address, input []byte, g
}
syscall := isSystemCall(caller)
// EIP-7928: per the Amsterdam spec, delegation resolution happens before
// the value-transfer check, so the delegated-to must appear in the BAL
// even when the call later reverts with ErrInsufficientBalance. Touch the
// target's code here (a no-op for non-delegated accounts) to record it.
evm.resolveCode(addr)
// Fail if we're trying to transfer more than the available balance.
if !syscall && !value.IsZero() && !evm.Context.CanTransfer(evm.StateDB, caller, value) {
return nil, gas.Preserved(), ErrInsufficientBalance
@ -347,6 +353,12 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
if evm.depth > int(params.CallCreateDepth) {
return nil, gas.Preserved(), ErrDepth
}
// EIP-7928: per the Amsterdam spec, delegation resolution happens before
// the value-transfer check, so the delegated-to must appear in the BAL
// even when the call later reverts with ErrInsufficientBalance.
evm.resolveCode(addr)
// Fail if we're trying to transfer more than the available balance
if !evm.Context.CanTransfer(evm.StateDB, caller, value) {
return nil, gas.Preserved(), ErrInsufficientBalance