-
Notifications
You must be signed in to change notification settings - Fork 3
/
enDef.go
67 lines (57 loc) · 2.06 KB
/
enDef.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package endpoint
import (
vmi "github.com/ElrondNetwork/elrond-vm-common"
blockchain "github.com/ElrondNetwork/elrond-vm/iele/elrond/node/hookadapter/blockchain"
krypto "github.com/ElrondNetwork/elrond-vm/iele/elrond/node/hookadapter/krypto"
interpreter "github.com/ElrondNetwork/elrond-vm/iele/elrond/node/iele-testing-kompiled/ieletestinginterpreter"
)
// AddressLength is the account address length expected by the VM.
const AddressLength = 32
// TestVMType is the VM type argument we use in tests.
var TestVMType = []byte{0, 0}
// ElrondIeleVM defines an object containing the state of the Iele VM.
// This is the Elrond version.
type ElrondIeleVM struct {
schedule Schedule
blockchainAdapter *blockchain.Blockchain
kryptoAdapter *krypto.Krypto
kinterpreter *interpreter.Interpreter
signedArguments bool
logIO bool
}
// NewElrondIeleVM creates new Elrond Iele VM instance
func NewElrondIeleVM(
vmType []byte,
schedule Schedule,
blockchainHook vmi.BlockchainHook,
cryptoHook vmi.CryptoHook) *ElrondIeleVM {
blockchainAdapter := &blockchain.Blockchain{
Upstream: blockchainHook,
VMType: vmType,
AddressLength: AddressLength,
LogToConsole: false,
}
kryptoAdapter := &krypto.Krypto{Upstream: cryptoHook}
kinterpreter := interpreter.NewInterpreter(blockchainAdapter, kryptoAdapter)
return &ElrondIeleVM{
schedule: schedule,
blockchainAdapter: blockchainAdapter,
kryptoAdapter: kryptoAdapter,
kinterpreter: kinterpreter,
signedArguments: false,
logIO: false,
}
}
// SetTracePretty turns on pretty trace creation, use for debugging only
func (vm *ElrondIeleVM) SetTracePretty() {
vm.kinterpreter.SetTracePretty()
}
// SetSignedArguments causes the VM to interpret call arguments as signed instead of unsigned (default) big ints.
func (vm *ElrondIeleVM) SetSignedArguments() {
vm.signedArguments = true
}
// SetLogIO causes the VM to print to console all inputs, data from hooks and output
func (vm *ElrondIeleVM) SetLogIO() {
vm.logIO = true
vm.blockchainAdapter.LogToConsole = true
}