Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
a0303ff4bd | |||
bf2d4e1e1e | |||
f0c7af0477 | |||
34c85d58a4 | |||
969eb61886 | |||
7fbf990cc9 | |||
d051274691 |
@ -50,7 +50,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ClientIdentifier = "Geth"
|
ClientIdentifier = "Geth"
|
||||||
Version = "1.0.1"
|
Version = "1.0.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -20,8 +20,5 @@ import "github.com/ethereum/go-ethereum/common"
|
|||||||
|
|
||||||
// Set of manually tracked bad hashes (usually hard forks)
|
// Set of manually tracked bad hashes (usually hard forks)
|
||||||
var BadHashes = map[common.Hash]bool{
|
var BadHashes = map[common.Hash]bool{
|
||||||
common.HexToHash("f269c503aed286caaa0d114d6a5320e70abbc2febe37953207e76a2873f2ba79"): true,
|
common.HexToHash("05bef30ef572270f654746da22639a7a0c97dd97a7050b9e252391996aaeb689"): true,
|
||||||
common.HexToHash("38f5bbbffd74804820ffa4bab0cd540e9de229725afb98c1a7e57936f4a714bc"): true,
|
|
||||||
common.HexToHash("7064455b364775a16afbdecd75370e912c6e2879f202eda85b9beae547fff3ac"): true,
|
|
||||||
common.HexToHash("5b7c80070a6eff35f3eb3181edb023465c776d40af2885571e1bc4689f3a44d8"): true,
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
jeff = common.HexToAddress("a8edb1ac2c86d3d9d78f96cd18001f60df29e52c")
|
jeff = common.HexToAddress("959c33de5961820567930eccce51ea715c496f85")
|
||||||
vitalik = common.HexToAddress("1baf27b88c48dd02b744999cf3522766929d2b2a")
|
vitalik = common.HexToAddress("c8158da0b567a8cc898991c2c2a073af67dc03a9")
|
||||||
christoph = common.HexToAddress("60d11b58744784dc97f878f7e3749c0f1381a004")
|
christoph = common.HexToAddress("7a19a893f91d5b6e2cdf941b6acbba2cbcf431ee")
|
||||||
gav = common.HexToAddress("4bb7e8ae99b645c2b7860b8f3a2328aae28bd80a")
|
gav = common.HexToAddress("539dd9aaf45c3feb03f9c004f4098bd3268fef6b")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Canary will check the 0'd address of the 4 contracts above.
|
// Canary will check the 0'd address of the 4 contracts above.
|
||||||
|
@ -83,6 +83,7 @@ type StateObject struct {
|
|||||||
// When an object is marked for deletion it will be delete from the trie
|
// When an object is marked for deletion it will be delete from the trie
|
||||||
// during the "update" phase of the state transition
|
// during the "update" phase of the state transition
|
||||||
remove bool
|
remove bool
|
||||||
|
deleted bool
|
||||||
dirty bool
|
dirty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,18 +203,20 @@ func (self *StateDB) UpdateStateObject(stateObject *StateObject) {
|
|||||||
|
|
||||||
// Delete the given state object and delete it from the state trie
|
// Delete the given state object and delete it from the state trie
|
||||||
func (self *StateDB) DeleteStateObject(stateObject *StateObject) {
|
func (self *StateDB) DeleteStateObject(stateObject *StateObject) {
|
||||||
|
stateObject.deleted = true
|
||||||
|
|
||||||
addr := stateObject.Address()
|
addr := stateObject.Address()
|
||||||
self.trie.Delete(addr[:])
|
self.trie.Delete(addr[:])
|
||||||
|
|
||||||
//delete(self.stateObjects, addr.Str())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve a state object given my the address. Nil if not found
|
// Retrieve a state object given my the address. Nil if not found
|
||||||
func (self *StateDB) GetStateObject(addr common.Address) *StateObject {
|
func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObject) {
|
||||||
//addr = common.Address(addr)
|
stateObject = self.stateObjects[addr.Str()]
|
||||||
|
|
||||||
stateObject := self.stateObjects[addr.Str()]
|
|
||||||
if stateObject != nil {
|
if stateObject != nil {
|
||||||
|
if stateObject.deleted {
|
||||||
|
stateObject = nil
|
||||||
|
}
|
||||||
|
|
||||||
return stateObject
|
return stateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +238,7 @@ func (self *StateDB) SetStateObject(object *StateObject) {
|
|||||||
// Retrieve a state object or create a new state object if nil
|
// Retrieve a state object or create a new state object if nil
|
||||||
func (self *StateDB) GetOrNewStateObject(addr common.Address) *StateObject {
|
func (self *StateDB) GetOrNewStateObject(addr common.Address) *StateObject {
|
||||||
stateObject := self.GetStateObject(addr)
|
stateObject := self.GetStateObject(addr)
|
||||||
if stateObject == nil {
|
if stateObject == nil || stateObject.deleted {
|
||||||
stateObject = self.CreateAccount(addr)
|
stateObject = self.CreateAccount(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ func runBlockTests(bt map[string]*BlockTest, skipTests []string) error {
|
|||||||
|
|
||||||
// test the block
|
// test the block
|
||||||
if err := runBlockTest(test); err != nil {
|
if err := runBlockTest(test); err != nil {
|
||||||
return err
|
return fmt.Errorf("%s: %v", name, err)
|
||||||
}
|
}
|
||||||
glog.Infoln("Block test passed: ", name)
|
glog.Infoln("Block test passed: ", name)
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
11
xeth/xeth.go
11
xeth/xeth.go
@ -20,8 +20,10 @@ package xeth
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ var (
|
|||||||
defaultGasPrice = big.NewInt(10000000000000) //150000000000
|
defaultGasPrice = big.NewInt(10000000000000) //150000000000
|
||||||
defaultGas = big.NewInt(90000) //500000
|
defaultGas = big.NewInt(90000) //500000
|
||||||
dappStorePre = []byte("dapp-")
|
dappStorePre = []byte("dapp-")
|
||||||
|
addrReg = regexp.MustCompile(`^(0x)?[a-fA-F0-9]{40}$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// byte will be inferred
|
// byte will be inferred
|
||||||
@ -878,6 +881,10 @@ func (self *XEth) Sign(fromStr, hashStr string, didUnlock bool) (string, error)
|
|||||||
return common.ToHex(sig), nil
|
return common.ToHex(sig), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isAddress(addr string) bool {
|
||||||
|
return addrReg.MatchString(addr)
|
||||||
|
}
|
||||||
|
|
||||||
func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
|
func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
|
||||||
|
|
||||||
// this minimalistic recoding is enough (works for natspec.js)
|
// this minimalistic recoding is enough (works for natspec.js)
|
||||||
@ -887,6 +894,10 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(toStr) > 0 && toStr != "0x" && !isAddress(toStr) {
|
||||||
|
return "", errors.New("Invalid address")
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
from = common.HexToAddress(fromStr)
|
from = common.HexToAddress(fromStr)
|
||||||
to = common.HexToAddress(toStr)
|
to = common.HexToAddress(toStr)
|
||||||
|
26
xeth/xeth_test.go
Normal file
26
xeth/xeth_test.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package xeth
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsAddress(t *testing.T) {
|
||||||
|
for _, invalid := range []string{
|
||||||
|
"0x00",
|
||||||
|
"0xNN",
|
||||||
|
"0x00000000000000000000000000000000000000NN",
|
||||||
|
"0xAAar000000000000000000000000000000000000",
|
||||||
|
} {
|
||||||
|
if isAddress(invalid) {
|
||||||
|
t.Error("Expected", invalid, "to be invalid")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, valid := range []string{
|
||||||
|
"0x0000000000000000000000000000000000000000",
|
||||||
|
"0xAABBbbCCccff9900000000000000000000000000",
|
||||||
|
"AABBbbCCccff9900000000000000000000000000",
|
||||||
|
} {
|
||||||
|
if !isAddress(valid) {
|
||||||
|
t.Error("Expected", valid, "to be valid")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user