aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-24 18:30:41 +0800
committerobscuren <geffobscura@gmail.com>2014-07-24 18:30:41 +0800
commita06a84d19b24da4005bc4d150f071ec4a703521b (patch)
tree68b5ff4d60831d278cea13ea2a95de8af04ff3ed /ethereal
parente7a80ec68165755678647f2d3e9b475d492a70dd (diff)
downloaddexon-a06a84d19b24da4005bc4d150f071ec4a703521b.tar.gz
dexon-a06a84d19b24da4005bc4d150f071ec4a703521b.tar.zst
dexon-a06a84d19b24da4005bc4d150f071ec4a703521b.zip
Refactored to reflect the new VM and State
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/assets/qml/wallet.qml2
-rw-r--r--ethereal/debugger.go44
-rw-r--r--ethereal/ext_app.go9
-rw-r--r--ethereal/html_container.go5
-rw-r--r--ethereal/main.go2
-rw-r--r--ethereal/qml_container.go5
-rw-r--r--ethereal/ui_lib.go4
7 files changed, 42 insertions, 29 deletions
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index a79e4708c..eef49824f 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -249,6 +249,8 @@ ApplicationWindow {
}
TextField {
text: eth.getCustomIdentifier()
+ width: 500
+ placeholderText: "Anonymous"
onTextChanged: {
eth.setCustomIdentifier(text)
}
diff --git a/ethereal/debugger.go b/ethereal/debugger.go
index a82dcb43f..096387405 100644
--- a/ethereal/debugger.go
+++ b/ethereal/debugger.go
@@ -3,7 +3,10 @@ package main
import (
"fmt"
"github.com/ethereum/eth-go/ethchain"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/eth-go/ethvm"
+ "github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"strconv"
@@ -15,10 +18,10 @@ type DebuggerWindow struct {
engine *qml.Engine
lib *UiLib
- vm *ethchain.Vm
+ vm *ethvm.Vm
Db *Debugger
- state *ethchain.State
+ state *ethstate.State
}
func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
@@ -32,7 +35,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
win := component.CreateWindow(nil)
- w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethchain.Vm{}}
+ w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethvm.Vm{}}
w.Db = NewDebugger(w)
return w
@@ -130,24 +133,29 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
state := self.lib.eth.StateManager().TransState()
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
- contract := ethchain.NewStateObject([]byte{0})
+ contract := ethstate.NewStateObject([]byte{0})
contract.Amount = value
self.SetAsm(script)
- callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice)
+ callerClosure := ethvm.NewClosure(account, contract, script, gas, gasPrice)
block := self.lib.eth.BlockChain().CurrentBlock
- vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
- Block: block,
- Origin: account.Address(),
- BlockNumber: block.Number,
- PrevHash: block.PrevHash,
- Coinbase: block.Coinbase,
- Time: block.Time,
- Diff: block.Difficulty,
- Value: ethutil.Big(valueStr),
- })
+
+ /*
+ vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
+ Block: block,
+ Origin: account.Address(),
+ BlockNumber: block.Number,
+ PrevHash: block.PrevHash,
+ Coinbase: block.Coinbase,
+ Time: block.Time,
+ Diff: block.Difficulty,
+ Value: ethutil.Big(valueStr),
+ })
+ */
+ env := utils.NewEnv(state, block, account.Address(), value)
+ vm := ethvm.New(env)
vm.Verbose = true
vm.Dbg = self.Db
@@ -257,13 +265,13 @@ type storeVal struct {
Key, Value string
}
-func (self *Debugger) BreakHook(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool {
+func (self *Debugger) BreakHook(pc int, op ethvm.OpCode, mem *ethvm.Memory, stack *ethvm.Stack, stateObject *ethstate.StateObject) bool {
self.main.Logln("break on instr:", pc)
return self.halting(pc, op, mem, stack, stateObject)
}
-func (self *Debugger) StepHook(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool {
+func (self *Debugger) StepHook(pc int, op ethvm.OpCode, mem *ethvm.Memory, stack *ethvm.Stack, stateObject *ethstate.StateObject) bool {
return self.halting(pc, op, mem, stack, stateObject)
}
@@ -275,7 +283,7 @@ func (self *Debugger) BreakPoints() []int64 {
return self.breakPoints
}
-func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool {
+func (d *Debugger) halting(pc int, op ethvm.OpCode, mem *ethvm.Memory, stack *ethvm.Stack, stateObject *ethstate.StateObject) bool {
d.win.Root().Call("setInstruction", pc)
d.win.Root().Call("clearMem")
d.win.Root().Call("clearStack")
diff --git a/ethereal/ext_app.go b/ethereal/ext_app.go
index 17c342a1b..ac3e090f9 100644
--- a/ethereal/ext_app.go
+++ b/ethereal/ext_app.go
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
)
@@ -16,8 +17,8 @@ type AppContainer interface {
Engine() *qml.Engine
NewBlock(*ethchain.Block)
- ObjectChanged(*ethchain.StateObject)
- StorageChanged(*ethchain.StorageState)
+ ObjectChanged(*ethstate.StateObject)
+ StorageChanged(*ethstate.StorageState)
NewWatcher(chan bool)
}
@@ -108,9 +109,9 @@ out:
app.container.NewBlock(block)
}
case object := <-app.changeChan:
- if stateObject, ok := object.Resource.(*ethchain.StateObject); ok {
+ if stateObject, ok := object.Resource.(*ethstate.StateObject); ok {
app.container.ObjectChanged(stateObject)
- } else if storageObject, ok := object.Resource.(*ethchain.StorageState); ok {
+ } else if storageObject, ok := object.Resource.(*ethstate.StorageState); ok {
app.container.StorageChanged(storageObject)
}
}
diff --git a/ethereal/html_container.go b/ethereal/html_container.go
index 04136f801..b00d3f78e 100644
--- a/ethereal/html_container.go
+++ b/ethereal/html_container.go
@@ -4,6 +4,7 @@ import (
"errors"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
"github.com/howeyc/fsnotify"
@@ -121,11 +122,11 @@ func (app *HtmlApplication) NewBlock(block *ethchain.Block) {
app.webView.Call("onNewBlockCb", b)
}
-func (app *HtmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
+func (app *HtmlApplication) ObjectChanged(stateObject *ethstate.StateObject) {
app.webView.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
}
-func (app *HtmlApplication) StorageChanged(storageObject *ethchain.StorageState) {
+func (app *HtmlApplication) StorageChanged(storageObject *ethstate.StorageState) {
app.webView.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
}
diff --git a/ethereal/main.go b/ethereal/main.go
index e1cd43ace..ebda552ee 100644
--- a/ethereal/main.go
+++ b/ethereal/main.go
@@ -10,7 +10,7 @@ import (
const (
ClientIdentifier = "Ethereal"
- Version = "0.5.17"
+ Version = "0.6.0"
)
func main() {
diff --git a/ethereal/qml_container.go b/ethereal/qml_container.go
index cb43a99bd..1b420ee21 100644
--- a/ethereal/qml_container.go
+++ b/ethereal/qml_container.go
@@ -3,6 +3,7 @@ package main
import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
+ "github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
"runtime"
@@ -50,11 +51,11 @@ func (app *QmlApplication) NewBlock(block *ethchain.Block) {
app.win.Call("onNewBlockCb", pblock)
}
-func (app *QmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
+func (app *QmlApplication) ObjectChanged(stateObject *ethstate.StateObject) {
app.win.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
}
-func (app *QmlApplication) StorageChanged(storageObject *ethchain.StorageState) {
+func (app *QmlApplication) StorageChanged(storageObject *ethstate.StorageState) {
app.win.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
}
diff --git a/ethereal/ui_lib.go b/ethereal/ui_lib.go
index 997a3391a..6a62fa1df 100644
--- a/ethereal/ui_lib.go
+++ b/ethereal/ui_lib.go
@@ -78,8 +78,8 @@ func (ui *UiLib) AssetPath(p string) string {
func (self *UiLib) StartDbWithContractAndData(contractHash, data string) {
dbWindow := NewDebuggerWindow(self)
object := self.eth.StateManager().CurrentState().GetStateObject(ethutil.Hex2Bytes(contractHash))
- if len(object.Script()) > 0 {
- dbWindow.SetCode("0x" + ethutil.Bytes2Hex(object.Script()))
+ if len(object.Code) > 0 {
+ dbWindow.SetCode("0x" + ethutil.Bytes2Hex(object.Code))
}
dbWindow.SetData("0x" + data)