Skip to content

Commit b3f25a6

Browse files
committed
Merge branch 'release/0.6.0'
2 parents f702e27 + 44da180 commit b3f25a6

12 files changed

+93
-42
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Ethereum
55

66
Ethereum Go Client © 2014 Jeffrey Wilcke.
77

8-
Current state: Proof of Concept 0.5.17.
8+
Current state: Proof of Concept 0.6.0.
99

1010
For the development package please see the [eth-go package](https://github.com/ethereum/eth-go).
1111

ethereal/assets/qml/wallet.qml

+2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ ApplicationWindow {
249249
}
250250
TextField {
251251
text: eth.getCustomIdentifier()
252+
width: 500
253+
placeholderText: "Anonymous"
252254
onTextChanged: {
253255
eth.setCustomIdentifier(text)
254256
}

ethereal/debugger.go

+29-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package main
33
import (
44
"fmt"
55
"github.com/ethereum/eth-go/ethchain"
6+
"github.com/ethereum/eth-go/ethstate"
67
"github.com/ethereum/eth-go/ethutil"
8+
"github.com/ethereum/eth-go/ethvm"
9+
"github.com/ethereum/go-ethereum/utils"
710
"github.com/go-qml/qml"
811
"math/big"
912
"strconv"
@@ -15,10 +18,10 @@ type DebuggerWindow struct {
1518
engine *qml.Engine
1619
lib *UiLib
1720

18-
vm *ethchain.Vm
21+
vm *ethvm.Vm
1922
Db *Debugger
2023

21-
state *ethchain.State
24+
state *ethstate.State
2225
}
2326

2427
func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
@@ -32,7 +35,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
3235

3336
win := component.CreateWindow(nil)
3437

35-
w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethchain.Vm{}}
38+
w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethvm.Vm{}}
3639
w.Db = NewDebugger(w)
3740

3841
return w
@@ -130,22 +133,29 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
130133

131134
state := self.lib.eth.StateManager().TransState()
132135
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
133-
contract := ethchain.NewStateObject([]byte{0})
136+
contract := ethstate.NewStateObject([]byte{0})
134137
contract.Amount = value
135138

136-
callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice)
139+
self.SetAsm(script)
140+
141+
callerClosure := ethvm.NewClosure(account, contract, script, gas, gasPrice)
137142

138143
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)
149159
vm.Verbose = true
150160
vm.Dbg = self.Db
151161

@@ -255,13 +265,13 @@ type storeVal struct {
255265
Key, Value string
256266
}
257267

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 {
259269
self.main.Logln("break on instr:", pc)
260270

261271
return self.halting(pc, op, mem, stack, stateObject)
262272
}
263273

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 {
265275
return self.halting(pc, op, mem, stack, stateObject)
266276
}
267277

@@ -273,7 +283,7 @@ func (self *Debugger) BreakPoints() []int64 {
273283
return self.breakPoints
274284
}
275285

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 {
277287
d.win.Root().Call("setInstruction", pc)
278288
d.win.Root().Call("clearMem")
279289
d.win.Root().Call("clearStack")
@@ -289,7 +299,7 @@ func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, sta
289299
d.win.Root().Call("setStack", val.String())
290300
}
291301

