diff options
-rw-r--r-- | Dockerfile | 12 | ||||
-rw-r--r-- | cmd/ethereum/flags.go | 6 | ||||
-rw-r--r-- | cmd/ethereum/main.go | 4 | ||||
-rw-r--r-- | cmd/ethereum/repl/repl.go | 1 | ||||
-rw-r--r-- | cmd/mist/assets/qml/main.qml | 2 | ||||
-rw-r--r-- | cmd/mist/main.go | 2 | ||||
-rw-r--r-- | core/genesis.go | 2 | ||||
-rw-r--r-- | core/state_transition.go | 5 | ||||
-rw-r--r-- | eth/backend.go | 3 | ||||
-rw-r--r-- | javascript/javascript_runtime.go | 58 | ||||
-rw-r--r-- | javascript/js_lib.go | 2 | ||||
-rw-r--r-- | state/dump.go | 7 | ||||
-rw-r--r-- | vm/vm.go | 18 |
13 files changed, 48 insertions, 74 deletions
diff --git a/Dockerfile b/Dockerfile index 1f6555d1a..b7e23aaab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:14.04.1 +FROM ubuntu:14.04.2 ## Environment setup ENV HOME /root @@ -12,22 +12,22 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get upgrade -y RUN apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev -## Install Qt5.4 (not required for CLI) -# RUN add-apt-repository ppa:beineri/opt-qt54-trusty -y +## Install Qt5.4.1 (not required for CLI) +# RUN add-apt-repository ppa:beineri/opt-qt541-trusty -y # RUN apt-get update -y # RUN apt-get install -y qt54quickcontrols qt54webengine mesa-common-dev libglu1-mesa-dev # ENV PKG_CONFIG_PATH /opt/qt54/lib/pkgconfig # Install Golang -RUN wget https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz +RUN wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz RUN tar -C /usr/local -xzf go*.tar.gz && go version # this is a workaround, to make sure that docker's cache is invalidated whenever the git repo changes ADD https://api.github.com/repos/ethereum/go-ethereum/git/refs/heads/develop file_does_not_exist ## Fetch and install go-ethereum -RUN go get -v github.com/tools/godep -RUN go get -v -d github.com/ethereum/go-ethereum/... +RUN go get github.com/tools/godep +RUN go get -d github.com/ethereum/go-ethereum/... WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum RUN git checkout develop RUN godep restore diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 7d410c8e4..c42083160 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -135,6 +135,12 @@ func Init() { flag.Parse() + // When the javascript console is started log to a file instead + // of stdout + if StartJsConsole { + LogFile = path.Join(Datadir, "ethereum.log") + } + var err error if NAT, err = nat.Parse(*natstr); err != nil { log.Fatalf("-nat: %v", err) diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 9c840de58..f72b11e14 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -37,7 +37,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.8.5" + Version = "0.8.6" ) var clilogger = logger.NewLogger("CLI") @@ -137,6 +137,8 @@ func main() { utils.StartEthereum(ethereum) + fmt.Printf("Welcome to the FRONTIER\n") + if StartJsConsole { InitJsConsole(ethereum) } else if len(InputFile) > 0 { diff --git a/cmd/ethereum/repl/repl.go b/cmd/ethereum/repl/repl.go index 4a7880ff4..11b812617 100644 --- a/cmd/ethereum/repl/repl.go +++ b/cmd/ethereum/repl/repl.go @@ -60,6 +60,7 @@ func (self *JSRepl) Start() { if !self.running { self.running = true repllogger.Infoln("init JS Console") + reader := bufio.NewReader(self.history) for { line, err := reader.ReadString('\n') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index e80bd87e0..a909916b7 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -964,7 +964,7 @@ ApplicationWindow { anchors.top: parent.top anchors.topMargin: 30 font.pointSize: 12 - text: "<h2>Mist (0.8.5)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br>Gustav Simonsson<br><h3>UX/UI</h3>Alex van de Sande<br>Fabian Vogelsteller" + text: "<h2>Mist (0.8.6)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br>Gustav Simonsson<br><h3>UX/UI</h3>Alex van de Sande<br>Fabian Vogelsteller" } } diff --git a/cmd/mist/main.go b/cmd/mist/main.go index ad6eb5bec..3abe16767 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -36,7 +36,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.8.5" + Version = "0.8.6" ) var ethereum *eth.Ethereum diff --git a/core/genesis.go b/core/genesis.go index 75b4fc100..decffc541 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -51,8 +51,6 @@ func GenesisBlock(db ethutil.Database) *types.Block { statedb.Sync() genesis.Header().Root = statedb.Root() - fmt.Printf("+++ genesis +++\nRoot: %x\nHash: %x\n", genesis.Header().Root, genesis.Hash()) - return genesis } diff --git a/core/state_transition.go b/core/state_transition.go index a065c4f6b..7331fdd4a 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -251,16 +251,13 @@ func (self *StateTransition) RefundGas() { coinbase, sender := self.Coinbase(), self.From() // Return remaining gas remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice()) - fmt.Println("REFUND:", remaining) sender.AddBalance(remaining) uhalf := new(big.Int).Div(self.GasUsed(), ethutil.Big2) for addr, ref := range self.state.Refunds() { refund := ethutil.BigMin(uhalf, ref) self.gas.Add(self.gas, refund) - addToIt := refund.Mul(refund, self.msg.GasPrice()) - fmt.Println("ADD TO IT", addToIt) - self.state.AddBalance([]byte(addr), addToIt) + self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice())) } coinbase.RefundGas(self.gas, self.msg.GasPrice()) diff --git a/eth/backend.go b/eth/backend.go index 0e5d24429..f67f9c78b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -147,7 +147,8 @@ func New(config *Config) (*Ethereum, error) { d, _ := db.Get([]byte("ProtocolVersion")) protov := ethutil.NewValue(d).Uint() if protov != ProtocolVersion && protov != 0 { - return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, ethutil.Config.ExecPath+"/database") + path := path.Join(config.DataDir, "database") + return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path) } // Create new keymanager diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 0aa0f73e2..beaca45b9 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -24,7 +24,7 @@ var jsrelogger = logger.NewLogger("JSRE") type JSRE struct { ethereum *eth.Ethereum Vm *otto.Otto - pipe *xeth.XEth + xeth *xeth.XEth events event.Subscription @@ -67,7 +67,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { // We have to make sure that, whoever calls this, calls "Stop" go re.mainLoop() - re.Bind("eth", &JSEthereum{re.pipe, re.Vm, ethereum}) + re.Bind("eth", &JSEthereum{re.xeth, re.Vm, ethereum}) re.initStdFuncs() @@ -113,12 +113,10 @@ func (self *JSRE) mainLoop() { func (self *JSRE) initStdFuncs() { t, _ := self.Vm.Get("eth") eth := t.Object() - eth.Set("watch", self.watch) - eth.Set("addPeer", self.addPeer) + eth.Set("connect", self.connect) eth.Set("require", self.require) eth.Set("stopMining", self.stopMining) eth.Set("startMining", self.startMining) - eth.Set("execBlock", self.execBlock) eth.Set("dump", self.dump) eth.Set("export", self.export) } @@ -152,7 +150,8 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { } statedb := state.New(block.Root(), self.ethereum.Db()) - v, _ := self.Vm.ToValue(statedb.Dump()) + + v, _ := self.Vm.ToValue(statedb.RawDump()) return v } @@ -167,36 +166,7 @@ func (self *JSRE) startMining(call otto.FunctionCall) otto.Value { return v } -// eth.watch -func (self *JSRE) watch(call otto.FunctionCall) otto.Value { - addr, _ := call.Argument(0).ToString() - var storageAddr string - var cb otto.Value - var storageCallback bool - if len(call.ArgumentList) > 2 { - storageCallback = true - storageAddr, _ = call.Argument(1).ToString() - cb = call.Argument(2) - } else { - cb = call.Argument(1) - } - - if storageCallback { - self.objectCb[addr+storageAddr] = append(self.objectCb[addr+storageAddr], cb) - - // event := "storage:" + string(ethutil.Hex2Bytes(addr)) + ":" + string(ethutil.Hex2Bytes(storageAddr)) - // self.ethereum.EventMux().Subscribe(event, self.changeChan) - } else { - self.objectCb[addr] = append(self.objectCb[addr], cb) - - // event := "object:" + string(ethutil.Hex2Bytes(addr)) - // self.ethereum.EventMux().Subscribe(event, self.changeChan) - } - - return otto.UndefinedValue() -} - -func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { +func (self *JSRE) connect(call otto.FunctionCall) otto.Value { nodeURL, err := call.Argument(0).ToString() if err != nil { return otto.FalseValue() @@ -222,22 +192,12 @@ func (self *JSRE) require(call otto.FunctionCall) otto.Value { return t } -func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value { - hash, err := call.Argument(0).ToString() - if err != nil { - return otto.UndefinedValue() - } - - err = utils.BlockDo(self.ethereum, ethutil.Hex2Bytes(hash)) - if err != nil { - fmt.Println(err) +func (self *JSRE) export(call otto.FunctionCall) otto.Value { + if len(call.ArgumentList) == 0 { + fmt.Println("err: require file name") return otto.FalseValue() } - return otto.TrueValue() -} - -func (self *JSRE) export(call otto.FunctionCall) otto.Value { fn, err := call.Argument(0).ToString() if err != nil { fmt.Println(err) diff --git a/javascript/js_lib.go b/javascript/js_lib.go index dd1fe5f4d..f828ca389 100644 --- a/javascript/js_lib.go +++ b/javascript/js_lib.go @@ -16,7 +16,7 @@ function pp(object) { str += " ]"; } else if(typeof(object) === "object") { str += "{ "; - var last = Object.keys(object).sort().pop() + var last = Object.keys(object).pop() for(var k in object) { str += k + ": " + pp(object[k]); diff --git a/state/dump.go b/state/dump.go index 073f89414..2c611d76b 100644 --- a/state/dump.go +++ b/state/dump.go @@ -20,7 +20,7 @@ type World struct { Accounts map[string]Account `json:"accounts"` } -func (self *StateDB) Dump() []byte { +func (self *StateDB) RawDump() World { world := World{ Root: ethutil.Bytes2Hex(self.trie.Root()), Accounts: make(map[string]Account), @@ -39,8 +39,11 @@ func (self *StateDB) Dump() []byte { } world.Accounts[ethutil.Bytes2Hex(it.Key)] = account } + return world +} - json, err := json.MarshalIndent(world, "", " ") +func (self *StateDB) Dump() []byte { + json, err := json.MarshalIndent(self.RawDump(), "", " ") if err != nil { fmt.Println("dump err", err) } @@ -16,6 +16,8 @@ type Vm struct { logStr string err error + // For logging + debug bool Dbg Debugger @@ -32,7 +34,7 @@ func New(env Environment) *Vm { lt = LogTyDiff } - return &Vm{env: env, logTy: lt, Recoverable: true} + return &Vm{debug: false, env: env, logTy: lt, Recoverable: true} } func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) { @@ -938,17 +940,21 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context * } func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine { - if self.logTy == LogTyPretty { - self.logStr += fmt.Sprintf(format, v...) + if self.debug { + if self.logTy == LogTyPretty { + self.logStr += fmt.Sprintf(format, v...) + } } return self } func (self *Vm) Endl() VirtualMachine { - if self.logTy == LogTyPretty { - vmlogger.Debugln(self.logStr) - self.logStr = "" + if self.debug { + if self.logTy == LogTyPretty { + vmlogger.Debugln(self.logStr) + self.logStr = "" + } } return self |