|
|
@ -6,9 +6,7 @@ import ( |
|
|
|
"github.com/ethereum/eth-go" |
|
|
|
"github.com/ethereum/eth-go" |
|
|
|
"github.com/ethereum/eth-go/ethchain" |
|
|
|
"github.com/ethereum/eth-go/ethchain" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
"github.com/ethereum/go-ethereum/utils" |
|
|
|
|
|
|
|
"github.com/go-qml/qml" |
|
|
|
"github.com/go-qml/qml" |
|
|
|
"github.com/obscuren/mutan" |
|
|
|
|
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
@ -121,27 +119,28 @@ func DefaultAssetPath() string { |
|
|
|
func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) { |
|
|
|
func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) { |
|
|
|
state := ui.eth.BlockChain().CurrentBlock.State() |
|
|
|
state := ui.eth.BlockChain().CurrentBlock.State() |
|
|
|
|
|
|
|
|
|
|
|
mainInput, _ := mutan.PreParse(data) |
|
|
|
script, err := ethutil.Compile(data) |
|
|
|
callerScript, err := utils.Compile(mainInput) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ethutil.Config.Log.Debugln(err) |
|
|
|
ethutil.Config.Log.Debugln(err) |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dis := ethchain.Disassemble(callerScript) |
|
|
|
dis := ethchain.Disassemble(script) |
|
|
|
ui.win.Root().Call("clearAsm") |
|
|
|
ui.win.Root().Call("clearAsm") |
|
|
|
|
|
|
|
|
|
|
|
for _, str := range dis { |
|
|
|
for _, str := range dis { |
|
|
|
ui.win.Root().Call("setAsm", str) |
|
|
|
ui.win.Root().Call("setAsm", str) |
|
|
|
} |
|
|
|
} |
|
|
|
callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), nil) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Contract addr as test address
|
|
|
|
// Contract addr as test address
|
|
|
|
keyPair := ethutil.GetKeyRing().Get(0) |
|
|
|
keyPair := ethutil.GetKeyRing().Get(0) |
|
|
|
|
|
|
|
callerTx := |
|
|
|
|
|
|
|
ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script) |
|
|
|
|
|
|
|
callerTx.Sign(keyPair.PrivateKey) |
|
|
|
|
|
|
|
|
|
|
|
account := ui.eth.StateManager().TransState().GetStateObject(keyPair.Address()) |
|
|
|
account := ui.eth.StateManager().TransState().GetStateObject(keyPair.Address()) |
|
|
|
c := ethchain.MakeContract(callerTx, state) |
|
|
|
contract := ethchain.MakeContract(callerTx, state) |
|
|
|
callerClosure := ethchain.NewClosure(account, c, c.Script(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr)) |
|
|
|
callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr)) |
|
|
|
|
|
|
|
|
|
|
|
block := ui.eth.BlockChain().CurrentBlock |
|
|
|
block := ui.eth.BlockChain().CurrentBlock |
|
|
|
vm := ethchain.NewVm(state, ui.eth.StateManager(), ethchain.RuntimeVars{ |
|
|
|
vm := ethchain.NewVm(state, ui.eth.StateManager(), ethchain.RuntimeVars{ |
|
|
@ -151,23 +150,28 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) |
|
|
|
Coinbase: block.Coinbase, |
|
|
|
Coinbase: block.Coinbase, |
|
|
|
Time: block.Time, |
|
|
|
Time: block.Time, |
|
|
|
Diff: block.Difficulty, |
|
|
|
Diff: block.Difficulty, |
|
|
|
TxData: nil, |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.Db.done = false |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
callerClosure.Call(vm, nil, ui.Db.halting) |
|
|
|
callerClosure.Call(vm, contract.Init(), ui.Db.halting) |
|
|
|
|
|
|
|
|
|
|
|
state.Reset() |
|
|
|
state.Reset() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.Db.done = true |
|
|
|
}() |
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ui *UiLib) Next() { |
|
|
|
func (ui *UiLib) Next() { |
|
|
|
|
|
|
|
if !ui.Db.done { |
|
|
|
ui.Db.Next() |
|
|
|
ui.Db.Next() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Debugger struct { |
|
|
|
type Debugger struct { |
|
|
|
win *qml.Window |
|
|
|
win *qml.Window |
|
|
|
N chan bool |
|
|
|
N chan bool |
|
|
|
|
|
|
|
done bool |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) { |
|
|
|
func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) { |
|
|
|