@@ -3,7 +3,10 @@ package main
3
3
import (
4
4
"fmt"
5
5
"github.com/ethereum/eth-go/ethchain"
6
+ "github.com/ethereum/eth-go/ethstate"
6
7
"github.com/ethereum/eth-go/ethutil"
8
+ "github.com/ethereum/eth-go/ethvm"
9
+ "github.com/ethereum/go-ethereum/utils"
7
10
"github.com/go-qml/qml"
8
11
"math/big"
9
12
"strconv"
@@ -15,10 +18,10 @@ type DebuggerWindow struct {
15
18
engine * qml.Engine
16
19
lib * UiLib
17
20
18
- vm * ethchain .Vm
21
+ vm * ethvm .Vm
19
22
Db * Debugger
20
23
21
- state * ethchain .State
24
+ state * ethstate .State
22
25
}
23
26
24
27
func NewDebuggerWindow (lib * UiLib ) * DebuggerWindow {
@@ -32,7 +35,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
32
35
33
36
win := component .CreateWindow (nil )
34
37
35
- w := & DebuggerWindow {engine : engine , win : win , lib : lib , vm : & ethchain .Vm {}}
38
+ w := & DebuggerWindow {engine : engine , win : win , lib : lib , vm : & ethvm .Vm {}}
36
39
w .Db = NewDebugger (w )
37
40
38
41
return w
@@ -130,24 +133,29 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
130
133
131
134
state := self .lib .eth .StateManager ().TransState ()
132
135
account := self .lib .eth .StateManager ().TransState ().GetAccount (keyPair .Address ())
133
- contract := ethchain .NewStateObject ([]byte {0 })
136
+ contract := ethstate .NewStateObject ([]byte {0 })
134
137
contract .Amount = value
135
138
136
139
self .SetAsm (script )
137
140
138
- callerClosure := ethchain .NewClosure (account , contract , script , state , gas , gasPrice )
141
+ callerClosure := ethvm .NewClosure (account , contract , script , gas , gasPrice )
139
142
140
143
block := self .lib .eth .BlockChain ().CurrentBlock
141
- vm := ethchain .NewVm (state , self .lib .eth .StateManager (), ethchain.RuntimeVars {
142
- Block : block ,
143
- Origin : account .Address (),
144
- BlockNumber : block .Number ,
145
- PrevHash : block .PrevHash ,
146
- Coinbase : block .Coinbase ,
147
- Time : block .Time ,
148
- Diff : block .Difficulty ,
149
- Value : ethutil .Big (valueStr ),
150
- })
144
+
145
+ /*
146
+ vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
147
+ Block: block,
148
+ Origin: account.Address(),
149
+ BlockNumber: block.Number,
150
+ PrevHash: block.PrevHash,
151
+ Coinbase: block.Coinbase,
152
+ Time: block.Time,
153
+ Diff: block.Difficulty,
154
+ Value: ethutil.Big(valueStr),
155
+ })
156
+ */
157
+ env := utils .NewEnv (state , block , account .Address (), value )
158
+ vm := ethvm .New (env )
151
159
vm .Verbose = true
152
160
vm .Dbg = self .Db
153
161
@@ -257,13 +265,13 @@ type storeVal struct {
257
265
Key , Value string
258
266
}
259
267
260
- func (self * Debugger ) BreakHook (pc int , op ethchain .OpCode , mem * ethchain .Memory , stack * ethchain .Stack , stateObject * ethchain .StateObject ) bool {
268
+ func (self * Debugger ) BreakHook (pc int , op ethvm .OpCode , mem * ethvm .Memory , stack * ethvm .Stack , stateObject * ethstate .StateObject ) bool {
261
269
self .main .Logln ("break on instr:" , pc )
262
270
263
271
return self .halting (pc , op , mem , stack , stateObject )
264
272
}
265
273
266
- func (self * Debugger ) StepHook (pc int , op ethchain .OpCode , mem * ethchain .Memory , stack * ethchain .Stack , stateObject * ethchain .StateObject ) bool {
274
+ func (self * Debugger ) StepHook (pc int , op ethvm .OpCode , mem * ethvm .Memory , stack * ethvm .Stack , stateObject * ethstate .StateObject ) bool {
267
275
return self .halting (pc , op , mem , stack , stateObject )
268
276
}
269
277
@@ -275,7 +283,7 @@ func (self *Debugger) BreakPoints() []int64 {
275
283
return self .breakPoints
276
284
}
277
285
278
- func (d * Debugger ) halting (pc int , op ethchain .OpCode , mem * ethchain .Memory , stack * ethchain .Stack , stateObject * ethchain .StateObject ) bool {
286
+ func (d * Debugger ) halting (pc int , op ethvm .OpCode , mem * ethvm .Memory , stack * ethvm .Stack , stateObject * ethstate .StateObject ) bool {
279
287
d .win .Root ().Call ("setInstruction" , pc )
280
288
d .win .Root ().Call ("clearMem" )
281
289
d .win .Root ().Call ("clearStack" )
0 commit comments