Skip to content

Commit 6881525

Browse files
authored
Merge pull request #3098 from ethereum/release/1.4
Geth 1.4.16 "Dear Diary"
2 parents cb7d7d3 + 4fced09 commit 6881525

File tree

782 files changed

+189577
-65929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

782 files changed

+189577
-65929
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.15
1+
1.4.16

accounts/abi/bind/backends/simulated.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
9797
statedb *state.StateDB
9898
)
9999
if pending {
100-
block, statedb = b.pendingBlock, b.pendingState.Copy()
100+
block, statedb = b.pendingBlock, b.pendingState
101+
defer statedb.RevertToSnapshot(statedb.Snapshot())
101102
} else {
102103
block = b.blockchain.CurrentBlock()
103104
statedb, _ = b.blockchain.State()
@@ -119,6 +120,7 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
119120
value: new(big.Int),
120121
data: data,
121122
}
123+
122124
// Execute the call and return
123125
vmenv := core.NewEnv(statedb, chainConfig, b.blockchain, msg, block.Header(), vm.Config{})
124126
gaspool := new(core.GasPool).AddGas(common.MaxBig)
@@ -146,8 +148,10 @@ func (b *SimulatedBackend) EstimateGasLimit(sender common.Address, contract *com
146148
// Create a copy of the currently pending state db to screw around with
147149
var (
148150
block = b.pendingBlock
149-
statedb = b.pendingState.Copy()
151+
statedb = b.pendingState
150152
)
153+
defer statedb.RevertToSnapshot(statedb.Snapshot())
154+
151155
// If there's no code to interact with, respond with an appropriate error
152156
if contract != nil {
153157
if code := statedb.GetCode(*contract); len(code) == 0 {

cmd/evm/main.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,22 @@ type ruleSet struct{}
223223

224224
func (ruleSet) IsHomestead(*big.Int) bool { return true }
225225

226-
func (self *VMEnv) RuleSet() vm.RuleSet { return ruleSet{} }
227-
func (self *VMEnv) Vm() vm.Vm { return self.evm }
228-
func (self *VMEnv) Db() vm.Database { return self.state }
229-
func (self *VMEnv) MakeSnapshot() vm.Database { return self.state.Copy() }
230-
func (self *VMEnv) SetSnapshot(db vm.Database) { self.state.Set(db.(*state.StateDB)) }
231-
func (self *VMEnv) Origin() common.Address { return *self.transactor }
232-
func (self *VMEnv) BlockNumber() *big.Int { return common.Big0 }
233-
func (self *VMEnv) Coinbase() common.Address { return *self.transactor }
234-
func (self *VMEnv) Time() *big.Int { return self.time }
235-
func (self *VMEnv) Difficulty() *big.Int { return common.Big1 }
236-
func (self *VMEnv) BlockHash() []byte { return make([]byte, 32) }
237-
func (self *VMEnv) Value() *big.Int { return self.value }
238-
func (self *VMEnv) GasLimit() *big.Int { return big.NewInt(1000000000) }
239-
func (self *VMEnv) VmType() vm.Type { return vm.StdVmTy }
240-
func (self *VMEnv) Depth() int { return 0 }
241-
func (self *VMEnv) SetDepth(i int) { self.depth = i }
226+
func (self *VMEnv) RuleSet() vm.RuleSet { return ruleSet{} }
227+
func (self *VMEnv) Vm() vm.Vm { return self.evm }
228+
func (self *VMEnv) Db() vm.Database { return self.state }
229+
func (self *VMEnv) SnapshotDatabase() int { return self.state.Snapshot() }
230+
func (self *VMEnv) RevertToSnapshot(snap int) { self.state.RevertToSnapshot(snap) }
231+
func (self *VMEnv) Origin() common.Address { return *self.transactor }
232+
func (self *VMEnv) BlockNumber() *big.Int { return common.Big0 }
233+
func (self *VMEnv) Coinbase() common.Address { return *self.transactor }
234+
func (self *VMEnv) Time() *big.Int { return self.time }
235+
func (self *VMEnv) Difficulty() *big.Int { return common.Big1 }
236+
func (self *VMEnv) BlockHash() []byte { return make([]byte, 32) }
237+
func (self *VMEnv) Value() *big.Int { return self.value }
238+
func (self *VMEnv) GasLimit() *big.Int { return big.NewInt(1000000000) }
239+
func (self *VMEnv) VmType() vm.Type { return vm.StdVmTy }
240+
func (self *VMEnv) Depth() int { return 0 }
241+
func (self *VMEnv) SetDepth(i int) { self.depth = i }
242242
func (self *VMEnv) GetHash(n uint64) common.Hash {
243243
if self.block.Number().Cmp(big.NewInt(int64(n))) == 0 {
244244
return self.block.Hash()

cmd/geth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const (
5050
clientIdentifier = "Geth" // Client identifier to advertise over the network
5151
versionMajor = 1 // Major version component of the current release
5252
versionMinor = 4 // Minor version component of the current release
53-
versionPatch = 15 // Patch version component of the current release
53+
versionPatch = 16 // Patch version component of the current release
5454
versionMeta = "stable" // Version metadata to append to the version string
5555

5656
versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle

cmd/utils/flags.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ import (
2222
"io/ioutil"
2323
"math"
2424
"math/big"
25-
"math/rand"
2625
"os"
2726
"path/filepath"
2827
"runtime"
2928
"strconv"
3029
"strings"
31-
"time"
3230

3331
"github.com/ethereum/ethash"
3432
"github.com/ethereum/go-ethereum/accounts"
@@ -667,17 +665,7 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte,
667665
}
668666
// Configure the Ethereum service
669667
accman := MakeAccountManager(ctx)
670-
671-
// initialise new random number generator
672-
rand := rand.New(rand.NewSource(time.Now().UnixNano()))
673-
// get enabled jit flag
674668
jitEnabled := ctx.GlobalBool(VMEnableJitFlag.Name)
675-
// if the jit is not enabled enable it for 10 pct of the people
676-
if !jitEnabled && rand.Float64() < 0.1 {
677-
jitEnabled = true
678-
glog.V(logger.Info).Infoln("You're one of the lucky few that will try out the JIT VM (random). If you get a consensus failure please be so kind to report this incident with the block hash that failed. You can switch to the regular VM by setting --jitvm=false")
679-
}
680-
681669
ethConf := &eth.Config{
682670
ChainConfig: MustMakeChainConfig(ctx),
683671
FastSync: ctx.GlobalBool(FastSyncFlag.Name),

core/chain_makers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (b *BlockGen) AddUncheckedReceipt(receipt *types.Receipt) {
131131
// TxNonce returns the next valid transaction nonce for the
132132
// account at addr. It panics if the account does not exist.
133133
func (b *BlockGen) TxNonce(addr common.Address) uint64 {
134-
if !b.statedb.HasAccount(addr) {
134+
if !b.statedb.Exist(addr) {
135135
panic("account does not exist")
136136
}
137137
return b.statedb.GetNonce(addr)

core/database_util_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (d *diffTest) UnmarshalJSON(b []byte) (err error) {
6262
return nil
6363
}
6464

65-
func TestDifficultyFrontier(t *testing.T) {
65+
func TestCalcDifficulty(t *testing.T) {
6666
file, err := os.Open("../tests/files/BasicTests/difficulty.json")
6767
if err != nil {
6868
t.Fatal(err)
@@ -75,9 +75,10 @@ func TestDifficultyFrontier(t *testing.T) {
7575
t.Fatal(err)
7676
}
7777

78+
config := &ChainConfig{HomesteadBlock: big.NewInt(1150000)}
7879
for name, test := range tests {
7980
number := new(big.Int).Sub(test.CurrentBlocknumber, big.NewInt(1))
80-
diff := calcDifficultyFrontier(test.CurrentTimestamp, test.ParentTimestamp, number, test.ParentDifficulty)
81+
diff := CalcDifficulty(config, test.CurrentTimestamp, test.ParentTimestamp, number, test.ParentDifficulty)
8182
if diff.Cmp(test.CurrentDifficulty) != 0 {
8283
t.Error(name, "failed. Expected", test.CurrentDifficulty, "and calculated", diff)
8384
}

core/execution.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A
8585
createAccount = true
8686
}
8787

88-
snapshotPreTransfer := env.MakeSnapshot()
88+
snapshotPreTransfer := env.SnapshotDatabase()
8989
var (
9090
from = env.Db().GetAccount(caller.Address())
9191
to vm.Account
@@ -129,7 +129,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A
129129
if err != nil && (env.RuleSet().IsHomestead(env.BlockNumber()) || err != vm.CodeStoreOutOfGasError) {
130130
contract.UseGas(contract.Gas)
131131

132-
env.SetSnapshot(snapshotPreTransfer)
132+
env.RevertToSnapshot(snapshotPreTransfer)
133133
}
134134

135135
return ret, addr, err
@@ -144,7 +144,7 @@ func execDelegateCall(env vm.Environment, caller vm.ContractRef, originAddr, toA
144144
return nil, common.Address{}, vm.DepthError
145145
}
146146

147-
snapshot := env.MakeSnapshot()
147+
snapshot := env.SnapshotDatabase()
148148

149149
var to vm.Account
150150
if !env.Db().Exist(*toAddr) {
@@ -162,7 +162,7 @@ func execDelegateCall(env vm.Environment, caller vm.ContractRef, originAddr, toA
162162
if err != nil {
163163
contract.UseGas(contract.Gas)
164164

165-
env.SetSnapshot(snapshot)
165+
env.RevertToSnapshot(snapshot)
166166
}
167167

168168
return ret, addr, err

core/state/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (self *StateDB) RawDump() Dump {
5252
panic(err)
5353
}
5454

55-
obj := NewObject(common.BytesToAddress(addr), data, nil)
55+
obj := newObject(nil, common.BytesToAddress(addr), data, nil)
5656
account := DumpAccount{
5757
Balance: data.Balance.String(),
5858
Nonce: data.Nonce,

core/state/journal.go

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright 2016 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package state
18+
19+
import (
20+
"math/big"
21+
22+
"github.com/ethereum/go-ethereum/common"
23+
)
24+
25+
type journalEntry interface {
26+
undo(*StateDB)
27+
}
28+
29+
type journal []journalEntry
30+
31+
type (
32+
// Changes to the account trie.
33+
createObjectChange struct {
34+
account *common.Address
35+
}
36+
resetObjectChange struct {
37+
prev *StateObject
38+
}
39+
suicideChange struct {
40+
account *common.Address
41+
prev bool // whether account had already suicided
42+
prevbalance *big.Int
43+
}
44+
45+
// Changes to individual accounts.
46+
balanceChange struct {
47+
account *common.Address
48+
prev *big.Int
49+
}
50+
nonceChange struct {
51+
account *common.Address
52+
prev uint64
53+
}
54+
storageChange struct {
55+
account *common.Address
56+
key, prevalue common.Hash
57+
}
58+
codeChange struct {
59+
account *common.Address
60+
prevcode, prevhash []byte
61+
}
62+
63+
// Changes to other state values.
64+
refundChange struct {
65+
prev *big.Int
66+
}
67+
addLogChange struct {
68+
txhash common.Hash
69+
}
70+
)
71+
72+
func (ch createObjectChange) undo(s *StateDB) {
73+
s.GetStateObject(*ch.account).deleted = true
74+
delete(s.stateObjects, *ch.account)
75+
delete(s.stateObjectsDirty, *ch.account)
76+
}
77+
78+
func (ch resetObjectChange) undo(s *StateDB) {
79+
s.setStateObject(ch.prev)
80+
}
81+
82+
func (ch suicideChange) undo(s *StateDB) {
83+
obj := s.GetStateObject(*ch.account)
84+
if obj != nil {
85+
obj.suicided = ch.prev
86+
obj.setBalance(ch.prevbalance)
87+
}
88+
}
89+
90+
func (ch balanceChange) undo(s *StateDB) {
91+
s.GetStateObject(*ch.account).setBalance(ch.prev)
92+
}
93+
94+
func (ch nonceChange) undo(s *StateDB) {
95+
s.GetStateObject(*ch.account).setNonce(ch.prev)
96+
}
97+
98+
func (ch codeChange) undo(s *StateDB) {
99+
s.GetStateObject(*ch.account).setCode(common.BytesToHash(ch.prevhash), ch.prevcode)
100+
}
101+
102+
func (ch storageChange) undo(s *StateDB) {
103+
s.GetStateObject(*ch.account).setState(ch.key, ch.prevalue)
104+
}
105+
106+
func (ch refundChange) undo(s *StateDB) {
107+
s.refund = ch.prev
108+
}
109+
110+
func (ch addLogChange) undo(s *StateDB) {
111+
logs := s.logs[ch.txhash]
112+
if len(logs) == 1 {
113+
delete(s.logs, ch.txhash)
114+
} else {
115+
s.logs[ch.txhash] = logs[:len(logs)-1]
116+
}
117+
}

0 commit comments

Comments
 (0)