From 0f471291134c0b38df07b9a9cffda5c9807435ae Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Thu, 20 Nov 2014 14:16:22 -0500 Subject: [PATCH 01/10] Updated main.go - fix for broken develop build Transaction execution fixes - 60cdb1148c404218846fd39331690658168f4e04 --- cmd/ethereum/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index ed42dfafb..88549b30a 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -93,7 +93,7 @@ func main() { os.Exit(1) } - fmt.Printf("RLP: %x\nstate: %x\nhash: %x\n", ethutil.Rlp(block), block.GetRoot(), block.Hash()) + fmt.Printf("RLP: %x\nstate: %x\nhash: %x\n", ethutil.Rlp(block), block.Root(), block.Hash()) // Leave the Println. This needs clean output for piping fmt.Printf("%s\n", block.State().Dump()) From d5ac24907e0e98329d2db0d982c035f9d2635c6d Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Thu, 20 Nov 2014 14:25:26 -0500 Subject: [PATCH 02/10] Updated install.sh - github paths for executables --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index f6232af83..1f03f3f99 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/sh if [ "$1" == "" ]; then - echo "Usage $0 executable branch ethereum develop" + echo "Usage $0 executable ethereum branch develop" echo "executable ethereum or mist" echo "branch develop or master" exit @@ -19,8 +19,8 @@ if [ "$GOPATH" == "" ]; then exit fi -echo "go get -u -d github.com/ethereum/go-ethereum/$exe" -go get -v -u -d github.com/ethereum/go-ethereum/$exe +echo "go get -u -d github.com/ethereum/go-ethereum/cmd/$exe" +go get -v -u -d github.com/ethereum/go-ethereum/cmd/$exe if [ $? != 0 ]; then echo "go get failed" exit @@ -31,7 +31,7 @@ cd $GOPATH/src/github.com/ethereum/go-ethereum git checkout $branch echo "go-ethereum" -cd $GOPATH/src/github.com/ethereum/go-ethereum/$exe +cd $GOPATH/src/github.com/ethereum/go-ethereum/cmd/$exe git checkout $branch if [ "$exe" == "mist" ]; then From c0bbb7e69a0f34020f211061aaa842f1bbedb507 Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Thu, 20 Nov 2014 15:02:24 -0500 Subject: [PATCH 03/10] fix for install script devel --- install.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 1f03f3f99..39212c3ed 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,20 @@ #!/bin/sh if [ "$1" == "" ]; then - echo "Usage $0 executable ethereum branch develop" - echo "executable ethereum or mist" - echo "branch develop or master" + echo "Usage $0 executable branch" + echo "executable ethereum | mist" + echo "branch develop | master" exit fi exe=$1 branch=$2 +branchPath="" + +# Set branchPath for develop as executables have moved +if [ "$branch" == "develop" ]; then + branchPath="cmd/" +fi # Test if go is installed command -v go >/dev/null 2>&1 || { echo >&2 "Unable to find 'go'. This script requires go."; exit 1; } @@ -19,8 +25,8 @@ if [ "$GOPATH" == "" ]; then exit fi -echo "go get -u -d github.com/ethereum/go-ethereum/cmd/$exe" -go get -v -u -d github.com/ethereum/go-ethereum/cmd/$exe +echo "go get -u -d github.com/ethereum/go-ethereum/$branchPath$exe" +go get -v -u -d github.com/ethereum/go-ethereum/$branchPath$exe if [ $? != 0 ]; then echo "go get failed" exit @@ -31,7 +37,7 @@ cd $GOPATH/src/github.com/ethereum/go-ethereum git checkout $branch echo "go-ethereum" -cd $GOPATH/src/github.com/ethereum/go-ethereum/cmd/$exe +cd $GOPATH/src/github.com/ethereum/go-ethereum/$branchPath$exe git checkout $branch if [ "$exe" == "mist" ]; then From 6c098ee779393a85c5a70ba4494b9f22dec9a394 Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Fri, 21 Nov 2014 00:06:33 -0500 Subject: [PATCH 04/10] changed install.sh to change branch and install executable --- install.sh | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index 39212c3ed..0b2ee3df2 100755 --- a/install.sh +++ b/install.sh @@ -8,12 +8,11 @@ if [ "$1" == "" ]; then fi exe=$1 +path=$exe branch=$2 -branchPath="" -# Set branchPath for develop as executables have moved if [ "$branch" == "develop" ]; then - branchPath="cmd/" + path="cmd/$exe" fi # Test if go is installed @@ -25,20 +24,11 @@ if [ "$GOPATH" == "" ]; then exit fi -echo "go get -u -d github.com/ethereum/go-ethereum/$branchPath$exe" -go get -v -u -d github.com/ethereum/go-ethereum/$branchPath$exe -if [ $? != 0 ]; then - echo "go get failed" - exit -fi - -echo "eth-go" +echo "changing branch to $branch" cd $GOPATH/src/github.com/ethereum/go-ethereum git checkout $branch -echo "go-ethereum" -cd $GOPATH/src/github.com/ethereum/go-ethereum/$branchPath$exe -git checkout $branch +cd $GOPATH/src/github.com/ethereum/go-ethereum/$path if [ "$exe" == "mist" ]; then echo "Building Mist GUI. Assuming Qt is installed. If this step" @@ -48,9 +38,4 @@ else fi go install -if [ $? == 0 ]; then - echo "go install failed" - exit -fi - echo "done. Please run $exe :-)" From eba3fca7bcc18952c62689f96d600725b9d45402 Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Fri, 21 Nov 2014 08:05:52 -0500 Subject: [PATCH 05/10] go get dependencies on executable --- install.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install.sh b/install.sh index 0b2ee3df2..957306e75 100755 --- a/install.sh +++ b/install.sh @@ -28,6 +28,14 @@ echo "changing branch to $branch" cd $GOPATH/src/github.com/ethereum/go-ethereum git checkout $branch + +echo "go get -u -d github.com/ethereum/go-ethereum/$path" +go get -v -u -d github.com/ethereum/go-ethereum/$path +if [ $? != 0 ]; then + echo "go get failed" + exit +fi + cd $GOPATH/src/github.com/ethereum/go-ethereum/$path if [ "$exe" == "mist" ]; then From 28b7dcc2041dfa945dc762f73f2524036517f328 Mon Sep 17 00:00:00 2001 From: Eric Robitaille Date: Fri, 21 Nov 2014 08:16:32 -0500 Subject: [PATCH 06/10] go get deps doesnt work with develop branch --- install.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 957306e75..30a3802e4 100755 --- a/install.sh +++ b/install.sh @@ -28,13 +28,17 @@ echo "changing branch to $branch" cd $GOPATH/src/github.com/ethereum/go-ethereum git checkout $branch +# installing package dependencies doesn't work for develop +# branch as go get always pulls from master head +# so build will continue to fail, but this installs locally +# for people who git clone since go install will manage deps -echo "go get -u -d github.com/ethereum/go-ethereum/$path" -go get -v -u -d github.com/ethereum/go-ethereum/$path -if [ $? != 0 ]; then - echo "go get failed" - exit -fi +#echo "go get -u -d github.com/ethereum/go-ethereum/$path" +#go get -v -u -d github.com/ethereum/go-ethereum/$path +#if [ $? != 0 ]; then +# echo "go get failed" +# exit +#fi cd $GOPATH/src/github.com/ethereum/go-ethereum/$path From 61556ef01de20a23951690376662ca58b345eca4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 28 Nov 2014 20:47:24 +0100 Subject: [PATCH 07/10] GasData changes & removed min gas price --- chain/block.go | 36 ++++++++++++++---------------------- chain/chain_manager.go | 2 -- chain/state_transition.go | 18 +++++++++++++++--- miner/miner.go | 1 - 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/chain/block.go b/chain/block.go index a4ab560dc..dccb7ca41 100644 --- a/chain/block.go +++ b/chain/block.go @@ -84,8 +84,6 @@ type Block struct { Time int64 // The block number Number *big.Int - // Minimum Gas Price - MinGasPrice *big.Int // Gas limit GasLimit *big.Int // Gas used @@ -124,16 +122,15 @@ func CreateBlock(root interface{}, extra string) *Block { block := &Block{ - PrevHash: prevHash, - Coinbase: base, - Difficulty: Difficulty, - Nonce: Nonce, - Time: time.Now().Unix(), - Extra: extra, - UncleSha: nil, - GasUsed: new(big.Int), - MinGasPrice: new(big.Int), - GasLimit: new(big.Int), + PrevHash: prevHash, + Coinbase: base, + Difficulty: Difficulty, + Nonce: Nonce, + Time: time.Now().Unix(), + Extra: extra, + UncleSha: nil, + GasUsed: new(big.Int), + GasLimit: new(big.Int), } block.SetUncles([]*Block{}) @@ -300,12 +297,11 @@ func (self *Block) setHeader(header *ethutil.Value) { self.LogsBloom = header.Get(6).Bytes() self.Difficulty = header.Get(7).BigInt() self.Number = header.Get(8).BigInt() - self.MinGasPrice = header.Get(9).BigInt() - self.GasLimit = header.Get(10).BigInt() - self.GasUsed = header.Get(11).BigInt() - self.Time = int64(header.Get(12).BigInt().Uint64()) - self.Extra = header.Get(13).Str() - self.Nonce = header.Get(14).Bytes() + self.GasLimit = header.Get(9).BigInt() + self.GasUsed = header.Get(10).BigInt() + self.Time = int64(header.Get(11).BigInt().Uint64()) + self.Extra = header.Get(12).Str() + self.Nonce = header.Get(13).Bytes() } func NewUncleBlockFromValue(header *ethutil.Value) *Block { @@ -351,8 +347,6 @@ func (block *Block) miningHeader() []interface{} { block.Difficulty, // The block number block.Number, - // Block minimum gas price - block.MinGasPrice, // Block upper gas bound block.GasLimit, // Block gas used @@ -380,7 +374,6 @@ func (block *Block) String() string { Bloom: %x Difficulty: %v Number: %v - MinGas: %v MaxLimit: %v GasUsed: %v Time: %v @@ -399,7 +392,6 @@ func (block *Block) String() string { block.LogsBloom, block.Difficulty, block.Number, - block.MinGasPrice, block.GasLimit, block.GasUsed, block.Time, diff --git a/chain/chain_manager.go b/chain/chain_manager.go index df390a4c0..0c3a7a928 100644 --- a/chain/chain_manager.go +++ b/chain/chain_manager.go @@ -59,8 +59,6 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *Block { nil, "") - block.MinGasPrice = big.NewInt(10000000000000) - parent := bc.CurrentBlock if parent != nil { block.Difficulty = CalcDifficulty(block, parent) diff --git a/chain/state_transition.go b/chain/state_transition.go index afe044299..f9b82c58b 100644 --- a/chain/state_transition.go +++ b/chain/state_transition.go @@ -156,12 +156,24 @@ func (self *StateTransition) TransitionState() (err error) { } // Pay data gas - dataPrice := big.NewInt(int64(len(self.data))) - dataPrice.Mul(dataPrice, vm.GasData) - if err = self.UseGas(dataPrice); err != nil { + var dgas int64 + for _, byt := range self.data { + if byt != 0 { + dgas += vm.GasData.Int64() + } else { + dgas += 1 // This is 1/5. If GasData changes this fails + } + } + if err = self.UseGas(big.NewInt(dgas)); err != nil { return } + //dataPrice := big.NewInt(int64(len(self.data))) + //dataPrice.Mul(dataPrice, vm.GasData) + //if err = self.UseGas(dataPrice); err != nil { + // return + //} + if sender.Balance().Cmp(self.value) < 0 { return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance) } diff --git a/miner/miner.go b/miner/miner.go index a678a6895..e3435f5a6 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -177,7 +177,6 @@ func (self *Miner) mine() { chainMan = self.eth.ChainManager() block = chainMan.NewBlock(self.Coinbase) ) - block.MinGasPrice = self.MinAcceptedGasPrice // Apply uncles if len(self.uncles) > 0 { From 6ba8328077e0ccce4e2631fc83098a3e4e54a42d Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 28 Nov 2014 20:57:10 +0100 Subject: [PATCH 08/10] Removed min gas price from genesis --- chain/genesis.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/chain/genesis.go b/chain/genesis.go index 14117a82c..85e85d1ed 100644 --- a/chain/genesis.go +++ b/chain/genesis.go @@ -37,8 +37,6 @@ var GenesisHeader = []interface{}{ big.NewInt(131072), // Number ethutil.Big0, - // Block minimum gas price - ethutil.Big0, // Block upper gas bound big.NewInt(1000000), // Block gas used From c8d0f8adc5145f650ced3ad5c8c008eb4b4094e2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 28 Nov 2014 21:20:32 +0100 Subject: [PATCH 09/10] Changed refund --- chain/block_manager.go | 9 +++++---- miner/miner.go | 2 +- state/state.go | 29 ++++++++++++++++------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/chain/block_manager.go b/chain/block_manager.go index efe9e0862..fdb221cc3 100644 --- a/chain/block_manager.go +++ b/chain/block_manager.go @@ -154,10 +154,11 @@ done: } } - // Update the state with pending changes - state.Update() - txGas.Sub(txGas, st.gas) + + // Update the state with pending changes + state.Update(txGas) + cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas)) receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, nil /*bloom*/, state.Logs()} receipt.Bloom = CreateBloom(Receipts{receipt}) @@ -245,7 +246,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me return } - state.Update() + state.Update(nil) if !block.State().Cmp(state) { err = fmt.Errorf("invalid merkle root. received=%x got=%x", block.Root(), state.Root()) diff --git a/miner/miner.go b/miner/miner.go index e3435f5a6..9152d532b 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -203,7 +203,7 @@ func (self *Miner) mine() { // Accumulate the rewards included for this block blockManager.AccumelateRewards(block.State(), block, parent) - block.State().Update() + block.State().Update(nil) minerlogger.Infof("Mining on block. Includes %v transactions", len(transactions)) diff --git a/state/state.go b/state/state.go index 3abf1545b..0a7f717fe 100644 --- a/state/state.go +++ b/state/state.go @@ -23,14 +23,14 @@ type State struct { manifest *Manifest - refund map[string]*big.Int + refund map[string][]refund logs Logs } // Create a new state from a given trie func New(trie *trie.Trie) *State { - return &State{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string]*big.Int)} + return &State{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string][]refund)} } func (self *State) EmptyLogs() { @@ -55,14 +55,12 @@ func (self *State) GetBalance(addr []byte) *big.Int { return ethutil.Big0 } +type refund struct { + gas, price *big.Int +} + func (self *State) Refund(addr []byte, gas, price *big.Int) { - amount := new(big.Int).Mul(gas, price) - - if self.refund[string(addr)] == nil { - self.refund[string(addr)] = new(big.Int) - } - - self.refund[string(addr)].Add(self.refund[string(addr)], amount) + self.refund[string(addr)] = append(self.refund[string(addr)], refund{gas, price}) } func (self *State) AddBalance(addr []byte, amount *big.Int) { @@ -276,15 +274,20 @@ func (s *State) Sync() { func (self *State) Empty() { self.stateObjects = make(map[string]*StateObject) - self.refund = make(map[string]*big.Int) + self.refund = make(map[string][]refund) } -func (self *State) Update() { +func (self *State) Update(gasUsed *big.Int) { var deleted bool // Refund any gas that's left - for addr, amount := range self.refund { - self.GetStateObject([]byte(addr)).AddBalance(amount) + uhalf := new(big.Int).Div(gasUsed, ethutil.Big2) + for addr, refs := range self.refund { + for _, ref := range refs { + refund := ethutil.BigMin(uhalf, ref.gas) + + self.GetStateObject([]byte(addr)).AddBalance(refund.Mul(refund, ref.price)) + } } for _, stateObject := range self.stateObjects { From a3559c5e1b469890bb8d71e9992175febaae31c7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 28 Nov 2014 21:38:10 +0100 Subject: [PATCH 10/10] updated PV --- cmd/ethereum/main.go | 2 +- cmd/mist/main.go | 2 +- peer.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 88549b30a..1493de384 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -30,7 +30,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.7.5" + Version = "0.7.6" ) var clilogger = logger.NewLogger("CLI") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index bc05d4f3d..39beeafdb 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -31,7 +31,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.7.5" + Version = "0.7.6" ) var ethereum *eth.Ethereum diff --git a/peer.go b/peer.go index b54978854..86423c816 100644 --- a/peer.go +++ b/peer.go @@ -24,7 +24,7 @@ const ( // The size of the output buffer for writing messages outputBufferSize = 50 // Current protocol version - ProtocolVersion = 42 + ProtocolVersion = 45 // Current P2P version P2PVersion = 2 // Ethereum network version