Skip to content

Commit 09be3aa

Browse files
committed
fix
Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent 81940b9 commit 09be3aa

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

core/vm/instructions.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -760,28 +760,6 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
760760
}
761761

762762
func chargeCallVariantEIP4762(evm *EVM, scope *ScopeContext) bool {
763-
if evm.chainRules.IsEIP4762 {
764-
address := common.Address(scope.Stack.Back(1).Bytes20())
765-
transfersValue := !scope.Stack.Back(2).IsZero()
766-
767-
// If value is transferred, it is charged before 1/64th
768-
// is subtracted from the available gas pool.
769-
if transfersValue {
770-
if !evm.Accesses.TouchAndChargeValueTransfer(scope.Contract.Address().Bytes()[:], address.Bytes()[:], scope.Contract.UseGas) {
771-
return false
772-
}
773-
}
774-
}
775-
776-
var err error
777-
evm.callGasTemp, err = callGas(evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
778-
if err != nil {
779-
return false
780-
}
781-
if !scope.Contract.UseGas(evm.callGasTemp) {
782-
return false
783-
}
784-
785763
target := common.Address(scope.Stack.Back(1).Bytes20())
786764
if _, isPrecompile := evm.precompile(target); isPrecompile {
787765
return true
@@ -800,6 +778,27 @@ func chargeCallVariantEIP4762(evm *EVM, scope *ScopeContext) bool {
800778
}
801779

802780
func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
781+
if interpreter.evm.chainRules.IsEIP4762 {
782+
address := common.Address(scope.Stack.Back(1).Bytes20())
783+
transfersValue := !scope.Stack.Back(2).IsZero()
784+
785+
// If value is transferred, it is charged before 1/64th
786+
// is subtracted from the available gas pool.
787+
if transfersValue {
788+
if !interpreter.evm.Accesses.TouchAndChargeValueTransfer(scope.Contract.Address().Bytes()[:], address.Bytes()[:], scope.Contract.UseGas) {
789+
return nil, ErrExecutionReverted
790+
}
791+
}
792+
}
793+
794+
var err error
795+
interpreter.evm.callGasTemp, err = callGas(interpreter.evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
796+
if err != nil {
797+
return nil, err
798+
}
799+
if !scope.Contract.UseGas(interpreter.evm.callGasTemp) {
800+
return nil, ErrOutOfGas
801+
}
803802
if !chargeCallVariantEIP4762(interpreter.evm, scope) {
804803
return nil, ErrExecutionReverted
805804
}

0 commit comments

Comments
 (0)