mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
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:
parent
6e4f5710f9
commit
05f242939f
1 changed files with 12 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue