aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/instructions.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/instructions.go')
-rw-r--r--core/vm/instructions.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index 4f9e45ffe..aaa8d7945 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -17,6 +17,7 @@
package vm
import (
+ "errors"
"fmt"
"math/big"
@@ -28,7 +29,8 @@ import (
)
var (
- bigZero = new(big.Int)
+ bigZero = new(big.Int)
+ errWriteProtection = errors.New("evm: write protection")
)
func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
@@ -656,6 +658,35 @@ func opDelegateCall(pc *uint64, evm *EVM, contract *Contract, memory *Memory, st
return ret, nil
}
+func opStaticCall(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
+ // pop gas
+ gas := stack.pop().Uint64()
+ // pop address
+ addr := stack.pop()
+ // pop input size and offset
+ inOffset, inSize := stack.pop(), stack.pop()
+ // pop return size and offset
+ retOffset, retSize := stack.pop(), stack.pop()
+
+ address := common.BigToAddress(addr)
+
+ // Get the arguments from the memory
+ args := memory.Get(inOffset.Int64(), inSize.Int64())
+
+ ret, returnGas, err := evm.StaticCall(contract, address, args, gas)
+ if err != nil {
+ stack.push(new(big.Int))
+ } else {
+ stack.push(big.NewInt(1))
+
+ memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
+ }
+ contract.Gas += returnGas
+
+ evm.interpreter.intPool.put(addr, inOffset, inSize, retOffset, retSize)
+ return ret, nil
+}
+
func opReturn(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
offset, size := stack.pop(), stack.pop()
ret := memory.GetPtr(offset.Int64(), size.Int64())