mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +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
23483010a4
commit
485e7fda54
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)
|
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.
|
// Fail if we're trying to transfer more than the available balance.
|
||||||
if !syscall && !value.IsZero() && !evm.Context.CanTransfer(evm.StateDB, caller, value) {
|
if !syscall && !value.IsZero() && !evm.Context.CanTransfer(evm.StateDB, caller, value) {
|
||||||
return nil, gas, ErrInsufficientBalance
|
return nil, gas, ErrInsufficientBalance
|
||||||
|
|
@ -356,6 +362,12 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
|
||||||
if evm.depth > int(params.CallCreateDepth) {
|
if evm.depth > int(params.CallCreateDepth) {
|
||||||
return nil, gas, ErrDepth
|
return nil, gas, 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
|
// Fail if we're trying to transfer more than the available balance
|
||||||
if !evm.Context.CanTransfer(evm.StateDB, caller, value) {
|
if !evm.Context.CanTransfer(evm.StateDB, caller, value) {
|
||||||
return nil, gas, ErrInsufficientBalance
|
return nil, gas, ErrInsufficientBalance
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue