aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--Godeps/Godeps.json4
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go4
-rw-r--r--Makefile22
-rwxr-xr-xbuild/env.sh28
-rw-r--r--cmd/geth/admin.go85
-rw-r--r--cmd/geth/js.go18
-rw-r--r--cmd/geth/main.go24
-rw-r--r--cmd/rlpdump/main.go2
-rw-r--r--cmd/utils/cmd.go2
-rw-r--r--cmd/utils/flags.go67
-rw-r--r--common/bytes.go17
-rw-r--r--common/docserver/docserver.go82
-rw-r--r--common/docserver/docserver_test.go38
-rw-r--r--common/natspec/natspec.go195
-rw-r--r--common/natspec/natspec_e2e_test.go340
-rw-r--r--common/natspec/natspec_js.go4042
-rw-r--r--common/natspec/natspec_test.go142
-rw-r--r--common/resolver/contracts.go36
-rw-r--r--common/resolver/resolver.go128
-rw-r--r--common/resolver/resolver_test.go88
-rw-r--r--core/block_processor.go35
-rw-r--r--core/blocks.go7
-rw-r--r--core/chain_makers.go4
-rw-r--r--core/chain_manager.go68
-rw-r--r--core/chain_manager_test.go7
-rw-r--r--core/genesis.go5
-rw-r--r--core/types/block.go16
-rw-r--r--core/types/common.go2
-rw-r--r--core/types/transaction.go2
-rw-r--r--crypto/crypto.go5
-rw-r--r--eth/backend.go68
-rw-r--r--eth/downloader/downloader.go272
-rw-r--r--eth/downloader/downloader_test.go7
-rw-r--r--eth/downloader/peer.go24
-rw-r--r--eth/downloader/queue.go31
-rw-r--r--eth/downloader/synchronous.go79
-rw-r--r--eth/handler.go335
-rw-r--r--eth/peer.go145
-rw-r--r--eth/protocol.go331
-rw-r--r--eth/protocol_test.go18
-rw-r--r--miner/miner.go12
-rw-r--r--miner/remote_agent.go13
-rw-r--r--miner/worker.go14
-rw-r--r--p2p/discover/udp.go2
-rw-r--r--p2p/message.go3
-rw-r--r--p2p/peer_error.go2
-rw-r--r--p2p/server.go11
-rw-r--r--rlp/decode.go332
-rw-r--r--rlp/decode_test.go287
-rw-r--r--rlp/encode.go8
-rw-r--r--rlp/typecache.go51
-rw-r--r--rpc/api.go12
-rw-r--r--rpc/args.go2
-rw-r--r--tests/blocktest.go46
-rw-r--r--tests/files/BlockTests/bcForkBlockTest.json367
-rw-r--r--tests/files/BlockTests/bcInvalidRLPTest.json52
-rw-r--r--tests/files/BlockTests/bcRPC_API_Test.json1257
-rw-r--r--tests/files/StateTests/RandomTests/st201504081928CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504081953JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504081954JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504081955JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504081956JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504081957JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504082000JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504082001JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504082002JAVA.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504090553CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504090657CPPJIT.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201504091403CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504091641CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504092303CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504100125CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504100215CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504100226PYTHON.json86
-rw-r--r--tests/files/StateTests/RandomTests/st201504100308CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504100337CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504100341CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504101009CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504101150CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504101223CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504101338CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504101754PYTHON.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504111554CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504130653JS.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140229CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140236CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140359CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140750CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140818CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201504140900CPPJIT.json71
-rw-r--r--tests/files/TransactionTests/ttTransactionTest.json341
-rw-r--r--tests/files/TransactionTests/ttWrongRLPTransaction.json8
-rw-r--r--tests/transaction_test.go29
-rw-r--r--tests/transaction_test_util.go19
-rw-r--r--ui/qt/qwhisper/whisper.go4
-rw-r--r--whisper/envelope.go38
-rw-r--r--whisper/filter.go11
-rw-r--r--whisper/main.go4
-rw-r--r--whisper/message.go26
-rw-r--r--whisper/message_test.go24
-rw-r--r--whisper/peer.go172
-rw-r--r--whisper/peer_test.go242
-rw-r--r--whisper/sort.go29
-rw-r--r--whisper/sort_test.go23
-rw-r--r--whisper/topic.go61
-rw-r--r--whisper/topic_test.go67
-rw-r--r--whisper/util.go36
-rw-r--r--whisper/whisper.go334
-rw-r--r--whisper/whisper_test.go189
-rw-r--r--xeth/frontend.go10
-rw-r--r--xeth/whisper.go4
-rw-r--r--xeth/xeth.go10
113 files changed, 11869 insertions, 1472 deletions
diff --git a/.gitignore b/.gitignore
index e72867f28..43061642a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,8 @@ mist
cmd/mist/mist
deploy/osx/Mist.app
deploy/osx/Mist\ Installer.dmg
+
+# used by the Makefile
+/build/_workspace/
+/build/bin/
+
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index c51a2312b..bc5e3144a 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -22,8 +22,8 @@
},
{
"ImportPath": "github.com/ethereum/ethash",
- "Comment": "v23.1-81-g4039fd0",
- "Rev": "4039fd095084679fb0bf3feae91d02506b5d67aa"
+ "Comment": "v23.1-82-g908aad3",
+ "Rev": "908aad345c9fbf3ab9bbb94031dc02d0d90df1b8"
},
{
"ImportPath": "github.com/ethereum/serpent-go",
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
index c33bfccc4..74285a33c 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
@@ -91,7 +91,7 @@ func makeParamsAndCache(chainManager pow.ChainManager, blockNum uint64) (*Params
return nil, err
}
- glog.V(logger.Info).Infoln("Making cache")
+ glog.V(logger.Info).Infof("Making cache for epoch: %d (%v) (%x)\n", paramsAndCache.Epoch, blockNum, seedHash)
start := time.Now()
C.ethash_mkcache(paramsAndCache.cache, paramsAndCache.params, (*C.ethash_blockhash_t)(unsafe.Pointer(&seedHash[0])))
@@ -387,7 +387,7 @@ func (pow *Ethash) verify(hash common.Hash, mixDigest common.Hash, difficulty *b
if blockNum/epochLength < pow.paramsAndCache.Epoch {
var err error
// If we can't make the params for some reason, this block is invalid
- pAc, err = makeParamsAndCache(pow.chainManager, blockNum+1)
+ pAc, err = makeParamsAndCache(pow.chainManager, blockNum)
if err != nil {
glog.V(logger.Info).Infoln("big fucking eror", err)
return false
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..1fdc36f98
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,22 @@
+# This Makefile is meant to be used by people that do not usually work
+# with Go source code. If you know what GOPATH is then you probably
+# don't need to bother with make.
+#
+# Note that there is no way to run the tests or do anything other than
+# building the binaries. This is by design.
+
+.PHONY: geth mist clean
+GOBIN = build/bin
+
+geth:
+ build/env.sh go install -v github.com/ethereum/go-ethereum/cmd/geth
+ @echo "Done building."
+ @echo "Run \"$(GOBIN)/geth\" to launch geth."
+
+mist:
+ build/env.sh go install -v github.com/ethereum/go-ethereum/cmd/mist
+ @echo "Done building."
+ @echo "Run \"$(GOBIN)/mist --asset_path=cmd/mist/assets\" to launch mist."
+
+clean:
+ rm -fr build/_workspace/pkg/ $(GOBIN)/*
diff --git a/build/env.sh b/build/env.sh
new file mode 100755
index 000000000..b28ad6259
--- /dev/null
+++ b/build/env.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+if [ ! -f "build/env.sh" ]; then
+ echo "$0 must be run from the root of the repository."
+ exit 2
+fi
+
+# Create fake Go workspace if it doesn't exist yet.
+workspace="$PWD/build/_workspace"
+root="$PWD"
+ethdir="$workspace/src/github.com/ethereum"
+if [ ! -L "$ethdir/go-ethereum" ]; then
+ mkdir -p "$ethdir"
+ cd "$ethdir"
+ ln -s ../../../../../. go-ethereum
+ cd "$root"
+fi
+
+# Set up the environment to use the workspace.
+# Also add Godeps workspace so we build using canned dependencies.
+GOPATH="$ethdir/go-ethereum/Godeps/_workspace:$workspace"
+GOBIN="$PWD/build/bin"
+export GOPATH GOBIN
+
+# Launch the arguments with the configured environment.
+exec $@
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 3b37cba75..bd09291bf 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -1,6 +1,7 @@
package main
import (
+ "errors"
"fmt"
"os"
"time"
@@ -9,6 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
@@ -35,6 +37,7 @@ func (js *jsre) adminBindings() {
admin.Set("export", js.exportChain)
admin.Set("verbosity", js.verbosity)
admin.Set("backtrace", js.backtrace)
+ admin.Set("progress", js.downloadProgress)
admin.Set("miner", struct{}{})
t, _ = admin.Get("miner")
@@ -49,6 +52,88 @@ func (js *jsre) adminBindings() {
debug := t.Object()
debug.Set("printBlock", js.printBlock)
debug.Set("dumpBlock", js.dumpBlock)
+ debug.Set("getBlockRlp", js.getBlockRlp)
+ debug.Set("setHead", js.setHead)
+ debug.Set("block", js.debugBlock)
+}
+
+func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
+ var block *types.Block
+ if len(call.ArgumentList) > 0 {
+ if call.Argument(0).IsNumber() {
+ num, _ := call.Argument(0).ToInteger()
+ block = js.ethereum.ChainManager().GetBlockByNumber(uint64(num))
+ } else if call.Argument(0).IsString() {
+ hash, _ := call.Argument(0).ToString()
+ block = js.ethereum.ChainManager().GetBlock(common.HexToHash(hash))
+ } else {
+ return nil, errors.New("invalid argument for dump. Either hex string or number")
+ }
+ return block, nil
+ }
+
+ return nil, errors.New("requires block number or block hash as argument")
+}
+
+func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
+ block, err := js.getBlock(call)
+ if err != nil {
+ fmt.Println(err)
+ return otto.UndefinedValue()
+ }
+
+ if block == nil {
+ fmt.Println("block not found")
+ return otto.UndefinedValue()
+ }
+
+ old := vm.Debug
+ vm.Debug = true
+ _, err = js.ethereum.BlockProcessor().RetryProcess(block)
+ if err != nil {
+ glog.Infoln(err)
+ }
+ vm.Debug = old
+
+ return otto.UndefinedValue()
+}
+
+func (js *jsre) setHead(call otto.FunctionCall) otto.Value {
+ block, err := js.getBlock(call)
+ if err != nil {
+ fmt.Println(err)
+ return otto.UndefinedValue()
+ }
+
+ if block == nil {
+ fmt.Println("block not found")
+ return otto.UndefinedValue()
+ }
+
+ js.ethereum.ChainManager().SetHead(block)
+ return otto.UndefinedValue()
+}
+
+func (js *jsre) downloadProgress(call otto.FunctionCall) otto.Value {
+ current, max := js.ethereum.Downloader().Stats()
+
+ return js.re.ToVal(fmt.Sprintf("%d/%d", current, max))
+}
+
+func (js *jsre) getBlockRlp(call otto.FunctionCall) otto.Value {
+ block, err := js.getBlock(call)
+ if err != nil {
+ fmt.Println(err)
+ return otto.UndefinedValue()
+ }
+
+ if block == nil {
+ fmt.Println("block not found")
+ return otto.UndefinedValue()
+ }
+
+ encoded, _ := rlp.EncodeToBytes(block)
+ return js.re.ToVal(fmt.Sprintf("%x", encoded))
}
func (js *jsre) setExtra(call otto.FunctionCall) otto.Value {
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 0061f20cf..6e5a6f1c7 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -25,7 +25,8 @@ import (
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/common/docserver"
+ "github.com/ethereum/go-ethereum/common/natspec"
"github.com/ethereum/go-ethereum/eth"
re "github.com/ethereum/go-ethereum/jsre"
"github.com/ethereum/go-ethereum/rpc"
@@ -139,10 +140,17 @@ var net = web3.net;
js.re.Eval(globalRegistrar + "registrar = new GlobalRegistrar(\"" + globalRegistrarAddr + "\");")
}
-func (self *jsre) ConfirmTransaction(tx *types.Transaction) bool {
- p := fmt.Sprintf("Confirm Transaction %v\n[y/n] ", tx)
- answer, _ := self.Prompt(p)
- return strings.HasPrefix(strings.Trim(answer, " "), "y")
+var ds, _ = docserver.New(utils.JSpathFlag.String())
+
+func (self *jsre) ConfirmTransaction(tx string) bool {
+ if self.ethereum.NatSpec {
+ notice := natspec.GetNotice(self.xeth, tx, ds)
+ fmt.Println(notice)
+ answer, _ := self.Prompt("Confirm Transaction\n[y/n] ")
+ return strings.HasPrefix(strings.Trim(answer, " "), "y")
+ } else {
+ return true
+ }
}
func (self *jsre) UnlockAccount(addr []byte) bool {
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index e18b92a2e..ddbd1f129 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -24,13 +24,13 @@ import (
"bufio"
"fmt"
"io/ioutil"
- "log"
- "net/http"
"os"
"runtime"
"strconv"
"time"
+ "path"
+
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
@@ -42,13 +42,12 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
"github.com/peterh/liner"
- "path"
)
import _ "net/http/pprof"
const (
ClientIdentifier = "Geth"
- Version = "0.9.9"
+ Version = "0.9.11"
)
var app = utils.NewApp(Version, "the go-ethereum command line interface")
@@ -217,6 +216,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
},
}
app.Flags = []cli.Flag{
+ utils.IdentityFlag,
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
utils.BootnodesFlag,
@@ -229,11 +229,13 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.MinerThreadsFlag,
utils.MiningEnabledFlag,
utils.NATFlag,
+ utils.NatspecEnabledFlag,
utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag,
utils.RPCEnabledFlag,
utils.RPCListenAddrFlag,
utils.RPCPortFlag,
+ utils.WhisperEnabledFlag,
utils.VMDebugFlag,
utils.ProtocolVersionFlag,
utils.NetworkIdFlag,
@@ -244,6 +246,14 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.LogVModuleFlag,
utils.LogFileFlag,
utils.LogJSONFlag,
+ utils.PProfEanbledFlag,
+ utils.PProfPortFlag,
+ }
+ app.Before = func(ctx *cli.Context) error {
+ if ctx.GlobalBool(utils.PProfEanbledFlag.Name) {
+ utils.StartPProf(ctx)
+ }
+ return nil
}
// missing:
@@ -258,11 +268,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
}
func main() {
- // Start up the default http server for pprof
- go func() {
- log.Println(http.ListenAndServe("localhost:6060", nil))
- }()
-
fmt.Printf("Welcome to the FRONTIER\n")
runtime.GOMAXPROCS(runtime.NumCPU())
defer logger.Flush()
@@ -334,6 +339,7 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
}
func startEth(ctx *cli.Context, eth *eth.Ethereum) {
+ // Start Ethereum itself
utils.StartEthereum(eth)
am := eth.AccountManager()
diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go
index 8567dcff8..528ccc6bd 100644
--- a/cmd/rlpdump/main.go
+++ b/cmd/rlpdump/main.go
@@ -78,7 +78,7 @@ func main() {
os.Exit(2)
}
- s := rlp.NewStream(r)
+ s := rlp.NewStream(r, 0)
for {
if err := dump(s, 0); err != nil {
if err != io.EOF {
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 7286f5c5e..64faf6ad1 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -154,7 +154,7 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
defer fh.Close()
chainmgr.Reset()
- stream := rlp.NewStream(fh)
+ stream := rlp.NewStream(fh, 0)
var i, n int
batchSize := 2500
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 8141fae82..b8f3982e2 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -2,6 +2,9 @@ package utils
import (
"crypto/ecdsa"
+ "fmt"
+ "log"
+ "net/http"
"os"
"path"
"runtime"
@@ -89,6 +92,14 @@ var (
Usage: "Blockchain version",
Value: core.BlockChainVersion,
}
+ IdentityFlag = cli.StringFlag{
+ Name: "identity",
+ Usage: "node name",
+ }
+ NatspecEnabledFlag = cli.BoolFlag{
+ Name: "natspec",
+ Usage: "Enable NatSpec confirmation notice",
+ }
// miner settings
MinerThreadsFlag = cli.IntFlag{
@@ -132,10 +143,33 @@ var (
Usage: "Send json structured log output to a file or '-' for standard output (default: no json output)",
Value: "",
}
+ LogToStdErrFlag = cli.BoolFlag{
+ Name: "logtostderr",
+ Usage: "Logs are written to standard error instead of to files.",
+ }
+ LogVModuleFlag = cli.GenericFlag{
+ Name: "vmodule",
+ Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a V level.",
+ Value: glog.GetVModule(),
+ }
VMDebugFlag = cli.BoolFlag{
Name: "vmdebug",
Usage: "Virtual Machine debug output",
}
+ BacktraceAtFlag = cli.GenericFlag{
+ Name: "backtrace_at",
+ Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log",
+ Value: glog.GetTraceLocation(),
+ }
+ PProfEanbledFlag = cli.BoolFlag{
+ Name: "pprof",
+ Usage: "Whether the profiling server should be enabled",
+ }
+ PProfPortFlag = cli.IntFlag{
+ Name: "pprofport",
+ Usage: "Port on which the profiler should listen",
+ Value: 6060,
+ }
// RPC settings
RPCEnabledFlag = cli.BoolFlag{
@@ -186,25 +220,15 @@ var (
Usage: "Port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
Value: "any",
}
+ WhisperEnabledFlag = cli.BoolFlag{
+ Name: "shh",
+ Usage: "Whether the whisper sub-protocol is enabled",
+ }
JSpathFlag = cli.StringFlag{
Name: "jspath",
Usage: "JS library path to be used with console and js subcommands",
Value: ".",
}
- BacktraceAtFlag = cli.GenericFlag{
- Name: "backtrace_at",
- Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log",
- Value: glog.GetTraceLocation(),
- }
- LogToStdErrFlag = cli.BoolFlag{
- Name: "logtostderr",
- Usage: "Logs are written to standard error instead of to files.",
- }
- LogVModuleFlag = cli.GenericFlag{
- Name: "vmodule",
- Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a V level.",
- Value: glog.GetVModule(),
- }
)
func GetNAT(ctx *cli.Context) nat.Interface {
@@ -242,6 +266,11 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
// Set the log dir
glog.SetLogDir(ctx.GlobalString(LogFileFlag.Name))
+ customName := ctx.GlobalString(IdentityFlag.Name)
+ if len(customName) > 0 {
+ clientID += "/" + customName
+ }
+
return &eth.Config{
Name: common.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
@@ -259,8 +288,9 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
Port: ctx.GlobalString(ListenPortFlag.Name),
NAT: GetNAT(ctx),
+ NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
NodeKey: GetNodeKey(ctx),
- Shh: true,
+ Shh: ctx.GlobalBool(WhisperEnabledFlag.Name),
Dial: true,
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
}
@@ -310,3 +340,10 @@ func StartRPC(eth *eth.Ethereum, ctx *cli.Context) {
xeth := xeth.New(eth, nil)
_ = rpc.Start(xeth, config)
}
+
+func StartPProf(ctx *cli.Context) {
+ address := fmt.Sprintf("localhost:%d", ctx.GlobalInt(PProfPortFlag.Name))
+ go func() {
+ log.Println(http.ListenAndServe(address, nil))
+ }()
+}
diff --git a/common/bytes.go b/common/bytes.go
index 5bdacd810..5d1245107 100644
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -147,6 +147,23 @@ func Hex2Bytes(str string) []byte {
return h
}
+func Hex2BytesFixed(str string, flen int) []byte {
+
+ h, _ := hex.DecodeString(str)
+ if len(h) == flen {
+ return h
+ } else {
+ if len(h) > flen {
+ return h[len(h)-flen : len(h)]
+ } else {
+ hh := make([]byte, flen)
+ copy(hh[flen-len(h):flen], h[:])
+ return hh
+ }
+ }
+
+}
+
func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
if len(str) > 1 && str[0:2] == "0x" && !strings.Contains(str, "\n") {
ret = Hex2Bytes(str[2:])
diff --git a/common/docserver/docserver.go b/common/docserver/docserver.go
new file mode 100644
index 000000000..5e076aa7e
--- /dev/null
+++ b/common/docserver/docserver.go
@@ -0,0 +1,82 @@
+package docserver
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net/http"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
+)
+
+// http://golang.org/pkg/net/http/#RoundTripper
+var (
+ schemes = map[string]func(*DocServer) http.RoundTripper{
+ // Simple File server from local disk file:///etc/passwd :)
+ "file": fileServerOnDocRoot,
+ }
+)
+
+func fileServerOnDocRoot(ds *DocServer) http.RoundTripper {
+ return http.NewFileTransport(http.Dir(ds.DocRoot))
+}
+
+type DocServer struct {
+ *http.Transport
+ DocRoot string
+}
+
+func New(docRoot string) (self *DocServer, err error) {
+ self = &DocServer{
+ Transport: &http.Transport{},
+ DocRoot: docRoot,
+ }
+ err = self.RegisterProtocols(schemes)
+ return
+}
+
+// Clients should be reused instead of created as needed. Clients are safe for concurrent use by multiple goroutines.
+
+// A Client is higher-level than a RoundTripper (such as Transport) and additionally handles HTTP details such as cookies and redirects.
+
+func (self *DocServer) Client() *http.Client {
+ return &http.Client{
+ Transport: self,
+ }
+}
+
+func (self *DocServer) RegisterProtocols(schemes map[string]func(*DocServer) http.RoundTripper) (err error) {
+ for scheme, rtf := range schemes {
+ self.RegisterProtocol(scheme, rtf(self))
+ }
+ return
+}
+
+func (self *DocServer) GetAuthContent(uri string, hash common.Hash) (content []byte, err error) {
+ // retrieve content
+ resp, err := self.Client().Get(uri)
+ defer func() {
+ if resp != nil {
+ resp.Body.Close()
+ }
+ }()
+ if err != nil {
+ return
+ }
+ content, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return
+ }
+
+ // check hash to authenticate content
+ hashbytes := crypto.Sha3(content)
+ var chash common.Hash
+ copy(chash[:], hashbytes)
+ if chash != hash {
+ content = nil
+ err = fmt.Errorf("content hash mismatch")
+ }
+
+ return
+
+}
diff --git a/common/docserver/docserver_test.go b/common/docserver/docserver_test.go
new file mode 100644
index 000000000..400d7447a
--- /dev/null
+++ b/common/docserver/docserver_test.go
@@ -0,0 +1,38 @@
+package docserver
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
+)
+
+func TestGetAuthContent(t *testing.T) {
+ text := "test"
+ hash := common.Hash{}
+ copy(hash[:], crypto.Sha3([]byte(text)))
+ ioutil.WriteFile("/tmp/test.content", []byte(text), os.ModePerm)
+
+ ds, err := New("/tmp/")
+ content, err := ds.GetAuthContent("file:///test.content", hash)
+ if err != nil {
+ t.Errorf("no error expected, got %v", err)
+ }
+ if string(content) != text {
+ t.Errorf("incorrect content. expected %v, got %v", text, string(content))
+ }
+
+ hash = common.Hash{}
+ content, err = ds.GetAuthContent("file:///test.content", hash)
+ expected := "content hash mismatch"
+ if err == nil {
+ t.Errorf("expected error, got nothing")
+ } else {
+ if err.Error() != expected {
+ t.Errorf("expected error '%s' got '%v'", expected, err)
+ }
+ }
+
+}
diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go
index 8e6568cef..38e7c1a9d 100644
--- a/common/natspec/natspec.go
+++ b/common/natspec/natspec.go
@@ -1,20 +1,137 @@
package natspec
import (
+ "bytes"
+ "encoding/json"
"fmt"
"github.com/robertkrimen/otto"
+ "strings"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/docserver"
+ "github.com/ethereum/go-ethereum/common/resolver"
+ "github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/xeth"
)
+type abi2method map[[8]byte]*method
+
type NatSpec struct {
- jsvm *otto.Otto
+ jsvm *otto.Otto
+ userDocJson, abiDocJson []byte
+ userDoc userDoc
+ tx, data string
+ // abiDoc abiDoc
+}
+
+func getFallbackNotice(comment, tx string) string {
+
+ return "About to submit transaction (" + comment + "): " + tx
+
}
-// TODO: should initialise with abi and userdoc jsons
-func New() (self *NatSpec, err error) {
+func GetNotice(xeth *xeth.XEth, tx string, http *docserver.DocServer) (notice string) {
+
+ ns, err := New(xeth, tx, http)
+ if err != nil {
+ if ns == nil {
+ return getFallbackNotice("no NatSpec info found for contract", tx)
+ } else {
+ return getFallbackNotice("invalid NatSpec info", tx)
+ }
+ }
+
+ notice, err2 := ns.Notice()
+
+ if err2 != nil {
+ return getFallbackNotice("NatSpec notice error \""+err2.Error()+"\"", tx)
+ }
+
+ return
+
+}
+
+func New(xeth *xeth.XEth, tx string, http *docserver.DocServer) (self *NatSpec, err error) {
+
+ // extract contract address from tx
+
+ var obj map[string]json.RawMessage
+ err = json.Unmarshal([]byte(tx), &obj)
+ if err != nil {
+ return
+ }
+ var tmp []map[string]string
+ err = json.Unmarshal(obj["params"], &tmp)
+ if err != nil {
+ return
+ }
+ contractAddress := tmp[0]["to"]
- self = new(NatSpec)
- self.jsvm = otto.New()
+ // retrieve contract hash from state
+ if !xeth.IsContract(contractAddress) {
+ err = fmt.Errorf("NatSpec error: contract not found")
+ return
+ }
+ codehex := xeth.CodeAt(contractAddress)
+ codeHash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex[2:])))
+ // parse out host/domain
+ // set up nameresolver with natspecreg + urlhint contract addresses
+ res := resolver.New(
+ xeth,
+ resolver.URLHintContractAddress,
+ resolver.HashRegContractAddress,
+ )
+
+ // resolve host via HashReg/UrlHint Resolver
+ uri, hash, err := res.KeyToUrl(codeHash)
+ if err != nil {
+ return
+ }
+
+ // get content via http client and authenticate content using hash
+ content, err := http.GetAuthContent(uri, hash)
+ if err != nil {
+ return
+ }
+
+ // get abi, userdoc
+ var obj2 map[string]json.RawMessage
+ err = json.Unmarshal(content, &obj2)
+ if err != nil {
+ return
+ }
+
+ abi := []byte(obj2["abi"])
+ userdoc := []byte(obj2["userdoc"])
+
+ self, err = NewWithDocs(abi, userdoc, tx)
+ return
+}
+
+func NewWithDocs(abiDocJson, userDocJson []byte, tx string) (self *NatSpec, err error) {
+
+ var obj map[string]json.RawMessage
+ err = json.Unmarshal([]byte(tx), &obj)
+ if err != nil {
+ return
+ }
+ var tmp []map[string]string
+ err = json.Unmarshal(obj["params"], &tmp)
+ if err != nil {
+ return
+ }
+ data := tmp[0]["data"]
+
+ self = &NatSpec{
+ jsvm: otto.New(),
+ abiDocJson: abiDocJson,
+ userDocJson: userDocJson,
+ tx: tx,
+ data: data,
+ }
+
+ // load and require natspec js (but it is meant to be protected environment)
_, err = self.jsvm.Run(natspecJS)
if err != nil {
return
@@ -24,20 +141,78 @@ func New() (self *NatSpec, err error) {
return
}
+ err = json.Unmarshal(userDocJson, &self.userDoc)
+ // err = parseAbiJson(abiDocJson, &self.abiDoc)
+
return
}
-func (self *NatSpec) Notice(transaction, abi, method, expression string) (string, error) {
- var err error
- if _, err = self.jsvm.Run("var transaction = " + transaction + ";"); err != nil {
+// type abiDoc []method
+
+// type method struct {
+// Name string `json:name`
+// Inputs []input `json:inputs`
+// abiKey [8]byte
+// }
+
+// type input struct {
+// Name string `json:name`
+// Type string `json:type`
+// }
+
+// json skeleton for abi doc (contract method definitions)
+type method struct {
+ Notice string `json:notice`
+ name string
+}
+
+type userDoc struct {
+ Methods map[string]*method `json:methods`
+}
+
+func (self *NatSpec) makeAbi2method(abiKey [8]byte) (meth *method) {
+ for signature, m := range self.userDoc.Methods {
+ name := strings.Split(signature, "(")[0]
+ hash := []byte(common.Bytes2Hex(crypto.Sha3([]byte(signature))))
+ var key [8]byte
+ copy(key[:], hash[:8])
+ if bytes.Equal(key[:], abiKey[:]) {
+ meth = m
+ meth.name = name
+ return
+ }
+ }
+ return
+}
+
+func (self *NatSpec) Notice() (notice string, err error) {
+ var abiKey [8]byte
+ if len(self.data) < 10 {
+ err = fmt.Errorf("Invalid transaction data")
+ return
+ }
+ copy(abiKey[:], self.data[2:10])
+ meth := self.makeAbi2method(abiKey)
+
+ if meth == nil {
+ err = fmt.Errorf("abi key does not match any method")
+ return
+ }
+ notice, err = self.noticeForMethod(self.tx, meth.name, meth.Notice)
+ return
+}
+
+func (self *NatSpec) noticeForMethod(tx string, name, expression string) (notice string, err error) {
+
+ if _, err = self.jsvm.Run("var transaction = " + tx + ";"); err != nil {
return "", fmt.Errorf("natspec.js error setting transaction: %v", err)
}
- if _, err = self.jsvm.Run("var abi = " + abi + ";"); err != nil {
+ if _, err = self.jsvm.Run("var abi = " + string(self.abiDocJson) + ";"); err != nil {
return "", fmt.Errorf("natspec.js error setting abi: %v", err)
}
- if _, err = self.jsvm.Run("var method = '" + method + "';"); err != nil {
+ if _, err = self.jsvm.Run("var method = '" + name + "';"); err != nil {
return "", fmt.Errorf("natspec.js error setting method: %v", err)
}
diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go
new file mode 100644
index 000000000..147abe162
--- /dev/null
+++ b/common/natspec/natspec_e2e_test.go
@@ -0,0 +1,340 @@
+package natspec
+
+import (
+ "io/ioutil"
+ "math/big"
+ "os"
+ "testing"
+
+ "github.com/ethereum/go-ethereum/accounts"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/docserver"
+ "github.com/ethereum/go-ethereum/common/resolver"
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/state"
+ "github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/rpc"
+ xe "github.com/ethereum/go-ethereum/xeth"
+)
+
+type testFrontend struct {
+ t *testing.T
+ ethereum *eth.Ethereum
+ xeth *xe.XEth
+ api *rpc.EthereumApi
+ coinbase string
+ stateDb *state.StateDB
+ txc uint64
+ lastConfirm string
+ makeNatSpec bool
+}
+
+const (
+ testAccount = "e273f01c99144c438695e10f24926dc1f9fbf62d"
+ testBalance = "1000000000000"
+)
+
+const testFileName = "long_file_name_for_testing_registration_of_URLs_longer_than_32_bytes.content"
+
+const testNotice = "Register key `utils.toHex(_key)` <- content `utils.toHex(_content)`"
+const testExpNotice = "Register key 0xadd1a7d961cff0242089674ec2ef6fca671ab15e1fe80e38859fc815b98d88ab <- content 0xc00d5bcc872e17813df6ec5c646bb281a6e2d3b454c2c400c78192adf3344af9"
+const testExpNotice2 = `About to submit transaction (NatSpec notice error "abi key does not match any method"): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0xb737b91f8e95cf756766fc7c62c9a8ff58470381","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0x31e12c20"}]}`
+const testExpNotice3 = `About to submit transaction (no NatSpec info found for contract): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0x8b839ad85686967a4f418eccc81962eaee314ac3","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0x300a3bbfc00d5bcc872e17813df6ec5c646bb281a6e2d3b454c2c400c78192adf3344af900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"}]}`
+
+const testUserDoc = `
+{
+ "source": "...",
+ "language": "Solidity",
+ "languageVersion": 1,
+ "methods": {
+ "register(uint256,uint256)": {
+ "notice": "` + testNotice + `"
+ }
+ },
+ "invariants": [
+ { "notice": "" }
+ ],
+ "construction": [
+ { "notice": "" }
+ ]
+}
+`
+
+const testABI = `
+[{
+ "name": "register",
+ "constant": false,
+ "type": "function",
+ "inputs": [{
+ "name": "_key",
+ "type": "uint256"
+ }, {
+ "name": "_content",
+ "type": "uint256"
+ }],
+ "outputs": []
+}]
+`
+
+const testDocs = `
+{
+ "userdoc": ` + testUserDoc + `,
+ "abi": ` + testABI + `
+}
+`
+
+func (f *testFrontend) UnlockAccount(acc []byte) bool {
+ f.t.Logf("Unlocking account %v\n", common.Bytes2Hex(acc))
+ f.ethereum.AccountManager().Unlock(acc, "password")
+ return true
+}
+
+func (f *testFrontend) ConfirmTransaction(tx string) bool {
+ //f.t.Logf("ConfirmTransaction called tx = %v", tx)
+ if f.makeNatSpec {
+ ds, err := docserver.New("/tmp/")
+ if err != nil {
+ f.t.Errorf("Error creating DocServer: %v", err)
+ }
+ f.lastConfirm = GetNotice(f.xeth, tx, ds)
+ }
+ return true
+}
+
+var port = 30300
+
+func testEth(t *testing.T) (ethereum *eth.Ethereum, err error) {
+ os.RemoveAll("/tmp/eth-natspec/")
+ err = os.MkdirAll("/tmp/eth-natspec/keys/e273f01c99144c438695e10f24926dc1f9fbf62d/", os.ModePerm)
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+ err = os.MkdirAll("/tmp/eth-natspec/data", os.ModePerm)
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+ ks := crypto.NewKeyStorePlain("/tmp/eth-natspec/keys")
+ ioutil.WriteFile("/tmp/eth-natspec/keys/e273f01c99144c438695e10f24926dc1f9fbf62d/e273f01c99144c438695e10f24926dc1f9fbf62d",
+ []byte(`{"Id":"RhRXD+fNRKS4jx+7ZfEsNA==","Address":"4nPwHJkUTEOGleEPJJJtwfn79i0=","PrivateKey":"h4ACVpe74uIvi5Cg/2tX/Yrm2xdr3J7QoMbMtNX2CNc="}`), os.ModePerm)
+
+ port++
+ ethereum, err = eth.New(&eth.Config{
+ DataDir: "/tmp/eth-natspec",
+ AccountManager: accounts.NewManager(ks),
+ Name: "test",
+ })
+
+ if err != nil {
+ t.Errorf("%v", err)
+ return
+ }
+
+ return
+}
+
+func testInit(t *testing.T) (self *testFrontend) {
+
+ core.GenesisData = []byte(`{
+ "` + testAccount + `": {"balance": "` + testBalance + `"}
+ }`)
+
+ ethereum, err := testEth(t)
+ if err != nil {
+ t.Errorf("error creating ethereum: %v", err)
+ return
+ }
+ err = ethereum.Start()
+ if err != nil {
+ t.Errorf("error starting ethereum: %v", err)
+ return
+ }
+
+ self = &testFrontend{t: t, ethereum: ethereum}
+ self.xeth = xe.New(ethereum, self)
+ self.api = rpc.NewEthereumApi(self.xeth)
+
+ addr := self.xeth.Coinbase()
+ self.coinbase = addr
+ if addr != "0x"+testAccount {
+ t.Errorf("CoinBase %v does not match TestAccount 0x%v", addr, testAccount)
+ }
+ t.Logf("CoinBase is %v", addr)
+
+ balance := self.xeth.BalanceAt(testAccount)
+ /*if balance != core.TestBalance {
+ t.Errorf("Balance %v does not match TestBalance %v", balance, core.TestBalance)
+ }*/
+ t.Logf("Balance is %v", balance)
+
+ self.stateDb = self.ethereum.ChainManager().State().Copy()
+
+ return
+
+}
+
+func (self *testFrontend) insertTx(addr, contract, fnsig string, args []string) {
+
+ //cb := common.HexToAddress(self.coinbase)
+ //coinbase := self.ethereum.ChainManager().State().GetStateObject(cb)
+
+ hash := common.Bytes2Hex(crypto.Sha3([]byte(fnsig)))
+ data := "0x" + hash[0:8]
+ for _, arg := range args {
+ data = data + common.Bytes2Hex(common.Hex2BytesFixed(arg, 32))
+ }
+ self.t.Logf("Tx data: %v", data)
+
+ jsontx := `
+[{
+ "from": "` + addr + `",
+ "to": "` + contract + `",
+ "value": "100000000000",
+ "gas": "100000",
+ "gasPrice": "100000",
+ "data": "` + data + `"
+}]
+`
+ req := &rpc.RpcRequest{
+ Jsonrpc: "2.0",
+ Method: "eth_transact",
+ Params: []byte(jsontx),
+ Id: 6,
+ }
+
+ var reply interface{}
+ err0 := self.api.GetRequestReply(req, &reply)
+ if err0 != nil {
+ self.t.Errorf("GetRequestReply error: %v", err0)
+ }
+
+ //self.xeth.Transact(addr, contract, "100000000000", "100000", "100000", data)
+
+}
+
+func (self *testFrontend) applyTxs() {
+
+ cb := common.HexToAddress(self.coinbase)
+ block := self.ethereum.ChainManager().NewBlock(cb)
+ coinbase := self.stateDb.GetStateObject(cb)
+ coinbase.SetGasPool(big.NewInt(10000000))
+ txs := self.ethereum.TxPool().GetTransactions()
+
+ for i := 0; i < len(txs); i++ {
+ for _, tx := range txs {
+ //self.t.Logf("%v %v %v", i, tx.Nonce(), self.txc)
+ if tx.Nonce() == self.txc {
+ _, gas, err := core.ApplyMessage(core.NewEnv(self.stateDb, self.ethereum.ChainManager(), tx, block), tx, coinbase)
+ //self.ethereum.TxPool().RemoveSet([]*types.Transaction{tx})
+ self.t.Logf("ApplyMessage: gas %v err %v", gas, err)
+ self.txc++
+ }
+ }
+ }
+
+ //self.ethereum.TxPool().RemoveSet(txs)
+ self.xeth = self.xeth.WithState(self.stateDb)
+
+}
+
+func (self *testFrontend) registerURL(hash common.Hash, url string) {
+ hashHex := common.Bytes2Hex(hash[:])
+ urlBytes := []byte(url)
+ var bb bool = true
+ var cnt byte
+ for bb {
+ bb = len(urlBytes) > 0
+ urlb := urlBytes
+ if len(urlb) > 32 {
+ urlb = urlb[:32]
+ }
+ urlHex := common.Bytes2Hex(urlb)
+ self.insertTx(self.coinbase, resolver.URLHintContractAddress, "register(uint256,uint8,uint256)", []string{hashHex, common.Bytes2Hex([]byte{cnt}), urlHex})
+ if len(urlBytes) > 32 {
+ urlBytes = urlBytes[32:]
+ } else {
+ urlBytes = nil
+ }
+ cnt++
+ }
+}
+
+func (self *testFrontend) setOwner() {
+
+ self.insertTx(self.coinbase, resolver.HashRegContractAddress, "setowner()", []string{})
+
+ /*owner := self.xeth.StorageAt("0x"+resolver.HashRegContractAddress, "0x0000000000000000000000000000000000000000000000000000000000000000")
+ self.t.Logf("owner = %v", owner)
+ if owner != self.coinbase {
+ self.t.Errorf("setowner() unsuccessful, owner != coinbase")
+ }*/
+}
+
+func (self *testFrontend) registerNatSpec(codehash, dochash common.Hash) {
+
+ codeHex := common.Bytes2Hex(codehash[:])
+ docHex := common.Bytes2Hex(dochash[:])
+ self.insertTx(self.coinbase, resolver.HashRegContractAddress, "register(uint256,uint256)", []string{codeHex, docHex})
+}
+
+func (self *testFrontend) testResolver() *resolver.Resolver {
+ return resolver.New(self.xeth, resolver.URLHintContractAddress, resolver.HashRegContractAddress)
+}
+
+func TestNatspecE2E(t *testing.T) {
+
+ tf := testInit(t)
+ defer tf.ethereum.Stop()
+
+ resolver.CreateContracts(tf.xeth, testAccount)
+ t.Logf("URLHint contract registered at %v", resolver.URLHintContractAddress)
+ t.Logf("HashReg contract registered at %v", resolver.HashRegContractAddress)
+ tf.applyTxs()
+
+ ioutil.WriteFile("/tmp/"+testFileName, []byte(testDocs), os.ModePerm)
+ dochash := common.BytesToHash(crypto.Sha3([]byte(testDocs)))
+
+ codehex := tf.xeth.CodeAt(resolver.HashRegContractAddress)
+ codehash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex[2:])))
+
+ tf.setOwner()
+ tf.registerNatSpec(codehash, dochash)
+ tf.registerURL(dochash, "file:///"+testFileName)
+ tf.applyTxs()
+
+ chash, err := tf.testResolver().KeyToContentHash(codehash)
+ if err != nil {
+ t.Errorf("Can't find content hash")
+ }
+ t.Logf("chash = %x err = %v", chash, err)
+ url, err2 := tf.testResolver().ContentHashToUrl(dochash)
+ if err2 != nil {
+ t.Errorf("Can't find URL hint")
+ }
+ t.Logf("url = %v err = %v", url, err2)
+
+ // NatSpec info for register method of HashReg contract installed
+ // now using the same transactions to check confirm messages
+
+ tf.makeNatSpec = true
+ tf.registerNatSpec(codehash, dochash)
+ t.Logf("Confirm message: %v\n", tf.lastConfirm)
+ if tf.lastConfirm != testExpNotice {
+ t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice, tf.lastConfirm)
+ }
+
+ tf.setOwner()
+ t.Logf("Confirm message for unknown method: %v\n", tf.lastConfirm)
+ if tf.lastConfirm != testExpNotice2 {
+ t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice2, tf.lastConfirm)
+ }
+
+ tf.registerURL(dochash, "file:///test.content")
+ t.Logf("Confirm message for unknown contract: %v\n", tf.lastConfirm)
+ if tf.lastConfirm != testExpNotice3 {
+ t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice3, tf.lastConfirm)
+ }
+
+}
diff --git a/common/natspec/natspec_js.go b/common/natspec/natspec_js.go
index 96d8204fb..571044bde 100644
--- a/common/natspec/natspec_js.go
+++ b/common/natspec/natspec_js.go
@@ -1,4 +1,4044 @@
package natspec
-const natspecJS = `require=function t(e,n,r){function i(f,u){if(!n[f]){if(!e[f]){var s="function"==typeof require&&require;if(!u&&s)return s(f,!0);if(o)return o(f,!0);var c=new Error("Cannot find module '"+f+"'");throw c.code="MODULE_NOT_FOUND",c}var a=n[f]={exports:{}};e[f][0].call(a.exports,function(t){var n=e[f][1][t];return i(n?n:t)},a,a.exports,t,e,n,r)}return n[f].exports}for(var o="function"==typeof require&&require,f=0;f<r.length;f++)i(r[f]);return i}({1:[function(){},{}],2:[function(t,e){function n(){if(!f){f=!0;for(var t,e=o.length;e;){t=o,o=[];for(var n=-1;++n<e;)t[n]();e=o.length}f=!1}}function r(){}var i=e.exports={},o=[],f=!1;i.nextTick=function(t){o.push(t),f||setTimeout(n,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.on=r,i.addListener=r,i.once=r,i.off=r,i.removeListener=r,i.removeAllListeners=r,i.emit=r,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],3:[function(t,e){var n=t("./utils"),r=t("./types"),i=t("./const"),o=t("./formatters"),f=function(t){console.error("parser does not support type: "+t)},u=function(t){return"[]"===t.slice(-2)},s=function(t,e){return u(t)||"string"===t?o.formatInputInt(e.length):""},c=r.inputTypes(),a=function(t,e){var n="",r="",i="";return t.forEach(function(t,r){n+=s(t.type,e[r])}),t.forEach(function(n,o){for(var s=!1,a=0;a<c.length&&!s;a++)s=c[a].type(t[o].type,e[o]);s||f(t[o].type);var l=c[a-1].format;u(t[o].type)?i+=e[o].reduce(function(t,e){return t+l(e)},""):"string"===t[o].type?i+=l(e[o]):r+=l(e[o])}),n+=r+i},l=function(t){return u(t)||"string"===t?2*i.ETH_PADDING:0},p=r.outputTypes(),h=function(t,e){e=e.slice(2);var n=[],s=2*i.ETH_PADDING,c=t.reduce(function(t,e){return t+l(e.type)},0),a=e.slice(0,c);return e=e.slice(c),t.forEach(function(i,c){for(var l=!1,h=0;h<p.length&&!l;h++)l=p[h].type(t[c].type);l||f(t[c].type);var g=p[h-1].format;if(u(t[c].type)){var m=o.formatOutputUInt(a.slice(0,s));a=a.slice(s);for(var d=[],v=0;m>v;v++)d.push(g(e.slice(0,s))),e=e.slice(s);n.push(d)}else r.prefixedType("string")(t[c].type)?(a=a.slice(s),n.push(g(e.slice(0,s))),e=e.slice(s)):(n.push(g(e.slice(0,s))),e=e.slice(s))}),n},g=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return a(t.inputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},m=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(e){return h(t.outputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e};e.exports={inputParser:g,outputParser:m,formatInput:a,formatOutput:h}},{"./const":4,"./formatters":5,"./types":6,"./utils":7}],4:[function(t,e){(function(n){if("build"!==n.env.NODE_ENV)var r=t("bignumber.js");var i=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:i,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:r.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3}}).call(this,t("_process"))},{_process:2,"bignumber.js":8}],5:[function(t,e){(function(n){if("build"!==n.env.NODE_ENV)var r=t("bignumber.js");var i=t("./utils"),o=t("./const"),f=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},u=function(t){var e=2*o.ETH_PADDING;return t instanceof r||"number"==typeof t?("number"==typeof t&&(t=new r(t)),r.config(o.ETH_BIGNUMBER_ROUNDING_MODE),t=t.round(),t.lessThan(0)&&(t=new r("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?u(new r(t)):(+t).toString(16),f(t,e)},s=function(t){return i.fromAscii(t,o.ETH_PADDING).substr(2)},c=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},a=function(t){return u(new r(t).times(new r(2).pow(128)))},l=function(t){return"1"===new r(t.substr(0,1),16).toString(2).substr(0,1)},p=function(t){return t=t||"0",l(t)?new r(t,16).minus(new r("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new r(t,16)},h=function(t){return t=t||"0",new r(t,16)},g=function(t){return p(t).dividedBy(new r(2).pow(128))},m=function(t){return h(t).dividedBy(new r(2).pow(128))},d=function(t){return"0x"+t},v=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},w=function(t){return i.toAscii(t)},y=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:u,formatInputString:s,formatInputBool:c,formatInputReal:a,formatOutputInt:p,formatOutputUInt:h,formatOutputReal:g,formatOutputUReal:m,formatOutputHash:d,formatOutputBool:v,formatOutputString:w,formatOutputAddress:y}}).call(this,t("_process"))},{"./const":4,"./utils":7,_process:2,"bignumber.js":8}],6:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},i=function(t){return function(e){return t===e}},o=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("hash"),format:n.formatInputInt},{type:r("string"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:i("address"),format:n.formatInputInt},{type:i("bool"),format:n.formatInputBool}]},f=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("hash"),format:n.formatOutputHash},{type:r("string"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:i("address"),format:n.formatOutputAddress},{type:i("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:i,inputTypes:o,outputTypes:f}},{"./formatters":5}],7:[function(t,e){var n=t("./const"),r=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},i=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},o=function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},f=function(t,e){e=void 0===e?0:e;for(var n=o(t);n.length<2*e;)n+="00";return"0x"+n},u=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},s=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)).replace(" ",""):""},c=function(t){return t.filter(function(t){return"function"===t.type})},a=function(t){return t.filter(function(t){return"event"===t.type})},l=function(t){for(var e="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,r=0,i=n.ETH_UNITS;e>3e3&&r<i.length-1;)e/=1e3,r++;for(var o=e.toString().length<e.toFixed(2).length?e.toString():e.toFixed(2),f=function(t,e,n){return e+","+n};;){var u=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,f),u===o)break}return o+" "+i[r]};e.exports={findIndex:r,toAscii:i,fromAscii:f,extractDisplayName:u,extractTypeName:s,filterFunctions:c,filterEvents:a,toEth:l}},{"./const":4}],8:[function(t,e){!function(n){"use strict";function r(t){function e(t,r){var i,o,f,u,s,c,a=this;if(!(a instanceof e))return $&&U(26,"constructor call without new",t),new e(t,r);if(null!=r&&z(r,2,64,L,"base")){if(r=0|r,c=t+"",10==r)return a=new e(t instanceof e?t:c),F(a,B+a.e+1,H);if((u="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(i="["+N.slice(0,r)+"]+")+"(?:\\."+i+")?$",37>r?"i":"").test(c))return m(a,c,u,r);u?(a.s=0>1/t?(c=c.slice(1),-1):1,$&&c.replace(/^0\.0*|\./,"").length>15&&U(L,O,t),u=!1):a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1,c=n(c,10,r,a.s)}else{if(t instanceof e)return a.s=t.s,a.e=t.e,a.c=(t=t.c)?t.slice():t,void(L=0);if((u="number"==typeof t)&&0*t==0){if(a.s=0>1/t?(t=-t,-1):1,t===~~t){for(o=0,f=t;f>=10;f/=10,o++);return a.e=o,a.c=[t],void(L=0)}c=t+""}else{if(!d.test(c=t+""))return m(a,c,u);a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1}}for((o=c.indexOf("."))>-1&&(c=c.replace(".","")),(f=c.search(/e/i))>0?(0>o&&(o=f),o+=+c.slice(f+1),c=c.substring(0,f)):0>o&&(o=c.length),f=0;48===c.charCodeAt(f);f++);for(s=c.length;48===c.charCodeAt(--s););if(c=c.slice(f,s+1))if(s=c.length,u&&$&&s>15&&U(L,O,a.s*t),o=o-f-1,o>q)a.c=a.e=null;else if(k>o)a.c=[a.e=0];else{if(a.e=o,a.c=[],f=(o+1)%I,0>o&&(f+=I),s>f){for(f&&a.c.push(+c.slice(0,f)),s-=I;s>f;)a.c.push(+c.slice(f,f+=I));c=c.slice(f),f=I-c.length}else f-=s;for(;f--;c+="0");a.c.push(+c)}else a.c=[a.e=0];L=0}function n(t,n,r,i){var f,u,s,a,p,h,g,m=t.indexOf("."),d=B,v=H;for(37>r&&(t=t.toLowerCase()),m>=0&&(s=Y,Y=0,t=t.replace(".",""),g=new e(r),p=g.pow(t.length-m),Y=s,g.c=c(l(o(p.c),p.e),10,n),g.e=g.c.length),h=c(t,r,n),u=s=h.length;0==h[--s];h.pop());if(!h[0])return"0";if(0>m?--u:(p.c=h,p.e=u,p.s=i,p=G(p,g,d,v,n),h=p.c,a=p.r,u=p.e),f=u+d+1,m=h[f],s=n/2,a=a||0>f||null!=h[f+1],a=4>v?(null!=m||a)&&(0==v||v==(p.s<0?3:2)):m>s||m==s&&(4==v||a||6==v&&1&h[f-1]||v==(p.s<0?8:7)),1>f||!h[0])t=a?l("1",-d):"0";else{if(h.length=f,a)for(--n;++h[--f]>n;)h[f]=0,f||(++u,h.unshift(1));for(s=h.length;!h[--s];);for(m=0,t="";s>=m;t+=N.charAt(h[m++]));t=l(t,u)}return t}function h(t,n,r,i){var f,u,s,c,p;if(r=null!=r&&z(r,0,8,i,b)?0|r:H,!t.c)return t.toString();if(f=t.c[0],s=t.e,null==n)p=o(t.c),p=19==i||24==i&&C>=s?a(p,s):l(p,s);else if(t=F(new e(t),n,r),u=t.e,p=o(t.c),c=p.length,19==i||24==i&&(u>=n||C>=u)){for(;n>c;p+="0",c++);p=a(p,u)}else if(n-=s,p=l(p,u),u+1>c){if(--n>0)for(p+=".";n--;p+="0");}else if(n+=u-c,n>0)for(u+1==c&&(p+=".");n--;p+="0");return t.s<0&&f?"-"+p:p}function S(t,n){var r,i,o=0;for(s(t[0])&&(t=t[0]),r=new e(t[0]);++o<t.length;){if(i=new e(t[o]),!i.s){r=i;break}n.call(r,i)&&(r=i)}return r}function A(t,e,n,r,i){return(e>t||t>n||t!=p(t))&&U(r,(i||"decimal places")+(e>t||t>n?" out of range":" not an integer"),t),!0}function R(t,e,n){for(var r=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,r++);return(n=r+n*I-1)>q?t.c=t.e=null:k>n?t.c=[t.e=0]:(t.e=n,t.c=e),t}function U(t,e,n){var r=new Error(["new BigNumber","cmp","config","div","divToInt","eq","gt","gte","lt","lte","minus","mod","plus","precision","random","round","shift","times","toDigits","toExponential","toFixed","toFormat","toFraction","pow","toPrecision","toString","BigNumber"][t]+"() "+e+": "+n);throw r.name="BigNumber Error",L=0,r}function F(t,e,n,r){var i,o,f,u,s,c,a,l=t.c,p=_;if(l){t:{for(i=1,u=l[0];u>=10;u/=10,i++);if(o=e-i,0>o)o+=I,f=e,s=l[c=0],a=s/p[i-f-1]%10|0;else if(c=v((o+1)/I),c>=l.length){if(!r)break t;for(;l.length<=c;l.push(0));s=a=0,i=1,o%=I,f=o-I+1}else{for(s=u=l[c],i=1;u>=10;u/=10,i++);o%=I,f=o-I+i,a=0>f?0:s/p[i-f-1]%10|0}if(r=r||0>e||null!=l[c+1]||(0>f?s:s%p[i-f-1]),r=4>n?(a||r)&&(0==n||n==(t.s<0?3:2)):a>5||5==a&&(4==n||r||6==n&&(o>0?f>0?s/p[i-f]:0:l[c-1])%10&1||n==(t.s<0?8:7)),1>e||!l[0])return l.length=0,r?(e-=t.e+1,l[0]=p[e%I],t.e=-e||0):l[0]=t.e=0,t;if(0==o?(l.length=c,u=1,c--):(l.length=c+1,u=p[I-o],l[c]=f>0?w(s/p[i-f]%p[f])*u:0),r)for(;;){if(0==c){for(o=1,f=l[0];f>=10;f/=10,o++);for(f=l[0]+=u,u=1;f>=10;f/=10,u++);o!=u&&(t.e++,l[0]==E&&(l[0]=1));break}if(l[c]+=u,l[c]!=E)break;l[c--]=0,u=1}for(o=l.length;0===l[--o];l.pop());}t.e>q?t.c=t.e=null:t.e<k&&(t.c=[t.e=0])}return t}var G,L=0,M=e.prototype,P=new e(1),B=20,H=4,C=-7,j=21,k=-1e7,q=1e7,$=!0,z=A,V=!1,W=1,Y=100,Z={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0};return e.another=r,e.ROUND_UP=0,e.ROUND_DOWN=1,e.ROUND_CEIL=2,e.ROUND_FLOOR=3,e.ROUND_HALF_UP=4,e.ROUND_HALF_DOWN=5,e.ROUND_HALF_EVEN=6,e.ROUND_HALF_CEIL=7,e.ROUND_HALF_FLOOR=8,e.EUCLID=9,e.config=function(){var t,e,n=0,r={},i=arguments,o=i[0],f=o&&"object"==typeof o?function(){return o.hasOwnProperty(e)?null!=(t=o[e]):void 0}:function(){return i.length>n?null!=(t=i[n++]):void 0};return f(e="DECIMAL_PLACES")&&z(t,0,D,2,e)&&(B=0|t),r[e]=B,f(e="ROUNDING_MODE")&&z(t,0,8,2,e)&&(H=0|t),r[e]=H,f(e="EXPONENTIAL_AT")&&(s(t)?z(t[0],-D,0,2,e)&&z(t[1],0,D,2,e)&&(C=0|t[0],j=0|t[1]):z(t,-D,D,2,e)&&(C=-(j=0|(0>t?-t:t)))),r[e]=[C,j],f(e="RANGE")&&(s(t)?z(t[0],-D,-1,2,e)&&z(t[1],1,D,2,e)&&(k=0|t[0],q=0|t[1]):z(t,-D,D,2,e)&&(0|t?k=-(q=0|(0>t?-t:t)):$&&U(2,e+" cannot be zero",t))),r[e]=[k,q],f(e="ERRORS")&&(t===!!t||1===t||0===t?(L=0,z=($=!!t)?A:u):$&&U(2,e+y,t)),r[e]=$,f(e="CRYPTO")&&(t===!!t||1===t||0===t?(V=!(!t||!g||"object"!=typeof g),t&&!V&&$&&U(2,"crypto unavailable",g)):$&&U(2,e+y,t)),r[e]=V,f(e="MODULO_MODE")&&z(t,0,9,2,e)&&(W=0|t),r[e]=W,f(e="POW_PRECISION")&&z(t,0,D,2,e)&&(Y=0|t),r[e]=Y,f(e="FORMAT")&&("object"==typeof t?Z=t:$&&U(2,e+" not an object",t)),r[e]=Z,r},e.max=function(){return S(arguments,M.lt)},e.min=function(){return S(arguments,M.gt)},e.random=function(){var t=9007199254740992,n=Math.random()*t&2097151?function(){return w(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,i,o,f,u,s=0,c=[],a=new e(P);if(t=null!=t&&z(t,0,D,14)?0|t:B,f=v(t/I),V)if(g&&g.getRandomValues){for(r=g.getRandomValues(new Uint32Array(f*=2));f>s;)u=131072*r[s]+(r[s+1]>>>11),u>=9e15?(i=g.getRandomValues(new Uint32Array(2)),r[s]=i[0],r[s+1]=i[1]):(c.push(u%1e14),s+=2);s=f/2}else if(g&&g.randomBytes){for(r=g.randomBytes(f*=7);f>s;)u=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6],u>=9e15?g.randomBytes(7).copy(r,s):(c.push(u%1e14),s+=7);s=f/7}else $&&U(14,"crypto unavailable",g);if(!s)for(;f>s;)u=n(),9e15>u&&(c[s++]=u%1e14);for(f=c[--s],t%=I,f&&t&&(u=_[I-t],c[s]=w(f/u)*u);0===c[s];c.pop(),s--);if(0>s)c=[o=0];else{for(o=-1;0===c[0];c.shift(),o-=I);for(s=1,u=c[0];u>=10;u/=10,s++);I>s&&(o-=I-s)}return a.e=o,a.c=c,a}}(),G=function(){function t(t,e,n){var r,i,o,f,u=0,s=t.length,c=e%T,a=e/T|0;for(t=t.slice();s--;)o=t[s]%T,f=t[s]/T|0,r=a*o+f*c,i=c*o+r%T*T+u,u=(i/n|0)+(r/T|0)+a*f,t[s]=i%n;return u&&t.unshift(u),t}function n(t,e,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;n>i;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]<e[n]?1:0,t[n]=i*r+t[n]-e[n];for(;!t[0]&&t.length>1;t.shift());}return function(o,f,u,s,c){var a,l,p,h,g,m,d,v,y,b,O,N,x,_,T,D,S,A=o.s==f.s?1:-1,R=o.c,U=f.c;if(!(R&&R[0]&&U&&U[0]))return new e(o.s&&f.s&&(R?!U||R[0]!=U[0]:U)?R&&0==R[0]||!U?0*A:A/0:0/0);for(v=new e(A),y=v.c=[],l=o.e-f.e,A=u+l+1,c||(c=E,l=i(o.e/I)-i(f.e/I),A=A/I|0),p=0;U[p]==(R[p]||0);p++);if(U[p]>(R[p]||0)&&l--,0>A)y.push(1),h=!0;else{for(_=R.length,D=U.length,p=0,A+=2,g=w(c/(U[0]+1)),g>1&&(U=t(U,g,c),R=t(R,g,c),D=U.length,_=R.length),x=D,b=R.slice(0,D),O=b.length;D>O;b[O++]=0);S=U.slice(),S.unshift(0),T=U[0],U[1]>=c/2&&T++;do g=0,a=n(U,b,D,O),0>a?(N=b[0],D!=O&&(N=N*c+(b[1]||0)),g=w(N/T),g>1?(g>=c&&(g=c-1),m=t(U,g,c),d=m.length,O=b.length,a=n(m,b,d,O),1==a&&(g--,r(m,d>D?S:U,d,c))):(0==g&&(a=g=1),m=U.slice()),d=m.length,O>d&&m.unshift(0),r(b,m,O,c),-1==a&&(O=b.length,a=n(U,b,D,O),1>a&&(g++,r(b,O>D?S:U,O,c))),O=b.length):0===a&&(g++,b=[0]),y[p++]=g,a&&b[0]?b[O++]=R[x]||0:(b=[R[x]],O=1);while((x++<_||null!=b[0])&&A--);h=null!=b[0],y[0]||y.shift()}if(c==E){for(p=1,A=y[0];A>=10;A/=10,p++);F(v,u+(v.e=p+l*I-1)+1,s,h)}else v.e=l,v.r=+h;return v}}(),m==function(){var t=/^(-?)0([xbo])(\w[\w.]*$)/i,n=/^([^.]+)\.$/,r=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,o=/^\s*\+([\w.])|^\s+|\s+$/g;return function(f,u,s,c){var a,l=s?u:u.replace(o,"$1");if(i.test(l))f.s=isNaN(l)?null:0>l?-1:1;else{if(!s&&(l=l.replace(t,function(t,e,n){return a="x"==(n=n.toLowerCase())?16:"b"==n?2:8,c&&c!=a?t:e}),c&&(a=c,l=l.replace(n,"$1").replace(r,"0.$1")),u!=l))return new e(l,a);$&&U(L,"not a"+(c?" base "+c:"")+" number",u),f.s=null}f.c=f.e=null,L=0}}(),M.absoluteValue=M.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},M.ceil=function(){return F(new e(this),this.e+1,2)},M.comparedTo=M.cmp=function(t,n){return L=1,f(this,new e(t,n))},M.decimalPlaces=M.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-i(this.e/I))*I,e=n[e])for(;e%10==0;e/=10,t--);return 0>t&&(t=0),t},M.dividedBy=M.div=function(t,n){return L=3,G(this,new e(t,n),B,H)},M.dividedToIntegerBy=M.divToInt=function(t,n){return L=4,G(this,new e(t,n),0,1)},M.equals=M.eq=function(t,n){return L=5,0===f(this,new e(t,n))},M.floor=function(){return F(new e(this),this.e+1,3)},M.greaterThan=M.gt=function(t,n){return L=6,f(this,new e(t,n))>0},M.greaterThanOrEqualTo=M.gte=function(t,n){return L=7,1===(n=f(this,new e(t,n)))||0===n},M.isFinite=function(){return!!this.c},M.isInteger=M.isInt=function(){return!!this.c&&i(this.e/I)>this.c.length-2},M.isNaN=function(){return!this.s},M.isNegative=M.isNeg=function(){return this.s<0},M.isZero=function(){return!!this.c&&0==this.c[0]},M.lessThan=M.lt=function(t,n){return L=8,f(this,new e(t,n))<0},M.lessThanOrEqualTo=M.lte=function(t,n){return L=9,-1===(n=f(this,new e(t,n)))||0===n},M.minus=M.sub=function(t,n){var r,o,f,u,s=this,c=s.s;if(L=10,t=new e(t,n),n=t.s,!c||!n)return new e(0/0);if(c!=n)return t.s=-n,s.plus(t);var a=s.e/I,l=t.e/I,p=s.c,h=t.c;if(!a||!l){if(!p||!h)return p?(t.s=-n,t):new e(h?s:0/0);if(!p[0]||!h[0])return h[0]?(t.s=-n,t):new e(p[0]?s:3==H?-0:0)}if(a=i(a),l=i(l),p=p.slice(),c=a-l){for((u=0>c)?(c=-c,f=p):(l=a,f=h),f.reverse(),n=c;n--;f.push(0));f.reverse()}else for(o=(u=(c=p.length)<(n=h.length))?c:n,c=n=0;o>n;n++)if(p[n]!=h[n]){u=p[n]<h[n];break}if(u&&(f=p,p=h,h=f,t.s=-t.s),n=(o=h.length)-(r=p.length),n>0)for(;n--;p[r++]=0);for(n=E-1;o>c;){if(p[--o]<h[o]){for(r=o;r&&!p[--r];p[r]=n);--p[r],p[o]+=E}p[o]-=h[o]}for(;0==p[0];p.shift(),--l);return p[0]?R(t,p,l):(t.s=3==H?-1:1,t.c=[t.e=0],t)},M.modulo=M.mod=function(t,n){var r,i,o=this;return L=11,t=new e(t,n),!o.c||!t.s||t.c&&!t.c[0]?new e(0/0):!t.c||o.c&&!o.c[0]?new e(o):(9==W?(i=t.s,t.s=1,r=G(o,t,0,3),t.s=i,r.s*=i):r=G(o,t,0,W),o.minus(r.times(t)))},M.negated=M.neg=function(){var t=new e(this);return t.s=-t.s||null,t},M.plus=M.add=function(t,n){var r,o=this,f=o.s;if(L=12,t=new e(t,n),n=t.s,!f||!n)return new e(0/0);if(f!=n)return t.s=-n,o.minus(t);var u=o.e/I,s=t.e/I,c=o.c,a=t.c;if(!u||!s){if(!c||!a)return new e(f/0);if(!c[0]||!a[0])return a[0]?t:new e(c[0]?o:0*f)}if(u=i(u),s=i(s),c=c.slice(),f=u-s){for(f>0?(s=u,r=a):(f=-f,r=c),r.reverse();f--;r.push(0));r.reverse()}for(f=c.length,n=a.length,0>f-n&&(r=a,a=c,c=r,n=f),f=0;n;)f=(c[--n]=c[n]+a[n]+f)/E|0,c[n]%=E;return f&&(c.unshift(f),++s),R(t,c,s)},M.precision=M.sd=function(t){var e,n,r=this,i=r.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&($&&U(13,"argument"+y,t),t!=!!t&&(t=null)),!i)return null;if(n=i.length-1,e=n*I+1,n=i[n]){for(;n%10==0;n/=10,e--);for(n=i[0];n>=10;n/=10,e++);}return t&&r.e+1>e&&(e=r.e+1),e},M.round=function(t,n){var r=new e(this);return(null==t||z(t,0,D,15))&&F(r,~~t+this.e+1,null!=n&&z(n,0,8,15,b)?0|n:H),r},M.shift=function(t){var n=this;return z(t,-x,x,16,"argument")?n.times("1e"+p(t)):new e(n.c&&n.c[0]&&(-x>t||t>x)?n.s*(0>t?0:1/0):n)},M.squareRoot=M.sqrt=function(){var t,n,r,f,u,s=this,c=s.c,a=s.s,l=s.e,p=B+4,h=new e("0.5");if(1!==a||!c||!c[0])return new e(!a||0>a&&(!c||c[0])?0/0:c?s:1/0);if(a=Math.sqrt(+s),0==a||a==1/0?(n=o(c),(n.length+l)%2==0&&(n+="0"),a=Math.sqrt(n),l=i((l+1)/2)-(0>l||l%2),a==1/0?n="1e"+l:(n=a.toExponential(),n=n.slice(0,n.indexOf("e")+1)+l),r=new e(n)):r=new e(a+""),r.c[0])for(l=r.e,a=l+p,3>a&&(a=0);;)if(u=r,r=h.times(u.plus(G(s,u,p,1))),o(u.c).slice(0,a)===(n=o(r.c)).slice(0,a)){if(r.e<l&&--a,n=n.slice(a-3,a+1),"9999"!=n&&(f||"4999"!=n)){(!+n||!+n.slice(1)&&"5"==n.charAt(0))&&(F(r,r.e+B+2,1),t=!r.times(r).eq(s));break}if(!f&&(F(u,u.e+B+2,0),u.times(u).eq(s))){r=u;break}p+=4,a+=4,f=1}return F(r,r.e+B+1,H,t)},M.times=M.mul=function(t,n){var r,o,f,u,s,c,a,l,p,h,g,m,d,v,w,y=this,b=y.c,O=(L=17,t=new e(t,n)).c;if(!(b&&O&&b[0]&&O[0]))return!y.s||!t.s||b&&!b[0]&&!O||O&&!O[0]&&!b?t.c=t.e=t.s=null:(t.s*=y.s,b&&O?(t.c=[0],t.e=0):t.c=t.e=null),t;for(o=i(y.e/I)+i(t.e/I),t.s*=y.s,a=b.length,h=O.length,h>a&&(d=b,b=O,O=d,f=a,a=h,h=f),f=a+h,d=[];f--;d.push(0));for(v=E,w=T,f=h;--f>=0;){for(r=0,g=O[f]%w,m=O[f]/w|0,s=a,u=f+s;u>f;)l=b[--s]%w,p=b[s]/w|0,c=m*l+p*g,l=g*l+c%w*w+d[u]+r,r=(l/v|0)+(c/w|0)+m*p,d[u--]=l%v;d[u]=r}return r?++o:d.shift(),R(t,d,o)},M.toDigits=function(t,n){var r=new e(this);return t=null!=t&&z(t,1,D,18,"precision")?0|t:null,n=null!=n&&z(n,0,8,18,b)?0|n:H,t?F(r,t,n):r},M.toExponential=function(t,e){return h(this,null!=t&&z(t,0,D,19)?~~t+1:null,e,19)},M.toFixed=function(t,e){return h(this,null!=t&&z(t,0,D,20)?~~t+this.e+1:null,e,20)},M.toFormat=function(t,e){var n=h(this,null!=t&&z(t,0,D,21)?~~t+this.e+1:null,e,21);if(this.c){var r,i=n.split("."),o=+Z.groupSize,f=+Z.secondaryGroupSize,u=Z.groupSeparator,s=i[0],c=i[1],a=this.s<0,l=a?s.slice(1):s,p=l.length;if(f&&(r=o,o=f,f=r,p-=r),o>0&&p>0){for(r=p%o||o,s=l.substr(0,r);p>r;r+=o)s+=u+l.substr(r,o);f>0&&(s+=u+l.slice(r)),a&&(s="-"+s)}n=c?s+Z.decimalSeparator+((f=+Z.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+Z.fractionGroupSeparator):c):s}return n},M.toFraction=function(t){var n,r,i,f,u,s,c,a,l,p=$,h=this,g=h.c,m=new e(P),d=r=new e(P),v=c=new e(P);if(null!=t&&($=!1,s=new e(t),$=p,(!(p=s.isInt())||s.lt(P))&&($&&U(22,"max denominator "+(p?"out of range":"not an integer"),t),t=!p&&s.c&&F(s,s.e+1,1).gte(P)?s:null)),!g)return h.toString();for(l=o(g),f=m.e=l.length-h.e-1,m.c[0]=_[(u=f%I)<0?I+u:u],t=!t||s.cmp(m)>0?f>0?m:d:s,u=q,q=1/0,s=new e(l),c.c[0]=0;a=G(s,m,0,1),i=r.plus(a.times(v)),1!=i.cmp(t);)r=v,v=i,d=c.plus(a.times(i=d)),c=i,m=s.minus(a.times(i=m)),s=i;return i=G(t.minus(r),v,0,1),c=c.plus(i.times(d)),r=r.plus(i.times(v)),c.s=d.s=h.s,f*=2,n=G(d,v,f,H).minus(h).abs().cmp(G(c,r,f,H).minus(h).abs())<1?[d.toString(),v.toString()]:[c.toString(),r.toString()],q=u,n},M.toNumber=function(){var t=this;return+t||(t.s?0*t.s:0/0)},M.toPower=M.pow=function(t){var n,r,i=w(0>t?-t:+t),o=this;if(!z(t,-x,x,23,"exponent")&&(!isFinite(t)||i>x&&(t/=0)||parseFloat(t)!=t&&!(t=0/0)))return new e(Math.pow(+o,t));for(n=Y?v(Y/I+2):0,r=new e(P);;){if(i%2){if(r=r.times(o),!r.c)break;n&&r.c.length>n&&(r.c.length=n)}if(i=w(i/2),!i)break;o=o.times(o),n&&o.c&&o.c.length>n&&(o.c.length=n)}return 0>t&&(r=P.div(r)),n?F(r,Y,H):r},M.toPrecision=function(t,e){return h(this,null!=t&&z(t,1,D,24,"precision")?0|t:null,e,24)},M.toString=function(t){var e,r=this,i=r.s,f=r.e;return null===f?i?(e="Infinity",0>i&&(e="-"+e)):e="NaN":(e=o(r.c),e=null!=t&&z(t,2,64,25,"base")?n(l(e,f),0|t,10,i):C>=f||f>=j?a(e,f):l(e,f),0>i&&r.c[0]&&(e="-"+e)),e},M.truncated=M.trunc=function(){return F(new e(this),this.e+1,1)},M.valueOf=M.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function i(t){var e=0|t;return t>0||t===e?e:e-1}function o(t){for(var e,n,r=1,i=t.length,o=t[0]+"";i>r;){for(e=t[r++]+"",n=I-e.length;n--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function f(t,e){var n,r,i=t.c,o=e.c,f=t.s,u=e.s,s=t.e,c=e.e;if(!f||!u)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-u:f;if(f!=u)return f;if(n=0>f,r=s==c,!i||!o)return r?0:!i^n?1:-1;if(!r)return s>c^n?1:-1;for(u=(s=i.length)<(c=o.length)?s:c,f=0;u>f;f++)if(i[f]!=o[f])return i[f]>o[f]^n?1:-1;return s==c?0:s>c^n?1:-1}function u(t,e,n){return(t=p(t))>=e&&n>=t}function s(t){return"[object Array]"==Object.prototype.toString.call(t)}function c(t,e,n){for(var r,i,o=[0],f=0,u=t.length;u>f;){for(i=o.length;i--;o[i]*=e);for(o[r=0]+=N.indexOf(t.charAt(f++));r<o.length;r++)o[r]>n-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function a(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(0>e?"e":"e+")+e}function l(t,e){var n,r;if(0>e){for(r="0.";++e;r+="0");t=r+t}else if(n=t.length,++e>n){for(r="0",e-=n;--e;r+="0");t+=r}else n>e&&(t=t.slice(0,e)+"."+t.slice(e));return t}function p(t){return t=parseFloat(t),0>t?v(t):w(t)}var h,g,m,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=Math.ceil,w=Math.floor,y=" not a boolean or binary digit",b="rounding mode",O="number type has more than 15 significant digits",N="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",E=1e14,I=14,x=9007199254740991,_=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],T=1e7,D=1e9;if(h=r(),"function"==typeof define&&define.amd)define(function(){return h});else if("undefined"!=typeof e&&e.exports){if(e.exports=h,!g)try{g=t("crypto")}catch(S){}}else n.BigNumber=h}(this)},{crypto:1}],natspec:[function(t,e){var n=t("./node_modules/ethereum.js/lib/abi.js"),r=function(){var t=function(t,e){Object.keys(t).forEach(function(n){e[n]=t[n]})},e=function(t){return Object.keys(t).reduce(function(t,e){return t+"var "+e+" = context['"+e+"'];\n"},"")},r=function(t,e){return t.filter(function(t){return t.name===e})[0]},i=function(t,e){var r=n.formatOutput(t.inputs,"0x"+e.params[0].data.slice(10));return t.inputs.reduce(function(t,e,n){return t[e.name]=r[n],t},{})},o=function(t,e){var n,r="",i=/\` + "`" + `(?:\\.|[^` + "`" + `\\])*\` + "`" + `/gim,o=0;try{for(;null!==(n=i.exec(t));){var f=i.lastIndex-n[0].length,u=n[0].slice(1,n[0].length-1);r+=t.slice(o,f);var s=e(u);r+=s,o=i.lastIndex}r+=t.slice(o)}catch(c){throw new Error("Natspec evaluation failed, wrong input params")}return r},f=function(n,f){var u={};if(f)try{var s=r(f.abi,f.method),c=i(s,f.transaction);t(c,u)}catch(a){throw new Error("Natspec evaluation failed, method does not exist")}var l=e(u),p=o(n,function(t){var e=new Function("context",l+"return "+t+";");return e(u).toString()});return p},u=function(t,e){try{return f(t,e)}catch(n){return n.message}};return{evaluateExpression:f,evaluateExpressionSafe:u}}();e.exports=r},{"./node_modules/ethereum.js/lib/abi.js":3}]},{},[]);
+const natspecJS = //`require=function t(e,n,r){function i(f,u){if(!n[f]){if(!e[f]){var s="function"==typeof require&&require;if(!u&&s)return s(f,!0);if(o)return o(f,!0);var c=new Error("Cannot find module '"+f+"'");throw c.code="MODULE_NOT_FOUND",c}var a=n[f]={exports:{}};e[f][0].call(a.exports,function(t){var n=e[f][1][t];return i(n?n:t)},a,a.exports,t,e,n,r)}return n[f].exports}for(var o="function"==typeof require&&require,f=0;f<r.length;f++)i(r[f]);return i}({1:[function(){},{}],2:[function(t,e){function n(){if(!f){f=!0;for(var t,e=o.length;e;){t=o,o=[];for(var n=-1;++n<e;)t[n]();e=o.length}f=!1}}function r(){}var i=e.exports={},o=[],f=!1;i.nextTick=function(t){o.push(t),f||setTimeout(n,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.on=r,i.addListener=r,i.once=r,i.off=r,i.removeListener=r,i.removeAllListeners=r,i.emit=r,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],3:[function(t,e){var n=t("./utils"),r=t("./types"),i=t("./const"),o=t("./formatters"),f=function(t){console.error("parser does not support type: "+t)},u=function(t){return"[]"===t.slice(-2)},s=function(t,e){return u(t)||"string"===t?o.formatInputInt(e.length):""},c=r.inputTypes(),a=function(t,e){var n="",r="",i="";return t.forEach(function(t,r){n+=s(t.type,e[r])}),t.forEach(function(n,o){for(var s=!1,a=0;a<c.length&&!s;a++)s=c[a].type(t[o].type,e[o]);s||f(t[o].type);var l=c[a-1].format;u(t[o].type)?i+=e[o].reduce(function(t,e){return t+l(e)},""):"string"===t[o].type?i+=l(e[o]):r+=l(e[o])}),n+=r+i},l=function(t){return u(t)||"string"===t?2*i.ETH_PADDING:0},p=r.outputTypes(),h=function(t,e){e=e.slice(2);var n=[],s=2*i.ETH_PADDING,c=t.reduce(function(t,e){return t+l(e.type)},0),a=e.slice(0,c);return e=e.slice(c),t.forEach(function(i,c){for(var l=!1,h=0;h<p.length&&!l;h++)l=p[h].type(t[c].type);l||f(t[c].type);var g=p[h-1].format;if(u(t[c].type)){var m=o.formatOutputUInt(a.slice(0,s));a=a.slice(s);for(var d=[],v=0;m>v;v++)d.push(g(e.slice(0,s))),e=e.slice(s);n.push(d)}else r.prefixedType("string")(t[c].type)?(a=a.slice(s),n.push(g(e.slice(0,s))),e=e.slice(s)):(n.push(g(e.slice(0,s))),e=e.slice(s))}),n},g=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return a(t.inputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},m=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(e){return h(t.outputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e};e.exports={inputParser:g,outputParser:m,formatInput:a,formatOutput:h}},{"./const":4,"./formatters":5,"./types":6,"./utils":7}],4:[function(t,e){(function(n){if("build"!==n.env.NODE_ENV)var r=t("bignumber.js");var i=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:i,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:r.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3}}).call(this,t("_process"))},{_process:2,"bignumber.js":8}],5:[function(t,e){(function(n){if("build"!==n.env.NODE_ENV)var r=t("bignumber.js");var i=t("./utils"),o=t("./const"),f=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},u=function(t){var e=2*o.ETH_PADDING;return t instanceof r||"number"==typeof t?("number"==typeof t&&(t=new r(t)),r.config(o.ETH_BIGNUMBER_ROUNDING_MODE),t=t.round(),t.lessThan(0)&&(t=new r("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?u(new r(t)):(+t).toString(16),f(t,e)},s=function(t){return i.fromAscii(t,o.ETH_PADDING).substr(2)},c=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},a=function(t){return u(new r(t).times(new r(2).pow(128)))},l=function(t){return"1"===new r(t.substr(0,1),16).toString(2).substr(0,1)},p=function(t){return t=t||"0",l(t)?new r(t,16).minus(new r("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new r(t,16)},h=function(t){return t=t||"0",new r(t,16)},g=function(t){return p(t).dividedBy(new r(2).pow(128))},m=function(t){return h(t).dividedBy(new r(2).pow(128))},d=function(t){return"0x"+t},v=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},w=function(t){return i.toAscii(t)},y=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:u,formatInputString:s,formatInputBool:c,formatInputReal:a,formatOutputInt:p,formatOutputUInt:h,formatOutputReal:g,formatOutputUReal:m,formatOutputHash:d,formatOutputBool:v,formatOutputString:w,formatOutputAddress:y}}).call(this,t("_process"))},{"./const":4,"./utils":7,_process:2,"bignumber.js":8}],6:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},i=function(t){return function(e){return t===e}},o=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("hash"),format:n.formatInputInt},{type:r("string"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:i("address"),format:n.formatInputInt},{type:i("bool"),format:n.formatInputBool}]},f=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("hash"),format:n.formatOutputHash},{type:r("string"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:i("address"),format:n.formatOutputAddress},{type:i("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:i,inputTypes:o,outputTypes:f}},{"./formatters":5}],7:[function(t,e){var n=t("./const"),r=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},i=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},o=function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},f=function(t,e){e=void 0===e?0:e;for(var n=o(t);n.length<2*e;)n+="00";return"0x"+n},u=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},s=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)).replace(" ",""):""},c=function(t){return t.filter(function(t){return"function"===t.type})},a=function(t){return t.filter(function(t){return"event"===t.type})},l=function(t){for(var e="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,r=0,i=n.ETH_UNITS;e>3e3&&r<i.length-1;)e/=1e3,r++;for(var o=e.toString().length<e.toFixed(2).length?e.toString():e.toFixed(2),f=function(t,e,n){return e+","+n};;){var u=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,f),u===o)break}return o+" "+i[r]};e.exports={findIndex:r,toAscii:i,fromAscii:f,extractDisplayName:u,extractTypeName:s,filterFunctions:c,filterEvents:a,toEth:l}},{"./const":4}],8:[function(t,e){!function(n){"use strict";function r(t){function e(t,r){var i,o,f,u,s,c,a=this;if(!(a instanceof e))return $&&U(26,"constructor call without new",t),new e(t,r);if(null!=r&&z(r,2,64,L,"base")){if(r=0|r,c=t+"",10==r)return a=new e(t instanceof e?t:c),F(a,B+a.e+1,H);if((u="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(i="["+N.slice(0,r)+"]+")+"(?:\\."+i+")?$",37>r?"i":"").test(c))return m(a,c,u,r);u?(a.s=0>1/t?(c=c.slice(1),-1):1,$&&c.replace(/^0\.0*|\./,"").length>15&&U(L,O,t),u=!1):a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1,c=n(c,10,r,a.s)}else{if(t instanceof e)return a.s=t.s,a.e=t.e,a.c=(t=t.c)?t.slice():t,void(L=0);if((u="number"==typeof t)&&0*t==0){if(a.s=0>1/t?(t=-t,-1):1,t===~~t){for(o=0,f=t;f>=10;f/=10,o++);return a.e=o,a.c=[t],void(L=0)}c=t+""}else{if(!d.test(c=t+""))return m(a,c,u);a.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1}}for((o=c.indexOf("."))>-1&&(c=c.replace(".","")),(f=c.search(/e/i))>0?(0>o&&(o=f),o+=+c.slice(f+1),c=c.substring(0,f)):0>o&&(o=c.length),f=0;48===c.charCodeAt(f);f++);for(s=c.length;48===c.charCodeAt(--s););if(c=c.slice(f,s+1))if(s=c.length,u&&$&&s>15&&U(L,O,a.s*t),o=o-f-1,o>q)a.c=a.e=null;else if(k>o)a.c=[a.e=0];else{if(a.e=o,a.c=[],f=(o+1)%I,0>o&&(f+=I),s>f){for(f&&a.c.push(+c.slice(0,f)),s-=I;s>f;)a.c.push(+c.slice(f,f+=I));c=c.slice(f),f=I-c.length}else f-=s;for(;f--;c+="0");a.c.push(+c)}else a.c=[a.e=0];L=0}function n(t,n,r,i){var f,u,s,a,p,h,g,m=t.indexOf("."),d=B,v=H;for(37>r&&(t=t.toLowerCase()),m>=0&&(s=Y,Y=0,t=t.replace(".",""),g=new e(r),p=g.pow(t.length-m),Y=s,g.c=c(l(o(p.c),p.e),10,n),g.e=g.c.length),h=c(t,r,n),u=s=h.length;0==h[--s];h.pop());if(!h[0])return"0";if(0>m?--u:(p.c=h,p.e=u,p.s=i,p=G(p,g,d,v,n),h=p.c,a=p.r,u=p.e),f=u+d+1,m=h[f],s=n/2,a=a||0>f||null!=h[f+1],a=4>v?(null!=m||a)&&(0==v||v==(p.s<0?3:2)):m>s||m==s&&(4==v||a||6==v&&1&h[f-1]||v==(p.s<0?8:7)),1>f||!h[0])t=a?l("1",-d):"0";else{if(h.length=f,a)for(--n;++h[--f]>n;)h[f]=0,f||(++u,h.unshift(1));for(s=h.length;!h[--s];);for(m=0,t="";s>=m;t+=N.charAt(h[m++]));t=l(t,u)}return t}function h(t,n,r,i){var f,u,s,c,p;if(r=null!=r&&z(r,0,8,i,b)?0|r:H,!t.c)return t.toString();if(f=t.c[0],s=t.e,null==n)p=o(t.c),p=19==i||24==i&&C>=s?a(p,s):l(p,s);else if(t=F(new e(t),n,r),u=t.e,p=o(t.c),c=p.length,19==i||24==i&&(u>=n||C>=u)){for(;n>c;p+="0",c++);p=a(p,u)}else if(n-=s,p=l(p,u),u+1>c){if(--n>0)for(p+=".";n--;p+="0");}else if(n+=u-c,n>0)for(u+1==c&&(p+=".");n--;p+="0");return t.s<0&&f?"-"+p:p}function S(t,n){var r,i,o=0;for(s(t[0])&&(t=t[0]),r=new e(t[0]);++o<t.length;){if(i=new e(t[o]),!i.s){r=i;break}n.call(r,i)&&(r=i)}return r}function A(t,e,n,r,i){return(e>t||t>n||t!=p(t))&&U(r,(i||"decimal places")+(e>t||t>n?" out of range":" not an integer"),t),!0}function R(t,e,n){for(var r=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,r++);return(n=r+n*I-1)>q?t.c=t.e=null:k>n?t.c=[t.e=0]:(t.e=n,t.c=e),t}function U(t,e,n){var r=new Error(["new BigNumber","cmp","config","div","divToInt","eq","gt","gte","lt","lte","minus","mod","plus","precision","random","round","shift","times","toDigits","toExponential","toFixed","toFormat","toFraction","pow","toPrecision","toString","BigNumber"][t]+"() "+e+": "+n);throw r.name="BigNumber Error",L=0,r}function F(t,e,n,r){var i,o,f,u,s,c,a,l=t.c,p=_;if(l){t:{for(i=1,u=l[0];u>=10;u/=10,i++);if(o=e-i,0>o)o+=I,f=e,s=l[c=0],a=s/p[i-f-1]%10|0;else if(c=v((o+1)/I),c>=l.length){if(!r)break t;for(;l.length<=c;l.push(0));s=a=0,i=1,o%=I,f=o-I+1}else{for(s=u=l[c],i=1;u>=10;u/=10,i++);o%=I,f=o-I+i,a=0>f?0:s/p[i-f-1]%10|0}if(r=r||0>e||null!=l[c+1]||(0>f?s:s%p[i-f-1]),r=4>n?(a||r)&&(0==n||n==(t.s<0?3:2)):a>5||5==a&&(4==n||r||6==n&&(o>0?f>0?s/p[i-f]:0:l[c-1])%10&1||n==(t.s<0?8:7)),1>e||!l[0])return l.length=0,r?(e-=t.e+1,l[0]=p[e%I],t.e=-e||0):l[0]=t.e=0,t;if(0==o?(l.length=c,u=1,c--):(l.length=c+1,u=p[I-o],l[c]=f>0?w(s/p[i-f]%p[f])*u:0),r)for(;;){if(0==c){for(o=1,f=l[0];f>=10;f/=10,o++);for(f=l[0]+=u,u=1;f>=10;f/=10,u++);o!=u&&(t.e++,l[0]==E&&(l[0]=1));break}if(l[c]+=u,l[c]!=E)break;l[c--]=0,u=1}for(o=l.length;0===l[--o];l.pop());}t.e>q?t.c=t.e=null:t.e<k&&(t.c=[t.e=0])}return t}var G,L=0,M=e.prototype,P=new e(1),B=20,H=4,C=-7,j=21,k=-1e7,q=1e7,$=!0,z=A,V=!1,W=1,Y=100,Z={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0};return e.another=r,e.ROUND_UP=0,e.ROUND_DOWN=1,e.ROUND_CEIL=2,e.ROUND_FLOOR=3,e.ROUND_HALF_UP=4,e.ROUND_HALF_DOWN=5,e.ROUND_HALF_EVEN=6,e.ROUND_HALF_CEIL=7,e.ROUND_HALF_FLOOR=8,e.EUCLID=9,e.config=function(){var t,e,n=0,r={},i=arguments,o=i[0],f=o&&"object"==typeof o?function(){return o.hasOwnProperty(e)?null!=(t=o[e]):void 0}:function(){return i.length>n?null!=(t=i[n++]):void 0};return f(e="DECIMAL_PLACES")&&z(t,0,D,2,e)&&(B=0|t),r[e]=B,f(e="ROUNDING_MODE")&&z(t,0,8,2,e)&&(H=0|t),r[e]=H,f(e="EXPONENTIAL_AT")&&(s(t)?z(t[0],-D,0,2,e)&&z(t[1],0,D,2,e)&&(C=0|t[0],j=0|t[1]):z(t,-D,D,2,e)&&(C=-(j=0|(0>t?-t:t)))),r[e]=[C,j],f(e="RANGE")&&(s(t)?z(t[0],-D,-1,2,e)&&z(t[1],1,D,2,e)&&(k=0|t[0],q=0|t[1]):z(t,-D,D,2,e)&&(0|t?k=-(q=0|(0>t?-t:t)):$&&U(2,e+" cannot be zero",t))),r[e]=[k,q],f(e="ERRORS")&&(t===!!t||1===t||0===t?(L=0,z=($=!!t)?A:u):$&&U(2,e+y,t)),r[e]=$,f(e="CRYPTO")&&(t===!!t||1===t||0===t?(V=!(!t||!g||"object"!=typeof g),t&&!V&&$&&U(2,"crypto unavailable",g)):$&&U(2,e+y,t)),r[e]=V,f(e="MODULO_MODE")&&z(t,0,9,2,e)&&(W=0|t),r[e]=W,f(e="POW_PRECISION")&&z(t,0,D,2,e)&&(Y=0|t),r[e]=Y,f(e="FORMAT")&&("object"==typeof t?Z=t:$&&U(2,e+" not an object",t)),r[e]=Z,r},e.max=function(){return S(arguments,M.lt)},e.min=function(){return S(arguments,M.gt)},e.random=function(){var t=9007199254740992,n=Math.random()*t&2097151?function(){return w(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,i,o,f,u,s=0,c=[],a=new e(P);if(t=null!=t&&z(t,0,D,14)?0|t:B,f=v(t/I),V)if(g&&g.getRandomValues){for(r=g.getRandomValues(new Uint32Array(f*=2));f>s;)u=131072*r[s]+(r[s+1]>>>11),u>=9e15?(i=g.getRandomValues(new Uint32Array(2)),r[s]=i[0],r[s+1]=i[1]):(c.push(u%1e14),s+=2);s=f/2}else if(g&&g.randomBytes){for(r=g.randomBytes(f*=7);f>s;)u=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6],u>=9e15?g.randomBytes(7).copy(r,s):(c.push(u%1e14),s+=7);s=f/7}else $&&U(14,"crypto unavailable",g);if(!s)for(;f>s;)u=n(),9e15>u&&(c[s++]=u%1e14);for(f=c[--s],t%=I,f&&t&&(u=_[I-t],c[s]=w(f/u)*u);0===c[s];c.pop(),s--);if(0>s)c=[o=0];else{for(o=-1;0===c[0];c.shift(),o-=I);for(s=1,u=c[0];u>=10;u/=10,s++);I>s&&(o-=I-s)}return a.e=o,a.c=c,a}}(),G=function(){function t(t,e,n){var r,i,o,f,u=0,s=t.length,c=e%T,a=e/T|0;for(t=t.slice();s--;)o=t[s]%T,f=t[s]/T|0,r=a*o+f*c,i=c*o+r%T*T+u,u=(i/n|0)+(r/T|0)+a*f,t[s]=i%n;return u&&t.unshift(u),t}function n(t,e,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;n>i;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]<e[n]?1:0,t[n]=i*r+t[n]-e[n];for(;!t[0]&&t.length>1;t.shift());}return function(o,f,u,s,c){var a,l,p,h,g,m,d,v,y,b,O,N,x,_,T,D,S,A=o.s==f.s?1:-1,R=o.c,U=f.c;if(!(R&&R[0]&&U&&U[0]))return new e(o.s&&f.s&&(R?!U||R[0]!=U[0]:U)?R&&0==R[0]||!U?0*A:A/0:0/0);for(v=new e(A),y=v.c=[],l=o.e-f.e,A=u+l+1,c||(c=E,l=i(o.e/I)-i(f.e/I),A=A/I|0),p=0;U[p]==(R[p]||0);p++);if(U[p]>(R[p]||0)&&l--,0>A)y.push(1),h=!0;else{for(_=R.length,D=U.length,p=0,A+=2,g=w(c/(U[0]+1)),g>1&&(U=t(U,g,c),R=t(R,g,c),D=U.length,_=R.length),x=D,b=R.slice(0,D),O=b.length;D>O;b[O++]=0);S=U.slice(),S.unshift(0),T=U[0],U[1]>=c/2&&T++;do g=0,a=n(U,b,D,O),0>a?(N=b[0],D!=O&&(N=N*c+(b[1]||0)),g=w(N/T),g>1?(g>=c&&(g=c-1),m=t(U,g,c),d=m.length,O=b.length,a=n(m,b,d,O),1==a&&(g--,r(m,d>D?S:U,d,c))):(0==g&&(a=g=1),m=U.slice()),d=m.length,O>d&&m.unshift(0),r(b,m,O,c),-1==a&&(O=b.length,a=n(U,b,D,O),1>a&&(g++,r(b,O>D?S:U,O,c))),O=b.length):0===a&&(g++,b=[0]),y[p++]=g,a&&b[0]?b[O++]=R[x]||0:(b=[R[x]],O=1);while((x++<_||null!=b[0])&&A--);h=null!=b[0],y[0]||y.shift()}if(c==E){for(p=1,A=y[0];A>=10;A/=10,p++);F(v,u+(v.e=p+l*I-1)+1,s,h)}else v.e=l,v.r=+h;return v}}(),m==function(){var t=/^(-?)0([xbo])(\w[\w.]*$)/i,n=/^([^.]+)\.$/,r=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,o=/^\s*\+([\w.])|^\s+|\s+$/g;return function(f,u,s,c){var a,l=s?u:u.replace(o,"$1");if(i.test(l))f.s=isNaN(l)?null:0>l?-1:1;else{if(!s&&(l=l.replace(t,function(t,e,n){return a="x"==(n=n.toLowerCase())?16:"b"==n?2:8,c&&c!=a?t:e}),c&&(a=c,l=l.replace(n,"$1").replace(r,"0.$1")),u!=l))return new e(l,a);$&&U(L,"not a"+(c?" base "+c:"")+" number",u),f.s=null}f.c=f.e=null,L=0}}(),M.absoluteValue=M.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},M.ceil=function(){return F(new e(this),this.e+1,2)},M.comparedTo=M.cmp=function(t,n){return L=1,f(this,new e(t,n))},M.decimalPlaces=M.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-i(this.e/I))*I,e=n[e])for(;e%10==0;e/=10,t--);return 0>t&&(t=0),t},M.dividedBy=M.div=function(t,n){return L=3,G(this,new e(t,n),B,H)},M.dividedToIntegerBy=M.divToInt=function(t,n){return L=4,G(this,new e(t,n),0,1)},M.equals=M.eq=function(t,n){return L=5,0===f(this,new e(t,n))},M.floor=function(){return F(new e(this),this.e+1,3)},M.greaterThan=M.gt=function(t,n){return L=6,f(this,new e(t,n))>0},M.greaterThanOrEqualTo=M.gte=function(t,n){return L=7,1===(n=f(this,new e(t,n)))||0===n},M.isFinite=function(){return!!this.c},M.isInteger=M.isInt=function(){return!!this.c&&i(this.e/I)>this.c.length-2},M.isNaN=function(){return!this.s},M.isNegative=M.isNeg=function(){return this.s<0},M.isZero=function(){return!!this.c&&0==this.c[0]},M.lessThan=M.lt=function(t,n){return L=8,f(this,new e(t,n))<0},M.lessThanOrEqualTo=M.lte=function(t,n){return L=9,-1===(n=f(this,new e(t,n)))||0===n},M.minus=M.sub=function(t,n){var r,o,f,u,s=this,c=s.s;if(L=10,t=new e(t,n),n=t.s,!c||!n)return new e(0/0);if(c!=n)return t.s=-n,s.plus(t);var a=s.e/I,l=t.e/I,p=s.c,h=t.c;if(!a||!l){if(!p||!h)return p?(t.s=-n,t):new e(h?s:0/0);if(!p[0]||!h[0])return h[0]?(t.s=-n,t):new e(p[0]?s:3==H?-0:0)}if(a=i(a),l=i(l),p=p.slice(),c=a-l){for((u=0>c)?(c=-c,f=p):(l=a,f=h),f.reverse(),n=c;n--;f.push(0));f.reverse()}else for(o=(u=(c=p.length)<(n=h.length))?c:n,c=n=0;o>n;n++)if(p[n]!=h[n]){u=p[n]<h[n];break}if(u&&(f=p,p=h,h=f,t.s=-t.s),n=(o=h.length)-(r=p.length),n>0)for(;n--;p[r++]=0);for(n=E-1;o>c;){if(p[--o]<h[o]){for(r=o;r&&!p[--r];p[r]=n);--p[r],p[o]+=E}p[o]-=h[o]}for(;0==p[0];p.shift(),--l);return p[0]?R(t,p,l):(t.s=3==H?-1:1,t.c=[t.e=0],t)},M.modulo=M.mod=function(t,n){var r,i,o=this;return L=11,t=new e(t,n),!o.c||!t.s||t.c&&!t.c[0]?new e(0/0):!t.c||o.c&&!o.c[0]?new e(o):(9==W?(i=t.s,t.s=1,r=G(o,t,0,3),t.s=i,r.s*=i):r=G(o,t,0,W),o.minus(r.times(t)))},M.negated=M.neg=function(){var t=new e(this);return t.s=-t.s||null,t},M.plus=M.add=function(t,n){var r,o=this,f=o.s;if(L=12,t=new e(t,n),n=t.s,!f||!n)return new e(0/0);if(f!=n)return t.s=-n,o.minus(t);var u=o.e/I,s=t.e/I,c=o.c,a=t.c;if(!u||!s){if(!c||!a)return new e(f/0);if(!c[0]||!a[0])return a[0]?t:new e(c[0]?o:0*f)}if(u=i(u),s=i(s),c=c.slice(),f=u-s){for(f>0?(s=u,r=a):(f=-f,r=c),r.reverse();f--;r.push(0));r.reverse()}for(f=c.length,n=a.length,0>f-n&&(r=a,a=c,c=r,n=f),f=0;n;)f=(c[--n]=c[n]+a[n]+f)/E|0,c[n]%=E;return f&&(c.unshift(f),++s),R(t,c,s)},M.precision=M.sd=function(t){var e,n,r=this,i=r.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&($&&U(13,"argument"+y,t),t!=!!t&&(t=null)),!i)return null;if(n=i.length-1,e=n*I+1,n=i[n]){for(;n%10==0;n/=10,e--);for(n=i[0];n>=10;n/=10,e++);}return t&&r.e+1>e&&(e=r.e+1),e},M.round=function(t,n){var r=new e(this);return(null==t||z(t,0,D,15))&&F(r,~~t+this.e+1,null!=n&&z(n,0,8,15,b)?0|n:H),r},M.shift=function(t){var n=this;return z(t,-x,x,16,"argument")?n.times("1e"+p(t)):new e(n.c&&n.c[0]&&(-x>t||t>x)?n.s*(0>t?0:1/0):n)},M.squareRoot=M.sqrt=function(){var t,n,r,f,u,s=this,c=s.c,a=s.s,l=s.e,p=B+4,h=new e("0.5");if(1!==a||!c||!c[0])return new e(!a||0>a&&(!c||c[0])?0/0:c?s:1/0);if(a=Math.sqrt(+s),0==a||a==1/0?(n=o(c),(n.length+l)%2==0&&(n+="0"),a=Math.sqrt(n),l=i((l+1)/2)-(0>l||l%2),a==1/0?n="1e"+l:(n=a.toExponential(),n=n.slice(0,n.indexOf("e")+1)+l),r=new e(n)):r=new e(a+""),r.c[0])for(l=r.e,a=l+p,3>a&&(a=0);;)if(u=r,r=h.times(u.plus(G(s,u,p,1))),o(u.c).slice(0,a)===(n=o(r.c)).slice(0,a)){if(r.e<l&&--a,n=n.slice(a-3,a+1),"9999"!=n&&(f||"4999"!=n)){(!+n||!+n.slice(1)&&"5"==n.charAt(0))&&(F(r,r.e+B+2,1),t=!r.times(r).eq(s));break}if(!f&&(F(u,u.e+B+2,0),u.times(u).eq(s))){r=u;break}p+=4,a+=4,f=1}return F(r,r.e+B+1,H,t)},M.times=M.mul=function(t,n){var r,o,f,u,s,c,a,l,p,h,g,m,d,v,w,y=this,b=y.c,O=(L=17,t=new e(t,n)).c;if(!(b&&O&&b[0]&&O[0]))return!y.s||!t.s||b&&!b[0]&&!O||O&&!O[0]&&!b?t.c=t.e=t.s=null:(t.s*=y.s,b&&O?(t.c=[0],t.e=0):t.c=t.e=null),t;for(o=i(y.e/I)+i(t.e/I),t.s*=y.s,a=b.length,h=O.length,h>a&&(d=b,b=O,O=d,f=a,a=h,h=f),f=a+h,d=[];f--;d.push(0));for(v=E,w=T,f=h;--f>=0;){for(r=0,g=O[f]%w,m=O[f]/w|0,s=a,u=f+s;u>f;)l=b[--s]%w,p=b[s]/w|0,c=m*l+p*g,l=g*l+c%w*w+d[u]+r,r=(l/v|0)+(c/w|0)+m*p,d[u--]=l%v;d[u]=r}return r?++o:d.shift(),R(t,d,o)},M.toDigits=function(t,n){var r=new e(this);return t=null!=t&&z(t,1,D,18,"precision")?0|t:null,n=null!=n&&z(n,0,8,18,b)?0|n:H,t?F(r,t,n):r},M.toExponential=function(t,e){return h(this,null!=t&&z(t,0,D,19)?~~t+1:null,e,19)},M.toFixed=function(t,e){return h(this,null!=t&&z(t,0,D,20)?~~t+this.e+1:null,e,20)},M.toFormat=function(t,e){var n=h(this,null!=t&&z(t,0,D,21)?~~t+this.e+1:null,e,21);if(this.c){var r,i=n.split("."),o=+Z.groupSize,f=+Z.secondaryGroupSize,u=Z.groupSeparator,s=i[0],c=i[1],a=this.s<0,l=a?s.slice(1):s,p=l.length;if(f&&(r=o,o=f,f=r,p-=r),o>0&&p>0){for(r=p%o||o,s=l.substr(0,r);p>r;r+=o)s+=u+l.substr(r,o);f>0&&(s+=u+l.slice(r)),a&&(s="-"+s)}n=c?s+Z.decimalSeparator+((f=+Z.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+Z.fractionGroupSeparator):c):s}return n},M.toFraction=function(t){var n,r,i,f,u,s,c,a,l,p=$,h=this,g=h.c,m=new e(P),d=r=new e(P),v=c=new e(P);if(null!=t&&($=!1,s=new e(t),$=p,(!(p=s.isInt())||s.lt(P))&&($&&U(22,"max denominator "+(p?"out of range":"not an integer"),t),t=!p&&s.c&&F(s,s.e+1,1).gte(P)?s:null)),!g)return h.toString();for(l=o(g),f=m.e=l.length-h.e-1,m.c[0]=_[(u=f%I)<0?I+u:u],t=!t||s.cmp(m)>0?f>0?m:d:s,u=q,q=1/0,s=new e(l),c.c[0]=0;a=G(s,m,0,1),i=r.plus(a.times(v)),1!=i.cmp(t);)r=v,v=i,d=c.plus(a.times(i=d)),c=i,m=s.minus(a.times(i=m)),s=i;return i=G(t.minus(r),v,0,1),c=c.plus(i.times(d)),r=r.plus(i.times(v)),c.s=d.s=h.s,f*=2,n=G(d,v,f,H).minus(h).abs().cmp(G(c,r,f,H).minus(h).abs())<1?[d.toString(),v.toString()]:[c.toString(),r.toString()],q=u,n},M.toNumber=function(){var t=this;return+t||(t.s?0*t.s:0/0)},M.toPower=M.pow=function(t){var n,r,i=w(0>t?-t:+t),o=this;if(!z(t,-x,x,23,"exponent")&&(!isFinite(t)||i>x&&(t/=0)||parseFloat(t)!=t&&!(t=0/0)))return new e(Math.pow(+o,t));for(n=Y?v(Y/I+2):0,r=new e(P);;){if(i%2){if(r=r.times(o),!r.c)break;n&&r.c.length>n&&(r.c.length=n)}if(i=w(i/2),!i)break;o=o.times(o),n&&o.c&&o.c.length>n&&(o.c.length=n)}return 0>t&&(r=P.div(r)),n?F(r,Y,H):r},M.toPrecision=function(t,e){return h(this,null!=t&&z(t,1,D,24,"precision")?0|t:null,e,24)},M.toString=function(t){var e,r=this,i=r.s,f=r.e;return null===f?i?(e="Infinity",0>i&&(e="-"+e)):e="NaN":(e=o(r.c),e=null!=t&&z(t,2,64,25,"base")?n(l(e,f),0|t,10,i):C>=f||f>=j?a(e,f):l(e,f),0>i&&r.c[0]&&(e="-"+e)),e},M.truncated=M.trunc=function(){return F(new e(this),this.e+1,1)},M.valueOf=M.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function i(t){var e=0|t;return t>0||t===e?e:e-1}function o(t){for(var e,n,r=1,i=t.length,o=t[0]+"";i>r;){for(e=t[r++]+"",n=I-e.length;n--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function f(t,e){var n,r,i=t.c,o=e.c,f=t.s,u=e.s,s=t.e,c=e.e;if(!f||!u)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-u:f;if(f!=u)return f;if(n=0>f,r=s==c,!i||!o)return r?0:!i^n?1:-1;if(!r)return s>c^n?1:-1;for(u=(s=i.length)<(c=o.length)?s:c,f=0;u>f;f++)if(i[f]!=o[f])return i[f]>o[f]^n?1:-1;return s==c?0:s>c^n?1:-1}function u(t,e,n){return(t=p(t))>=e&&n>=t}function s(t){return"[object Array]"==Object.prototype.toString.call(t)}function c(t,e,n){for(var r,i,o=[0],f=0,u=t.length;u>f;){for(i=o.length;i--;o[i]*=e);for(o[r=0]+=N.indexOf(t.charAt(f++));r<o.length;r++)o[r]>n-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function a(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(0>e?"e":"e+")+e}function l(t,e){var n,r;if(0>e){for(r="0.";++e;r+="0");t=r+t}else if(n=t.length,++e>n){for(r="0",e-=n;--e;r+="0");t+=r}else n>e&&(t=t.slice(0,e)+"."+t.slice(e));return t}function p(t){return t=parseFloat(t),0>t?v(t):w(t)}var h,g,m,d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=Math.ceil,w=Math.floor,y=" not a boolean or binary digit",b="rounding mode",O="number type has more than 15 significant digits",N="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",E=1e14,I=14,x=9007199254740991,_=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],T=1e7,D=1e9;if(h=r(),"function"==typeof define&&define.amd)define(function(){return h});else if("undefined"!=typeof e&&e.exports){if(e.exports=h,!g)try{g=t("crypto")}catch(S){}}else n.BigNumber=h}(this)},{crypto:1}],natspec:[function(t,e){var n=t("./node_modules/ethereum.js/lib/abi.js"),r=function(){var t=function(t,e){Object.keys(t).forEach(function(n){e[n]=t[n]})},e=function(t){return Object.keys(t).reduce(function(t,e){return t+"var "+e+" = context['"+e+"'];\n"},"")},r=function(t,e){return t.filter(function(t){return t.name===e})[0]},i=function(t,e){var r=n.formatOutput(t.inputs,"0x"+e.params[0].data.slice(10));return t.inputs.reduce(function(t,e,n){return t[e.name]=r[n],t},{})},o=function(t,e){var n,r="",i=/\` + "`" + `(?:\\.|[^` + "`" + `\\])*\` + "`" + `/gim,o=0;try{for(;null!==(n=i.exec(t));){var f=i.lastIndex-n[0].length,u=n[0].slice(1,n[0].length-1);r+=t.slice(o,f);var s=e(u);r+=s,o=i.lastIndex}r+=t.slice(o)}catch(c){throw new Error("Natspec evaluation failed, wrong input params")}return r},f=function(n,f){var u={};if(f)try{var s=r(f.abi,f.method),c=i(s,f.transaction);t(c,u)}catch(a){throw new Error("Natspec evaluation failed, method does not exist")}var l=e(u),p=o(n,function(t){var e=new Function("context",l+"return "+t+";");return e(u).toString()});return p},u=function(t,e){try{return f(t,e)}catch(n){return n.message}};return{evaluateExpression:f,evaluateExpressionSafe:u}}();e.exports=r},{"./node_modules/ethereum.js/lib/abi.js":3}]},{},[]);
+`
+require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+
+},{}],2:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file abi.js
+ * @author Marek Kotewicz <marek@ethdev.com>
+ * @author Gav Wood <g@ethdev.com>
+ * @date 2014
+ */
+
+var utils = require('../utils/utils');
+var c = require('../utils/config');
+var types = require('./types');
+var f = require('./formatters');
+var solUtils = require('./utils');
+
+/**
+ * throw incorrect type error
+ *
+ * @method throwTypeError
+ * @param {String} type
+ * @throws incorrect type error
+ */
+var throwTypeError = function (type) {
+ throw new Error('parser does not support type: ' + type);
+};
+
+/** This method should be called if we want to check if givent type is an array type
+ *
+ * @method isArrayType
+ * @param {String} type name
+ * @returns {Boolean} true if it is, otherwise false
+ */
+var isArrayType = function (type) {
+ return type.slice(-2) === '[]';
+};
+
+/**
+ * This method should be called to return dynamic type length in hex
+ *
+ * @method dynamicTypeBytes
+ * @param {String} type
+ * @param {String|Array} dynamic type
+ * @return {String} length of dynamic type in hex or empty string if type is not dynamic
+ */
+var dynamicTypeBytes = function (type, value) {
+ // TODO: decide what to do with array of strings
+ if (isArrayType(type) || type === 'bytes')
+ return f.formatInputInt(value.length);
+ return "";
+};
+
+var inputTypes = types.inputTypes();
+
+/**
+ * Formats input params to bytes
+ *
+ * @method formatInput
+ * @param {Array} abi inputs of method
+ * @param {Array} params that will be formatted to bytes
+ * @returns bytes representation of input params
+ */
+var formatInput = function (inputs, params) {
+ var bytes = "";
+ var toAppendConstant = "";
+ var toAppendArrayContent = "";
+
+ /// first we iterate in search for dynamic
+ inputs.forEach(function (input, index) {
+ bytes += dynamicTypeBytes(input.type, params[index]);
+ });
+
+ inputs.forEach(function (input, i) {
+ /*jshint maxcomplexity:5 */
+ var typeMatch = false;
+ for (var j = 0; j < inputTypes.length && !typeMatch; j++) {
+ typeMatch = inputTypes[j].type(inputs[i].type, params[i]);
+ }
+ if (!typeMatch) {
+ throwTypeError(inputs[i].type);
+ }
+
+ var formatter = inputTypes[j - 1].format;
+
+ if (isArrayType(inputs[i].type))
+ toAppendArrayContent += params[i].reduce(function (acc, curr) {
+ return acc + formatter(curr);
+ }, "");
+ else if (inputs[i].type === 'bytes')
+ toAppendArrayContent += formatter(params[i]);
+ else
+ toAppendConstant += formatter(params[i]);
+ });
+
+ bytes += toAppendConstant + toAppendArrayContent;
+
+ return bytes;
+};
+
+/**
+ * This method should be called to predict the length of dynamic type
+ *
+ * @method dynamicBytesLength
+ * @param {String} type
+ * @returns {Number} length of dynamic type, 0 or multiplication of ETH_PADDING (32)
+ */
+var dynamicBytesLength = function (type) {
+ if (isArrayType(type) || type === 'bytes')
+ return c.ETH_PADDING * 2;
+ return 0;
+};
+
+var outputTypes = types.outputTypes();
+
+/**
+ * Formats output bytes back to param list
+ *
+ * @method formatOutput
+ * @param {Array} abi outputs of method
+ * @param {String} bytes represention of output
+ * @returns {Array} output params
+ */
+var formatOutput = function (outs, output) {
+
+ output = output.slice(2);
+ var result = [];
+ var padding = c.ETH_PADDING * 2;
+
+ var dynamicPartLength = outs.reduce(function (acc, curr) {
+ return acc + dynamicBytesLength(curr.type);
+ }, 0);
+
+ var dynamicPart = output.slice(0, dynamicPartLength);
+ output = output.slice(dynamicPartLength);
+
+ outs.forEach(function (out, i) {
+ /*jshint maxcomplexity:6 */
+ var typeMatch = false;
+ for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
+ typeMatch = outputTypes[j].type(outs[i].type);
+ }
+
+ if (!typeMatch) {
+ throwTypeError(outs[i].type);
+ }
+
+ var formatter = outputTypes[j - 1].format;
+ if (isArrayType(outs[i].type)) {
+ var size = f.formatOutputUInt(dynamicPart.slice(0, padding));
+ dynamicPart = dynamicPart.slice(padding);
+ var array = [];
+ for (var k = 0; k < size; k++) {
+ array.push(formatter(output.slice(0, padding)));
+ output = output.slice(padding);
+ }
+ result.push(array);
+ }
+ else if (types.prefixedType('bytes')(outs[i].type)) {
+ dynamicPart = dynamicPart.slice(padding);
+ result.push(formatter(output.slice(0, padding)));
+ output = output.slice(padding);
+ } else {
+ result.push(formatter(output.slice(0, padding)));
+ output = output.slice(padding);
+ }
+ });
+
+ return result;
+};
+
+/**
+ * Should be called to create input parser for contract with given abi
+ *
+ * @method inputParser
+ * @param {Array} contract abi
+ * @returns {Object} input parser object for given json abi
+ * TODO: refactor creating the parser, do not double logic from contract
+ */
+var inputParser = function (json) {
+ var parser = {};
+ json.forEach(function (method) {
+ var displayName = utils.extractDisplayName(method.name);
+ var typeName = utils.extractTypeName(method.name);
+
+ var impl = function () {
+ var params = Array.prototype.slice.call(arguments);
+ return formatInput(method.inputs, params);
+ };
+
+ if (parser[displayName] === undefined) {
+ parser[displayName] = impl;
+ }
+
+ parser[displayName][typeName] = impl;
+ });
+
+ return parser;
+};
+
+/**
+ * Should be called to create output parser for contract with given abi
+ *
+ * @method outputParser
+ * @param {Array} contract abi
+ * @returns {Object} output parser for given json abi
+ */
+var outputParser = function (json) {
+ var parser = {};
+ json.forEach(function (method) {
+
+ var displayName = utils.extractDisplayName(method.name);
+ var typeName = utils.extractTypeName(method.name);
+
+ var impl = function (output) {
+ return formatOutput(method.outputs, output);
+ };
+
+ if (parser[displayName] === undefined) {
+ parser[displayName] = impl;
+ }
+
+ parser[displayName][typeName] = impl;
+ });
+
+ return parser;
+};
+
+var formatConstructorParams = function (abi, params) {
+ var constructor = solUtils.getConstructor(abi, params.length);
+ if (!constructor) {
+ if (params.length > 0) {
+ console.warn("didn't found matching constructor, using default one");
+ }
+ return '';
+ }
+ return formatInput(constructor.inputs, params);
+};
+
+module.exports = {
+ inputParser: inputParser,
+ outputParser: outputParser,
+ formatInput: formatInput,
+ formatOutput: formatOutput,
+ formatConstructorParams: formatConstructorParams
+};
+
+},{"../utils/config":6,"../utils/utils":7,"./formatters":3,"./types":4,"./utils":5}],3:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file formatters.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+var BigNumber = require('bignumber.js');
+var utils = require('../utils/utils');
+var c = require('../utils/config');
+
+/**
+ * Formats input value to byte representation of int
+ * If value is negative, return it's two's complement
+ * If the value is floating point, round it down
+ *
+ * @method formatInputInt
+ * @param {String|Number|BigNumber} value that needs to be formatted
+ * @returns {String} right-aligned byte representation of int
+ */
+var formatInputInt = function (value) {
+ var padding = c.ETH_PADDING * 2;
+ BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
+ return utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);
+};
+
+/**
+ * Formats input value to byte representation of string
+ *
+ * @method formatInputString
+ * @param {String}
+ * @returns {String} left-algined byte representation of string
+ */
+var formatInputString = function (value) {
+ return utils.fromAscii(value, c.ETH_PADDING).substr(2);
+};
+
+/**
+ * Formats input value to byte representation of bool
+ *
+ * @method formatInputBool
+ * @param {Boolean}
+ * @returns {String} right-aligned byte representation bool
+ */
+var formatInputBool = function (value) {
+ return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
+};
+
+/**
+ * Formats input value to byte representation of real
+ * Values are multiplied by 2^m and encoded as integers
+ *
+ * @method formatInputReal
+ * @param {String|Number|BigNumber}
+ * @returns {String} byte representation of real
+ */
+var formatInputReal = function (value) {
+ return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
+};
+
+/**
+ * Check if input value is negative
+ *
+ * @method signedIsNegative
+ * @param {String} value is hex format
+ * @returns {Boolean} true if it is negative, otherwise false
+ */
+var signedIsNegative = function (value) {
+ return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
+};
+
+/**
+ * Formats right-aligned output bytes to int
+ *
+ * @method formatOutputInt
+ * @param {String} bytes
+ * @returns {BigNumber} right-aligned output bytes formatted to big number
+ */
+var formatOutputInt = function (value) {
+
+ value = value || "0";
+
+ // check if it's negative number
+ // it it is, return two's complement
+ if (signedIsNegative(value)) {
+ return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
+ }
+ return new BigNumber(value, 16);
+};
+
+/**
+ * Formats right-aligned output bytes to uint
+ *
+ * @method formatOutputUInt
+ * @param {String} bytes
+ * @returns {BigNumeber} right-aligned output bytes formatted to uint
+ */
+var formatOutputUInt = function (value) {
+ value = value || "0";
+ return new BigNumber(value, 16);
+};
+
+/**
+ * Formats right-aligned output bytes to real
+ *
+ * @method formatOutputReal
+ * @param {String}
+ * @returns {BigNumber} input bytes formatted to real
+ */
+var formatOutputReal = function (value) {
+ return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
+};
+
+/**
+ * Formats right-aligned output bytes to ureal
+ *
+ * @method formatOutputUReal
+ * @param {String}
+ * @returns {BigNumber} input bytes formatted to ureal
+ */
+var formatOutputUReal = function (value) {
+ return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
+};
+
+/**
+ * Should be used to format output hash
+ *
+ * @method formatOutputHash
+ * @param {String}
+ * @returns {String} right-aligned output bytes formatted to hex
+ */
+var formatOutputHash = function (value) {
+ return "0x" + value;
+};
+
+/**
+ * Should be used to format output bool
+ *
+ * @method formatOutputBool
+ * @param {String}
+ * @returns {Boolean} right-aligned input bytes formatted to bool
+ */
+var formatOutputBool = function (value) {
+ return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
+};
+
+/**
+ * Should be used to format output string
+ *
+ * @method formatOutputString
+ * @param {Sttring} left-aligned hex representation of string
+ * @returns {String} ascii string
+ */
+var formatOutputString = function (value) {
+ return utils.toAscii(value);
+};
+
+/**
+ * Should be used to format output address
+ *
+ * @method formatOutputAddress
+ * @param {String} right-aligned input bytes
+ * @returns {String} address
+ */
+var formatOutputAddress = function (value) {
+ return "0x" + value.slice(value.length - 40, value.length);
+};
+
+module.exports = {
+ formatInputInt: formatInputInt,
+ formatInputString: formatInputString,
+ formatInputBool: formatInputBool,
+ formatInputReal: formatInputReal,
+ formatOutputInt: formatOutputInt,
+ formatOutputUInt: formatOutputUInt,
+ formatOutputReal: formatOutputReal,
+ formatOutputUReal: formatOutputUReal,
+ formatOutputHash: formatOutputHash,
+ formatOutputBool: formatOutputBool,
+ formatOutputString: formatOutputString,
+ formatOutputAddress: formatOutputAddress
+};
+
+
+},{"../utils/config":6,"../utils/utils":7,"bignumber.js":8}],4:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file types.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+var f = require('./formatters');
+
+/// @param expected type prefix (string)
+/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
+var prefixedType = function (prefix) {
+ return function (type) {
+ return type.indexOf(prefix) === 0;
+ };
+};
+
+/// @param expected type name (string)
+/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
+var namedType = function (name) {
+ return function (type) {
+ return name === type;
+ };
+};
+
+/// Setups input formatters for solidity types
+/// @returns an array of input formatters
+var inputTypes = function () {
+
+ return [
+ { type: prefixedType('uint'), format: f.formatInputInt },
+ { type: prefixedType('int'), format: f.formatInputInt },
+ { type: prefixedType('bytes'), format: f.formatInputString },
+ { type: prefixedType('real'), format: f.formatInputReal },
+ { type: prefixedType('ureal'), format: f.formatInputReal },
+ { type: namedType('address'), format: f.formatInputInt },
+ { type: namedType('bool'), format: f.formatInputBool }
+ ];
+};
+
+/// Setups output formaters for solidity types
+/// @returns an array of output formatters
+var outputTypes = function () {
+
+ return [
+ { type: prefixedType('uint'), format: f.formatOutputUInt },
+ { type: prefixedType('int'), format: f.formatOutputInt },
+ { type: prefixedType('bytes'), format: f.formatOutputString },
+ { type: prefixedType('real'), format: f.formatOutputReal },
+ { type: prefixedType('ureal'), format: f.formatOutputUReal },
+ { type: namedType('address'), format: f.formatOutputAddress },
+ { type: namedType('bool'), format: f.formatOutputBool }
+ ];
+};
+
+module.exports = {
+ prefixedType: prefixedType,
+ namedType: namedType,
+ inputTypes: inputTypes,
+ outputTypes: outputTypes
+};
+
+
+},{"./formatters":3}],5:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file utils.js
+ * @author Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+/**
+ * Returns the contstructor with matching number of arguments
+ *
+ * @method getConstructor
+ * @param {Array} abi
+ * @param {Number} numberOfArgs
+ * @returns {Object} constructor function abi
+ */
+var getConstructor = function (abi, numberOfArgs) {
+ return abi.filter(function (f) {
+ return f.type === 'constructor' && f.inputs.length === numberOfArgs;
+ })[0];
+};
+
+/**
+ * Filters all functions from input abi
+ *
+ * @method filterFunctions
+ * @param {Array} abi
+ * @returns {Array} abi array with filtered objects of type 'function'
+ */
+var filterFunctions = function (json) {
+ return json.filter(function (current) {
+ return current.type === 'function';
+ });
+};
+
+/**
+ * Filters all events from input abi
+ *
+ * @method filterEvents
+ * @param {Array} abi
+ * @returns {Array} abi array with filtered objects of type 'event'
+ */
+var filterEvents = function (json) {
+ return json.filter(function (current) {
+ return current.type === 'event';
+ });
+};
+
+module.exports = {
+ getConstructor: getConstructor,
+ filterFunctions: filterFunctions,
+ filterEvents: filterEvents
+};
+
+
+},{}],6:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file config.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+/**
+ * Utils
+ *
+ * @module utils
+ */
+
+/**
+ * Utility functions
+ *
+ * @class [utils] config
+ * @constructor
+ */
+
+/// required to define ETH_BIGNUMBER_ROUNDING_MODE
+var BigNumber = require('bignumber.js');
+
+var ETH_UNITS = [
+ 'wei',
+ 'Kwei',
+ 'Mwei',
+ 'Gwei',
+ 'szabo',
+ 'finney',
+ 'ether',
+ 'grand',
+ 'Mether',
+ 'Gether',
+ 'Tether',
+ 'Pether',
+ 'Eether',
+ 'Zether',
+ 'Yether',
+ 'Nether',
+ 'Dether',
+ 'Vether',
+ 'Uether'
+];
+
+module.exports = {
+ ETH_PADDING: 32,
+ ETH_SIGNATURE_LENGTH: 4,
+ ETH_UNITS: ETH_UNITS,
+ ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
+ ETH_POLLING_TIMEOUT: 1000,
+ ETH_DEFAULTBLOCK: 'latest'
+};
+
+
+},{"bignumber.js":8}],7:[function(require,module,exports){
+/*
+ This file is part of ethereum.js.
+
+ ethereum.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ ethereum.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file utils.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+/**
+ * Utils
+ *
+ * @module utils
+ */
+
+/**
+ * Utility functions
+ *
+ * @class [utils] utils
+ * @constructor
+ */
+
+var BigNumber = require('bignumber.js');
+
+var unitMap = {
+ 'wei': '1',
+ 'kwei': '1000',
+ 'ada': '1000',
+ 'mwei': '1000000',
+ 'babbage': '1000000',
+ 'gwei': '1000000000',
+ 'shannon': '1000000000',
+ 'szabo': '1000000000000',
+ 'finney': '1000000000000000',
+ 'ether': '1000000000000000000',
+ 'kether': '1000000000000000000000',
+ 'grand': '1000000000000000000000',
+ 'einstein': '1000000000000000000000',
+ 'mether': '1000000000000000000000000',
+ 'gether': '1000000000000000000000000000',
+ 'tether': '1000000000000000000000000000000'
+};
+
+/**
+ * Should be called to pad string to expected length
+ *
+ * @method padLeft
+ * @param {String} string to be padded
+ * @param {Number} characters that result string should have
+ * @param {String} sign, by default 0
+ * @returns {String} right aligned string
+ */
+var padLeft = function (string, chars, sign) {
+ return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
+};
+
+/** Finds first index of array element matching pattern
+ *
+ * @method findIndex
+ * @param {Array}
+ * @param {Function} pattern
+ * @returns {Number} index of element
+ */
+var findIndex = function (array, callback) {
+ var end = false;
+ var i = 0;
+ for (; i < array.length && !end; i++) {
+ end = callback(array[i]);
+ }
+ return end ? i - 1 : -1;
+};
+
+/**
+ * Should be called to get sting from it's hex representation
+ *
+ * @method toAscii
+ * @param {String} string in hex
+ * @returns {String} ascii string representation of hex value
+ */
+var toAscii = function(hex) {
+// Find termination
+ var str = "";
+ var i = 0, l = hex.length;
+ if (hex.substring(0, 2) === '0x') {
+ i = 2;
+ }
+ for (; i < l; i+=2) {
+ var code = parseInt(hex.substr(i, 2), 16);
+ if (code === 0) {
+ break;
+ }
+
+ str += String.fromCharCode(code);
+ }
+
+ return str;
+};
+
+/**
+ * Shold be called to get hex representation (prefixed by 0x) of ascii string
+ *
+ * @method fromAscii
+ * @param {String} string
+ * @returns {String} hex representation of input string
+ */
+var toHexNative = function(str) {
+ var hex = "";
+ for(var i = 0; i < str.length; i++) {
+ var n = str.charCodeAt(i).toString(16);
+ hex += n.length < 2 ? '0' + n : n;
+ }
+
+ return hex;
+};
+
+/**
+ * Shold be called to get hex representation (prefixed by 0x) of ascii string
+ *
+ * @method fromAscii
+ * @param {String} string
+ * @param {Number} optional padding
+ * @returns {String} hex representation of input string
+ */
+var fromAscii = function(str, pad) {
+ pad = pad === undefined ? 0 : pad;
+ var hex = toHexNative(str);
+ while (hex.length < pad*2)
+ hex += "00";
+ return "0x" + hex;
+};
+
+/**
+ * Should be called to get display name of contract function
+ *
+ * @method extractDisplayName
+ * @param {String} name of function/event
+ * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
+ */
+var extractDisplayName = function (name) {
+ var length = name.indexOf('(');
+ return length !== -1 ? name.substr(0, length) : name;
+};
+
+/// @returns overloaded part of function/event name
+var extractTypeName = function (name) {
+ /// TODO: make it invulnerable
+ var length = name.indexOf('(');
+ return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
+};
+
+/**
+ * Converts value to it's decimal representation in string
+ *
+ * @method toDecimal
+ * @param {String|Number|BigNumber}
+ * @return {String}
+ */
+var toDecimal = function (value) {
+ return toBigNumber(value).toNumber();
+};
+
+/**
+ * Converts value to it's hex representation
+ *
+ * @method fromDecimal
+ * @param {String|Number|BigNumber}
+ * @return {String}
+ */
+var fromDecimal = function (value) {
+ var number = toBigNumber(value);
+ var result = number.toString(16);
+
+ return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
+};
+
+/**
+ * Auto converts any given value into it's hex representation.
+ *
+ * And even stringifys objects before.
+ *
+ * @method toHex
+ * @param {String|Number|BigNumber|Object}
+ * @return {String}
+ */
+var toHex = function (val) {
+ /*jshint maxcomplexity:7 */
+
+ if (isBoolean(val))
+ return fromDecimal(+val);
+
+ if (isBigNumber(val))
+ return fromDecimal(val);
+
+ if (isObject(val))
+ return fromAscii(JSON.stringify(val));
+
+ // if its a negative number, pass it through fromDecimal
+ if (isString(val)) {
+ if (val.indexOf('-0x') === 0)
+ return fromDecimal(val);
+ else if (!isFinite(val))
+ return fromAscii(val);
+ }
+
+ return fromDecimal(val);
+};
+
+/**
+ * Returns value of unit in Wei
+ *
+ * @method getValueOfUnit
+ * @param {String} unit the unit to convert to, default ether
+ * @returns {BigNumber} value of the unit (in Wei)
+ * @throws error if the unit is not correct:w
+ */
+var getValueOfUnit = function (unit) {
+ unit = unit ? unit.toLowerCase() : 'ether';
+ var unitValue = unitMap[unit];
+ if (unitValue === undefined) {
+ throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
+ }
+ return new BigNumber(unitValue, 10);
+};
+
+/**
+ * Takes a number of wei and converts it to any other ether unit.
+ *
+ * Possible units are:
+ * - kwei/ada
+ * - mwei/babbage
+ * - gwei/shannon
+ * - szabo
+ * - finney
+ * - ether
+ * - kether/grand/einstein
+ * - mether
+ * - gether
+ * - tether
+ *
+ * @method fromWei
+ * @param {Number|String} number can be a number, number string or a HEX of a decimal
+ * @param {String} unit the unit to convert to, default ether
+ * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
+*/
+var fromWei = function(number, unit) {
+ var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
+
+ return isBigNumber(number) ? returnValue : returnValue.toString(10);
+};
+
+/**
+ * Takes a number of a unit and converts it to wei.
+ *
+ * Possible units are:
+ * - kwei/ada
+ * - mwei/babbage
+ * - gwei/shannon
+ * - szabo
+ * - finney
+ * - ether
+ * - kether/grand/einstein
+ * - mether
+ * - gether
+ * - tether
+ *
+ * @method toWei
+ * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
+ * @param {String} unit the unit to convert from, default ether
+ * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
+*/
+var toWei = function(number, unit) {
+ var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
+
+ return isBigNumber(number) ? returnValue : returnValue.toString(10);
+};
+
+/**
+ * Takes an input and transforms it into an bignumber
+ *
+ * @method toBigNumber
+ * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
+ * @return {BigNumber} BigNumber
+*/
+var toBigNumber = function(number) {
+ /*jshint maxcomplexity:5 */
+ number = number || 0;
+ if (isBigNumber(number))
+ return number;
+
+ if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
+ return new BigNumber(number.replace('0x',''), 16);
+ }
+
+ return new BigNumber(number.toString(10), 10);
+};
+
+/**
+ * Takes and input transforms it into bignumber and if it is negative value, into two's complement
+ *
+ * @method toTwosComplement
+ * @param {Number|String|BigNumber}
+ * @return {BigNumber}
+ */
+var toTwosComplement = function (number) {
+ var bigNumber = toBigNumber(number);
+ if (bigNumber.lessThan(0)) {
+ return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
+ }
+ return bigNumber;
+};
+
+/**
+ * Checks if the given string is strictly an address
+ *
+ * @method isStrictAddress
+ * @param {String} address the given HEX adress
+ * @return {Boolean}
+*/
+var isStrictAddress = function (address) {
+ return /^0x[0-9a-f]{40}$/.test(address);
+};
+
+/**
+ * Checks if the given string is an address
+ *
+ * @method isAddress
+ * @param {String} address the given HEX adress
+ * @return {Boolean}
+*/
+var isAddress = function (address) {
+ return /^(0x)?[0-9a-f]{40}$/.test(address);
+};
+
+/**
+ * Transforms given string to valid 20 bytes-length addres with 0x prefix
+ *
+ * @method toAddress
+ * @param {String} address
+ * @return {String} formatted address
+ */
+var toAddress = function (address) {
+ if (isStrictAddress(address)) {
+ return address;
+ }
+
+ if (/^[0-9a-f]{40}$/.test(address)) {
+ return '0x' + address;
+ }
+
+ return '0x' + padLeft(toHex(address).substr(2), 40);
+};
+
+/**
+ * Returns true if object is BigNumber, otherwise false
+ *
+ * @method isBigNumber
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isBigNumber = function (object) {
+ return object instanceof BigNumber ||
+ (object && object.constructor && object.constructor.name === 'BigNumber');
+};
+
+/**
+ * Returns true if object is string, otherwise false
+ *
+ * @method isString
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isString = function (object) {
+ return typeof object === 'string' ||
+ (object && object.constructor && object.constructor.name === 'String');
+};
+
+/**
+ * Returns true if object is function, otherwise false
+ *
+ * @method isFunction
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isFunction = function (object) {
+ return typeof object === 'function';
+};
+
+/**
+ * Returns true if object is Objet, otherwise false
+ *
+ * @method isObject
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isObject = function (object) {
+ return typeof object === 'object';
+};
+
+/**
+ * Returns true if object is boolean, otherwise false
+ *
+ * @method isBoolean
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isBoolean = function (object) {
+ return typeof object === 'boolean';
+};
+
+/**
+ * Returns true if object is array, otherwise false
+ *
+ * @method isArray
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isArray = function (object) {
+ return object instanceof Array;
+};
+
+/**
+ * Returns true if given string is valid json object
+ *
+ * @method isJson
+ * @param {String}
+ * @return {Boolean}
+ */
+var isJson = function (str) {
+ try {
+ return !!JSON.parse(str);
+ } catch (e) {
+ return false;
+ }
+};
+
+module.exports = {
+ padLeft: padLeft,
+ findIndex: findIndex,
+ toHex: toHex,
+ toDecimal: toDecimal,
+ fromDecimal: fromDecimal,
+ toAscii: toAscii,
+ fromAscii: fromAscii,
+ extractDisplayName: extractDisplayName,
+ extractTypeName: extractTypeName,
+ toWei: toWei,
+ fromWei: fromWei,
+ toBigNumber: toBigNumber,
+ toTwosComplement: toTwosComplement,
+ toAddress: toAddress,
+ isBigNumber: isBigNumber,
+ isStrictAddress: isStrictAddress,
+ isAddress: isAddress,
+ isFunction: isFunction,
+ isString: isString,
+ isObject: isObject,
+ isBoolean: isBoolean,
+ isArray: isArray,
+ isJson: isJson
+};
+
+
+},{"bignumber.js":8}],8:[function(require,module,exports){
+/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
+
+;(function (global) {
+ 'use strict';
+
+ /*
+ bignumber.js v2.0.7
+ A JavaScript library for arbitrary-precision arithmetic.
+ https://github.com/MikeMcl/bignumber.js
+ Copyright (c) 2015 Michael Mclaughlin <M8ch88l@gmail.com>
+ MIT Expat Licence
+ */
+
+
+ var BigNumber, crypto, parseNumeric,
+ isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
+ mathceil = Math.ceil,
+ mathfloor = Math.floor,
+ notBool = ' not a boolean or binary digit',
+ roundingMode = 'rounding mode',
+ tooManyDigits = 'number type has more than 15 significant digits',
+ ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
+ BASE = 1e14,
+ LOG_BASE = 14,
+ MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
+ // MAX_INT32 = 0x7fffffff, // 2^31 - 1
+ POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
+ SQRT_BASE = 1e7,
+
+ /*
+ * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
+ * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
+ * exception is thrown (if ERRORS is true).
+ */
+ MAX = 1E9; // 0 to MAX_INT32
+
+
+ /*
+ * Create and return a BigNumber constructor.
+ */
+ function another(configObj) {
+ var div,
+
+ // id tracks the caller function, so its name can be included in error messages.
+ id = 0,
+ P = BigNumber.prototype,
+ ONE = new BigNumber(1),
+
+
+ /********************************* EDITABLE DEFAULTS **********************************/
+
+
+ /*
+ * The default values below must be integers within the inclusive ranges stated.
+ * The values can also be changed at run-time using BigNumber.config.
+ */
+
+ // The maximum number of decimal places for operations involving division.
+ DECIMAL_PLACES = 20, // 0 to MAX
+
+ /*
+ * The rounding mode used when rounding to the above decimal places, and when using
+ * toExponential, toFixed, toFormat and toPrecision, and round (default value).
+ * UP 0 Away from zero.
+ * DOWN 1 Towards zero.
+ * CEIL 2 Towards +Infinity.
+ * FLOOR 3 Towards -Infinity.
+ * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
+ * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
+ * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
+ * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
+ * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
+ */
+ ROUNDING_MODE = 4, // 0 to 8
+
+ // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
+
+ // The exponent value at and beneath which toString returns exponential notation.
+ // Number type: -7
+ TO_EXP_NEG = -7, // 0 to -MAX
+
+ // The exponent value at and above which toString returns exponential notation.
+ // Number type: 21
+ TO_EXP_POS = 21, // 0 to MAX
+
+ // RANGE : [MIN_EXP, MAX_EXP]
+
+ // The minimum exponent value, beneath which underflow to zero occurs.
+ // Number type: -324 (5e-324)
+ MIN_EXP = -1e7, // -1 to -MAX
+
+ // The maximum exponent value, above which overflow to Infinity occurs.
+ // Number type: 308 (1.7976931348623157e+308)
+ // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
+ MAX_EXP = 1e7, // 1 to MAX
+
+ // Whether BigNumber Errors are ever thrown.
+ ERRORS = true, // true or false
+
+ // Change to intValidatorNoErrors if ERRORS is false.
+ isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
+
+ // Whether to use cryptographically-secure random number generation, if available.
+ CRYPTO = false, // true or false
+
+ /*
+ * The modulo mode used when calculating the modulus: a mod n.
+ * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
+ * The remainder (r) is calculated as: r = a - n * q.
+ *
+ * UP 0 The remainder is positive if the dividend is negative, else is negative.
+ * DOWN 1 The remainder has the same sign as the dividend.
+ * This modulo mode is commonly known as 'truncated division' and is
+ * equivalent to (a % n) in JavaScript.
+ * FLOOR 3 The remainder has the same sign as the divisor (Python %).
+ * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
+ * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
+ * The remainder is always positive.
+ *
+ * The truncated division, floored division, Euclidian division and IEEE 754 remainder
+ * modes are commonly used for the modulus operation.
+ * Although the other rounding modes can also be used, they may not give useful results.
+ */
+ MODULO_MODE = 1, // 0 to 9
+
+ // The maximum number of significant digits of the result of the toPower operation.
+ // If POW_PRECISION is 0, there will be unlimited significant digits.
+ POW_PRECISION = 100, // 0 to MAX
+
+ // The format specification used by the BigNumber.prototype.toFormat method.
+ FORMAT = {
+ decimalSeparator: '.',
+ groupSeparator: ',',
+ groupSize: 3,
+ secondaryGroupSize: 0,
+ fractionGroupSeparator: '\xA0', // non-breaking space
+ fractionGroupSize: 0
+ };
+
+
+ /******************************************************************************************/
+
+
+ // CONSTRUCTOR
+
+
+ /*
+ * The BigNumber constructor and exported function.
+ * Create and return a new instance of a BigNumber object.
+ *
+ * n {number|string|BigNumber} A numeric value.
+ * [b] {number} The base of n. Integer, 2 to 64 inclusive.
+ */
+ function BigNumber( n, b ) {
+ var c, e, i, num, len, str,
+ x = this;
+
+ // Enable constructor usage without new.
+ if ( !( x instanceof BigNumber ) ) {
+
+ // 'BigNumber() constructor call without new: {n}'
+ if (ERRORS) raise( 26, 'constructor call without new', n );
+ return new BigNumber( n, b );
+ }
+
+ // 'new BigNumber() base not an integer: {b}'
+ // 'new BigNumber() base out of range: {b}'
+ if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
+
+ // Duplicate.
+ if ( n instanceof BigNumber ) {
+ x.s = n.s;
+ x.e = n.e;
+ x.c = ( n = n.c ) ? n.slice() : n;
+ id = 0;
+ return;
+ }
+
+ if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
+ x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
+
+ // Fast path for integers.
+ if ( n === ~~n ) {
+ for ( e = 0, i = n; i >= 10; i /= 10, e++ );
+ x.e = e;
+ x.c = [n];
+ id = 0;
+ return;
+ }
+
+ str = n + '';
+ } else {
+ if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
+ x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
+ }
+ } else {
+ b = b | 0;
+ str = n + '';
+
+ // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
+ // Allow exponential notation to be used with base 10 argument.
+ if ( b == 10 ) {
+ x = new BigNumber( n instanceof BigNumber ? n : str );
+ return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
+ }
+
+ // Avoid potential interpretation of Infinity and NaN as base 44+ values.
+ // Any number in exponential form will fail due to the [Ee][+-].
+ if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
+ !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
+ '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
+ return parseNumeric( x, str, num, b );
+ }
+
+ if (num) {
+ x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
+
+ if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
+
+ // 'new BigNumber() number type has more than 15 significant digits: {n}'
+ raise( id, tooManyDigits, n );
+ }
+
+ // Prevent later check for length on converted number.
+ num = false;
+ } else {
+ x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
+ }
+
+ str = convertBase( str, 10, b, x.s );
+ }
+
+ // Decimal point?
+ if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
+
+ // Exponential form?
+ if ( ( i = str.search( /e/i ) ) > 0 ) {
+
+ // Determine exponent.
+ if ( e < 0 ) e = i;
+ e += +str.slice( i + 1 );
+ str = str.substring( 0, i );
+ } else if ( e < 0 ) {
+
+ // Integer.
+ e = str.length;
+ }
+
+ // Determine leading zeros.
+ for ( i = 0; str.charCodeAt(i) === 48; i++ );
+
+ // Determine trailing zeros.
+ for ( len = str.length; str.charCodeAt(--len) === 48; );
+ str = str.slice( i, len + 1 );
+
+ if (str) {
+ len = str.length;
+
+ // Disallow numbers with over 15 significant digits if number type.
+ // 'new BigNumber() number type has more than 15 significant digits: {n}'
+ if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
+
+ e = e - i - 1;
+
+ // Overflow?
+ if ( e > MAX_EXP ) {
+
+ // Infinity.
+ x.c = x.e = null;
+
+ // Underflow?
+ } else if ( e < MIN_EXP ) {
+
+ // Zero.
+ x.c = [ x.e = 0 ];
+ } else {
+ x.e = e;
+ x.c = [];
+
+ // Transform base
+
+ // e is the base 10 exponent.
+ // i is where to slice str to get the first element of the coefficient array.
+ i = ( e + 1 ) % LOG_BASE;
+ if ( e < 0 ) i += LOG_BASE;
+
+ if ( i < len ) {
+ if (i) x.c.push( +str.slice( 0, i ) );
+
+ for ( len -= LOG_BASE; i < len; ) {
+ x.c.push( +str.slice( i, i += LOG_BASE ) );
+ }
+
+ str = str.slice(i);
+ i = LOG_BASE - str.length;
+ } else {
+ i -= len;
+ }
+
+ for ( ; i--; str += '0' );
+ x.c.push( +str );
+ }
+ } else {
+
+ // Zero.
+ x.c = [ x.e = 0 ];
+ }
+
+ id = 0;
+ }
+
+
+ // CONSTRUCTOR PROPERTIES
+
+
+ BigNumber.another = another;
+
+ BigNumber.ROUND_UP = 0;
+ BigNumber.ROUND_DOWN = 1;
+ BigNumber.ROUND_CEIL = 2;
+ BigNumber.ROUND_FLOOR = 3;
+ BigNumber.ROUND_HALF_UP = 4;
+ BigNumber.ROUND_HALF_DOWN = 5;
+ BigNumber.ROUND_HALF_EVEN = 6;
+ BigNumber.ROUND_HALF_CEIL = 7;
+ BigNumber.ROUND_HALF_FLOOR = 8;
+ BigNumber.EUCLID = 9;
+
+
+ /*
+ * Configure infrequently-changing library-wide settings.
+ *
+ * Accept an object or an argument list, with one or many of the following properties or
+ * parameters respectively:
+ *
+ * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
+ * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
+ * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
+ * [integer -MAX to 0 incl., 0 to MAX incl.]
+ * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
+ * [integer -MAX to -1 incl., integer 1 to MAX incl.]
+ * ERRORS {boolean|number} true, false, 1 or 0
+ * CRYPTO {boolean|number} true, false, 1 or 0
+ * MODULO_MODE {number} 0 to 9 inclusive
+ * POW_PRECISION {number} 0 to MAX inclusive
+ * FORMAT {object} See BigNumber.prototype.toFormat
+ * decimalSeparator {string}
+ * groupSeparator {string}
+ * groupSize {number}
+ * secondaryGroupSize {number}
+ * fractionGroupSeparator {string}
+ * fractionGroupSize {number}
+ *
+ * (The values assigned to the above FORMAT object properties are not checked for validity.)
+ *
+ * E.g.
+ * BigNumber.config(20, 4) is equivalent to
+ * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
+ *
+ * Ignore properties/parameters set to null or undefined.
+ * Return an object with the properties current values.
+ */
+ BigNumber.config = function () {
+ var v, p,
+ i = 0,
+ r = {},
+ a = arguments,
+ o = a[0],
+ has = o && typeof o == 'object'
+ ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
+ : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
+
+ // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
+ // 'config() DECIMAL_PLACES not an integer: {v}'
+ // 'config() DECIMAL_PLACES out of range: {v}'
+ if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
+ DECIMAL_PLACES = v | 0;
+ }
+ r[p] = DECIMAL_PLACES;
+
+ // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
+ // 'config() ROUNDING_MODE not an integer: {v}'
+ // 'config() ROUNDING_MODE out of range: {v}'
+ if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
+ ROUNDING_MODE = v | 0;
+ }
+ r[p] = ROUNDING_MODE;
+
+ // EXPONENTIAL_AT {number|number[]}
+ // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
+ // 'config() EXPONENTIAL_AT not an integer: {v}'
+ // 'config() EXPONENTIAL_AT out of range: {v}'
+ if ( has( p = 'EXPONENTIAL_AT' ) ) {
+
+ if ( isArray(v) ) {
+ if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
+ TO_EXP_NEG = v[0] | 0;
+ TO_EXP_POS = v[1] | 0;
+ }
+ } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
+ TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
+ }
+ }
+ r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
+
+ // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
+ // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
+ // 'config() RANGE not an integer: {v}'
+ // 'config() RANGE cannot be zero: {v}'
+ // 'config() RANGE out of range: {v}'
+ if ( has( p = 'RANGE' ) ) {
+
+ if ( isArray(v) ) {
+ if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
+ MIN_EXP = v[0] | 0;
+ MAX_EXP = v[1] | 0;
+ }
+ } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
+ if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
+ else if (ERRORS) raise( 2, p + ' cannot be zero', v );
+ }
+ }
+ r[p] = [ MIN_EXP, MAX_EXP ];
+
+ // ERRORS {boolean|number} true, false, 1 or 0.
+ // 'config() ERRORS not a boolean or binary digit: {v}'
+ if ( has( p = 'ERRORS' ) ) {
+
+ if ( v === !!v || v === 1 || v === 0 ) {
+ id = 0;
+ isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
+ } else if (ERRORS) {
+ raise( 2, p + notBool, v );
+ }
+ }
+ r[p] = ERRORS;
+
+ // CRYPTO {boolean|number} true, false, 1 or 0.
+ // 'config() CRYPTO not a boolean or binary digit: {v}'
+ // 'config() crypto unavailable: {crypto}'
+ if ( has( p = 'CRYPTO' ) ) {
+
+ if ( v === !!v || v === 1 || v === 0 ) {
+ CRYPTO = !!( v && crypto && typeof crypto == 'object' );
+ if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
+ } else if (ERRORS) {
+ raise( 2, p + notBool, v );
+ }
+ }
+ r[p] = CRYPTO;
+
+ // MODULO_MODE {number} Integer, 0 to 9 inclusive.
+ // 'config() MODULO_MODE not an integer: {v}'
+ // 'config() MODULO_MODE out of range: {v}'
+ if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
+ MODULO_MODE = v | 0;
+ }
+ r[p] = MODULO_MODE;
+
+ // POW_PRECISION {number} Integer, 0 to MAX inclusive.
+ // 'config() POW_PRECISION not an integer: {v}'
+ // 'config() POW_PRECISION out of range: {v}'
+ if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
+ POW_PRECISION = v | 0;
+ }
+ r[p] = POW_PRECISION;
+
+ // FORMAT {object}
+ // 'config() FORMAT not an object: {v}'
+ if ( has( p = 'FORMAT' ) ) {
+
+ if ( typeof v == 'object' ) {
+ FORMAT = v;
+ } else if (ERRORS) {
+ raise( 2, p + ' not an object', v );
+ }
+ }
+ r[p] = FORMAT;
+
+ return r;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the maximum of the arguments.
+ *
+ * arguments {number|string|BigNumber}
+ */
+ BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
+
+
+ /*
+ * Return a new BigNumber whose value is the minimum of the arguments.
+ *
+ * arguments {number|string|BigNumber}
+ */
+ BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
+
+
+ /*
+ * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
+ * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
+ * zeros are produced).
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ *
+ * 'random() decimal places not an integer: {dp}'
+ * 'random() decimal places out of range: {dp}'
+ * 'random() crypto unavailable: {crypto}'
+ */
+ BigNumber.random = (function () {
+ var pow2_53 = 0x20000000000000;
+
+ // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
+ // Check if Math.random() produces more than 32 bits of randomness.
+ // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
+ // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
+ var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
+ ? function () { return mathfloor( Math.random() * pow2_53 ); }
+ : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
+ (Math.random() * 0x800000 | 0); };
+
+ return function (dp) {
+ var a, b, e, k, v,
+ i = 0,
+ c = [],
+ rand = new BigNumber(ONE);
+
+ dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
+ k = mathceil( dp / LOG_BASE );
+
+ if (CRYPTO) {
+
+ // Browsers supporting crypto.getRandomValues.
+ if ( crypto && crypto.getRandomValues ) {
+
+ a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
+
+ for ( ; i < k; ) {
+
+ // 53 bits:
+ // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
+ // 11111 11111111 11111111 11111111 11100000 00000000 00000000
+ // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
+ // 11111 11111111 11111111
+ // 0x20000 is 2^21.
+ v = a[i] * 0x20000 + (a[i + 1] >>> 11);
+
+ // Rejection sampling:
+ // 0 <= v < 9007199254740992
+ // Probability that v >= 9e15, is
+ // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
+ if ( v >= 9e15 ) {
+ b = crypto.getRandomValues( new Uint32Array(2) );
+ a[i] = b[0];
+ a[i + 1] = b[1];
+ } else {
+
+ // 0 <= v <= 8999999999999999
+ // 0 <= (v % 1e14) <= 99999999999999
+ c.push( v % 1e14 );
+ i += 2;
+ }
+ }
+ i = k / 2;
+
+ // Node.js supporting crypto.randomBytes.
+ } else if ( crypto && crypto.randomBytes ) {
+
+ // buffer
+ a = crypto.randomBytes( k *= 7 );
+
+ for ( ; i < k; ) {
+
+ // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
+ // 0x100000000 is 2^32, 0x1000000 is 2^24
+ // 11111 11111111 11111111 11111111 11111111 11111111 11111111
+ // 0 <= v < 9007199254740992
+ v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
+ ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
+ ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
+
+ if ( v >= 9e15 ) {
+ crypto.randomBytes(7).copy( a, i );
+ } else {
+
+ // 0 <= (v % 1e14) <= 99999999999999
+ c.push( v % 1e14 );
+ i += 7;
+ }
+ }
+ i = k / 7;
+ } else if (ERRORS) {
+ raise( 14, 'crypto unavailable', crypto );
+ }
+ }
+
+ // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
+ if (!i) {
+
+ for ( ; i < k; ) {
+ v = random53bitInt();
+ if ( v < 9e15 ) c[i++] = v % 1e14;
+ }
+ }
+
+ k = c[--i];
+ dp %= LOG_BASE;
+
+ // Convert trailing digits to zeros according to dp.
+ if ( k && dp ) {
+ v = POWS_TEN[LOG_BASE - dp];
+ c[i] = mathfloor( k / v ) * v;
+ }
+
+ // Remove trailing elements which are zero.
+ for ( ; c[i] === 0; c.pop(), i-- );
+
+ // Zero?
+ if ( i < 0 ) {
+ c = [ e = 0 ];
+ } else {
+
+ // Remove leading elements which are zero and adjust exponent accordingly.
+ for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
+
+ // Count the digits of the first element of c to determine leading zeros, and...
+ for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
+
+ // adjust the exponent accordingly.
+ if ( i < LOG_BASE ) e -= LOG_BASE - i;
+ }
+
+ rand.e = e;
+ rand.c = c;
+ return rand;
+ };
+ })();
+
+
+ // PRIVATE FUNCTIONS
+
+
+ // Convert a numeric string of baseIn to a numeric string of baseOut.
+ function convertBase( str, baseOut, baseIn, sign ) {
+ var d, e, k, r, x, xc, y,
+ i = str.indexOf( '.' ),
+ dp = DECIMAL_PLACES,
+ rm = ROUNDING_MODE;
+
+ if ( baseIn < 37 ) str = str.toLowerCase();
+
+ // Non-integer.
+ if ( i >= 0 ) {
+ k = POW_PRECISION;
+
+ // Unlimited precision.
+ POW_PRECISION = 0;
+ str = str.replace( '.', '' );
+ y = new BigNumber(baseIn);
+ x = y.pow( str.length - i );
+ POW_PRECISION = k;
+
+ // Convert str as if an integer, then restore the fraction part by dividing the
+ // result by its base raised to a power.
+ y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
+ y.e = y.c.length;
+ }
+
+ // Convert the number as integer.
+ xc = toBaseOut( str, baseIn, baseOut );
+ e = k = xc.length;
+
+ // Remove trailing zeros.
+ for ( ; xc[--k] == 0; xc.pop() );
+ if ( !xc[0] ) return '0';
+
+ if ( i < 0 ) {
+ --e;
+ } else {
+ x.c = xc;
+ x.e = e;
+
+ // sign is needed for correct rounding.
+ x.s = sign;
+ x = div( x, y, dp, rm, baseOut );
+ xc = x.c;
+ r = x.r;
+ e = x.e;
+ }
+
+ d = e + dp + 1;
+
+ // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
+ i = xc[d];
+ k = baseOut / 2;
+ r = r || d < 0 || xc[d + 1] != null;
+
+ r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
+ : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
+ rm == ( x.s < 0 ? 8 : 7 ) );
+
+ if ( d < 1 || !xc[0] ) {
+
+ // 1^-dp or 0.
+ str = r ? toFixedPoint( '1', -dp ) : '0';
+ } else {
+ xc.length = d;
+
+ if (r) {
+
+ // Rounding up may mean the previous digit has to be rounded up and so on.
+ for ( --baseOut; ++xc[--d] > baseOut; ) {
+ xc[d] = 0;
+
+ if ( !d ) {
+ ++e;
+ xc.unshift(1);
+ }
+ }
+ }
+
+ // Determine trailing zeros.
+ for ( k = xc.length; !xc[--k]; );
+
+ // E.g. [4, 11, 15] becomes 4bf.
+ for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
+ str = toFixedPoint( str, e );
+ }
+
+ // The caller will add the sign.
+ return str;
+ }
+
+
+ // Perform division in the specified base. Called by div and convertBase.
+ div = (function () {
+
+ // Assume non-zero x and k.
+ function multiply( x, k, base ) {
+ var m, temp, xlo, xhi,
+ carry = 0,
+ i = x.length,
+ klo = k % SQRT_BASE,
+ khi = k / SQRT_BASE | 0;
+
+ for ( x = x.slice(); i--; ) {
+ xlo = x[i] % SQRT_BASE;
+ xhi = x[i] / SQRT_BASE | 0;
+ m = khi * xlo + xhi * klo;
+ temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
+ carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
+ x[i] = temp % base;
+ }
+
+ if (carry) x.unshift(carry);
+
+ return x;
+ }
+
+ function compare( a, b, aL, bL ) {
+ var i, cmp;
+
+ if ( aL != bL ) {
+ cmp = aL > bL ? 1 : -1;
+ } else {
+
+ for ( i = cmp = 0; i < aL; i++ ) {
+
+ if ( a[i] != b[i] ) {
+ cmp = a[i] > b[i] ? 1 : -1;
+ break;
+ }
+ }
+ }
+ return cmp;
+ }
+
+ function subtract( a, b, aL, base ) {
+ var i = 0;
+
+ // Subtract b from a.
+ for ( ; aL--; ) {
+ a[aL] -= i;
+ i = a[aL] < b[aL] ? 1 : 0;
+ a[aL] = i * base + a[aL] - b[aL];
+ }
+
+ // Remove leading zeros.
+ for ( ; !a[0] && a.length > 1; a.shift() );
+ }
+
+ // x: dividend, y: divisor.
+ return function ( x, y, dp, rm, base ) {
+ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
+ yL, yz,
+ s = x.s == y.s ? 1 : -1,
+ xc = x.c,
+ yc = y.c;
+
+ // Either NaN, Infinity or 0?
+ if ( !xc || !xc[0] || !yc || !yc[0] ) {
+
+ return new BigNumber(
+
+ // Return NaN if either NaN, or both Infinity or 0.
+ !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
+
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
+ );
+ }
+
+ q = new BigNumber(s);
+ qc = q.c = [];
+ e = x.e - y.e;
+ s = dp + e + 1;
+
+ if ( !base ) {
+ base = BASE;
+ e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
+ s = s / LOG_BASE | 0;
+ }
+
+ // Result exponent may be one less then the current value of e.
+ // The coefficients of the BigNumbers from convertBase may have trailing zeros.
+ for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
+ if ( yc[i] > ( xc[i] || 0 ) ) e--;
+
+ if ( s < 0 ) {
+ qc.push(1);
+ more = true;
+ } else {
+ xL = xc.length;
+ yL = yc.length;
+ i = 0;
+ s += 2;
+
+ // Normalise xc and yc so highest order digit of yc is >= base / 2.
+
+ n = mathfloor( base / ( yc[0] + 1 ) );
+
+ // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
+ // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
+ if ( n > 1 ) {
+ yc = multiply( yc, n, base );
+ xc = multiply( xc, n, base );
+ yL = yc.length;
+ xL = xc.length;
+ }
+
+ xi = yL;
+ rem = xc.slice( 0, yL );
+ remL = rem.length;
+
+ // Add zeros to make remainder as long as divisor.
+ for ( ; remL < yL; rem[remL++] = 0 );
+ yz = yc.slice();
+ yz.unshift(0);
+ yc0 = yc[0];
+ if ( yc[1] >= base / 2 ) yc0++;
+ // Not necessary, but to prevent trial digit n > base, when using base 3.
+ // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
+
+ do {
+ n = 0;
+
+ // Compare divisor and remainder.
+ cmp = compare( yc, rem, yL, remL );
+
+ // If divisor < remainder.
+ if ( cmp < 0 ) {
+
+ // Calculate trial digit, n.
+
+ rem0 = rem[0];
+ if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
+
+ // n is how many times the divisor goes into the current remainder.
+ n = mathfloor( rem0 / yc0 );
+
+ // Algorithm:
+ // 1. product = divisor * trial digit (n)
+ // 2. if product > remainder: product -= divisor, n--
+ // 3. remainder -= product
+ // 4. if product was < remainder at 2:
+ // 5. compare new remainder and divisor
+ // 6. If remainder > divisor: remainder -= divisor, n++
+
+ if ( n > 1 ) {
+
+ // n may be > base only when base is 3.
+ if (n >= base) n = base - 1;
+
+ // product = divisor * trial digit.
+ prod = multiply( yc, n, base );
+ prodL = prod.length;
+ remL = rem.length;
+
+ // Compare product and remainder.
+ // If product > remainder.
+ // Trial digit n too high.
+ // n is 1 too high about 5% of the time, and is not known to have
+ // ever been more than 1 too high.
+ while ( compare( prod, rem, prodL, remL ) == 1 ) {
+ n--;
+
+ // Subtract divisor from product.
+ subtract( prod, yL < prodL ? yz : yc, prodL, base );
+ prodL = prod.length;
+ cmp = 1;
+ }
+ } else {
+
+ // n is 0 or 1, cmp is -1.
+ // If n is 0, there is no need to compare yc and rem again below,
+ // so change cmp to 1 to avoid it.
+ // If n is 1, leave cmp as -1, so yc and rem are compared again.
+ if ( n == 0 ) {
+
+ // divisor < remainder, so n must be at least 1.
+ cmp = n = 1;
+ }
+
+ // product = divisor
+ prod = yc.slice();
+ prodL = prod.length;
+ }
+
+ if ( prodL < remL ) prod.unshift(0);
+
+ // Subtract product from remainder.
+ subtract( rem, prod, remL, base );
+ remL = rem.length;
+
+ // If product was < remainder.
+ if ( cmp == -1 ) {
+
+ // Compare divisor and new remainder.
+ // If divisor < new remainder, subtract divisor from remainder.
+ // Trial digit n too low.
+ // n is 1 too low about 5% of the time, and very rarely 2 too low.
+ while ( compare( yc, rem, yL, remL ) < 1 ) {
+ n++;
+
+ // Subtract divisor from remainder.
+ subtract( rem, yL < remL ? yz : yc, remL, base );
+ remL = rem.length;
+ }
+ }
+ } else if ( cmp === 0 ) {
+ n++;
+ rem = [0];
+ } // else cmp === 1 and n will be 0
+
+ // Add the next digit, n, to the result array.
+ qc[i++] = n;
+
+ // Update the remainder.
+ if ( rem[0] ) {
+ rem[remL++] = xc[xi] || 0;
+ } else {
+ rem = [ xc[xi] ];
+ remL = 1;
+ }
+ } while ( ( xi++ < xL || rem[0] != null ) && s-- );
+
+ more = rem[0] != null;
+
+ // Leading zero?
+ if ( !qc[0] ) qc.shift();
+ }
+
+ if ( base == BASE ) {
+
+ // To calculate q.e, first get the number of digits of qc[0].
+ for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
+ round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
+
+ // Caller is convertBase.
+ } else {
+ q.e = e;
+ q.r = +more;
+ }
+
+ return q;
+ };
+ })();
+
+
+ /*
+ * Return a string representing the value of BigNumber n in fixed-point or exponential
+ * notation rounded to the specified decimal places or significant digits.
+ *
+ * n is a BigNumber.
+ * i is the index of the last digit required (i.e. the digit that may be rounded up).
+ * rm is the rounding mode.
+ * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
+ */
+ function format( n, i, rm, caller ) {
+ var c0, e, ne, len, str;
+
+ rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
+ ? rm | 0 : ROUNDING_MODE;
+
+ if ( !n.c ) return n.toString();
+ c0 = n.c[0];
+ ne = n.e;
+
+ if ( i == null ) {
+ str = coeffToString( n.c );
+ str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
+ ? toExponential( str, ne )
+ : toFixedPoint( str, ne );
+ } else {
+ n = round( new BigNumber(n), i, rm );
+
+ // n.e may have changed if the value was rounded up.
+ e = n.e;
+
+ str = coeffToString( n.c );
+ len = str.length;
+
+ // toPrecision returns exponential notation if the number of significant digits
+ // specified is less than the number of digits necessary to represent the integer
+ // part of the value in fixed-point notation.
+
+ // Exponential notation.
+ if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
+
+ // Append zeros?
+ for ( ; len < i; str += '0', len++ );
+ str = toExponential( str, e );
+
+ // Fixed-point notation.
+ } else {
+ i -= ne;
+ str = toFixedPoint( str, e );
+
+ // Append zeros?
+ if ( e + 1 > len ) {
+ if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
+ } else {
+ i += e - len;
+ if ( i > 0 ) {
+ if ( e + 1 == len ) str += '.';
+ for ( ; i--; str += '0' );
+ }
+ }
+ }
+ }
+
+ return n.s < 0 && c0 ? '-' + str : str;
+ }
+
+
+ // Handle BigNumber.max and BigNumber.min.
+ function maxOrMin( args, method ) {
+ var m, n,
+ i = 0;
+
+ if ( isArray( args[0] ) ) args = args[0];
+ m = new BigNumber( args[0] );
+
+ for ( ; ++i < args.length; ) {
+ n = new BigNumber( args[i] );
+
+ // If any number is NaN, return NaN.
+ if ( !n.s ) {
+ m = n;
+ break;
+ } else if ( method.call( m, n ) ) {
+ m = n;
+ }
+ }
+
+ return m;
+ }
+
+
+ /*
+ * Return true if n is an integer in range, otherwise throw.
+ * Use for argument validation when ERRORS is true.
+ */
+ function intValidatorWithErrors( n, min, max, caller, name ) {
+ if ( n < min || n > max || n != truncate(n) ) {
+ raise( caller, ( name || 'decimal places' ) +
+ ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
+ }
+
+ return true;
+ }
+
+
+ /*
+ * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
+ * Called by minus, plus and times.
+ */
+ function normalise( n, c, e ) {
+ var i = 1,
+ j = c.length;
+
+ // Remove trailing zeros.
+ for ( ; !c[--j]; c.pop() );
+
+ // Calculate the base 10 exponent. First get the number of digits of c[0].
+ for ( j = c[0]; j >= 10; j /= 10, i++ );
+
+ // Overflow?
+ if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
+
+ // Infinity.
+ n.c = n.e = null;
+
+ // Underflow?
+ } else if ( e < MIN_EXP ) {
+
+ // Zero.
+ n.c = [ n.e = 0 ];
+ } else {
+ n.e = e;
+ n.c = c;
+ }
+
+ return n;
+ }
+
+
+ // Handle values that fail the validity test in BigNumber.
+ parseNumeric = (function () {
+ var basePrefix=/^(-?)0([xbo])/i,
+ dotAfter=/^([^.]+)\.$/,
+ dotBefore=/^\.([^.]+)$/,
+ isInfinityOrNaN=/^-?(Infinity|NaN)$/,
+ whitespaceOrPlus=/^\s*\+|^\s+|\s+$/g;
+
+ return function ( x, str, num, b ) {
+ var base,
+ s = num ? str : str.replace( whitespaceOrPlus, '' );
+
+ // No exception on ±Infinity or NaN.
+ if ( isInfinityOrNaN.test(s) ) {
+ x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
+ } else {
+ if ( !num ) {
+
+ // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
+ s = s.replace( basePrefix, function ( m, p1, p2 ) {
+ base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
+ return !b || b == base ? p1 : m;
+ });
+
+ if (b) {
+ base = b;
+
+ // E.g. '1.' to '1', '.1' to '0.1'
+ s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
+ }
+
+ if ( str != s ) return new BigNumber( s, base );
+ }
+
+ // 'new BigNumber() not a number: {n}'
+ // 'new BigNumber() not a base {b} number: {n}'
+ if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
+ x.s = null;
+ }
+
+ x.c = x.e = null;
+ id = 0;
+ }
+ })();
+
+
+ // Throw a BigNumber Error.
+ function raise( caller, msg, val ) {
+ var error = new Error( [
+ 'new BigNumber', // 0
+ 'cmp', // 1
+ 'config', // 2
+ 'div', // 3
+ 'divToInt', // 4
+ 'eq', // 5
+ 'gt', // 6
+ 'gte', // 7
+ 'lt', // 8
+ 'lte', // 9
+ 'minus', // 10
+ 'mod', // 11
+ 'plus', // 12
+ 'precision', // 13
+ 'random', // 14
+ 'round', // 15
+ 'shift', // 16
+ 'times', // 17
+ 'toDigits', // 18
+ 'toExponential', // 19
+ 'toFixed', // 20
+ 'toFormat', // 21
+ 'toFraction', // 22
+ 'pow', // 23
+ 'toPrecision', // 24
+ 'toString', // 25
+ 'BigNumber' // 26
+ ][caller] + '() ' + msg + ': ' + val );
+
+ error.name = 'BigNumber Error';
+ id = 0;
+ throw error;
+ }
+
+
+ /*
+ * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
+ * If r is truthy, it is known that there are more digits after the rounding digit.
+ */
+ function round( x, sd, rm, r ) {
+ var d, i, j, k, n, ni, rd,
+ xc = x.c,
+ pows10 = POWS_TEN;
+
+ // if x is not Infinity or NaN...
+ if (xc) {
+
+ // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
+ // n is a base 1e14 number, the value of the element of array x.c containing rd.
+ // ni is the index of n within x.c.
+ // d is the number of digits of n.
+ // i is the index of rd within n including leading zeros.
+ // j is the actual index of rd within n (if < 0, rd is a leading zero).
+ out: {
+
+ // Get the number of digits of the first element of xc.
+ for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
+ i = sd - d;
+
+ // If the rounding digit is in the first element of xc...
+ if ( i < 0 ) {
+ i += LOG_BASE;
+ j = sd;
+ n = xc[ ni = 0 ];
+
+ // Get the rounding digit at index j of n.
+ rd = n / pows10[ d - j - 1 ] % 10 | 0;
+ } else {
+ ni = mathceil( ( i + 1 ) / LOG_BASE );
+
+ if ( ni >= xc.length ) {
+
+ if (r) {
+
+ // Needed by sqrt.
+ for ( ; xc.length <= ni; xc.push(0) );
+ n = rd = 0;
+ d = 1;
+ i %= LOG_BASE;
+ j = i - LOG_BASE + 1;
+ } else {
+ break out;
+ }
+ } else {
+ n = k = xc[ni];
+
+ // Get the number of digits of n.
+ for ( d = 1; k >= 10; k /= 10, d++ );
+
+ // Get the index of rd within n.
+ i %= LOG_BASE;
+
+ // Get the index of rd within n, adjusted for leading zeros.
+ // The number of leading zeros of n is given by LOG_BASE - d.
+ j = i - LOG_BASE + d;
+
+ // Get the rounding digit at index j of n.
+ rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
+ }
+ }
+
+ r = r || sd < 0 ||
+
+ // Are there any non-zero digits after the rounding digit?
+ // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
+ xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
+
+ r = rm < 4
+ ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
+ : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
+
+ // Check whether the digit to the left of the rounding digit is odd.
+ ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
+ rm == ( x.s < 0 ? 8 : 7 ) );
+
+ if ( sd < 1 || !xc[0] ) {
+ xc.length = 0;
+
+ if (r) {
+
+ // Convert sd to decimal places.
+ sd -= x.e + 1;
+
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
+ xc[0] = pows10[ sd % LOG_BASE ];
+ x.e = -sd || 0;
+ } else {
+
+ // Zero.
+ xc[0] = x.e = 0;
+ }
+
+ return x;
+ }
+
+ // Remove excess digits.
+ if ( i == 0 ) {
+ xc.length = ni;
+ k = 1;
+ ni--;
+ } else {
+ xc.length = ni + 1;
+ k = pows10[ LOG_BASE - i ];
+
+ // E.g. 56700 becomes 56000 if 7 is the rounding digit.
+ // j > 0 means i > number of leading zeros of n.
+ xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
+ }
+
+ // Round up?
+ if (r) {
+
+ for ( ; ; ) {
+
+ // If the digit to be rounded up is in the first element of xc...
+ if ( ni == 0 ) {
+
+ // i will be the length of xc[0] before k is added.
+ for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
+ j = xc[0] += k;
+ for ( k = 1; j >= 10; j /= 10, k++ );
+
+ // if i != k the length has increased.
+ if ( i != k ) {
+ x.e++;
+ if ( xc[0] == BASE ) xc[0] = 1;
+ }
+
+ break;
+ } else {
+ xc[ni] += k;
+ if ( xc[ni] != BASE ) break;
+ xc[ni--] = 0;
+ k = 1;
+ }
+ }
+ }
+
+ // Remove trailing zeros.
+ for ( i = xc.length; xc[--i] === 0; xc.pop() );
+ }
+
+ // Overflow? Infinity.
+ if ( x.e > MAX_EXP ) {
+ x.c = x.e = null;
+
+ // Underflow? Zero.
+ } else if ( x.e < MIN_EXP ) {
+ x.c = [ x.e = 0 ];
+ }
+ }
+
+ return x;
+ }
+
+
+ // PROTOTYPE/INSTANCE METHODS
+
+
+ /*
+ * Return a new BigNumber whose value is the absolute value of this BigNumber.
+ */
+ P.absoluteValue = P.abs = function () {
+ var x = new BigNumber(this);
+ if ( x.s < 0 ) x.s = 1;
+ return x;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
+ * number in the direction of Infinity.
+ */
+ P.ceil = function () {
+ return round( new BigNumber(this), this.e + 1, 2 );
+ };
+
+
+ /*
+ * Return
+ * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
+ * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
+ * 0 if they have the same value,
+ * or null if the value of either is NaN.
+ */
+ P.comparedTo = P.cmp = function ( y, b ) {
+ id = 1;
+ return compare( this, new BigNumber( y, b ) );
+ };
+
+
+ /*
+ * Return the number of decimal places of the value of this BigNumber, or null if the value
+ * of this BigNumber is ±Infinity or NaN.
+ */
+ P.decimalPlaces = P.dp = function () {
+ var n, v,
+ c = this.c;
+
+ if ( !c ) return null;
+ n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
+
+ // Subtract the number of trailing zeros of the last number.
+ if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
+ if ( n < 0 ) n = 0;
+
+ return n;
+ };
+
+
+ /*
+ * n / 0 = I
+ * n / N = N
+ * n / I = 0
+ * 0 / n = 0
+ * 0 / 0 = N
+ * 0 / N = N
+ * 0 / I = 0
+ * N / n = N
+ * N / 0 = N
+ * N / N = N
+ * N / I = N
+ * I / n = I
+ * I / 0 = I
+ * I / N = N
+ * I / I = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
+ * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
+ */
+ P.dividedBy = P.div = function ( y, b ) {
+ id = 3;
+ return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the integer part of dividing the value of this
+ * BigNumber by the value of BigNumber(y, b).
+ */
+ P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
+ id = 4;
+ return div( this, new BigNumber( y, b ), 0, 1 );
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
+ * otherwise returns false.
+ */
+ P.equals = P.eq = function ( y, b ) {
+ id = 5;
+ return compare( this, new BigNumber( y, b ) ) === 0;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
+ * number in the direction of -Infinity.
+ */
+ P.floor = function () {
+ return round( new BigNumber(this), this.e + 1, 3 );
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
+ * otherwise returns false.
+ */
+ P.greaterThan = P.gt = function ( y, b ) {
+ id = 6;
+ return compare( this, new BigNumber( y, b ) ) > 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is greater than or equal to the value of
+ * BigNumber(y, b), otherwise returns false.
+ */
+ P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
+ id = 7;
+ return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
+
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is a finite number, otherwise returns false.
+ */
+ P.isFinite = function () {
+ return !!this.c;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is an integer, otherwise return false.
+ */
+ P.isInteger = P.isInt = function () {
+ return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is NaN, otherwise returns false.
+ */
+ P.isNaN = function () {
+ return !this.s;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is negative, otherwise returns false.
+ */
+ P.isNegative = P.isNeg = function () {
+ return this.s < 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
+ */
+ P.isZero = function () {
+ return !!this.c && this.c[0] == 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
+ * otherwise returns false.
+ */
+ P.lessThan = P.lt = function ( y, b ) {
+ id = 8;
+ return compare( this, new BigNumber( y, b ) ) < 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is less than or equal to the value of
+ * BigNumber(y, b), otherwise returns false.
+ */
+ P.lessThanOrEqualTo = P.lte = function ( y, b ) {
+ id = 9;
+ return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
+ };
+
+
+ /*
+ * n - 0 = n
+ * n - N = N
+ * n - I = -I
+ * 0 - n = -n
+ * 0 - 0 = 0
+ * 0 - N = N
+ * 0 - I = -I
+ * N - n = N
+ * N - 0 = N
+ * N - N = N
+ * N - I = N
+ * I - n = I
+ * I - 0 = I
+ * I - N = N
+ * I - I = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber minus the value of
+ * BigNumber(y, b).
+ */
+ P.minus = P.sub = function ( y, b ) {
+ var i, j, t, xLTy,
+ x = this,
+ a = x.s;
+
+ id = 10;
+ y = new BigNumber( y, b );
+ b = y.s;
+
+ // Either NaN?
+ if ( !a || !b ) return new BigNumber(NaN);
+
+ // Signs differ?
+ if ( a != b ) {
+ y.s = -b;
+ return x.plus(y);
+ }
+
+ var xe = x.e / LOG_BASE,
+ ye = y.e / LOG_BASE,
+ xc = x.c,
+ yc = y.c;
+
+ if ( !xe || !ye ) {
+
+ // Either Infinity?
+ if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
+
+ // Either zero?
+ if ( !xc[0] || !yc[0] ) {
+
+ // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
+ return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
+
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
+ ROUNDING_MODE == 3 ? -0 : 0 );
+ }
+ }
+
+ xe = bitFloor(xe);
+ ye = bitFloor(ye);
+ xc = xc.slice();
+
+ // Determine which is the bigger number.
+ if ( a = xe - ye ) {
+
+ if ( xLTy = a < 0 ) {
+ a = -a;
+ t = xc;
+ } else {
+ ye = xe;
+ t = yc;
+ }
+
+ t.reverse();
+
+ // Prepend zeros to equalise exponents.
+ for ( b = a; b--; t.push(0) );
+ t.reverse();
+ } else {
+
+ // Exponents equal. Check digit by digit.
+ j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
+
+ for ( a = b = 0; b < j; b++ ) {
+
+ if ( xc[b] != yc[b] ) {
+ xLTy = xc[b] < yc[b];
+ break;
+ }
+ }
+ }
+
+ // x < y? Point xc to the array of the bigger number.
+ if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
+
+ b = ( j = yc.length ) - ( i = xc.length );
+
+ // Append zeros to xc if shorter.
+ // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
+ if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
+ b = BASE - 1;
+
+ // Subtract yc from xc.
+ for ( ; j > a; ) {
+
+ if ( xc[--j] < yc[j] ) {
+ for ( i = j; i && !xc[--i]; xc[i] = b );
+ --xc[i];
+ xc[j] += BASE;
+ }
+
+ xc[j] -= yc[j];
+ }
+
+ // Remove leading zeros and adjust exponent accordingly.
+ for ( ; xc[0] == 0; xc.shift(), --ye );
+
+ // Zero?
+ if ( !xc[0] ) {
+
+ // Following IEEE 754 (2008) 6.3,
+ // n - n = +0 but n - n = -0 when rounding towards -Infinity.
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
+ y.c = [ y.e = 0 ];
+ return y;
+ }
+
+ // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
+ // for finite x and y.
+ return normalise( y, xc, ye );
+ };
+
+
+ /*
+ * n % 0 = N
+ * n % N = N
+ * n % I = n
+ * 0 % n = 0
+ * -0 % n = -0
+ * 0 % 0 = N
+ * 0 % N = N
+ * 0 % I = 0
+ * N % n = N
+ * N % 0 = N
+ * N % N = N
+ * N % I = N
+ * I % n = N
+ * I % 0 = N
+ * I % N = N
+ * I % I = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
+ * BigNumber(y, b). The result depends on the value of MODULO_MODE.
+ */
+ P.modulo = P.mod = function ( y, b ) {
+ var q, s,
+ x = this;
+
+ id = 11;
+ y = new BigNumber( y, b );
+
+ // Return NaN if x is Infinity or NaN, or y is NaN or zero.
+ if ( !x.c || !y.s || y.c && !y.c[0] ) {
+ return new BigNumber(NaN);
+
+ // Return x if y is Infinity or x is zero.
+ } else if ( !y.c || x.c && !x.c[0] ) {
+ return new BigNumber(x);
+ }
+
+ if ( MODULO_MODE == 9 ) {
+
+ // Euclidian division: q = sign(y) * floor(x / abs(y))
+ // r = x - qy where 0 <= r < abs(y)
+ s = y.s;
+ y.s = 1;
+ q = div( x, y, 0, 3 );
+ y.s = s;
+ q.s *= s;
+ } else {
+ q = div( x, y, 0, MODULO_MODE );
+ }
+
+ return x.minus( q.times(y) );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber negated,
+ * i.e. multiplied by -1.
+ */
+ P.negated = P.neg = function () {
+ var x = new BigNumber(this);
+ x.s = -x.s || null;
+ return x;
+ };
+
+
+ /*
+ * n + 0 = n
+ * n + N = N
+ * n + I = I
+ * 0 + n = n
+ * 0 + 0 = 0
+ * 0 + N = N
+ * 0 + I = I
+ * N + n = N
+ * N + 0 = N
+ * N + N = N
+ * N + I = N
+ * I + n = I
+ * I + 0 = I
+ * I + N = N
+ * I + I = I
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber plus the value of
+ * BigNumber(y, b).
+ */
+ P.plus = P.add = function ( y, b ) {
+ var t,
+ x = this,
+ a = x.s;
+
+ id = 12;
+ y = new BigNumber( y, b );
+ b = y.s;
+
+ // Either NaN?
+ if ( !a || !b ) return new BigNumber(NaN);
+
+ // Signs differ?
+ if ( a != b ) {
+ y.s = -b;
+ return x.minus(y);
+ }
+
+ var xe = x.e / LOG_BASE,
+ ye = y.e / LOG_BASE,
+ xc = x.c,
+ yc = y.c;
+
+ if ( !xe || !ye ) {
+
+ // Return ±Infinity if either ±Infinity.
+ if ( !xc || !yc ) return new BigNumber( a / 0 );
+
+ // Either zero?
+ // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
+ if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
+ }
+
+ xe = bitFloor(xe);
+ ye = bitFloor(ye);
+ xc = xc.slice();
+
+ // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
+ if ( a = xe - ye ) {
+ if ( a > 0 ) {
+ ye = xe;
+ t = yc;
+ } else {
+ a = -a;
+ t = xc;
+ }
+
+ t.reverse();
+ for ( ; a--; t.push(0) );
+ t.reverse();
+ }
+
+ a = xc.length;
+ b = yc.length;
+
+ // Point xc to the longer array, and b to the shorter length.
+ if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
+
+ // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
+ for ( a = 0; b; ) {
+ a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
+ xc[b] %= BASE;
+ }
+
+ if (a) {
+ xc.unshift(a);
+ ++ye;
+ }
+
+ // No need to check for zero, as +x + +y != 0 && -x + -y != 0
+ // ye = MAX_EXP + 1 possible
+ return normalise( y, xc, ye );
+ };
+
+
+ /*
+ * Return the number of significant digits of the value of this BigNumber.
+ *
+ * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
+ */
+ P.precision = P.sd = function (z) {
+ var n, v,
+ x = this,
+ c = x.c;
+
+ // 'precision() argument not a boolean or binary digit: {z}'
+ if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
+ if (ERRORS) raise( 13, 'argument' + notBool, z );
+ if ( z != !!z ) z = null;
+ }
+
+ if ( !c ) return null;
+ v = c.length - 1;
+ n = v * LOG_BASE + 1;
+
+ if ( v = c[v] ) {
+
+ // Subtract the number of trailing zeros of the last element.
+ for ( ; v % 10 == 0; v /= 10, n-- );
+
+ // Add the number of digits of the first element.
+ for ( v = c[0]; v >= 10; v /= 10, n++ );
+ }
+
+ if ( z && x.e + 1 > n ) n = x.e + 1;
+
+ return n;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
+ * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
+ * omitted.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'round() decimal places out of range: {dp}'
+ * 'round() decimal places not an integer: {dp}'
+ * 'round() rounding mode not an integer: {rm}'
+ * 'round() rounding mode out of range: {rm}'
+ */
+ P.round = function ( dp, rm ) {
+ var n = new BigNumber(this);
+
+ if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
+ round( n, ~~dp + this.e + 1, rm == null ||
+ !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
+ }
+
+ return n;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
+ * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
+ *
+ * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
+ *
+ * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
+ * otherwise.
+ *
+ * 'shift() argument not an integer: {k}'
+ * 'shift() argument out of range: {k}'
+ */
+ P.shift = function (k) {
+ var n = this;
+ return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
+
+ // k < 1e+21, or truncate(k) will produce exponential notation.
+ ? n.times( '1e' + truncate(k) )
+ : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
+ ? n.s * ( k < 0 ? 0 : 1 / 0 )
+ : n );
+ };
+
+
+ /*
+ * sqrt(-n) = N
+ * sqrt( N) = N
+ * sqrt(-I) = N
+ * sqrt( I) = I
+ * sqrt( 0) = 0
+ * sqrt(-0) = -0
+ *
+ * Return a new BigNumber whose value is the square root of the value of this BigNumber,
+ * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
+ */
+ P.squareRoot = P.sqrt = function () {
+ var m, n, r, rep, t,
+ x = this,
+ c = x.c,
+ s = x.s,
+ e = x.e,
+ dp = DECIMAL_PLACES + 4,
+ half = new BigNumber('0.5');
+
+ // Negative/NaN/Infinity/zero?
+ if ( s !== 1 || !c || !c[0] ) {
+ return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
+ }
+
+ // Initial estimate.
+ s = Math.sqrt( +x );
+
+ // Math.sqrt underflow/overflow?
+ // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
+ if ( s == 0 || s == 1 / 0 ) {
+ n = coeffToString(c);
+ if ( ( n.length + e ) % 2 == 0 ) n += '0';
+ s = Math.sqrt(n);
+ e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
+
+ if ( s == 1 / 0 ) {
+ n = '1e' + e;
+ } else {
+ n = s.toExponential();
+ n = n.slice( 0, n.indexOf('e') + 1 ) + e;
+ }
+
+ r = new BigNumber(n);
+ } else {
+ r = new BigNumber( s + '' );
+ }
+
+ // Check for zero.
+ // r could be zero if MIN_EXP is changed after the this value was created.
+ // This would cause a division by zero (x/t) and hence Infinity below, which would cause
+ // coeffToString to throw.
+ if ( r.c[0] ) {
+ e = r.e;
+ s = e + dp;
+ if ( s < 3 ) s = 0;
+
+ // Newton-Raphson iteration.
+ for ( ; ; ) {
+ t = r;
+ r = half.times( t.plus( div( x, t, dp, 1 ) ) );
+
+ if ( coeffToString( t.c ).slice( 0, s ) === ( n =
+ coeffToString( r.c ) ).slice( 0, s ) ) {
+
+ // The exponent of r may here be one less than the final result exponent,
+ // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
+ // are indexed correctly.
+ if ( r.e < e ) --s;
+ n = n.slice( s - 3, s + 1 );
+
+ // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
+ // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
+ // iteration.
+ if ( n == '9999' || !rep && n == '4999' ) {
+
+ // On the first iteration only, check to see if rounding up gives the
+ // exact result as the nines may infinitely repeat.
+ if ( !rep ) {
+ round( t, t.e + DECIMAL_PLACES + 2, 0 );
+
+ if ( t.times(t).eq(x) ) {
+ r = t;
+ break;
+ }
+ }
+
+ dp += 4;
+ s += 4;
+ rep = 1;
+ } else {
+
+ // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
+ // result. If not, then there are further digits and m will be truthy.
+ if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
+
+ // Truncate to the first rounding digit.
+ round( r, r.e + DECIMAL_PLACES + 2, 1 );
+ m = !r.times(r).eq(x);
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
+ };
+
+
+ /*
+ * n * 0 = 0
+ * n * N = N
+ * n * I = I
+ * 0 * n = 0
+ * 0 * 0 = 0
+ * 0 * N = N
+ * 0 * I = N
+ * N * n = N
+ * N * 0 = N
+ * N * N = N
+ * N * I = N
+ * I * n = I
+ * I * 0 = N
+ * I * N = N
+ * I * I = I
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber times the value of
+ * BigNumber(y, b).
+ */
+ P.times = P.mul = function ( y, b ) {
+ var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
+ base, sqrtBase,
+ x = this,
+ xc = x.c,
+ yc = ( id = 17, y = new BigNumber( y, b ) ).c;
+
+ // Either NaN, ±Infinity or ±0?
+ if ( !xc || !yc || !xc[0] || !yc[0] ) {
+
+ // Return NaN if either is NaN, or one is 0 and the other is Infinity.
+ if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
+ y.c = y.e = y.s = null;
+ } else {
+ y.s *= x.s;
+
+ // Return ±Infinity if either is ±Infinity.
+ if ( !xc || !yc ) {
+ y.c = y.e = null;
+
+ // Return ±0 if either is ±0.
+ } else {
+ y.c = [0];
+ y.e = 0;
+ }
+ }
+
+ return y;
+ }
+
+ e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
+ y.s *= x.s;
+ xcL = xc.length;
+ ycL = yc.length;
+
+ // Ensure xc points to longer array and xcL to its length.
+ if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
+
+ // Initialise the result array with zeros.
+ for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
+
+ base = BASE;
+ sqrtBase = SQRT_BASE;
+
+ for ( i = ycL; --i >= 0; ) {
+ c = 0;
+ ylo = yc[i] % sqrtBase;
+ yhi = yc[i] / sqrtBase | 0;
+
+ for ( k = xcL, j = i + k; j > i; ) {
+ xlo = xc[--k] % sqrtBase;
+ xhi = xc[k] / sqrtBase | 0;
+ m = yhi * xlo + xhi * ylo;
+ xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
+ c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
+ zc[j--] = xlo % base;
+ }
+
+ zc[j] = c;
+ }
+
+ if (c) {
+ ++e;
+ } else {
+ zc.shift();
+ }
+
+ return normalise( y, zc, e );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
+ * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toDigits() precision out of range: {sd}'
+ * 'toDigits() precision not an integer: {sd}'
+ * 'toDigits() rounding mode not an integer: {rm}'
+ * 'toDigits() rounding mode out of range: {rm}'
+ */
+ P.toDigits = function ( sd, rm ) {
+ var n = new BigNumber(this);
+ sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
+ rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
+ return sd ? round( n, sd, rm ) : n;
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in exponential notation and
+ * rounded using ROUNDING_MODE to dp fixed decimal places.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toExponential() decimal places not an integer: {dp}'
+ * 'toExponential() decimal places out of range: {dp}'
+ * 'toExponential() rounding mode not an integer: {rm}'
+ * 'toExponential() rounding mode out of range: {rm}'
+ */
+ P.toExponential = function ( dp, rm ) {
+ return format( this,
+ dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in fixed-point notation rounding
+ * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
+ *
+ * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
+ * but e.g. (-0.00001).toFixed(0) is '-0'.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toFixed() decimal places not an integer: {dp}'
+ * 'toFixed() decimal places out of range: {dp}'
+ * 'toFixed() rounding mode not an integer: {rm}'
+ * 'toFixed() rounding mode out of range: {rm}'
+ */
+ P.toFixed = function ( dp, rm ) {
+ return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
+ ? ~~dp + this.e + 1 : null, rm, 20 );
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in fixed-point notation rounded
+ * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
+ * of the FORMAT object (see BigNumber.config).
+ *
+ * FORMAT = {
+ * decimalSeparator : '.',
+ * groupSeparator : ',',
+ * groupSize : 3,
+ * secondaryGroupSize : 0,
+ * fractionGroupSeparator : '\xA0', // non-breaking space
+ * fractionGroupSize : 0
+ * };
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toFormat() decimal places not an integer: {dp}'
+ * 'toFormat() decimal places out of range: {dp}'
+ * 'toFormat() rounding mode not an integer: {rm}'
+ * 'toFormat() rounding mode out of range: {rm}'
+ */
+ P.toFormat = function ( dp, rm ) {
+ var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
+ ? ~~dp + this.e + 1 : null, rm, 21 );
+
+ if ( this.c ) {
+ var i,
+ arr = str.split('.'),
+ g1 = +FORMAT.groupSize,
+ g2 = +FORMAT.secondaryGroupSize,
+ groupSeparator = FORMAT.groupSeparator,
+ intPart = arr[0],
+ fractionPart = arr[1],
+ isNeg = this.s < 0,
+ intDigits = isNeg ? intPart.slice(1) : intPart,
+ len = intDigits.length;
+
+ if (g2) i = g1, g1 = g2, g2 = i, len -= i;
+
+ if ( g1 > 0 && len > 0 ) {
+ i = len % g1 || g1;
+ intPart = intDigits.substr( 0, i );
+
+ for ( ; i < len; i += g1 ) {
+ intPart += groupSeparator + intDigits.substr( i, g1 );
+ }
+
+ if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
+ if (isNeg) intPart = '-' + intPart;
+ }
+
+ str = fractionPart
+ ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
+ ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
+ '$&' + FORMAT.fractionGroupSeparator )
+ : fractionPart )
+ : intPart;
+ }
+
+ return str;
+ };
+
+
+ /*
+ * Return a string array representing the value of this BigNumber as a simple fraction with
+ * an integer numerator and an integer denominator. The denominator will be a positive
+ * non-zero value less than or equal to the specified maximum denominator. If a maximum
+ * denominator is not specified, the denominator will be the lowest value necessary to
+ * represent the number exactly.
+ *
+ * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
+ *
+ * 'toFraction() max denominator not an integer: {md}'
+ * 'toFraction() max denominator out of range: {md}'
+ */
+ P.toFraction = function (md) {
+ var arr, d0, d2, e, exp, n, n0, q, s,
+ k = ERRORS,
+ x = this,
+ xc = x.c,
+ d = new BigNumber(ONE),
+ n1 = d0 = new BigNumber(ONE),
+ d1 = n0 = new BigNumber(ONE);
+
+ if ( md != null ) {
+ ERRORS = false;
+ n = new BigNumber(md);
+ ERRORS = k;
+
+ if ( !( k = n.isInt() ) || n.lt(ONE) ) {
+
+ if (ERRORS) {
+ raise( 22,
+ 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
+ }
+
+ // ERRORS is false:
+ // If md is a finite non-integer >= 1, round it to an integer and use it.
+ md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
+ }
+ }
+
+ if ( !xc ) return x.toString();
+ s = coeffToString(xc);
+
+ // Determine initial denominator.
+ // d is a power of 10 and the minimum max denominator that specifies the value exactly.
+ e = d.e = s.length - x.e - 1;
+ d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
+ md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
+
+ exp = MAX_EXP;
+ MAX_EXP = 1 / 0;
+ n = new BigNumber(s);
+
+ // n0 = d1 = 0
+ n0.c[0] = 0;
+
+ for ( ; ; ) {
+ q = div( n, d, 0, 1 );
+ d2 = d0.plus( q.times(d1) );
+ if ( d2.cmp(md) == 1 ) break;
+ d0 = d1;
+ d1 = d2;
+ n1 = n0.plus( q.times( d2 = n1 ) );
+ n0 = d2;
+ d = n.minus( q.times( d2 = d ) );
+ n = d2;
+ }
+
+ d2 = div( md.minus(d0), d1, 0, 1 );
+ n0 = n0.plus( d2.times(n1) );
+ d0 = d0.plus( d2.times(d1) );
+ n0.s = n1.s = x.s;
+ e *= 2;
+
+ // Determine which fraction is closer to x, n0/d0 or n1/d1
+ arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
+ div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
+ ? [ n1.toString(), d1.toString() ]
+ : [ n0.toString(), d0.toString() ];
+
+ MAX_EXP = exp;
+ return arr;
+ };
+
+
+ /*
+ * Return the value of this BigNumber converted to a number primitive.
+ */
+ P.toNumber = function () {
+ var x = this;
+
+ // Ensure zero has correct sign.
+ return +x || ( x.s ? x.s * 0 : NaN );
+ };
+
+
+ /*
+ * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
+ * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
+ * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
+ *
+ * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
+ * (Performs 54 loop iterations for n of 9007199254740992.)
+ *
+ * 'pow() exponent not an integer: {n}'
+ * 'pow() exponent out of range: {n}'
+ */
+ P.toPower = P.pow = function (n) {
+ var k, y,
+ i = mathfloor( n < 0 ? -n : +n ),
+ x = this;
+
+ // Pass ±Infinity to Math.pow if exponent is out of range.
+ if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
+ ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
+ parseFloat(n) != n && !( n = NaN ) ) ) {
+ return new BigNumber( Math.pow( +x, n ) );
+ }
+
+ // Truncating each coefficient array to a length of k after each multiplication equates
+ // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
+ // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
+ k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
+ y = new BigNumber(ONE);
+
+ for ( ; ; ) {
+
+ if ( i % 2 ) {
+ y = y.times(x);
+ if ( !y.c ) break;
+ if ( k && y.c.length > k ) y.c.length = k;
+ }
+
+ i = mathfloor( i / 2 );
+ if ( !i ) break;
+
+ x = x.times(x);
+ if ( k && x.c && x.c.length > k ) x.c.length = k;
+ }
+
+ if ( n < 0 ) y = ONE.div(y);
+ return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber rounded to sd significant digits
+ * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
+ * necessary to represent the integer part of the value in fixed-point notation, then use
+ * exponential notation.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toPrecision() precision not an integer: {sd}'
+ * 'toPrecision() precision out of range: {sd}'
+ * 'toPrecision() rounding mode not an integer: {rm}'
+ * 'toPrecision() rounding mode out of range: {rm}'
+ */
+ P.toPrecision = function ( sd, rm ) {
+ return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
+ ? sd | 0 : null, rm, 24 );
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in base b, or base 10 if b is
+ * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
+ * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
+ * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
+ * TO_EXP_NEG, return exponential notation.
+ *
+ * [b] {number} Integer, 2 to 64 inclusive.
+ *
+ * 'toString() base not an integer: {b}'
+ * 'toString() base out of range: {b}'
+ */
+ P.toString = function (b) {
+ var str,
+ n = this,
+ s = n.s,
+ e = n.e;
+
+ // Infinity or NaN?
+ if ( e === null ) {
+
+ if (s) {
+ str = 'Infinity';
+ if ( s < 0 ) str = '-' + str;
+ } else {
+ str = 'NaN';
+ }
+ } else {
+ str = coeffToString( n.c );
+
+ if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS
+ ? toExponential( str, e )
+ : toFixedPoint( str, e );
+ } else {
+ str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
+ }
+
+ if ( s < 0 && n.c[0] ) str = '-' + str;
+ }
+
+ return str;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
+ * number.
+ */
+ P.truncated = P.trunc = function () {
+ return round( new BigNumber(this), this.e + 1, 1 );
+ };
+
+
+
+ /*
+ * Return as toString, but do not accept a base argument.
+ */
+ P.valueOf = P.toJSON = function () {
+ return this.toString();
+ };
+
+
+ // Aliases for BigDecimal methods.
+ //P.add = P.plus; // P.add included above
+ //P.subtract = P.minus; // P.sub included above
+ //P.multiply = P.times; // P.mul included above
+ //P.divide = P.div;
+ //P.remainder = P.mod;
+ //P.compareTo = P.cmp;
+ //P.negate = P.neg;
+
+
+ if ( configObj != null ) BigNumber.config(configObj);
+
+ return BigNumber;
+ }
+
+
+ // PRIVATE HELPER FUNCTIONS
+
+
+ function bitFloor(n) {
+ var i = n | 0;
+ return n > 0 || n === i ? i : i - 1;
+ }
+
+
+ // Return a coefficient array as a string of base 10 digits.
+ function coeffToString(a) {
+ var s, z,
+ i = 1,
+ j = a.length,
+ r = a[0] + '';
+
+ for ( ; i < j; ) {
+ s = a[i++] + '';
+ z = LOG_BASE - s.length;
+ for ( ; z--; s = '0' + s );
+ r += s;
+ }
+
+ // Determine trailing zeros.
+ for ( j = r.length; r.charCodeAt(--j) === 48; );
+ return r.slice( 0, j + 1 || 1 );
+ }
+
+
+ // Compare the value of BigNumbers x and y.
+ function compare( x, y ) {
+ var a, b,
+ xc = x.c,
+ yc = y.c,
+ i = x.s,
+ j = y.s,
+ k = x.e,
+ l = y.e;
+
+ // Either NaN?
+ if ( !i || !j ) return null;
+
+ a = xc && !xc[0];
+ b = yc && !yc[0];
+
+ // Either zero?
+ if ( a || b ) return a ? b ? 0 : -j : i;
+
+ // Signs differ?
+ if ( i != j ) return i;
+
+ a = i < 0;
+ b = k == l;
+
+ // Either Infinity?
+ if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
+
+ // Compare exponents.
+ if ( !b ) return k > l ^ a ? 1 : -1;
+
+ j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
+
+ // Compare digit by digit.
+ for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
+
+ // Compare lengths.
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
+ }
+
+
+ /*
+ * Return true if n is a valid number in range, otherwise false.
+ * Use for argument validation when ERRORS is false.
+ * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
+ */
+ function intValidatorNoErrors( n, min, max ) {
+ return ( n = truncate(n) ) >= min && n <= max;
+ }
+
+
+ function isArray(obj) {
+ return Object.prototype.toString.call(obj) == '[object Array]';
+ }
+
+
+ /*
+ * Convert string of baseIn to an array of numbers of baseOut.
+ * Eg. convertBase('255', 10, 16) returns [15, 15].
+ * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
+ */
+ function toBaseOut( str, baseIn, baseOut ) {
+ var j,
+ arr = [0],
+ arrL,
+ i = 0,
+ len = str.length;
+
+ for ( ; i < len; ) {
+ for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
+ arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
+
+ for ( ; j < arr.length; j++ ) {
+
+ if ( arr[j] > baseOut - 1 ) {
+ if ( arr[j + 1] == null ) arr[j + 1] = 0;
+ arr[j + 1] += arr[j] / baseOut | 0;
+ arr[j] %= baseOut;
+ }
+ }
+ }
+
+ return arr.reverse();
+ }
+
+
+ function toExponential( str, e ) {
+ return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
+ ( e < 0 ? 'e' : 'e+' ) + e;
+ }
+
+
+ function toFixedPoint( str, e ) {
+ var len, z;
+
+ // Negative exponent?
+ if ( e < 0 ) {
+
+ // Prepend zeros.
+ for ( z = '0.'; ++e; z += '0' );
+ str = z + str;
+
+ // Positive exponent
+ } else {
+ len = str.length;
+
+ // Append zeros.
+ if ( ++e > len ) {
+ for ( z = '0', e -= len; --e; z += '0' );
+ str += z;
+ } else if ( e < len ) {
+ str = str.slice( 0, e ) + '.' + str.slice(e);
+ }
+ }
+
+ return str;
+ }
+
+
+ function truncate(n) {
+ n = parseFloat(n);
+ return n < 0 ? mathceil(n) : mathfloor(n);
+ }
+
+
+ // EXPORT
+
+
+ BigNumber = another();
+
+ // AMD.
+ if ( typeof define == 'function' && define.amd ) {
+ define( function () { return BigNumber; } );
+
+ // Node and other environments that support module.exports.
+ } else if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = BigNumber;
+ if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
+
+ // Browser.
+ } else {
+ global.BigNumber = BigNumber;
+ }
+})(this);
+
+},{"crypto":1}],"natspec":[function(require,module,exports){
+/*
+ This file is part of natspec.js.
+
+ natspec.js is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ natspec.js is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with natspec.js. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file natspec.js
+ * @authors:
+ * Marek Kotewicz <marek@ethdev.com>
+ * @date 2015
+ */
+
+var abi = require('./node_modules/web3/lib/solidity/abi.js');
+
+/**
+ * This object should be used to evaluate natspec expression
+ * It has one method evaluateExpression which shoul be used
+ */
+var natspec = (function () {
+ /**
+ * Helper method
+ * Should be called to copy values from object to global context
+ *
+ * @method copyToContext
+ * @param {Object} object from which we want to copy properties
+ * @param {Object} object to which we copy
+ */
+ var copyToContext = function (obj, context) {
+ Object.keys(obj).forEach(function (key) {
+ context[key] = obj[key];
+ });
+ }
+
+ /**
+ * Should be used to generate codes, which will be evaluated
+ *
+ * @method generateCode
+ * @param {Object} object from which code will be generated
+ * @return {String} javascript code which is used to initalized variables
+ */
+ var generateCode = function (obj) {
+ return Object.keys(obj).reduce(function (acc, key) {
+ return acc + "var " + key + " = context['" + key + "'];\n";
+ }, "");
+ };
+
+ /**
+ * Helper method
+ * Should be called to get method with given name from the abi
+ *
+ * @method getMethodWithName
+ * @param {Array} contract's abi
+ * @param {String} name of the method that we are looking for
+ * @return {Object} abi for method with name
+ */
+ var getMethodWithName = function(abi, name) {
+ return abi.filter(function (method) {
+ return method.name === name;
+ })[0];
+ };
+
+ /**
+ * Should be used to get all contract method input variables
+ *
+ * @method getMethodInputParams
+ * @param {Object} abi for certain method
+ * @param {Object} transaction object
+ * @return {Object} object with all contract's method input variables
+ */
+ var getMethodInputParams = function (method, transaction) {
+ // do it with output formatter (cause we have to decode)
+ var params = abi.formatOutput(method.inputs, '0x' + transaction.params[0].data.slice(10));
+
+ return method.inputs.reduce(function (acc, current, index) {
+ acc[current.name] = params[index];
+ return acc;
+ }, {});
+ };
+
+ /**
+ * Should be called when we want to evaluate natspec expression
+ * Replaces all natspec 'subexpressions' with evaluated value
+ *
+ * @method mapExpressionToEvaluate
+ * @param {String} expression to evaluate
+ * @param {Function} callback which is called to evaluate te expression
+ * @return {String} evaluated expression
+ */
+ var mapExpressionsToEvaluate = function (expression, cb) {
+ var evaluatedExpression = "";
+
+ // match everything in quotes
+ var pattern = /\` + "`" + `(?:\\.|[^` + "`" + `\\])*\` + "`" + `/gim
+ var match;
+ var lastIndex = 0;
+ try {
+ while ((match = pattern.exec(expression)) !== null) {
+ var startIndex = pattern.lastIndex - match[0].length;
+ var toEval = match[0].slice(1, match[0].length - 1);
+ evaluatedExpression += expression.slice(lastIndex, startIndex);
+ var evaluatedPart = cb(toEval);
+ evaluatedExpression += evaluatedPart;
+ lastIndex = pattern.lastIndex;
+ }
+
+ evaluatedExpression += expression.slice(lastIndex);
+ }
+ catch (err) {
+ throw new Error("Natspec evaluation failed, wrong input params");
+ }
+
+ return evaluatedExpression;
+ };
+
+ /**
+ * Should be called to evaluate single expression
+ * Is internally using javascript's 'eval' method
+ *
+ * @method evaluateExpression
+ * @param {String} expression which should be evaluated
+ * @param {Object} [call] object containing contract abi, transaction, called method
+ * @return {String} evaluated expression
+ * @throws exception if method is not found or we are trying to evaluate input params that does not exists
+ */
+
+ var utils = require('../utils/utils');
+
+ var evaluateExpression = function (expression, call) {
+ //var self = this;
+ var context = {};
+
+ if (!!call) {
+ try {
+ var method = getMethodWithName(call.abi, call.method);
+ var params = getMethodInputParams(method, call.transaction);
+ copyToContext(params, context);
+ }
+ catch (err) {
+ throw new Error("Natspec evaluation failed, method does not exist");
+ }
+ }
+
+ var code = generateCode(context);
+
+ var evaluatedExpression = mapExpressionsToEvaluate(expression, function (toEval) {
+ //var fn = new Function("context", "toHex", code + "return " + toEval + ";");
+ //return fn(context, toHex).toString();
+ var fn = new Function("context", "utils", code + "return " + toEval + ";");
+ return fn(context, utils).toString();
+ });
+
+ return evaluatedExpression;
+ };
+
+ /**
+ * Safe version of evaluateExpression
+ * Instead of throwing an exception it returns it as a string
+ *
+ * @method evaluateExpressionSafe
+ * @param {String} expression which should be evaluated
+ * @param {Object} [call] object containing contract abi, transaction, called method
+ * @return {String} evaluated expression
+ */
+ var evaluateExpressionSafe = function (expression, call) {
+ try {
+ return evaluateExpression(expression, call);
+ }
+ catch (err) {
+ return err.message;
+ }
+ };
+
+ return {
+ evaluateExpression: evaluateExpression,
+ evaluateExpressionSafe: evaluateExpressionSafe
+ };
+
+})();
+
+module.exports = natspec;
+
+
+},{"./node_modules/web3/lib/solidity/abi.js":2,"../utils/utils":7}]},{},[]);
+`
+
//# sourceMappingURL=natspec.js.map`
diff --git a/common/natspec/natspec_test.go b/common/natspec/natspec_test.go
index 3b548817b..35a59469a 100644
--- a/common/natspec/natspec_test.go
+++ b/common/natspec/natspec_test.go
@@ -4,87 +4,141 @@ import (
"testing"
)
-func TestNotice(t *testing.T) {
+func makeUserdoc(desc string) []byte {
+ return []byte(`
+{
+ "source": "...",
+ "language": "Solidity",
+ "languageVersion": 1,
+ "methods": {
+ "multiply(uint256)": {
+ "notice": "` + desc + `"
+ },
+ "balance(address)": {
+ "notice": "` + "`(balanceInmGAV / 1000).fixed(0,3)`" + ` GAV is the total funds available to ` + "`who.address()`." + `"
+ }
+ },
+ "invariants": [
+ { "notice": "The sum total amount of GAV in the system is 1 million." }
+ ],
+ "construction": [
+ { "notice": "Endows ` + "`message.caller.address()`" + ` with 1m GAV." }
+ ]
+}
+`)
+}
- tx := `
- {
- "jsonrpc": "2.0",
- "method": "eth_call",
- "params": [{
- "to": "0x8521742d3f456bd237e312d6e30724960f72517a",
- "data": "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
- }],
- "id": 6
- }
- `
-
- abi := `
- [{
- "name": "multiply",
- "constant": false,
- "type": "function",
- "inputs": [{
- "name": "a",
- "type": "uint256"
- }],
- "outputs": [{
- "name": "d",
- "type": "uint256"
- }]
+var data = "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
+
+var tx = `
+{
+ "jsonrpc": "2.0",
+ "method": "eth_call",
+ "params": [{
+ "to": "0x8521742d3f456bd237e312d6e30724960f72517a",
+ "data": "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
+ }],
+ "id": 6
+}
+`
+
+var abi = []byte(`
+[{
+ "name": "multiply",
+ "constant": false,
+ "type": "function",
+ "inputs": [{
+ "name": "a",
+ "type": "uint256"
+ }],
+ "outputs": [{
+ "name": "d",
+ "type": "uint256"
}]
- `
+}]
+`)
+
+func TestNotice(t *testing.T) {
desc := "Will multiply `a` by 7 and return `a * 7`."
+ expected := "Will multiply 122 by 7 and return 854."
- method := "multiply"
+ userdoc := makeUserdoc(desc)
- ns, err := New()
+ ns, err := NewWithDocs(abi, userdoc, tx)
if err != nil {
- t.Errorf("NewNATSpec error %v", err)
+ t.Errorf("New: error: %v", err)
}
- notice, err := ns.Notice(tx, abi, method, desc)
+ notice, err := ns.Notice()
if err != nil {
- t.Errorf("expected no error got %v", err)
+ t.Errorf("expected no error, got %v", err)
}
- expected := "Will multiply 122 by 7 and return 854."
if notice != expected {
t.Errorf("incorrect notice. expected %v, got %v", expected, notice)
} else {
t.Logf("returned notice \"%v\"", notice)
}
+}
+
+// test missing method
+func TestMissingMethod(t *testing.T) {
- notice, err = ns.Notice(tx, abi, method, "Will multiply 122 by \"7\" and return 854.")
+ desc := "Will multiply `a` by 7 and return `a * 7`."
+ userdoc := makeUserdoc(desc)
+ expected := "natspec.js error evaluating expression: Natspec evaluation failed, method does not exist"
+
+ ns, err := NewWithDocs(abi, userdoc, tx)
+ if err != nil {
+ t.Errorf("New: error: %v", err)
+ }
- expected = "natspec.js error setting expression: (anonymous): Line 1:41 Unexpected number"
+ notice, err := ns.noticeForMethod(tx, "missing_method", "")
if err == nil {
- t.Errorf("expected error, got nothing (notice: '%v')", err, notice)
+ t.Errorf("expected error, got nothing (notice: '%v')", notice)
} else {
if err.Error() != expected {
t.Errorf("expected error '%s' got '%v' (notice: '%v')", expected, err, notice)
}
}
+}
+
+// test invalid desc
- // https://github.com/ethereum/natspec.js/issues/1
- badDesc := "Will multiply `e` by 7 and return `a * 7`."
- notice, err = ns.Notice(tx, abi, method, badDesc)
+func TestInvalidDesc(t *testing.T) {
- expected = "natspec.js error evaluating expression: Natspec evaluation failed, wrong input params"
+ desc := "Will multiply 122 by \"7\" and return 854."
+ expected := "invalid character '7' after object key:value pair"
+ userdoc := makeUserdoc(desc)
+
+ _, err := NewWithDocs(abi, userdoc, tx)
if err == nil {
- t.Errorf("expected error, got nothing (notice: '%v')", notice)
+ t.Errorf("expected error, got nothing", err)
} else {
if err.Error() != expected {
- t.Errorf("expected error '%s' got '%v' (notice: '%v')", expected, err, notice)
+ t.Errorf("expected error '%s' got '%v'", expected, err)
}
}
+}
+
+// test wrong input params
+func TestWrongInputParams(t *testing.T) {
+
+ desc := "Will multiply `e` by 7 and return `a * 7`."
+ expected := "natspec.js error evaluating expression: Natspec evaluation failed, wrong input params"
- notice, err = ns.Notice(tx, abi, "missing_method", desc)
+ userdoc := makeUserdoc(desc)
+
+ ns, err := NewWithDocs(abi, userdoc, tx)
+ if err != nil {
+ t.Errorf("New: error: %v", err)
+ }
- expected = "natspec.js error evaluating expression: Natspec evaluation failed, method does not exist"
+ notice, err := ns.Notice()
if err == nil {
t.Errorf("expected error, got nothing (notice: '%v')", notice)
diff --git a/common/resolver/contracts.go b/common/resolver/contracts.go
new file mode 100644
index 000000000..4aad95e43
--- /dev/null
+++ b/common/resolver/contracts.go
@@ -0,0 +1,36 @@
+package resolver
+
+const ( // built-in contracts address and code
+ ContractCodeURLhint = "0x60c180600c6000396000f30060003560e060020a90048063300a3bbf14601557005b6024600435602435604435602a565b60006000f35b6000600084815260200190815260200160002054600160a060020a0316600014806078575033600160a060020a03166000600085815260200190815260200160002054600160a060020a0316145b607f5760bc565b336000600085815260200190815260200160002081905550806001600085815260200190815260200160002083610100811060b657005b01819055505b50505056"
+ /*
+ contract URLhint {
+ function register(uint256 _hash, uint8 idx, uint256 _url) {
+ if (owner[_hash] == 0 || owner[_hash] == msg.sender) {
+ owner[_hash] = msg.sender;
+ url[_hash][idx] = _url;
+ }
+ }
+ mapping (uint256 => address) owner;
+ mapping (uint256 => uint256[256]) url;
+ }
+ */
+
+ ContractCodeHashReg = "0x609880600c6000396000f30060003560e060020a9004806331e12c2014601f578063d66d6c1014602b57005b6025603d565b60006000f35b6037600435602435605d565b60006000f35b600054600160a060020a0316600014605357605b565b336000819055505b565b600054600160a060020a031633600160a060020a031614607b576094565b8060016000848152602001908152602001600020819055505b505056"
+ /*
+ contract HashReg {
+ function setowner() {
+ if (owner == 0) {
+ owner = msg.sender;
+ }
+ }
+ function register(uint256 _key, uint256 _content) {
+ if (msg.sender == owner) {
+ content[_key] = _content;
+ }
+ }
+ address owner;
+ mapping (uint256 => uint256) content;
+ }
+ */
+
+)
diff --git a/common/resolver/resolver.go b/common/resolver/resolver.go
new file mode 100644
index 000000000..1e6d03ffb
--- /dev/null
+++ b/common/resolver/resolver.go
@@ -0,0 +1,128 @@
+package resolver
+
+import (
+ "encoding/binary"
+ "fmt"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
+ xe "github.com/ethereum/go-ethereum/xeth"
+)
+
+/*
+Resolver implements the Ethereum DNS mapping
+HashReg : Key Hash (hash of domain name or contract code) -> Content Hash
+UrlHint : Content Hash -> Url Hint
+
+The resolver is meant to be called by the roundtripper transport implementation
+of a url scheme
+*/
+
+// contract addresses will be hardcoded after they're created
+var URLHintContractAddress string = "0000000000000000000000000000000000000000000000000000000000001234"
+var HashRegContractAddress string = "0000000000000000000000000000000000000000000000000000000000005678"
+
+func CreateContracts(xeth *xe.XEth, addr string) {
+ var err error
+ URLHintContractAddress, err = xeth.Transact(addr, "", "100000000000", "1000000", "100000", ContractCodeURLhint)
+ if err != nil {
+ panic(err)
+ }
+ HashRegContractAddress, err = xeth.Transact(addr, "", "100000000000", "1000000", "100000", ContractCodeHashReg)
+ if err != nil {
+ panic(err)
+ }
+}
+
+type Resolver struct {
+ backend Backend
+ urlHintContractAddress string
+ hashRegContractAddress string
+}
+
+type Backend interface {
+ StorageAt(string, string) string
+}
+
+func New(eth Backend, uhca, nrca string) *Resolver {
+ return &Resolver{eth, uhca, nrca}
+}
+
+func (self *Resolver) KeyToContentHash(khash common.Hash) (chash common.Hash, err error) {
+ // look up in hashReg
+ key := storageAddress(storageMapping(storageIdx2Addr(1), khash[:]))
+ hash := self.backend.StorageAt(self.hashRegContractAddress, key)
+
+ if hash == "0x0" || len(hash) < 3 {
+ err = fmt.Errorf("GetHashReg: content hash not found")
+ return
+ }
+
+ copy(chash[:], common.Hex2BytesFixed(hash[2:], 32))
+ return
+}
+
+func (self *Resolver) ContentHashToUrl(chash common.Hash) (uri string, err error) {
+ // look up in URL reg
+ var str string = " "
+ var idx uint32
+ for len(str) > 0 {
+ mapaddr := storageMapping(storageIdx2Addr(1), chash[:])
+ key := storageAddress(storageFixedArray(mapaddr, storageIdx2Addr(idx)))
+ hex := self.backend.StorageAt(self.urlHintContractAddress, key)
+ str = string(common.Hex2Bytes(hex[2:]))
+ l := len(str)
+ for (l > 0) && (str[l-1] == 0) {
+ l--
+ }
+ str = str[:l]
+ uri = uri + str
+ idx++
+ }
+
+ if len(uri) == 0 {
+ err = fmt.Errorf("GetURLhint: URL hint not found")
+ }
+ return
+}
+
+func (self *Resolver) KeyToUrl(key common.Hash) (uri string, hash common.Hash, err error) {
+ // look up in urlHint
+ hash, err = self.KeyToContentHash(key)
+ if err != nil {
+ return
+ }
+ uri, err = self.ContentHashToUrl(hash)
+ return
+}
+
+func storageIdx2Addr(varidx uint32) []byte {
+ data := make([]byte, 32)
+ binary.BigEndian.PutUint32(data[28:32], varidx)
+ return data
+}
+
+func storageMapping(addr, key []byte) []byte {
+ data := make([]byte, 64)
+ copy(data[0:32], key[0:32])
+ copy(data[32:64], addr[0:32])
+ return crypto.Sha3(data)
+}
+
+func storageFixedArray(addr, idx []byte) []byte {
+ var carry byte
+ for i := 31; i >= 0; i-- {
+ var b byte = addr[i] + idx[i] + carry
+ if b < addr[i] {
+ carry = 1
+ } else {
+ carry = 0
+ }
+ addr[i] = b
+ }
+ return addr
+}
+
+func storageAddress(addr []byte) string {
+ return common.ToHex(addr)
+}
diff --git a/common/resolver/resolver_test.go b/common/resolver/resolver_test.go
new file mode 100644
index 000000000..f5eb51437
--- /dev/null
+++ b/common/resolver/resolver_test.go
@@ -0,0 +1,88 @@
+package resolver
+
+import (
+ "testing"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
+)
+
+type testBackend struct {
+ // contracts mock
+ contracts map[string](map[string]string)
+}
+
+var (
+ text = "test"
+ codehash = common.StringToHash("1234")
+ hash = common.BytesToHash(crypto.Sha3([]byte(text)))
+ url = "bzz://bzzhash/my/path/contr.act"
+)
+
+func NewTestBackend() *testBackend {
+ self := &testBackend{}
+ self.contracts = make(map[string](map[string]string))
+
+ self.contracts[HashRegContractAddress] = make(map[string]string)
+ key := storageAddress(storageMapping(storageIdx2Addr(1), codehash[:]))
+ self.contracts[HashRegContractAddress][key] = hash.Hex()
+
+ self.contracts[URLHintContractAddress] = make(map[string]string)
+ mapaddr := storageMapping(storageIdx2Addr(1), hash[:])
+
+ key = storageAddress(storageFixedArray(mapaddr, storageIdx2Addr(0)))
+ self.contracts[URLHintContractAddress][key] = common.ToHex([]byte(url))
+ key = storageAddress(storageFixedArray(mapaddr, storageIdx2Addr(1)))
+ self.contracts[URLHintContractAddress][key] = "0x00"
+
+ return self
+}
+
+func (self *testBackend) StorageAt(ca, sa string) (res string) {
+ c := self.contracts[ca]
+ if c == nil {
+ return
+ }
+ res = c[sa]
+ return
+}
+
+func TestKeyToContentHash(t *testing.T) {
+ b := NewTestBackend()
+ res := New(b, URLHintContractAddress, HashRegContractAddress)
+
+ got, err := res.KeyToContentHash(codehash)
+ if err != nil {
+ t.Errorf("expected no error, got %v", err)
+ } else {
+ if got != hash {
+ t.Errorf("incorrect result, expected %x, got %x: ", hash.Hex(), got.Hex())
+ }
+ }
+}
+
+func TestContentHashToUrl(t *testing.T) {
+ b := NewTestBackend()
+ res := New(b, URLHintContractAddress, HashRegContractAddress)
+ got, err := res.ContentHashToUrl(hash)
+ if err != nil {
+ t.Errorf("expected no error, got %v", err)
+ } else {
+ if string(got) != url {
+ t.Errorf("incorrect result, expected %v, got %s: ", url, string(got))
+ }
+ }
+}
+
+func TestKeyToUrl(t *testing.T) {
+ b := NewTestBackend()
+ res := New(b, URLHintContractAddress, HashRegContractAddress)
+ got, _, err := res.KeyToUrl(codehash)
+ if err != nil {
+ t.Errorf("expected no error, got %v", err)
+ } else {
+ if string(got) != url {
+ t.Errorf("incorrect result, expected %v, got %s: ", url, string(got))
+ }
+ }
+}
diff --git a/core/block_processor.go b/core/block_processor.go
index d5a29b258..4c70872ac 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -21,7 +21,7 @@ import (
const (
// must be bumped when consensus algorithm is changed, this forces the upgradedb
// command to be run (forces the blocks to be imported again using the new algorithm)
- BlockChainVersion = 1
+ BlockChainVersion = 2
)
var statelogger = logger.NewLogger("BLOCK")
@@ -149,28 +149,42 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
return receipts, err
}
+func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err error) {
+ // Processing a blocks may never happen simultaneously
+ sm.mutex.Lock()
+ defer sm.mutex.Unlock()
+
+ header := block.Header()
+ if !sm.bc.HasBlock(header.ParentHash) {
+ return nil, ParentError(header.ParentHash)
+ }
+ parent := sm.bc.GetBlock(header.ParentHash)
+
+ return sm.processWithParent(block, parent)
+}
+
// Process block will attempt to process the given block's transactions and applies them
// on top of the block's parent state (given it exists) and will return wether it was
// successful or not.
-func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, logs state.Logs, err error) {
+func (sm *BlockProcessor) Process(block *types.Block) (logs state.Logs, err error) {
// Processing a blocks may never happen simultaneously
sm.mutex.Lock()
defer sm.mutex.Unlock()
header := block.Header()
if sm.bc.HasBlock(header.Hash()) {
- return nil, nil, &KnownBlockError{header.Number, header.Hash()}
+ return nil, &KnownBlockError{header.Number, header.Hash()}
}
if !sm.bc.HasBlock(header.ParentHash) {
- return nil, nil, ParentError(header.ParentHash)
+ return nil, ParentError(header.ParentHash)
}
parent := sm.bc.GetBlock(header.ParentHash)
return sm.processWithParent(block, parent)
}
-func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big.Int, logs state.Logs, err error) {
+func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs state.Logs, err error) {
sm.lastAttemptedBlock = block
// Create a new state based on the parent's root (e.g., create copy)
@@ -183,7 +197,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// There can be at most two uncles
if len(block.Uncles()) > 2 {
- return nil, nil, ValidationError("Block can only contain one uncle (contained %v)", len(block.Uncles()))
+ return nil, ValidationError("Block can only contain one uncle (contained %v)", len(block.Uncles()))
}
receipts, err := sm.TransitionState(state, parent, block, false)
@@ -232,7 +246,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
}
// Calculate the td for this block
- td = CalculateTD(block, parent)
+ //td = CalculateTD(block, parent)
// Sync the current block's state to the database
state.Sync()
@@ -244,7 +258,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
putTx(sm.extraDb, tx, block, uint64(i))
}
- return td, state.Logs(), nil
+ return state.Logs(), nil
}
// Validates the current block. Returns an error if the block was invalid,
@@ -323,7 +337,7 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
}
uncles.Add(block.Hash())
- for _, uncle := range block.Uncles() {
+ for i, uncle := range block.Uncles() {
if uncles.Has(uncle.Hash()) {
// Error not unique
return UncleError("Uncle not unique")
@@ -340,9 +354,8 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
}
if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash]); err != nil {
- return ValidationError(fmt.Sprintf("%v", err))
+ return ValidationError(fmt.Sprintf("uncle[%d](%x) header invalid: %v", i, uncle.Hash().Bytes()[:4], err))
}
-
}
return nil
diff --git a/core/blocks.go b/core/blocks.go
new file mode 100644
index 000000000..b26e8f6ee
--- /dev/null
+++ b/core/blocks.go
@@ -0,0 +1,7 @@
+package core
+
+import "github.com/ethereum/go-ethereum/common"
+
+var badHashes = []common.Hash{
+ common.HexToHash("f269c503aed286caaa0d114d6a5320e70abbc2febe37953207e76a2873f2ba79"),
+}
diff --git a/core/chain_makers.go b/core/chain_makers.go
index 810741820..250671ef8 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -93,12 +93,12 @@ func makeChain(bman *BlockProcessor, parent *types.Block, max int, db common.Dat
blocks := make(types.Blocks, max)
for i := 0; i < max; i++ {
block := makeBlock(bman, parent, i, db, seed)
- td, _, err := bman.processWithParent(block, parent)
+ _, err := bman.processWithParent(block, parent)
if err != nil {
fmt.Println("process with parent failed", err)
panic(err)
}
- block.Td = td
+ block.Td = CalculateTD(block, parent)
blocks[i] = block
parent = block
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 7e792864a..3f2b3a26a 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -97,6 +97,21 @@ type ChainManager struct {
func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *ChainManager {
bc := &ChainManager{blockDb: blockDb, stateDb: stateDb, genesisBlock: GenesisBlock(stateDb), eventMux: mux, quit: make(chan struct{}), cache: NewBlockCache(blockCacheLimit)}
bc.setLastBlock()
+
+ // Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
+ for _, hash := range badHashes {
+ if block := bc.GetBlock(hash); block != nil {
+ glog.V(logger.Error).Infof("Found bad hash. Reorganising chain to state %x\n", block.ParentHash().Bytes()[:4])
+ block = bc.GetBlock(block.ParentHash())
+ if block == nil {
+ glog.Fatal("Unable to complete. Parent block not found. Corrupted DB?")
+ }
+ bc.SetHead(block)
+
+ glog.V(logger.Error).Infoln("Chain reorg was successfull. Resuming normal operation")
+ }
+ }
+
bc.transState = bc.State().Copy()
// Take ownership of this particular state
bc.txState = state.ManageState(bc.State().Copy())
@@ -109,6 +124,26 @@ func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *Chai
return bc
}
+func (bc *ChainManager) SetHead(head *types.Block) {
+ bc.mu.Lock()
+ defer bc.mu.Unlock()
+
+ for block := bc.currentBlock; block != nil && block.Hash() != head.Hash(); block = bc.GetBlock(block.Header().ParentHash) {
+ bc.removeBlock(block)
+ }
+
+ bc.cache = NewBlockCache(blockCacheLimit)
+ bc.currentBlock = head
+ bc.makeCache()
+
+ statedb := state.New(head.Root(), bc.stateDb)
+ bc.txState = state.ManageState(statedb)
+ bc.transState = statedb.Copy()
+ bc.setTotalDifficulty(head.Td)
+ bc.insert(head)
+ bc.setLastBlock()
+}
+
func (self *ChainManager) Td() *big.Int {
self.mu.RLock()
defer self.mu.RUnlock()
@@ -287,7 +322,12 @@ func (self *ChainManager) Export(w io.Writer) error {
last := self.currentBlock.NumberU64()
for nr := uint64(0); nr <= last; nr++ {
- if err := self.GetBlockByNumber(nr).EncodeRLP(w); err != nil {
+ block := self.GetBlockByNumber(nr)
+ if block == nil {
+ return fmt.Errorf("export failed on #%d: not found", nr)
+ }
+
+ if err := block.EncodeRLP(w); err != nil {
return err
}
}
@@ -330,14 +370,13 @@ func (self *ChainManager) GetBlockHashesFromHash(hash common.Hash, max uint64) (
}
// XXX Could be optimised by using a different database which only holds hashes (i.e., linked list)
for i := uint64(0); i < max; i++ {
- parentHash := block.Header().ParentHash
- block = self.GetBlock(parentHash)
+ block = self.GetBlock(block.ParentHash())
if block == nil {
break
}
chain = append(chain, block.Hash())
- if block.Header().Number.Cmp(common.Big0) <= 0 {
+ if block.Number().Cmp(common.Big0) <= 0 {
break
}
}
@@ -366,6 +405,12 @@ func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block {
self.mu.RLock()
defer self.mu.RUnlock()
+ return self.getBlockByNumber(num)
+
+}
+
+// non blocking version
+func (self *ChainManager) getBlockByNumber(num uint64) *types.Block {
key, _ := self.blockDb.Get(append(blockNumPre, big.NewInt(int64(num)).Bytes()...))
if len(key) == 0 {
return nil
@@ -456,7 +501,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
// Call in to the block processor and check for errors. It's likely that if one block fails
// all others will fail too (unless a known block is returned).
- td, logs, err := self.processor.Process(block)
+ logs, err := self.processor.Process(block)
if err != nil {
if IsKnownBlockErr(err) {
continue
@@ -481,13 +526,14 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
h := block.Header()
- glog.V(logger.Error).Infof("INVALID block #%v (%x)\n", h.Number, h.Hash().Bytes()[:4])
+ glog.V(logger.Error).Infof("INVALID block #%v (%x)\n", h.Number, h.Hash().Bytes())
glog.V(logger.Error).Infoln(err)
glog.V(logger.Debug).Infoln(block)
return err
}
- block.Td = td
+
+ block.Td = new(big.Int).Set(CalculateTD(block, self.GetBlock(block.ParentHash())))
self.mu.Lock()
{
@@ -497,23 +543,23 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self.write(block)
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
- if td.Cmp(self.td) > 0 {
+ if block.Td.Cmp(self.td) > 0 {
//if block.Header().Number.Cmp(new(big.Int).Add(cblock.Header().Number, common.Big1)) < 0 {
if block.Number().Cmp(cblock.Number()) <= 0 {
chash := cblock.Hash()
hash := block.Hash()
if glog.V(logger.Info) {
- glog.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, hash[:4], td, cblock.Header().Number, chash[:4], self.td)
+ glog.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, hash[:4], block.Td, cblock.Header().Number, chash[:4], self.td)
}
// during split we merge two different chains and create the new canonical chain
- self.merge(cblock, block)
+ self.merge(self.getBlockByNumber(block.NumberU64()), block)
queue[i] = ChainSplitEvent{block, logs}
queueEvent.splitCount++
}
- self.setTotalDifficulty(td)
+ self.setTotalDifficulty(block.Td)
self.insert(block)
jsonlogger.LogJson(&logger.EthChainNewHead{
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go
index 19afe0d5c..f16c0f0c3 100644
--- a/core/chain_manager_test.go
+++ b/core/chain_manager_test.go
@@ -69,15 +69,16 @@ func printChain(bc *ChainManager) {
func testChain(chainB types.Blocks, bman *BlockProcessor) (*big.Int, error) {
td := new(big.Int)
for _, block := range chainB {
- td2, _, err := bman.bc.processor.Process(block)
+ _, err := bman.bc.processor.Process(block)
if err != nil {
if IsKnownBlockErr(err) {
continue
}
return nil, err
}
- block.Td = td2
- td = td2
+ parent := bman.bc.GetBlock(block.ParentHash())
+ block.Td = CalculateTD(block, parent)
+ td = block.Td
bman.bc.mu.Lock()
{
diff --git a/core/genesis.go b/core/genesis.go
index 8ef1e140f..e72834822 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -36,7 +36,7 @@ func GenesisBlock(db common.Database) *types.Block {
Balance string
Code string
}
- err := json.Unmarshal(genesisData, &accounts)
+ err := json.Unmarshal(GenesisData, &accounts)
if err != nil {
fmt.Println("enable to decode genesis json data:", err)
os.Exit(1)
@@ -52,11 +52,12 @@ func GenesisBlock(db common.Database) *types.Block {
}
statedb.Sync()
genesis.Header().Root = statedb.Root()
+ genesis.Td = params.GenesisDifficulty
return genesis
}
-var genesisData = []byte(`{
+var GenesisData = []byte(`{
"0000000000000000000000000000000000000001": {"balance": "1"},
"0000000000000000000000000000000000000002": {"balance": "1"},
"0000000000000000000000000000000000000003": {"balance": "1"},
diff --git a/core/types/block.go b/core/types/block.go
index c47b555ed..f9206ec76 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -347,22 +347,20 @@ func (self *Block) Copy() *Block {
}
func (self *Block) String() string {
- return fmt.Sprintf(`BLOCK(%x): Size: %v TD: %v {
-NoNonce: %x
-Header:
-[
+ return fmt.Sprintf(`Block(#%v): Size: %v TD: %v {
+MinerHash: %x
%v
-]
Transactions:
%v
Uncles:
%v
}
-`, self.header.Hash(), self.Size(), self.Td, self.header.HashNoNonce(), self.header, self.transactions, self.uncles)
+`, self.Number(), self.Size(), self.Td, self.header.HashNoNonce(), self.header, self.transactions, self.uncles)
}
func (self *Header) String() string {
- return fmt.Sprintf(`
+ return fmt.Sprintf(`Header(%x):
+[
ParentHash: %x
UncleHash: %x
Coinbase: %x
@@ -377,8 +375,8 @@ func (self *Header) String() string {
Time: %v
Extra: %s
MixDigest: %x
- Nonce: %x`,
- self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra, self.MixDigest, self.Nonce)
+ Nonce: %x
+]`, self.Hash(), self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra, self.MixDigest, self.Nonce)
}
type Blocks []*Block
diff --git a/core/types/common.go b/core/types/common.go
index 4397d4938..dbdaaba0c 100644
--- a/core/types/common.go
+++ b/core/types/common.go
@@ -10,7 +10,7 @@ import (
)
type BlockProcessor interface {
- Process(*Block) (*big.Int, state.Logs, error)
+ Process(*Block) (state.Logs, error)
}
const bloomLength = 256
diff --git a/core/types/transaction.go b/core/types/transaction.go
index 6646bdf29..d8dcd7424 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -22,7 +22,7 @@ type Transaction struct {
AccountNonce uint64
Price *big.Int
GasLimit *big.Int
- Recipient *common.Address // nil means contract creation
+ Recipient *common.Address `rlp:"nil"` // nil means contract creation
Amount *big.Int
Payload []byte
V byte
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 9865c87c4..89423e0c4 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -120,6 +120,7 @@ func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error) {
}
// LoadECDSA loads a secp256k1 private key from the given file.
+// The key data is expected to be hex-encoded.
func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
buf := make([]byte, 64)
fd, err := os.Open(file)
@@ -139,8 +140,8 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
return ToECDSA(key), nil
}
-// SaveECDSA saves a secp256k1 private key to the given file with restrictive
-// permissions
+// SaveECDSA saves a secp256k1 private key to the given file with
+// restrictive permissions. The key data is saved hex-encoded.
func SaveECDSA(file string, key *ecdsa.PrivateKey) error {
k := hex.EncodeToString(FromECDSA(key))
return ioutil.WriteFile(file, []byte(k), 0600)
diff --git a/eth/backend.go b/eth/backend.go
index cde7b167d..ec2444836 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -3,19 +3,18 @@ package eth
import (
"crypto/ecdsa"
"fmt"
- "io/ioutil"
"math"
"path"
"strings"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
@@ -51,6 +50,7 @@ type Config struct {
LogLevel int
LogJSON string
VmDebug bool
+ NatSpec bool
MaxPeers int
Port string
@@ -110,7 +110,7 @@ func (cfg *Config) nodeKey() (*ecdsa.PrivateKey, error) {
if key, err = crypto.GenerateKey(); err != nil {
return nil, fmt.Errorf("could not generate server key: %v", err)
}
- if err := ioutil.WriteFile(keyfile, crypto.FromECDSA(key), 0600); err != nil {
+ if err := crypto.SaveECDSA(keyfile, key); err != nil {
glog.V(logger.Error).Infoln("could not persist nodekey: ", err)
}
return key, nil
@@ -127,23 +127,25 @@ type Ethereum struct {
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
- blockProcessor *core.BlockProcessor
- txPool *core.TxPool
- chainManager *core.ChainManager
- blockPool *blockpool.BlockPool
- accountManager *accounts.Manager
- whisper *whisper.Whisper
- pow *ethash.Ethash
-
- net *p2p.Server
- eventMux *event.TypeMux
- txSub event.Subscription
- blockSub event.Subscription
- miner *miner.Miner
+ blockProcessor *core.BlockProcessor
+ txPool *core.TxPool
+ chainManager *core.ChainManager
+ accountManager *accounts.Manager
+ whisper *whisper.Whisper
+ pow *ethash.Ethash
+ protocolManager *ProtocolManager
+ downloader *downloader.Downloader
+
+ net *p2p.Server
+ eventMux *event.TypeMux
+ txSub event.Subscription
+ minedBlockSub event.Subscription
+ miner *miner.Miner
// logger logger.LogSystem
Mining bool
+ NatSpec bool
DataDir string
etherbase common.Address
clientVersion string
@@ -205,9 +207,11 @@ func New(config *Config) (*Ethereum, error) {
clientVersion: config.Name, // TODO should separate from Name
ethVersionId: config.ProtocolVersion,
netVersionId: config.NetworkId,
+ NatSpec: config.NatSpec,
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
+ eth.downloader = downloader.New(eth.chainManager.HasBlock, eth.chainManager.InsertChain, eth.chainManager.Td)
eth.pow = ethash.New(eth.chainManager)
eth.txPool = core.NewTxPool(eth.EventMux(), eth.chainManager.State)
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
@@ -215,23 +219,16 @@ func New(config *Config) (*Ethereum, error) {
eth.whisper = whisper.New()
eth.shhVersionId = int(eth.whisper.Version())
eth.miner = miner.New(eth, eth.pow, config.MinerThreads)
-
- hasBlock := eth.chainManager.HasBlock
- insertChain := eth.chainManager.InsertChain
- td := eth.chainManager.Td()
- eth.blockPool = blockpool.New(hasBlock, insertChain, eth.pow.Verify, eth.EventMux(), td)
+ eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.txPool, eth.chainManager, eth.downloader)
netprv, err := config.nodeKey()
if err != nil {
return nil, err
}
-
- ethProto := EthProtocol(config.ProtocolVersion, config.NetworkId, eth.txPool, eth.chainManager, eth.blockPool)
- protocols := []p2p.Protocol{ethProto}
+ protocols := []p2p.Protocol{eth.protocolManager.SubProtocol}
if config.Shh {
protocols = append(protocols, eth.whisper.Protocol())
}
-
eth.net = &p2p.Server{
PrivateKey: netprv,
Name: config.Name,
@@ -349,7 +346,6 @@ func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManag
func (s *Ethereum) ChainManager() *core.ChainManager { return s.chainManager }
func (s *Ethereum) BlockProcessor() *core.BlockProcessor { return s.blockProcessor }
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
-func (s *Ethereum) BlockPool() *blockpool.BlockPool { return s.blockPool }
func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) BlockDb() common.Database { return s.blockDb }
@@ -363,6 +359,7 @@ func (s *Ethereum) ClientVersion() string { return s.clientVersio
func (s *Ethereum) EthVersion() int { return s.ethVersionId }
func (s *Ethereum) NetVersion() int { return s.netVersionId }
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
+func (s *Ethereum) Downloader() *downloader.Downloader { return s.downloader }
// Start the ethereum
func (s *Ethereum) Start() error {
@@ -380,7 +377,6 @@ func (s *Ethereum) Start() error {
// Start services
s.txPool.Start()
- s.blockPool.Start()
if s.whisper != nil {
s.whisper.Start()
@@ -391,8 +387,8 @@ func (s *Ethereum) Start() error {
go s.txBroadcastLoop()
// broadcast mined blocks
- s.blockSub = s.eventMux.Subscribe(core.ChainHeadEvent{})
- go s.blockBroadcastLoop()
+ s.minedBlockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
+ go s.minedBroadcastLoop()
glog.V(logger.Info).Infoln("Server started")
return nil
@@ -406,7 +402,6 @@ func (s *Ethereum) StartForTest() {
// Start services
s.txPool.Start()
- s.blockPool.Start()
}
func (self *Ethereum) SuggestPeer(nodeURL string) error {
@@ -424,12 +419,11 @@ func (s *Ethereum) Stop() {
defer s.stateDb.Close()
defer s.extraDb.Close()
- s.txSub.Unsubscribe() // quits txBroadcastLoop
- s.blockSub.Unsubscribe() // quits blockBroadcastLoop
+ s.txSub.Unsubscribe() // quits txBroadcastLoop
+ s.minedBlockSub.Unsubscribe() // quits blockBroadcastLoop
s.txPool.Stop()
s.eventMux.Stop()
- s.blockPool.Stop()
if s.whisper != nil {
s.whisper.Stop()
}
@@ -468,12 +462,12 @@ func (self *Ethereum) syncAccounts(tx *types.Transaction) {
}
}
-func (self *Ethereum) blockBroadcastLoop() {
+func (self *Ethereum) minedBroadcastLoop() {
// automatically stops if unsubscribe
- for obj := range self.blockSub.Chan() {
+ for obj := range self.minedBlockSub.Chan() {
switch ev := obj.(type) {
- case core.ChainHeadEvent:
- self.net.BroadcastLimited("eth", NewBlockMsg, math.Sqrt, []interface{}{ev.Block, ev.Block.Td})
+ case core.NewMinedBlockEvent:
+ self.protocolManager.BroadcastBlock(ev.Block.Hash(), ev.Block)
}
}
}
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 91cc65249..cfc494b2f 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -1,6 +1,8 @@
package downloader
import (
+ "errors"
+ "fmt"
"math"
"math/big"
"sync"
@@ -16,8 +18,22 @@ import (
)
const (
- maxBlockFetch = 256 // Amount of max blocks to be fetched per chunk
- minDesiredPeerCount = 3 // Amount of peers desired to start syncing
+ maxBlockFetch = 256 // Amount of max blocks to be fetched per chunk
+ peerCountTimeout = 12 * time.Second // Amount of time it takes for the peer handler to ignore minDesiredPeerCount
+ hashTtl = 20 * time.Second // The amount of time it takes for a hash request to time out
+)
+
+var (
+ minDesiredPeerCount = 5 // Amount of peers desired to start syncing
+ blockTtl = 20 * time.Second // The amount of time it takes for a block request to time out
+
+ errLowTd = errors.New("peer's TD is too low")
+ errBusy = errors.New("busy")
+ errUnknownPeer = errors.New("peer's unknown or unhealthy")
+ errBadPeer = errors.New("action from bad peer ignored")
+ errTimeout = errors.New("timeout")
+ errEmptyHashSet = errors.New("empty hash set by peer")
+ errPeersUnavailable = errors.New("no peers available or all peers tried for block download process")
)
type hashCheckFn func(common.Hash) bool
@@ -25,10 +41,22 @@ type chainInsertFn func(types.Blocks) error
type hashIterFn func() (common.Hash, error)
type currentTdFn func() *big.Int
+type blockPack struct {
+ peerId string
+ blocks []*types.Block
+}
+
+type syncPack struct {
+ peer *peer
+ hash common.Hash
+ ignoreInitial bool
+}
+
type Downloader struct {
- mu sync.RWMutex
- queue *queue
- peers peers
+ mu sync.RWMutex
+ queue *queue
+ peers peers
+ activePeer string
// Callbacks
hasBlock hashCheckFn
@@ -43,22 +71,11 @@ type Downloader struct {
// Channels
newPeerCh chan *peer
syncCh chan syncPack
- HashCh chan []common.Hash
+ hashCh chan []common.Hash
blockCh chan blockPack
quit chan struct{}
}
-type blockPack struct {
- peerId string
- blocks []*types.Block
-}
-
-type syncPack struct {
- peer *peer
- hash common.Hash
- ignoreInitial bool
-}
-
func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn) *Downloader {
downloader := &Downloader{
queue: newqueue(),
@@ -68,7 +85,7 @@ func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn)
currentTd: currentTd,
newPeerCh: make(chan *peer, 1),
syncCh: make(chan syncPack, 1),
- HashCh: make(chan []common.Hash, 1),
+ hashCh: make(chan []common.Hash, 1),
blockCh: make(chan blockPack, 1),
quit: make(chan struct{}),
}
@@ -78,11 +95,15 @@ func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn)
return downloader
}
+func (d *Downloader) Stats() (current int, max int) {
+ return d.queue.blockHashes.Size(), d.queue.fetchPool.Size() + d.queue.hashPool.Size()
+}
+
func (d *Downloader) RegisterPeer(id string, td *big.Int, hash common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) error {
d.mu.Lock()
defer d.mu.Unlock()
- glog.V(logger.Detail).Infoln("Register peer", id)
+ glog.V(logger.Detail).Infoln("Register peer", id, "TD =", td)
// Create a new peer and add it to the list of known peers
peer := newPeer(id, td, hash, getHashes, getBlocks)
@@ -94,6 +115,7 @@ func (d *Downloader) RegisterPeer(id string, td *big.Int, hash common.Hash, getH
return nil
}
+// UnregisterPeer unregister's a peer. This will prevent any action from the specified peer.
func (d *Downloader) UnregisterPeer(id string) {
d.mu.Lock()
defer d.mu.Unlock()
@@ -105,22 +127,28 @@ func (d *Downloader) UnregisterPeer(id string) {
func (d *Downloader) peerHandler() {
// itimer is used to determine when to start ignoring `minDesiredPeerCount`
- //itimer := time.NewTicker(5 * time.Second)
- itimer := time.NewTimer(5 * time.Second)
+ itimer := time.NewTimer(peerCountTimeout)
out:
for {
select {
case <-d.newPeerCh:
- itimer.Stop()
// Meet the `minDesiredPeerCount` before we select our best peer
if len(d.peers) < minDesiredPeerCount {
break
}
+ itimer.Stop()
+
d.selectPeer(d.peers.bestPeer())
case <-itimer.C:
// The timer will make sure that the downloader keeps an active state
// in which it attempts to always check the network for highest td peers
- d.selectPeer(d.peers.bestPeer())
+ // Either select the peer or restart the timer if no peers could
+ // be selected.
+ if peer := d.peers.bestPeer(); peer != nil {
+ d.selectPeer(d.peers.bestPeer())
+ } else {
+ itimer.Reset(5 * time.Second)
+ }
case <-d.quit:
break out
}
@@ -131,17 +159,19 @@ func (d *Downloader) selectPeer(p *peer) {
// Make sure it's doing neither. Once done we can restart the
// downloading process if the TD is higher. For now just get on
// with whatever is going on. This prevents unecessary switching.
- if !(d.isFetchingHashes() || d.isDownloadingBlocks() || d.isProcessing()) {
- // selected peer must be better than our own
- // XXX we also check the peer's recent hash to make sure we
- // don't have it. Some peers report (i think) incorrect TD.
- if p.td.Cmp(d.currentTd()) <= 0 || d.hasBlock(p.recentHash) {
- return
- }
-
- glog.V(logger.Detail).Infoln("New peer with highest TD =", p.td)
- d.syncCh <- syncPack{p, p.recentHash, false}
+ if d.isBusy() {
+ return
}
+ // selected peer must be better than our own
+ // XXX we also check the peer's recent hash to make sure we
+ // don't have it. Some peers report (i think) incorrect TD.
+ if p.td.Cmp(d.currentTd()) <= 0 || d.hasBlock(p.recentHash) {
+ return
+ }
+
+ glog.V(logger.Detail).Infoln("New peer with highest TD =", p.td)
+ d.syncCh <- syncPack{p, p.recentHash, false}
+
}
func (d *Downloader) update() {
@@ -149,30 +179,13 @@ out:
for {
select {
case sync := <-d.syncCh:
- selectedPeer := sync.peer
- glog.V(logger.Detail).Infoln("Synchronising with network using:", selectedPeer.id)
- // Start the fetcher. This will block the update entirely
- // interupts need to be send to the appropriate channels
- // respectively.
- if err := d.startFetchingHashes(selectedPeer, sync.hash, sync.ignoreInitial); err != nil {
- // handle error
- glog.V(logger.Debug).Infoln("Error fetching hashes:", err)
- // XXX Reset
+ var peer *peer = sync.peer
+ err := d.getFromPeer(peer, sync.hash, sync.ignoreInitial)
+ if err != nil {
+ glog.V(logger.Detail).Infoln(err)
break
}
- // Start fetching blocks in paralel. The strategy is simple
- // take any available peers, seserve a chunk for each peer available,
- // let the peer deliver the chunkn and periodically check if a peer
- // has timedout. When done downloading, process blocks.
- if err := d.startFetchingBlocks(selectedPeer); err != nil {
- glog.V(logger.Debug).Infoln("Error downloading blocks:", err)
- // XXX reset
- break
- }
-
- glog.V(logger.Detail).Infoln("Sync completed")
-
d.process()
case <-d.quit:
break out
@@ -182,6 +195,9 @@ out:
// XXX Make synchronous
func (d *Downloader) startFetchingHashes(p *peer, hash common.Hash, ignoreInitial bool) error {
+ atomic.StoreInt32(&d.fetchingHashes, 1)
+ defer atomic.StoreInt32(&d.fetchingHashes, 0)
+
glog.V(logger.Debug).Infof("Downloading hashes (%x) from %s", hash.Bytes()[:4], p.id)
start := time.Now()
@@ -192,15 +208,17 @@ func (d *Downloader) startFetchingHashes(p *peer, hash common.Hash, ignoreInitia
// Add the hash to the queue first
d.queue.hashPool.Add(hash)
}
-
// Get the first batch of hashes
p.getHashes(hash)
- atomic.StoreInt32(&d.fetchingHashes, 1)
+
+ failureResponseTimer := time.NewTimer(hashTtl)
out:
for {
select {
- case hashes := <-d.HashCh:
+ case hashes := <-d.hashCh:
+ failureResponseTimer.Reset(hashTtl)
+
var done bool // determines whether we're done fetching hashes (i.e. common hash found)
hashSet := set.New()
for _, hash := range hashes {
@@ -216,26 +234,40 @@ out:
d.queue.put(hashSet)
// Add hashes to the chunk set
- // Check if we're done fetching
- if !done && len(hashes) > 0 {
- //fmt.Println("re-fetch. current =", d.queue.hashPool.Size())
+ if len(hashes) == 0 { // Make sure the peer actually gave you something valid
+ glog.V(logger.Debug).Infof("Peer (%s) responded with empty hash set\n", p.id)
+ d.queue.reset()
+
+ return errEmptyHashSet
+ } else if !done { // Check if we're done fetching
// Get the next set of hashes
p.getHashes(hashes[len(hashes)-1])
- atomic.StoreInt32(&d.fetchingHashes, 1)
- } else {
- atomic.StoreInt32(&d.fetchingHashes, 0)
+ } else { // we're done
break out
}
+ case <-failureResponseTimer.C:
+ glog.V(logger.Debug).Infof("Peer (%s) didn't respond in time for hash request\n", p.id)
+ // TODO instead of reseting the queue select a new peer from which we can start downloading hashes.
+ // 1. check for peer's best hash to be included in the current hash set;
+ // 2. resume from last point (hashes[len(hashes)-1]) using the newly selected peer.
+ d.queue.reset()
+
+ return errTimeout
}
}
- glog.V(logger.Detail).Infof("Downloaded hashes (%d). Took %v\n", d.queue.hashPool.Size(), time.Since(start))
+ glog.V(logger.Detail).Infof("Downloaded hashes (%d) in %v\n", d.queue.hashPool.Size(), time.Since(start))
return nil
}
func (d *Downloader) startFetchingBlocks(p *peer) error {
- glog.V(logger.Detail).Infoln("Downloading", d.queue.hashPool.Size(), "blocks")
+ glog.V(logger.Detail).Infoln("Downloading", d.queue.hashPool.Size(), "block(s)")
atomic.StoreInt32(&d.downloadingBlocks, 1)
+ defer atomic.StoreInt32(&d.downloadingBlocks, 0)
+ // Defer the peer reset. This will empty the peer requested set
+ // and makes sure there are no lingering peers with an incorrect
+ // state
+ defer d.peers.reset()
start := time.Now()
@@ -245,18 +277,18 @@ out:
for {
select {
case blockPack := <-d.blockCh:
- d.peers[blockPack.peerId].promote()
- d.queue.deliver(blockPack.peerId, blockPack.blocks)
- d.peers.setState(blockPack.peerId, idleState)
+ // If the peer was previously banned and failed to deliver it's pack
+ // in a reasonable time frame, ignore it's message.
+ if d.peers[blockPack.peerId] != nil {
+ d.peers[blockPack.peerId].promote()
+ d.queue.deliver(blockPack.peerId, blockPack.blocks)
+ d.peers.setState(blockPack.peerId, idleState)
+ }
case <-ticker.C:
// If there are unrequested hashes left start fetching
// from the available peers.
if d.queue.hashPool.Size() > 0 {
availablePeers := d.peers.get(idleState)
- if len(availablePeers) == 0 {
- glog.V(logger.Detail).Infoln("No peers available out of", len(d.peers))
- }
-
for _, peer := range availablePeers {
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
@@ -265,7 +297,6 @@ out:
continue
}
- //fmt.Println("fetching for", peer.id)
// XXX make fetch blocking.
// Fetch the chunk and check for error. If the peer was somehow
// already fetching a chunk due to a bug, it will be returned to
@@ -276,13 +307,19 @@ out:
d.queue.put(chunk.hashes)
}
}
- atomic.StoreInt32(&d.downloadingBlocks, 1)
+
+ // make sure that we have peers available for fetching. If all peers have been tried
+ // and all failed throw an error
+ if len(d.queue.fetching) == 0 {
+ d.queue.reset()
+
+ return fmt.Errorf("%v peers avaialable = %d. total peers = %d. hashes needed = %d", errPeersUnavailable, len(availablePeers), len(d.peers), d.queue.hashPool.Size())
+ }
+
} else if len(d.queue.fetching) == 0 {
// When there are no more queue and no more `fetching`. We can
// safely assume we're done. Another part of the process will check
// for parent errors and will re-request anything that's missing
- atomic.StoreInt32(&d.downloadingBlocks, 0)
- // Break out so that we can process with processing blocks
break out
} else {
// Check for bad peers. Bad peers may indicate a peer not responding
@@ -293,10 +330,10 @@ out:
d.queue.mu.Lock()
var badPeers []string
for pid, chunk := range d.queue.fetching {
- if time.Since(chunk.itime) > 5*time.Second {
+ if time.Since(chunk.itime) > blockTtl {
badPeers = append(badPeers, pid)
// remove peer as good peer from peer list
- d.UnregisterPeer(pid)
+ //d.UnregisterPeer(pid)
}
}
d.queue.mu.Unlock()
@@ -311,28 +348,50 @@ out:
// 2) Measure their speed;
// 3) Amount and availability.
d.queue.deliver(pid, nil)
- if peer := p.peers[pid]; peer != nil {
+ if peer := d.peers[pid]; peer != nil {
peer.demote()
+ peer.reset()
}
}
}
- //fmt.Println(d.queue.hashPool.Size(), len(d.queue.fetching))
}
}
- glog.V(logger.Detail).Infoln("Download blocks: done. Took", time.Since(start))
+ glog.V(logger.Detail).Infoln("Downloaded block(s) in", time.Since(start))
+
+ return nil
+}
+
+// Deliver a chunk to the downloader. This is usually done through the BlocksMsg by
+// the protocol handler.
+func (d *Downloader) DeliverChunk(id string, blocks []*types.Block) {
+ d.blockCh <- blockPack{id, blocks}
+}
+
+func (d *Downloader) AddHashes(id string, hashes []common.Hash) error {
+ // make sure that the hashes that are being added are actually from the peer
+ // that's the current active peer. hashes that have been received from other
+ // peers are dropped and ignored.
+ if d.activePeer != id {
+ return fmt.Errorf("received hashes from %s while active peer is %s", id, d.activePeer)
+ }
+
+ d.hashCh <- hashes
return nil
}
// Add an (unrequested) block to the downloader. This is usually done through the
// NewBlockMsg by the protocol handler.
-func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
+// Adding blocks is done synchronously. if there are missing blocks, blocks will be
+// fetched first. If the downloader is busy or if some other processed failed an error
+// will be returned.
+func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) error {
hash := block.Hash()
if d.hasBlock(hash) {
- return
+ return fmt.Errorf("known block %x", hash.Bytes()[:4])
}
peer := d.peers.getPeer(id)
@@ -340,7 +399,7 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
// and add the block. Otherwise just ignore it
if peer == nil {
glog.V(logger.Detail).Infof("Ignored block from bad peer %s\n", id)
- return
+ return errBadPeer
}
peer.mu.Lock()
@@ -353,23 +412,24 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
d.queue.addBlock(id, block, td)
// if neither go ahead to process
- if !(d.isFetchingHashes() || d.isDownloadingBlocks()) {
- // Check if the parent of the received block is known.
- // If the block is not know, request it otherwise, request.
- phash := block.ParentHash()
- if !d.hasBlock(phash) {
- glog.V(logger.Detail).Infof("Missing parent %x, requires fetching\n", phash.Bytes()[:4])
- d.syncCh <- syncPack{peer, peer.recentHash, true}
- } else {
- d.process()
+ if d.isBusy() {
+ return errBusy
+ }
+
+ // Check if the parent of the received block is known.
+ // If the block is not know, request it otherwise, request.
+ phash := block.ParentHash()
+ if !d.hasBlock(phash) {
+ glog.V(logger.Detail).Infof("Missing parent %x, requires fetching\n", phash.Bytes()[:4])
+
+ // Get the missing hashes from the peer (synchronously)
+ err := d.getFromPeer(peer, peer.recentHash, true)
+ if err != nil {
+ return err
}
}
-}
-// Deliver a chunk to the downloader. This is usually done through the BlocksMsg by
-// the protocol handler.
-func (d *Downloader) DeliverChunk(id string, blocks []*types.Block) {
- d.blockCh <- blockPack{id, blocks}
+ return d.process()
}
func (d *Downloader) process() error {
@@ -383,8 +443,11 @@ func (d *Downloader) process() error {
// to a seperate goroutine where it periodically checks for linked pieces.
types.BlockBy(types.Number).Sort(d.queue.blocks)
blocks := d.queue.blocks
+ if len(blocks) == 0 {
+ return nil
+ }
- glog.V(logger.Debug).Infoln("Inserting chain with", len(blocks), "blocks")
+ glog.V(logger.Debug).Infof("Inserting chain with %d blocks (#%v - #%v)\n", len(blocks), blocks[0].Number(), blocks[len(blocks)-1].Number())
var err error
// Loop untill we're out of blocks
@@ -408,6 +471,13 @@ func (d *Downloader) process() error {
}
}
break
+ } else if err != nil {
+ // immediatly unregister the false peer but do not disconnect
+ d.UnregisterPeer(d.activePeer)
+ // Reset chain completely. This needs much, much improvement.
+ // instead: check all blocks leading down to this block false block and remove it
+ blocks = nil
+ break
}
blocks = blocks[max:]
}
@@ -432,3 +502,7 @@ func (d *Downloader) isDownloadingBlocks() bool {
func (d *Downloader) isProcessing() bool {
return atomic.LoadInt32(&d.processingBlocks) == 1
}
+
+func (d *Downloader) isBusy() bool {
+ return d.isFetchingHashes() || d.isDownloadingBlocks() || d.isProcessing()
+}
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index 6cf99b678..1d449cfba 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -73,7 +73,7 @@ func (dl *downloadTester) insertChain(blocks types.Blocks) error {
}
func (dl *downloadTester) getHashes(hash common.Hash) error {
- dl.downloader.HashCh <- dl.hashes
+ dl.downloader.hashCh <- dl.hashes
return nil
}
@@ -109,6 +109,9 @@ func TestDownload(t *testing.T) {
glog.SetV(logger.Detail)
glog.SetToStderr(true)
+ minDesiredPeerCount = 4
+ blockTtl = 1 * time.Second
+
hashes := createHashes(0, 1000)
blocks := createBlocksFromHashes(hashes)
tester := newTester(t, hashes, blocks)
@@ -123,7 +126,7 @@ success:
case <-tester.done:
break success
case <-time.After(10 * time.Second): // XXX this could actually fail on a slow computer
- t.Error("timout")
+ t.Error("timeout")
}
}
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index 4cd306a05..bcb8ad43a 100644
--- a/eth/downloader/peer.go
+++ b/eth/downloader/peer.go
@@ -6,6 +6,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
+ "gopkg.in/fatih/set.v0"
)
const (
@@ -19,6 +20,12 @@ type blockFetcherFn func([]common.Hash) error
// XXX make threadsafe!!!!
type peers map[string]*peer
+func (p peers) reset() {
+ for _, peer := range p {
+ peer.reset()
+ }
+}
+
func (p peers) get(state int) []*peer {
var peers []*peer
for _, peer := range p {
@@ -64,13 +71,23 @@ type peer struct {
td *big.Int
recentHash common.Hash
+ ignored *set.Set
+
getHashes hashFetcherFn
getBlocks blockFetcherFn
}
// create a new peer
func newPeer(id string, td *big.Int, hash common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) *peer {
- return &peer{id: id, td: td, recentHash: hash, getHashes: getHashes, getBlocks: getBlocks, state: idleState}
+ return &peer{
+ id: id,
+ td: td,
+ recentHash: hash,
+ getHashes: getHashes,
+ getBlocks: getBlocks,
+ state: idleState,
+ ignored: set.New(),
+ }
}
// fetch a chunk using the peer
@@ -115,3 +132,8 @@ func (p *peer) demote() {
p.rep = 0
}
}
+
+func (p *peer) reset() {
+ p.state = idleState
+ p.ignored.Clear()
+}
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index 4d1aa4e93..adbc2a0d0 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -31,6 +31,17 @@ func newqueue() *queue {
}
}
+func (c *queue) reset() {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ c.hashPool.Clear()
+ c.fetchPool.Clear()
+ c.blockHashes.Clear()
+ c.blocks = nil
+ c.fetching = make(map[string]*chunk)
+}
+
// reserve a `max` set of hashes for `p` peer.
func (c *queue) get(p *peer, max int) *chunk {
c.mu.Lock()
@@ -45,22 +56,32 @@ func (c *queue) get(p *peer, max int) *chunk {
// Create a new set of hashes
hashes, i := set.New(), 0
c.hashPool.Each(func(v interface{}) bool {
+ // break on limit
if i == limit {
return false
}
+ // skip any hashes that have previously been requested from the peer
+ if p.ignored.Has(v) {
+ return true
+ }
hashes.Add(v)
i++
return true
})
+ // if no hashes can be requested return a nil chunk
+ if hashes.Size() == 0 {
+ return nil
+ }
+
// remove the fetchable hashes from hash pool
c.hashPool.Separate(hashes)
c.fetchPool.Merge(hashes)
// Create a new chunk for the seperated hashes. The time is being used
// to reset the chunk (timeout)
- chunk := &chunk{hashes, time.Now()}
+ chunk := &chunk{p, hashes, time.Now()}
// register as 'fetching' state
c.fetching[p.id] = chunk
@@ -92,6 +113,12 @@ func (c *queue) deliver(id string, blocks []*types.Block) {
// If the chunk was never requested simply ignore it
if chunk != nil {
delete(c.fetching, id)
+ // check the length of the returned blocks. If the length of blocks is 0
+ // we'll assume the peer doesn't know about the chain.
+ if len(blocks) == 0 {
+ // So we can ignore the blocks we didn't know about
+ chunk.peer.ignored.Merge(chunk.hashes)
+ }
// seperate the blocks and the hashes
blockHashes := chunk.fetchedHashes(blocks)
@@ -99,7 +126,6 @@ func (c *queue) deliver(id string, blocks []*types.Block) {
c.blockHashes.Merge(blockHashes)
// Add the blocks
c.blocks = append(c.blocks, blocks...)
-
// Add back whatever couldn't be delivered
c.hashPool.Merge(chunk.hashes)
c.fetchPool.Separate(chunk.hashes)
@@ -115,6 +141,7 @@ func (c *queue) put(hashes *set.Set) {
}
type chunk struct {
+ peer *peer
hashes *set.Set
itime time.Time
}
diff --git a/eth/downloader/synchronous.go b/eth/downloader/synchronous.go
new file mode 100644
index 000000000..7bb49d24e
--- /dev/null
+++ b/eth/downloader/synchronous.go
@@ -0,0 +1,79 @@
+package downloader
+
+import (
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
+)
+
+// THIS IS PENDING AND TO DO CHANGES FOR MAKING THE DOWNLOADER SYNCHRONOUS
+
+// SynchroniseWithPeer will select the peer and use it for synchronising. If an empty string is given
+// it will use the best peer possible and synchronise if it's TD is higher than our own. If any of the
+// checks fail an error will be returned. This method is synchronous
+func (d *Downloader) SynchroniseWithPeer(id string) (types.Blocks, error) {
+ // Check if we're busy
+ if d.isBusy() {
+ return nil, errBusy
+ }
+
+ // Attempt to select a peer. This can either be nothing, which returns, best peer
+ // or selected peer. If no peer could be found an error will be returned
+ var p *peer
+ if len(id) == 0 {
+ p = d.peers[id]
+ if p == nil {
+ return nil, errUnknownPeer
+ }
+ } else {
+ p = d.peers.bestPeer()
+ }
+
+ // Make sure our td is lower than the peer's td
+ if p.td.Cmp(d.currentTd()) <= 0 || d.hasBlock(p.recentHash) {
+ return nil, errLowTd
+ }
+
+ // Get the hash from the peer and initiate the downloading progress.
+ err := d.getFromPeer(p, p.recentHash, false)
+ if err != nil {
+ return nil, err
+ }
+
+ return d.queue.blocks, nil
+}
+
+// Synchronise will synchronise using the best peer.
+func (d *Downloader) Synchronise() (types.Blocks, error) {
+ return d.SynchroniseWithPeer("")
+}
+
+func (d *Downloader) getFromPeer(p *peer, hash common.Hash, ignoreInitial bool) error {
+ d.activePeer = p.id
+
+ glog.V(logger.Detail).Infoln("Synchronising with the network using:", p.id)
+ // Start the fetcher. This will block the update entirely
+ // interupts need to be send to the appropriate channels
+ // respectively.
+ if err := d.startFetchingHashes(p, hash, ignoreInitial); err != nil {
+ // handle error
+ glog.V(logger.Debug).Infoln("Error fetching hashes:", err)
+ // XXX Reset
+ return err
+ }
+
+ // Start fetching blocks in paralel. The strategy is simple
+ // take any available peers, seserve a chunk for each peer available,
+ // let the peer deliver the chunkn and periodically check if a peer
+ // has timedout. When done downloading, process blocks.
+ if err := d.startFetchingBlocks(p); err != nil {
+ glog.V(logger.Debug).Infoln("Error downloading blocks:", err)
+ // XXX reset
+ return err
+ }
+
+ glog.V(logger.Detail).Infoln("Sync completed")
+
+ return nil
+}
diff --git a/eth/handler.go b/eth/handler.go
new file mode 100644
index 000000000..622f22132
--- /dev/null
+++ b/eth/handler.go
@@ -0,0 +1,335 @@
+package eth
+
+// XXX Fair warning, most of the code is re-used from the old protocol. Please be aware that most of this will actually change
+// The idea is that most of the calls within the protocol will become synchronous.
+// Block downloading and block processing will be complete seperate processes
+/*
+# Possible scenarios
+
+// Synching scenario
+// Use the best peer to synchronise
+blocks, err := pm.downloader.Synchronise()
+if err != nil {
+ // handle
+ break
+}
+pm.chainman.InsertChain(blocks)
+
+// Receiving block with known parent
+if parent_exist {
+ if err := pm.chainman.InsertChain(block); err != nil {
+ // handle
+ break
+ }
+ pm.BroadcastBlock(block)
+}
+
+// Receiving block with unknown parent
+blocks, err := pm.downloader.SynchroniseWithPeer(peer)
+if err != nil {
+ // handle
+ break
+}
+pm.chainman.InsertChain(blocks)
+
+*/
+
+import (
+ "fmt"
+ "math"
+ "math/big"
+ "sync"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth/downloader"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/rlp"
+)
+
+func errResp(code errCode, format string, v ...interface{}) error {
+ return fmt.Errorf("%v - %v", code, fmt.Sprintf(format, v...))
+}
+
+type hashFetcherFn func(common.Hash) error
+type blockFetcherFn func([]common.Hash) error
+
+// extProt is an interface which is passed around so we can expose GetHashes and GetBlock without exposing it to the rest of the protocol
+// extProt is passed around to peers which require to GetHashes and GetBlocks
+type extProt struct {
+ getHashes hashFetcherFn
+ getBlocks blockFetcherFn
+}
+
+func (ep extProt) GetHashes(hash common.Hash) error { return ep.getHashes(hash) }
+func (ep extProt) GetBlock(hashes []common.Hash) error { return ep.getBlocks(hashes) }
+
+type ProtocolManager struct {
+ protVer, netId int
+ txpool txPool
+ chainman *core.ChainManager
+ downloader *downloader.Downloader
+
+ pmu sync.Mutex
+ peers map[string]*peer
+
+ SubProtocol p2p.Protocol
+}
+
+// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
+// with the ethereum network.
+func NewProtocolManager(protocolVersion, networkId int, txpool txPool, chainman *core.ChainManager, downloader *downloader.Downloader) *ProtocolManager {
+ manager := &ProtocolManager{
+ txpool: txpool,
+ chainman: chainman,
+ downloader: downloader,
+ peers: make(map[string]*peer),
+ }
+
+ manager.SubProtocol = p2p.Protocol{
+ Name: "eth",
+ Version: uint(protocolVersion),
+ Length: ProtocolLength,
+ Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
+ peer := manager.newPeer(protocolVersion, networkId, p, rw)
+ err := manager.handle(peer)
+ //glog.V(logger.Detail).Infof("[%s]: %v\n", peer.id, err)
+
+ return err
+ },
+ }
+
+ return manager
+}
+
+func (pm *ProtocolManager) newPeer(pv, nv int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer {
+
+ td, current, genesis := pm.chainman.Status()
+
+ return newPeer(pv, nv, genesis, current, td, p, rw)
+}
+
+func (pm *ProtocolManager) handle(p *peer) error {
+ if err := p.handleStatus(); err != nil {
+ return err
+ }
+ pm.pmu.Lock()
+ pm.peers[p.id] = p
+ pm.pmu.Unlock()
+
+ pm.downloader.RegisterPeer(p.id, p.td, p.currentHash, p.requestHashes, p.requestBlocks)
+ defer func() {
+ pm.pmu.Lock()
+ defer pm.pmu.Unlock()
+ delete(pm.peers, p.id)
+ pm.downloader.UnregisterPeer(p.id)
+ }()
+
+ // propagate existing transactions. new transactions appearing
+ // after this will be sent via broadcasts.
+ if err := p.sendTransactions(pm.txpool.GetTransactions()); err != nil {
+ return err
+ }
+
+ // main loop. handle incoming messages.
+ for {
+ if err := pm.handleMsg(p); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func (self *ProtocolManager) handleMsg(p *peer) error {
+ msg, err := p.rw.ReadMsg()
+ if err != nil {
+ return err
+ }
+ if msg.Size > ProtocolMaxMsgSize {
+ return errResp(ErrMsgTooLarge, "%v > %v", msg.Size, ProtocolMaxMsgSize)
+ }
+ // make sure that the payload has been fully consumed
+ defer msg.Discard()
+
+ switch msg.Code {
+ case GetTxMsg: // ignore
+ case StatusMsg:
+ return errResp(ErrExtraStatusMsg, "uncontrolled status message")
+
+ case TxMsg:
+ // TODO: rework using lazy RLP stream
+ var txs []*types.Transaction
+ if err := msg.Decode(&txs); err != nil {
+ return errResp(ErrDecode, "msg %v: %v", msg, err)
+ }
+ for i, tx := range txs {
+ if tx == nil {
+ return errResp(ErrDecode, "transaction %d is nil", i)
+ }
+ jsonlogger.LogJson(&logger.EthTxReceived{
+ TxHash: tx.Hash().Hex(),
+ RemoteId: p.ID().String(),
+ })
+ }
+ self.txpool.AddTransactions(txs)
+
+ case GetBlockHashesMsg:
+ var request getBlockHashesMsgData
+ if err := msg.Decode(&request); err != nil {
+ return errResp(ErrDecode, "->msg %v: %v", msg, err)
+ }
+
+ if request.Amount > maxHashes {
+ request.Amount = maxHashes
+ }
+
+ hashes := self.chainman.GetBlockHashesFromHash(request.Hash, request.Amount)
+
+ if glog.V(logger.Debug) {
+ if len(hashes) == 0 {
+ glog.Infof("invalid block hash %x", request.Hash.Bytes()[:4])
+ }
+ }
+
+ // returns either requested hashes or nothing (i.e. not found)
+ return p.sendBlockHashes(hashes)
+ case BlockHashesMsg:
+ msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
+
+ var hashes []common.Hash
+ if err := msgStream.Decode(&hashes); err != nil {
+ break
+ }
+ err := self.downloader.AddHashes(p.id, hashes)
+ if err != nil {
+ glog.V(logger.Debug).Infoln(err)
+ }
+
+ case GetBlocksMsg:
+ var blocks []*types.Block
+
+ msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
+ if _, err := msgStream.List(); err != nil {
+ return err
+ }
+ var i int
+ for {
+ i++
+ var hash common.Hash
+ err := msgStream.Decode(&hash)
+ if err == rlp.EOL {
+ break
+ } else if err != nil {
+ return errResp(ErrDecode, "msg %v: %v", msg, err)
+ }
+
+ block := self.chainman.GetBlock(hash)
+ if block != nil {
+ blocks = append(blocks, block)
+ }
+ if i == maxBlocks {
+ break
+ }
+ }
+ return p.sendBlocks(blocks)
+ case BlocksMsg:
+ var blocks []*types.Block
+
+ msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
+ if err := msgStream.Decode(&blocks); err != nil {
+ glog.V(logger.Detail).Infoln("Decode error", err)
+ blocks = nil
+ }
+ self.downloader.DeliverChunk(p.id, blocks)
+
+ case NewBlockMsg:
+ var request newBlockMsgData
+ if err := msg.Decode(&request); err != nil {
+ return errResp(ErrDecode, "%v: %v", msg, err)
+ }
+ if err := request.Block.ValidateFields(); err != nil {
+ return errResp(ErrDecode, "block validation %v: %v", msg, err)
+ }
+ hash := request.Block.Hash()
+ // Add the block hash as a known hash to the peer. This will later be used to detirmine
+ // who should receive this.
+ p.blockHashes.Add(hash)
+
+ _, chainHead, _ := self.chainman.Status()
+
+ jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{
+ BlockHash: hash.Hex(),
+ BlockNumber: request.Block.Number(), // this surely must be zero
+ ChainHeadHash: chainHead.Hex(),
+ BlockPrevHash: request.Block.ParentHash().Hex(),
+ RemoteId: p.ID().String(),
+ })
+
+ // Make sure the block isn't already known. If this is the case simply drop
+ // the message and move on. If the TD is < currentTd; drop it as well. If this
+ // chain at some point becomes canonical, the downloader will fetch it.
+ if self.chainman.HasBlock(hash) {
+ break
+ }
+ /* XXX unsure about this */
+ if self.chainman.Td().Cmp(request.TD) > 0 && new(big.Int).Add(request.Block.Number(), big.NewInt(7)).Cmp(self.chainman.CurrentBlock().Number()) < 0 {
+ glog.V(logger.Debug).Infof("[%s] dropped block %v due to low TD %v\n", p.id, request.Block.Number(), request.TD)
+ break
+ }
+
+ // Attempt to insert the newly received by checking if the parent exists.
+ // if the parent exists we process the block and propagate to our peers
+ // if the parent does not exists we delegate to the downloader.
+ // NOTE we can reduce chatter by dropping blocks with Td < currentTd
+ if self.chainman.HasBlock(request.Block.ParentHash()) {
+ if err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
+ // handle error
+ return nil
+ }
+ self.BroadcastBlock(hash, request.Block)
+ //fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
+ } else {
+ // adding blocks is synchronous
+ go func() {
+ err := self.downloader.AddBlock(p.id, request.Block, request.TD)
+ if err != nil {
+ glog.V(logger.Detail).Infoln("downloader err:", err)
+ return
+ }
+ self.BroadcastBlock(hash, request.Block)
+ //fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
+ }()
+ }
+ default:
+ return errResp(ErrInvalidMsgCode, "%v", msg.Code)
+ }
+ return nil
+}
+
+// BroadcastBlock will propagate the block to its connected peers. It will sort
+// out which peers do not contain the block in their block set and will do a
+// sqrt(peers) to determine the amount of peers we broadcast to.
+func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block) {
+ pm.pmu.Lock()
+ defer pm.pmu.Unlock()
+
+ // Find peers who don't know anything about the given hash. Peers that
+ // don't know about the hash will be a candidate for the broadcast loop
+ var peers []*peer
+ for _, peer := range pm.peers {
+ if !peer.blockHashes.Has(hash) {
+ peers = append(peers, peer)
+ }
+ }
+ // Broadcast block to peer set
+ // XXX due to the current shit state of the network disable the limit
+ peers = peers[:int(math.Sqrt(float64(len(peers))))]
+ for _, peer := range peers {
+ peer.sendNewBlock(block)
+ }
+ glog.V(logger.Detail).Infoln("broadcast block to", len(peers), "peers")
+}
diff --git a/eth/peer.go b/eth/peer.go
new file mode 100644
index 000000000..972880845
--- /dev/null
+++ b/eth/peer.go
@@ -0,0 +1,145 @@
+package eth
+
+import (
+ "fmt"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/p2p"
+ "gopkg.in/fatih/set.v0"
+)
+
+type statusMsgData struct {
+ ProtocolVersion uint32
+ NetworkId uint32
+ TD *big.Int
+ CurrentBlock common.Hash
+ GenesisBlock common.Hash
+}
+
+type getBlockHashesMsgData struct {
+ Hash common.Hash
+ Amount uint64
+}
+
+type peer struct {
+ *p2p.Peer
+
+ rw p2p.MsgReadWriter
+
+ protv, netid int
+
+ currentHash common.Hash
+ id string
+ td *big.Int
+
+ genesis, ourHash common.Hash
+ ourTd *big.Int
+
+ txHashes *set.Set
+ blockHashes *set.Set
+}
+
+func newPeer(protv, netid int, genesis, currentHash common.Hash, td *big.Int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer {
+ id := p.ID()
+
+ return &peer{
+ Peer: p,
+ rw: rw,
+ genesis: genesis,
+ ourHash: currentHash,
+ ourTd: td,
+ protv: protv,
+ netid: netid,
+ id: fmt.Sprintf("%x", id[:8]),
+ txHashes: set.New(),
+ blockHashes: set.New(),
+ }
+}
+
+// sendTransactions sends transactions to the peer and includes the hashes
+// in it's tx hash set for future reference. The tx hash will allow the
+// manager to check whether the peer has already received this particular
+// transaction
+func (p *peer) sendTransactions(txs types.Transactions) error {
+ for _, tx := range txs {
+ p.txHashes.Add(tx.Hash())
+ }
+
+ return p2p.Send(p.rw, TxMsg, txs)
+}
+
+func (p *peer) sendBlockHashes(hashes []common.Hash) error {
+ return p2p.Send(p.rw, BlockHashesMsg, hashes)
+}
+
+func (p *peer) sendBlocks(blocks []*types.Block) error {
+ return p2p.Send(p.rw, BlocksMsg, blocks)
+}
+
+func (p *peer) sendNewBlock(block *types.Block) error {
+ p.blockHashes.Add(block.Hash())
+
+ return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, block.Td})
+}
+
+func (p *peer) requestHashes(from common.Hash) error {
+ glog.V(logger.Debug).Infof("[%s] fetching hashes (%d) %x...\n", p.id, maxHashes, from[:4])
+ return p2p.Send(p.rw, GetBlockHashesMsg, getBlockHashesMsgData{from, maxHashes})
+}
+
+func (p *peer) requestBlocks(hashes []common.Hash) error {
+ glog.V(logger.Debug).Infof("[%s] fetching %v blocks\n", p.id, len(hashes))
+ return p2p.Send(p.rw, GetBlocksMsg, hashes)
+}
+
+func (p *peer) handleStatus() error {
+ errc := make(chan error, 1)
+ go func() {
+ errc <- p2p.Send(p.rw, StatusMsg, &statusMsgData{
+ ProtocolVersion: uint32(p.protv),
+ NetworkId: uint32(p.netid),
+ TD: p.ourTd,
+ CurrentBlock: p.ourHash,
+ GenesisBlock: p.genesis,
+ })
+ }()
+
+ // read and handle remote status
+ msg, err := p.rw.ReadMsg()
+ if err != nil {
+ return err
+ }
+ if msg.Code != StatusMsg {
+ return errResp(ErrNoStatusMsg, "first msg has code %x (!= %x)", msg.Code, StatusMsg)
+ }
+ if msg.Size > ProtocolMaxMsgSize {
+ return errResp(ErrMsgTooLarge, "%v > %v", msg.Size, ProtocolMaxMsgSize)
+ }
+
+ var status statusMsgData
+ if err := msg.Decode(&status); err != nil {
+ return errResp(ErrDecode, "msg %v: %v", msg, err)
+ }
+
+ if status.GenesisBlock != p.genesis {
+ return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock, p.genesis)
+ }
+
+ if int(status.NetworkId) != p.netid {
+ return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, p.netid)
+ }
+
+ if int(status.ProtocolVersion) != p.protv {
+ return errResp(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, p.protv)
+ }
+ // Set the total difficulty of the peer
+ p.td = status.TD
+ // set the best hash of the peer
+ p.currentHash = status.CurrentBlock
+
+ return <-errc
+}
diff --git a/eth/protocol.go b/eth/protocol.go
index 1a19307db..48f37b59c 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -1,16 +1,10 @@
package eth
import (
- "fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/errs"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/rlp"
)
const (
@@ -18,8 +12,8 @@ const (
NetworkId = 0
ProtocolLength = uint64(8)
ProtocolMaxMsgSize = 10 * 1024 * 1024
- maxHashes = 256
- maxBlocks = 64
+ maxHashes = 512
+ maxBlocks = 128
)
// eth protocol message codes
@@ -34,6 +28,8 @@ const (
NewBlockMsg
)
+type errCode int
+
const (
ErrMsgTooLarge = iota
ErrDecode
@@ -46,6 +42,11 @@ const (
ErrSuspendedPeer
)
+func (e errCode) String() string {
+ return errorToString[int(e)]
+}
+
+// XXX change once legacy code is out
var errorToString = map[int]string{
ErrMsgTooLarge: "Message too long",
ErrDecode: "Invalid message",
@@ -58,20 +59,6 @@ var errorToString = map[int]string{
ErrSuspendedPeer: "Suspended peer",
}
-// ethProtocol represents the ethereum wire protocol
-// instance is running on each peer
-type ethProtocol struct {
- txPool txPool
- chainManager chainManager
- blockPool blockPool
- peer *p2p.Peer
- id string
- rw p2p.MsgReadWriter
- errors *errs.Errors
- protocolVersion int
- networkId int
-}
-
// backend is the interface the ethereum protocol backend should implement
// used as an argument to EthProtocol
type txPool interface {
@@ -85,308 +72,8 @@ type chainManager interface {
Status() (td *big.Int, currentBlock common.Hash, genesisBlock common.Hash)
}
-type blockPool interface {
- AddBlockHashes(next func() (common.Hash, bool), peerId string)
- AddBlock(block *types.Block, peerId string)
- AddPeer(td *big.Int, currentBlock common.Hash, peerId string, requestHashes func(common.Hash) error, requestBlocks func([]common.Hash) error, peerError func(*errs.Error)) (best bool, suspended bool)
- RemovePeer(peerId string)
-}
-
// message structs used for RLP serialization
type newBlockMsgData struct {
Block *types.Block
TD *big.Int
}
-
-type getBlockHashesMsgData struct {
- Hash common.Hash
- Amount uint64
-}
-
-type statusMsgData struct {
- ProtocolVersion uint32
- NetworkId uint32
- TD *big.Int
- CurrentBlock common.Hash
- GenesisBlock common.Hash
-}
-
-// main entrypoint, wrappers starting a server running the eth protocol
-// use this constructor to attach the protocol ("class") to server caps
-// the Dev p2p layer then runs the protocol instance on each peer
-func EthProtocol(protocolVersion, networkId int, txPool txPool, chainManager chainManager, blockPool blockPool) p2p.Protocol {
- return p2p.Protocol{
- Name: "eth",
- Version: uint(protocolVersion),
- Length: ProtocolLength,
- Run: func(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
- return runEthProtocol(protocolVersion, networkId, txPool, chainManager, blockPool, peer, rw)
- },
- }
-}
-
-// the main loop that handles incoming messages
-// note RemovePeer in the post-disconnect hook
-func runEthProtocol(protocolVersion, networkId int, txPool txPool, chainManager chainManager, blockPool blockPool, peer *p2p.Peer, rw p2p.MsgReadWriter) (err error) {
- id := peer.ID()
- self := &ethProtocol{
- txPool: txPool,
- chainManager: chainManager,
- blockPool: blockPool,
- rw: rw,
- peer: peer,
- protocolVersion: protocolVersion,
- networkId: networkId,
- errors: &errs.Errors{
- Package: "ETH",
- Errors: errorToString,
- },
- id: fmt.Sprintf("%x", id[:8]),
- }
-
- // handshake.
- if err := self.handleStatus(); err != nil {
- return err
- }
- defer self.blockPool.RemovePeer(self.id)
-
- // propagate existing transactions. new transactions appearing
- // after this will be sent via broadcasts.
- if err := p2p.Send(rw, TxMsg, txPool.GetTransactions()); err != nil {
- return err
- }
-
- // main loop. handle incoming messages.
- for {
- if err := self.handle(); err != nil {
- return err
- }
- }
-}
-
-func (self *ethProtocol) handle() error {
- msg, err := self.rw.ReadMsg()
- if err != nil {
- return err
- }
- if msg.Size > ProtocolMaxMsgSize {
- return self.protoError(ErrMsgTooLarge, "%v > %v", msg.Size, ProtocolMaxMsgSize)
- }
- // make sure that the payload has been fully consumed
- defer msg.Discard()
-
- switch msg.Code {
- case GetTxMsg: // ignore
- case StatusMsg:
- return self.protoError(ErrExtraStatusMsg, "")
-
- case TxMsg:
- // TODO: rework using lazy RLP stream
- var txs []*types.Transaction
- if err := msg.Decode(&txs); err != nil {
- return self.protoError(ErrDecode, "msg %v: %v", msg, err)
- }
- for i, tx := range txs {
- if tx == nil {
- return self.protoError(ErrDecode, "transaction %d is nil", i)
- }
- jsonlogger.LogJson(&logger.EthTxReceived{
- TxHash: tx.Hash().Hex(),
- RemoteId: self.peer.ID().String(),
- })
- }
- self.txPool.AddTransactions(txs)
-
- case GetBlockHashesMsg:
- var request getBlockHashesMsgData
- if err := msg.Decode(&request); err != nil {
- return self.protoError(ErrDecode, "->msg %v: %v", msg, err)
- }
-
- if request.Amount > maxHashes {
- request.Amount = maxHashes
- }
- hashes := self.chainManager.GetBlockHashesFromHash(request.Hash, request.Amount)
- return p2p.Send(self.rw, BlockHashesMsg, hashes)
-
- case BlockHashesMsg:
- msgStream := rlp.NewStream(msg.Payload)
- if _, err := msgStream.List(); err != nil {
- return err
- }
-
- var i int
- iter := func() (hash common.Hash, ok bool) {
- err := msgStream.Decode(&hash)
- if err == rlp.EOL {
- return common.Hash{}, false
- } else if err != nil {
- self.protoError(ErrDecode, "msg %v: after %v hashes : %v", msg, i, err)
- return common.Hash{}, false
- }
-
- i++
- return hash, true
- }
- self.blockPool.AddBlockHashes(iter, self.id)
-
- case GetBlocksMsg:
- msgStream := rlp.NewStream(msg.Payload)
- if _, err := msgStream.List(); err != nil {
- return err
- }
-
- var blocks []*types.Block
- var i int
- for {
- i++
- var hash common.Hash
- err := msgStream.Decode(&hash)
- if err == rlp.EOL {
- break
- } else if err != nil {
- return self.protoError(ErrDecode, "msg %v: %v", msg, err)
- }
-
- block := self.chainManager.GetBlock(hash)
- if block != nil {
- blocks = append(blocks, block)
- }
- if i == maxBlocks {
- break
- }
- }
- return p2p.Send(self.rw, BlocksMsg, blocks)
-
- case BlocksMsg:
- msgStream := rlp.NewStream(msg.Payload)
- if _, err := msgStream.List(); err != nil {
- return err
- }
- for {
- var block types.Block
- if err := msgStream.Decode(&block); err != nil {
- if err == rlp.EOL {
- break
- } else {
- return self.protoError(ErrDecode, "msg %v: %v", msg, err)
- }
- }
- if err := block.ValidateFields(); err != nil {
- return self.protoError(ErrDecode, "block validation %v: %v", msg, err)
- }
- self.blockPool.AddBlock(&block, self.id)
- }
-
- case NewBlockMsg:
- var request newBlockMsgData
- if err := msg.Decode(&request); err != nil {
- return self.protoError(ErrDecode, "%v: %v", msg, err)
- }
- if err := request.Block.ValidateFields(); err != nil {
- return self.protoError(ErrDecode, "block validation %v: %v", msg, err)
- }
- hash := request.Block.Hash()
- _, chainHead, _ := self.chainManager.Status()
-
- jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{
- BlockHash: hash.Hex(),
- BlockNumber: request.Block.Number(), // this surely must be zero
- ChainHeadHash: chainHead.Hex(),
- BlockPrevHash: request.Block.ParentHash().Hex(),
- RemoteId: self.peer.ID().String(),
- })
- // to simplify backend interface adding a new block
- // uses AddPeer followed by AddBlock only if peer is the best peer
- // (or selected as new best peer)
- if _, suspended := self.blockPool.AddPeer(request.TD, hash, self.id, self.requestBlockHashes, self.requestBlocks, self.protoErrorDisconnect); !suspended {
- self.blockPool.AddBlock(request.Block, self.id)
- }
-
- default:
- return self.protoError(ErrInvalidMsgCode, "%v", msg.Code)
- }
- return nil
-}
-
-func (self *ethProtocol) handleStatus() error {
- if err := self.sendStatus(); err != nil {
- return err
- }
-
- // read and handle remote status
- msg, err := self.rw.ReadMsg()
- if err != nil {
- return err
- }
- if msg.Code != StatusMsg {
- return self.protoError(ErrNoStatusMsg, "first msg has code %x (!= %x)", msg.Code, StatusMsg)
- }
- if msg.Size > ProtocolMaxMsgSize {
- return self.protoError(ErrMsgTooLarge, "%v > %v", msg.Size, ProtocolMaxMsgSize)
- }
-
- var status statusMsgData
- if err := msg.Decode(&status); err != nil {
- return self.protoError(ErrDecode, "msg %v: %v", msg, err)
- }
-
- _, _, genesisBlock := self.chainManager.Status()
-
- if status.GenesisBlock != genesisBlock {
- return self.protoError(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock, genesisBlock)
- }
-
- if int(status.NetworkId) != self.networkId {
- return self.protoError(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, self.networkId)
- }
-
- if int(status.ProtocolVersion) != self.protocolVersion {
- return self.protoError(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, self.protocolVersion)
- }
-
- _, suspended := self.blockPool.AddPeer(status.TD, status.CurrentBlock, self.id, self.requestBlockHashes, self.requestBlocks, self.protoErrorDisconnect)
- if suspended {
- return self.protoError(ErrSuspendedPeer, "")
- }
-
- self.peer.Debugf("Peer is [eth] capable (%d/%d). TD=%v H=%x\n", status.ProtocolVersion, status.NetworkId, status.TD, status.CurrentBlock[:4])
-
- return nil
-}
-
-func (self *ethProtocol) requestBlockHashes(from common.Hash) error {
- self.peer.Debugf("fetching hashes (%d) %x...\n", maxHashes, from[0:4])
- return p2p.Send(self.rw, GetBlockHashesMsg, getBlockHashesMsgData{from, maxHashes})
-}
-
-func (self *ethProtocol) requestBlocks(hashes []common.Hash) error {
- self.peer.Debugf("fetching %v blocks", len(hashes))
- return p2p.Send(self.rw, GetBlocksMsg, hashes)
-}
-
-func (self *ethProtocol) protoError(code int, format string, params ...interface{}) (err *errs.Error) {
- err = self.errors.New(code, format, params...)
- //err.Log(self.peer.Logger)
- err.Log(glog.V(logger.Info))
- return
-}
-
-func (self *ethProtocol) sendStatus() error {
- td, currentBlock, genesisBlock := self.chainManager.Status()
- return p2p.Send(self.rw, StatusMsg, &statusMsgData{
- ProtocolVersion: uint32(self.protocolVersion),
- NetworkId: uint32(self.networkId),
- TD: td,
- CurrentBlock: currentBlock,
- GenesisBlock: genesisBlock,
- })
-}
-
-func (self *ethProtocol) protoErrorDisconnect(err *errs.Error) {
- err.Log(glog.V(logger.Info))
- if err.Fatal() {
- self.peer.Disconnect(p2p.DiscSubprotocolError)
- }
-
-}
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index 7c724f7a7..d44f66b89 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -1,20 +1,7 @@
package eth
-import (
- "log"
- "math/big"
- "os"
- "testing"
- "time"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/errs"
- ethlogger "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
-)
+/*
+TODO All of these tests need to be re-written
var logsys = ethlogger.NewStdLogSystem(os.Stdout, log.LstdFlags, ethlogger.LogLevel(ethlogger.DebugDetailLevel))
@@ -398,3 +385,4 @@ func TestTransactionsMsg(t *testing.T) {
eth.checkError(ErrDecode, delay)
}
+*/
diff --git a/miner/miner.go b/miner/miner.go
index a14a195d2..883956370 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -16,9 +16,10 @@ type Miner struct {
MinAcceptedGasPrice *big.Int
- mining bool
- eth core.Backend
- pow pow.PoW
+ threads int
+ mining bool
+ eth core.Backend
+ pow pow.PoW
}
func New(eth core.Backend, pow pow.PoW, minerThreads int) *Miner {
@@ -28,6 +29,7 @@ func New(eth core.Backend, pow pow.PoW, minerThreads int) *Miner {
for i := 0; i < minerThreads; i++ {
miner.worker.register(NewCpuMiner(i, pow))
}
+ miner.threads = minerThreads
return miner
}
@@ -40,7 +42,9 @@ func (self *Miner) Start(coinbase common.Address) {
self.mining = true
self.worker.coinbase = coinbase
- self.pow.(*ethash.Ethash).UpdateDAG()
+ if self.threads > 0 {
+ self.pow.(*ethash.Ethash).UpdateDAG()
+ }
self.worker.start()
diff --git a/miner/remote_agent.go b/miner/remote_agent.go
index aa04a58aa..87456cfec 100644
--- a/miner/remote_agent.go
+++ b/miner/remote_agent.go
@@ -1,6 +1,8 @@
package miner
import (
+ "math/big"
+
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@@ -50,7 +52,6 @@ out:
break out
case work := <-a.workCh:
a.work = work
- a.returnCh <- nil
}
}
}
@@ -58,12 +59,18 @@ out:
func (a *RemoteAgent) GetWork() [3]string {
var res [3]string
- // XXX Wait here until work != nil ?
if a.work != nil {
+ a.currentWork = a.work
+
res[0] = a.work.HashNoNonce().Hex()
seedHash, _ := ethash.GetSeedHash(a.currentWork.NumberU64())
res[1] = common.Bytes2Hex(seedHash)
- res[2] = common.Bytes2Hex(a.work.Difficulty().Bytes())
+ // Calculate the "target" to be returned to the external miner
+ n := big.NewInt(1)
+ n.Lsh(n, 255)
+ n.Div(n, a.work.Difficulty())
+ n.Lsh(n, 1)
+ res[2] = common.Bytes2Hex(n.Bytes())
}
return res
diff --git a/miner/worker.go b/miner/worker.go
index 9fb248efa..63645cd54 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -6,7 +6,6 @@ import (
"sort"
"sync"
"sync/atomic"
- "time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
@@ -151,8 +150,6 @@ func (self *worker) register(agent Agent) {
func (self *worker) update() {
events := self.mux.Subscribe(core.ChainHeadEvent{}, core.ChainSideEvent{}, core.TxPreEvent{})
- timer := time.NewTicker(2 * time.Second)
-
out:
for {
select {
@@ -171,15 +168,6 @@ out:
}
case <-self.quit:
break out
- case <-timer.C:
- if glog.V(logger.Detail) && atomic.LoadInt64(&self.mining) == 1 {
- glog.Infoln("Hash rate:", self.HashRate(), "Khash")
- }
-
- // XXX In case all mined a possible uncle
- if atomic.LoadInt64(&self.atWork) == 0 && atomic.LoadInt64(&self.mining) == 1 {
- self.commitNewWork()
- }
}
}
@@ -201,7 +189,7 @@ func (self *worker) wait() {
}
self.mux.Post(core.NewMinedBlockEvent{block})
- glog.V(logger.Info).Infof("🔨 Mined block #%v", block.Number())
+ glog.V(logger.Info).Infof("🔨 Mined block #%v", block.Number())
jsonlogger.LogJson(&logger.EthMinerNewBlock{
BlockHash: block.Hash().Hex(),
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 61a0abed9..07a1a739c 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -413,7 +413,7 @@ func decodePacket(buf []byte) (packet, NodeID, []byte, error) {
default:
return nil, fromID, hash, fmt.Errorf("unknown type: %d", ptype)
}
- err = rlp.Decode(bytes.NewReader(sigdata[1:]), req)
+ err = rlp.DecodeBytes(sigdata[1:], req)
return req, fromID, hash, err
}
diff --git a/p2p/message.go b/p2p/message.go
index b42acbe3c..be6405d6f 100644
--- a/p2p/message.go
+++ b/p2p/message.go
@@ -32,7 +32,8 @@ type Msg struct {
//
// For the decoding rules, please see package rlp.
func (msg Msg) Decode(val interface{}) error {
- if err := rlp.Decode(msg.Payload, val); err != nil {
+ s := rlp.NewStream(msg.Payload, uint64(msg.Size))
+ if err := s.Decode(val); err != nil {
return newPeerError(errInvalidMsg, "(code %x) (size %d) %v", msg.Code, msg.Size, err)
}
return nil
diff --git a/p2p/peer_error.go b/p2p/peer_error.go
index 402131630..a912f6064 100644
--- a/p2p/peer_error.go
+++ b/p2p/peer_error.go
@@ -57,7 +57,7 @@ func (self *peerError) Error() string {
return self.message
}
-type DiscReason byte
+type DiscReason uint
const (
DiscRequested DiscReason = iota
diff --git a/p2p/server.go b/p2p/server.go
index eaffc9d13..b5c4a1f59 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -359,9 +359,11 @@ func (srv *Server) dialLoop() {
rand.Read(target[:])
findresults <- srv.ntab.Lookup(target)
}()
- refresh.Stop()
+ } else {
+ // Make sure we check again if the peer count falls
+ // below MaxPeers.
+ refresh.Reset(refreshPeersInterval)
}
-
case dest := <-srv.peerConnect:
dial(dest)
case dests := <-findresults:
@@ -371,7 +373,10 @@ func (srv *Server) dialLoop() {
refresh.Reset(refreshPeersInterval)
case dest := <-dialed:
delete(dialing, dest.ID)
-
+ if len(dialing) == 0 {
+ // Check again immediately after dialing all current candidates.
+ refresh.Reset(0)
+ }
case <-srv.quit:
// TODO: maybe wait for active dials
return
diff --git a/rlp/decode.go b/rlp/decode.go
index 3b5617475..6952ecaea 100644
--- a/rlp/decode.go
+++ b/rlp/decode.go
@@ -9,6 +9,7 @@ import (
"io"
"math/big"
"reflect"
+ "strings"
)
var (
@@ -35,25 +36,35 @@ type Decoder interface {
// If the type implements the Decoder interface, decode calls
// DecodeRLP.
//
-// To decode into a pointer, Decode will set the pointer to nil if the
-// input has size zero or the input is a single byte with value zero.
-// If the input has nonzero size, Decode will allocate a new value of
-// the type being pointed to.
+// To decode into a pointer, Decode will decode into the value pointed
+// to. If the pointer is nil, a new value of the pointer's element
+// type is allocated. If the pointer is non-nil, the existing value
+// will reused.
//
// To decode into a struct, Decode expects the input to be an RLP
// list. The decoded elements of the list are assigned to each public
-// field in the order given by the struct's definition. If the input
-// list has too few elements, no error is returned and the remaining
-// fields will have the zero value.
-// Recursive struct types are supported.
+// field in the order given by the struct's definition. The input list
+// must contain an element for each decoded field. Decode returns an
+// error if there are too few or too many elements.
+//
+// The decoding of struct fields honours one particular struct tag,
+// "nil". This tag applies to pointer-typed fields and changes the
+// decoding rules for the field such that input values of size zero
+// decode as a nil pointer. This tag can be useful when decoding recursive
+// types.
+//
+// type StructWithEmptyOK struct {
+// Foo *[20]byte `rlp:"nil"`
+// }
//
// To decode into a slice, the input must be a list and the resulting
-// slice will contain the input elements in order.
-// As a special case, if the slice has a byte-size element type, the input
-// can also be an RLP string.
+// slice will contain the input elements in order. For byte slices,
+// the input must be an RLP string. Array types decode similarly, with
+// the additional restriction that the number of input elements (or
+// bytes) must match the array's length.
//
// To decode into a Go string, the input must be an RLP string. The
-// bytes are taken as-is and will not necessarily be valid UTF-8.
+// input bytes are taken as-is and will not necessarily be valid UTF-8.
//
// To decode into an unsigned integer type, the input must also be an RLP
// string. The bytes are interpreted as a big endian representation of
@@ -64,20 +75,28 @@ type Decoder interface {
// To decode into an interface value, Decode stores one of these
// in the value:
//
-// []interface{}, for RLP lists
-// []byte, for RLP strings
+// []interface{}, for RLP lists
+// []byte, for RLP strings
//
// Non-empty interface types are not supported, nor are booleans,
// signed integers, floating point numbers, maps, channels and
// functions.
+//
+// Note that Decode does not set an input limit for all readers
+// and may be vulnerable to panics cause by huge value sizes. If
+// you need an input limit, use
+//
+// NewStream(r, limit).Decode(val)
func Decode(r io.Reader, val interface{}) error {
- return NewStream(r).Decode(val)
+ // TODO: this could use a Stream from a pool.
+ return NewStream(r, 0).Decode(val)
}
// DecodeBytes parses RLP data from b into val.
// Please see the documentation of Decode for the decoding rules.
func DecodeBytes(b []byte, val interface{}) error {
- return NewStream(bytes.NewReader(b)).Decode(val)
+ // TODO: this could use a Stream from a pool.
+ return NewStream(bytes.NewReader(b), uint64(len(b))).Decode(val)
}
type decodeError struct {
@@ -100,7 +119,9 @@ func (err *decodeError) Error() string {
func wrapStreamError(err error, typ reflect.Type) error {
switch err {
case ErrCanonInt:
- return &decodeError{msg: "canon int error appends zero's", typ: typ}
+ return &decodeError{msg: "non-canonical integer (leading zero bytes)", typ: typ}
+ case ErrCanonSize:
+ return &decodeError{msg: "non-canonical size information", typ: typ}
case ErrExpectedList:
return &decodeError{msg: "expected input list", typ: typ}
case ErrExpectedString:
@@ -125,7 +146,7 @@ var (
bigInt = reflect.TypeOf(big.Int{})
)
-func makeDecoder(typ reflect.Type) (dec decoder, err error) {
+func makeDecoder(typ reflect.Type, tags tags) (dec decoder, err error) {
kind := typ.Kind()
switch {
case typ.Implements(decoderInterface):
@@ -145,6 +166,9 @@ func makeDecoder(typ reflect.Type) (dec decoder, err error) {
case kind == reflect.Struct:
return makeStructDecoder(typ)
case kind == reflect.Ptr:
+ if tags.nilOK {
+ return makeOptionalPtrDecoder(typ)
+ }
return makePtrDecoder(typ)
case kind == reflect.Interface:
return decodeInterface, nil
@@ -186,12 +210,10 @@ func decodeBigInt(s *Stream, val reflect.Value) error {
i = new(big.Int)
val.Set(reflect.ValueOf(i))
}
-
- // Reject big integers which are zero appended
+ // Reject leading zero bytes
if len(b) > 0 && b[0] == 0 {
return wrapStreamError(ErrCanonInt, val.Type())
}
-
i.SetBytes(b)
return nil
}
@@ -205,7 +227,7 @@ func makeListDecoder(typ reflect.Type) (decoder, error) {
return decodeByteSlice, nil
}
}
- etypeinfo, err := cachedTypeInfo1(etype)
+ etypeinfo, err := cachedTypeInfo1(etype, tags{})
if err != nil {
return nil, err
}
@@ -259,19 +281,10 @@ func decodeListSlice(s *Stream, val reflect.Value, elemdec decoder) error {
}
func decodeListArray(s *Stream, val reflect.Value, elemdec decoder) error {
- size, err := s.List()
+ _, err := s.List()
if err != nil {
- return err
- }
- if size == 0 {
- zero(val, 0)
- return s.ListEnd()
+ return wrapStreamError(err, val.Type())
}
-
- // The approach here is stolen from package json, although we differ
- // in the semantics for arrays. package json discards remaining
- // elements that would not fit into the array. We generate an error in
- // this case because we'd be losing information.
vlen := val.Len()
i := 0
for ; i < vlen; i++ {
@@ -282,24 +295,18 @@ func decodeListArray(s *Stream, val reflect.Value, elemdec decoder) error {
}
}
if i < vlen {
- zero(val, i)
+ return &decodeError{msg: "input list has too few elements", typ: val.Type()}
}
return wrapStreamError(s.ListEnd(), val.Type())
}
func decodeByteSlice(s *Stream, val reflect.Value) error {
- kind, _, err := s.Kind()
- if err != nil {
- return err
- }
- if kind == List {
- return decodeListSlice(s, val, decodeUint)
- }
b, err := s.Bytes()
- if err == nil {
- val.SetBytes(b)
+ if err != nil {
+ return wrapStreamError(err, val.Type())
}
- return err
+ val.SetBytes(b)
+ return nil
}
func decodeByteArray(s *Stream, val reflect.Value) error {
@@ -307,42 +314,38 @@ func decodeByteArray(s *Stream, val reflect.Value) error {
if err != nil {
return err
}
+ vlen := val.Len()
switch kind {
case Byte:
- if val.Len() == 0 {
+ if vlen == 0 {
return &decodeError{msg: "input string too long", typ: val.Type()}
}
+ if vlen > 1 {
+ return &decodeError{msg: "input string too short", typ: val.Type()}
+ }
bv, _ := s.Uint()
val.Index(0).SetUint(bv)
- zero(val, 1)
case String:
- if uint64(val.Len()) < size {
+ if uint64(vlen) < size {
return &decodeError{msg: "input string too long", typ: val.Type()}
}
- slice := val.Slice(0, int(size)).Interface().([]byte)
+ if uint64(vlen) > size {
+ return &decodeError{msg: "input string too short", typ: val.Type()}
+ }
+ slice := val.Slice(0, vlen).Interface().([]byte)
if err := s.readFull(slice); err != nil {
return err
}
- zero(val, int(size))
+ // Reject cases where single byte encoding should have been used.
+ if size == 1 && slice[0] < 56 {
+ return wrapStreamError(ErrCanonSize, val.Type())
+ }
case List:
- return decodeListArray(s, val, decodeUint)
+ return wrapStreamError(ErrExpectedString, val.Type())
}
return nil
}
-func zero(val reflect.Value, start int) {
- z := reflect.Zero(val.Type().Elem())
- end := val.Len()
- for i := start; i < end; i++ {
- val.Index(i).Set(z)
- }
-}
-
-type field struct {
- index int
- info *typeinfo
-}
-
func makeStructDecoder(typ reflect.Type) (decoder, error) {
fields, err := structFields(typ)
if err != nil {
@@ -355,8 +358,7 @@ func makeStructDecoder(typ reflect.Type) (decoder, error) {
for _, f := range fields {
err = f.info.decoder(s, val.Field(f.index))
if err == EOL {
- // too few elements. leave the rest at their zero value.
- break
+ return &decodeError{msg: "too few elements", typ: typ}
} else if err != nil {
return addErrorContext(err, "."+typ.Field(f.index).Name)
}
@@ -366,15 +368,41 @@ func makeStructDecoder(typ reflect.Type) (decoder, error) {
return dec, nil
}
+// makePtrDecoder creates a decoder that decodes into
+// the pointer's element type.
func makePtrDecoder(typ reflect.Type) (decoder, error) {
etype := typ.Elem()
- etypeinfo, err := cachedTypeInfo1(etype)
+ etypeinfo, err := cachedTypeInfo1(etype, tags{})
if err != nil {
return nil, err
}
dec := func(s *Stream, val reflect.Value) (err error) {
- _, size, err := s.Kind()
- if err != nil || size == 0 && s.byteval == 0 {
+ newval := val
+ if val.IsNil() {
+ newval = reflect.New(etype)
+ }
+ if err = etypeinfo.decoder(s, newval.Elem()); err == nil {
+ val.Set(newval)
+ }
+ return err
+ }
+ return dec, nil
+}
+
+// makeOptionalPtrDecoder creates a decoder that decodes empty values
+// as nil. Non-empty values are decoded into a value of the element type,
+// just like makePtrDecoder does.
+//
+// This decoder is used for pointer-typed struct fields with struct tag "nil".
+func makeOptionalPtrDecoder(typ reflect.Type) (decoder, error) {
+ etype := typ.Elem()
+ etypeinfo, err := cachedTypeInfo1(etype, tags{})
+ if err != nil {
+ return nil, err
+ }
+ dec := func(s *Stream, val reflect.Value) (err error) {
+ kind, size, err := s.Kind()
+ if err != nil || size == 0 && kind != Byte {
// rearm s.Kind. This is important because the input
// position must advance to the next value even though
// we don't read anything.
@@ -465,15 +493,18 @@ var (
// has been reached during streaming.
EOL = errors.New("rlp: end of list")
- // Other errors
+ // Actual Errors
ErrExpectedString = errors.New("rlp: expected String or Byte")
ErrExpectedList = errors.New("rlp: expected List")
- ErrCanonInt = errors.New("rlp: expected Int")
+ ErrCanonInt = errors.New("rlp: non-canonical integer format")
+ ErrCanonSize = errors.New("rlp: non-canonical size information")
ErrElemTooLarge = errors.New("rlp: element is larger than containing list")
+ ErrValueTooLarge = errors.New("rlp: value size exceeds available input length")
// internal errors
- errNotInList = errors.New("rlp: call of ListEnd outside of any list")
- errNotAtEOL = errors.New("rlp: call of ListEnd not positioned at EOL")
+ errNotInList = errors.New("rlp: call of ListEnd outside of any list")
+ errNotAtEOL = errors.New("rlp: call of ListEnd not positioned at EOL")
+ errUintOverflow = errors.New("rlp: uint overflow")
)
// ByteReader must be implemented by any input reader for a Stream. It
@@ -496,23 +527,44 @@ type ByteReader interface {
//
// Stream is not safe for concurrent use.
type Stream struct {
- r ByteReader
+ r ByteReader
+
+ // number of bytes remaining to be read from r.
+ remaining uint64
+ limited bool
+
+ // auxiliary buffer for integer decoding
uintbuf []byte
kind Kind // kind of value ahead
size uint64 // size of value ahead
byteval byte // value of single byte in type tag
+ kinderr error // error from last readKind
stack []listpos
}
type listpos struct{ pos, size uint64 }
-// NewStream creates a new stream reading from r.
-// If r does not implement ByteReader, the Stream will
-// introduce its own buffering.
-func NewStream(r io.Reader) *Stream {
+// NewStream creates a new decoding stream reading from r.
+//
+// If r implements the ByteReader interface, Stream will
+// not introduce any buffering.
+//
+// For non-toplevel values, Stream returns ErrElemTooLarge
+// for values that do not fit into the enclosing list.
+//
+// Stream supports an optional input limit. If a limit is set, the
+// size of any toplevel value will be checked against the remaining
+// input length. Stream operations that encounter a value exceeding
+// the remaining input length will return ErrValueTooLarge. The limit
+// can be set by passing a non-zero value for inputLimit.
+//
+// If r is a bytes.Reader or strings.Reader, the input limit is set to
+// the length of r's underlying data unless an explicit limit is
+// provided.
+func NewStream(r io.Reader, inputLimit uint64) *Stream {
s := new(Stream)
- s.Reset(r)
+ s.Reset(r, inputLimit)
return s
}
@@ -520,7 +572,7 @@ func NewStream(r io.Reader) *Stream {
// at an encoded list of the given length.
func NewListStream(r io.Reader, len uint64) *Stream {
s := new(Stream)
- s.Reset(r)
+ s.Reset(r, len)
s.kind = List
s.size = len
return s
@@ -543,6 +595,9 @@ func (s *Stream) Bytes() ([]byte, error) {
if err = s.readFull(b); err != nil {
return nil, err
}
+ if size == 1 && b[0] < 56 {
+ return nil, ErrCanonSize
+ }
return b, nil
default:
return nil, ErrExpectedString
@@ -574,8 +629,6 @@ func (s *Stream) Raw() ([]byte, error) {
return buf, nil
}
-var errUintOverflow = errors.New("rlp: uint overflow")
-
// Uint reads an RLP string of up to 8 bytes and returns its contents
// as an unsigned integer. If the input does not contain an RLP string, the
// returned error will be ErrExpectedString.
@@ -590,13 +643,27 @@ func (s *Stream) uint(maxbits int) (uint64, error) {
}
switch kind {
case Byte:
+ if s.byteval == 0 {
+ return 0, ErrCanonInt
+ }
s.kind = -1 // rearm Kind
return uint64(s.byteval), nil
case String:
if size > uint64(maxbits/8) {
return 0, errUintOverflow
}
- return s.readUint(byte(size))
+ v, err := s.readUint(byte(size))
+ switch {
+ case err == ErrCanonSize:
+ // Adjust error because we're not reading a size right now.
+ return 0, ErrCanonInt
+ case err != nil:
+ return 0, err
+ case size > 0 && v < 56:
+ return 0, ErrCanonSize
+ default:
+ return v, nil
+ }
default:
return 0, ErrExpectedString
}
@@ -653,7 +720,7 @@ func (s *Stream) Decode(val interface{}) error {
if rval.IsNil() {
return errDecodeIntoNil
}
- info, err := cachedTypeInfo(rtyp.Elem())
+ info, err := cachedTypeInfo(rtyp.Elem(), tags{})
if err != nil {
return err
}
@@ -667,17 +734,40 @@ func (s *Stream) Decode(val interface{}) error {
}
// Reset discards any information about the current decoding context
-// and starts reading from r. If r does not also implement ByteReader,
-// Stream will do its own buffering.
-func (s *Stream) Reset(r io.Reader) {
+// and starts reading from r. This method is meant to facilitate reuse
+// of a preallocated Stream across many decoding operations.
+//
+// If r does not also implement ByteReader, Stream will do its own
+// buffering.
+func (s *Stream) Reset(r io.Reader, inputLimit uint64) {
+ if inputLimit > 0 {
+ s.remaining = inputLimit
+ s.limited = true
+ } else {
+ // Attempt to automatically discover
+ // the limit when reading from a byte slice.
+ switch br := r.(type) {
+ case *bytes.Reader:
+ s.remaining = uint64(br.Len())
+ s.limited = true
+ case *strings.Reader:
+ s.remaining = uint64(br.Len())
+ s.limited = true
+ default:
+ s.limited = false
+ }
+ }
+ // Wrap r with a buffer if it doesn't have one.
bufr, ok := r.(ByteReader)
if !ok {
bufr = bufio.NewReader(r)
}
s.r = bufr
+ // Reset the decoding context.
s.stack = s.stack[:0]
s.size = 0
s.kind = -1
+ s.kinderr = nil
if s.uintbuf == nil {
s.uintbuf = make([]byte, 8)
}
@@ -700,19 +790,31 @@ func (s *Stream) Kind() (kind Kind, size uint64, err error) {
tos = &s.stack[len(s.stack)-1]
}
if s.kind < 0 {
+ s.kinderr = nil
+ // Don't read further if we're at the end of the
+ // innermost list.
if tos != nil && tos.pos == tos.size {
return 0, 0, EOL
}
- kind, size, err = s.readKind()
- if err != nil {
- return 0, 0, err
+ s.kind, s.size, s.kinderr = s.readKind()
+ if s.kinderr == nil {
+ if tos == nil {
+ // At toplevel, check that the value is smaller
+ // than the remaining input length.
+ if s.limited && s.size > s.remaining {
+ s.kinderr = ErrValueTooLarge
+ }
+ } else {
+ // Inside a list, check that the value doesn't overflow the list.
+ if s.size > tos.size-tos.pos {
+ s.kinderr = ErrElemTooLarge
+ }
+ }
}
- s.kind, s.size = kind, size
- }
- if tos != nil && tos.pos+s.size > tos.size {
- return 0, 0, ErrElemTooLarge
}
- return s.kind, s.size, nil
+ // Note: this might return a sticky error generated
+ // by an earlier call to readKind.
+ return s.kind, s.size, s.kinderr
}
func (s *Stream) readKind() (kind Kind, size uint64, err error) {
@@ -741,6 +843,9 @@ func (s *Stream) readKind() (kind Kind, size uint64, err error) {
// would be encoded as 0xB90400 followed by the string. The range of
// the first byte is thus [0xB8, 0xBF].
size, err = s.readUint(b - 0xB7)
+ if err == nil && size < 56 {
+ err = ErrCanonSize
+ }
return String, size, err
case b < 0xF8:
// If the total payload of a list
@@ -757,27 +862,46 @@ func (s *Stream) readKind() (kind Kind, size uint64, err error) {
// the concatenation of the RLP encodings of the items. The
// range of the first byte is thus [0xF8, 0xFF].
size, err = s.readUint(b - 0xF7)
+ if err == nil && size < 56 {
+ err = ErrCanonSize
+ }
return List, size, err
}
}
func (s *Stream) readUint(size byte) (uint64, error) {
- if size == 1 {
+ switch size {
+ case 0:
+ s.kind = -1 // rearm Kind
+ return 0, nil
+ case 1:
b, err := s.readByte()
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return uint64(b), err
+ default:
+ start := int(8 - size)
+ for i := 0; i < start; i++ {
+ s.uintbuf[i] = 0
+ }
+ if err := s.readFull(s.uintbuf[start:]); err != nil {
+ return 0, err
+ }
+ if s.uintbuf[start] == 0 {
+ // Note: readUint is also used to decode integer
+ // values. The error needs to be adjusted to become
+ // ErrCanonInt in this case.
+ return 0, ErrCanonSize
+ }
+ return binary.BigEndian.Uint64(s.uintbuf), nil
}
- start := int(8 - size)
- for i := 0; i < start; i++ {
- s.uintbuf[i] = 0
- }
- err := s.readFull(s.uintbuf[start:])
- return binary.BigEndian.Uint64(s.uintbuf), err
}
func (s *Stream) readFull(buf []byte) (err error) {
+ if s.limited && s.remaining < uint64(len(buf)) {
+ return ErrValueTooLarge
+ }
s.willRead(uint64(len(buf)))
var nn, n int
for n < len(buf) && err == nil {
@@ -791,6 +915,9 @@ func (s *Stream) readFull(buf []byte) (err error) {
}
func (s *Stream) readByte() (byte, error) {
+ if s.limited && s.remaining == 0 {
+ return 0, io.EOF
+ }
s.willRead(1)
b, err := s.r.ReadByte()
if len(s.stack) > 0 && err == io.EOF {
@@ -801,6 +928,9 @@ func (s *Stream) readByte() (byte, error) {
func (s *Stream) willRead(n uint64) {
s.kind = -1 // rearm Kind
+ if s.limited {
+ s.remaining -= n
+ }
if len(s.stack) > 0 {
s.stack[len(s.stack)-1].pos += n
}
diff --git a/rlp/decode_test.go b/rlp/decode_test.go
index 73a31c67f..d07520bd0 100644
--- a/rlp/decode_test.go
+++ b/rlp/decode_test.go
@@ -21,22 +21,18 @@ func TestStreamKind(t *testing.T) {
{"7F", Byte, 0},
{"80", String, 0},
{"B7", String, 55},
- {"B800", String, 0},
{"B90400", String, 1024},
- {"BA000400", String, 1024},
- {"BB00000400", String, 1024},
{"BFFFFFFFFFFFFFFFFF", String, ^uint64(0)},
{"C0", List, 0},
{"C8", List, 8},
{"F7", List, 55},
- {"F800", List, 0},
- {"F804", List, 4},
{"F90400", List, 1024},
{"FFFFFFFFFFFFFFFFFF", List, ^uint64(0)},
}
for i, test := range tests {
- s := NewStream(bytes.NewReader(unhex(test.input)))
+ // using plainReader to inhibit input limit errors.
+ s := NewStream(newPlainReader(unhex(test.input)), 0)
kind, len, err := s.Kind()
if err != nil {
t.Errorf("test %d: Kind returned error: %v", i, err)
@@ -70,29 +66,85 @@ func TestNewListStream(t *testing.T) {
}
func TestStreamErrors(t *testing.T) {
+ withoutInputLimit := func(b []byte) *Stream {
+ return NewStream(newPlainReader(b), 0)
+ }
+ withCustomInputLimit := func(limit uint64) func([]byte) *Stream {
+ return func(b []byte) *Stream {
+ return NewStream(bytes.NewReader(b), limit)
+ }
+ }
+
type calls []string
tests := []struct {
string
calls
- error
+ newStream func([]byte) *Stream // uses bytes.Reader if nil
+ error error
}{
- {"", calls{"Kind"}, io.EOF},
- {"", calls{"List"}, io.EOF},
- {"", calls{"Uint"}, io.EOF},
- {"C0", calls{"Bytes"}, ErrExpectedString},
- {"C0", calls{"Uint"}, ErrExpectedString},
- {"81", calls{"Bytes"}, io.ErrUnexpectedEOF},
- {"81", calls{"Uint"}, io.ErrUnexpectedEOF},
- {"BFFFFFFFFFFFFFFF", calls{"Bytes"}, io.ErrUnexpectedEOF},
- {"89000000000000000001", calls{"Uint"}, errUintOverflow},
- {"00", calls{"List"}, ErrExpectedList},
- {"80", calls{"List"}, ErrExpectedList},
- {"C0", calls{"List", "Uint"}, EOL},
- {"C801", calls{"List", "Uint", "Uint"}, io.ErrUnexpectedEOF},
- {"C8C9", calls{"List", "Kind"}, ErrElemTooLarge},
- {"C3C2010201", calls{"List", "List", "Uint", "Uint", "ListEnd", "Uint"}, EOL},
- {"00", calls{"ListEnd"}, errNotInList},
- {"C40102", calls{"List", "Uint", "ListEnd"}, errNotAtEOL},
+ {"C0", calls{"Bytes"}, nil, ErrExpectedString},
+ {"C0", calls{"Uint"}, nil, ErrExpectedString},
+ {"89000000000000000001", calls{"Uint"}, nil, errUintOverflow},
+ {"00", calls{"List"}, nil, ErrExpectedList},
+ {"80", calls{"List"}, nil, ErrExpectedList},
+ {"C0", calls{"List", "Uint"}, nil, EOL},
+ {"C8C9010101010101010101", calls{"List", "Kind"}, nil, ErrElemTooLarge},
+ {"C3C2010201", calls{"List", "List", "Uint", "Uint", "ListEnd", "Uint"}, nil, EOL},
+ {"00", calls{"ListEnd"}, nil, errNotInList},
+ {"C401020304", calls{"List", "Uint", "ListEnd"}, nil, errNotAtEOL},
+
+ // Non-canonical integers (e.g. leading zero bytes).
+ {"00", calls{"Uint"}, nil, ErrCanonInt},
+ {"820002", calls{"Uint"}, nil, ErrCanonInt},
+ {"8133", calls{"Uint"}, nil, ErrCanonSize},
+ {"8156", calls{"Uint"}, nil, nil},
+
+ // Size tags must use the smallest possible encoding.
+ // Leading zero bytes in the size tag are also rejected.
+ {"8100", calls{"Uint"}, nil, ErrCanonSize},
+ {"8100", calls{"Bytes"}, nil, ErrCanonSize},
+ {"B800", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"B90000", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"B90055", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"BA0002FFFF", calls{"Bytes"}, withoutInputLimit, ErrCanonSize},
+ {"F800", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"F90000", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"F90055", calls{"Kind"}, withoutInputLimit, ErrCanonSize},
+ {"FA0002FFFF", calls{"List"}, withoutInputLimit, ErrCanonSize},
+
+ // Expected EOF
+ {"", calls{"Kind"}, nil, io.EOF},
+ {"", calls{"Uint"}, nil, io.EOF},
+ {"", calls{"List"}, nil, io.EOF},
+ {"8158", calls{"Uint", "Uint"}, nil, io.EOF},
+ {"C0", calls{"List", "ListEnd", "List"}, nil, io.EOF},
+
+ // Input limit errors.
+ {"81", calls{"Bytes"}, nil, ErrValueTooLarge},
+ {"81", calls{"Uint"}, nil, ErrValueTooLarge},
+ {"81", calls{"Raw"}, nil, ErrValueTooLarge},
+ {"BFFFFFFFFFFFFFFFFFFF", calls{"Bytes"}, nil, ErrValueTooLarge},
+ {"C801", calls{"List"}, nil, ErrValueTooLarge},
+
+ // Test for list element size check overflow.
+ {"CD04040404FFFFFFFFFFFFFFFFFF0303", calls{"List", "Uint", "Uint", "Uint", "Uint", "List"}, nil, ErrElemTooLarge},
+
+ // Test for input limit overflow. Since we are counting the limit
+ // down toward zero in Stream.remaining, reading too far can overflow
+ // remaining to a large value, effectively disabling the limit.
+ {"C40102030401", calls{"Raw", "Uint"}, withCustomInputLimit(5), io.EOF},
+ {"C4010203048158", calls{"Raw", "Uint"}, withCustomInputLimit(6), ErrValueTooLarge},
+
+ // Check that the same calls are fine without a limit.
+ {"C40102030401", calls{"Raw", "Uint"}, withoutInputLimit, nil},
+ {"C4010203048158", calls{"Raw", "Uint"}, withoutInputLimit, nil},
+
+ // Unexpected EOF. This only happens when there is
+ // no input limit, so the reader needs to be 'dumbed down'.
+ {"81", calls{"Bytes"}, withoutInputLimit, io.ErrUnexpectedEOF},
+ {"81", calls{"Uint"}, withoutInputLimit, io.ErrUnexpectedEOF},
+ {"BFFFFFFFFFFFFFFF", calls{"Bytes"}, withoutInputLimit, io.ErrUnexpectedEOF},
+ {"C801", calls{"List", "Uint", "Uint"}, withoutInputLimit, io.ErrUnexpectedEOF},
// This test verifies that the input position is advanced
// correctly when calling Bytes for empty strings. Kind can be called
@@ -109,12 +161,15 @@ func TestStreamErrors(t *testing.T) {
"Bytes", // past final element
"Bytes", // this one should fail
- }, EOL},
+ }, nil, EOL},
}
testfor:
for i, test := range tests {
- s := NewStream(bytes.NewReader(unhex(test.string)))
+ if test.newStream == nil {
+ test.newStream = func(b []byte) *Stream { return NewStream(bytes.NewReader(b), 0) }
+ }
+ s := test.newStream(unhex(test.string))
rs := reflect.ValueOf(s)
for j, call := range test.calls {
fval := rs.MethodByName(call)
@@ -124,11 +179,17 @@ testfor:
err = lastret.(error).Error()
}
if j == len(test.calls)-1 {
- if err != test.error.Error() {
- t.Errorf("test %d: last call (%s) error mismatch\ngot: %s\nwant: %v",
+ want := "<nil>"
+ if test.error != nil {
+ want = test.error.Error()
+ }
+ if err != want {
+ t.Log(test)
+ t.Errorf("test %d: last call (%s) error mismatch\ngot: %s\nwant: %s",
i, call, err, test.error)
}
} else if err != "<nil>" {
+ t.Log(test)
t.Errorf("test %d: call %d (%s) unexpected error: %q", i, j, call, err)
continue testfor
}
@@ -137,7 +198,7 @@ testfor:
}
func TestStreamList(t *testing.T) {
- s := NewStream(bytes.NewReader(unhex("C80102030405060708")))
+ s := NewStream(bytes.NewReader(unhex("C80102030405060708")), 0)
len, err := s.List()
if err != nil {
@@ -166,7 +227,7 @@ func TestStreamList(t *testing.T) {
}
func TestStreamRaw(t *testing.T) {
- s := NewStream(bytes.NewReader(unhex("C58401010101")))
+ s := NewStream(bytes.NewReader(unhex("C58401010101")), 0)
s.List()
want := unhex("8401010101")
@@ -219,7 +280,7 @@ type simplestruct struct {
type recstruct struct {
I uint
- Child *recstruct
+ Child *recstruct `rlp:"nil"`
}
var (
@@ -229,78 +290,58 @@ var (
)
)
-var (
- sharedByteArray [5]byte
- sharedPtr = new(*uint)
-)
-
var decodeTests = []decodeTest{
// integers
{input: "05", ptr: new(uint32), value: uint32(5)},
{input: "80", ptr: new(uint32), value: uint32(0)},
- {input: "8105", ptr: new(uint32), value: uint32(5)},
{input: "820505", ptr: new(uint32), value: uint32(0x0505)},
{input: "83050505", ptr: new(uint32), value: uint32(0x050505)},
{input: "8405050505", ptr: new(uint32), value: uint32(0x05050505)},
{input: "850505050505", ptr: new(uint32), error: "rlp: input string too long for uint32"},
{input: "C0", ptr: new(uint32), error: "rlp: expected input string or byte for uint32"},
+ {input: "00", ptr: new(uint32), error: "rlp: non-canonical integer (leading zero bytes) for uint32"},
+ {input: "8105", ptr: new(uint32), error: "rlp: non-canonical size information for uint32"},
+ {input: "820004", ptr: new(uint32), error: "rlp: non-canonical integer (leading zero bytes) for uint32"},
+ {input: "B8020004", ptr: new(uint32), error: "rlp: non-canonical size information for uint32"},
// slices
{input: "C0", ptr: new([]uint), value: []uint{}},
{input: "C80102030405060708", ptr: new([]uint), value: []uint{1, 2, 3, 4, 5, 6, 7, 8}},
+ {input: "F8020004", ptr: new([]uint), error: "rlp: non-canonical size information for []uint"},
// arrays
- {input: "C0", ptr: new([5]uint), value: [5]uint{}},
{input: "C50102030405", ptr: new([5]uint), value: [5]uint{1, 2, 3, 4, 5}},
+ {input: "C0", ptr: new([5]uint), error: "rlp: input list has too few elements for [5]uint"},
+ {input: "C102", ptr: new([5]uint), error: "rlp: input list has too few elements for [5]uint"},
{input: "C6010203040506", ptr: new([5]uint), error: "rlp: input list has too many elements for [5]uint"},
+ {input: "F8020004", ptr: new([5]uint), error: "rlp: non-canonical size information for [5]uint"},
+
+ // zero sized arrays
+ {input: "C0", ptr: new([0]uint), value: [0]uint{}},
+ {input: "C101", ptr: new([0]uint), error: "rlp: input list has too many elements for [0]uint"},
// byte slices
{input: "01", ptr: new([]byte), value: []byte{1}},
{input: "80", ptr: new([]byte), value: []byte{}},
{input: "8D6162636465666768696A6B6C6D", ptr: new([]byte), value: []byte("abcdefghijklm")},
- {input: "C0", ptr: new([]byte), value: []byte{}},
- {input: "C3010203", ptr: new([]byte), value: []byte{1, 2, 3}},
-
- {
- input: "C3820102",
- ptr: new([]byte),
- error: "rlp: input string too long for uint8, decoding into ([]uint8)[0]",
- },
+ {input: "C0", ptr: new([]byte), error: "rlp: expected input string or byte for []uint8"},
+ {input: "8105", ptr: new([]byte), error: "rlp: non-canonical size information for []uint8"},
// byte arrays
- {input: "01", ptr: new([5]byte), value: [5]byte{1}},
- {input: "80", ptr: new([5]byte), value: [5]byte{}},
+ {input: "02", ptr: new([1]byte), value: [1]byte{2}},
{input: "850102030405", ptr: new([5]byte), value: [5]byte{1, 2, 3, 4, 5}},
- {input: "C0", ptr: new([5]byte), value: [5]byte{}},
- {input: "C3010203", ptr: new([5]byte), value: [5]byte{1, 2, 3, 0, 0}},
- {
- input: "C3820102",
- ptr: new([5]byte),
- error: "rlp: input string too long for uint8, decoding into ([5]uint8)[0]",
- },
- {
- input: "86010203040506",
- ptr: new([5]byte),
- error: "rlp: input string too long for [5]uint8",
- },
- {
- input: "850101",
- ptr: new([5]byte),
- error: io.ErrUnexpectedEOF.Error(),
- },
-
- // byte array reuse (should be zeroed)
- {input: "850102030405", ptr: &sharedByteArray, value: [5]byte{1, 2, 3, 4, 5}},
- {input: "8101", ptr: &sharedByteArray, value: [5]byte{1}}, // kind: String
- {input: "850102030405", ptr: &sharedByteArray, value: [5]byte{1, 2, 3, 4, 5}},
- {input: "01", ptr: &sharedByteArray, value: [5]byte{1}}, // kind: Byte
- {input: "C3010203", ptr: &sharedByteArray, value: [5]byte{1, 2, 3, 0, 0}},
- {input: "C101", ptr: &sharedByteArray, value: [5]byte{1}}, // kind: List
+ // byte array errors
+ {input: "02", ptr: new([5]byte), error: "rlp: input string too short for [5]uint8"},
+ {input: "80", ptr: new([5]byte), error: "rlp: input string too short for [5]uint8"},
+ {input: "820000", ptr: new([5]byte), error: "rlp: input string too short for [5]uint8"},
+ {input: "C0", ptr: new([5]byte), error: "rlp: expected input string or byte for [5]uint8"},
+ {input: "C3010203", ptr: new([5]byte), error: "rlp: expected input string or byte for [5]uint8"},
+ {input: "86010203040506", ptr: new([5]byte), error: "rlp: input string too long for [5]uint8"},
+ {input: "8105", ptr: new([1]byte), error: "rlp: non-canonical size information for [1]uint8"},
// zero sized byte arrays
{input: "80", ptr: new([0]byte), value: [0]byte{}},
- {input: "C0", ptr: new([0]byte), value: [0]byte{}},
{input: "01", ptr: new([0]byte), error: "rlp: input string too long for [0]uint8"},
{input: "8101", ptr: new([0]byte), error: "rlp: input string too long for [0]uint8"},
@@ -312,20 +353,44 @@ var decodeTests = []decodeTest{
// big ints
{input: "01", ptr: new(*big.Int), value: big.NewInt(1)},
{input: "89FFFFFFFFFFFFFFFFFF", ptr: new(*big.Int), value: veryBigInt},
- {input: "820001", ptr: new(big.Int), error: "rlp: canon int error appends zero's for *big.Int"},
{input: "10", ptr: new(big.Int), value: *big.NewInt(16)}, // non-pointer also works
{input: "C0", ptr: new(*big.Int), error: "rlp: expected input string or byte for *big.Int"},
+ {input: "820001", ptr: new(big.Int), error: "rlp: non-canonical integer (leading zero bytes) for *big.Int"},
+ {input: "8105", ptr: new(big.Int), error: "rlp: non-canonical size information for *big.Int"},
// structs
- {input: "C0", ptr: new(simplestruct), value: simplestruct{0, ""}},
- {input: "C105", ptr: new(simplestruct), value: simplestruct{5, ""}},
- {input: "C50583343434", ptr: new(simplestruct), value: simplestruct{5, "444"}},
{
- input: "C501C302C103",
+ input: "C50583343434",
+ ptr: new(simplestruct),
+ value: simplestruct{5, "444"},
+ },
+ {
+ input: "C601C402C203C0",
ptr: new(recstruct),
value: recstruct{1, &recstruct{2, &recstruct{3, nil}}},
},
+ // struct errors
+ {
+ input: "C0",
+ ptr: new(simplestruct),
+ error: "rlp: too few elements for rlp.simplestruct",
+ },
+ {
+ input: "C105",
+ ptr: new(simplestruct),
+ error: "rlp: too few elements for rlp.simplestruct",
+ },
+ {
+ input: "C7C50583343434C0",
+ ptr: new([]*simplestruct),
+ error: "rlp: too few elements for rlp.simplestruct, decoding into ([]*rlp.simplestruct)[1]",
+ },
+ {
+ input: "83222222",
+ ptr: new(simplestruct),
+ error: "rlp: expected input list for rlp.simplestruct",
+ },
{
input: "C3010101",
ptr: new(simplestruct),
@@ -338,20 +403,16 @@ var decodeTests = []decodeTest{
},
// pointers
- {input: "00", ptr: new(*uint), value: (*uint)(nil)},
- {input: "80", ptr: new(*uint), value: (*uint)(nil)},
- {input: "C0", ptr: new(*uint), value: (*uint)(nil)},
+ {input: "00", ptr: new(*[]byte), value: &[]byte{0}},
+ {input: "80", ptr: new(*uint), value: uintp(0)},
+ {input: "C0", ptr: new(*uint), error: "rlp: expected input string or byte for uint"},
{input: "07", ptr: new(*uint), value: uintp(7)},
- {input: "8108", ptr: new(*uint), value: uintp(8)},
+ {input: "8158", ptr: new(*uint), value: uintp(0x58)},
{input: "C109", ptr: new(*[]uint), value: &[]uint{9}},
{input: "C58403030303", ptr: new(*[][]byte), value: &[][]byte{{3, 3, 3, 3}}},
// check that input position is advanced also for empty values.
- {input: "C3808005", ptr: new([]*uint), value: []*uint{nil, nil, uintp(5)}},
-
- // pointer should be reset to nil
- {input: "05", ptr: sharedPtr, value: uintp(5)},
- {input: "80", ptr: sharedPtr, value: (*uint)(nil)},
+ {input: "C3808005", ptr: new([]*uint), value: []*uint{uintp(0), uintp(0), uintp(5)}},
// interface{}
{input: "00", ptr: new(interface{}), value: []byte{0}},
@@ -401,11 +462,17 @@ func TestDecodeWithByteReader(t *testing.T) {
})
}
-// dumbReader reads from a byte slice but does not
-// implement ReadByte.
-type dumbReader []byte
+// plainReader reads from a byte slice but does not
+// implement ReadByte. It is also not recognized by the
+// size validation. This is useful to test how the decoder
+// behaves on a non-buffered input stream.
+type plainReader []byte
+
+func newPlainReader(b []byte) io.Reader {
+ return (*plainReader)(&b)
+}
-func (r *dumbReader) Read(buf []byte) (n int, err error) {
+func (r *plainReader) Read(buf []byte) (n int, err error) {
if len(*r) == 0 {
return 0, io.EOF
}
@@ -416,15 +483,14 @@ func (r *dumbReader) Read(buf []byte) (n int, err error) {
func TestDecodeWithNonByteReader(t *testing.T) {
runTests(t, func(input []byte, into interface{}) error {
- r := dumbReader(input)
- return Decode(&r, into)
+ return Decode(newPlainReader(input), into)
})
}
func TestDecodeStreamReset(t *testing.T) {
- s := NewStream(nil)
+ s := NewStream(nil, 0)
runTests(t, func(input []byte, into interface{}) error {
- s.Reset(bytes.NewReader(input))
+ s.Reset(bytes.NewReader(input), 0)
return s.Decode(into)
})
}
@@ -516,9 +582,36 @@ func ExampleDecode() {
// Decoded value: rlp.example{A:0xa, B:0x14, private:0x0, String:"foobar"}
}
+func ExampleDecode_structTagNil() {
+ // In this example, we'll use the "nil" struct tag to change
+ // how a pointer-typed field is decoded. The input contains an RLP
+ // list of one element, an empty string.
+ input := []byte{0xC1, 0x80}
+
+ // This type uses the normal rules.
+ // The empty input string is decoded as a pointer to an empty Go string.
+ var normalRules struct {
+ String *string
+ }
+ Decode(bytes.NewReader(input), &normalRules)
+ fmt.Printf("normal: String = %q\n", *normalRules.String)
+
+ // This type uses the struct tag.
+ // The empty input string is decoded as a nil pointer.
+ var withEmptyOK struct {
+ String *string `rlp:"nil"`
+ }
+ Decode(bytes.NewReader(input), &withEmptyOK)
+ fmt.Printf("with nil tag: String = %v\n", withEmptyOK.String)
+
+ // Output:
+ // normal: String = ""
+ // with nil tag: String = <nil>
+}
+
func ExampleStream() {
input, _ := hex.DecodeString("C90A1486666F6F626172")
- s := NewStream(bytes.NewReader(input))
+ s := NewStream(bytes.NewReader(input), 0)
// Check what kind of value lies ahead
kind, size, _ := s.Kind()
diff --git a/rlp/encode.go b/rlp/encode.go
index 6cf6776d6..10ff0ae79 100644
--- a/rlp/encode.go
+++ b/rlp/encode.go
@@ -194,7 +194,7 @@ func (w *encbuf) Write(b []byte) (int, error) {
func (w *encbuf) encode(val interface{}) error {
rval := reflect.ValueOf(val)
- ti, err := cachedTypeInfo(rval.Type())
+ ti, err := cachedTypeInfo(rval.Type(), tags{})
if err != nil {
return err
}
@@ -485,7 +485,7 @@ func writeInterface(val reflect.Value, w *encbuf) error {
return nil
}
eval := val.Elem()
- ti, err := cachedTypeInfo(eval.Type())
+ ti, err := cachedTypeInfo(eval.Type(), tags{})
if err != nil {
return err
}
@@ -493,7 +493,7 @@ func writeInterface(val reflect.Value, w *encbuf) error {
}
func makeSliceWriter(typ reflect.Type) (writer, error) {
- etypeinfo, err := cachedTypeInfo1(typ.Elem())
+ etypeinfo, err := cachedTypeInfo1(typ.Elem(), tags{})
if err != nil {
return nil, err
}
@@ -530,7 +530,7 @@ func makeStructWriter(typ reflect.Type) (writer, error) {
}
func makePtrWriter(typ reflect.Type) (writer, error) {
- etypeinfo, err := cachedTypeInfo1(typ.Elem())
+ etypeinfo, err := cachedTypeInfo1(typ.Elem(), tags{})
if err != nil {
return nil, err
}
diff --git a/rlp/typecache.go b/rlp/typecache.go
index 398f25d90..d512012e9 100644
--- a/rlp/typecache.go
+++ b/rlp/typecache.go
@@ -7,7 +7,7 @@ import (
var (
typeCacheMutex sync.RWMutex
- typeCache = make(map[reflect.Type]*typeinfo)
+ typeCache = make(map[typekey]*typeinfo)
)
type typeinfo struct {
@@ -15,13 +15,25 @@ type typeinfo struct {
writer
}
+// represents struct tags
+type tags struct {
+ nilOK bool
+}
+
+type typekey struct {
+ reflect.Type
+ // the key must include the struct tags because they
+ // might generate a different decoder.
+ tags
+}
+
type decoder func(*Stream, reflect.Value) error
type writer func(reflect.Value, *encbuf) error
-func cachedTypeInfo(typ reflect.Type) (*typeinfo, error) {
+func cachedTypeInfo(typ reflect.Type, tags tags) (*typeinfo, error) {
typeCacheMutex.RLock()
- info := typeCache[typ]
+ info := typeCache[typekey{typ, tags}]
typeCacheMutex.RUnlock()
if info != nil {
return info, nil
@@ -29,11 +41,12 @@ func cachedTypeInfo(typ reflect.Type) (*typeinfo, error) {
// not in the cache, need to generate info for this type.
typeCacheMutex.Lock()
defer typeCacheMutex.Unlock()
- return cachedTypeInfo1(typ)
+ return cachedTypeInfo1(typ, tags)
}
-func cachedTypeInfo1(typ reflect.Type) (*typeinfo, error) {
- info := typeCache[typ]
+func cachedTypeInfo1(typ reflect.Type, tags tags) (*typeinfo, error) {
+ key := typekey{typ, tags}
+ info := typeCache[key]
if info != nil {
// another goroutine got the write lock first
return info, nil
@@ -41,21 +54,27 @@ func cachedTypeInfo1(typ reflect.Type) (*typeinfo, error) {
// put a dummmy value into the cache before generating.
// if the generator tries to lookup itself, it will get
// the dummy value and won't call itself recursively.
- typeCache[typ] = new(typeinfo)
- info, err := genTypeInfo(typ)
+ typeCache[key] = new(typeinfo)
+ info, err := genTypeInfo(typ, tags)
if err != nil {
// remove the dummy value if the generator fails
- delete(typeCache, typ)
+ delete(typeCache, key)
return nil, err
}
- *typeCache[typ] = *info
- return typeCache[typ], err
+ *typeCache[key] = *info
+ return typeCache[key], err
+}
+
+type field struct {
+ index int
+ info *typeinfo
}
func structFields(typ reflect.Type) (fields []field, err error) {
for i := 0; i < typ.NumField(); i++ {
if f := typ.Field(i); f.PkgPath == "" { // exported
- info, err := cachedTypeInfo1(f.Type)
+ tags := parseStructTag(f.Tag.Get("rlp"))
+ info, err := cachedTypeInfo1(f.Type, tags)
if err != nil {
return nil, err
}
@@ -65,9 +84,13 @@ func structFields(typ reflect.Type) (fields []field, err error) {
return fields, nil
}
-func genTypeInfo(typ reflect.Type) (info *typeinfo, err error) {
+func parseStructTag(tag string) tags {
+ return tags{nilOK: tag == "nil"}
+}
+
+func genTypeInfo(typ reflect.Type, tags tags) (info *typeinfo, err error) {
info = new(typeinfo)
- if info.decoder, err = makeDecoder(typ); err != nil {
+ if info.decoder, err = makeDecoder(typ, tags); err != nil {
return nil, err
}
if info.writer, err = makeWriter(typ); err != nil {
diff --git a/rpc/api.go b/rpc/api.go
index 4b61fa3a5..66283752b 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -2,7 +2,7 @@ package rpc
import (
"encoding/json"
- // "fmt"
+ "fmt"
"math/big"
"sync"
@@ -167,6 +167,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err
}
+ // call ConfirmTransaction first
+ tx, _ := json.Marshal(req)
+ if !api.xeth().ConfirmTransaction(string(tx)) {
+ return fmt.Errorf("Transaction not confirmed")
+ }
+
v, err := api.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data)
if err != nil {
return err
@@ -182,8 +188,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if err != nil {
return err
}
-
- *reply = v
+ // TODO unwrap the parent method's ToHex call
+ *reply = newHexData(common.FromHex(v))
case "eth_flush":
return NewNotImplementedError(req.Method)
case "eth_getBlockByHash":
diff --git a/rpc/args.go b/rpc/args.go
index 4bc36f5d9..4b3840285 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -279,6 +279,8 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
return NewDecodeParamError(err.Error())
}
+ args.From = ext.From
+
if len(ext.To) == 0 {
return NewValidationError("to", "is required")
}
diff --git a/tests/blocktest.go b/tests/blocktest.go
index 84b70678d..2d6b11944 100644
--- a/tests/blocktest.go
+++ b/tests/blocktest.go
@@ -187,9 +187,9 @@ func mustConvertHeader(in btHeader) *types.Header {
UncleHash: mustConvertHash(in.UncleHash),
ParentHash: mustConvertHash(in.ParentHash),
Extra: mustConvertBytes(in.ExtraData),
- GasUsed: mustConvertBigInt10(in.GasUsed),
- GasLimit: mustConvertBigInt10(in.GasLimit),
- Difficulty: mustConvertBigInt10(in.Difficulty),
+ GasUsed: mustConvertBigInt(in.GasUsed),
+ GasLimit: mustConvertBigInt(in.GasLimit),
+ Difficulty: mustConvertBigInt(in.Difficulty),
Time: mustConvertUint(in.Timestamp),
}
// XXX cheats? :-)
@@ -211,9 +211,13 @@ func mustConvertBlocks(testBlocks []btBlock) []*types.Block {
}
func mustConvertBytes(in string) []byte {
- out, err := hex.DecodeString(strings.TrimPrefix(in, "0x"))
+ if in == "0x" {
+ return []byte{}
+ }
+ h := strings.TrimPrefix(unfuckCPPHexInts(in), "0x")
+ out, err := hex.DecodeString(h)
if err != nil {
- panic(fmt.Errorf("invalid hex: %q", in))
+ panic(fmt.Errorf("invalid hex: %q", h))
}
return out
}
@@ -242,16 +246,8 @@ func mustConvertBloom(in string) types.Bloom {
return types.BytesToBloom(out)
}
-func mustConvertBigInt10(in string) *big.Int {
- out, ok := new(big.Int).SetString(in, 10)
- if !ok {
- panic(fmt.Errorf("invalid integer: %q", in))
- }
- return out
-}
-
-func mustConvertBigIntHex(in string) *big.Int {
- out, ok := new(big.Int).SetString(in, 16)
+func mustConvertBigInt(in string) *big.Int {
+ out, ok := new(big.Int).SetString(unfuckCPPHexInts(in), 0)
if !ok {
panic(fmt.Errorf("invalid integer: %q", in))
}
@@ -259,15 +255,7 @@ func mustConvertBigIntHex(in string) *big.Int {
}
func mustConvertUint(in string) uint64 {
- out, err := strconv.ParseUint(in, 0, 64)
- if err != nil {
- panic(fmt.Errorf("invalid integer: %q", in))
- }
- return out
-}
-
-func mustConvertUintHex(in string) uint64 {
- out, err := strconv.ParseUint(in, 16, 64)
+ out, err := strconv.ParseUint(unfuckCPPHexInts(in), 0, 64)
if err != nil {
panic(fmt.Errorf("invalid integer: %q", in))
}
@@ -303,3 +291,13 @@ func findLine(data []byte, offset int64) (line int) {
}
return
}
+
+func unfuckCPPHexInts(s string) string {
+ if s == "0x" { // no respect for the empty value :(
+ return "0x00"
+ }
+ if (len(s) % 2) != 0 { // motherfucking nibbles
+ return "0x0" + s[2:]
+ }
+ return s
+}
diff --git a/tests/files/BlockTests/bcForkBlockTest.json b/tests/files/BlockTests/bcForkBlockTest.json
new file mode 100644
index 000000000..af2964246
--- /dev/null
+++ b/tests/files/BlockTests/bcForkBlockTest.json
@@ -0,0 +1,367 @@
+{
+ "SimpleTxCosts20000" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf90260f901f9a0e6b9733f0b922036b3ba8de0e077c160b553fef8935f5a0f1d8dd46325b26733a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0414135f01c4de156a9f2bc01a42ed827e1042f859aea4b1a00dd0713a4e8c696a08da0fbf1adcf4cacf92376e5d04d9a27c12241aec440fa650da14ffe53cbc811a0e60c1a8e6afacd80b169c0b7b970bca5bd532f50549e8a525b2d7bfd5fd90270b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8824e2084551f121980a0e90230ef822cf25172ec98a598fa15e0395fbff5a41a8edb075fbf3a1c243fdf8898997592fb8a3fa7f861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca08457f38c821af59f4e088a0cc693070670ea540209a33cf17b174cdc2364c5a8a09590e57e474e6428079057e4ab7135a73168c28b2dd32a1b0fb9e5bb72e45d24c0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "e6b9733f0b922036b3ba8de0e077c160b553fef8935f5a0f1d8dd46325b26733",
+ "mixHash" : "79a516ea16b8b0071c9a83c89ebfd96d29e614f1bd519f733ea82cb76287ca6c",
+ "nonce" : "3c37bc117e5135d8",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a079a516ea16b8b0071c9a83c89ebfd96d29e614f1bd519f733ea82cb76287ca6c883c37bc117e5135d8c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
+
+ "BlockExtraData25" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf90663f905fca055e75bec293d5d5f38213bded3d27435ca91cee285c1f76a658ddccdccd08d00a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a09ee6c6d3ba44b01327c41171dd5316e04f0f71f8286960fe8408e06fe156438fa0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd88252088455200109b904010102030405060708091011121314151617181920212223242510000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a0a0fdabfa4034aea18f6b722643f1611f33a4da71804367cec161946f5308ceae8803c6884fb3570f4af861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0e172fae6bbd140fdce64cb80776b0a70488646c1bce1caf94dfba74975d14414a03b55ce283b425c4c37219148f4b057fd67018096f5feef8dc7afafdfc91df442c0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "55e75bec293d5d5f38213bded3d27435ca91cee285c1f76a658ddccdccd08d00",
+ "mixHash" : "2afb8dc82d0d45cce72967ed9c00892fb808bb92e9ff22fe1c51a6b842c783e5",
+ "nonce" : "f9d04b2fcc151a74",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a02afb8dc82d0d45cce72967ed9c00892fb808bb92e9ff22fe1c51a6b842c783e588f9d04b2fcc151a74c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
+
+ "BlockGenesisWrongDifficulty" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf9024cf901f9a0a86ae992fdd69bae849f81cfc40fcfc67f39c4eaf6fad19cf7dabe773a0337f1a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0443892374258a3217e783406d838bb714fbff41c4125baf205728c0649854ca8a07d2ff7c2e6ffb3372e645af2a93aaa586a5174759998521c46a3762b034c0601a0054f528d1c19f01267c568d9953b1eb39157ea6d464aef0774c39f9061a15c69b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008301ffff01832fefd8825208845520560600a06b69365fe3c4aeb3e2d346cfd4b5c5d3237f74378cc86f520a776178a67cf8a9889d9bacd2ec71eef0f84df84b800a82c3508080801ba0aa794cfca0c38438b5a2fd0ca28ede104e5deca7e584dfb79597c2c9e32bfccea0dd90c12157f6f0100c388080d73a04e0d6ea683b761e83205f4d8fe72386d701c0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131071",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "a86ae992fdd69bae849f81cfc40fcfc67f39c4eaf6fad19cf7dabe773a0337f1",
+ "mixHash" : "6b059edc07e4915f38662bef99823f4a4d23d649d268ab4c7776525e4b9e7687",
+ "nonce" : "67758801b3aecd77",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008301ffff80832fefd8808454c98c8142a06b059edc07e4915f38662bef99823f4a4d23d649d268ab4c7776525e4b9e76878867758801b3aecd77c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
+
+ "BlockWrongStoreSetGas" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf90260f901f9a0fe8971aa67f2b822d705da25733a5915216649b723157e72cde735fdd0bbbfe6a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0fa43a6918249a341c9dc2ac6901c65206245c2a1913d108adf9ee896b86b72d8a0499e7f409b56dad6f79d7cc5b25083ae73a8942bac5a49baa23d70a19263c419a073a67c5782873d66dc97e72fdcccd005e47ebf9b19450ca38f923bb69dc036ffb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd88252d6845520589c00a04b510481836fcfc589dbc1480a88394fc3800c1ba1e3540d74b22abe0867f0a188ef8d43e412b29332f861f85f800a82c35094b94f5374fce5edbc8e2a8697c15331677e6ebf0b80801ca0ef1f1816a506f56b5260c709f34c311903fa24ee7d1a4cc9be26f6c7b12ed570a0e2377a1966e346733505bc42fb65ed854a9323f846c16a139bfabab3dc9b717ac0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "fe8971aa67f2b822d705da25733a5915216649b723157e72cde735fdd0bbbfe6",
+ "mixHash" : "e49f57f3c1eec112b86bf41733f03a1d82f402941c11219e250574514627e577",
+ "nonce" : "aa40d3c520d10cc8",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "781413a37d7ceb31dd5e02ed699bb19f875904a6cd46e003a5238121fdef623b",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0781413a37d7ceb31dd5e02ed699bb19f875904a6cd46e003a5238121fdef623ba056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a0e49f57f3c1eec112b86bf41733f03a1d82f402941c11219e250574514627e57788aa40d3c520d10cc8c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x6012600055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x6012600055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
+
+ "BlockWrongResetGas" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf90260f901f9a0e58728c5c414ab020e2ea1afc57c6d568d59c15da6e865fba417ffeff4194c63a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a00c4e05cfc93ec92cbfb6ff3f07b9ccba294e13f8881ca3b695a47691725e9d52a039e2a46254e21f73fb52b7754e6494dca6d1bae60e194628fff47ca3dea11518a05272b11fc2171a6cf2d6dcdc701cca353310245e9a1f1777602e7ff025d96aabb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd88252138455205cb500a0b183084eabf791848551bb954dea9bc9cbb3dede738209d98f2d09e93a660d0e8845f9bffe0a8c2ad2f861f85f800a82c35094b94f5374fce5edbc8e2a8697c15331677e6ebf0b80801ba0879aba7b6048f06a581f904fefeaa8557c9a7eb83eb63af6938aa3cc90733a76a0b92eca3949cc83e4bb8069f65b09894eb4f6ee3a2c144df899c557c63f0d24a3c0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "e58728c5c414ab020e2ea1afc57c6d568d59c15da6e865fba417ffeff4194c63",
+ "mixHash" : "27e9f3fd3617f1c02782709eba97fe7920b03961de1bd88dabc4a8c431facdad",
+ "nonce" : "be030eed4ae24d69",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "5b53ecce92ad44bada5b97cdfc139c770a9d253d4e3c72e925cc1ea11cfe6082",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05b53ecce92ad44bada5b97cdfc139c770a9d253d4e3c72e925cc1ea11cfe6082a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a027e9f3fd3617f1c02782709eba97fe7920b03961de1bd88dabc4a8c431facdad88be030eed4ae24d69c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x6032600055",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x12"
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x6032600055",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x12"
+ }
+ }
+ }
+ },
+
+ "BlockWrongStoreClears" : {
+ "blocks" : [
+ {
+ "rlp" : "0xf90260f901f9a0b3eb70baa54ac60fb26770e2bd62108db9f2e189375660af7f47ef276f520551a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a022acf357764b1a92bad08aa2b892c4fb202603a7c5d93715f264fcfc0006560aa0fa47fec4460036c6adadad7abf8dcca6351745fff036fb9d6509d1fffa9c47b5a0bb944e3499f51548f6d37e04f9d918d8510954760cd4c0262507733f60e6432fb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd882292084552064c700a02340ad0249a1e6bbe4c6a880d7aa95cef5ceb6cea6e63fa6a50ad8319822d61688936bfd96de95375ff861f85f800a82c35094b94f5374fce5edbc8e2a8697c15331677e6ebf0b80801ba02388d4327dec4a133b3b8e558d25e7a117f6c7d2f5b1431014b69cae7496f758a0542851efe150eba1c3d9bae8778f41db144bb65fa71bee41915fc03d3ecfe1a4c0"
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "b3eb70baa54ac60fb26770e2bd62108db9f2e189375660af7f47ef276f520551",
+ "mixHash" : "99d5457ad6de954e86e0c80f56ca1fbc81c692766cd2206d2038b1880f98ff38",
+ "nonce" : "99f1656c715f2fa8",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "309e578cb5523a22eb5b4580ae2faa53906d5637f6fd9fd171211ef3c503a5e6",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0309e578cb5523a22eb5b4580ae2faa53906d5637f6fd9fd171211ef3c503a5e6a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a099d5457ad6de954e86e0c80f56ca1fbc81c692766cd2206d2038b1880f98ff388899f1656c715f2fa8c0c0",
+ "postState" : {
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "1500000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x60006000556000600155600060025560006003556000600455",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x12",
+ "0x01" : "0x12",
+ "0x02" : "0x12",
+ "0x03" : "0x12",
+ "0x04" : "0x12"
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000",
+ "code" : "0x60006000556000600155600060025560006003556000600455",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x12",
+ "0x01" : "0x12",
+ "0x02" : "0x12",
+ "0x03" : "0x12",
+ "0x04" : "0x12"
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/BlockTests/bcInvalidRLPTest.json b/tests/files/BlockTests/bcInvalidRLPTest.json
index a1e8839ac..fcf83981a 100644
--- a/tests/files/BlockTests/bcInvalidRLPTest.json
+++ b/tests/files/BlockTests/bcInvalidRLPTest.json
@@ -1,8 +1,8 @@
{
- "BLOCK_HeaderLargerThanRLP_0" : {
+ "RLPLengthOfLengthWithFirstZeros" : {
"blocks" : [
{
- "rlp" : "0xf9026ef901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xfa000260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -43,10 +43,10 @@
}
},
- "BLOCK_HeaderGivenAsArray_0" : {
+ "BLOCK_HeaderLargerThanRLP_0" : {
"blocks" : [
{
- "rlp" : "0xb90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf9026ef901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -87,10 +87,10 @@
}
},
- "BLOCK_HeaderLargerThanRLP_1" : {
+ "BLOCK_HeaderGivenAsArray_0" : {
"blocks" : [
{
- "rlp" : "0xf90260f90207a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xb90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -131,10 +131,10 @@
}
},
- "BLOCK_HeaderGivenAsArray_1" : {
+ "BLOCK_HeaderLargerThanRLP_1" : {
"blocks" : [
{
- "rlp" : "0xf90260b901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90260f90207a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -175,10 +175,10 @@
}
},
- "BLOCK_bloom_Prefixed0000" : {
+ "BLOCK_HeaderGivenAsArray_1" : {
"blocks" : [
{
- "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b901020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90260b901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -219,10 +219,10 @@
}
},
- "BLOCK_coinbase_Prefixed0000" : {
+ "BLOCK_bloom_Prefixed0000" : {
"blocks" : [
{
- "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493479600008888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b901020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -263,10 +263,10 @@
}
},
- "BLOCK_coinbase_TooLarge" : {
+ "BLOCK_coinbase_Prefixed0000" : {
"blocks" : [
{
- "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934796ef3d8888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493479600008888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -307,10 +307,10 @@
}
},
- "BLOCK_coinbase_TooShort" : {
+ "BLOCK_coinbase_TooLarge" : {
"blocks" : [
{
- "rlp" : "0xf9025ef901f7a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934792f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934796ef3d8888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -351,10 +351,10 @@
}
},
- "BLOCK_coinbase_GivenAsList" : {
+ "BLOCK_coinbase_TooShort" : {
"blocks" : [
{
- "rlp" : "0xf90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347d48888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf9025ef901f7a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934792f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -395,10 +395,10 @@
}
},
- "BLOCK_difficulty_Prefixed0000" : {
+ "BLOCK_coinbase_GivenAsList" : {
"blocks" : [
{
- "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085000002000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347d48888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -439,10 +439,10 @@
}
},
- "BLOCK_difficulty_TooLarge" : {
+ "BLOCK_difficulty_Prefixed0000" : {
"blocks" : [
{
- "rlp" : "0xf90280f90219a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085000002000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -483,10 +483,10 @@
}
},
- "BLOCK_difficulty_GivenAsList" : {
+ "BLOCK_difficulty_TooLarge" : {
"blocks" : [
{
- "rlp" : "0xf90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90280f90219a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
@@ -527,10 +527,10 @@
}
},
- "BLOCK_extraData_Prefixed0000" : {
+ "BLOCK_difficulty_GivenAsList" : {
"blocks" : [
{
- "rlp" : "0xf90262f901fba02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd88252088455098142820000a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
+ "rlp" : "0xf90260f901f9a02a3c692012a15502ba9c39f3aebb36694eed978c74b52e6c0cf210d301dbf325a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0b6c9fd1447d0b414a1f05957927746f58ef5a2ebde17db631d460eaf6a93b18da0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c302000001832fefd8825208845509814280a00451dd53d9c09f3cfb627b51d9d80632ed801f6330ee584bffc26caac9b9249f88c7bffe5ebd94cc2ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba098c3a099885a281885f487fd37550de16436e8c47874cd213531b10fe751617fa044b6b81011ce57bffcaf610bf728fb8a7237ad261ea2d937423d78eb9e137076c0"
}
],
"genesisBlockHeader" : {
diff --git a/tests/files/BlockTests/bcRPC_API_Test.json b/tests/files/BlockTests/bcRPC_API_Test.json
new file mode 100644
index 000000000..4fda238d8
--- /dev/null
+++ b/tests/files/BlockTests/bcRPC_API_Test.json
@@ -0,0 +1,1257 @@
+{
+ "RPC_API_Test" : {
+ "blocks" : [
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "485355",
+ "hash" : "3cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352",
+ "mixHash" : "e7c0ac40e41e32853cd7fd612fce5c5d199515fcb0f41182817a7ecdf57cadf5",
+ "nonce" : "648151f718824fd6",
+ "number" : "1",
+ "parentHash" : "02aa46ee7e8a588ecb36ae05a225f442a4410e7dca91b4e2e8fa351148a418c5",
+ "receiptTrie" : "843716b02b7b22c1c8beb74a8ce2421471f9f35bccaf454b06ca1a6e796dee52",
+ "stateRoot" : "6d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1",
+ "timestamp" : "1429004696",
+ "transactionsTrie" : "0337bf35b741bf9be4594a78cbdcd220d7736eb452c9711343637f75508d73a7",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90942f901faa002aa46ee7e8a588ecb36ae05a225f442a4410e7dca91b4e2e8fa351148a418c5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a06d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1a00337bf35b741bf9be4594a78cbdcd220d7736eb452c9711343637f75508d73a7a0843716b02b7b22c1c8beb74a8ce2421471f9f35bccaf454b06ca1a6e796dee52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8830767eb84552ce19880a0e7c0ac40e41e32853cd7fd612fce5c5d199515fcb0f41182817a7ecdf57cadf588648151f718824fd6f90741f9073e8001832fefd8800ab906f05b5b6106e0806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104b1565b60006000f35b610142610376565b8060005260206000f35b610157600435610301565b60006000f35b6101686004356102c9565b60006000f35b61017661041d565b8060005260206000f35b6101886103ae565b8060ff1660005260206000f35b61019d6103ee565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104a0565b60006000f35b6101d3610392565b8060000b60005260206000f35b6101e861042f565b60006000f35b6101f66103dc565b8060005260206000f35b6102086104fa565b60006000f35b6102196004356102e5565b60006000f35b61022761066e565b60006000f35b61023860043561031d565b60006000f35b61024661045f565b60006000f35b61025461046e565b60006000f35b610265600435610368565b60006000f35b61027660043561032b565b60006000f35b610287600435610339565b60006000f35b61029561058f565b60006000f35b6102a3610522565b60006000f35b6102b16103ca565b8060005260206000f35b6102c36105db565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff021916908302179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff16905061038f565b90565b6000600060019054906101000a900460ff1690506103ab565b90565b6000600060029054906101000a900460ff1690506103c7565b90565b600060016000505490506103d9565b90565b600060026000505490506103eb565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061041a565b90565b6000600460005054905061042c565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b561ca0f3ad419ce7510ae207aaa5aaefa0809d70e5dc2cc8eaae13918b5225631b9bfda0ed8214956dac9f349be703fe3a7c4061614066e5dc491047f66bbc71074d0f7cc0",
+ "transactions" : [
+ {
+ "data" : "0x5b5b6106e0806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104b1565b60006000f35b610142610376565b8060005260206000f35b610157600435610301565b60006000f35b6101686004356102c9565b60006000f35b61017661041d565b8060005260206000f35b6101886103ae565b8060ff1660005260206000f35b61019d6103ee565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104a0565b60006000f35b6101d3610392565b8060000b60005260206000f35b6101e861042f565b60006000f35b6101f66103dc565b8060005260206000f35b6102086104fa565b60006000f35b6102196004356102e5565b60006000f35b61022761066e565b60006000f35b61023860043561031d565b60006000f35b61024661045f565b60006000f35b61025461046e565b60006000f35b610265600435610368565b60006000f35b61027660043561032b565b60006000f35b610287600435610339565b60006000f35b61029561058f565b60006000f35b6102a3610522565b60006000f35b6102b16103ca565b8060005260206000f35b6102c36105db565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff021916908302179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff16905061038f565b90565b6000600060019054906101000a900460ff1690506103ab565b90565b6000600060029054906101000a900460ff1690506103c7565b90565b600060016000505490506103d9565b90565b600060026000505490506103eb565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061041a565b90565b6000600460005054905061042c565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56",
+ "gasLimit" : "3141592",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "r" : "0xf3ad419ce7510ae207aaa5aaefa0809d70e5dc2cc8eaae13918b5225631b9bfd",
+ "s" : "0xed8214956dac9f349be703fe3a7c4061614066e5dc491047f66bbc71074d0f7c",
+ "to" : "",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131136",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21488",
+ "hash" : "b0ce489fae521c12a147d7d8dd3602be614e4c7a832ed33f15b4a79eda5b3be9",
+ "mixHash" : "58b602921f4bb4bc83031a11d62dfc6b0c06ac44f56afddc2995df393e2aa2da",
+ "nonce" : "0a9bd6d7775e51e4",
+ "number" : "2",
+ "parentHash" : "3cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352",
+ "receiptTrie" : "76ce23a5dcd0aab349e1437efc64693a1c3c9c578c35d33b41ff71d9139962e4",
+ "stateRoot" : "b7ce0796f6b89a269bcdab2df04e6b9f62ffcd76050fcdc609dba9de5d7ebb19",
+ "timestamp" : "1429004702",
+ "transactionsTrie" : "b605a5efd5c16b6303c8c888da4b800c0376b5a0902c6a1867335e2a1a42dc4e",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a03cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0b7ce0796f6b89a269bcdab2df04e6b9f62ffcd76050fcdc609dba9de5d7ebb19a0b605a5efd5c16b6303c8c888da4b800c0376b5a0902c6a1867335e2a1a42dc4ea076ce23a5dcd0aab349e1437efc64693a1c3c9c578c35d33b41ff71d9139962e4b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefd88253f084552ce19e80a058b602921f4bb4bc83031a11d62dfc6b0c06ac44f56afddc2995df393e2aa2da880a9bd6d7775e51e4f866f86401018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8412a7b9141ca0c8f05c2219b22248f13eb55e7492461e167135058f200581d39f932540f942f4a03629ea76afb87083e9c41c380e3f41544ddd7b6139b3045c76d4f07594374b73c0",
+ "transactions" : [
+ {
+ "data" : "0x12a7b914",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "1",
+ "r" : "0xc8f05c2219b22248f13eb55e7492461e167135058f200581d39f932540f942f4",
+ "s" : "0x3629ea76afb87083e9c41c380e3f41544ddd7b6139b3045c76d4f07594374b73",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131200",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21660",
+ "hash" : "e08b5d4011d4483d0eafa59dc46b17d6a7408c7bcefbd100c4b3bbb1d9b8a4c7",
+ "mixHash" : "3ea94307f644649d2c1b339d0cc6c933647cdc38192af8060b67004b2803efec",
+ "nonce" : "8e41d0bef5220d8d",
+ "number" : "3",
+ "parentHash" : "b0ce489fae521c12a147d7d8dd3602be614e4c7a832ed33f15b4a79eda5b3be9",
+ "receiptTrie" : "6b91611fce2a69de207bf5f145636b7d0839d95ab71a8c12498e14bb501aa6c8",
+ "stateRoot" : "197c6ce79b4f3787e8c3f459223bb43694f2ace47462cd3d8c82eb2a8d9bbb1f",
+ "timestamp" : "1429004704",
+ "transactionsTrie" : "9b3f61d7e0e90b92894bc8fac3155178028d0494528568d1ebfe86e39a839f11",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0b0ce489fae521c12a147d7d8dd3602be614e4c7a832ed33f15b4a79eda5b3be9a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0197c6ce79b4f3787e8c3f459223bb43694f2ace47462cd3d8c82eb2a8d9bbb1fa09b3f61d7e0e90b92894bc8fac3155178028d0494528568d1ebfe86e39a839f11a06b91611fce2a69de207bf5f145636b7d0839d95ab71a8c12498e14bb501aa6c8b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefd882549c84552ce1a080a03ea94307f644649d2c1b339d0cc6c933647cdc38192af8060b67004b2803efec888e41d0bef5220d8df866f86402018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8457cb2fc41ca08a709ee04af49fe31babfeba923455c1a567593cd67c58f1237838b26b540453a034b6da0c1f695070cecc1f4c795c7c2da9601875303debb48cc00f4197b2b0f6c0",
+ "transactions" : [
+ {
+ "data" : "0x57cb2fc4",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "2",
+ "r" : "0x8a709ee04af49fe31babfeba923455c1a567593cd67c58f1237838b26b540453",
+ "s" : "0x34b6da0c1f695070cecc1f4c795c7c2da9601875303debb48cc00f4197b2b0f6",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131264",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21592",
+ "hash" : "080b42a9fd2ac500075a871019d9b32887cbd97196e3f2323c6c32face9d0463",
+ "mixHash" : "95ed4a0f3ed622d43d1070b83547f82b742d8dc2d28655d86f20effff9a192b2",
+ "nonce" : "881b4a1ea5726818",
+ "number" : "4",
+ "parentHash" : "e08b5d4011d4483d0eafa59dc46b17d6a7408c7bcefbd100c4b3bbb1d9b8a4c7",
+ "receiptTrie" : "c6ed4b4998f89da693677539b6762dbc9d5844bbc04db3d36568ac11c5cc466f",
+ "stateRoot" : "f9c2d2f5ebe8a3059eaa578fd3265a0c66bb15e1966fd190d66a97db39a8ac23",
+ "timestamp" : "1429004705",
+ "transactionsTrie" : "adf50d39fcb209d38229b8836dc501c91c4cbd865d319c4a36355531870b284d",
+ "uncleHash" : "8692b0b3f5ae3b9c3b09ed5b8964c9a61bf4fd82e66038e064187339dfea7f99"
+ },
+ "rlp" : "0xf9065bf901f9a0e08b5d4011d4483d0eafa59dc46b17d6a7408c7bcefbd100c4b3bbb1d9b8a4c7a08692b0b3f5ae3b9c3b09ed5b8964c9a61bf4fd82e66038e064187339dfea7f99948888f1f195afa192cfee860698584c030f4c9db1a0f9c2d2f5ebe8a3059eaa578fd3265a0c66bb15e1966fd190d66a97db39a8ac23a0adf50d39fcb209d38229b8836dc501c91c4cbd865d319c4a36355531870b284da0c6ed4b4998f89da693677539b6762dbc9d5844bbc04db3d36568ac11c5cc466fb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200c004832fefd882545884552ce1a180a095ed4a0f3ed622d43d1070b83547f82b742d8dc2d28655d86f20effff9a192b288881b4a1ea5726818f866f86403018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84343a875d1ca0db31289d2c976bc09495d20de04e3ea1cf094ffafa679e7b79a33dac371a01f2a01ac4bcb08af7fd22419f6d9b3eb256edc8eadcba1570f156bd593cd06d3fda9ff903f4f901f7a03cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794a94f5374fce5edbc8e2a8697c15331677e6ebf0ba06d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000002832fefd88084552ce1a080a00d68a5a04b4bda56f4548fc9c474b47c7a0167d92d2ff2b493d358e02ff9d31c880fd3ed21fccfa805f901f7a03cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794bcde5374fce5edbc8e2a8697c15331677e6ebf0ba06d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000002832fefd88084552ce1a380a01e393c9c4ec7247ac4c8c5d5f101e8a5bbd08cb65775e7c3af095ad7c8707535884137c508795341a3",
+ "transactions" : [
+ {
+ "data" : "0x343a875d",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "3",
+ "r" : "0xdb31289d2c976bc09495d20de04e3ea1cf094ffafa679e7b79a33dac371a01f2",
+ "s" : "0x1ac4bcb08af7fd22419f6d9b3eb256edc8eadcba1570f156bd593cd06d3fda9f",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "difficulty" : "131072",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "7c80ee6e247ba175276f32db2c524b625aa9122b29d9131bf980b371bbcc6973",
+ "mixHash" : "0d68a5a04b4bda56f4548fc9c474b47c7a0167d92d2ff2b493d358e02ff9d31c",
+ "nonce" : "0fd3ed21fccfa805",
+ "number" : "2",
+ "parentHash" : "3cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "6d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1",
+ "timestamp" : "1429004704",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "bcde5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "difficulty" : "131072",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "67c67352b9d1ee4aed85ad24df50eb83dc54b2e93c67793d7276f9ecdf6a8beb",
+ "mixHash" : "1e393c9c4ec7247ac4c8c5d5f101e8a5bbd08cb65775e7c3af095ad7c8707535",
+ "nonce" : "4137c508795341a3",
+ "number" : "2",
+ "parentHash" : "3cc19bfa993dcd1ba0fe9e42b7b8fde10f5cd5149bc1613636ad68ade617f352",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "6d030caaafd4575d820b495c72c2471cd427c1f314e675045227d1646ef862f1",
+ "timestamp" : "1429004707",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ }
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131328",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21919",
+ "hash" : "8481779fcc4d453a9f11f4c1dec148b225e95b180d33b993761bf6f8681d4bbd",
+ "mixHash" : "2e21eba890af4c6512f567097fcdff89fd277394a2e7e32f242dbd4f5489c237",
+ "nonce" : "61032445b0afe10c",
+ "number" : "5",
+ "parentHash" : "080b42a9fd2ac500075a871019d9b32887cbd97196e3f2323c6c32face9d0463",
+ "receiptTrie" : "316e7588a4deffb558bf4073571307b42e8de4224e0fbde8a1c440b9c04a81e9",
+ "stateRoot" : "9a8f3fe4746315cf31b2efc3da983b2aed59c45109ed7f758e244bbbcb7e9a1f",
+ "timestamp" : "1429004709",
+ "transactionsTrie" : "c623d6ea158838ed10794734f34a805cb59e9e7a2f52a289d9dfd75e6087cee9",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0080b42a9fd2ac500075a871019d9b32887cbd97196e3f2323c6c32face9d0463a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a09a8f3fe4746315cf31b2efc3da983b2aed59c45109ed7f758e244bbbcb7e9a1fa0c623d6ea158838ed10794734f34a805cb59e9e7a2f52a289d9dfd75e6087cee9a0316e7588a4deffb558bf4073571307b42e8de4224e0fbde8a1c440b9c04a81e9b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302010005832fefd882559f84552ce1a580a02e21eba890af4c6512f567097fcdff89fd277394a2e7e32f242dbd4f5489c2378861032445b0afe10cf866f86404018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84f5b53e171ca03dd66e0e6cae407ec7e695ba65827fbab3c95c66b78abf3b842ca3449559a8e5a085a83ec760812ce6d547bd6dbaf9891d12059999bb25c677d3aa9bdf6fae2d40c0",
+ "transactions" : [
+ {
+ "data" : "0xf5b53e17",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "4",
+ "r" : "0x3dd66e0e6cae407ec7e695ba65827fbab3c95c66b78abf3b842ca3449559a8e5",
+ "s" : "0x85a83ec760812ce6d547bd6dbaf9891d12059999bb25c677d3aa9bdf6fae2d40",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131392",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21655",
+ "hash" : "9b63fb821942960d3ec351b38a9a2d8796b9d51a5bf7fbaefa4deb7abc138ed7",
+ "mixHash" : "e708fbae79c4bb86317e8fbbfb53592770aad04f75c1600057cff69e9c2f1917",
+ "nonce" : "8e1ce07686dec274",
+ "number" : "6",
+ "parentHash" : "8481779fcc4d453a9f11f4c1dec148b225e95b180d33b993761bf6f8681d4bbd",
+ "receiptTrie" : "1f80c786dc12c1232c46c8cbb1e6a550408938d0b96752d7b4a0c07a648f70ee",
+ "stateRoot" : "a00f89dc52334ba977f7d2efa37efeffd9c749f426f34afb426b505bbe955f87",
+ "timestamp" : "1429004710",
+ "transactionsTrie" : "0fb433b32c2fa566522da9494601b215b4d6c1ad7c76f4eda60e3ba7c7a60b9e",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a08481779fcc4d453a9f11f4c1dec148b225e95b180d33b993761bf6f8681d4bbda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0a00f89dc52334ba977f7d2efa37efeffd9c749f426f34afb426b505bbe955f87a00fb433b32c2fa566522da9494601b215b4d6c1ad7c76f4eda60e3ba7c7a60b9ea01f80c786dc12c1232c46c8cbb1e6a550408938d0b96752d7b4a0c07a648f70eeb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302014006832fefd882549784552ce1a680a0e708fbae79c4bb86317e8fbbfb53592770aad04f75c1600057cff69e9c2f1917888e1ce07686dec274f866f86405018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84688959791ba06b299d00f696a6c8f564a16e72c3a936fc81f34f27ac48ef1ef66670ba7c1071a06e221b9ba35c2af03fabfdda6dbccc1b7b0dd635698a6b5dbe76eac94a2a4eeec0",
+ "transactions" : [
+ {
+ "data" : "0x68895979",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "5",
+ "r" : "0x6b299d00f696a6c8f564a16e72c3a936fc81f34f27ac48ef1ef66670ba7c1071",
+ "s" : "0x6e221b9ba35c2af03fabfdda6dbccc1b7b0dd635698a6b5dbe76eac94a2a4eee",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131456",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21604",
+ "hash" : "00a7996b43ac2273954e6a5f122d979197a14fd4b250773f7f3b8a670b84fb26",
+ "mixHash" : "9818d7d7c4221b127378a6971b6f6116f2cfa5fc5c63fe732a933cc407a69cb4",
+ "nonce" : "0fb803aef0a13676",
+ "number" : "7",
+ "parentHash" : "9b63fb821942960d3ec351b38a9a2d8796b9d51a5bf7fbaefa4deb7abc138ed7",
+ "receiptTrie" : "c5c1da2c8329bb971f07e54ce5c2a3f7eab44a28e4fdc2e6c0e6ec2ba6d63b56",
+ "stateRoot" : "983a9e4cad0b14f662860dbc044019d412daddc6a829295924f85c4e7b7101da",
+ "timestamp" : "1429004711",
+ "transactionsTrie" : "9e505dd92006df553633480898c3537610f4e1ca8be71f8a7c534dad05429de4",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a09b63fb821942960d3ec351b38a9a2d8796b9d51a5bf7fbaefa4deb7abc138ed7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0983a9e4cad0b14f662860dbc044019d412daddc6a829295924f85c4e7b7101daa09e505dd92006df553633480898c3537610f4e1ca8be71f8a7c534dad05429de4a0c5c1da2c8329bb971f07e54ce5c2a3f7eab44a28e4fdc2e6c0e6ec2ba6d63b56b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302018007832fefd882546484552ce1a780a09818d7d7c4221b127378a6971b6f6116f2cfa5fc5c63fe732a933cc407a69cb4880fb803aef0a13676f866f86406018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8438cc48311ba02cd2d63604fd324d7edd46fd1e8dfbd1da550af4b5f4e1c3688ea57e33878ec7a0fc29ab71ac7371039268a4bda0bbd673303ca5361ec2a91487252e6421489e85c0",
+ "transactions" : [
+ {
+ "data" : "0x38cc4831",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "6",
+ "r" : "0x2cd2d63604fd324d7edd46fd1e8dfbd1da550af4b5f4e1c3688ea57e33878ec7",
+ "s" : "0xfc29ab71ac7371039268a4bda0bbd673303ca5361ec2a91487252e6421489e85",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131520",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21523",
+ "hash" : "aa6d0e41c4996ec1033245e02296f1a0df03d3200beb957285b6a65b5a9dba5b",
+ "mixHash" : "beb2674b3107a6b74ff40cb13ea25baa73917f9b18f7785bc7a117996bad3fa0",
+ "nonce" : "c88ee1220784044e",
+ "number" : "8",
+ "parentHash" : "00a7996b43ac2273954e6a5f122d979197a14fd4b250773f7f3b8a670b84fb26",
+ "receiptTrie" : "8160022d1a4e98d5cf9c23a36fbca1dbc470b02292dfffbe38bf800cd4733e56",
+ "stateRoot" : "2523f12f347cc0c4d53e2a5a5c7328c984fb8ae567ae0ceb1d508f0e618ea6c1",
+ "timestamp" : "1429004712",
+ "transactionsTrie" : "24e3b22bfbc257c4aa4ca8462c0eccaadd3d131ee52bd3d43819de054beac865",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a000a7996b43ac2273954e6a5f122d979197a14fd4b250773f7f3b8a670b84fb26a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a02523f12f347cc0c4d53e2a5a5c7328c984fb8ae567ae0ceb1d508f0e618ea6c1a024e3b22bfbc257c4aa4ca8462c0eccaadd3d131ee52bd3d43819de054beac865a08160022d1a4e98d5cf9c23a36fbca1dbc470b02292dfffbe38bf800cd4733e56b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830201c008832fefd882541384552ce1a880a0beb2674b3107a6b74ff40cb13ea25baa73917f9b18f7785bc7a117996bad3fa088c88ee1220784044ef866f86407018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a841f9030371ba0e75d4dff1ad0769a064f48e0f1c21e15ad586dbc76888d2862dc36d05c57c9c0a099f18a294d6ec839c4ca50a61ac706f1153992a5504afcabf3418db85c4b6117c0",
+ "transactions" : [
+ {
+ "data" : "0x1f903037",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "7",
+ "r" : "0xe75d4dff1ad0769a064f48e0f1c21e15ad586dbc76888d2862dc36d05c57c9c0",
+ "s" : "0x99f18a294d6ec839c4ca50a61ac706f1153992a5504afcabf3418db85c4b6117",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131584",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "41720",
+ "hash" : "de3d5f641cd7851ad1e4f34c548b07ac70a7f8d18a4331089c889cb2bcc687be",
+ "mixHash" : "7fe4aca3224a4630aeba27f7bea440272eaef4f17f303b9d96a6f13383f69163",
+ "nonce" : "b39f90f6704f196e",
+ "number" : "9",
+ "parentHash" : "aa6d0e41c4996ec1033245e02296f1a0df03d3200beb957285b6a65b5a9dba5b",
+ "receiptTrie" : "e608a90ed76468ef4df25f29fedfcdbccd1ea6046ec812f677bf8928e14cb711",
+ "stateRoot" : "89204c534dd7921536998786a3747bf3d4163cf991b89b2c3266ba9acd173e77",
+ "timestamp" : "1429004715",
+ "transactionsTrie" : "2e85b4dac28e9d6e0673c72fd5afc961f25dfb409d087b10f63784e5f4f7ba19",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0aa6d0e41c4996ec1033245e02296f1a0df03d3200beb957285b6a65b5a9dba5ba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a089204c534dd7921536998786a3747bf3d4163cf991b89b2c3266ba9acd173e77a02e85b4dac28e9d6e0673c72fd5afc961f25dfb409d087b10f63784e5f4f7ba19a0e608a90ed76468ef4df25f29fedfcdbccd1ea6046ec812f677bf8928e14cb711b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302020009832fefd882a2f884552ce1ab80a07fe4aca3224a4630aeba27f7bea440272eaef4f17f303b9d96a6f13383f6916388b39f90f6704f196ef886f88408018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa41e26fd3300000000000000000000000000000000000000000000000000000000000000011ba06e5aa30e95cebeddb708b05d03088d0c9c3c56fc85283d5b7854e9a0c701ee4fa03b58f89921001d4e7790528c52db31cef56cee213ff48a4a034a28d19f4a15eec0",
+ "transactions" : [
+ {
+ "data" : "0x1e26fd330000000000000000000000000000000000000000000000000000000000000001",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "8",
+ "r" : "0x6e5aa30e95cebeddb708b05d03088d0c9c3c56fc85283d5b7854e9a0c701ee4f",
+ "s" : "0x3b58f89921001d4e7790528c52db31cef56cee213ff48a4a034a28d19f4a15ee",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131648",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "26720",
+ "hash" : "2aceecd0f649d00aabbda9610ca5373fd2732386e04dbd82b0f4fed74783547b",
+ "mixHash" : "9a13b1347a23b9fd2b7e2a3d48dab57f505dda26c938e8b99480e9a0ece3e306",
+ "nonce" : "10e262696a045586",
+ "number" : "10",
+ "parentHash" : "de3d5f641cd7851ad1e4f34c548b07ac70a7f8d18a4331089c889cb2bcc687be",
+ "receiptTrie" : "943ee48ebe9c45702f84e8e651e1c474cd56d6bbbe6b634bcf16927941370bbb",
+ "stateRoot" : "cfd0e1aef82103416fdab738034df60a7e5fc4a08b2f347ed518a62420a46c8d",
+ "timestamp" : "1429004717",
+ "transactionsTrie" : "948b061d7d11e89f295610b19c1cad1ba903f42ec183e0b147df1dc79ab29628",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0de3d5f641cd7851ad1e4f34c548b07ac70a7f8d18a4331089c889cb2bcc687bea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cfd0e1aef82103416fdab738034df60a7e5fc4a08b2f347ed518a62420a46c8da0948b061d7d11e89f295610b19c1cad1ba903f42ec183e0b147df1dc79ab29628a0943ee48ebe9c45702f84e8e651e1c474cd56d6bbbe6b634bcf16927941370bbbb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202400a832fefd882686084552ce1ad80a09a13b1347a23b9fd2b7e2a3d48dab57f505dda26c938e8b99480e9a0ece3e3068810e262696a045586f886f88409018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa41e26fd3300000000000000000000000000000000000000000000000000000000000000011ca0edb2e0e735c7c6d6e09cdbfecc47cc978b53b5e5243101c9b6eefed81ef6adaca0edeac497f009e4d8034c22be789838f1cf429d9f09f0c512f20755919e2813a3c0",
+ "transactions" : [
+ {
+ "data" : "0x1e26fd330000000000000000000000000000000000000000000000000000000000000001",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "9",
+ "r" : "0xedb2e0e735c7c6d6e09cdbfecc47cc978b53b5e5243101c9b6eefed81ef6adac",
+ "s" : "0xedeac497f009e4d8034c22be789838f1cf429d9f09f0c512f20755919e2813a3",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131584",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "27376",
+ "hash" : "bc01dbdbb0fe22c4a4da081fec42a7b43c3c467d0648193e39ecb3047cfbde5f",
+ "mixHash" : "f578795dc6db8ee995b198fbf7f9785f4a07bb6e405f11dd5d529d60307dd930",
+ "nonce" : "d4423264b25b2e04",
+ "number" : "11",
+ "parentHash" : "2aceecd0f649d00aabbda9610ca5373fd2732386e04dbd82b0f4fed74783547b",
+ "receiptTrie" : "342a33c2ea332772c41939a0fccaed8060d224a086d1bb829c3e7c4816f60518",
+ "stateRoot" : "8938cdb3e5ae973bde941090c5f5ef6101bdd8846e78b682e3b5f1a60c9a72c4",
+ "timestamp" : "1429004725",
+ "transactionsTrie" : "aeb6508b9fbbe19c983002636f383002596ca0329575832f1140082e273cbb7f",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a02aceecd0f649d00aabbda9610ca5373fd2732386e04dbd82b0f4fed74783547ba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a08938cdb3e5ae973bde941090c5f5ef6101bdd8846e78b682e3b5f1a60c9a72c4a0aeb6508b9fbbe19c983002636f383002596ca0329575832f1140082e273cbb7fa0342a33c2ea332772c41939a0fccaed8060d224a086d1bb829c3e7c4816f60518b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202000b832fefd8826af084552ce1b580a0f578795dc6db8ee995b198fbf7f9785f4a07bb6e405f11dd5d529d60307dd93088d4423264b25b2e04f886f8840a018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa49a19a953000000000000000000000000000000000000000000000000fffffffffffffffa1ca0560a12b6c35ee2ff44fb85a8c86ba05b7beb784dc007b6cb282f2f4aa4baa3dda0099db7dd1bd8f551b25bd3eb40ee5b573183745d8b62a711501f55a856b1b003c0",
+ "transactions" : [
+ {
+ "data" : "0x9a19a953000000000000000000000000000000000000000000000000fffffffffffffffa",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "10",
+ "r" : "0x560a12b6c35ee2ff44fb85a8c86ba05b7beb784dc007b6cb282f2f4aa4baa3dd",
+ "s" : "0x099db7dd1bd8f551b25bd3eb40ee5b573183745d8b62a711501f55a856b1b003",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131648",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "26708",
+ "hash" : "c129a959d86bca41268c97264d2455d146800dce07d1c7d148b6e6cf6f99a014",
+ "mixHash" : "829aa7169b53d2b5f51a3f3e195b03955b91295f86f6066a3e81a973b04e55c0",
+ "nonce" : "3ffeff9eb37117d9",
+ "number" : "12",
+ "parentHash" : "bc01dbdbb0fe22c4a4da081fec42a7b43c3c467d0648193e39ecb3047cfbde5f",
+ "receiptTrie" : "b6de692a098ce57141a2098b3c7d29a5accf2360e0a0737f40ae535bca741e86",
+ "stateRoot" : "31eba56ed7b7f89f50ed728d733379c664f45f720b1cb6e9f1527447ebffef6f",
+ "timestamp" : "1429004726",
+ "transactionsTrie" : "12184c02bd2be61c605f0fe1e8ce473dffec02dabe6e2b673fa44c5960d4d8ce",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0bc01dbdbb0fe22c4a4da081fec42a7b43c3c467d0648193e39ecb3047cfbde5fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a031eba56ed7b7f89f50ed728d733379c664f45f720b1cb6e9f1527447ebffef6fa012184c02bd2be61c605f0fe1e8ce473dffec02dabe6e2b673fa44c5960d4d8cea0b6de692a098ce57141a2098b3c7d29a5accf2360e0a0737f40ae535bca741e86b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202400c832fefd882685484552ce1b680a0829aa7169b53d2b5f51a3f3e195b03955b91295f86f6066a3e81a973b04e55c0883ffeff9eb37117d9f886f8840b018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa41774e64600000000000000000000000000000000000000000000000000000000000000081ca084f856b4c899f50ab60ca8a752a08569ba214698a7b913121adebe49376840c2a0bd778b92a0e68be99825befdee1e9368b690cf5c11e67fff1eb0cfa8f116fdc7c0",
+ "transactions" : [
+ {
+ "data" : "0x1774e6460000000000000000000000000000000000000000000000000000000000000008",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "11",
+ "r" : "0x84f856b4c899f50ab60ca8a752a08569ba214698a7b913121adebe49376840c2",
+ "s" : "0xbd778b92a0e68be99825befdee1e9368b690cf5c11e67fff1eb0cfa8f116fdc7",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131584",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "43854",
+ "hash" : "ec09b6f925c75c823969d42c091ca005b9ba67dc1516bcbb396e7c931827777a",
+ "mixHash" : "93dc3a7ce3d6c4ca827ed325b2e8b6575248b8e9dbc8a607351135059cc39d50",
+ "nonce" : "857c6247a8ac3f6e",
+ "number" : "13",
+ "parentHash" : "c129a959d86bca41268c97264d2455d146800dce07d1c7d148b6e6cf6f99a014",
+ "receiptTrie" : "215275b1fa435c25fc6d9effc1a1955fc89da60b538965a52c4ea9ea153a7476",
+ "stateRoot" : "8cfae5db6ae801da16de946a2f357d28a11700bccd65c71dd9e25018a444858d",
+ "timestamp" : "1429004736",
+ "transactionsTrie" : "dc4a8f1c6497890460d66b0e5b7c9ca90d630b5a9c6f4fd13e5ed71e7e99df85",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0c129a959d86bca41268c97264d2455d146800dce07d1c7d148b6e6cf6f99a014a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a08cfae5db6ae801da16de946a2f357d28a11700bccd65c71dd9e25018a444858da0dc4a8f1c6497890460d66b0e5b7c9ca90d630b5a9c6f4fd13e5ed71e7e99df85a0215275b1fa435c25fc6d9effc1a1955fc89da60b538965a52c4ea9ea153a7476b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202000d832fefd882ab4e84552ce1c080a093dc3a7ce3d6c4ca827ed325b2e8b6575248b8e9dbc8a607351135059cc39d5088857c6247a8ac3f6ef886f8840c018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa4a53b1c1effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee1ca0897f91eab94c25f16d9d41deb83169d99f2e68c07fd0750072c949ce722a46dca0849cefc9d0ef4f091e7c227ce250a6192f62fca2909381e305a617a2af04c4a2c0",
+ "transactions" : [
+ {
+ "data" : "0xa53b1c1effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "12",
+ "r" : "0x897f91eab94c25f16d9d41deb83169d99f2e68c07fd0750072c949ce722a46dc",
+ "s" : "0x849cefc9d0ef4f091e7c227ce250a6192f62fca2909381e305a617a2af04c4a2",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131648",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "43942",
+ "hash" : "34ebe8ddef75030fe2c7a29a8455268d368774cbe79fcf51d6c86af14d54be75",
+ "mixHash" : "d6665a934791183a38a07655ecaf257bcec95d4ff0119e336c04109302a9c995",
+ "nonce" : "93476c671a2c9c7d",
+ "number" : "14",
+ "parentHash" : "ec09b6f925c75c823969d42c091ca005b9ba67dc1516bcbb396e7c931827777a",
+ "receiptTrie" : "3e621ae0aee0740df46d8540d30b317fd8dabf3509e98a53b578056162357634",
+ "stateRoot" : "94a9b67506c9435ea50d858c2f38384ce4e7afbbd631aa7765908879a9a9be7a",
+ "timestamp" : "1429004737",
+ "transactionsTrie" : "6b33cad487b6050c8808872804bb6563b3dec32969aa44d897f159788482fb11",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0ec09b6f925c75c823969d42c091ca005b9ba67dc1516bcbb396e7c931827777aa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a094a9b67506c9435ea50d858c2f38384ce4e7afbbd631aa7765908879a9a9be7aa06b33cad487b6050c8808872804bb6563b3dec32969aa44d897f159788482fb11a03e621ae0aee0740df46d8540d30b317fd8dabf3509e98a53b578056162357634b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202400e832fefd882aba684552ce1c180a0d6665a934791183a38a07655ecaf257bcec95d4ff0119e336c04109302a9c9958893476c671a2c9c7df886f8840d018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa4d2282dc5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee1ba06fdf27c6540317d089fcee1aef2ed2dd80b6acdc655514330c6f3248742095f3a08f62259a525d491eaae85c4b302fb5780e5475f3f94de7308b1f73bd4c4a08b9c0",
+ "transactions" : [
+ {
+ "data" : "0xd2282dc5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "13",
+ "r" : "0x6fdf27c6540317d089fcee1aef2ed2dd80b6acdc655514330c6f3248742095f3",
+ "s" : "0x8f62259a525d491eaae85c4b302fb5780e5475f3f94de7308b1f73bd4c4a08b9",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131712",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "43992",
+ "hash" : "093c89c9c2434c74c581aecb0d088667ded6761cba877a84bc72e755db792731",
+ "mixHash" : "2be64475c5f710aec25b508f3bbbd89ddcd42645557ef8ac9b4200c0a1df00b9",
+ "nonce" : "717ada6959ee7576",
+ "number" : "15",
+ "parentHash" : "34ebe8ddef75030fe2c7a29a8455268d368774cbe79fcf51d6c86af14d54be75",
+ "receiptTrie" : "1eecc45290aeb42700f81bf2c739ecdffd26fe148a0cbb76c34f1da9e00d5e19",
+ "stateRoot" : "583c53bfd9e2aec63f8fb0653e18ca226b792b3955150045c3970ff66b547846",
+ "timestamp" : "1429004740",
+ "transactionsTrie" : "ab2277046a1ac522e908b1fe3154747e3d89db50d9ba1c84bd6c964775c42db9",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a034ebe8ddef75030fe2c7a29a8455268d368774cbe79fcf51d6c86af14d54be75a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0583c53bfd9e2aec63f8fb0653e18ca226b792b3955150045c3970ff66b547846a0ab2277046a1ac522e908b1fe3154747e3d89db50d9ba1c84bd6c964775c42db9a01eecc45290aeb42700f81bf2c739ecdffd26fe148a0cbb76c34f1da9e00d5e19b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202800f832fefd882abd884552ce1c480a02be64475c5f710aec25b508f3bbbd89ddcd42645557ef8ac9b4200c0a1df00b988717ada6959ee7576f886f8840e018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa4e30081a0aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee1ba091c093358ec71426833a98d5b1213552f01b6235cfff072cedd7d99438549f2fa01a5f8491cdd5ace9b8e2b5e2e0fd2e5bb6a0beabd305c26eacfc059560112002c0",
+ "transactions" : [
+ {
+ "data" : "0xe30081a0aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "14",
+ "r" : "0x91c093358ec71426833a98d5b1213552f01b6235cfff072cedd7d99438549f2f",
+ "s" : "0x1a5f8491cdd5ace9b8e2b5e2e0fd2e5bb6a0beabd305c26eacfc059560112002",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131776",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "43920",
+ "hash" : "3ff47db8d46f611d2840303838a7e6d7326e5fb5f94d6a520da2e0bea645f273",
+ "mixHash" : "60dbb8a3641d3f26b23b7b03f1e37cf6874febe9092fcd385508ee3bb13ed7d4",
+ "nonce" : "5a973f3d75839249",
+ "number" : "16",
+ "parentHash" : "093c89c9c2434c74c581aecb0d088667ded6761cba877a84bc72e755db792731",
+ "receiptTrie" : "d9373facb2e79bbd00157bf6709ed03c2bc5ca388b945c684d8c70ca3e567035",
+ "stateRoot" : "ae7548305896855e4cb7d578c857ac89272514ddcb35fc9919edf3976f5e68c4",
+ "timestamp" : "1429004741",
+ "transactionsTrie" : "03b9aa3e00baa725d7af65ded115652b11f47797d6392367adf216277ee0c962",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90285f901f9a0093c89c9c2434c74c581aecb0d088667ded6761cba877a84bc72e755db792731a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ae7548305896855e4cb7d578c857ac89272514ddcb35fc9919edf3976f5e68c4a003b9aa3e00baa725d7af65ded115652b11f47797d6392367adf216277ee0c962a0d9373facb2e79bbd00157bf6709ed03c2bc5ca388b945c684d8c70ca3e567035b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830202c010832fefd882ab9084552ce1c580a060dbb8a3641d3f26b23b7b03f1e37cf6874febe9092fcd385508ee3bb13ed7d4885a973f3d75839249f886f8840f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0aa4c2b12a73aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee1ba01fa9dfbc6dde2348036c12585e5f5074054c02d483ddb4d7263c955d118f0078a0839fa94cd6b47060346d85025dd2c75e780e4509ccfce611afe2b1c438a86fadc0",
+ "transactions" : [
+ {
+ "data" : "0xc2b12a73aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "15",
+ "r" : "0x1fa9dfbc6dde2348036c12585e5f5074054c02d483ddb4d7263c955d118f0078",
+ "s" : "0x839fa94cd6b47060346d85025dd2c75e780e4509ccfce611afe2b1c438a86fad",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131840",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21660",
+ "hash" : "0ec7986c2e538fc267d21f2c0df3c247cd07700add387b2165f4844ecf32b014",
+ "mixHash" : "9646aa8b33db0e5151d53a90b95272ffc6003f2ff4fbd3f77b14aae0066e15c2",
+ "nonce" : "04e4b54b58127d63",
+ "number" : "17",
+ "parentHash" : "3ff47db8d46f611d2840303838a7e6d7326e5fb5f94d6a520da2e0bea645f273",
+ "receiptTrie" : "8e44e3bc071a29e5582d4c5f5511e1c11afdd6a323129c7014dda056a5496f75",
+ "stateRoot" : "de9e1c30a472ad1fbade66e4ce7e3bf3ff5200821dbd9ef740d4778f7919fddb",
+ "timestamp" : "1429004742",
+ "transactionsTrie" : "0c8b670e996f826f7cde28f230a7b920748598c548452e251c5f50599481e20a",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a03ff47db8d46f611d2840303838a7e6d7326e5fb5f94d6a520da2e0bea645f273a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0de9e1c30a472ad1fbade66e4ce7e3bf3ff5200821dbd9ef740d4778f7919fddba00c8b670e996f826f7cde28f230a7b920748598c548452e251c5f50599481e20aa08e44e3bc071a29e5582d4c5f5511e1c11afdd6a323129c7014dda056a5496f75b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302030011832fefd882549c84552ce1c680a09646aa8b33db0e5151d53a90b95272ffc6003f2ff4fbd3f77b14aae0066e15c28804e4b54b58127d63f866f86410018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8457cb2fc41ba0e7b73f420c3df9519d32ce22db9f71bbbc90b1be7bc34145b1650ae318a380d5a08cdac8ac35262bcc260fc97f2313bafc4ebe20b61f35a834bd8875b418c81039c0",
+ "transactions" : [
+ {
+ "data" : "0x57cb2fc4",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "16",
+ "r" : "0xe7b73f420c3df9519d32ce22db9f71bbbc90b1be7bc34145b1650ae318a380d5",
+ "s" : "0x8cdac8ac35262bcc260fc97f2313bafc4ebe20b61f35a834bd8875b418c81039",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131904",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21592",
+ "hash" : "0ab4770f08467b0f94107c8eb48673f6f01cae71f7f5a04e07ee3051f092e05c",
+ "mixHash" : "99d9ce3faf4688a7751a1904dcf376eaf0f99b185348a2e113c8cd81cdc74326",
+ "nonce" : "ee3865e70ca67d89",
+ "number" : "18",
+ "parentHash" : "0ec7986c2e538fc267d21f2c0df3c247cd07700add387b2165f4844ecf32b014",
+ "receiptTrie" : "6c6a23aa68882b1d882407f3c69215bf2a285d8adbe46b18747b4a1f92882850",
+ "stateRoot" : "d883dfc1ad76c6ecff5225bd1f0f48f136ed7259e65cbf978b59700cdf55f56e",
+ "timestamp" : "1429004743",
+ "transactionsTrie" : "84184d640fe4f4061f22247312946d147f7c31621838c2753d062c5e310a62d2",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a00ec7986c2e538fc267d21f2c0df3c247cd07700add387b2165f4844ecf32b014a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0d883dfc1ad76c6ecff5225bd1f0f48f136ed7259e65cbf978b59700cdf55f56ea084184d640fe4f4061f22247312946d147f7c31621838c2753d062c5e310a62d2a06c6a23aa68882b1d882407f3c69215bf2a285d8adbe46b18747b4a1f92882850b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302034012832fefd882545884552ce1c780a099d9ce3faf4688a7751a1904dcf376eaf0f99b185348a2e113c8cd81cdc7432688ee3865e70ca67d89f866f86411018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84343a875d1ca06dbe0cda8ddef16b219906acbfb10ec2f699fe718a4cd1a9805d662a06efe85aa0e2ae9a0febdf18340ac33afb093c0c3395634db92d7d417877deb9d5479562eac0",
+ "transactions" : [
+ {
+ "data" : "0x343a875d",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "17",
+ "r" : "0x6dbe0cda8ddef16b219906acbfb10ec2f699fe718a4cd1a9805d662a06efe85a",
+ "s" : "0xe2ae9a0febdf18340ac33afb093c0c3395634db92d7d417877deb9d5479562ea",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131968",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21919",
+ "hash" : "4e8553ae510704c34efe4c414a8deb363712ad602d339c909ba9959c38aa5ceb",
+ "mixHash" : "2c909097fea276939ccc407ba79fb737dd93813096ab18463ec387606e724b49",
+ "nonce" : "85ff2623c92350db",
+ "number" : "19",
+ "parentHash" : "0ab4770f08467b0f94107c8eb48673f6f01cae71f7f5a04e07ee3051f092e05c",
+ "receiptTrie" : "bd05b74e4382ed04d48345c21c066e8e44497c5e7c17ed16fe6d09c5a83d1f4f",
+ "stateRoot" : "8699975a29cb76335bf43d7b5e28753c39d39cf620ef8b654eb76b4314ffdf0f",
+ "timestamp" : "1429004746",
+ "transactionsTrie" : "e9dbe96409fc875b8d7a248d0b59234506c16dc99115f99369f11155d4159d81",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a00ab4770f08467b0f94107c8eb48673f6f01cae71f7f5a04e07ee3051f092e05ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a08699975a29cb76335bf43d7b5e28753c39d39cf620ef8b654eb76b4314ffdf0fa0e9dbe96409fc875b8d7a248d0b59234506c16dc99115f99369f11155d4159d81a0bd05b74e4382ed04d48345c21c066e8e44497c5e7c17ed16fe6d09c5a83d1f4fb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302038013832fefd882559f84552ce1ca80a02c909097fea276939ccc407ba79fb737dd93813096ab18463ec387606e724b498885ff2623c92350dbf866f86412018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84f5b53e171ba0ff48f6e0fc4369873fb45f3628f8d71698917b6a4abcd6780ca47338d1d8ddb0a07056f2c9a77d2abd807f6429b9e81c79d11df1c1c08601aee488686d8d002fb1c0",
+ "transactions" : [
+ {
+ "data" : "0xf5b53e17",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "18",
+ "r" : "0xff48f6e0fc4369873fb45f3628f8d71698917b6a4abcd6780ca47338d1d8ddb0",
+ "s" : "0x7056f2c9a77d2abd807f6429b9e81c79d11df1c1c08601aee488686d8d002fb1",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132032",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21655",
+ "hash" : "18a0cd0f616629e7e0a39be6c3cafe4957777d38aa29d8621726a0a63e03a5d2",
+ "mixHash" : "913606239306caf707adcb5c46552bf312eb2615bc959539e14be1a3bb7883ce",
+ "nonce" : "e96e0cce4856a3c6",
+ "number" : "20",
+ "parentHash" : "4e8553ae510704c34efe4c414a8deb363712ad602d339c909ba9959c38aa5ceb",
+ "receiptTrie" : "0feee313dff69cadd6bc4988339bd7d99326caa7395163f3173e438ec608c83b",
+ "stateRoot" : "68990c875a01db9f0f1acd09b7479b800b86a2139702f2eb91fe2eb007ee9493",
+ "timestamp" : "1429004747",
+ "transactionsTrie" : "a2d1ece8a32a84a7ab8958d24468961fcbd20e5a2be8d69cdc059c292b9a0e54",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a04e8553ae510704c34efe4c414a8deb363712ad602d339c909ba9959c38aa5ceba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a068990c875a01db9f0f1acd09b7479b800b86a2139702f2eb91fe2eb007ee9493a0a2d1ece8a32a84a7ab8958d24468961fcbd20e5a2be8d69cdc059c292b9a0e54a00feee313dff69cadd6bc4988339bd7d99326caa7395163f3173e438ec608c83bb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830203c014832fefd882549784552ce1cb80a0913606239306caf707adcb5c46552bf312eb2615bc959539e14be1a3bb7883ce88e96e0cce4856a3c6f866f86413018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84688959791ca070be89f7186d8afdfbd86b921f0bb091f8bf8a105c305b92cf8ba7eccf0033dea084ae5df287a3cb51a2ab81e2436af681a78b90d6845186a621576a5a3fdee8f0c0",
+ "transactions" : [
+ {
+ "data" : "0x68895979",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "19",
+ "r" : "0x70be89f7186d8afdfbd86b921f0bb091f8bf8a105c305b92cf8ba7eccf0033de",
+ "s" : "0x84ae5df287a3cb51a2ab81e2436af681a78b90d6845186a621576a5a3fdee8f0",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132096",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21604",
+ "hash" : "c61434d42697ea5fd2cecb9c0b59fe0b54829761bc54749a3df1dab5ff1a985e",
+ "mixHash" : "bf830d012810c9e2c5fd9f1965adf4f16230309e0223223282bbc13bfce90f23",
+ "nonce" : "c7f5c151fb34cda9",
+ "number" : "21",
+ "parentHash" : "18a0cd0f616629e7e0a39be6c3cafe4957777d38aa29d8621726a0a63e03a5d2",
+ "receiptTrie" : "db1b241e0c2c9bdf83529adf47b81a5575050b6dd2b007185dbcb6283adfbc57",
+ "stateRoot" : "eb177989399cd8c9aa556f83e2e9699b17ae97798a571f0c39cdbca5f0a82b86",
+ "timestamp" : "1429004749",
+ "transactionsTrie" : "f64f6f29ecca7997bdc840200ed10728035eb6cb4cf9e3d3bb964d848a8dab66",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a018a0cd0f616629e7e0a39be6c3cafe4957777d38aa29d8621726a0a63e03a5d2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0eb177989399cd8c9aa556f83e2e9699b17ae97798a571f0c39cdbca5f0a82b86a0f64f6f29ecca7997bdc840200ed10728035eb6cb4cf9e3d3bb964d848a8dab66a0db1b241e0c2c9bdf83529adf47b81a5575050b6dd2b007185dbcb6283adfbc57b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302040015832fefd882546484552ce1cd80a0bf830d012810c9e2c5fd9f1965adf4f16230309e0223223282bbc13bfce90f2388c7f5c151fb34cda9f866f86414018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8438cc48311ba027b55041cecd38aaf0cd82bc4a15b3243ecb302403c64f23abb1e8e424b6745aa0c6541ce67c47be3df3923b8326ced2f21f7ef2d1297113a6d979817b2ffcfcb8c0",
+ "transactions" : [
+ {
+ "data" : "0x38cc4831",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "20",
+ "r" : "0x27b55041cecd38aaf0cd82bc4a15b3243ecb302403c64f23abb1e8e424b6745a",
+ "s" : "0xc6541ce67c47be3df3923b8326ced2f21f7ef2d1297113a6d979817b2ffcfcb8",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132160",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "21523",
+ "hash" : "fe6dec0a580574c23add8f05b6833a8fbba9a6035926df3f5eb3422eb1b46735",
+ "mixHash" : "1b0b1da7842539a9acb2d6aa75a4c817cba127e5a2fe002a8a56a92c4c251f63",
+ "nonce" : "c14011b2f0a4e25f",
+ "number" : "22",
+ "parentHash" : "c61434d42697ea5fd2cecb9c0b59fe0b54829761bc54749a3df1dab5ff1a985e",
+ "receiptTrie" : "6c2cc9e9eba3a56e3c1ce1516bbc0b1dae0caf33d1a1f62571db993a21ed2484",
+ "stateRoot" : "975ac0d3406ec7168df1437c895a806b3c69f8399da40da99cea18e62baa0ac1",
+ "timestamp" : "1429004751",
+ "transactionsTrie" : "fa2c50ecc8b96584eb95d1338c4694ece59e29cd86636ff20ad47a0f74a5f4c6",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0c61434d42697ea5fd2cecb9c0b59fe0b54829761bc54749a3df1dab5ff1a985ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0975ac0d3406ec7168df1437c895a806b3c69f8399da40da99cea18e62baa0ac1a0fa2c50ecc8b96584eb95d1338c4694ece59e29cd86636ff20ad47a0f74a5f4c6a06c2cc9e9eba3a56e3c1ce1516bbc0b1dae0caf33d1a1f62571db993a21ed2484b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302044016832fefd882541384552ce1cf80a01b0b1da7842539a9acb2d6aa75a4c817cba127e5a2fe002a8a56a92c4c251f6388c14011b2f0a4e25ff866f86415018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a841f9030371ca075e99646ce6ffe6ecf237928ae3f9015add6e2672b21874400c13646241fc4f6a0a65798219de6ab28c65e7bbea31aec363d48220a752dac5b31011138f2b5d7b3c0",
+ "transactions" : [
+ {
+ "data" : "0x1f903037",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "21",
+ "r" : "0x75e99646ce6ffe6ecf237928ae3f9015add6e2672b21874400c13646241fc4f6",
+ "s" : "0xa65798219de6ab28c65e7bbea31aec363d48220a752dac5b31011138f2b5d7b3",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000020000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132224",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "22574",
+ "hash" : "ca80200a53fae63ce61c0a60c6ed90dd01d61c87ee9defc92210632d85c96938",
+ "mixHash" : "437d0f173ab75db1ed9a6983e1ec9ffa0d509a2a21f462680928a05b56b902e3",
+ "nonce" : "5a8aeab223ca04b7",
+ "number" : "23",
+ "parentHash" : "fe6dec0a580574c23add8f05b6833a8fbba9a6035926df3f5eb3422eb1b46735",
+ "receiptTrie" : "710f9e35ca93745f53a0fb86299eb59ee7f0f776157bf6acf4f49dffb97d3d8d",
+ "stateRoot" : "876329a3ef6776a2f803052b97c95c92b3ad890d31f3b3a876ca5365464245c4",
+ "timestamp" : "1429004752",
+ "transactionsTrie" : "b25245e9dbd551ba7b89b31db73a05385cd80097918ac8c482687ca20322e431",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0fe6dec0a580574c23add8f05b6833a8fbba9a6035926df3f5eb3422eb1b46735a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0876329a3ef6776a2f803052b97c95c92b3ad890d31f3b3a876ca5365464245c4a0b25245e9dbd551ba7b89b31db73a05385cd80097918ac8c482687ca20322e431a0710f9e35ca93745f53a0fb86299eb59ee7f0f776157bf6acf4f49dffb97d3d8db90100000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000020000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000200000000008302048017832fefd882582e84552ce1d080a0437d0f173ab75db1ed9a6983e1ec9ffa0d509a2a21f462680928a05b56b902e3885a8aeab223ca04b7f866f86416018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8465538c731ca06e41d6836a07c9eafdf43ee0104171be085cfc51a9b3aeed9b5526686f8a3aeea07aa96d52a0d272f550396600bd48b569c77261a06ef576370644e456c4fe6a7ec0",
+ "transactions" : [
+ {
+ "data" : "0x65538c73",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "22",
+ "r" : "0x6e41d6836a07c9eafdf43ee0104171be085cfc51a9b3aeed9b5526686f8a3aee",
+ "s" : "0x7aa96d52a0d272f550396600bd48b569c77261a06ef576370644e456c4fe6a7e",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132288",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "22328",
+ "hash" : "e8c22cfb77aa8ae1c5349f83207f095df1d1bbd1f3472721cd992d6f1000674a",
+ "mixHash" : "6778b006216d5f2759cbf1acde9c8e7b7c39a68f22723efdca3acc7588e795bd",
+ "nonce" : "3af599d85d399e3f",
+ "number" : "24",
+ "parentHash" : "ca80200a53fae63ce61c0a60c6ed90dd01d61c87ee9defc92210632d85c96938",
+ "receiptTrie" : "73703b5d2d8be77b5a83e1b80ecd591caee081695037040f43f1bc998eaf7e7b",
+ "stateRoot" : "56a7bc66a3bf7478216413fe1968e63df4db7ef22debbe3128e915ec88ba4e39",
+ "timestamp" : "1429004754",
+ "transactionsTrie" : "1f121207f9ccad4f4280813e8a3ce4dd0a2f8908c79ff67dddc71d923c504d4c",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0ca80200a53fae63ce61c0a60c6ed90dd01d61c87ee9defc92210632d85c96938a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a056a7bc66a3bf7478216413fe1968e63df4db7ef22debbe3128e915ec88ba4e39a01f121207f9ccad4f4280813e8a3ce4dd0a2f8908c79ff67dddc71d923c504d4ca073703b5d2d8be77b5a83e1b80ecd591caee081695037040f43f1bc998eaf7e7bb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000830204c018832fefd882573884552ce1d280a06778b006216d5f2759cbf1acde9c8e7b7c39a68f22723efdca3acc7588e795bd883af599d85d399e3ff866f86417018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84a67808571ca067f21d170a87e5150e065014acc642f89f9e999cc951108944ee8e2fbefaa2c9a0c3deb69a55d15053b2381749e2c67f1c20ad02cb7a75e2c75a7a5dcce395cf73c0",
+ "transactions" : [
+ {
+ "data" : "0xa6780857",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "23",
+ "r" : "0x67f21d170a87e5150e065014acc642f89f9e999cc951108944ee8e2fbefaa2c9",
+ "s" : "0xc3deb69a55d15053b2381749e2c67f1c20ad02cb7a75e2c75a7a5dcce395cf73",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000002000000000000000100000000000000000000000000000000000000000000000000000000000800000000040000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132352",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23106",
+ "hash" : "f715a597e843da8061fa43282541c9f06603e0367352fec8ea1558c0d65b5307",
+ "mixHash" : "545a4662c8c9e2a1390e2e4cf197a808c32671b31d2152199e9c742ef0de7409",
+ "nonce" : "21ed5b1c78e8b948",
+ "number" : "25",
+ "parentHash" : "e8c22cfb77aa8ae1c5349f83207f095df1d1bbd1f3472721cd992d6f1000674a",
+ "receiptTrie" : "3b0a06e82c9b3e06cb069495c804bec6dba7ee65f250c945e727c01d20f3e05e",
+ "stateRoot" : "6df045d624470facb76b7449e4a0ef3a2b95c17e699ba46ae458029f2aa75b22",
+ "timestamp" : "1429004755",
+ "transactionsTrie" : "2a99df259ea15e0a6fa54b65397663a042f6c3e0cc65c6bbc6456017d332b844",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0e8c22cfb77aa8ae1c5349f83207f095df1d1bbd1f3472721cd992d6f1000674aa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a06df045d624470facb76b7449e4a0ef3a2b95c17e699ba46ae458029f2aa75b22a02a99df259ea15e0a6fa54b65397663a042f6c3e0cc65c6bbc6456017d332b844a03b0a06e82c9b3e06cb069495c804bec6dba7ee65f250c945e727c01d20f3e05eb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000020000000000000000000000000000000000020000000000000001000000000000000000000000000000000000000000000000000000000008000000000400000000000000000000000000000000000000000000000000000000000000000008302050019832fefd8825a4284552ce1d380a0545a4662c8c9e2a1390e2e4cf197a808c32671b31d2152199e9c742ef0de74098821ed5b1c78e8b948f866f86418018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84b61c05031ca0b2f142cd3a3b1ee18aeffd72b9344e7487d081540e563a138fcaa77eb12e5941a056c5657569422bb591d0c8fd644adc2be0eb9249ec28eda4a9ce03700fdf4557c0",
+ "transactions" : [
+ {
+ "data" : "0xb61c0503",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "24",
+ "r" : "0xb2f142cd3a3b1ee18aeffd72b9344e7487d081540e563a138fcaa77eb12e5941",
+ "s" : "0x56c5657569422bb591d0c8fd644adc2be0eb9249ec28eda4a9ce03700fdf4557",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000040000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132416",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "22530",
+ "hash" : "b903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238",
+ "mixHash" : "9a7ceee968527ca6c5cca67c38fc66b8defaf2c7546567344702aaf660686047",
+ "nonce" : "b6d66ec69916dbdd",
+ "number" : "26",
+ "parentHash" : "f715a597e843da8061fa43282541c9f06603e0367352fec8ea1558c0d65b5307",
+ "receiptTrie" : "cacf3e4849699a6bf39509b0b319b7f0056e4fcefe47987268d2f3d7b77fefaf",
+ "stateRoot" : "39e454d17a15c1d8da2f38d63f4dabe3f0e6cc36b3c02e7fc3ae03deb56463d5",
+ "timestamp" : "1429004758",
+ "transactionsTrie" : "4defdcded18f77d2081b03626aadd716cf157516fdb9a075b4f6b763db581b75",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0f715a597e843da8061fa43282541c9f06603e0367352fec8ea1558c0d65b5307a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a039e454d17a15c1d8da2f38d63f4dabe3f0e6cc36b3c02e7fc3ae03deb56463d5a04defdcded18f77d2081b03626aadd716cf157516fdb9a075b4f6b763db581b75a0cacf3e4849699a6bf39509b0b319b7f0056e4fcefe47987268d2f3d7b77fefafb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000040000000000000000000000000000000000000000000000000000000000000000000830205401a832fefd882580284552ce1d680a09a7ceee968527ca6c5cca67c38fc66b8defaf2c7546567344702aaf66068604788b6d66ec69916dbddf866f86419018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a844e7ad3671ba044a776ad2e8170fe233a21d707bb7d7f445f6b9f0616e9a11331f85fbbe2cc9aa080166c8220a877c1e14c820ccb4d61ee1d5c6e3e9e66fc1c0fbbde053ad37630c0",
+ "transactions" : [
+ {
+ "data" : "0x4e7ad367",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "25",
+ "r" : "0x44a776ad2e8170fe233a21d707bb7d7f445f6b9f0616e9a11331f85fbbe2cc9a",
+ "s" : "0x80166c8220a877c1e14c820ccb4d61ee1d5c6e3e9e66fc1c0fbbde053ad37630",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00200000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000008000800000000040000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132480",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23137",
+ "hash" : "76397ef48a05c4aac791330025f60bf8a75a31d89d5fa20118e6715ce293cb4b",
+ "mixHash" : "7061e69d0b8ed5888cbed1fe3786e96191ddac4007ec1967a181e0c2a660d36d",
+ "nonce" : "83ab8c97b7727b45",
+ "number" : "27",
+ "parentHash" : "b903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238",
+ "receiptTrie" : "53a297c5071f572c34f358d8a792d89c5ebd6f4bad5e3d9cd6fcee3c41fa5fea",
+ "stateRoot" : "86052c49a8b3b28f5c197b0df92d0689d4d5b0d4633f1a1c1082f936a9d2dc09",
+ "timestamp" : "1429004762",
+ "transactionsTrie" : "8436346d3428dbb7f180003f86837ca64682bb6a18285a56ef4b6f08daceb214",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a0b903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a086052c49a8b3b28f5c197b0df92d0689d4d5b0d4633f1a1c1082f936a9d2dc09a08436346d3428dbb7f180003f86837ca64682bb6a18285a56ef4b6f08daceb214a053a297c5071f572c34f358d8a792d89c5ebd6f4bad5e3d9cd6fcee3c41fa5feab9010000200000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000008000800000000040000000000000000000000000000000000000000000000000000000000000000000830205801b832fefd8825a6184552ce1da80a07061e69d0b8ed5888cbed1fe3786e96191ddac4007ec1967a181e0c2a660d36d8883ab8c97b7727b45f866f8641a018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84102accc11ca0b13cb36b906c926ac449da4cfffd40d694cd3e697313b42de65069fe7c21e8b9a044fad1f1c45ae6f4e1d5600e7679e5476487a5116124fe7e7c897b2eed1b6989c0",
+ "transactions" : [
+ {
+ "data" : "0x102accc1",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "26",
+ "r" : "0xb13cb36b906c926ac449da4cfffd40d694cd3e697313b42de65069fe7c21e8b9",
+ "s" : "0x44fad1f1c45ae6f4e1d5600e7679e5476487a5116124fe7e7c897b2eed1b6989",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000040000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132416",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23001",
+ "hash" : "3409ca9c70c1e729592b8cc7845457d1bd7a319e89200af249bb517c56b3f46b",
+ "mixHash" : "10e70466b38b681289359af1cdc21c4f91516fb61fd41012bc370b0ebfbacf55",
+ "nonce" : "6f70a905f98ba732",
+ "number" : "28",
+ "parentHash" : "76397ef48a05c4aac791330025f60bf8a75a31d89d5fa20118e6715ce293cb4b",
+ "receiptTrie" : "1bb4d2d4f245881f8f80a6e978298c63daedb73adac2b122275587fced99108a",
+ "stateRoot" : "2887e4b6cb8fee911a13606b9098dbd3876166cf7c5e98354049c8f8b4bb0ffe",
+ "timestamp" : "1429004773",
+ "transactionsTrie" : "4b6a3188e87e875fc2d5b52d660f263754534f9ffa6441ef637c4f0df7b983e4",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a076397ef48a05c4aac791330025f60bf8a75a31d89d5fa20118e6715ce293cb4ba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a02887e4b6cb8fee911a13606b9098dbd3876166cf7c5e98354049c8f8b4bb0ffea04b6a3188e87e875fc2d5b52d660f263754534f9ffa6441ef637c4f0df7b983e4a01bb4d2d4f245881f8f80a6e978298c63daedb73adac2b122275587fced99108ab9010000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000040000000000000000000000000000000000000000000000000000000000000000000830205401c832fefd88259d984552ce1e580a010e70466b38b681289359af1cdc21c4f91516fb61fd41012bc370b0ebfbacf55886f70a905f98ba732f866f8641b018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a8476bc21d91ca0385f0d177531211f9842bd11e1c72b596dc39883878cb43f261c02826b25d5f8a04934fc15130ec6954b7c6309ff5610a678d2117526f271f2a5e0e8bf183cdd38c0",
+ "transactions" : [
+ {
+ "data" : "0x76bc21d9",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "27",
+ "r" : "0x385f0d177531211f9842bd11e1c72b596dc39883878cb43f261c02826b25d5f8",
+ "s" : "0x4934fc15130ec6954b7c6309ff5610a678d2117526f271f2a5e0e8bf183cdd38",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200080000000000000002000000000000000000000000000000000000000000000000000800000000000000000000000200000000000000000000000000000000000800000000040000000000000000000000000000000000000000010000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132480",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23921",
+ "hash" : "29468b28f7dab0d61ed4c467816e8a8222242bbf4a0dffec3f6bcd7fb79b4267",
+ "mixHash" : "01c04de4a638cb75a8f287a4456fff5ba0c24feecad54d1920bdb59ef38415f8",
+ "nonce" : "8f01f144c61e07da",
+ "number" : "29",
+ "parentHash" : "3409ca9c70c1e729592b8cc7845457d1bd7a319e89200af249bb517c56b3f46b",
+ "receiptTrie" : "ed92b526af2c507678a8c0c73955c3942dfe28330ce043e09cc49be41060fca4",
+ "stateRoot" : "c5fbb91485b3eff9b2e0936f66d5c3650ee2c76f6f684e4f5e977b3994d60a3f",
+ "timestamp" : "1429004774",
+ "transactionsTrie" : "be1a34c4dfd8203f83a96a67d962dd22be454ce204f5f5a652e3c6ad29295381",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a03409ca9c70c1e729592b8cc7845457d1bd7a319e89200af249bb517c56b3f46ba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0c5fbb91485b3eff9b2e0936f66d5c3650ee2c76f6f684e4f5e977b3994d60a3fa0be1a34c4dfd8203f83a96a67d962dd22be454ce204f5f5a652e3c6ad29295381a0ed92b526af2c507678a8c0c73955c3942dfe28330ce043e09cc49be41060fca4b9010000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200080000000000000002000000000000000000000000000000000000000000000000000800000000000000000000000200000000000000000000000000000000000800000000040000000000000000000000000000000000000000010000000000000000000000000830205801d832fefd8825d7184552ce1e680a001c04de4a638cb75a8f287a4456fff5ba0c24feecad54d1920bdb59ef38415f8888f01f144c61e07daf866f8641c018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84f38b06001ca0d3cdac61edf302d213a4217a3fa9b8560b2ff2f4b1f618f711663161e6b41326a03d27b63b746fab465465ddc31ed25a1671df6d15d231cc121b56910e7e0a5542c0",
+ "transactions" : [
+ {
+ "data" : "0xf38b0600",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "28",
+ "r" : "0xd3cdac61edf302d213a4217a3fa9b8560b2ff2f4b1f618f711663161e6b41326",
+ "s" : "0x3d27b63b746fab465465ddc31ed25a1671df6d15d231cc121b56910e7e0a5542",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "28",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000800000000040000000000000000000000000000000000000000010000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132544",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23585",
+ "hash" : "82e12f65ce1381610bb1a5b1d76f72396e52f859b2c1d576ff45c52e0e4b2f1e",
+ "mixHash" : "48d9ea0c8b91c08562d1f10851f328c47e56e44be137fa53bbe9f7f8e268b32e",
+ "nonce" : "aa6e34d542c1fc98",
+ "number" : "30",
+ "parentHash" : "29468b28f7dab0d61ed4c467816e8a8222242bbf4a0dffec3f6bcd7fb79b4267",
+ "receiptTrie" : "7627e85e8b19f5115e4663c2ca51deb346bb55b7e369fbd52e80100340fba2db",
+ "stateRoot" : "a1d7db77cdcb7a4a1277abae26124e10e33030a347be972916927a674484c1ff",
+ "timestamp" : "1429004775",
+ "transactionsTrie" : "3fac3544d7cf9bedc636a762984d23405d076e7af9e941b74729f777d8a5d60c",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a029468b28f7dab0d61ed4c467816e8a8222242bbf4a0dffec3f6bcd7fb79b4267a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0a1d7db77cdcb7a4a1277abae26124e10e33030a347be972916927a674484c1ffa03fac3544d7cf9bedc636a762984d23405d076e7af9e941b74729f777d8a5d60ca07627e85e8b19f5115e4663c2ca51deb346bb55b7e369fbd52e80100340fba2dbb9010000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000800000000040000000000000000000000000000000000000000010000000000000000000000000830205c01e832fefd8825c2184552ce1e780a048d9ea0c8b91c08562d1f10851f328c47e56e44be137fa53bbe9f7f8e268b32e88aa6e34d542c1fc98f866f8641d018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84e8beef5b1ba0bf974f0d4161217391103a828101c9ad038cbdd5f8fb77621a0b7393a533a24ea0eb036d756ea39b88d8d02331bb12c7296fa8664b6f9f947cd935428c046726b5c0",
+ "transactions" : [
+ {
+ "data" : "0xe8beef5b",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "29",
+ "r" : "0xbf974f0d4161217391103a828101c9ad038cbdd5f8fb77621a0b7393a533a24e",
+ "s" : "0xeb036d756ea39b88d8d02331bb12c7296fa8664b6f9f947cd935428c046726b5",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200000000000000000002000000000000000000000001000000000000000000000000000000000000000000000000000200000000000000000000000000000000000800000000040000000000001000000000000000000000000000010000000000000000000400000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132608",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "24303",
+ "hash" : "4454afa5c6805f17106dd476bd029a357df9e37effce0acbdac5afda92eff25a",
+ "mixHash" : "38e258f1f8fb1a5719662d2564a14c22ffc18d42e9f603a66ac9d3c85e59dac2",
+ "nonce" : "46ab7aa33c326267",
+ "number" : "31",
+ "parentHash" : "82e12f65ce1381610bb1a5b1d76f72396e52f859b2c1d576ff45c52e0e4b2f1e",
+ "receiptTrie" : "c13c5643ed61bbb7652f2da98cd4b053cd59dec06271c431f977411c17feed0a",
+ "stateRoot" : "fcf4de7aa948b4bc7452154c2481022cf26892c40af60b73ed52aa7a0057875f",
+ "timestamp" : "1429004781",
+ "transactionsTrie" : "69f066fcb73e0cfcfa0ca236c5d98e8fc202c2e6989ee260c799381d47d594ae",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a082e12f65ce1381610bb1a5b1d76f72396e52f859b2c1d576ff45c52e0e4b2f1ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0fcf4de7aa948b4bc7452154c2481022cf26892c40af60b73ed52aa7a0057875fa069f066fcb73e0cfcfa0ca236c5d98e8fc202c2e6989ee260c799381d47d594aea0c13c5643ed61bbb7652f2da98cd4b053cd59dec06271c431f977411c17feed0ab9010000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200000000000000000002000000000000000000000001000000000000000000000000000000000000000000000000000200000000000000000000000000000000000800000000040000000000001000000000000000000000000000010000000000000000000400000830206001f832fefd8825eef84552ce1ed80a038e258f1f8fb1a5719662d2564a14c22ffc18d42e9f603a66ac9d3c85e59dac28846ab7aa33c326267f866f8641e018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a84fd4087671ba089d1f27e014972a13474f61f36f92cfea7dcdd85d60017d19bede2330dded948a0e27b31dc72d3b33aa9a2753e2d7b497a1c1bb7edb61ce57e7eea4280e143dc8ac0",
+ "transactions" : [
+ {
+ "data" : "0xfd408767",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "30",
+ "r" : "0x89d1f27e014972a13474f61f36f92cfea7dcdd85d60017d19bede2330dded948",
+ "s" : "0xe27b31dc72d3b33aa9a2753e2d7b497a1c1bb7edb61ce57e7eea4280e143dc8a",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ },
+ {
+ "blockHeader" : {
+ "bloom" : "00000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000080000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000400000000000000000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000800000000040000000000000000000000000000000000000000010000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "132672",
+ "extraData" : "0x",
+ "gasLimit" : "3141592",
+ "gasUsed" : "23705",
+ "hash" : "d153907eccbb699e569ba2d07833aec324785be70bbccc22008aed5d08993235",
+ "mixHash" : "206ed031b28997779dc1542a7d1ae110d0e20a549a132a742b958e781b5d5d2c",
+ "nonce" : "6c0086c774208491",
+ "number" : "32",
+ "parentHash" : "4454afa5c6805f17106dd476bd029a357df9e37effce0acbdac5afda92eff25a",
+ "receiptTrie" : "b42e987e824b2882be51bce4c29d6a12c80b345016180f53e4226e161c56af6e",
+ "stateRoot" : "9508ae08580735c0ad97380892c11d57919bbbe0c131b20f8957c93e092048c7",
+ "timestamp" : "1429004784",
+ "transactionsTrie" : "dea8e04d1845b461ca78ee250c4557c6bd22245d1e764bb22f7f4dfc135d5720",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "rlp" : "0xf90265f901f9a04454afa5c6805f17106dd476bd029a357df9e37effce0acbdac5afda92eff25aa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a09508ae08580735c0ad97380892c11d57919bbbe0c131b20f8957c93e092048c7a0dea8e04d1845b461ca78ee250c4557c6bd22245d1e764bb22f7f4dfc135d5720a0b42e987e824b2882be51bce4c29d6a12c80b345016180f53e4226e161c56af6eb90100000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000004000000000000000002000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000008000000000400000000000000000000000000000000000000000100000000000000000000000008302064020832fefd8825c9984552ce1f080a0206ed031b28997779dc1542a7d1ae110d0e20a549a132a742b958e781b5d5d2c886c0086c774208491f866f8641f018304cb2f946295ee1b4f6dd65047762f924ecd367c17eabf8f0a849dc2c8f51ba0f79e7419f683dc418fe6ff9a2b4f2082cdd9f71c51af2185a2af17624b3af7bea009df19d1ae4321040080d1fe5e1affa4fd20b5dfdb9f809c278c4b2d4131eb28c0",
+ "transactions" : [
+ {
+ "data" : "0x9dc2c8f5",
+ "gasLimit" : "314159",
+ "gasPrice" : "1",
+ "nonce" : "31",
+ "r" : "0xf79e7419f683dc418fe6ff9a2b4f2082cdd9f71c51af2185a2af17624b3af7be",
+ "s" : "0x09df19d1ae4321040080d1fe5e1affa4fd20b5dfdb9f809c278c4b2d4131eb28",
+ "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f",
+ "v" : "27",
+ "value" : "10"
+ }
+ ],
+ "uncleHeaders" : [
+ ]
+ }
+ ],
+ "genesisBlockHeader" : {
+ "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
+ "difficulty" : "131072",
+ "extraData" : "0x42",
+ "gasLimit" : "3141592",
+ "gasUsed" : "0",
+ "hash" : "02aa46ee7e8a588ecb36ae05a225f442a4410e7dca91b4e2e8fa351148a418c5",
+ "mixHash" : "2493675b2bf686bcd3f4e54df88e793c1fed42eb465696997e26c7edede4eb4a",
+ "nonce" : "96cbe44e03435e2e",
+ "number" : "0",
+ "parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
+ "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "stateRoot" : "7dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1",
+ "timestamp" : "1422494849",
+ "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
+ },
+ "genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a07dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a02493675b2bf686bcd3f4e54df88e793c1fed42eb465696997e26c7edede4eb4a8896cbe44e03435e2ec0c0",
+ "postState" : {
+ "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : {
+ "balance" : "320",
+ "code" : "0x6000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104b1565b60006000f35b610142610376565b8060005260206000f35b610157600435610301565b60006000f35b6101686004356102c9565b60006000f35b61017661041d565b8060005260206000f35b6101886103ae565b8060ff1660005260206000f35b61019d6103ee565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104a0565b60006000f35b6101d3610392565b8060000b60005260206000f35b6101e861042f565b60006000f35b6101f66103dc565b8060005260206000f35b6102086104fa565b60006000f35b6102196004356102e5565b60006000f35b61022761066e565b60006000f35b61023860043561031d565b60006000f35b61024661045f565b60006000f35b61025461046e565b60006000f35b610265600435610368565b60006000f35b61027660043561032b565b60006000f35b610287600435610339565b60006000f35b61029561058f565b60006000f35b6102a3610522565b60006000f35b6102b16103ca565b8060005260206000f35b6102c36105db565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff021916908302179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff16905061038f565b90565b6000600060019054906101000a900460ff1690506103ab565b90565b6000600060029054906101000a900460ff1690506103c7565b90565b600060016000505490506103d9565b90565b600060026000505490506103eb565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061041a565b90565b6000600460005054905061042c565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0xffffffffffff08fa01",
+ "0x01" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "0x02" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "0x03" : "0xaabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
+ "0x04" : "0xaabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee"
+ }
+ },
+ "8888f1f195afa192cfee860698584c030f4c9db1" : {
+ "balance" : "48093750000001297171",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1125009999998702509",
+ "code" : "0x",
+ "nonce" : "32",
+ "storage" : {
+ }
+ },
+ "bcde5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1125000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/files/StateTests/RandomTests/st201504081928CPPJIT.json b/tests/files/StateTests/RandomTests/st201504081928CPPJIT.json
new file mode 100644
index 000000000..03b58f460
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081928CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1582728260",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998417271786",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "cbcd9800020c801c45de04da2bd7697b9fd44d571860a7555ebc61ba44ae11af",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
+ "gasLimit" : "0x5e568416",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1174580620"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504081953JAVA.json b/tests/files/StateTests/RandomTests/st201504081953JAVA.json
new file mode 100644
index 000000000..83d260158
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081953JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1384582119",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "30725",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998615387202",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9bfe791ae77437f94a9768f5ba5ae336dad7eeab155897b8a8ea8a5445f50d9e",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c",
+ "gasLimit" : "0x10730dc2",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1384582119"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504081954JAVA.json b/tests/files/StateTests/RandomTests/st201504081954JAVA.json
new file mode 100644
index 000000000..239b6e3f4
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081954JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "00000000427fffffffffffffffffffffffffffff" : {
+ "balance" : "211829998",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "15653",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999788154395",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "4b0266280765370fc26f2ecee50a128fcc7d1ff0e578ce684a43f546fabf41ad",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f00000000000000000000000100000000000000000000000000000000000000006f427ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7e6410f26f519c538ea2070a6c60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f00000000000000000000000100000000000000000000000000000000000000006f427ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7e6410f26f519c538ea2070a6c",
+ "gasLimit" : "0x2c138ff5",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "211829998"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504081955JAVA.json b/tests/files/StateTests/RandomTests/st201504081955JAVA.json
new file mode 100644
index 000000000..5cc9a4f07
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081955JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "108687806",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906606425655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "30960",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999891281280",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "e8dbd20c0ca9c7daab8dc415e43f312f4fcd38b250500f7b66ba86ae5b7270a6",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906606425655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9066064256",
+ "gasLimit" : "0x2ab6153e",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "108687806"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504081956JAVA.json b/tests/files/StateTests/RandomTests/st201504081956JAVA.json
new file mode 100644
index 000000000..85d8451ef
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081956JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff337f000000000000000000000000000000000000000000000000000000000000000099447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350735b9f81208b6f526655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "2038066738",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999997961933308",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "b91b3d631e6b6f635a4448954b5633aa870671ea8558c44a7e1dfe6c028652a9",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff337f000000000000000000000000000000000000000000000000000000000000000099447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350735b9f81208b6f526655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff337f000000000000000000000000000000000000000000000000000000000000000099447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350735b9f81208b6f5266",
+ "gasLimit" : "0x797a6e04",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "519689383"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504081957JAVA.json b/tests/files/StateTests/RandomTests/st201504081957JAVA.json
new file mode 100644
index 000000000..196e12189
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504081957JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "0000000000000000005b7fffffffffffffffffff" : {
+ "balance" : "1615246365",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "15009",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998384738672",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "b010df03a8f3e5d887163e5a995c0f01b0b190bd572aeb9e12d2c3a927e76c34",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff6a5b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe66f2707d83713b6b8f320855",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff6a5b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe66f2707d83713b6b8f3208",
+ "gasLimit" : "0x3c465078",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1615246365"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504082000JAVA.json b/tests/files/StateTests/RandomTests/st201504082000JAVA.json
new file mode 100644
index 000000000..00f290dca
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504082000JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000140523c6d91f24568a3393490820630181a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1904591245",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998095408801",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9f0735add7612c06e51b8e53a857ff6a4fc74171d6681ae40baa764eba0cb4f0",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000140523c6d91f24568a3393490820630181a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000140523c6d91f24568a3393490820630181a",
+ "gasLimit" : "0x7185c15f",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "2037953415"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504082001JAVA.json b/tests/files/StateTests/RandomTests/st201504082001JAVA.json
new file mode 100644
index 000000000..bb912d1e2
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504082001JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x457f000000000000000000000000000000000000000000000000000000000000c350397ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0a9d30390b8c858455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "2071421771",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999997928578275",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "d1b4c4dbe542c00c23f35c9610b0d0e1e826e9e82dbad3b22ac582b128bd9bba",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x457f000000000000000000000000000000000000000000000000000000000000c350397ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0a9d30390b8c858455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x457f000000000000000000000000000000000000000000000000000000000000c350397ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0a9d30390b8c8584",
+ "gasLimit" : "0x7b77631d",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "532918830"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504082002JAVA.json b/tests/files/StateTests/RandomTests/st201504082002JAVA.json
new file mode 100644
index 000000000..c0f4764cf
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504082002JAVA.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000010000000000000000000000000000000000000000807f00000000000000000000000000000000000000000000000000000000000000017f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff50885560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21978457",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999978021589",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "31fef3f415e32007a44dafc952f408ea27e3508450c6bea84d1b24c5a3033240",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000010000000000000000000000000000000000000000807f00000000000000000000000000000000000000000000000000000000000000017f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff50885560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000010000000000000000000000000000000000000000807f00000000000000000000000000000000000000000000000000000000000000017f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff5088",
+ "gasLimit" : "0x014f5d2b",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "6954369"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504090553CPPJIT.json b/tests/files/StateTests/RandomTests/st201504090553CPPJIT.json
new file mode 100644
index 000000000..c434c1c30
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504090553CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "844312201",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001447f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f1606588a909558021569",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "25756",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999155662089",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "1b827147bee0055ef753387d41f23fc8e5599501ec201dc57e209e9da6ced93d",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001447f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f1606588a909558021569",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001447f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f1606588a909558021569",
+ "gasLimit" : "0x0d3c510a",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "844312201"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504090657CPPJIT.json b/tests/files/StateTests/RandomTests/st201504090657CPPJIT.json
new file mode 100644
index 000000000..a366a29cb
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504090657CPPJIT.json
@@ -0,0 +1,72 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "471893354",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f000000000000000000000001000000000000000000000000000000000000000060005155",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x010000000000000000000000000000000000000000"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "50134",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999528056558",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "35ebe0f6a4286a321843e62f25e42b67bd3f0092db4b2d8edb96d2e1b1501bdd",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f000000000000000000000001000000000000000000000000000000000000000060005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f0000000000000000000000010000000000000000000000000000000000000000",
+ "gasLimit" : "0x5cf717b8",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "471893354"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504091403CPPJIT.json b/tests/files/StateTests/RandomTests/st201504091403CPPJIT.json
new file mode 100644
index 000000000..4fccb48bc
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504091403CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "15051",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999691174220",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ },
+ "fffffffffffffffffffffffffffffffffffffffe" : {
+ "balance" : "308810775",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "09299b57ad249c83444f382e4a185543b9df064510d430447284c0c9ffe51933",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff20547f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeff61853634f06b907f899d7455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff20547f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeff61853634f06b907f899d74",
+ "gasLimit" : "0x54d3ff45",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "308810775"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504091641CPPJIT.json b/tests/files/StateTests/RandomTests/st201504091641CPPJIT.json
new file mode 100644
index 000000000..a3a64ca26
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504091641CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "181540957",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5437f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1174648789aa349e0915aa5911",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "32231",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999818426858",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "919463d8f7cd3da2e857914d046de2c08fc6c0be11ee2988525c071b3c818623",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5437f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1174648789aa349e0915aa5911",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5437f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1174648789aa349e0915aa5911",
+ "gasLimit" : "0x1e1cba4d",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "181540957"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504092303CPPJIT.json b/tests/files/StateTests/RandomTests/st201504092303CPPJIT.json
new file mode 100644
index 000000000..756c9a536
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504092303CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x847f000000000000000000000000000000000000000000000000000000000000c35043657f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4362f03c897f50f073f219105455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1095160435",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998904839611",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "440660f4f8e63e8399d8ff0c24d1ce4f96b1957dede66eaf4e49c5ad3bdbbdb0",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x847f000000000000000000000000000000000000000000000000000000000000c35043657f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4362f03c897f50f073f219105455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x847f000000000000000000000000000000000000000000000000000000000000c35043657f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4362f03c897f50f073f2191054",
+ "gasLimit" : "0x4146d245",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1741426477"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100125CPPJIT.json b/tests/files/StateTests/RandomTests/st201504100125CPPJIT.json
new file mode 100644
index 000000000..84831f668
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100125CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c350f4fd94058f06a255",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "375133674",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999624866372",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "842ed2e7ebbadb1a081941031ca1c783f7bed31561d1ae3e5b57325aa0bc7ce4",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c350f4fd94058f06a255",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c350f4fd94058f06a2",
+ "gasLimit" : "0x165c15bc",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1996511098"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100215CPPJIT.json b/tests/files/StateTests/RandomTests/st201504100215CPPJIT.json
new file mode 100644
index 000000000..b798144eb
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100215CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5587f0000000000000000000000000000000000000000000000000000000000000001957f0000000000000000000000000000000000000000000000000000000000000000407f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3509781040107338b35071887a186",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "71266589",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999928733457",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "f6138f5e594083610a5e80c269b7cd74a9afb59150aee99257d0c835454b3b1e",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5587f0000000000000000000000000000000000000000000000000000000000000001957f0000000000000000000000000000000000000000000000000000000000000000407f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3509781040107338b35071887a186",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5587f0000000000000000000000000000000000000000000000000000000000000001957f0000000000000000000000000000000000000000000000000000000000000000407f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3509781040107338b35071887a186",
+ "gasLimit" : "0x043f70ef",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "335580338"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100226PYTHON.json b/tests/files/StateTests/RandomTests/st201504100226PYTHON.json
new file mode 100644
index 000000000..21645fd55
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100226PYTHON.json
@@ -0,0 +1,86 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1254734781",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5547f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000037f055",
+ "nonce" : "1",
+ "storage" : {
+ "0xd2571607e241ecf590ed94b12d87c94babe36db6" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5"
+ }
+ },
+ "62c01474f089b07dae603491675dc5b5748f7049" : {
+ "balance" : "50000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "138012",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998745077253",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ },
+ "d2571607e241ecf590ed94b12d87c94babe36db6" : {
+ "balance" : "0",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "d04b66431e303267d08004a1239a4a9cdf974aeac6a40ae39e8fb6fc1e130350",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5547f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000037f055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5547f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000037f0",
+ "gasLimit" : "0x1f729d33",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1254784781"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100308CPPJIT.json b/tests/files/StateTests/RandomTests/st201504100308CPPJIT.json
new file mode 100644
index 000000000..374d1da2e
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100308CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x557ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5627f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b56a328b186e166407917c7af102925060005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1468895792",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998531104254",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "cfbcad42dfd8524a08d45d9badd9a9db60dc4337f69d3c964f01af504f91a183",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x557ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5627f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b56a328b186e166407917c7af102925060005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x557ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5627f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b56a328b186e166407917c7af1029250",
+ "gasLimit" : "0x578d9202",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1535680761"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100337CPPJIT.json b/tests/files/StateTests/RandomTests/st201504100337CPPJIT.json
new file mode 100644
index 000000000..09d8b2d66
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100337CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe92357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff597f00000000000000000000000000000000000000000000000000000000000000019385a39988160a205a93196d336428",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "103015785",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999896984261",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "db746085a68ff63096d43202f64f089300ea5fabcc4dc769472b0710c0029383",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe92357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff597f00000000000000000000000000000000000000000000000000000000000000019385a39988160a205a93196d336428",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe92357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff597f00000000000000000000000000000000000000000000000000000000000000019385a39988160a205a93196d336428",
+ "gasLimit" : "0x0623e53b",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1592853550"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504100341CPPJIT.json b/tests/files/StateTests/RandomTests/st201504100341CPPJIT.json
new file mode 100644
index 000000000..0f13d23a5
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504100341CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1657754250",
+ "code" : "0x7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b53a7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001817d7b8956970660129f5015fe0a355560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "26920",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998342218876",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9cbbf1891be48f82515a092cddb48a37eb456c8a5eb3d9c3ea463fb3adfda444",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b53a7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001817d7b8956970660129f5015fe0a355560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f00000000000000000000000000000000000000000000000000000000000000017f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b53a7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017f0000000000000000000000000000000000000000000000000000000000000001817d7b8956970660129f5015fe0a35",
+ "gasLimit" : "0x13433a42",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1657754250"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504101009CPPJIT.json b/tests/files/StateTests/RandomTests/st201504101009CPPJIT.json
new file mode 100644
index 000000000..4a2af3f6c
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504101009CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "00000000000000000000000000007fffffffffff" : {
+ "balance" : "1090344298",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "15214",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998909640534",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "ba463233d6fc930224054669afa5005e13f881984266ad54742d6483cb87995a",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x657ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe43659a936055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x657ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe43659a9360",
+ "gasLimit" : "0x40e55a54",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1090344298"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504101150CPPJIT.json b/tests/files/StateTests/RandomTests/st201504101150CPPJIT.json
new file mode 100644
index 000000000..aa4504e15
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504101150CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000001757f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57a7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe83189b60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1861454639",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998138545407",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9d35d961673db10b4083751411fb01ce25c9d6b4dae15c4bc12db4ae3aa45b06",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000001757f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57a7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe83189b60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f0000000000000000000000000000000000000000000000000000000000000001757f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57a7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5447ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe83189b",
+ "gasLimit" : "0x6ef38b01",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1062041617"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504101223CPPJIT.json b/tests/files/StateTests/RandomTests/st201504101223CPPJIT.json
new file mode 100644
index 000000000..609f8952c
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504101223CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "530365208",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c350407f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff72785560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "26569",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999469608269",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "6d38e831c668646f03942f18800f75fc1833e5010ce8bd130443537a42909ca3",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c350407f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff72785560005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c350407f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7278",
+ "gasLimit" : "0x40a95160",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "530365208"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504101338CPPJIT.json b/tests/files/StateTests/RandomTests/st201504101338CPPJIT.json
new file mode 100644
index 000000000..6fd7e0a59
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504101338CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "395877699",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000447f000000000000000000000000000000000000000000000000000000000000c3505b7f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe417f00000000000000000000000000000000000000000000000000000000000000006867f1",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "24761",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999604097586",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "da85203ef9f44556143339fd61425f8184b51a8a0bd7a6b132933c1064f8b7f2",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000447f000000000000000000000000000000000000000000000000000000000000c3505b7f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe417f00000000000000000000000000000000000000000000000000000000000000006867f1",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f0000000000000000000000000000000000000000000000000000000000000000447f000000000000000000000000000000000000000000000000000000000000c3505b7f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe417f00000000000000000000000000000000000000000000000000000000000000006867f1",
+ "gasLimit" : "0x435eefa4",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "395877699"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504101754PYTHON.json b/tests/files/StateTests/RandomTests/st201504101754PYTHON.json
new file mode 100644
index 000000000..b67527889
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504101754PYTHON.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1472986584",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5067f0000000000000000000000000000000000000000000000000000000000000000407f000000000000000000000000000000000000000000000000000000000000c350427f00000000000000000000000000000000000000000000000000000000000000013a0960005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "30179",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998526983283",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "8142eea848215059272c6f827e23f5c2975fa53c8b128e91eb84fdbe876394ec",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5067f0000000000000000000000000000000000000000000000000000000000000000407f000000000000000000000000000000000000000000000000000000000000c350427f00000000000000000000000000000000000000000000000000000000000000013a0960005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5067f0000000000000000000000000000000000000000000000000000000000000000407f000000000000000000000000000000000000000000000000000000000000c350427f00000000000000000000000000000000000000000000000000000000000000013a09",
+ "gasLimit" : "0x46cdc800",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1472986584"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504111554CPPJIT.json b/tests/files/StateTests/RandomTests/st201504111554CPPJIT.json
new file mode 100644
index 000000000..ac3ae7b58
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504111554CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffffa405457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b588015a9a0542a13a051497514215",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "264530562",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999735469484",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "523f1bafc827465557ef569f1c1f0e047d287c61485d8ecf12a9331a4f367e52",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffffa405457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b588015a9a0542a13a051497514215",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffffa405457f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b588015a9a0542a13a051497514215",
+ "gasLimit" : "0x0fc46a54",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "191496672"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504130653JS.json b/tests/files/StateTests/RandomTests/st201504130653JS.json
new file mode 100644
index 000000000..8629fb82d
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504130653JS.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1398079665",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f0000000000000000000000000000000000000000000000000000000000000000427f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f00000000000000000000000100000000000000000000000000000000000000003bf1135a3a58",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "67665",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998601852716",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "7114ebb96d3623cd066573e441eee29b24e267c630b69628e81b23d770a68ba5",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f0000000000000000000000000000000000000000000000000000000000000000427f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f00000000000000000000000100000000000000000000000000000000000000003bf1135a3a58",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c3507f0000000000000000000000000000000000000000000000000000000000000000427f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff437f00000000000000000000000100000000000000000000000000000000000000003bf1135a3a58",
+ "gasLimit" : "0x3d0d185c",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1398079665"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140229CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140229CPPJIT.json
new file mode 100644
index 000000000..9986cbf6a
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140229CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff428d06809e75f26764867d853b0555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "144161518",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999855838528",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "77c02157a2c1be59d8e59537503c9cff114d187fd4196ad3b4594e827a7c302e",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff428d06809e75f26764867d853b0555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7f000000000000000000000000000000000000000000000000000000000000c3507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c3507f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff428d06809e75f26764867d853b05",
+ "gasLimit" : "0x0897bac0",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "801407730"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140236CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140236CPPJIT.json
new file mode 100644
index 000000000..4d572c0fe
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140236CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe427f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5097f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe8e0781816fff31986c0a773c9b014460005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1172118239",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998827881807",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "61be519aff25f0c4f5eaede65d1ee274fd776b8736dd5628bda0a155bb3adc7c",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe427f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5097f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe8e0781816fff31986c0a773c9b014460005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe427f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5097f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe8e0781816fff31986c0a773c9b0144",
+ "gasLimit" : "0x45dd1ab1",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1737878734"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140359CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140359CPPJIT.json
new file mode 100644
index 000000000..a4f0ae7b1
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140359CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe457f0000000000000000000000000000000000000000000000000000000000000001e37f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c35001589a84106d9c60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1891130376",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998108869670",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "6eeb44aa195850cff56903b1bc6ad37ae32a33bf577e45dcda5013ecd50cf546",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe457f0000000000000000000000000000000000000000000000000000000000000001e37f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c35001589a84106d9c60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe457f0000000000000000000000000000000000000000000000000000000000000001e37f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000000000000000000000000000000000000000c35001589a84106d9c",
+ "gasLimit" : "0x70b85bda",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1095126158"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140750CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140750CPPJIT.json
new file mode 100644
index 000000000..27cea4516
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140750CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1542389267",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350437f00000000000000000000000000000000000000000000000000000000000000016e6a078e5652549f57423955",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "27740",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998457583039",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "03be16281312d1cd04b333e3102b99dbcd72c92b3e9aecb4ec1b05777f14fd14",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350437f00000000000000000000000000000000000000000000000000000000000000016e6a078e5652549f57423955",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000c3507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000c350437f00000000000000000000000000000000000000000000000000000000000000016e6a078e5652549f574239",
+ "gasLimit" : "0x527cfd5b",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1542389267"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140818CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140818CPPJIT.json
new file mode 100644
index 000000000..d589649fe
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140818CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x0b7f00000000000000000000000000000000000000000000000000000000000000013c7f000000000000000000000000000000000000000000000000000000000000c350a345457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8287a3208c8c5a60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1213823124",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998786176922",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "f356f55e90b79b2b441790436315fe7067f1db8a9e00061266cfc67af7a0ae28",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x0b7f00000000000000000000000000000000000000000000000000000000000000013c7f000000000000000000000000000000000000000000000000000000000000c350a345457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8287a3208c8c5a60005155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x0b7f00000000000000000000000000000000000000000000000000000000000000013c7f000000000000000000000000000000000000000000000000000000000000c350a345457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8287a3208c8c5a",
+ "gasLimit" : "0x48597866",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "827973881"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201504140900CPPJIT.json b/tests/files/StateTests/RandomTests/st201504140900CPPJIT.json
new file mode 100644
index 000000000..201a97700
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201504140900CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x407f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000100000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c350057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000000085f98f3c3c9d0345f2155a9a7d0b131555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "1850655959",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999998149344087",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9138d769f5c41c39e892f6fc18d67f4d38ae452a71cfa966a39a274af70da846",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "0",
+ "code" : "0x407f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000100000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c350057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000000085f98f3c3c9d0345f2155a9a7d0b131555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x407f000000000000000000000000000000000000000000000000000000000000c3507f00000000000000000000000100000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000c350057ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000000000000000000000000000000000000000000085f98f3c3c9d0345f2155a9a7d0b1315",
+ "gasLimit" : "0x6e4ec4a9",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "122762203"
+ }
+ }
+}
diff --git a/tests/files/TransactionTests/ttTransactionTest.json b/tests/files/TransactionTests/ttTransactionTest.json
index ed00d81e9..fa8ef39b7 100644
--- a/tests/files/TransactionTests/ttTransactionTest.json
+++ b/tests/files/TransactionTests/ttTransactionTest.json
@@ -1,90 +1,84 @@
{
"AddressLessThan20" : {
- "rlp" : "0xf85280018207d0870b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf8528001825208870b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"AddressLessThan20Prefixed0" : {
- "rlp" : "0xf85f80018207d094000000000000000000000000000b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "sender" : "23f0d6e160851f7b435f743d2ec368449bb06c0f",
+ "rlp" : "0xf85f800182520894000000000000000000000000000b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
+ "sender" : "31bb58672e8bf7684108feeacf424ab62b873824",
"transaction" : {
- "data" : "",
- "gasLimit" : "2000",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
"s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
"to" : "0x000000000000000000000000000b9331677e6ebf",
- "v" : "28",
- "value" : "10"
+ "v" : "0x1c",
+ "value" : "0x0a"
}
},
"AddressMoreThan20" : {
- "rlp" : "0xf86080018207d095b94f5374fce5edbc8e2a8697c15331677e6ebf0b1c0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf860800182520895b94f5374fce5edbc8e2a8697c15331677e6ebf0b1c0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"AddressMoreThan20PrefixedBy0" : {
- "rlp" : "0xf867367b8203e89c0000000000000000095e7baea6a6c7c4c2dfeb977efac326af552d870b121ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ "rlp" : "0xf867367b8252089c0000000000000000095e7baea6a6c7c4c2dfeb977efac326af552d870b121ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
- "DataTest" : {
- "rlp" : "0xf86d800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "33f4b78a24c0b941c385dd0bb4a635b8f5dd21d8",
+ "DataTestEnoughGAS" : {
+ "rlp" : "0xf86d80018259d894095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "ce26839c9bd0e87e38897bb97fca8b340fd12a53",
"transaction" : {
"data" : "0x0358ac39584bc98a7c979f984b03",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "gasLimit" : "0x59d8",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "10"
+ "v" : "0x1b",
+ "value" : "0x0a"
}
},
+ "DataTestNotEnoughGAS" : {
+ "rlp" : "0xf86d800182521c94095e7baea6a6c7c4c2dfeb977efac326af552d870a8e0358ac39584bc98a7c979f984b031ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ },
"EmptyTransaction" : {
- "rlp" : "0xf85d80808094095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "3e2ddf4fea89f584a735a1234cf20d8627421564",
- "transaction" : {
- "data" : "",
- "gasLimit" : "",
- "gasPrice" : "",
- "nonce" : "",
- "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
- "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : ""
- }
+ "rlp" : "0xf85d80808094095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ },
+ "NotEnoughGasLimit" : {
+ "rlp" : "0xf85f0301824e2094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"RSsecp256k1" : {
- "rlp" : "0xf86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141a0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"
+ "rlp" : "0xf85f030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141a0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"
},
"RightVRSTest" : {
- "rlp" : "0xf86103018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255441ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "sender" : "5ba306ae3650c72c3586da6f1dbac3c9fa7e529e",
+ "rlp" : "0xf85f030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
+ "sender" : "fa7f04899691becd07dd3081d0a2f3ee7640af52",
"transaction" : {
- "data" : "0x5544",
- "gasLimit" : "2000",
- "gasPrice" : "1",
- "nonce" : "3",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x03",
"r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
"s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "v" : "28",
- "value" : "10"
+ "v" : "0x1c",
+ "value" : "0x0a"
}
},
"SenderTest" : {
- "//" : "sender a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "rlp" : "0xf85f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "//" : "sender 0f65fe9276bc9a24ae7083ae28e2660ef72df99e",
+ "rlp" : "0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "0f65fe9276bc9a24ae7083ae28e2660ef72df99e",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "10"
+ "v" : "0x1b",
+ "value" : "0x0a"
}
},
"TransactionWithGasLimitOverflow" : {
@@ -94,237 +88,222 @@
"rlp" : "0xf8858088016345785d8a0000a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff94095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"sender" : "700764607c82cf3e9cf4ecbd49185f8914f1a361",
"transaction" : {
- "data" : "",
- "gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
- "gasPrice" : "100000000000000000",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
+ "gasPrice" : "0x016345785d8a0000",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "0"
+ "v" : "0x1b",
+ "value" : "0x"
}
},
"TransactionWithGasPriceOverflow" : {
- "rlp" : "0xf88080a101000000000000000000000000000000000000000000000000000000000000000082035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ "rlp" : "0xf88080a101000000000000000000000000000000000000000000000000000000000000000082520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ },
+ "TransactionWithHighValueOverflow" : {
+ "rlp" : "0xf880800182520894095e7baea6a6c7c4c2dfeb977efac326af552d87a1010000000000000000000000000000000000000000000000000000000000000000801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
"TransactionWithHihghGas" : {
"rlp" : "0xf87d8001a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff94095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"sender" : "9e92c26895f279d68ad7b57b803dc522717d5572",
"transaction" : {
- "data" : "",
- "gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "0"
+ "v" : "0x1b",
+ "value" : "0x"
}
},
"TransactionWithHihghGasPrice" : {
- "rlp" : "0xf87f80a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203e894095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "16fd9197d7c7e37ac06ef78a2c2fcf5a70ae2db3",
+ "rlp" : "0xf87f80a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82520894095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "b10eac078276dc8dbf1753715396d480156236f8",
"transaction" : {
- "data" : "",
- "gasLimit" : "1000",
- "gasPrice" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "0"
+ "v" : "0x1b",
+ "value" : "0x"
}
},
"TransactionWithHihghNonce" : {
- "rlp" : "0xf87fa0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0182035294095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "224fdba918cbedf058c4694f2e88a35fae134623",
+ "rlp" : "0xf87fa0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0182520894095e7baea6a6c7c4c2dfeb977efac326af552d8780801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "9b96002788562fefd5ac08d5af877fa738272dc7",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "0"
+ "v" : "0x1b",
+ "value" : "0x"
}
},
"TransactionWithHihghValue" : {
- "rlp" : "0xf87f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d87a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "50702f47f1c4bfc6b75e65e2b995a8024fe25be9",
+ "rlp" : "0xf87f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d87a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "396bd0363e26195eeacfedbe54c44f16fbe470b6",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "115792089237316195423570985008687907853269984665640564039457584007913129639935"
+ "v" : "0x1b",
+ "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
}
},
- "TransactionWithHihghValueOverflow" : {
- "rlp" : "0xf880800182035294095e7baea6a6c7c4c2dfeb977efac326af552d87a1010000000000000000000000000000000000000000000000000000000000000000801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
- },
"TransactionWithNonceOverflow" : {
- "rlp" : "0xf880a10100000000000000000000000000000000000000000000000000000000000000000182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ "rlp" : "0xf880a10100000000000000000000000000000000000000000000000000000000000000000182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
"TransactionWithRvalueHigh" : {
- "rlp" : "0xf85f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140a08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140a08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"TransactionWithRvalueOverflow" : {
- "rlp" : "0xf861800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba2fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641410000a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
- },
- "TransactionWithRvalueTooHigh" : {
- "rlp" : "0xf85f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ "rlp" : "0xf861800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba2fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641410000a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
- "TransactionWithRvalueWrongSize" : {
- "rlp" : "0xf850800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801b910ebaaedce6af48a03bbfd25e8cd0364141a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "590233a2475e255fcdbc91d70da548315ca938a8",
+ "TransactionWithRvaluePrefixed00" : {
+ "rlp" : "0xf850800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801b910ebaaedce6af48a03bbfd25e8cd0364141a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "0dd0dcb6502a463fa90ecaa59ca29a5e6571deef",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0xebaaedce6af48a03bbfd25e8cd0364141",
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "11"
+ "v" : "0x1b",
+ "value" : "0x0b"
}
},
+ "TransactionWithRvalueTooHigh" : {
+ "rlp" : "0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba0fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
+ },
"TransactionWithSvalueHigh" : {
- "rlp" : "0xf85f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e",
- "sender" : "53ea6a7f58d1b13a32147d908c2631611680e2ac",
+ "rlp" : "0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e",
+ "sender" : "cae01e4c9e1eb0fc7676055de1fa1f1e8cfd36ee",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
"s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "11"
+ "v" : "0x1b",
+ "value" : "0x0b"
}
},
"TransactionWithSvalueOverflow" : {
- "rlp" : "0xf861800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a2fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000"
+ "rlp" : "0xf861800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a2fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000"
},
- "TransactionWithSvalueTooHigh" : {
- "rlp" : "0xf85f800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
- },
- "TransactionWithSvalueWrongSize" : {
- "rlp" : "0xf851800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a920ef0b28ad43601b4ab949f53faa07bd2c804",
- "sender" : "3a9f53e51de6314acdcfb604fcb2a11f10345d8e",
+ "TransactionWithSvaluePrefixed00" : {
+ "rlp" : "0xf851800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a920ef0b28ad43601b4ab949f53faa07bd2c804",
+ "sender" : "a825d77f343f31619c991cd7db5aaa6adbe9452e",
"transaction" : {
- "data" : "",
- "gasLimit" : "850",
- "gasPrice" : "1",
- "nonce" : "0",
+ "data" : "0x",
+ "gasLimit" : "0x5208",
+ "gasPrice" : "0x01",
+ "nonce" : "0x",
"r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
"s" : "0xef0b28ad43601b4ab949f53faa07bd2c804",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "v" : "27",
- "value" : "11"
+ "v" : "0x1b",
+ "value" : "0x0b"
}
},
+ "TransactionWithSvalueTooHigh" : {
+ "rlp" : "0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870b801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
+ },
"TransactionWithTooFewRLPElements" : {
"rlp" : "0xf85b800194095e7baea6a6c7c4c2dfeb977efac326af552d87801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
"TransactionWithTooManyRLPElements" : {
- "rlp" : "0xf865800182035294095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804851de98d0edd"
+ "rlp" : "0xf865800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804851de98d0edd"
},
"V_overflow32bit" : {
- "rlp" : "0xf86603018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a82554485010000001ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf866030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a82554485010000001ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"V_overflow32bitSigned" : {
- "rlp" : "0xf86503018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544847fffffffa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf865030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544847fffffffa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"V_overflow64bit" : {
- "rlp" : "0xf86a03018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255448901000000000000001ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf86a030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a8255448901000000000000001ba098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"V_overflow64bitSigned" : {
- "rlp" : "0xf86903018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a82554488ffffffffffffff1ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
- },
- "ValuesAsDec" : {
- "rlp" : "0xf86a830ffdc50183adc05394b94f5374fce5edbc8e2a8697c15331677e6ebf0b870ffdc5fffdc12c801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "sender" : "3eb583df408b324b4ba3a8d63e6b2dba1c4f28f6",
- "transaction" : {
- "data" : "",
- "gasLimit" : "11386963",
- "gasPrice" : "1",
- "nonce" : "1048005",
- "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
- "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "v" : "28",
- "value" : "4501151495864620"
- }
- },
- "ValuesAsHex" : {
- "rlp" : "0xf867830ffdc50183adc05394b94f5374fce5edbc8e2a8697c15331677e6ebf0b84fffdc12c801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "sender" : "24ef2c911b7b98e481e4c97c201194ee7889501b",
- "transaction" : {
- "data" : "",
- "gasLimit" : "0xadc053",
- "gasPrice" : "1",
- "nonce" : "0xffdc5",
- "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
- "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3",
- "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "v" : "28",
- "value" : "4294820140"
- }
+ "rlp" : "0xf869030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a82554488ffffffffffffff1ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"WrongVRSTestIncorrectSize" : {
- "rlp" : "0xf86380018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca298ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a02c3a28887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a302c3"
+ "rlp" : "0xf863800182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca298ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a02c3a28887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a302c3"
},
"WrongVRSTestVEqual26" : {
- "rlp" : "0xf85f80018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801aa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf85f800182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801aa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"WrongVRSTestVEqual29" : {
- "rlp" : "0xf85f80018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801da098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf85f800182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801da098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"WrongVRSTestVEqual31" : {
- "rlp" : "0xf85f80018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801fa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf85f800182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801fa098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
},
"WrongVRSTestVOverflow" : {
- "rlp" : "0xf86180018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a80820136a098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ "rlp" : "0xf861800182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a80820136a098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ },
+ "dataTx_bcValidBlockTest" : {
+ "rlp" : "0xf901fb803282c3508080b901ae60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b561ca0c5689ed1ad124753d54576dfb4b571465a41900a1dff4058d8adf16f752013d0a0e221cbd70ec28c94a3b55ec771bcbc70778d6ee0b51ca7ea9514594c861b1884",
+ "sender" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "transaction" : {
+ "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56",
+ "gasLimit" : "0xc350",
+ "gasPrice" : "0x32",
+ "nonce" : "0x",
+ "r" : "0xc5689ed1ad124753d54576dfb4b571465a41900a1dff4058d8adf16f752013d0",
+ "s" : "0xe221cbd70ec28c94a3b55ec771bcbc70778d6ee0b51ca7ea9514594c861b1884",
+ "to" : "",
+ "v" : "0x1c",
+ "value" : "0x"
+ }
},
"libsecp256k1test" : {
- "rlp" : "0xd1808609184e72a0008213888080801b2c04",
- "sender" : "847c8602054c653f489398f0fc2de507083d6f1c",
+ "rlp" : "0xd1808609184e72a00082f3888080801b2c04",
+ "sender" : "170ad78f26da62f591fa3fe3d54c30016167cbbf",
"transaction" : {
- "data" : "",
- "gasLimit" : "0x1388",
+ "data" : "0x",
+ "gasLimit" : "0xf388",
"gasPrice" : "0x09184e72a000",
- "nonce" : "",
- "r" : "44",
- "s" : "4",
+ "nonce" : "0x",
+ "r" : "0x2c",
+ "s" : "0x04",
"to" : "",
- "v" : "27",
- "value" : ""
+ "v" : "0x1b",
+ "value" : "0x"
}
},
"unpadedRValue" : {
- "rlp" : "0xf8880d8609184e72a000822710947c47ef93268a311f4cad0c750724299e9b72c26880a4379607f500000000000000000000000000000000000000000000000000000000000000051c9f6ab6dda9f4df56ea45583af36660329147f1753f3724ea5eb9ed83e812ca77a0495701e230667832c8999e884e366a61028633ecf951e8cd66d119f381ae5718",
- "sender" : "7adf3b3bce3a5c8c17e8b243f4c331dd97c60579",
+ "rlp" : "0xf8880d8609184e72a00082f710947c47ef93268a311f4cad0c750724299e9b72c26880a4379607f500000000000000000000000000000000000000000000000000000000000000051c9f6ab6dda9f4df56ea45583af36660329147f1753f3724ea5eb9ed83e812ca77a0495701e230667832c8999e884e366a61028633ecf951e8cd66d119f381ae5718",
+ "sender" : "c1584838993ee7a9581cba0bced81785e8bb581d",
"transaction" : {
"data" : "0x379607f50000000000000000000000000000000000000000000000000000000000000005",
- "gasLimit" : "0x2710",
+ "gasLimit" : "0xf710",
"gasPrice" : "0x09184e72a000",
- "nonce" : "13",
+ "nonce" : "0x0d",
"r" : "0x006ab6dda9f4df56ea45583af36660329147f1753f3724ea5eb9ed83e812ca77",
"s" : "0x495701e230667832c8999e884e366a61028633ecf951e8cd66d119f381ae5718",
"to" : "7c47ef93268a311f4cad0c750724299e9b72c268",
- "v" : "28",
- "value" : ""
+ "v" : "0x1c",
+ "value" : "0x"
}
}
} \ No newline at end of file
diff --git a/tests/files/TransactionTests/ttWrongRLPTransaction.json b/tests/files/TransactionTests/ttWrongRLPTransaction.json
index 743770b70..6caf47984 100644
--- a/tests/files/TransactionTests/ttWrongRLPTransaction.json
+++ b/tests/files/TransactionTests/ttWrongRLPTransaction.json
@@ -1,4 +1,12 @@
{
+ "RLPLengthWithFirstZeros" : {
+ "rlp" : "0xf9005f030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ },
+
+ "RLPIncorrectByteEncoding" : {
+ "rlp" : "0xf86081030182520894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa08887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
+ },
+
"RLPNonceWithFirstZeros" : {
"rlp" : "0xf86384000000030182035294095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
},
diff --git a/tests/transaction_test.go b/tests/transaction_test.go
index dabc7823b..a6c7492d5 100644
--- a/tests/transaction_test.go
+++ b/tests/transaction_test.go
@@ -6,19 +6,11 @@ import (
func TestTransactions(t *testing.T) {
notWorking := make(map[string]bool, 100)
- // TODO: all commented out tests should work!
+ // TODO: all these tests should work! remove them from the array when they work
snafus := []string{
- "EmptyTransaction",
- "TransactionWithHihghNonce",
- "TransactionWithRvalueWrongSize",
- "TransactionWithSvalueHigh",
- "TransactionWithSvalueTooHigh",
- "TransactionWithSvalueWrongSize",
- "ValuesAsDec",
- "ValuesAsHex",
- "libsecp256k1test",
- "unpadedRValue",
+ "TransactionWithHihghNonce", // fails due to testing upper bound of 256 bit nonce
+ "TransactionWithSvalueHigh", // fails due to C++ wrong ECDSA r,s ranges. see https://github.com/ethereum/yellowpaper/pull/112
}
for _, name := range snafus {
@@ -42,3 +34,18 @@ func TestWrongRLPTransactions(t *testing.T) {
t.Fatal(err)
}
}
+
+/*
+
+Not working until it's fields are in HEX
+
+func Test10MBtx(t *testing.T) {
+ notWorking := make(map[string]bool, 100)
+ var err error
+ err = RunTransactionTests("./files/TransactionTests/tt10mbDataField.json",
+ notWorking)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+*/
diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go
index 1b2ee88b1..567aba66f 100644
--- a/tests/transaction_test_util.go
+++ b/tests/transaction_test_util.go
@@ -90,9 +90,16 @@ func runTest(txTest TransactionTest) (err error) {
if expectedV != uint64(tx.V) {
return fmt.Errorf("V mismatch: %v %v", expectedV, uint64(tx.V))
}
- if expectedTo != *tx.Recipient {
- return fmt.Errorf("To mismatch: %v %v", expectedTo, *tx.Recipient)
+ if tx.Recipient == nil {
+ if expectedTo != common.BytesToAddress([]byte{}) { // "empty" or "zero" address
+ return fmt.Errorf("To mismatch when recipient is nil (contract creation): %v", expectedTo)
+ }
+ } else {
+ if expectedTo != *tx.Recipient {
+ return fmt.Errorf("To mismatch: %v %v", expectedTo, *tx.Recipient)
+ }
}
+
if expectedValue.Cmp(tx.Amount) != 0 {
return fmt.Errorf("Value mismatch: %v %v", expectedValue, tx.Amount)
}
@@ -120,14 +127,14 @@ func convertTestTypes(txTest TransactionTest) (sender, to common.Address,
txInputData = mustConvertBytes(txTest.Transaction.Data)
rlpBytes = mustConvertBytes(txTest.Rlp)
- gasLimit = mustConvertBigInt10(txTest.Transaction.GasLimit)
- gasPrice = mustConvertBigInt10(txTest.Transaction.GasPrice)
- value = mustConvertBigInt10(txTest.Transaction.Value)
+ gasLimit = mustConvertBigInt(txTest.Transaction.GasLimit)
+ gasPrice = mustConvertBigInt(txTest.Transaction.GasPrice)
+ value = mustConvertBigInt(txTest.Transaction.Value)
r = common.Bytes2Big(mustConvertBytes(txTest.Transaction.R))
s = common.Bytes2Big(mustConvertBytes(txTest.Transaction.S))
- nonce = mustConvertUintHex(txTest.Transaction.Nonce)
+ nonce = mustConvertUint(txTest.Transaction.Nonce)
v = mustConvertUint(txTest.Transaction.V)
return sender, to, txInputData, rlpBytes, gasLimit, gasPrice, value, r, s, nonce, v, nil
diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go
index 3c2d0a4b9..50b0626f5 100644
--- a/ui/qt/qwhisper/whisper.go
+++ b/ui/qt/qwhisper/whisper.go
@@ -41,7 +41,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
TTL: time.Duration(ttl) * time.Second,
To: crypto.ToECDSAPub(common.FromHex(to)),
From: key,
- Topics: whisper.TopicsFromString(topics...),
+ Topics: whisper.NewTopicsFromStrings(topics...),
})
if err != nil {
@@ -106,7 +106,7 @@ func filterFromMap(opts map[string]interface{}) (f whisper.Filter) {
if topicList, ok := opts["topics"].(*qml.List); ok {
var topics []string
topicList.Convert(&topics)
- f.Topics = whisper.TopicsFromString(topics...)
+ f.Topics = whisper.NewTopicsFromStrings(topics...)
}
return
diff --git a/whisper/envelope.go b/whisper/envelope.go
index f35a40a42..07762c300 100644
--- a/whisper/envelope.go
+++ b/whisper/envelope.go
@@ -20,16 +20,16 @@ import (
type Envelope struct {
Expiry uint32 // Whisper protocol specifies int32, really should be int64
TTL uint32 // ^^^^^^
- Topics [][]byte
+ Topics []Topic
Data []byte
Nonce uint32
- hash common.Hash
+ hash common.Hash // Cached hash of the envelope to avoid rehashing every time
}
// NewEnvelope wraps a Whisper message with expiration and destination data
// included into an envelope for network forwarding.
-func NewEnvelope(ttl time.Duration, topics [][]byte, msg *Message) *Envelope {
+func NewEnvelope(ttl time.Duration, topics []Topic, msg *Message) *Envelope {
return &Envelope{
Expiry: uint32(time.Now().Add(ttl).Unix()),
TTL: uint32(ttl.Seconds()),
@@ -59,16 +59,6 @@ func (self *Envelope) Seal(pow time.Duration) {
}
}
-// valid checks whether the claimed proof of work was indeed executed.
-// TODO: Is this really useful? Isn't this always true?
-func (self *Envelope) valid() bool {
- d := make([]byte, 64)
- copy(d[:32], self.rlpWithoutNonce())
- binary.BigEndian.PutUint32(d[60:], self.Nonce)
-
- return common.FirstBitSet(common.BigD(crypto.Sha3(d))) > 0
-}
-
// rlpWithoutNonce returns the RLP encoded envelope contents, except the nonce.
func (self *Envelope) rlpWithoutNonce() []byte {
enc, _ := rlp.EncodeToBytes([]interface{}{self.Expiry, self.TTL, self.Topics, self.Data})
@@ -85,20 +75,19 @@ func (self *Envelope) Open(key *ecdsa.PrivateKey) (msg *Message, err error) {
}
data = data[1:]
- if message.Flags&128 == 128 {
- if len(data) < 65 {
- return nil, fmt.Errorf("unable to open envelope. First bit set but len(data) < 65")
+ if message.Flags&signatureFlag == signatureFlag {
+ if len(data) < signatureLength {
+ return nil, fmt.Errorf("unable to open envelope. First bit set but len(data) < len(signature)")
}
- message.Signature, data = data[:65], data[65:]
+ message.Signature, data = data[:signatureLength], data[signatureLength:]
}
message.Payload = data
- // Short circuit if the encryption was requested
+ // Decrypt the message, if requested
if key == nil {
return message, nil
}
- // Otherwise try to decrypt the message
- message.Payload, err = crypto.Decrypt(key, message.Payload)
+ err = message.decrypt(key)
switch err {
case nil:
return message, nil
@@ -120,16 +109,17 @@ func (self *Envelope) Hash() common.Hash {
return self.hash
}
-// rlpenv is an Envelope but is not an rlp.Decoder.
-// It is used for decoding because we need to
-type rlpenv Envelope
-
// DecodeRLP decodes an Envelope from an RLP data stream.
func (self *Envelope) DecodeRLP(s *rlp.Stream) error {
raw, err := s.Raw()
if err != nil {
return err
}
+ // The decoding of Envelope uses the struct fields but also needs
+ // to compute the hash of the whole RLP-encoded envelope. This
+ // type has the same structure as Envelope but is not an
+ // rlp.Decoder so we can reuse the Envelope struct definition.
+ type rlpenv Envelope
if err := rlp.DecodeBytes(raw, (*rlpenv)(self)); err != nil {
return err
}
diff --git a/whisper/filter.go b/whisper/filter.go
index b33f2c1a2..8fcc45afd 100644
--- a/whisper/filter.go
+++ b/whisper/filter.go
@@ -1,10 +1,13 @@
+// Contains the message filter for fine grained subscriptions.
+
package whisper
import "crypto/ecdsa"
+// Filter is used to subscribe to specific types of whisper messages.
type Filter struct {
- To *ecdsa.PublicKey
- From *ecdsa.PublicKey
- Topics [][]byte
- Fn func(*Message)
+ To *ecdsa.PublicKey // Recipient of the message
+ From *ecdsa.PublicKey // Sender of the message
+ Topics []Topic // Topics to watch messages on
+ Fn func(*Message) // Handler in case of a match
}
diff --git a/whisper/main.go b/whisper/main.go
index 422f0fa3b..3c8c3801f 100644
--- a/whisper/main.go
+++ b/whisper/main.go
@@ -69,10 +69,10 @@ func selfSend(shh *whisper.Whisper, payload []byte) error {
})
// Wrap the payload and encrypt it
msg := whisper.NewMessage(payload)
- envelope, err := msg.Wrap(whisper.DefaultProofOfWork, whisper.Options{
+ envelope, err := msg.Wrap(whisper.DefaultPoW, whisper.Options{
From: id,
To: &id.PublicKey,
- TTL: whisper.DefaultTimeToLive,
+ TTL: whisper.DefaultTTL,
})
if err != nil {
return fmt.Errorf("failed to seal message: %v", err)
diff --git a/whisper/message.go b/whisper/message.go
index 2666ee6e0..07c673567 100644
--- a/whisper/message.go
+++ b/whisper/message.go
@@ -30,13 +30,14 @@ type Options struct {
From *ecdsa.PrivateKey
To *ecdsa.PublicKey
TTL time.Duration
- Topics [][]byte
+ Topics []Topic
}
// NewMessage creates and initializes a non-signed, non-encrypted Whisper message.
func NewMessage(payload []byte) *Message {
- // Construct an initial flag set: bit #1 = 0 (no signature), rest random
- flags := byte(rand.Intn(128))
+ // Construct an initial flag set: no signature, rest random
+ flags := byte(rand.Intn(256))
+ flags &= ^signatureFlag
// Assemble and return the message
return &Message{
@@ -61,7 +62,7 @@ func NewMessage(payload []byte) *Message {
func (self *Message) Wrap(pow time.Duration, options Options) (*Envelope, error) {
// Use the default TTL if non was specified
if options.TTL == 0 {
- options.TTL = DefaultTimeToLive
+ options.TTL = DefaultTTL
}
// Sign and encrypt the message if requested
if options.From != nil {
@@ -84,7 +85,7 @@ func (self *Message) Wrap(pow time.Duration, options Options) (*Envelope, error)
// sign calculates and sets the cryptographic signature for the message , also
// setting the sign flag.
func (self *Message) sign(key *ecdsa.PrivateKey) (err error) {
- self.Flags |= 1 << 7
+ self.Flags |= signatureFlag
self.Signature, err = crypto.Sign(self.hash(), key)
return
}
@@ -93,6 +94,11 @@ func (self *Message) sign(key *ecdsa.PrivateKey) (err error) {
func (self *Message) Recover() *ecdsa.PublicKey {
defer func() { recover() }() // in case of invalid signature
+ // Short circuit if no signature is present
+ if self.Signature == nil {
+ return nil
+ }
+ // Otherwise try and recover the signature
pub, err := crypto.SigToPub(self.hash(), self.Signature)
if err != nil {
glog.V(logger.Error).Infof("Could not get public key from signature: %v", err)
@@ -102,8 +108,14 @@ func (self *Message) Recover() *ecdsa.PublicKey {
}
// encrypt encrypts a message payload with a public key.
-func (self *Message) encrypt(to *ecdsa.PublicKey) (err error) {
- self.Payload, err = crypto.Encrypt(to, self.Payload)
+func (self *Message) encrypt(key *ecdsa.PublicKey) (err error) {
+ self.Payload, err = crypto.Encrypt(key, self.Payload)
+ return
+}
+
+// decrypt decrypts an encrypted payload with a private key.
+func (self *Message) decrypt(key *ecdsa.PrivateKey) (err error) {
+ self.Payload, err = crypto.Decrypt(key, self.Payload)
return
}
diff --git a/whisper/message_test.go b/whisper/message_test.go
index 8d4c5e990..18a254e5c 100644
--- a/whisper/message_test.go
+++ b/whisper/message_test.go
@@ -13,11 +13,11 @@ func TestMessageSimpleWrap(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- if _, err := msg.Wrap(DefaultProofOfWork, Options{}); err != nil {
+ if _, err := msg.Wrap(DefaultPoW, Options{}); err != nil {
t.Fatalf("failed to wrap message: %v", err)
}
- if msg.Flags&128 != 0 {
- t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 0)
+ if msg.Flags&signatureFlag != 0 {
+ t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, 0)
}
if len(msg.Signature) != 0 {
t.Fatalf("signature found for simple wrapping: 0x%x", msg.Signature)
@@ -36,13 +36,13 @@ func TestMessageCleartextSignRecover(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- if _, err := msg.Wrap(DefaultProofOfWork, Options{
+ if _, err := msg.Wrap(DefaultPoW, Options{
From: key,
}); err != nil {
t.Fatalf("failed to sign message: %v", err)
}
- if msg.Flags&128 != 128 {
- t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 1)
+ if msg.Flags&signatureFlag != signatureFlag {
+ t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, signatureFlag)
}
if bytes.Compare(msg.Payload, payload) != 0 {
t.Fatalf("payload mismatch after signing: have 0x%x, want 0x%x", msg.Payload, payload)
@@ -69,14 +69,14 @@ func TestMessageAnonymousEncryptDecrypt(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
To: &key.PublicKey,
})
if err != nil {
t.Fatalf("failed to encrypt message: %v", err)
}
- if msg.Flags&128 != 0 {
- t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 0)
+ if msg.Flags&signatureFlag != 0 {
+ t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, 0)
}
if len(msg.Signature) != 0 {
t.Fatalf("signature found for anonymous message: 0x%x", msg.Signature)
@@ -104,15 +104,15 @@ func TestMessageFullCrypto(t *testing.T) {
payload := []byte("hello world")
msg := NewMessage(payload)
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
+ envelope, err := msg.Wrap(DefaultPoW, Options{
From: fromKey,
To: &toKey.PublicKey,
})
if err != nil {
t.Fatalf("failed to encrypt message: %v", err)
}
- if msg.Flags&128 != 128 {
- t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 1)
+ if msg.Flags&signatureFlag != signatureFlag {
+ t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, signatureFlag)
}
if len(msg.Signature) == 0 {
t.Fatalf("no signature found for signed message")
diff --git a/whisper/peer.go b/whisper/peer.go
index 338166c25..28abf4260 100644
--- a/whisper/peer.go
+++ b/whisper/peer.go
@@ -4,110 +4,160 @@ import (
"fmt"
"time"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
"gopkg.in/fatih/set.v0"
)
-const (
- protocolVersion uint64 = 0x02
-)
-
+// peer represents a whisper protocol peer connection.
type peer struct {
host *Whisper
peer *p2p.Peer
ws p2p.MsgReadWriter
- // XXX Eventually this is going to reach exceptional large space. We need an expiry here
- known *set.Set
+ known *set.Set // Messages already known by the peer to avoid wasting bandwidth
quit chan struct{}
}
-func NewPeer(host *Whisper, p *p2p.Peer, ws p2p.MsgReadWriter) *peer {
- return &peer{host, p, ws, set.New(), make(chan struct{})}
-}
-
-func (self *peer) init() error {
- if err := self.handleStatus(); err != nil {
- return err
+// newPeer creates and initializes a new whisper peer connection, returning either
+// the newly constructed link or a failure reason.
+func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) (*peer, error) {
+ p := &peer{
+ host: host,
+ peer: remote,
+ ws: rw,
+ known: set.New(),
+ quit: make(chan struct{}),
}
-
- return nil
+ if err := p.handshake(); err != nil {
+ return nil, err
+ }
+ return p, nil
}
+// start initiates the peer updater, periodically broadcasting the whisper packets
+// into the network.
func (self *peer) start() {
go self.update()
self.peer.Debugln("whisper started")
}
+// stop terminates the peer updater, stopping message forwarding to it.
func (self *peer) stop() {
+ close(self.quit)
self.peer.Debugln("whisper stopped")
+}
- close(self.quit)
+// handshake sends the protocol initiation status message to the remote peer and
+// verifies the remote status too.
+func (self *peer) handshake() error {
+ // Send the handshake status message asynchronously
+ errc := make(chan error, 1)
+ go func() {
+ errc <- p2p.SendItems(self.ws, statusCode, protocolVersion)
+ }()
+ // Fetch the remote status packet and verify protocol match
+ packet, err := self.ws.ReadMsg()
+ if err != nil {
+ return err
+ }
+ if packet.Code != statusCode {
+ return fmt.Errorf("peer sent %x before status packet", packet.Code)
+ }
+ s := rlp.NewStream(packet.Payload, uint64(packet.Size))
+ if _, err := s.List(); err != nil {
+ return fmt.Errorf("bad status message: %v", err)
+ }
+ peerVersion, err := s.Uint()
+ if err != nil {
+ return fmt.Errorf("bad status message: %v", err)
+ }
+ if peerVersion != protocolVersion {
+ return fmt.Errorf("protocol version mismatch %d != %d", peerVersion, protocolVersion)
+ }
+ // Wait until out own status is consumed too
+ if err := <-errc; err != nil {
+ return fmt.Errorf("failed to send status packet: %v", err)
+ }
+ return nil
}
+// update executes periodic operations on the peer, including message transmission
+// and expiration.
func (self *peer) update() {
- relay := time.NewTicker(300 * time.Millisecond)
-out:
+ // Start the tickers for the updates
+ expire := time.NewTicker(expirationCycle)
+ transmit := time.NewTicker(transmissionCycle)
+
+ // Loop and transmit until termination is requested
for {
select {
- case <-relay.C:
- err := self.broadcast(self.host.envelopes())
- if err != nil {
- self.peer.Infoln("broadcast err:", err)
- break out
+ case <-expire.C:
+ self.expire()
+
+ case <-transmit.C:
+ if err := self.broadcast(); err != nil {
+ self.peer.Infoln("broadcast failed:", err)
+ return
}
case <-self.quit:
- break out
+ return
}
}
}
-func (self *peer) broadcast(envelopes []*Envelope) error {
- envs := make([]*Envelope, 0, len(envelopes))
- for _, env := range envelopes {
- if !self.known.Has(env.Hash()) {
- envs = append(envs, env)
- self.known.Add(env.Hash())
- }
- }
- if len(envs) > 0 {
- if err := p2p.Send(self.ws, envelopesMsg, envs); err != nil {
- return err
- }
- self.peer.DebugDetailln("broadcasted", len(envs), "message(s)")
- }
- return nil
+// mark marks an envelope known to the peer so that it won't be sent back.
+func (self *peer) mark(envelope *Envelope) {
+ self.known.Add(envelope.Hash())
}
-func (self *peer) addKnown(envelope *Envelope) {
- self.known.Add(envelope.Hash())
+// marked checks if an envelope is already known to the remote peer.
+func (self *peer) marked(envelope *Envelope) bool {
+ return self.known.Has(envelope.Hash())
}
-func (self *peer) handleStatus() error {
- ws := self.ws
- if err := p2p.SendItems(ws, statusMsg, protocolVersion); err != nil {
- return err
- }
- msg, err := ws.ReadMsg()
- if err != nil {
- return err
+// expire iterates over all the known envelopes in the host and removes all
+// expired (unknown) ones from the known list.
+func (self *peer) expire() {
+ // Assemble the list of available envelopes
+ available := set.NewNonTS()
+ for _, envelope := range self.host.envelopes() {
+ available.Add(envelope.Hash())
}
- if msg.Code != statusMsg {
- return fmt.Errorf("peer send %x before status msg", msg.Code)
- }
- s := rlp.NewStream(msg.Payload)
- if _, err := s.List(); err != nil {
- return fmt.Errorf("bad status message: %v", err)
+ // Cross reference availability with known status
+ unmark := make(map[common.Hash]struct{})
+ self.known.Each(func(v interface{}) bool {
+ if !available.Has(v.(common.Hash)) {
+ unmark[v.(common.Hash)] = struct{}{}
+ }
+ return true
+ })
+ // Dump all known but unavailable
+ for hash, _ := range unmark {
+ self.known.Remove(hash)
}
- pv, err := s.Uint()
- if err != nil {
- return fmt.Errorf("bad status message: %v", err)
+}
+
+// broadcast iterates over the collection of envelopes and transmits yet unknown
+// ones over the network.
+func (self *peer) broadcast() error {
+ // Fetch the envelopes and collect the unknown ones
+ envelopes := self.host.envelopes()
+ transmit := make([]*Envelope, 0, len(envelopes))
+ for _, envelope := range envelopes {
+ if !self.marked(envelope) {
+ transmit = append(transmit, envelope)
+ self.mark(envelope)
+ }
}
- if pv != protocolVersion {
- return fmt.Errorf("protocol version mismatch %d != %d", pv, protocolVersion)
+ // Transmit the unknown batch (potentially empty)
+ if err := p2p.Send(self.ws, messagesCode, transmit); err != nil {
+ return err
}
- return msg.Discard() // ignore anything after protocol version
+ self.peer.DebugDetailln("broadcasted", len(transmit), "message(s)")
+
+ return nil
}
diff --git a/whisper/peer_test.go b/whisper/peer_test.go
new file mode 100644
index 000000000..9008cdc59
--- /dev/null
+++ b/whisper/peer_test.go
@@ -0,0 +1,242 @@
+package whisper
+
+import (
+ "testing"
+ "time"
+
+ "github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/p2p/discover"
+)
+
+type testPeer struct {
+ client *Whisper
+ stream *p2p.MsgPipeRW
+ termed chan struct{}
+}
+
+func startTestPeer() *testPeer {
+ // Create a simulated P2P remote peer and data streams to it
+ remote := p2p.NewPeer(discover.NodeID{}, "", nil)
+ tester, tested := p2p.MsgPipe()
+
+ // Create a whisper client and connect with it to the tester peer
+ client := New()
+ client.Start()
+
+ termed := make(chan struct{})
+ go func() {
+ defer client.Stop()
+ defer close(termed)
+ defer tested.Close()
+
+ client.handlePeer(remote, tested)
+ }()
+
+ return &testPeer{
+ client: client,
+ stream: tester,
+ termed: termed,
+ }
+}
+
+func startTestPeerInited() (*testPeer, error) {
+ peer := startTestPeer()
+
+ if err := p2p.ExpectMsg(peer.stream, statusCode, []uint64{protocolVersion}); err != nil {
+ peer.stream.Close()
+ return nil, err
+ }
+ if err := p2p.SendItems(peer.stream, statusCode, protocolVersion); err != nil {
+ peer.stream.Close()
+ return nil, err
+ }
+ return peer, nil
+}
+
+func TestPeerStatusMessage(t *testing.T) {
+ tester := startTestPeer()
+
+ // Wait for the handshake status message and check it
+ if err := p2p.ExpectMsg(tester.stream, statusCode, []uint64{protocolVersion}); err != nil {
+ t.Fatalf("status message mismatch: %v", err)
+ }
+ // Terminate the node
+ tester.stream.Close()
+
+ select {
+ case <-tester.termed:
+ case <-time.After(time.Second):
+ t.Fatalf("local close timed out")
+ }
+}
+
+func TestPeerHandshakeFail(t *testing.T) {
+ tester := startTestPeer()
+
+ // Wait for and check the handshake
+ if err := p2p.ExpectMsg(tester.stream, statusCode, []uint64{protocolVersion}); err != nil {
+ t.Fatalf("status message mismatch: %v", err)
+ }
+ // Send an invalid handshake status and verify disconnect
+ if err := p2p.SendItems(tester.stream, messagesCode); err != nil {
+ t.Fatalf("failed to send malformed status: %v", err)
+ }
+ select {
+ case <-tester.termed:
+ case <-time.After(time.Second):
+ t.Fatalf("remote close timed out")
+ }
+}
+
+func TestPeerHandshakeSuccess(t *testing.T) {
+ tester := startTestPeer()
+
+ // Wait for and check the handshake
+ if err := p2p.ExpectMsg(tester.stream, statusCode, []uint64{protocolVersion}); err != nil {
+ t.Fatalf("status message mismatch: %v", err)
+ }
+ // Send a valid handshake status and make sure connection stays live
+ if err := p2p.SendItems(tester.stream, statusCode, protocolVersion); err != nil {
+ t.Fatalf("failed to send status: %v", err)
+ }
+ select {
+ case <-tester.termed:
+ t.Fatalf("valid handshake disconnected")
+
+ case <-time.After(100 * time.Millisecond):
+ }
+ // Clean up the test
+ tester.stream.Close()
+
+ select {
+ case <-tester.termed:
+ case <-time.After(time.Second):
+ t.Fatalf("local close timed out")
+ }
+}
+
+func TestPeerSend(t *testing.T) {
+ // Start a tester and execute the handshake
+ tester, err := startTestPeerInited()
+ if err != nil {
+ t.Fatalf("failed to start initialized peer: %v", err)
+ }
+ defer tester.stream.Close()
+
+ // Construct a message and inject into the tester
+ message := NewMessage([]byte("peer broadcast test message"))
+ envelope, err := message.Wrap(DefaultPoW, Options{
+ TTL: DefaultTTL,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := tester.client.Send(envelope); err != nil {
+ t.Fatalf("failed to send message: %v", err)
+ }
+ // Check that the message is eventually forwarded
+ payload := []interface{}{envelope}
+ if err := p2p.ExpectMsg(tester.stream, messagesCode, payload); err != nil {
+ t.Fatalf("message mismatch: %v", err)
+ }
+ // Make sure that even with a re-insert, an empty batch is received
+ if err := tester.client.Send(envelope); err != nil {
+ t.Fatalf("failed to send message: %v", err)
+ }
+ if err := p2p.ExpectMsg(tester.stream, messagesCode, []interface{}{}); err != nil {
+ t.Fatalf("message mismatch: %v", err)
+ }
+}
+
+func TestPeerDeliver(t *testing.T) {
+ // Start a tester and execute the handshake
+ tester, err := startTestPeerInited()
+ if err != nil {
+ t.Fatalf("failed to start initialized peer: %v", err)
+ }
+ defer tester.stream.Close()
+
+ // Watch for all inbound messages
+ arrived := make(chan struct{}, 1)
+ tester.client.Watch(Filter{
+ Fn: func(message *Message) {
+ arrived <- struct{}{}
+ },
+ })
+ // Construct a message and deliver it to the tester peer
+ message := NewMessage([]byte("peer broadcast test message"))
+ envelope, err := message.Wrap(DefaultPoW, Options{
+ TTL: DefaultTTL,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := p2p.Send(tester.stream, messagesCode, []*Envelope{envelope}); err != nil {
+ t.Fatalf("failed to transfer message: %v", err)
+ }
+ // Check that the message is delivered upstream
+ select {
+ case <-arrived:
+ case <-time.After(time.Second):
+ t.Fatalf("message delivery timeout")
+ }
+ // Check that a resend is not delivered
+ if err := p2p.Send(tester.stream, messagesCode, []*Envelope{envelope}); err != nil {
+ t.Fatalf("failed to transfer message: %v", err)
+ }
+ select {
+ case <-time.After(2 * transmissionCycle):
+ case <-arrived:
+ t.Fatalf("repeating message arrived")
+ }
+}
+
+func TestPeerMessageExpiration(t *testing.T) {
+ // Start a tester and execute the handshake
+ tester, err := startTestPeerInited()
+ if err != nil {
+ t.Fatalf("failed to start initialized peer: %v", err)
+ }
+ defer tester.stream.Close()
+
+ // Fetch the peer instance for later inspection
+ tester.client.peerMu.RLock()
+ if peers := len(tester.client.peers); peers != 1 {
+ t.Fatalf("peer pool size mismatch: have %v, want %v", peers, 1)
+ }
+ var peer *peer
+ for peer, _ = range tester.client.peers {
+ break
+ }
+ tester.client.peerMu.RUnlock()
+
+ // Construct a message and pass it through the tester
+ message := NewMessage([]byte("peer test message"))
+ envelope, err := message.Wrap(DefaultPoW, Options{
+ TTL: time.Second,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := tester.client.Send(envelope); err != nil {
+ t.Fatalf("failed to send message: %v", err)
+ }
+ payload := []interface{}{envelope}
+ if err := p2p.ExpectMsg(tester.stream, messagesCode, payload); err != nil {
+ t.Fatalf("message mismatch: %v", err)
+ }
+ // Check that the message is inside the cache
+ if !peer.known.Has(envelope.Hash()) {
+ t.Fatalf("message not found in cache")
+ }
+ // Discard messages until expiration and check cache again
+ exp := time.Now().Add(time.Second + expirationCycle)
+ for time.Now().Before(exp) {
+ if err := p2p.ExpectMsg(tester.stream, messagesCode, []interface{}{}); err != nil {
+ t.Fatalf("message mismatch: %v", err)
+ }
+ }
+ if peer.known.Has(envelope.Hash()) {
+ t.Fatalf("message not expired from cache")
+ }
+}
diff --git a/whisper/sort.go b/whisper/sort.go
deleted file mode 100644
index 313ba5ac0..000000000
--- a/whisper/sort.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package whisper
-
-import (
- "sort"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-type sortedKeys struct {
- k []int32
-}
-
-func (self *sortedKeys) Len() int { return len(self.k) }
-func (self *sortedKeys) Less(i, j int) bool { return self.k[i] < self.k[j] }
-func (self *sortedKeys) Swap(i, j int) { self.k[i], self.k[j] = self.k[j], self.k[i] }
-
-func sortKeys(m map[int32]common.Hash) []int32 {
- sorted := new(sortedKeys)
- sorted.k = make([]int32, len(m))
- i := 0
- for key, _ := range m {
- sorted.k[i] = key
- i++
- }
-
- sort.Sort(sorted)
-
- return sorted.k
-}
diff --git a/whisper/sort_test.go b/whisper/sort_test.go
deleted file mode 100644
index a61fde4c2..000000000
--- a/whisper/sort_test.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package whisper
-
-import (
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
-)
-
-func TestSorting(t *testing.T) {
- m := map[int32]common.Hash{
- 1: {1},
- 3: {3},
- 2: {2},
- 5: {5},
- }
- exp := []int32{1, 2, 3, 5}
- res := sortKeys(m)
- for i, k := range res {
- if k != exp[i] {
- t.Error(k, "failed. Expected", exp[i])
- }
- }
-}
diff --git a/whisper/topic.go b/whisper/topic.go
new file mode 100644
index 000000000..a965c7cc2
--- /dev/null
+++ b/whisper/topic.go
@@ -0,0 +1,61 @@
+// Contains the Whisper protocol Topic element. For formal details please see
+// the specs at https://github.com/ethereum/wiki/wiki/Whisper-PoC-1-Protocol-Spec#topics.
+
+package whisper
+
+import "github.com/ethereum/go-ethereum/crypto"
+
+// Topic represents a cryptographically secure, probabilistic partial
+// classifications of a message, determined as the first (left) 4 bytes of the
+// SHA3 hash of some arbitrary data given by the original author of the message.
+type Topic [4]byte
+
+// NewTopic creates a topic from the 4 byte prefix of the SHA3 hash of the data.
+func NewTopic(data []byte) Topic {
+ prefix := [4]byte{}
+ copy(prefix[:], crypto.Sha3(data)[:4])
+ return Topic(prefix)
+}
+
+// NewTopics creates a list of topics from a list of binary data elements, by
+// iteratively calling NewTopic on each of them.
+func NewTopics(data ...[]byte) []Topic {
+ topics := make([]Topic, len(data))
+ for i, element := range data {
+ topics[i] = NewTopic(element)
+ }
+ return topics
+}
+
+// NewTopicFromString creates a topic using the binary data contents of the
+// specified string.
+func NewTopicFromString(data string) Topic {
+ return NewTopic([]byte(data))
+}
+
+// NewTopicsFromStrings creates a list of topics from a list of textual data
+// elements, by iteratively calling NewTopicFromString on each of them.
+func NewTopicsFromStrings(data ...string) []Topic {
+ topics := make([]Topic, len(data))
+ for i, element := range data {
+ topics[i] = NewTopicFromString(element)
+ }
+ return topics
+}
+
+// String converts a topic byte array to a string representation.
+func (self *Topic) String() string {
+ return string(self[:])
+}
+
+// TopicSet represents a hash set to check if a topic exists or not.
+type topicSet map[string]struct{}
+
+// NewTopicSet creates a topic hash set from a slice of topics.
+func newTopicSet(topics []Topic) topicSet {
+ set := make(map[string]struct{})
+ for _, topic := range topics {
+ set[topic.String()] = struct{}{}
+ }
+ return topicSet(set)
+}
diff --git a/whisper/topic_test.go b/whisper/topic_test.go
new file mode 100644
index 000000000..4015079dc
--- /dev/null
+++ b/whisper/topic_test.go
@@ -0,0 +1,67 @@
+package whisper
+
+import (
+ "bytes"
+ "testing"
+)
+
+var topicCreationTests = []struct {
+ data []byte
+ hash [4]byte
+}{
+ {hash: [4]byte{0xc5, 0xd2, 0x46, 0x01}, data: nil},
+ {hash: [4]byte{0xc5, 0xd2, 0x46, 0x01}, data: []byte{}},
+ {hash: [4]byte{0x8f, 0x9a, 0x2b, 0x7d}, data: []byte("test name")},
+}
+
+func TestTopicCreation(t *testing.T) {
+ // Create the topics individually
+ for i, tt := range topicCreationTests {
+ topic := NewTopic(tt.data)
+ if bytes.Compare(topic[:], tt.hash[:]) != 0 {
+ t.Errorf("binary test %d: hash mismatch: have %v, want %v.", i, topic, tt.hash)
+ }
+ }
+ for i, tt := range topicCreationTests {
+ topic := NewTopicFromString(string(tt.data))
+ if bytes.Compare(topic[:], tt.hash[:]) != 0 {
+ t.Errorf("textual test %d: hash mismatch: have %v, want %v.", i, topic, tt.hash)
+ }
+ }
+ // Create the topics in batches
+ binaryData := make([][]byte, len(topicCreationTests))
+ for i, tt := range topicCreationTests {
+ binaryData[i] = tt.data
+ }
+ textualData := make([]string, len(topicCreationTests))
+ for i, tt := range topicCreationTests {
+ textualData[i] = string(tt.data)
+ }
+
+ topics := NewTopics(binaryData...)
+ for i, tt := range topicCreationTests {
+ if bytes.Compare(topics[i][:], tt.hash[:]) != 0 {
+ t.Errorf("binary batch test %d: hash mismatch: have %v, want %v.", i, topics[i], tt.hash)
+ }
+ }
+ topics = NewTopicsFromStrings(textualData...)
+ for i, tt := range topicCreationTests {
+ if bytes.Compare(topics[i][:], tt.hash[:]) != 0 {
+ t.Errorf("textual batch test %d: hash mismatch: have %v, want %v.", i, topics[i], tt.hash)
+ }
+ }
+}
+
+func TestTopicSetCreation(t *testing.T) {
+ topics := make([]Topic, len(topicCreationTests))
+ for i, tt := range topicCreationTests {
+ topics[i] = NewTopic(tt.data)
+ }
+ set := newTopicSet(topics)
+ for i, tt := range topicCreationTests {
+ topic := NewTopic(tt.data)
+ if _, ok := set[topic.String()]; !ok {
+ t.Errorf("topic %d: not found in set", i)
+ }
+ }
+}
diff --git a/whisper/util.go b/whisper/util.go
deleted file mode 100644
index 7a222395f..000000000
--- a/whisper/util.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package whisper
-
-import "github.com/ethereum/go-ethereum/crypto"
-
-func hashTopic(topic []byte) []byte {
- return crypto.Sha3(topic)[:4]
-}
-
-// NOTE this isn't DRY, but I don't want to iterate twice.
-
-// Returns a formatted topics byte slice.
-// data: unformatted data (e.g., no hashes needed)
-func Topics(data [][]byte) [][]byte {
- d := make([][]byte, len(data))
- for i, byts := range data {
- d[i] = hashTopic(byts)
- }
- return d
-}
-
-func TopicsFromString(data ...string) [][]byte {
- d := make([][]byte, len(data))
- for i, str := range data {
- d[i] = hashTopic([]byte(str))
- }
- return d
-}
-
-func bytesToMap(s [][]byte) map[string]struct{} {
- m := make(map[string]struct{})
- for _, topic := range s {
- m[string(topic)] = struct{}{}
- }
-
- return m
-}
diff --git a/whisper/whisper.go b/whisper/whisper.go
index d803e27d4..9317fad50 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -2,7 +2,6 @@ package whisper
import (
"crypto/ecdsa"
- "errors"
"sync"
"time"
@@ -17,9 +16,22 @@ import (
)
const (
- statusMsg = 0x0
- envelopesMsg = 0x01
- whisperVersion = 0x02
+ statusCode = 0x00
+ messagesCode = 0x01
+
+ protocolVersion uint64 = 0x02
+ protocolName = "shh"
+
+ signatureFlag = byte(1 << 7)
+ signatureLength = 65
+
+ expirationCycle = 800 * time.Millisecond
+ transmissionCycle = 300 * time.Millisecond
+)
+
+const (
+ DefaultTTL = 50 * time.Second
+ DefaultPoW = 50 * time.Millisecond
)
type MessageEvent struct {
@@ -28,250 +40,298 @@ type MessageEvent struct {
Message *Message
}
-const (
- DefaultTimeToLive = 50 * time.Second
- DefaultProofOfWork = 50 * time.Millisecond
-)
-
+// Whisper represents a dark communication interface through the Ethereum
+// network, using its very own P2P communication layer.
type Whisper struct {
protocol p2p.Protocol
filters *filter.Filters
- mmu sync.RWMutex
- messages map[common.Hash]*Envelope
- expiry map[uint32]*set.SetNonTS
+ keys map[string]*ecdsa.PrivateKey
- quit chan struct{}
+ messages map[common.Hash]*Envelope // Pool of messages currently tracked by this node
+ expirations map[uint32]*set.SetNonTS // Message expiration pool (TODO: something lighter)
+ poolMu sync.RWMutex // Mutex to sync the message and expiration pools
- keys map[string]*ecdsa.PrivateKey
+ peers map[*peer]struct{} // Set of currently active peers
+ peerMu sync.RWMutex // Mutex to sync the active peer set
+
+ quit chan struct{}
}
func New() *Whisper {
whisper := &Whisper{
- messages: make(map[common.Hash]*Envelope),
- filters: filter.New(),
- expiry: make(map[uint32]*set.SetNonTS),
- quit: make(chan struct{}),
- keys: make(map[string]*ecdsa.PrivateKey),
+ filters: filter.New(),
+ keys: make(map[string]*ecdsa.PrivateKey),
+ messages: make(map[common.Hash]*Envelope),
+ expirations: make(map[uint32]*set.SetNonTS),
+ peers: make(map[*peer]struct{}),
+ quit: make(chan struct{}),
}
whisper.filters.Start()
// p2p whisper sub protocol handler
whisper.protocol = p2p.Protocol{
- Name: "shh",
- Version: uint(whisperVersion),
+ Name: protocolName,
+ Version: uint(protocolVersion),
Length: 2,
- Run: whisper.msgHandler,
+ Run: whisper.handlePeer,
}
return whisper
}
-func (self *Whisper) Version() uint {
- return self.protocol.Version
-}
-
-func (self *Whisper) Start() {
- glog.V(logger.Info).Infoln("Whisper started")
- go self.update()
-}
-
-func (self *Whisper) Stop() {
- close(self.quit)
+// Protocol returns the whisper sub-protocol handler for this particular client.
+func (self *Whisper) Protocol() p2p.Protocol {
+ return self.protocol
}
-func (self *Whisper) Send(envelope *Envelope) error {
- return self.add(envelope)
+// Version returns the whisper sub-protocols version number.
+func (self *Whisper) Version() uint {
+ return self.protocol.Version
}
+// NewIdentity generates a new cryptographic identity for the client, and injects
+// it into the known identities for message decryption.
func (self *Whisper) NewIdentity() *ecdsa.PrivateKey {
key, err := crypto.GenerateKey()
if err != nil {
panic(err)
}
-
self.keys[string(crypto.FromECDSAPub(&key.PublicKey))] = key
return key
}
+// HasIdentity checks if the the whisper node is configured with the private key
+// of the specified public pair.
func (self *Whisper) HasIdentity(key *ecdsa.PublicKey) bool {
return self.keys[string(crypto.FromECDSAPub(key))] != nil
}
+// GetIdentity retrieves the private key of the specified public identity.
func (self *Whisper) GetIdentity(key *ecdsa.PublicKey) *ecdsa.PrivateKey {
return self.keys[string(crypto.FromECDSAPub(key))]
}
-// func (self *Whisper) RemoveIdentity(key *ecdsa.PublicKey) bool {
-// k := string(crypto.FromECDSAPub(key))
-// if _, ok := self.keys[k]; ok {
-// delete(self.keys, k)
-// return true
-// }
-// return false
-// }
-
-func (self *Whisper) Watch(opts Filter) int {
- return self.filters.Install(filter.Generic{
- Str1: string(crypto.FromECDSAPub(opts.To)),
- Str2: string(crypto.FromECDSAPub(opts.From)),
- Data: bytesToMap(opts.Topics),
+// Watch installs a new message handler to run in case a matching packet arrives
+// from the whisper network.
+func (self *Whisper) Watch(options Filter) int {
+ filter := filter.Generic{
+ Str1: string(crypto.FromECDSAPub(options.To)),
+ Str2: string(crypto.FromECDSAPub(options.From)),
+ Data: newTopicSet(options.Topics),
Fn: func(data interface{}) {
- opts.Fn(data.(*Message))
+ options.Fn(data.(*Message))
},
- })
+ }
+ return self.filters.Install(filter)
}
+// Unwatch removes an installed message handler.
func (self *Whisper) Unwatch(id int) {
self.filters.Uninstall(id)
}
-func (self *Whisper) Messages(id int) (messages []*Message) {
- filter := self.filters.Get(id)
- if filter != nil {
- for _, e := range self.messages {
- if msg, key := self.open(e); msg != nil {
- f := createFilter(msg, e.Topics, key)
- if self.filters.Match(filter, f) {
- messages = append(messages, msg)
+// Send injects a message into the whisper send queue, to be distributed in the
+// network in the coming cycles.
+func (self *Whisper) Send(envelope *Envelope) error {
+ return self.add(envelope)
+}
+
+func (self *Whisper) Start() {
+ glog.V(logger.Info).Infoln("Whisper started")
+ go self.update()
+}
+
+func (self *Whisper) Stop() {
+ close(self.quit)
+ glog.V(logger.Info).Infoln("Whisper stopped")
+}
+
+// Messages retrieves the currently pooled messages matching a filter id.
+func (self *Whisper) Messages(id int) []*Message {
+ messages := make([]*Message, 0)
+ if filter := self.filters.Get(id); filter != nil {
+ for _, envelope := range self.messages {
+ if message := self.open(envelope); message != nil {
+ if self.filters.Match(filter, createFilter(message, envelope.Topics)) {
+ messages = append(messages, message)
}
}
}
}
-
- return
+ return messages
}
-// Main handler for passing whisper messages to whisper peer objects
-func (self *Whisper) msgHandler(peer *p2p.Peer, ws p2p.MsgReadWriter) error {
- wpeer := NewPeer(self, peer, ws)
- // initialise whisper peer (handshake/status)
- if err := wpeer.init(); err != nil {
+// func (self *Whisper) RemoveIdentity(key *ecdsa.PublicKey) bool {
+// k := string(crypto.FromECDSAPub(key))
+// if _, ok := self.keys[k]; ok {
+// delete(self.keys, k)
+// return true
+// }
+// return false
+// }
+
+// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
+// connection is negotiated.
+func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
+ // Create, initialize and start the whisper peer
+ whisperPeer, err := newPeer(self, peer, rw)
+ if err != nil {
return err
}
- // kick of the main handler for broadcasting/managing envelopes
- go wpeer.start()
- defer wpeer.stop()
-
- // Main *read* loop. Writing is done by the peer it self.
+ whisperPeer.start()
+ defer whisperPeer.stop()
+
+ // Start tracking the active peer
+ self.peerMu.Lock()
+ self.peers[whisperPeer] = struct{}{}
+ self.peerMu.Unlock()
+
+ defer func() {
+ self.peerMu.Lock()
+ delete(self.peers, whisperPeer)
+ self.peerMu.Unlock()
+ }()
+ // Read and process inbound messages directly to merge into client-global state
for {
- msg, err := ws.ReadMsg()
+ // Fetch the next packet and decode the contained envelopes
+ packet, err := rw.ReadMsg()
if err != nil {
return err
}
-
var envelopes []*Envelope
- if err := msg.Decode(&envelopes); err != nil {
- peer.Infoln(err)
+ if err := packet.Decode(&envelopes); err != nil {
+ peer.Infof("failed to decode enveloped: %v", err)
continue
}
-
+ // Inject all envelopes into the internal pool
for _, envelope := range envelopes {
if err := self.add(envelope); err != nil {
// TODO Punish peer here. Invalid envelope.
- peer.Debugln(err)
+ peer.Debugf("failed to pool envelope: %f", err)
}
- wpeer.addKnown(envelope)
+ whisperPeer.mark(envelope)
}
}
}
-// takes care of adding envelopes to the messages pool. At this moment no sanity checks are being performed.
+// add inserts a new envelope into the message pool to be distributed within the
+// whisper network. It also inserts the envelope into the expiration pool at the
+// appropriate time-stamp.
func (self *Whisper) add(envelope *Envelope) error {
- if !envelope.valid() {
- return errors.New("invalid pow provided for envelope")
- }
-
- self.mmu.Lock()
- defer self.mmu.Unlock()
+ self.poolMu.Lock()
+ defer self.poolMu.Unlock()
+ // Insert the message into the tracked pool
hash := envelope.Hash()
+ if _, ok := self.messages[hash]; ok {
+ glog.V(logger.Detail).Infof("whisper envelope already cached: %x\n", envelope)
+ return nil
+ }
self.messages[hash] = envelope
- if self.expiry[envelope.Expiry] == nil {
- self.expiry[envelope.Expiry] = set.NewNonTS()
+
+ // Insert the message into the expiration pool for later removal
+ if self.expirations[envelope.Expiry] == nil {
+ self.expirations[envelope.Expiry] = set.NewNonTS()
}
+ if !self.expirations[envelope.Expiry].Has(hash) {
+ self.expirations[envelope.Expiry].Add(hash)
- if !self.expiry[envelope.Expiry].Has(hash) {
- self.expiry[envelope.Expiry].Add(hash)
+ // Notify the local node of a message arrival
go self.postEvent(envelope)
}
+ glog.V(logger.Detail).Infof("cached whisper envelope %x\n", envelope)
- glog.V(logger.Detail).Infof("added whisper envelope %x\n", envelope)
+ return nil
+}
+
+// postEvent opens an envelope with the configured identities and delivers the
+// message upstream from application processing.
+func (self *Whisper) postEvent(envelope *Envelope) {
+ if message := self.open(envelope); message != nil {
+ self.filters.Notify(createFilter(message, envelope.Topics), message)
+ }
+}
+// open tries to decrypt a whisper envelope with all the configured identities,
+// returning the decrypted message and the key used to achieve it. If not keys
+// are configured, open will return the payload as if non encrypted.
+func (self *Whisper) open(envelope *Envelope) *Message {
+ // Short circuit if no identity is set, and assume clear-text
+ if len(self.keys) == 0 {
+ if message, err := envelope.Open(nil); err == nil {
+ return message
+ }
+ }
+ // Iterate over the keys and try to decrypt the message
+ for _, key := range self.keys {
+ message, err := envelope.Open(key)
+ if err == nil || err == ecies.ErrInvalidPublicKey {
+ message.To = &key.PublicKey
+ return message
+ }
+ }
+ // Failed to decrypt, don't return anything
return nil
}
+// createFilter creates a message filter to check against installed handlers.
+func createFilter(message *Message, topics []Topic) filter.Filter {
+ return filter.Generic{
+ Str1: string(crypto.FromECDSAPub(message.To)),
+ Str2: string(crypto.FromECDSAPub(message.Recover())),
+ Data: newTopicSet(topics),
+ }
+}
+
+// update loops until the lifetime of the whisper node, updating its internal
+// state by expiring stale messages from the pool.
func (self *Whisper) update() {
- expire := time.NewTicker(800 * time.Millisecond)
-out:
+ // Start a ticker to check for expirations
+ expire := time.NewTicker(expirationCycle)
+
+ // Repeat updates until termination is requested
for {
select {
case <-expire.C:
self.expire()
+
case <-self.quit:
- break out
+ return
}
}
}
+// expire iterates over all the expiration timestamps, removing all stale
+// messages from the pools.
func (self *Whisper) expire() {
- self.mmu.Lock()
- defer self.mmu.Unlock()
+ self.poolMu.Lock()
+ defer self.poolMu.Unlock()
now := uint32(time.Now().Unix())
- for then, hashSet := range self.expiry {
+ for then, hashSet := range self.expirations {
+ // Short circuit if a future time
if then > now {
continue
}
-
+ // Dump all expired messages and remove timestamp
hashSet.Each(func(v interface{}) bool {
delete(self.messages, v.(common.Hash))
return true
})
- self.expiry[then].Clear()
+ self.expirations[then].Clear()
}
}
-func (self *Whisper) envelopes() (envelopes []*Envelope) {
- self.mmu.RLock()
- defer self.mmu.RUnlock()
+// envelopes retrieves all the messages currently pooled by the node.
+func (self *Whisper) envelopes() []*Envelope {
+ self.poolMu.RLock()
+ defer self.poolMu.RUnlock()
- envelopes = make([]*Envelope, len(self.messages))
- i := 0
+ envelopes := make([]*Envelope, 0, len(self.messages))
for _, envelope := range self.messages {
- envelopes[i] = envelope
- i++
- }
-
- return
-}
-
-func (self *Whisper) postEvent(envelope *Envelope) {
- if message, key := self.open(envelope); message != nil {
- self.filters.Notify(createFilter(message, envelope.Topics, key), message)
- }
-}
-
-func (self *Whisper) open(envelope *Envelope) (*Message, *ecdsa.PrivateKey) {
- for _, key := range self.keys {
- if message, err := envelope.Open(key); err == nil || (err != nil && err == ecies.ErrInvalidPublicKey) {
- message.To = &key.PublicKey
-
- return message, key
- }
- }
-
- return nil, nil
-}
-
-func (self *Whisper) Protocol() p2p.Protocol {
- return self.protocol
-}
-
-func createFilter(message *Message, topics [][]byte, key *ecdsa.PrivateKey) filter.Filter {
- return filter.Generic{
- Str1: string(crypto.FromECDSAPub(&key.PublicKey)), Str2: string(crypto.FromECDSAPub(message.Recover())),
- Data: bytesToMap(topics),
+ envelopes = append(envelopes, envelope)
}
+ return envelopes
}
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go
index b29e34a5e..def8e68d8 100644
--- a/whisper/whisper_test.go
+++ b/whisper/whisper_test.go
@@ -1,38 +1,185 @@
package whisper
import (
- "fmt"
"testing"
"time"
+
+ "github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/p2p/discover"
)
-func TestEvent(t *testing.T) {
- res := make(chan *Message, 1)
- whisper := New()
- id := whisper.NewIdentity()
- whisper.Watch(Filter{
- To: &id.PublicKey,
+func startTestCluster(n int) []*Whisper {
+ // Create the batch of simulated peers
+ nodes := make([]*p2p.Peer, n)
+ for i := 0; i < n; i++ {
+ nodes[i] = p2p.NewPeer(discover.NodeID{}, "", nil)
+ }
+ whispers := make([]*Whisper, n)
+ for i := 0; i < n; i++ {
+ whispers[i] = New()
+ whispers[i].Start()
+ }
+ // Wire all the peers to the root one
+ for i := 1; i < n; i++ {
+ src, dst := p2p.MsgPipe()
+
+ go whispers[0].handlePeer(nodes[i], src)
+ go whispers[i].handlePeer(nodes[0], dst)
+ }
+ return whispers
+}
+
+func TestSelfMessage(t *testing.T) {
+ // Start the single node cluster
+ client := startTestCluster(1)[0]
+
+ // Start watching for self messages, signal any arrivals
+ self := client.NewIdentity()
+ done := make(chan struct{})
+
+ client.Watch(Filter{
+ To: &self.PublicKey,
Fn: func(msg *Message) {
- res <- msg
+ close(done)
},
})
-
- msg := NewMessage([]byte(fmt.Sprintf("Hello world. This is whisper-go. Incase you're wondering; the time is %v", time.Now())))
- envelope, err := msg.Wrap(DefaultProofOfWork, Options{
- TTL: DefaultTimeToLive,
- From: id,
- To: &id.PublicKey,
+ // Send a dummy message to oneself
+ msg := NewMessage([]byte("self whisper"))
+ envelope, err := msg.Wrap(DefaultPoW, Options{
+ From: self,
+ To: &self.PublicKey,
+ TTL: DefaultTTL,
})
if err != nil {
- fmt.Println(err)
- t.FailNow()
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ // Dump the message into the system and wait for it to pop back out
+ if err := client.Send(envelope); err != nil {
+ t.Fatalf("failed to send self-message: %v", err)
+ }
+ select {
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatalf("self-message receive timeout")
}
+}
+
+func TestDirectMessage(t *testing.T) {
+ // Start the sender-recipient cluster
+ cluster := startTestCluster(2)
- tick := time.NewTicker(time.Second)
- whisper.postEvent(envelope)
+ sender := cluster[0]
+ senderId := sender.NewIdentity()
+
+ recipient := cluster[1]
+ recipientId := recipient.NewIdentity()
+
+ // Watch for arriving messages on the recipient
+ done := make(chan struct{})
+ recipient.Watch(Filter{
+ To: &recipientId.PublicKey,
+ Fn: func(msg *Message) {
+ close(done)
+ },
+ })
+ // Send a dummy message from the sender
+ msg := NewMessage([]byte("direct whisper"))
+ envelope, err := msg.Wrap(DefaultPoW, Options{
+ From: senderId,
+ To: &recipientId.PublicKey,
+ TTL: DefaultTTL,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := sender.Send(envelope); err != nil {
+ t.Fatalf("failed to send direct message: %v", err)
+ }
+ // Wait for an arrival or a timeout
select {
- case <-res:
- case <-tick.C:
- t.Error("did not receive message")
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatalf("direct message receive timeout")
+ }
+}
+
+func TestAnonymousBroadcast(t *testing.T) {
+ testBroadcast(true, t)
+}
+
+func TestIdentifiedBroadcast(t *testing.T) {
+ testBroadcast(false, t)
+}
+
+func testBroadcast(anonymous bool, t *testing.T) {
+ // Start the single sender multi recipient cluster
+ cluster := startTestCluster(3)
+
+ sender := cluster[1]
+ targets := cluster[1:]
+ for _, target := range targets {
+ if !anonymous {
+ target.NewIdentity()
+ }
+ }
+ // Watch for arriving messages on the recipients
+ dones := make([]chan struct{}, len(targets))
+ for i := 0; i < len(targets); i++ {
+ done := make(chan struct{}) // need for the closure
+ dones[i] = done
+
+ targets[i].Watch(Filter{
+ Topics: NewTopicsFromStrings("broadcast topic"),
+ Fn: func(msg *Message) {
+ close(done)
+ },
+ })
+ }
+ // Send a dummy message from the sender
+ msg := NewMessage([]byte("broadcast whisper"))
+ envelope, err := msg.Wrap(DefaultPoW, Options{
+ Topics: NewTopicsFromStrings("broadcast topic"),
+ TTL: DefaultTTL,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := sender.Send(envelope); err != nil {
+ t.Fatalf("failed to send broadcast message: %v", err)
+ }
+ // Wait for an arrival on each recipient, or timeouts
+ timeout := time.After(time.Second)
+ for _, done := range dones {
+ select {
+ case <-done:
+ case <-timeout:
+ t.Fatalf("broadcast message receive timeout")
+ }
+ }
+}
+
+func TestMessageExpiration(t *testing.T) {
+ // Start the single node cluster and inject a dummy message
+ node := startTestCluster(1)[0]
+
+ message := NewMessage([]byte("expiring message"))
+ envelope, err := message.Wrap(DefaultPoW, Options{
+ TTL: time.Second,
+ })
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ if err := node.Send(envelope); err != nil {
+ t.Fatalf("failed to inject message: %v", err)
+ }
+ // Check that the message is inside the cache
+ if _, ok := node.messages[envelope.Hash()]; !ok {
+ t.Fatalf("message not found in cache")
+ }
+ // Wait for expiration and check cache again
+ time.Sleep(time.Second) // wait for expiration
+ time.Sleep(expirationCycle) // wait for cleanup cycle
+ if _, ok := node.messages[envelope.Hash()]; ok {
+ t.Fatalf("message not expired from cache")
}
}
diff --git a/xeth/frontend.go b/xeth/frontend.go
index 8deb5c98c..fe1d57c50 100644
--- a/xeth/frontend.go
+++ b/xeth/frontend.go
@@ -1,9 +1,5 @@
package xeth
-import (
- "github.com/ethereum/go-ethereum/core/types"
-)
-
// Frontend should be implemented by users of XEth. Its methods are
// called whenever XEth makes a decision that requires user input.
type Frontend interface {
@@ -21,12 +17,12 @@ type Frontend interface {
//
// ConfirmTransaction is not used for Call transactions
// because they cannot change any state.
- ConfirmTransaction(tx *types.Transaction) bool
+ ConfirmTransaction(tx string) bool
}
// dummyFrontend is a non-interactive frontend that allows all
// transactions but cannot not unlock any keys.
type dummyFrontend struct{}
-func (dummyFrontend) UnlockAccount([]byte) bool { return false }
-func (dummyFrontend) ConfirmTransaction(*types.Transaction) bool { return true }
+func (dummyFrontend) UnlockAccount([]byte) bool { return false }
+func (dummyFrontend) ConfirmTransaction(string) bool { return true }
diff --git a/xeth/whisper.go b/xeth/whisper.go
index 51caec8d6..342910b5c 100644
--- a/xeth/whisper.go
+++ b/xeth/whisper.go
@@ -36,7 +36,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
TTL: time.Duration(ttl) * time.Second,
To: crypto.ToECDSAPub(common.FromHex(to)),
From: key,
- Topics: whisper.TopicsFromString(topics...),
+ Topics: whisper.NewTopicsFromStrings(topics...),
})
if err != nil {
@@ -71,7 +71,7 @@ func (self *Whisper) Watch(opts *Options) int {
filter := whisper.Filter{
To: crypto.ToECDSAPub(common.FromHex(opts.To)),
From: crypto.ToECDSAPub(common.FromHex(opts.From)),
- Topics: whisper.TopicsFromString(opts.Topics...),
+ Topics: whisper.NewTopicsFromStrings(opts.Topics...),
}
var i int
diff --git a/xeth/xeth.go b/xeth/xeth.go
index c1a2ec283..afcb33e4c 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -148,10 +148,10 @@ func (self *XEth) AtStateNum(num int64) *XEth {
}
}
- return self.withState(st)
+ return self.WithState(st)
}
-func (self *XEth) withState(statedb *state.StateDB) *XEth {
+func (self *XEth) WithState(statedb *state.StateDB) *XEth {
xeth := &XEth{
backend: self.backend,
}
@@ -608,6 +608,12 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
return common.ToHex(res), err
}
+func (self *XEth) ConfirmTransaction(tx string) bool {
+
+ return self.frontend.ConfirmTransaction(tx)
+
+}
+
func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
var (
from = common.HexToAddress(fromStr)