292-
stateObject.State().EachStorage(func(key string, node *ethutil.Value) {
302+
stateObject.EachStorage(func(key string, node *ethutil.Value) {
293303
d.win.Root().Call("setStorage", storeVal{fmt.Sprintf("% x", key), fmt.Sprintf("% x", node.Str())})
294304
})
295305

ethereal/ext_app.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/ethereum/eth-go/ethchain"
66
"github.com/ethereum/eth-go/ethpub"
7+
"github.com/ethereum/eth-go/ethstate"
78
"github.com/ethereum/eth-go/ethutil"
89
"github.com/go-qml/qml"
910
)
@@ -16,8 +17,8 @@ type AppContainer interface {
1617
Engine() *qml.Engine
1718

1819
NewBlock(*ethchain.Block)
19-
ObjectChanged(*ethchain.StateObject)
20-
StorageChanged(*ethchain.StorageState)
20+
ObjectChanged(*ethstate.StateObject)
21+
StorageChanged(*ethstate.StorageState)
2122
NewWatcher(chan bool)
2223
}
2324

@@ -108,9 +109,9 @@ out:
108109
app.container.NewBlock(block)
109110
}
110111
case object := <-app.changeChan:
111-
if stateObject, ok := object.Resource.(*ethchain.StateObject); ok {
112+
if stateObject, ok := object.Resource.(*ethstate.StateObject); ok {
112113
app.container.ObjectChanged(stateObject)
113-
} else if storageObject, ok := object.Resource.(*ethchain.StorageState); ok {
114+
} else if storageObject, ok := object.Resource.(*ethstate.StorageState); ok {
114115
app.container.StorageChanged(storageObject)
115116
}
116117
}

ethereal/gui.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
143143

144144
win := gui.createWindow(component)
145145

146-
gui.setInitialBlockChain()
147-
gui.loadAddressBook()
148-
gui.readPreviousTransactions()
149-
gui.setPeerInfo()
146+
go func() {
147+
gui.setInitialBlockChain()
148+
gui.loadAddressBook()
149+
gui.readPreviousTransactions()
150+
gui.setPeerInfo()
151+
}()
150152

151153
go gui.update()
152154

