@@ -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,22 +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
- callerClosure := ethchain .NewClosure (account , contract , script , state , gas , gasPrice )
139
+ self .SetAsm (script )
140
+
141
+ callerClosure := ethvm .NewClosure (account , contract , script , gas , gasPrice )
137
142
138
143
block := self .lib .eth .BlockChain ().CurrentBlock
139
- vm := ethchain .NewVm (state , self .lib .eth .StateManager (), ethchain.RuntimeVars {
140
- Block : block ,
141
- Origin : account .Address (),
142
- BlockNumber : block .Number ,
143
- PrevHash : block .PrevHash ,
144
- Coinbase : block .Coinbase ,
145
- Time : block .Time ,
146
- Diff : block .Difficulty ,
147
- Value : ethutil .Big (valueStr ),
148
- })
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 )
149
159
vm .Verbose = true
150
160
vm .Dbg = self .Db
151
161
@@ -255,13 +265,13 @@ type storeVal struct {
255
265
Key , Value string
256
266
}
257
267
258
- 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 {
259
269
self .main .Logln ("break on instr:" , pc )
260
270
261
271
return self .halting (pc , op , mem , stack , stateObject )
262
272
}
263
273
264
- 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 {
265
275
return self .halting (pc , op , mem , stack , stateObject )
266
276
}
267
277
@@ -273,7 +283,7 @@ func (self *Debugger) BreakPoints() []int64 {
273
283
return self .breakPoints
274
284
}
275
285
276
- 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 {
277
287
d .win .Root ().Call ("setInstruction" , pc )
278
288
d .win .Root ().Call ("clearMem" )
279
289
d .win .Root ().Call ("clearStack" )
@@ -289,7 +299,7 @@ func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, sta
289
299
d .win .Root ().Call ("setStack" , val .String ())
290
300
}
291
301
292
- stateObject .State (). EachStorage (func (key string , node * ethutil.Value ) {
302
+ stateObject .EachStorage (func (key string , node * ethutil.Value ) {
293
303
d .win .Root ().Call ("setStorage" , storeVal {fmt .Sprintf ("% x" , key ), fmt .Sprintf ("% x" , node .Str ())})
294
304
})
295
305
0 commit comments