github.com/annchain/OG@v0.0.9/vm/ovm/vm_interface.go (about) 1 package ovm 2 3 import ( 4 "github.com/annchain/OG/common" 5 vmtypes "github.com/annchain/OG/vm/types" 6 "math/big" 7 ) 8 9 type VM interface { 10 // Cancel cancels any running VM operation. This may be called concurrently and 11 // it's safe to be called multiple times. 12 Cancel() 13 14 // Interpreter returns the current interpreter 15 Interpreter() Interpreter 16 17 // Call executes the vmtypes.Contract associated with the addr with the given input as 18 // parameters. It also handles any necessary Value transfer required and takes 19 // the necessary steps to create accounts and reverses the state in case of an 20 // execution error or failed Value transfer. 21 Call(caller vmtypes.ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) 22 23 // CallCode executes the vmtypes.Contract associated with the addr with the given input 24 // as parameters. It also handles any necessary Value transfer required and takes 25 // the necessary steps to create accounts and reverses the state in case of an 26 // execution error or failed Value transfer. 27 // 28 // CallCode differs from Call in the sense that it executes the given address' 29 // Code with the caller as context. 30 CallCode(caller vmtypes.ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) 31 32 // DelegateCall executes the vmtypes.Contract associated with the addr with the given input 33 // as parameters. It reverses the state in case of an execution error. 34 // 35 // DelegateCall differs from CallCode in the sense that it executes the given address' 36 // Code with the caller as context and the caller is set to the caller of the caller. 37 DelegateCall(caller vmtypes.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error) 38 39 // StaticCall executes the vmtypes.Contract associated with the addr with the given input 40 // as parameters while disallowing any modifications to the state during the call. 41 // Opcodes that attempt to perform such modifications will result in exceptions 42 // instead of performing the modifications. 43 StaticCall(caller vmtypes.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error) 44 45 // Create creates a new vmtypes.Contract using Code as deployment Code. 46 Create(caller vmtypes.ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, ContractAddr common.Address, leftOverGas uint64, err error) 47 48 // Create2 creates a new vmtypes.Contract using Code as deployment Code. 49 // 50 // The different between Create2 with Create is Create2 uses sha3(0xff ++ msg.sender ++ salt ++ sha3(init_code))[12:] 51 // instead of the usual sender-and-Nonce-hash as the address where the vmtypes.Contract is initialized at. 52 Create2(caller vmtypes.ContractRef, code []byte, gas uint64, endowment *big.Int, salt *big.Int) (ret []byte, ContractAddr common.Address, leftOverGas uint64, err error) 53 }