@@ -220,8 +222,9 @@ func (gui *Gui) loadAddressBook() {
220222

221223
nameReg := ethpub.EthereumConfig(gui.eth.StateManager()).NameReg()
222224
if nameReg != nil {
223-
nameReg.State().EachStorage(func(name string, value *ethutil.Value) {
225+
nameReg.EachStorage(func(name string, value *ethutil.Value) {
224226
if name[0] != 0 {
227+
value.Decode()
225228
gui.win.Root().Call("addAddress", struct{ Name, Address string }{name, ethutil.Bytes2Hex(value.Bytes())})
226229
}
227230
})

ethereal/html_container.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"github.com/ethereum/eth-go/ethchain"
66
"github.com/ethereum/eth-go/ethpub"
7+
"github.com/ethereum/eth-go/ethstate"
78
"github.com/ethereum/eth-go/ethutil"
89
"github.com/go-qml/qml"
910
"github.com/howeyc/fsnotify"
@@ -121,11 +122,11 @@ func (app *HtmlApplication) NewBlock(block *ethchain.Block) {
121122
app.webView.Call("onNewBlockCb", b)
122123
}
123124

124-
func (app *HtmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
125+
func (app *HtmlApplication) ObjectChanged(stateObject *ethstate.StateObject) {
125126
app.webView.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
126127
}
127128

128-
func (app *HtmlApplication) StorageChanged(storageObject *ethchain.StorageState) {
129+
func (app *HtmlApplication) StorageChanged(storageObject *ethstate.StorageState) {
129130
app.webView.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
130131
}
131132

ethereal/main.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import (
1010

1111
const (
1212
ClientIdentifier = "Ethereal"
13-
Version = "0.5.17"
13+
Version = "0.6.0"
1414
)
1515

1616
func main() {
17-
// Leave QT on top at ALL times. Qt Needs to be initialized from the main thread
18-
qml.Init(nil)
19-
2017
runtime.GOMAXPROCS(runtime.NumCPU())
2118

19+
qml.Init(nil)
20+
2221
var interrupted = false
2322
utils.RegisterInterrupt(func(os.Signal) {
2423
interrupted = true

ethereal/qml_container.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"github.com/ethereum/eth-go/ethchain"
55
"github.com/ethereum/eth-go/ethpub"
6+
"github.com/ethereum/eth-go/ethstate"
67
"github.com/ethereum/eth-go/ethutil"
78
"github.com/go-qml/qml"
89
"runtime"
@@ -50,11 +51,11 @@ func (app *QmlApplication) NewBlock(block *ethchain.Block) {
5051
app.win.Call("onNewBlockCb", pblock)
5152
}
5253

53-
func (app *QmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
54+
func (app *QmlApplication) ObjectChanged(stateObject *ethstate.StateObject) {
5455
app.win.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
5556
}
5657

57-
func (app *QmlApplication) StorageChanged(storageObject *ethchain.StorageState) {
58+
func (app *QmlApplication) StorageChanged(storageObject *ethstate.StorageState) {
5859
app.win.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
5960
}
6061

ethereal/ui_lib.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func (ui *UiLib) AssetPath(p string) string {
7878
func (self *UiLib) StartDbWithContractAndData(contractHash, data string) {
7979
dbWindow := NewDebuggerWindow(self)
8080
object := self.eth.StateManager().CurrentState().GetStateObject(ethutil.Hex2Bytes(contractHash))
81-
if len(object.Script()) > 0 {
82-
dbWindow.SetCode("0x" + ethutil.Bytes2Hex(object.Script()))
81+
if len(object.Code) > 0 {
82+
dbWindow.SetCode("0x" + ethutil.Bytes2Hex(object.Code))
8383
}
8484
dbWindow.SetData("0x" + data)
8585

ethereum/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
const (
1111
ClientIdentifier = "Ethereum(G)"
12-
Version = "0.5.17"
12+
Version = "0.6.0"
1313
)
1414

1515
var logger = ethlog.NewLogger("CLI")

ethereum/repl/javascript_runtime.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/ethereum/eth-go/ethchain"
77
"github.com/ethereum/eth-go/ethlog"
88
"github.com/ethereum/eth-go/ethpub"
9+
"github.com/ethereum/eth-go/ethstate"
910
"github.com/ethereum/eth-go/ethutil"
1011
"github.com/ethereum/go-ethereum/utils"
1112
"github.com/obscuren/otto"
@@ -121,12 +122,12 @@ out:
121122
if _, ok := block.Resource.(*ethchain.Block); ok {
122123
}
123124
case object := <-self.changeChan:
124-
if stateObject, ok := object.Resource.(*ethchain.StateObject); ok {
125+
if stateObject, ok := object.Resource.(*ethstate.StateObject); ok {
125126
for _, cb := range self.objectCb[ethutil.Bytes2Hex(stateObject.Address())] {
126127
val, _ := self.vm.ToValue(ethpub.NewPStateObject(stateObject))
127128
cb.Call(cb, val)
128129
}
129-
} else if storageObject, ok := object.Resource.(*ethchain.StorageState); ok {
130+
} else if storageObject, ok := object.Resource.(*ethstate.StorageState); ok {
130131
for _, cb := range self.objectCb[ethutil.Bytes2Hex(storageObject.StateAddress)+ethutil.Bytes2Hex(storageObject.Address)] {
131132
val, _ := self.vm.ToValue(ethpub.NewPStorageState(storageObject))
132133
cb.Call(cb, val)

utils/vm_env.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package utils
2+
3+
import (
4+
"github.com/ethereum/eth-go/ethchain"
5+
"github.com/ethereum/eth-go/ethstate"
6+
"math/big"
7+
)
8+
9+
type VMEnv struct {
10+
state *ethstate.State
11+
block *ethchain.Block
12+
13+
transactor []byte
14+
value *big.Int
15+
}
16+
17+
func NewEnv(state *ethstate.State, block *ethchain.Block, transactor []byte, value *big.Int) *VMEnv {
18+
return &VMEnv{
19+
state: state,
20+
block: block,
21+
transactor: transactor,
22+
value: value,
23+
}
24+
}
25+
26+
func (self *VMEnv) Origin() []byte { return self.transactor }
27+
func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number }
28+
func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash }
29+
func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase }
30+
func (self *VMEnv) Time() int64 { return self.block.Time }
31+
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
32+
func (self *VMEnv) Value() *big.Int { return self.value }
33+
func (self *VMEnv) State() *ethstate.State { return self.state }

0 commit comments

Comments
 (0)