Skip to content

Commit bf2d4e1

Browse files
committed
Merge branch 'release/1.0.1'
2 parents 82ef26f + f0c7af0 commit bf2d4e1

File tree

8 files changed

+826
-169
lines changed

8 files changed

+826
-169
lines changed

core/blocks.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@ import "github.com/ethereum/go-ethereum/common"
2020

2121
// Set of manually tracked bad hashes (usually hard forks)
2222
var BadHashes = map[common.Hash]bool{
23-
common.HexToHash("f269c503aed286caaa0d114d6a5320e70abbc2febe37953207e76a2873f2ba79"): true,
24-
common.HexToHash("38f5bbbffd74804820ffa4bab0cd540e9de229725afb98c1a7e57936f4a714bc"): true,
25-
common.HexToHash("7064455b364775a16afbdecd75370e912c6e2879f202eda85b9beae547fff3ac"): true,
26-
common.HexToHash("5b7c80070a6eff35f3eb3181edb023465c776d40af2885571e1bc4689f3a44d8"): true,
23+
common.HexToHash("05bef30ef572270f654746da22639a7a0c97dd97a7050b9e252391996aaeb689"): true,
2724
}

core/canary.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
)
2525

2626
var (
27-
jeff = common.HexToAddress("a8edb1ac2c86d3d9d78f96cd18001f60df29e52c")
28-
vitalik = common.HexToAddress("1baf27b88c48dd02b744999cf3522766929d2b2a")
29-
christoph = common.HexToAddress("60d11b58744784dc97f878f7e3749c0f1381a004")
30-
gav = common.HexToAddress("4bb7e8ae99b645c2b7860b8f3a2328aae28bd80a")
27+
jeff = common.HexToAddress("959c33de5961820567930eccce51ea715c496f85")
28+
vitalik = common.HexToAddress("c8158da0b567a8cc898991c2c2a073af67dc03a9")
29+
christoph = common.HexToAddress("7a19a893f91d5b6e2cdf941b6acbba2cbcf431ee")
30+
gav = common.HexToAddress("539dd9aaf45c3feb03f9c004f4098bd3268fef6b")
3131
)
3232

3333
// Canary will check the 0'd address of the 4 contracts above.

core/state/state_object.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ type StateObject struct {
8282
// Mark for deletion
8383
// When an object is marked for deletion it will be delete from the trie
8484
// during the "update" phase of the state transition
85-
remove bool
86-
dirty bool
85+
remove bool
86+
deleted bool
87+
dirty bool
8788
}
8889

8990
func (self *StateObject) Reset() {

core/state/statedb.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,20 @@ func (self *StateDB) UpdateStateObject(stateObject *StateObject) {
203203

204204
// Delete the given state object and delete it from the state trie
205205
func (self *StateDB) DeleteStateObject(stateObject *StateObject) {
206+
stateObject.deleted = true
207+
206208
addr := stateObject.Address()
207209
self.trie.Delete(addr[:])
208-
209-
//delete(self.stateObjects, addr.Str())
210210
}
211211

212212
// Retrieve a state object given my the address. Nil if not found
213-
func (self *StateDB) GetStateObject(addr common.Address) *StateObject {
214-
//addr = common.Address(addr)
215-
216-
stateObject := self.stateObjects[addr.Str()]
213+
func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObject) {
214+
stateObject = self.stateObjects[addr.Str()]
217215
if stateObject != nil {
216+
if stateObject.deleted {
217+
stateObject = nil
218+
}
219+
218220
return stateObject
219221
}
220222

@@ -236,7 +238,7 @@ func (self *StateDB) SetStateObject(object *StateObject) {
236238
// Retrieve a state object or create a new state object if nil
237239
func (self *StateDB) GetOrNewStateObject(addr common.Address) *StateObject {
238240
stateObject := self.GetStateObject(addr)
239-
if stateObject == nil {
241+
if stateObject == nil || stateObject.deleted {
240242
stateObject = self.CreateAccount(addr)
241243
}
242244

tests/block_test_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func runBlockTests(bt map[string]*BlockTest, skipTests []string) error {
150150

151151
// test the block
152152
if err := runBlockTest(test); err != nil {
153-
return err
153+
return fmt.Errorf("%s: %v", name, err)
154154
}
155155
glog.Infoln("Block test passed: ", name)
156156

tests/files/BlockchainTests/bcValidBlockTest.json

Lines changed: 771 additions & 151 deletions
Large diffs are not rendered by default.

xeth/xeth.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ package xeth
2020
import (
2121
"bytes"
2222
"encoding/json"
23+
"errors"
2324
"fmt"
2425
"math/big"
26+
"regexp"
2527
"sync"
2628
"time"
2729

@@ -45,6 +47,7 @@ var (
4547
defaultGasPrice = big.NewInt(10000000000000) //150000000000
4648
defaultGas = big.NewInt(90000) //500000
4749
dappStorePre = []byte("dapp-")
50+
addrReg = regexp.MustCompile(`^(0x)?[a-fA-F0-9]{40}$`)
4851
)
4952

5053
// byte will be inferred
@@ -878,6 +881,10 @@ func (self *XEth) Sign(fromStr, hashStr string, didUnlock bool) (string, error)
878881
return common.ToHex(sig), nil
879882
}
880883

884+
func isAddress(addr string) bool {
885+
return addrReg.MatchString(addr)
886+
}
887+
881888
func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
882889

883890
// this minimalistic recoding is enough (works for natspec.js)
@@ -887,6 +894,10 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
887894
return "", err
888895
}
889896

897+
if len(toStr) > 0 && toStr != "0x" && !isAddress(toStr) {
898+
return "", errors.New("Invalid address")
899+
}
900+
890901
var (
891902
from = common.HexToAddress(fromStr)
892903
to = common.HexToAddress(toStr)

xeth/xeth_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package xeth
2+
3+
import "testing"
4+
5+
func TestIsAddress(t *testing.T) {
6+
for _, invalid := range []string{
7+
"0x00",
8+
"0xNN",
9+
"0x00000000000000000000000000000000000000NN",
10+
"0xAAar000000000000000000000000000000000000",
11+
} {
12+
if isAddress(invalid) {
13+
t.Error("Expected", invalid, "to be invalid")
14+
}
15+
}
16+
17+
for _, valid := range []string{
18+
"0x0000000000000000000000000000000000000000",
19+
"0xAABBbbCCccff9900000000000000000000000000",
20+
"AABBbbCCccff9900000000000000000000000000",
21+
} {
22+
if !isAddress(valid) {
23+
t.Error("Expected", valid, "to be valid")
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)