aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Godeps/Godeps.json4
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/.gitignore2
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt10
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/MANIFEST.in17
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/Makefile7
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/cryptopp/CMakeLists.txt2
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go296
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/.gitignore2
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/__init__.py3
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/setup.py22
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp2
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt29
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake3
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp59
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h1
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt1
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h649
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h51
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c100
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h2
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp8
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h8
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c303
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp52
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go82
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/go/test.sh20
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/python/requirements.txt1
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh4
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test_pyethash.py104
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh7
-rw-r--r--cmd/ethereum/main.go2
-rw-r--r--cmd/ethtest/main.go17
m---------cmd/mist/assets/ext/ethereum.js0
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.bowerrc5
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.editorconfig12
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.gitignore18
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.jshintrc50
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.npmignore9
-rw-r--r--cmd/mist/assets/ext/ethereum.js/.travis.yml13
-rw-r--r--cmd/mist/assets/ext/ethereum.js/LICENSE14
-rw-r--r--cmd/mist/assets/ext/ethereum.js/README.md96
-rw-r--r--cmd/mist/assets/ext/ethereum.js/bower.json51
-rw-r--r--cmd/mist/assets/ext/ethereum.js/dist/ethereum.js2799
-rw-r--r--cmd/mist/assets/ext/ethereum.js/dist/ethereum.js.map41
-rw-r--r--cmd/mist/assets/ext/ethereum.js/dist/ethereum.min.js1
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/balance.html43
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/contract.html74
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/contract_with_array.html76
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/event.html120
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/event_inc.html66
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/natspec_contract.html77
-rw-r--r--cmd/mist/assets/ext/ethereum.js/example/node-app.js12
-rw-r--r--cmd/mist/assets/ext/ethereum.js/gulpfile.js104
-rw-r--r--cmd/mist/assets/ext/ethereum.js/index.js11
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/abi.js210
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/const.js56
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/contract.js217
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/event.js135
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/filter.js101
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/formatters.js154
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/httpsync.js46
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/jsonrpc.js65
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/local.js18
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/providermanager.js102
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/qtsync.js33
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/types.js79
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/utils.js142
-rw-r--r--cmd/mist/assets/ext/ethereum.js/lib/web3.js256
-rw-r--r--cmd/mist/assets/ext/ethereum.js/package.json69
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/abi.parsers.js860
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/db.methods.js14
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/eth.methods.js34
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/mocha.opts2
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/shh.methods.js14
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/utils.js19
-rw-r--r--cmd/mist/assets/ext/ethereum.js/test/web3.methods.js10
-rw-r--r--cmd/mist/assets/qml/depricated_browser.qml2
-rw-r--r--cmd/mist/ui_lib.go3
-rw-r--r--cmd/utils/flags.go3
-rw-r--r--core/block_processor.go35
-rw-r--r--core/block_processor_test.go2
-rw-r--r--core/chain_makers.go2
-rw-r--r--core/chain_manager.go82
-rw-r--r--core/chain_manager_test.go4
-rw-r--r--core/error.go2
-rw-r--r--core/execution.go11
-rw-r--r--core/genesis.go4
-rw-r--r--core/state_transition.go50
-rw-r--r--core/types/block.go7
-rw-r--r--eth/backend.go19
-rw-r--r--eth/protocol.go2
-rw-r--r--ethutil/common.go20
-rw-r--r--ethutil/common_test.go21
-rw-r--r--ethutil/natspec/natspec_js.go3520
-rw-r--r--ethutil/natspec/natspec_test.go22
-rw-r--r--miner/worker.go14
-rw-r--r--p2p/server.go10
-rw-r--r--pow/block.go1
-rw-r--r--rpc/api.go113
-rw-r--r--rpc/args.go198
-rw-r--r--rpc/args_test.go61
-rw-r--r--rpc/http.go27
-rw-r--r--rpc/messages.go99
-rw-r--r--rpc/util.go19
-rw-r--r--rpc/util_test.go25
-rw-r--r--state/managed_state.go84
-rw-r--r--state/managed_state_test.go89
-rw-r--r--state/state_object.go33
-rw-r--r--state/statedb.go18
-rw-r--r--tests/blocktest.go2
-rw-r--r--tests/files/StateTests/RandomTests/st201503121046CPPJIT.json64
-rw-r--r--tests/files/StateTests/RandomTests/st201503121739CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503121803PYTHON.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503121806PYTHON.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503121848GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503121849GO.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503121850GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503121851GO.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503121953GO.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122023GO.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122023PYTHON.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122027GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122054GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122055GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122115CPPJIT.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122115GO.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122123GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122124GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122128PYTHON.json71
-rw-r--r--tests/files/StateTests/RandomTests/st201503122140GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122159GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122204GO.json72
-rw-r--r--tests/files/StateTests/RandomTests/st201503122212GO.json72
-rw-r--r--tests/files/VMTests/RandomTests/201503112218PYTHON.json31
-rw-r--r--tests/files/VMTests/RandomTests/201503120317PYTHON.json31
-rw-r--r--tests/files/VMTests/RandomTests/201503120525PYTHON.json31
-rw-r--r--tests/files/VMTests/RandomTests/201503120547PYTHON.json31
-rw-r--r--tests/files/VMTests/RandomTests/201503120909PYTHON.json31
-rw-r--r--tests/files/VMTests/vmArithmeticTest.json123
-rw-r--r--tests/files/VMTests/vmBlockInfoTest.json29
-rw-r--r--tests/files/VMTests/vmEnvironmentalInfoTest.json65
-rw-r--r--tests/helper/vm.go3
-rw-r--r--tests/vm/gh_test.go2
-rw-r--r--ui/qt/qwhisper/whisper.go18
-rw-r--r--vm/common.go8
-rw-r--r--vm/context.go25
-rw-r--r--vm/environment.go2
-rw-r--r--vm/virtual_machine.go4
-rw-r--r--vm/vm.go54
-rw-r--r--xeth/state.go11
-rw-r--r--xeth/types.go11
-rw-r--r--xeth/whisper.go13
-rw-r--r--xeth/xeth.go42
154 files changed, 4138 insertions, 10869 deletions
diff --git a/.gitmodules b/.gitmodules
index 324e7f6a7..461a5a748 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "ethereal/assets/samplecoin"]
path = ethereal/assets/samplecoin
url = git@github.com:obscuren/SampleCoin.git
+[submodule "cmd/mist/assets/ext/ethereum.js"]
+ path = cmd/mist/assets/ext/ethereum.js
+ url = https://github.com/ethereum/ethereum.js
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index e0a932f8b..988c21d4f 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -22,8 +22,8 @@
},
{
"ImportPath": "github.com/ethereum/ethash",
- "Comment": "v17-64-ga323708",
- "Rev": "a323708b8c4d253b8567bf6c72727d1aec302225"
+ "Comment": "v23-11-g5376ec8",
+ "Rev": "5376ec8816d6bf787d4fc91a08b4527bc5e1f469"
},
{
"ImportPath": "github.com/ethereum/serpent-go",
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/.gitignore b/Godeps/_workspace/src/github.com/ethereum/ethash/.gitignore
index 3162bd828..da074e6b3 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/.gitignore
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/.gitignore
@@ -8,3 +8,5 @@ pyethash.egg-info/
*.so
*~
*.swp
+MANIFEST
+dist/
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt b/Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt
index c93395bf8..79f2e5335 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.7)
project(ethash)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(ETHHASH_LIBS ethash)
if (WIN32 AND WANT_CRYPTOPP)
@@ -10,6 +10,12 @@ endif()
add_subdirectory(src/libethash)
# bin2h.cmake doesn't work
-#add_subdirectory(src/libethash-cl EXCLUDE_FROM_ALL)
+if (NOT OpenCL_FOUND)
+ find_package(OpenCL)
+endif()
+
+if (OpenCL_FOUND)
+ add_subdirectory(src/libethash-cl)
+endif()
add_subdirectory(src/benchmark EXCLUDE_FROM_ALL)
add_subdirectory(test/c EXCLUDE_FROM_ALL)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/MANIFEST.in b/Godeps/_workspace/src/github.com/ethereum/ethash/MANIFEST.in
new file mode 100644
index 000000000..74e73c8be
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/MANIFEST.in
@@ -0,0 +1,17 @@
+include setup.py
+
+# C sources
+include src/libethash/internal.c
+include src/libethash/sha3.c
+include src/libethash/util.c
+include src/python/core.c
+
+# Headers
+include src/libethash/compiler.h
+include src/libethash/data_sizes.h
+include src/libethash/endian.h
+include src/libethash/ethash.h
+include src/libethash/fnv.h
+include src/libethash/internal.h
+include src/libethash/sha3.h
+include src/libethash/util.h
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/Makefile b/Godeps/_workspace/src/github.com/ethereum/ethash/Makefile
index e2630581e..741d3b56d 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/Makefile
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/Makefile
@@ -1,3 +1,6 @@
-.PHONY: clean
+.PHONY: clean test
+test:
+ ./test/test.sh
+
clean:
- rm -rf *.so pyethash.egg-info/ build/ test/python/python-virtual-env/ test/c/build/ pyethash/*.{so,pyc}
+ rm -rf *.so pyethash.egg-info/ build/ test/python/python-virtual-env/ test/c/build/ pyethash.so test/python/*.pyc dist/ MANIFEST
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/cryptopp/CMakeLists.txt b/Godeps/_workspace/src/github.com/ethereum/ethash/cryptopp/CMakeLists.txt
index 4cd9f36c6..6f4280532 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/cryptopp/CMakeLists.txt
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/cryptopp/CMakeLists.txt
@@ -8,6 +8,6 @@ file(GLOB SOURCE "../../cryptopp/*.cpp")
add_library(${LIBRARY} ${HEADERS} ${SOURCE})
-set(CRYPTOPP_INCLUDE_DIRS "../.." PARENT_SCOPE)
+set(CRYPTOPP_INCLUDE_DIRS "../.." "../../../" PARENT_SCOPE)
set(CRYPTOPP_LIBRARIES ${LIBRARY} PARENT_SCOPE)
set(CRYPTOPP_FOUND TRUE PARENT_SCOPE)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
index bf184020a..6f1302bb8 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
@@ -1,3 +1,13 @@
+/*
+###################################################################################
+###################################################################################
+#################### ####################
+#################### EDIT AND YOU SHALL FEEL MY WRATH - jeff ####################
+#################### ####################
+###################################################################################
+###################################################################################
+*/
+
package ethash
/*
@@ -11,8 +21,8 @@ import "C"
import (
"bytes"
"encoding/binary"
+ "fmt"
"io/ioutil"
- "log"
"math/big"
"math/rand"
"os"
@@ -21,25 +31,26 @@ import (
"time"
"unsafe"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
)
-var tt256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
+var minDifficulty = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
var powlogger = logger.NewLogger("POW")
-type DAG struct {
- SeedBlockNum uint64
- dag unsafe.Pointer // full GB of memory for dag
- file bool
+type ParamsAndCache struct {
+ params *C.ethash_params
+ cache *C.ethash_cache
+ Epoch uint64
}
-type ParamsAndCache struct {
- params *C.ethash_params
- cache *C.ethash_cache
- SeedBlockNum uint64
+type DAG struct {
+ dag unsafe.Pointer // full GB of memory for dag
+ file bool
+ paramsAndCache *ParamsAndCache
}
type Ethash struct {
@@ -48,10 +59,9 @@ type Ethash struct {
chainManager pow.ChainManager
dag *DAG
paramsAndCache *ParamsAndCache
- nextdag unsafe.Pointer
ret *C.ethash_return_value
- dagMutex *sync.Mutex
- cacheMutex *sync.Mutex
+ dagMutex *sync.RWMutex
+ cacheMutex *sync.RWMutex
}
func parseNonce(nonce []byte) (uint64, error) {
@@ -65,151 +75,212 @@ func parseNonce(nonce []byte) (uint64, error) {
const epochLength uint64 = 30000
-func GetSeedBlockNum(blockNum uint64) uint64 {
- var seedBlockNum uint64 = 0
- if blockNum > epochLength {
- seedBlockNum = ((blockNum - 1) / epochLength) * epochLength
+func makeParamsAndCache(chainManager pow.ChainManager, blockNum uint64) (*ParamsAndCache, error) {
+ if blockNum >= epochLength*2048 {
+ return nil, fmt.Errorf("block number is out of bounds (value %v, limit is %v)", blockNum, epochLength*2048)
}
- return seedBlockNum
-}
-
-/*
-XXX THIS DOESN'T WORK!! NEEDS FIXING
-blockEpoch will underflow and wrap around causing massive issues
-func GetSeedBlockNum(blockNum uint64) uint64 {
- var seedBlockNum uint64 = 0
- if blockNum > epochLength {
- seedBlockNum = ((blockNum - 1) / epochLength) * epochLength
- }
- return seedBlockNum
-}
-*/
-
-func makeParamsAndCache(chainManager pow.ChainManager, blockNum uint64) *ParamsAndCache {
- seedBlockNum := GetSeedBlockNum(blockNum)
paramsAndCache := &ParamsAndCache{
- params: new(C.ethash_params),
- cache: new(C.ethash_cache),
- SeedBlockNum: seedBlockNum,
+ params: new(C.ethash_params),
+ cache: new(C.ethash_cache),
+ Epoch: blockNum / epochLength,
}
- C.ethash_params_init(paramsAndCache.params, C.uint32_t(seedBlockNum))
+ C.ethash_params_init(paramsAndCache.params, C.uint32_t(uint32(blockNum)))
paramsAndCache.cache.mem = C.malloc(paramsAndCache.params.cache_size)
- seedHash := chainManager.GetBlockByNumber(seedBlockNum).SeedHash()
- log.Println("Making Cache")
+ seedHash, err := GetSeedHash(blockNum)
+ if err != nil {
+ return nil, err
+ }
+
+ powlogger.Infoln("Making Cache")
start := time.Now()
C.ethash_mkcache(paramsAndCache.cache, paramsAndCache.params, (*C.uint8_t)(unsafe.Pointer(&seedHash[0])))
- log.Println("Took:", time.Since(start))
+ powlogger.Infoln("Took:", time.Since(start))
- return paramsAndCache
+ return paramsAndCache, nil
}
-func (pow *Ethash) updateCache() {
+func (pow *Ethash) UpdateCache(force bool) error {
pow.cacheMutex.Lock()
- seedNum := GetSeedBlockNum(pow.chainManager.CurrentBlock().NumberU64())
- if pow.paramsAndCache.SeedBlockNum != seedNum {
- pow.paramsAndCache = makeParamsAndCache(pow.chainManager, pow.chainManager.CurrentBlock().NumberU64())
+ thisEpoch := pow.chainManager.CurrentBlock().NumberU64()
+ if force || pow.paramsAndCache.Epoch != thisEpoch {
+ var err error
+ pow.paramsAndCache, err = makeParamsAndCache(pow.chainManager, pow.chainManager.CurrentBlock().NumberU64())
+ if err != nil {
+ panic(err)
+ }
}
pow.cacheMutex.Unlock()
+ return nil
}
func makeDAG(p *ParamsAndCache) *DAG {
d := &DAG{
- dag: C.malloc(p.params.full_size),
- SeedBlockNum: p.SeedBlockNum,
+ dag: C.malloc(p.params.full_size),
+ file: false,
+ paramsAndCache: p,
}
+
+ donech := make(chan string)
+ go func() {
+ t := time.NewTicker(5 * time.Second)
+ tstart := time.Now()
+ done:
+ for {
+ select {
+ case <-t.C:
+ powlogger.Infof("... still generating DAG (%v) ...\n", time.Since(tstart).Seconds())
+ case str := <-donech:
+ powlogger.Infof("... %s ...\n", str)
+ break done
+ }
+ }
+ }()
C.ethash_compute_full_data(d.dag, p.params, p.cache)
+ donech <- "DAG generation completed"
return d
}
-func (pow *Ethash) writeDagToDisk(dag *DAG, seedNum uint64) *os.File {
- data := C.GoBytes(unsafe.Pointer(dag.dag), C.int(pow.paramsAndCache.params.full_size))
+func (pow *Ethash) writeDagToDisk(dag *DAG, epoch uint64) *os.File {
+ if epoch > 2048 {
+ panic(fmt.Errorf("Epoch must be less than 2048 (is %v)", epoch))
+ }
+ data := C.GoBytes(unsafe.Pointer(dag.dag), C.int(dag.paramsAndCache.params.full_size))
file, err := os.Create("/tmp/dag")
if err != nil {
panic(err)
}
- num := make([]byte, 8)
- binary.BigEndian.PutUint64(num, seedNum)
+ dataEpoch := make([]byte, 8)
+ binary.BigEndian.PutUint64(dataEpoch, epoch)
- file.Write(num)
+ file.Write(dataEpoch)
file.Write(data)
return file
}
func (pow *Ethash) UpdateDAG() {
- pow.cacheMutex.Lock()
- pow.dagMutex.Lock()
+ blockNum := pow.chainManager.CurrentBlock().NumberU64()
+ if blockNum >= epochLength*2048 {
+ // This will crash in the 2030s or 2040s
+ panic(fmt.Errorf("Current block number is out of bounds (value %v, limit is %v)", blockNum, epochLength*2048))
+ }
- seedNum := GetSeedBlockNum(pow.chainManager.CurrentBlock().NumberU64())
- if pow.dag == nil || pow.dag.SeedBlockNum != seedNum {
+ pow.dagMutex.Lock()
+ defer pow.dagMutex.Unlock()
+ thisEpoch := blockNum / epochLength
+ if pow.dag == nil || pow.dag.paramsAndCache.Epoch != thisEpoch {
if pow.dag != nil && pow.dag.dag != nil {
C.free(pow.dag.dag)
pow.dag.dag = nil
}
+ if pow.dag != nil && pow.dag.paramsAndCache.cache.mem != nil {
+ C.free(pow.dag.paramsAndCache.cache.mem)
+ pow.dag.paramsAndCache.cache.mem = nil
+ }
+
+ // Make the params and cache for the DAG
+ paramsAndCache, err := makeParamsAndCache(pow.chainManager, blockNum)
+ if err != nil {
+ panic(err)
+ }
+
+ // TODO: On non-SSD disks, loading the DAG from disk takes longer than generating it in memory
+ pow.paramsAndCache = paramsAndCache
path := path.Join("/", "tmp", "dag")
pow.dag = nil
- log.Println("Generating dag")
+ powlogger.Infoln("Retrieving DAG")
start := time.Now()
file, err := os.Open(path)
if err != nil {
- log.Printf("No dag found in '%s'. Generating new dago(takes a while)...", path)
- pow.dag = makeDAG(pow.paramsAndCache)
- file = pow.writeDagToDisk(pow.dag, seedNum)
+ powlogger.Infof("No DAG found. Generating new DAG in '%s' (this takes a while)...\n", path)
+ pow.dag = makeDAG(paramsAndCache)
+ file = pow.writeDagToDisk(pow.dag, thisEpoch)
+ pow.dag.file = true
} else {
data, err := ioutil.ReadAll(file)
if err != nil {
- panic(err)
+ powlogger.Infof("DAG load err: %v\n", err)
}
- num := binary.BigEndian.Uint64(data[0:8])
- if num < seedNum {
- log.Printf("Old found. Generating new dag (takes a while)...")
- pow.dag = makeDAG(pow.paramsAndCache)
- file = pow.writeDagToDisk(pow.dag, seedNum)
+ if len(data) < 8 {
+ powlogger.Infof("DAG in '%s' is less than 8 bytes, it must be corrupted. Generating new DAG (this takes a while)...\n", path)
+ pow.dag = makeDAG(paramsAndCache)
+ file = pow.writeDagToDisk(pow.dag, thisEpoch)
+ pow.dag.file = true
} else {
- data = data[8:]
- pow.dag = &DAG{
- dag: unsafe.Pointer(&data[0]),
- file: true,
- SeedBlockNum: pow.paramsAndCache.SeedBlockNum,
+ dataEpoch := binary.BigEndian.Uint64(data[0:8])
+ if dataEpoch < thisEpoch {
+ powlogger.Infof("DAG in '%s' is stale. Generating new DAG (this takes a while)...\n", path)
+ pow.dag = makeDAG(paramsAndCache)
+ file = pow.writeDagToDisk(pow.dag, thisEpoch)
+ pow.dag.file = true
+ } else if dataEpoch > thisEpoch {
+ // FIXME
+ panic(fmt.Errorf("Saved DAG in '%s' reports to be from future epoch %v (current epoch is %v)\n", path, dataEpoch, thisEpoch))
+ } else if len(data) != (int(paramsAndCache.params.full_size) + 8) {
+ powlogger.Infof("DAG in '%s' is corrupted. Generating new DAG (this takes a while)...\n", path)
+ pow.dag = makeDAG(paramsAndCache)
+ file = pow.writeDagToDisk(pow.dag, thisEpoch)
+ pow.dag.file = true
+ } else {
+ data = data[8:]
+ pow.dag = &DAG{
+ dag: unsafe.Pointer(&data[0]),
+ file: true,
+ paramsAndCache: paramsAndCache,
+ }
}
}
}
- log.Println("Took:", time.Since(start))
+ powlogger.Infoln("Took:", time.Since(start))
file.Close()
}
-
- pow.dagMutex.Unlock()
- pow.cacheMutex.Unlock()
}
func New(chainManager pow.ChainManager) *Ethash {
+ paramsAndCache, err := makeParamsAndCache(chainManager, chainManager.CurrentBlock().NumberU64())
+ if err != nil {
+ panic(err)
+ }
+
return &Ethash{
turbo: true,
- paramsAndCache: makeParamsAndCache(chainManager, chainManager.CurrentBlock().NumberU64()),
+ paramsAndCache: paramsAndCache,
chainManager: chainManager,
dag: nil,
- cacheMutex: new(sync.Mutex),
- dagMutex: new(sync.Mutex),
+ cacheMutex: new(sync.RWMutex),
+ dagMutex: new(sync.RWMutex),
}
}
func (pow *Ethash) DAGSize() uint64 {
- return uint64(pow.paramsAndCache.params.full_size)
+ return uint64(pow.dag.paramsAndCache.params.full_size)
}
func (pow *Ethash) CacheSize() uint64 {
return uint64(pow.paramsAndCache.params.cache_size)
}
-func (pow *Ethash) GetSeedHash(blockNum uint64) []byte {
- seednum := GetSeedBlockNum(blockNum)
- return pow.chainManager.GetBlockByNumber(seednum).SeedHash()
+func GetSeedHash(blockNum uint64) ([]byte, error) {
+ if blockNum >= epochLength*2048 {
+ return nil, fmt.Errorf("block number is out of bounds (value %v, limit is %v)", blockNum, epochLength*2048)
+ }
+
+ epoch := blockNum / epochLength
+ seedHash := make([]byte, 32)
+ var i uint64
+ for i = 0; i < 32; i++ {
+ seedHash[i] = 0
+ }
+ for i = 0; i < epoch; i++ {
+ seedHash = crypto.Sha3(seedHash)
+ }
+ return seedHash, nil
}
func (pow *Ethash) Stop() {
@@ -224,17 +295,18 @@ func (pow *Ethash) Stop() {
if pow.dag.dag != nil && !pow.dag.file {
C.free(pow.dag.dag)
}
+ if pow.dag != nil && pow.dag.paramsAndCache != nil && pow.dag.paramsAndCache.cache.mem != nil {
+ C.free(pow.dag.paramsAndCache.cache.mem)
+ pow.dag.paramsAndCache.cache.mem = nil
+ }
pow.dag.dag = nil
}
func (pow *Ethash) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte, []byte) {
- //pow.UpdateDAG()
+ pow.UpdateDAG()
- // Not very elegant, multiple mining instances are not supported
- //pow.dagMutex.Lock()
- //pow.cacheMutex.Lock()
- //defer pow.cacheMutex.Unlock()
- //defer pow.dagMutex.Unlock()
+ pow.dagMutex.RLock()
+ defer pow.dagMutex.RUnlock()
r := rand.New(rand.NewSource(time.Now().UnixNano()))
miningHash := block.HashNoNonce()
@@ -246,7 +318,7 @@ func (pow *Ethash) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte
nonce := uint64(r.Int63())
cMiningHash := (*C.uint8_t)(unsafe.Pointer(&miningHash[0]))
- target := new(big.Int).Div(tt256, diff)
+ target := new(big.Int).Div(minDifficulty, diff)
var ret C.ethash_return_value
for {
@@ -262,14 +334,17 @@ func (pow *Ethash) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte
hashes := ((float64(1e9) / float64(elapsed)) * float64(i-starti)) / 1000
pow.HashRate = int64(hashes)
- C.ethash_full(&ret, pow.dag.dag, pow.paramsAndCache.params, cMiningHash, C.uint64_t(nonce))
+ C.ethash_full(&ret, pow.dag.dag, pow.dag.paramsAndCache.params, cMiningHash, C.uint64_t(nonce))
result := ethutil.Bytes2Big(C.GoBytes(unsafe.Pointer(&ret.result[0]), C.int(32)))
+ // TODO: disagrees with the spec https://github.com/ethereum/wiki/wiki/Ethash#mining
if result.Cmp(target) <= 0 {
mixDigest := C.GoBytes(unsafe.Pointer(&ret.mix_hash[0]), C.int(32))
-
- return nonce, mixDigest, pow.GetSeedHash(block.NumberU64())
-
+ seedHash, err := GetSeedHash(block.NumberU64()) // This seedhash is useless
+ if err != nil {
+ panic(err)
+ }
+ return nonce, mixDigest, seedHash
}
nonce += 1
@@ -283,32 +358,41 @@ func (pow *Ethash) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte
}
func (pow *Ethash) Verify(block pow.Block) bool {
- // Make sure the SeedHash is set correctly
- if bytes.Compare(block.SeedHash(), pow.GetSeedHash(block.NumberU64())) != 0 {
- return false
- }
return pow.verify(block.HashNoNonce(), block.MixDigest(), block.Difficulty(), block.NumberU64(), block.Nonce())
}
func (pow *Ethash) verify(hash []byte, mixDigest []byte, difficulty *big.Int, blockNum uint64, nonce uint64) bool {
- // First check: make sure header, mixDigest, nonce are correct without hitting the DAG
+ // Make sure the block num is valid
+ if blockNum >= epochLength*2048 {
+ powlogger.Infoln(fmt.Sprintf("Block number exceeds limit, invalid (value is %v, limit is %v)",
+ blockNum, epochLength*2048))
+ return false
+ }
+
+ // First check: make sure header, mixDigest, nonce are correct without hitting the cache
// This is to prevent DOS attacks
chash := (*C.uint8_t)(unsafe.Pointer(&hash[0]))
cnonce := C.uint64_t(nonce)
- target := new(big.Int).Div(tt256, difficulty)
+ target := new(big.Int).Div(minDifficulty, difficulty)
var pAc *ParamsAndCache
// If its an old block (doesn't use the current cache)
// get the cache for it but don't update (so we don't need the mutex)
- // Otherwise, it's the current block or a future.
+ // Otherwise, it's the current block or a future block.
// If current, updateCache will do nothing.
- if GetSeedBlockNum(blockNum) < pow.paramsAndCache.SeedBlockNum {
- pAc = makeParamsAndCache(pow.chainManager, blockNum)
+ 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)
+ if err != nil {
+ powlogger.Infoln(err)
+ return false
+ }
} else {
- pow.updateCache()
- pow.cacheMutex.Lock()
- defer pow.cacheMutex.Unlock()
+ pow.UpdateCache(false)
+ pow.cacheMutex.RLock()
+ defer pow.cacheMutex.RUnlock()
pAc = pow.paramsAndCache
}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/.gitignore b/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/.gitignore
deleted file mode 100644
index e1374b866..000000000
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-pyethash.egg-info/
-*.so
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/__init__.py b/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/__init__.py
deleted file mode 100644
index fca037dba..000000000
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/pyethash/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import pyethash.core
-core = pyethash.core
-EPOCH_LENGTH = 30000
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py b/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
index 4e27aad6c..29d6ad6d2 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
@@ -1,21 +1,33 @@
#!/usr/bin/env python
from distutils.core import setup, Extension
-pyethash_core = Extension('pyethash.core',
+pyethash = Extension('pyethash',
sources = [
'src/python/core.c',
'src/libethash/util.c',
'src/libethash/internal.c',
- 'src/libethash/sha3.c'
+ 'src/libethash/sha3.c'],
+ depends = [
+ 'src/libethash/ethash.h',
+ 'src/libethash/compiler.h',
+ 'src/libethash/data_sizes.h',
+ 'src/libethash/endian.h',
+ 'src/libethash/ethash.h',
+ 'src/libethash/fnv.h',
+ 'src/libethash/internal.h',
+ 'src/libethash/sha3.h',
+ 'src/libethash/util.h'
],
- extra_compile_args = ["-std=gnu99"])
+ extra_compile_args = ["-Isrc/", "-std=gnu99", "-Wall"])
setup (
name = 'pyethash',
author = "Matthew Wampler-Doty",
author_email = "matthew.wampler.doty@gmail.com",
license = 'GPL',
- version = '1.0',
+ version = '23',
+ url = 'https://github.com/ethereum/ethash',
+ download_url = 'https://github.com/ethereum/ethash/tarball/v23',
description = 'Python wrappers for ethash, the ethereum proof of work hashing function',
- ext_modules = [pyethash_core],
+ ext_modules = [pyethash],
)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp b/Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
index 4c8f700c5..7dae4f18c 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/benchmark/benchmark.cpp
@@ -31,7 +31,7 @@
#include <algorithm>
#ifdef WITH_CRYPTOPP
-#include <libethash/SHA3_cryptopp.h>
+#include <libethash/sha3_cryptopp.h>
#include <string>
#else
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
index fe563aae4..f37471cf3 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/CMakeLists.txt
@@ -2,14 +2,39 @@ set(LIBRARY ethash-cl)
set(CMAKE_BUILD_TYPE Release)
include(bin2h.cmake)
-bin2h(SOURCE_FILE ethash_cl_miner_kernel.cl VARIABLE_NAME ethash_cl_miner_kernel HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h)
+bin2h(SOURCE_FILE ethash_cl_miner_kernel.cl
+ VARIABLE_NAME ethash_cl_miner_kernel
+ HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h)
+
+if (NOT MSVC)
+ # Initialize CXXFLAGS for c++11
+ set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
+ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
+
+ # Compiler-specific C++11 activation.
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
+ execute_process(
+ COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
+ message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
+ endif ()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ else ()
+ message(FATAL_ERROR "Your C++ compiler does not support C++11.")
+ endif ()
+endif()
if (NOT OpenCL_FOUND)
find_package(OpenCL)
endif()
+
if (OpenCL_FOUND)
include_directories(${OpenCL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
include_directories(..)
- add_library(${LIBRARY} ethash_cl_miner.cpp ethash_cl_miner.h)
+ add_library(${LIBRARY} ethash_cl_miner.cpp ethash_cl_miner.h cl.hpp)
TARGET_LINK_LIBRARIES(${LIBRARY} ${OpenCL_LIBRARIES} ethash)
endif()
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake
index e224c1a67..90ca9cc5b 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/bin2h.cmake
@@ -68,8 +68,7 @@ function(BIN2H)
string(REGEX REPLACE ", $" "" arrayValues ${arrayValues})
# converts the variable name into proper C identifier
- # TODO: fix for legacy cmake
- IF (${CMAKE_VERSION} GREATER 2.8.10)
+ IF (${CMAKE_VERSION} GREATER 2.8.10) # fix for legacy cmake
string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
ENDIF()
string(TOUPPER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
index c0dbea21d..18133256a 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.cpp
@@ -24,15 +24,22 @@
#include <assert.h>
#include <queue>
+#include <vector>
#include "ethash_cl_miner.h"
#include "ethash_cl_miner_kernel.h"
#include <libethash/util.h>
+#define ETHASH_BYTES 32
+
+// workaround lame platforms
+#if !CL_VERSION_1_2
+#define CL_MAP_WRITE_INVALIDATE_REGION CL_MAP_WRITE
+#define CL_MEM_HOST_READ_ONLY 0
+#endif
+
#undef min
#undef max
-#define HASH_BYTES 32
-
static void add_definition(std::string& source, char const* id, unsigned value)
{
char buf[256];
@@ -41,6 +48,7 @@ static void add_definition(std::string& source, char const* id, unsigned value)
}
ethash_cl_miner::ethash_cl_miner()
+: m_opencl_1_1()
{
}
@@ -71,11 +79,23 @@ bool ethash_cl_miner::init(ethash_params const& params, const uint8_t seed[32],
}
// use default device
- cl::Device& device = devices[0];
- debugf("Using device: %s\n", device.getInfo<CL_DEVICE_NAME>().c_str());
+ unsigned device_num = 0;
+ cl::Device& device = devices[device_num];
+ std::string device_version = device.getInfo<CL_DEVICE_VERSION>();
+ debugf("Using device: %s (%s)\n", device.getInfo<CL_DEVICE_NAME>().c_str(),device_version.c_str());
+
+ if (strncmp("OpenCL 1.0", device_version.c_str(), 10) == 0)
+ {
+ debugf("OpenCL 1.0 is not supported.\n");
+ return false;
+ }
+ if (strncmp("OpenCL 1.1", device_version.c_str(), 10) == 0)
+ {
+ m_opencl_1_1 = true;
+ }
// create context
- m_context = cl::Context({device});
+ m_context = cl::Context(std::vector<cl::Device>(&device, &device+1));
m_queue = cl::CommandQueue(m_context, device);
// use requested workgroup size, but we require multiple of 8
@@ -120,7 +140,7 @@ bool ethash_cl_miner::init(ethash_params const& params, const uint8_t seed[32],
ethash_mkcache(&cache, &params, seed);
// if this throws then it's because we probably need to subdivide the dag uploads for compatibility
- void* dag_ptr = m_queue.enqueueMapBuffer(m_dag, true, CL_MAP_WRITE_INVALIDATE_REGION, 0, params.full_size);
+ void* dag_ptr = m_queue.enqueueMapBuffer(m_dag, true, m_opencl_1_1 ? CL_MAP_WRITE : CL_MAP_WRITE_INVALIDATE_REGION, 0, params.full_size);
ethash_compute_full_data(dag_ptr, &params, &cache);
m_queue.enqueueUnmapMemObject(m_dag, dag_ptr);
@@ -130,7 +150,7 @@ bool ethash_cl_miner::init(ethash_params const& params, const uint8_t seed[32],
// create mining buffers
for (unsigned i = 0; i != c_num_buffers; ++i)
{
- m_hash_buf[i] = cl::Buffer(m_context, CL_MEM_WRITE_ONLY | CL_MEM_HOST_READ_ONLY, 32*c_hash_batch_size);
+ m_hash_buf[i] = cl::Buffer(m_context, CL_MEM_WRITE_ONLY | (!m_opencl_1_1 ? CL_MEM_HOST_READ_ONLY : 0), 32*c_hash_batch_size);
m_search_buf[i] = cl::Buffer(m_context, CL_MEM_WRITE_ONLY, (c_max_search_results + 1) * sizeof(uint32_t));
}
return true;
@@ -176,7 +196,6 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
m_hash_kernel.setArg(0, m_hash_buf[buf]);
// execute it!
- clock_t start_time = clock();
m_queue.enqueueNDRangeKernel(
m_hash_kernel,
cl::NullRange,
@@ -196,8 +215,8 @@ void ethash_cl_miner::hash(uint8_t* ret, uint8_t const* header, uint64_t nonce,
pending_batch const& batch = pending.front();
// could use pinned host pointer instead, but this path isn't that important.
- uint8_t* hashes = (uint8_t*)m_queue.enqueueMapBuffer(m_hash_buf[batch.buf], true, CL_MAP_READ, 0, batch.count * HASH_BYTES);
- memcpy(ret + batch.base*HASH_BYTES, hashes, batch.count*HASH_BYTES);
+ uint8_t* hashes = (uint8_t*)m_queue.enqueueMapBuffer(m_hash_buf[batch.buf], true, CL_MAP_READ, 0, batch.count * ETHASH_BYTES);
+ memcpy(ret + batch.base*ETHASH_BYTES, hashes, batch.count*ETHASH_BYTES);
m_queue.enqueueUnmapMemObject(m_hash_buf[batch.buf], hashes);
pending.pop();
@@ -223,8 +242,19 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
{
m_queue.enqueueWriteBuffer(m_search_buf[i], false, 0, 4, &c_zero);
}
+
+#if CL_VERSION_1_2
cl::Event pre_return_event;
- m_queue.enqueueBarrierWithWaitList(NULL, &pre_return_event);
+ if (!m_opencl_1_1)
+ {
+ m_queue.enqueueBarrierWithWaitList(NULL, &pre_return_event);
+ }
+ else
+#else
+ {
+ m_queue.finish();
+ }
+#endif
/*
__kernel void ethash_combined_search(
@@ -284,6 +314,11 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
}
// not safe to return until this is ready
- pre_return_event.wait();
+#if CL_VERSION_1_2
+ if (!m_opencl_1_1)
+ {
+ pre_return_event.wait();
+ }
+#endif
}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
index f37100d91..3fb98b5b7 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash-cl/ethash_cl_miner.h
@@ -40,4 +40,5 @@ private:
cl::Buffer m_hash_buf[c_num_buffers];
cl::Buffer m_search_buf[c_num_buffers];
unsigned m_workgroup_size;
+ bool m_opencl_1_1;
}; \ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
index 7bc147af7..38fc821c0 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/CMakeLists.txt
@@ -2,7 +2,6 @@ set(LIBRARY ethash)
if (CPPETHEREUM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-#else ()
endif ()
set(CMAKE_BUILD_TYPE Release)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h
index a10d4c42c..3b747b3ea 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/data_sizes.h
@@ -20,8 +20,6 @@
* @date 2015
*/
-// TODO: Update this after ~3.5 years
-
#pragma once
#include <stdint.h>
@@ -33,23 +31,24 @@ extern "C" {
#include <stdint.h>
-// 2048 Epochs worth of tabulated DAG sizes
+// 2048 Epochs (~20 years) worth of tabulated DAG sizes
// Generated with the following Mathematica Code:
-// GetDataSizes[n_] := Module[{
-// DataSetSizeBytesInit = 2^30,
-// MixBytes = 128,
-// DataSetGrowth = 2^23,
+// GetCacheSizes[n_] := Module[{
+// CacheSizeBytesInit = 2^24,
+// CacheGrowth = 2^17,
+// HashBytes = 64,
// j = 0},
-// Reap[
-// While[j < n,
-// Module[{i =
-// Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / MixBytes]},
-// While[! PrimeQ[i], i--];
-// Sow[i*MixBytes]; j++]]]][[2]][[1]]
+// Reap[
+// While[j < n,
+// Module[{i =
+// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]},
+// While[! PrimeQ[i], i--];
+// Sow[i*HashBytes]; j++]]]][[2]][[1]]
+
-static const size_t dag_sizes[] = {
+static const size_t dag_sizes[2048] = {
1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U,
1115684224U, 1124070016U, 1132461952U, 1140849536U, 1149232768U,
1157627776U, 1166013824U, 1174404736U, 1182786944U, 1191180416U,
@@ -478,300 +477,334 @@ static const size_t dag_sizes[] = {
// While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]]
-const size_t cache_sizes[] = {
- 1048384U, 1055552U, 1064512U, 1072832U, 1080896U, 1089344U, 1096768U,
- 1104448U, 1113664U, 1121216U, 1130176U, 1138624U, 1146304U, 1155008U,
- 1162816U, 1171264U, 1179328U, 1187392U, 1195456U, 1203392U, 1210816U,
- 1220416U, 1227712U, 1236416U, 1244608U, 1253312U, 1261376U, 1268416U,
- 1277632U, 1285696U, 1294016U, 1302208U, 1310656U, 1318336U, 1326784U,
- 1334848U, 1342912U, 1350848U, 1359808U, 1366208U, 1376192U, 1383488U,
- 1392448U, 1400384U, 1408832U, 1416512U, 1425344U, 1433408U, 1440704U,
- 1449664U, 1458112U, 1466048U, 1474496U, 1482688U, 1490752U, 1498688U,
- 1507136U, 1515328U, 1523264U, 1531456U, 1539904U, 1547584U, 1556288U,
- 1564352U, 1572544U, 1580608U, 1588544U, 1596992U, 1605568U, 1612096U,
- 1621952U, 1630144U, 1637696U, 1645888U, 1654336U, 1662784U, 1671104U,
- 1679168U, 1686848U, 1695296U, 1702208U, 1711168U, 1720256U, 1727552U,
- 1736128U, 1744576U, 1751488U, 1760576U, 1769408U, 1777472U, 1785664U,
- 1793984U, 1801664U, 1810112U, 1818304U, 1826624U, 1834816U, 1842752U,
- 1851328U, 1858112U, 1867456U, 1875904U, 1883968U, 1892288U, 1899712U,
- 1908416U, 1916608U, 1924544U, 1932992U, 1940672U, 1948736U, 1956928U,
- 1965632U, 1973824U, 1982144U, 1989824U, 1998784U, 2006848U, 2014784U,
- 2022848U, 2031424U, 2038976U, 2047424U, 2055616U, 2064064U, 2072384U,
- 2080448U, 2088512U, 2095936U, 2104768U, 2113472U, 2121664U, 2127808U,
- 2137792U, 2146112U, 2153408U, 2162624U, 2170304U, 2178496U, 2186944U,
- 2195392U, 2203456U, 2211136U, 2219968U, 2227648U, 2236096U, 2244416U,
- 2250944U, 2260928U, 2268736U, 2276672U, 2283328U, 2293696U, 2301632U,
- 2309312U, 2317888U, 2325952U, 2334656U, 2342848U, 2350144U, 2358848U,
- 2366656U, 2375488U, 2383552U, 2391616U, 2400064U, 2407616U, 2415808U,
- 2424256U, 2432704U, 2439616U, 2448704U, 2457152U, 2464064U, 2473792U,
- 2482112U, 2489792U, 2497472U, 2506432U, 2514752U, 2522816U, 2531264U,
- 2539456U, 2547136U, 2555456U, 2564032U, 2572096U, 2578496U, 2587712U,
- 2595776U, 2604736U, 2613056U, 2620736U, 2629184U, 2637632U, 2645824U,
- 2653888U, 2662208U, 2670016U, 2678464U, 2686912U, 2694464U, 2703296U,
- 2710976U, 2719424U, 2727104U, 2736064U, 2743232U, 2752192U, 2760512U,
- 2768704U, 2777024U, 2785088U, 2792512U, 2800576U, 2809024U, 2817856U,
- 2826176U, 2833984U, 2840896U, 2850752U, 2858048U, 2867008U, 2875328U,
- 2883392U, 2891584U, 2899648U, 2908096U, 2915648U, 2924224U, 2932672U,
- 2940736U, 2948672U, 2956736U, 2964928U, 2973248U, 2981824U, 2988992U,
- 2997184U, 3005248U, 3013952U, 3022144U, 3030592U, 3037376U, 3046976U,
- 3055552U, 3063616U, 3070784U, 3079744U, 3087808U, 3096512U, 3103808U,
- 3111872U, 3121088U, 3128896U, 3137216U, 3144896U, 3153856U, 3161152U,
- 3169984U, 3178432U, 3186496U, 3194816U, 3203008U, 3210176U, 3218624U,
- 3227072U, 3235264U, 3243712U, 3250496U, 3259456U, 3268544U, 3276736U,
- 3283648U, 3292736U, 3301184U, 3308224U, 3317696U, 3324736U, 3333184U,
- 3342272U, 3348544U, 3357248U, 3365312U, 3374912U, 3383104U, 3390784U,
- 3399488U, 3407296U, 3414976U, 3424192U, 3432256U, 3440576U, 3448768U,
- 3456832U, 3464896U, 3473216U, 3480128U, 3489344U, 3497408U, 3505856U,
- 3514048U, 3521344U, 3530432U, 3538624U, 3546304U, 3555008U, 3563072U,
- 3571648U, 3579712U, 3587392U, 3595456U, 3603904U, 3612352U, 3620416U,
- 3628864U, 3636928U, 3645248U, 3652928U, 3660992U, 3669184U, 3677888U,
- 3685952U, 3694528U, 3702592U, 3710528U, 3719104U, 3727168U, 3735488U,
- 3742784U, 3751232U, 3759424U, 3765184U, 3775808U, 3783872U, 3792832U,
- 3800768U, 3808832U, 3816256U, 3825344U, 3832768U, 3841856U, 3849536U,
- 3857344U, 3866432U, 3874496U, 3882304U, 3890752U, 3899072U, 3907264U,
- 3914816U, 3923008U, 3930688U, 3939904U, 3947968U, 3956416U, 3964736U,
- 3972544U, 3981248U, 3988928U, 3997376U, 4005824U, 4012864U, 4020928U,
- 4030144U, 4038592U, 4045504U, 4054592U, 4063168U, 4071104U, 4079552U,
- 4087232U, 4095808U, 4103872U, 4111168U, 4120384U, 4127936U, 4136512U,
- 4144832U, 4153024U, 4160704U, 4169408U, 4177216U, 4186048U, 4193344U,
- 4202048U, 4210496U, 4217536U, 4227008U, 4235072U, 4243264U, 4251584U,
- 4259392U, 4267712U, 4275776U, 4284352U, 4291904U, 4300096U, 4307648U,
- 4316992U, 4325056U, 4333376U, 4341056U, 4349888U, 4357568U, 4366016U,
- 4374464U, 4382528U, 4390208U, 4398656U, 4407232U, 4413632U, 4423616U,
- 4431808U, 4439744U, 4447936U, 4455872U, 4463296U, 4472128U, 4480576U,
- 4489024U, 4497344U, 4505152U, 4512448U, 4520896U, 4530112U, 4537664U,
- 4546496U, 4554688U, 4562752U, 4570816U, 4579264U, 4586944U, 4595648U,
- 4603712U, 4611392U, 4619072U, 4628032U, 4635584U, 4643776U, 4652864U,
- 4660672U, 4669376U, 4677056U, 4684096U, 4693184U, 4702144U, 4710208U,
- 4718528U, 4726336U, 4734272U, 4742464U, 4750784U, 4759232U, 4767296U,
- 4775872U, 4783808U, 4791872U, 4797376U, 4808512U, 4816192U, 4825024U,
- 4832704U, 4841024U, 4849472U, 4856512U, 4865984U, 4874176U, 4882112U,
- 4889792U, 4898752U, 4906688U, 4913984U, 4922816U, 4931008U, 4938944U,
- 4946624U, 4955584U, 4964032U, 4972096U, 4980032U, 4988864U, 4997056U,
- 5004992U, 5012288U, 5020096U, 5029312U, 5037632U, 5045696U, 5052224U,
- 5062592U, 5070784U, 5078848U, 5086784U, 5095232U, 5100736U, 5111488U,
- 5119936U, 5127104U, 5136064U, 5143616U, 5151424U, 5160256U, 5168704U,
- 5175232U, 5185472U, 5192384U, 5199296U, 5209664U, 5218112U, 5225536U,
- 5233472U, 5242816U, 5250496U, 5258944U, 5267264U, 5274944U, 5283776U,
- 5290048U, 5300032U, 5308096U, 5316544U, 5323328U, 5331904U, 5340736U,
- 5349056U, 5356864U, 5365312U, 5372096U, 5381696U, 5390272U, 5398336U,
- 5405888U, 5413696U, 5422784U, 5430976U, 5439424U, 5446976U, 5455808U,
- 5463616U, 5471168U, 5480128U, 5488064U, 5494592U, 5504704U, 5513152U,
- 5521216U, 5529536U, 5536576U, 5544256U, 5554112U, 5559616U, 5570368U,
- 5577664U, 5586752U, 5594944U, 5603008U, 5611456U, 5619392U, 5627584U,
- 5634368U, 5643328U, 5651264U, 5659328U, 5667008U, 5675584U, 5684416U,
- 5692864U, 5701568U, 5709632U, 5717056U, 5725376U, 5734336U, 5740096U,
- 5750336U, 5758912U, 5766848U, 5775296U, 5782976U, 5790784U, 5799616U,
- 5807936U, 5815232U, 5823808U, 5832256U, 5840192U, 5848768U, 5856832U,
- 5864896U, 5873344U, 5879872U, 5888576U, 5897792U, 5905216U, 5914432U,
- 5920448U, 5930944U, 5938624U, 5947328U, 5955392U, 5963456U, 5971648U,
- 5979328U, 5988032U, 5995712U, 6003904U, 6012736U, 6021056U, 6029248U,
- 6037184U, 6045632U, 6053312U, 6061376U, 6070208U, 6077504U, 6086464U,
- 6094784U, 6101696U, 6110912U, 6118592U, 6127168U, 6135616U, 6143296U,
- 6150208U, 6158912U, 6168128U, 6175808U, 6182464U, 6192832U, 6201152U,
- 6209344U, 6217664U, 6224576U, 6233408U, 6241472U, 6249664U, 6258496U,
- 6266816U, 6275008U, 6281152U, 6291136U, 6299456U, 6306752U, 6314816U,
- 6323776U, 6332096U, 6339392U, 6348224U, 6356288U, 6364096U, 6373184U,
- 6381376U, 6389696U, 6397504U, 6404416U, 6413632U, 6421952U, 6430016U,
- 6437824U, 6446912U, 6454592U, 6463168U, 6471616U, 6478144U, 6487232U,
- 6496192U, 6504128U, 6511936U, 6520256U, 6528832U, 6536896U, 6544576U,
- 6553408U, 6561472U, 6569792U, 6577216U, 6586304U, 6592448U, 6601024U,
- 6610624U, 6619072U, 6627136U, 6634816U, 6643264U, 6650816U, 6659776U,
- 6667712U, 6675904U, 6682688U, 6691904U, 6700864U, 6709184U, 6717376U,
- 6724544U, 6733504U, 6741824U, 6749888U, 6756032U, 6766528U, 6773056U,
- 6782912U, 6790976U, 6798016U, 6807488U, 6815168U, 6823744U, 6832064U,
- 6840128U, 6847552U, 6855872U, 6864064U, 6872128U, 6880576U, 6889408U,
- 6897472U, 6905792U, 6913472U, 6920896U, 6930368U, 6938432U, 6946624U,
- 6953536U, 6963136U, 6971072U, 6979136U, 6986944U, 6995392U, 7003712U,
- 7012288U, 7019072U, 7028416U, 7036352U, 7044416U, 7051712U, 7060672U,
- 7069376U, 7077568U, 7085504U, 7092544U, 7102016U, 7110592U, 7118656U,
- 7126208U, 7135168U, 7143104U, 7150912U, 7159744U, 7167808U, 7175744U,
- 7184192U, 7191232U, 7200448U, 7207744U, 7216576U, 7224128U, 7233472U,
- 7241536U, 7249856U, 7256512U, 7264832U, 7274048U, 7282112U, 7290176U,
- 7298752U, 7306688U, 7315136U, 7322816U, 7331392U, 7339456U, 7347776U,
- 7356224U, 7364288U, 7371712U, 7380928U, 7387456U, 7396544U, 7404352U,
- 7413568U, 7421632U, 7429696U, 7436864U, 7446464U, 7454144U, 7461952U,
- 7470784U, 7478336U, 7487296U, 7495616U, 7503424U, 7511872U, 7520192U,
- 7527616U, 7536448U, 7544512U, 7551424U, 7560128U, 7568576U, 7577536U,
- 7583552U, 7592512U, 7600448U, 7610048U, 7618496U, 7626176U, 7634752U,
- 7642816U, 7651264U, 7659328U, 7667008U, 7675456U, 7683136U, 7691584U,
- 7700416U, 7707584U, 7716416U, 7724224U, 7733056U, 7740608U, 7749184U,
- 7756096U, 7765952U, 7774016U, 7781824U, 7790528U, 7798592U, 7805888U,
- 7814336U, 7822784U, 7831232U, 7839296U, 7847104U, 7855552U, 7863616U,
- 7872448U, 7880128U, 7888576U, 7896256U, 7905088U, 7912768U, 7920448U,
- 7928768U, 7937344U, 7945792U, 7953728U, 7959488U, 7970752U, 7978816U,
- 7987136U, 7994816U, 8003392U, 8011712U, 8019904U, 8027456U, 8035264U,
- 8044352U, 8052544U, 8060224U, 8069056U, 8076736U, 8084672U, 8093504U,
- 8101312U, 8110016U, 8117696U, 8125888U, 8134592U, 8142016U, 8149952U,
- 8159168U, 8166976U, 8175296U, 8183488U, 8191808U, 8199616U, 8207296U,
- 8216128U, 8224576U, 8232256U, 8241088U, 8248256U, 8257472U, 8264128U,
- 8273728U, 8281792U, 8290112U, 8297152U, 8305216U, 8314816U, 8322752U,
- 8330944U, 8339392U, 8347072U, 8355392U, 8363968U, 8371904U, 8379328U,
- 8388544U, 8394944U, 8404544U, 8412736U, 8421184U, 8429504U, 8437696U,
- 8445376U, 8452544U, 8460736U, 8470208U, 8478016U, 8486848U, 8494144U,
- 8503232U, 8511296U, 8519488U, 8527424U, 8534464U, 8543936U, 8552384U,
- 8558912U, 8568128U, 8575936U, 8584256U, 8593216U, 8601536U, 8608832U,
- 8616896U, 8625728U, 8634176U, 8641856U, 8649664U, 8658112U, 8666176U,
- 8674112U, 8682944U, 8691136U, 8699456U, 8707648U, 8716096U, 8724416U,
- 8732608U, 8740672U, 8748352U, 8756032U, 8764864U, 8773568U, 8781376U,
- 8789824U, 8796992U, 8806208U, 8814272U, 8822336U, 8830912U, 8838848U,
- 8847296U, 8854336U, 8863552U, 8871488U, 8879296U, 8887616U, 8894528U,
- 8904512U, 8911424U, 8920768U, 8928704U, 8936128U, 8944576U, 8953664U,
- 8960576U, 8970176U, 8977984U, 8986304U, 8994112U, 9002432U, 9011008U,
- 9018176U, 9026624U, 9035584U, 9043904U, 9052096U, 9059264U, 9068096U,
- 9075904U, 9084224U, 9092288U, 9100352U, 9108928U, 9116992U, 9125824U,
- 9133504U, 9141824U, 9150272U, 9157952U, 9164608U, 9174848U, 9182912U,
- 9190976U, 9199552U, 9205312U, 9215936U, 9222592U, 9232192U, 9240512U,
- 9248704U, 9256256U, 9264832U, 9272896U, 9281344U, 9288896U, 9297088U,
- 9305536U, 9313984U, 9322304U, 9329728U, 9337792U, 9346112U, 9355072U,
- 9363136U, 9371072U, 9378752U, 9387712U, 9395648U, 9404224U, 9411008U,
- 9420608U, 9428416U, 9436864U, 9445312U, 9453376U, 9460928U, 9468736U,
- 9477824U, 9485248U, 9493696U, 9502144U, 9509056U, 9518528U, 9527104U,
- 9535424U, 9543616U, 9551296U, 9559744U, 9568192U, 9576256U, 9584576U,
- 9591872U, 9600704U, 9608384U, 9615808U, 9624512U, 9633472U, 9641536U,
- 9649856U, 9658048U, 9665728U, 9674432U, 9682496U, 9691072U, 9699136U,
- 9707072U, 9715136U, 9722176U, 9732032U, 9740096U, 9747904U, 9756352U,
- 9764288U, 9771584U, 9780544U, 9789376U, 9796928U, 9804224U, 9813952U,
- 9822016U, 9829696U, 9838016U, 9845824U, 9852992U, 9863104U, 9870656U,
- 9878464U, 9887552U, 9895744U, 9903808U, 9912128U, 9920192U, 9927616U,
- 9936064U, 9944768U, 9952576U, 9960128U, 9969472U, 9977152U, 9985216U,
- 9994048U, 10001216U, 10007744U, 10018496U, 10026944U, 10035136U, 10042432U,
- 10051264U, 10059584U, 10067648U, 10075712U, 10083904U, 10091456U, 10100672U,
- 10108864U, 10116928U, 10124864U, 10133056U, 10140736U, 10149824U, 10156736U,
- 10165952U, 10173376U, 10182208U, 10190528U, 10198336U, 10206272U, 10213696U,
- 10223296U, 10231744U, 10238656U, 10247488U, 10256192U, 10263872U, 10272448U,
- 10280896U, 10288448U, 10296512U, 10305088U, 10313536U, 10321088U, 10330048U,
- 10337984U, 10346176U, 10354112U, 10362304U, 10369088U, 10377152U, 10386752U,
- 10394816U, 10403648U, 10411712U, 10418624U, 10427968U, 10436032U, 10444736U,
- 10452928U, 10459712U, 10468672U, 10476608U, 10484416U, 10491328U, 10501952U,
- 10509376U, 10517824U, 10526528U, 10534336U, 10542656U, 10549696U, 10559168U,
- 10566592U, 10575808U, 10583488U, 10590656U, 10599488U, 10607936U, 10616768U,
- 10624832U, 10630336U, 10640576U, 10649536U, 10655168U, 10665152U, 10674112U,
- 10682176U, 10690496U, 10698176U, 10705216U, 10715072U, 10722752U, 10731328U,
- 10739264U, 10746688U, 10754752U, 10761664U, 10770752U, 10779712U, 10787776U,
- 10796608U, 10803392U, 10812352U, 10821056U, 10828736U, 10837952U, 10846144U,
- 10853824U, 10861376U, 10869952U, 10877248U, 10887104U, 10895296U, 10903232U,
- 10910912U, 10918976U, 10927936U, 10935872U, 10944448U, 10952384U, 10960832U,
- 10968512U, 10977088U, 10985024U, 10992832U, 11000896U, 11009984U, 11018048U,
- 11026112U, 11034304U, 11042624U, 11050432U, 11058368U, 11064512U, 11075392U,
- 11083712U, 11091776U, 11099584U, 11107904U, 11115968U, 11124416U, 11131712U,
- 11141056U, 11148608U, 11157184U, 11165248U, 11173312U, 11180992U, 11189056U,
- 11197376U, 11206592U, 11214656U, 11222336U, 11230784U, 11238464U, 11246528U,
- 11254976U, 11263552U, 11271872U, 11279552U, 11288512U, 11296576U, 11304256U,
- 11312192U, 11320768U, 11329216U, 11336384U, 11345216U, 11352512U, 11362112U,
- 11369408U, 11378624U, 11386688U, 11394496U, 11402816U, 11411264U, 11418688U,
- 11427776U, 11435584U, 11444032U, 11452096U, 11459648U, 11467072U, 11476928U,
- 11484992U, 11493184U, 11500352U, 11509312U, 11517248U, 11524928U, 11534144U,
- 11542208U, 11550272U, 11556416U, 11566784U, 11574208U, 11581376U, 11589568U,
- 11599552U, 11607104U, 11616064U, 11623616U, 11632576U, 11639872U, 11648704U,
- 11657024U, 11664704U, 11672896U, 11681216U, 11689792U, 11697856U, 11705536U,
- 11714368U, 11722688U, 11730496U, 11737408U, 11745728U, 11754304U, 11763008U,
- 11770816U, 11779648U, 11788096U, 11795776U, 11804608U, 11812544U, 11820992U,
- 11829184U, 11837248U, 11844928U, 11852096U, 11860928U, 11869888U, 11878336U,
- 11886272U, 11894336U, 11902144U, 11910848U, 11919296U, 11925952U, 11934784U,
- 11943616U, 11951552U, 11960128U, 11968192U, 11976512U, 11983168U, 11992768U,
- 12000832U, 12008896U, 12016832U, 12025408U, 12033856U, 12042176U, 12049984U,
- 12058048U, 12066112U, 12073792U, 12082624U, 12091328U, 12098752U, 12106816U,
- 12115904U, 12124096U, 12131776U, 12140224U, 12148672U, 12156736U, 12164032U,
- 12173248U, 12181184U, 12186176U, 12197824U, 12205888U, 12213952U, 12218944U,
- 12230336U, 12238784U, 12246592U, 12254272U, 12262336U, 12269888U, 12279104U,
- 12287936U, 12295744U, 12304064U, 12312512U, 12319936U, 12328768U, 12337088U,
- 12344896U, 12352832U, 12361408U, 12368704U, 12377152U, 12384832U, 12394432U,
- 12402496U, 12409024U, 12417728U, 12426688U, 12433216U, 12443584U, 12450752U,
- 12459968U, 12468032U, 12475712U, 12484544U, 12492608U, 12500416U, 12508352U,
- 12517184U, 12525376U, 12532288U, 12541888U, 12549568U, 12556864U, 12565568U,
- 12574528U, 12582208U, 12590528U, 12598592U, 12607424U, 12615488U, 12623552U,
- 12631744U, 12638656U, 12647744U, 12656576U, 12664768U, 12672832U, 12680896U,
- 12688576U, 12697408U, 12704192U, 12713408U, 12721216U, 12729664U, 12738496U,
- 12745792U, 12754496U, 12762688U, 12769472U, 12779456U, 12787648U, 12795712U,
- 12804032U, 12812224U, 12819008U, 12828352U, 12836672U, 12844736U, 12851648U,
- 12859456U, 12868672U, 12877504U, 12885568U, 12892864U, 12902336U, 12909376U,
- 12918208U, 12926656U, 12934976U, 12942784U, 12951104U, 12959552U, 12967744U,
- 12976064U, 12984256U, 12991936U, 12999488U, 13007936U, 13016768U, 13021504U,
- 13033024U, 13041472U, 13049408U, 13057472U, 13065664U, 13072064U, 13081408U,
- 13089344U, 13098688U, 13107008U, 13115072U, 13122752U, 13130944U, 13139648U,
- 13147712U, 13155776U, 13162432U, 13172672U, 13180864U, 13188928U, 13196992U,
- 13203392U, 13213504U, 13219264U, 13228736U, 13236928U, 13244992U, 13253056U,
- 13262528U, 13269952U, 13278784U, 13285952U, 13295552U, 13303616U, 13311808U,
- 13319744U, 13328192U, 13336256U, 13344704U, 13352384U, 13360576U, 13369024U,
- 13377344U, 13385408U, 13393216U, 13401664U, 13410112U, 13418176U, 13426496U,
- 13434688U, 13442368U, 13451072U, 13459136U, 13466944U, 13475648U, 13482944U,
- 13491904U, 13500352U, 13508288U, 13516736U, 13524416U, 13532224U, 13541312U,
- 13549504U, 13556288U, 13564736U, 13573184U, 13581376U, 13587008U, 13598656U,
- 13605952U, 13612864U, 13622464U, 13631168U, 13639616U, 13647808U, 13655104U,
- 13663424U, 13671872U, 13680064U, 13688768U, 13696576U, 13705024U, 13712576U,
- 13721536U, 13729216U, 13737664U, 13746112U, 13753024U, 13759552U, 13770304U,
- 13777856U, 13786688U, 13793984U, 13802176U, 13811264U, 13819328U, 13827904U,
- 13835456U, 13844416U, 13851584U, 13860544U, 13868992U, 13877056U, 13884608U,
- 13893184U, 13901248U, 13909696U, 13917632U, 13925056U, 13934528U, 13942336U,
- 13950784U, 13959104U, 13966912U, 13975232U, 13982656U, 13991872U, 13999936U,
- 14007872U, 14016064U, 14024512U, 14032064U, 14040896U, 14049088U, 14057408U,
- 14065088U, 14072896U, 14081344U, 14089664U, 14097856U, 14106304U, 14114752U,
- 14122688U, 14130752U, 14138816U, 14147008U, 14155072U, 14163904U, 14170432U,
- 14180288U, 14187328U, 14196032U, 14204864U, 14212672U, 14220736U, 14229056U,
- 14237504U, 14245568U, 14253632U, 14261824U, 14269888U, 14278592U, 14286656U,
- 14293696U, 14302784U, 14309696U, 14317504U, 14326336U, 14335936U, 14343232U,
- 14352064U, 14359232U, 14368064U, 14376512U, 14384576U, 14393024U, 14401472U,
- 14409536U, 14416832U, 14424512U, 14433856U, 14440768U, 14449984U, 14458816U,
- 14465728U, 14474816U, 14482112U, 14491328U, 14499392U, 14506816U, 14516032U,
- 14524352U, 14531392U, 14540224U, 14547392U, 14556992U, 14565184U, 14573248U,
- 14580928U, 14588864U, 14596928U, 14606272U, 14613824U, 14622656U, 14630464U,
- 14638912U, 14646976U, 14655296U, 14661952U, 14671808U, 14679872U, 14687936U,
- 14696384U, 14704576U, 14710336U, 14720192U, 14729152U, 14736448U, 14745152U,
- 14752448U, 14761792U, 14769856U, 14777024U, 14785984U, 14792384U, 14802752U,
- 14810816U, 14819264U, 14827328U, 14835136U, 14843072U, 14851264U, 14860096U,
- 14867648U, 14876096U, 14884544U, 14892736U, 14900672U, 14907968U, 14917312U,
- 14924864U, 14933824U, 14939968U, 14950336U, 14957632U, 14966464U, 14974912U,
- 14982592U, 14991296U, 14999104U, 15006272U, 15015232U, 15023936U, 15031616U,
- 15040448U, 15047488U, 15055552U, 15063616U, 15073216U, 15079744U, 15088064U,
- 15097664U, 15105344U, 15113792U, 15122368U, 15130048U, 15137728U, 15146176U,
- 15154112U, 15162688U, 15171392U, 15179456U, 15187264U, 15194176U, 15204032U,
- 15212224U, 15220544U, 15227456U, 15237056U, 15245248U, 15253184U, 15261632U,
- 15269824U, 15277376U, 15285824U, 15293888U, 15301568U, 15310784U, 15318848U,
- 15325504U, 15335104U, 15343168U, 15350848U, 15359936U, 15367232U, 15373376U,
- 15384256U, 15392576U, 15400384U, 15408832U, 15417152U, 15424832U, 15433024U,
- 15441344U, 15449152U, 15457088U, 15466432U, 15474112U, 15482816U, 15488576U,
- 15499072U, 15505856U, 15514816U, 15523264U, 15531584U, 15540032U, 15547328U,
- 15553984U, 15564608U, 15571904U, 15579968U, 15589312U, 15597376U, 15605696U,
- 15612992U, 15621824U, 15630016U, 15638464U, 15646144U, 15654592U, 15662912U,
- 15671104U, 15677248U, 15686848U, 15693376U, 15701696U, 15712064U, 15720256U,
- 15728576U, 15736384U, 15744704U, 15752512U, 15761344U, 15769024U, 15777728U,
- 15785152U, 15793984U, 15802048U, 15809984U, 15817024U, 15825856U, 15834944U,
- 15843008U, 15849664U, 15859136U, 15866432U, 15876032U, 15884096U, 15892288U,
- 15900608U, 15908416U, 15916864U, 15924928U, 15930176U, 15941056U, 15949504U,
- 15957824U, 15965632U, 15973952U, 15982528U, 15990592U, 15998272U, 16006976U,
- 16012736U, 16023104U, 16031296U, 16039616U, 16048064U, 16055744U, 16064192U,
- 16071488U, 16080832U, 16088768U, 16097216U, 16104896U, 16112704U, 16121792U,
- 16129856U, 16138048U, 16146112U, 16154176U, 16162624U, 16170688U, 16177856U,
- 16186816U, 16195136U, 16202176U, 16211648U, 16220096U, 16228288U, 16235584U,
- 16244672U, 16252864U, 16260544U, 16269248U, 16277056U, 16285504U, 16291648U,
- 16301632U, 16309312U, 16318144U, 16326208U, 16333888U, 16342336U, 16351168U,
- 16359232U, 16367552U, 16375616U, 16383296U, 16391744U, 16398016U, 16407616U,
- 16415936U, 16424896U, 16432448U, 16440896U, 16449088U, 16457024U, 16465472U,
- 16474048U, 16481216U, 16490048U, 16498624U, 16505792U, 16513984U, 16523072U,
- 16531136U, 16538944U, 16547264U, 16555328U, 16563776U, 16570816U, 16578112U,
- 16587712U, 16596544U, 16604992U, 16613312U, 16620608U, 16629568U, 16637888U,
- 16645696U, 16653632U, 16661696U, 16669888U, 16677568U, 16686272U, 16695232U,
- 16703168U, 16710464U, 16719424U, 16726592U, 16733888U, 16744384U, 16752448U,
- 16760768U, 16768448U, 16776896U, 16785344U, 16793536U, 16801216U, 16809664U,
- 16818112U, 16826176U, 16833472U, 16842688U, 16850752U, 16859072U, 16866368U,
- 16875328U, 16883392U, 16891712U, 16899776U, 16907456U, 16915264U, 16924352U,
- 16931776U, 16940608U, 16949056U, 16957376U, 16965056U, 16973248U, 16981696U,
- 16990144U, 16997056U, 17005888U, 17014208U, 17021504U, 17031104U, 17039296U,
- 17046976U, 17055424U, 17062592U, 17070016U, 17079488U, 17087936U, 17096512U,
- 17104576U, 17113024U, 17121088U, 17129408U, 17136832U, 17145664U, 17152832U,
- 17161792U, 17170112U, 17177792U, 17186368U, 17194304U, 17202496U, 17211328U,
- 17218624U, 17227712U, 17233984U, 17243584U, 17251904U, 17259712U, 17266624U,
- 17276608U, 17284672U, 17292224U, 17301056U, 17309632U, 17317568U, 17326016U,
- 17333824U, 17342272U, 17350208U, 17358784U, 17366848U, 17374912U, 17382592U,
- 17390656U, 17399488U, 17406784U, 17413952U, 17423936U, 17432512U, 17440448U,
- 17447744U, 17456704U, 17464768U, 17472064U, 17481536U, 17489344U, 17495488U,
- 17505728U, 17513792U, 17522368U, 17530816U, 17538112U, 17546944U, 17555264U,
- 17563072U, 17569856U, 17579456U, 17587904U, 17596352U, 17603776U, 17611712U,
- 17620672U, 17628992U, 17637184U, 17645504U, 17653568U, 17661632U, 17669824U,
- 17677376U, 17686208U, 17693888U, 17702336U, 17710144U, 17718208U, 17726528U,
- 17734336U, 17743808U, 17751872U, 17759936U, 17766592U, 17776448U, 17784512U,
- 17791936U, 17801152U, 17809216U, 17817152U
+const size_t cache_sizes[2048] = {
+ 16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U,
+ 17693888U, 17824192U, 17955904U, 18087488U, 18218176U, 18349504U, 18481088U,
+ 18611392U, 18742336U, 18874304U, 19004224U, 19135936U, 19267264U, 19398208U,
+ 19529408U, 19660096U, 19791424U, 19922752U, 20053952U, 20184896U, 20315968U,
+ 20446912U, 20576576U, 20709184U, 20840384U, 20971072U, 21102272U, 21233216U,
+ 21364544U, 21494848U, 21626816U, 21757376U, 21887552U, 22019392U, 22151104U,
+ 22281536U, 22412224U, 22543936U, 22675264U, 22806464U, 22935872U, 23068096U,
+ 23198272U, 23330752U, 23459008U, 23592512U, 23723968U, 23854912U, 23986112U,
+ 24116672U, 24247616U, 24378688U, 24509504U, 24640832U, 24772544U, 24903488U,
+ 25034432U, 25165376U, 25296704U, 25427392U, 25558592U, 25690048U, 25820096U,
+ 25951936U, 26081728U, 26214208U, 26345024U, 26476096U, 26606656U, 26737472U,
+ 26869184U, 26998208U, 27131584U, 27262528U, 27393728U, 27523904U, 27655744U,
+ 27786688U, 27917888U, 28049344U, 28179904U, 28311488U, 28441792U, 28573504U,
+ 28700864U, 28835648U, 28966208U, 29096768U, 29228608U, 29359808U, 29490752U,
+ 29621824U, 29752256U, 29882816U, 30014912U, 30144448U, 30273728U, 30406976U,
+ 30538432U, 30670784U, 30799936U, 30932672U, 31063744U, 31195072U, 31325248U,
+ 31456192U, 31588288U, 31719232U, 31850432U, 31981504U, 32110784U, 32243392U,
+ 32372672U, 32505664U, 32636608U, 32767808U, 32897344U, 33029824U, 33160768U,
+ 33289664U, 33423296U, 33554368U, 33683648U, 33816512U, 33947456U, 34076992U,
+ 34208704U, 34340032U, 34471744U, 34600256U, 34734016U, 34864576U, 34993984U,
+ 35127104U, 35258176U, 35386688U, 35518528U, 35650624U, 35782336U, 35910976U,
+ 36044608U, 36175808U, 36305728U, 36436672U, 36568384U, 36699968U, 36830656U,
+ 36961984U, 37093312U, 37223488U, 37355072U, 37486528U, 37617472U, 37747904U,
+ 37879232U, 38009792U, 38141888U, 38272448U, 38403392U, 38535104U, 38660672U,
+ 38795584U, 38925632U, 39059264U, 39190336U, 39320768U, 39452096U, 39581632U,
+ 39713984U, 39844928U, 39974848U, 40107968U, 40238144U, 40367168U, 40500032U,
+ 40631744U, 40762816U, 40894144U, 41023552U, 41155904U, 41286208U, 41418304U,
+ 41547712U, 41680448U, 41811904U, 41942848U, 42073792U, 42204992U, 42334912U,
+ 42467008U, 42597824U, 42729152U, 42860096U, 42991552U, 43122368U, 43253696U,
+ 43382848U, 43515712U, 43646912U, 43777088U, 43907648U, 44039104U, 44170432U,
+ 44302144U, 44433344U, 44564288U, 44694976U, 44825152U, 44956864U, 45088448U,
+ 45219008U, 45350464U, 45481024U, 45612608U, 45744064U, 45874496U, 46006208U,
+ 46136768U, 46267712U, 46399424U, 46529344U, 46660672U, 46791488U, 46923328U,
+ 47053504U, 47185856U, 47316928U, 47447872U, 47579072U, 47710144U, 47839936U,
+ 47971648U, 48103232U, 48234176U, 48365248U, 48496192U, 48627136U, 48757312U,
+ 48889664U, 49020736U, 49149248U, 49283008U, 49413824U, 49545152U, 49675712U,
+ 49807168U, 49938368U, 50069056U, 50200256U, 50331584U, 50462656U, 50593472U,
+ 50724032U, 50853952U, 50986048U, 51117632U, 51248576U, 51379904U, 51510848U,
+ 51641792U, 51773248U, 51903296U, 52035136U, 52164032U, 52297664U, 52427968U,
+ 52557376U, 52690112U, 52821952U, 52952896U, 53081536U, 53213504U, 53344576U,
+ 53475776U, 53608384U, 53738816U, 53870528U, 54000832U, 54131776U, 54263744U,
+ 54394688U, 54525248U, 54655936U, 54787904U, 54918592U, 55049152U, 55181248U,
+ 55312064U, 55442752U, 55574336U, 55705024U, 55836224U, 55967168U, 56097856U,
+ 56228672U, 56358592U, 56490176U, 56621888U, 56753728U, 56884928U, 57015488U,
+ 57146816U, 57278272U, 57409216U, 57540416U, 57671104U, 57802432U, 57933632U,
+ 58064576U, 58195264U, 58326976U, 58457408U, 58588864U, 58720192U, 58849984U,
+ 58981696U, 59113024U, 59243456U, 59375552U, 59506624U, 59637568U, 59768512U,
+ 59897792U, 60030016U, 60161984U, 60293056U, 60423872U, 60554432U, 60683968U,
+ 60817216U, 60948032U, 61079488U, 61209664U, 61341376U, 61471936U, 61602752U,
+ 61733696U, 61865792U, 61996736U, 62127808U, 62259136U, 62389568U, 62520512U,
+ 62651584U, 62781632U, 62910784U, 63045056U, 63176128U, 63307072U, 63438656U,
+ 63569216U, 63700928U, 63831616U, 63960896U, 64093888U, 64225088U, 64355392U,
+ 64486976U, 64617664U, 64748608U, 64879424U, 65009216U, 65142464U, 65273792U,
+ 65402816U, 65535424U, 65666752U, 65797696U, 65927744U, 66060224U, 66191296U,
+ 66321344U, 66453056U, 66584384U, 66715328U, 66846656U, 66977728U, 67108672U,
+ 67239104U, 67370432U, 67501888U, 67631296U, 67763776U, 67895104U, 68026304U,
+ 68157248U, 68287936U, 68419264U, 68548288U, 68681408U, 68811968U, 68942912U,
+ 69074624U, 69205568U, 69337024U, 69467584U, 69599168U, 69729472U, 69861184U,
+ 69989824U, 70122944U, 70253888U, 70385344U, 70515904U, 70647232U, 70778816U,
+ 70907968U, 71040832U, 71171648U, 71303104U, 71432512U, 71564992U, 71695168U,
+ 71826368U, 71958464U, 72089536U, 72219712U, 72350144U, 72482624U, 72613568U,
+ 72744512U, 72875584U, 73006144U, 73138112U, 73268672U, 73400128U, 73530944U,
+ 73662272U, 73793344U, 73924544U, 74055104U, 74185792U, 74316992U, 74448832U,
+ 74579392U, 74710976U, 74841664U, 74972864U, 75102784U, 75233344U, 75364544U,
+ 75497024U, 75627584U, 75759296U, 75890624U, 76021696U, 76152256U, 76283072U,
+ 76414144U, 76545856U, 76676672U, 76806976U, 76937792U, 77070016U, 77200832U,
+ 77331392U, 77462464U, 77593664U, 77725376U, 77856448U, 77987776U, 78118336U,
+ 78249664U, 78380992U, 78511424U, 78642496U, 78773056U, 78905152U, 79033664U,
+ 79166656U, 79297472U, 79429568U, 79560512U, 79690816U, 79822784U, 79953472U,
+ 80084672U, 80214208U, 80346944U, 80477632U, 80608576U, 80740288U, 80870848U,
+ 81002048U, 81133504U, 81264448U, 81395648U, 81525952U, 81657536U, 81786304U,
+ 81919808U, 82050112U, 82181312U, 82311616U, 82443968U, 82573376U, 82705984U,
+ 82835776U, 82967744U, 83096768U, 83230528U, 83359552U, 83491264U, 83622464U,
+ 83753536U, 83886016U, 84015296U, 84147776U, 84277184U, 84409792U, 84540608U,
+ 84672064U, 84803008U, 84934336U, 85065152U, 85193792U, 85326784U, 85458496U,
+ 85589312U, 85721024U, 85851968U, 85982656U, 86112448U, 86244416U, 86370112U,
+ 86506688U, 86637632U, 86769344U, 86900672U, 87031744U, 87162304U, 87293632U,
+ 87424576U, 87555392U, 87687104U, 87816896U, 87947968U, 88079168U, 88211264U,
+ 88341824U, 88473152U, 88603712U, 88735424U, 88862912U, 88996672U, 89128384U,
+ 89259712U, 89390272U, 89521984U, 89652544U, 89783872U, 89914816U, 90045376U,
+ 90177088U, 90307904U, 90438848U, 90569152U, 90700096U, 90832832U, 90963776U,
+ 91093696U, 91223744U, 91356992U, 91486784U, 91618496U, 91749824U, 91880384U,
+ 92012224U, 92143552U, 92273344U, 92405696U, 92536768U, 92666432U, 92798912U,
+ 92926016U, 93060544U, 93192128U, 93322816U, 93453632U, 93583936U, 93715136U,
+ 93845056U, 93977792U, 94109504U, 94240448U, 94371776U, 94501184U, 94632896U,
+ 94764224U, 94895552U, 95023424U, 95158208U, 95287744U, 95420224U, 95550016U,
+ 95681216U, 95811904U, 95943872U, 96075328U, 96203584U, 96337856U, 96468544U,
+ 96599744U, 96731072U, 96860992U, 96992576U, 97124288U, 97254848U, 97385536U,
+ 97517248U, 97647808U, 97779392U, 97910464U, 98041408U, 98172608U, 98303168U,
+ 98434496U, 98565568U, 98696768U, 98827328U, 98958784U, 99089728U, 99220928U,
+ 99352384U, 99482816U, 99614272U, 99745472U, 99876416U, 100007104U,
+ 100138048U, 100267072U, 100401088U, 100529984U, 100662592U, 100791872U,
+ 100925248U, 101056064U, 101187392U, 101317952U, 101449408U, 101580608U,
+ 101711296U, 101841728U, 101973824U, 102104896U, 102235712U, 102366016U,
+ 102498112U, 102628672U, 102760384U, 102890432U, 103021888U, 103153472U,
+ 103284032U, 103415744U, 103545152U, 103677248U, 103808576U, 103939648U,
+ 104070976U, 104201792U, 104332736U, 104462528U, 104594752U, 104725952U,
+ 104854592U, 104988608U, 105118912U, 105247808U, 105381184U, 105511232U,
+ 105643072U, 105774784U, 105903296U, 106037056U, 106167872U, 106298944U,
+ 106429504U, 106561472U, 106691392U, 106822592U, 106954304U, 107085376U,
+ 107216576U, 107346368U, 107478464U, 107609792U, 107739712U, 107872192U,
+ 108003136U, 108131392U, 108265408U, 108396224U, 108527168U, 108657344U,
+ 108789568U, 108920384U, 109049792U, 109182272U, 109312576U, 109444928U,
+ 109572928U, 109706944U, 109837888U, 109969088U, 110099648U, 110230976U,
+ 110362432U, 110492992U, 110624704U, 110755264U, 110886208U, 111017408U,
+ 111148864U, 111279296U, 111410752U, 111541952U, 111673024U, 111803456U,
+ 111933632U, 112066496U, 112196416U, 112328512U, 112457792U, 112590784U,
+ 112715968U, 112852672U, 112983616U, 113114944U, 113244224U, 113376448U,
+ 113505472U, 113639104U, 113770304U, 113901376U, 114031552U, 114163264U,
+ 114294592U, 114425536U, 114556864U, 114687424U, 114818624U, 114948544U,
+ 115080512U, 115212224U, 115343296U, 115473472U, 115605184U, 115736128U,
+ 115867072U, 115997248U, 116128576U, 116260288U, 116391488U, 116522944U,
+ 116652992U, 116784704U, 116915648U, 117046208U, 117178304U, 117308608U,
+ 117440192U, 117569728U, 117701824U, 117833024U, 117964096U, 118094656U,
+ 118225984U, 118357312U, 118489024U, 118617536U, 118749632U, 118882112U,
+ 119012416U, 119144384U, 119275328U, 119406016U, 119537344U, 119668672U,
+ 119798464U, 119928896U, 120061376U, 120192832U, 120321728U, 120454336U,
+ 120584512U, 120716608U, 120848192U, 120979136U, 121109056U, 121241408U,
+ 121372352U, 121502912U, 121634752U, 121764416U, 121895744U, 122027072U,
+ 122157632U, 122289088U, 122421184U, 122550592U, 122682944U, 122813888U,
+ 122945344U, 123075776U, 123207488U, 123338048U, 123468736U, 123600704U,
+ 123731264U, 123861952U, 123993664U, 124124608U, 124256192U, 124386368U,
+ 124518208U, 124649024U, 124778048U, 124911296U, 125041088U, 125173696U,
+ 125303744U, 125432896U, 125566912U, 125696576U, 125829056U, 125958592U,
+ 126090304U, 126221248U, 126352832U, 126483776U, 126615232U, 126746432U,
+ 126876608U, 127008704U, 127139392U, 127270336U, 127401152U, 127532224U,
+ 127663552U, 127794752U, 127925696U, 128055232U, 128188096U, 128319424U,
+ 128449856U, 128581312U, 128712256U, 128843584U, 128973632U, 129103808U,
+ 129236288U, 129365696U, 129498944U, 129629888U, 129760832U, 129892288U,
+ 130023104U, 130154048U, 130283968U, 130416448U, 130547008U, 130678336U,
+ 130807616U, 130939456U, 131071552U, 131202112U, 131331776U, 131464384U,
+ 131594048U, 131727296U, 131858368U, 131987392U, 132120256U, 132250816U,
+ 132382528U, 132513728U, 132644672U, 132774976U, 132905792U, 133038016U,
+ 133168832U, 133299392U, 133429312U, 133562048U, 133692992U, 133823296U,
+ 133954624U, 134086336U, 134217152U, 134348608U, 134479808U, 134607296U,
+ 134741056U, 134872384U, 135002944U, 135134144U, 135265472U, 135396544U,
+ 135527872U, 135659072U, 135787712U, 135921472U, 136052416U, 136182848U,
+ 136313792U, 136444864U, 136576448U, 136707904U, 136837952U, 136970048U,
+ 137099584U, 137232064U, 137363392U, 137494208U, 137625536U, 137755712U,
+ 137887424U, 138018368U, 138149824U, 138280256U, 138411584U, 138539584U,
+ 138672832U, 138804928U, 138936128U, 139066688U, 139196864U, 139328704U,
+ 139460032U, 139590208U, 139721024U, 139852864U, 139984576U, 140115776U,
+ 140245696U, 140376512U, 140508352U, 140640064U, 140769856U, 140902336U,
+ 141032768U, 141162688U, 141294016U, 141426496U, 141556544U, 141687488U,
+ 141819584U, 141949888U, 142080448U, 142212544U, 142342336U, 142474432U,
+ 142606144U, 142736192U, 142868288U, 142997824U, 143129408U, 143258944U,
+ 143392448U, 143523136U, 143653696U, 143785024U, 143916992U, 144045632U,
+ 144177856U, 144309184U, 144440768U, 144570688U, 144701888U, 144832448U,
+ 144965056U, 145096384U, 145227584U, 145358656U, 145489856U, 145620928U,
+ 145751488U, 145883072U, 146011456U, 146144704U, 146275264U, 146407232U,
+ 146538176U, 146668736U, 146800448U, 146931392U, 147062336U, 147193664U,
+ 147324224U, 147455936U, 147586624U, 147717056U, 147848768U, 147979456U,
+ 148110784U, 148242368U, 148373312U, 148503232U, 148635584U, 148766144U,
+ 148897088U, 149028416U, 149159488U, 149290688U, 149420224U, 149551552U,
+ 149683136U, 149814976U, 149943616U, 150076352U, 150208064U, 150338624U,
+ 150470464U, 150600256U, 150732224U, 150862784U, 150993088U, 151125952U,
+ 151254976U, 151388096U, 151519168U, 151649728U, 151778752U, 151911104U,
+ 152042944U, 152174144U, 152304704U, 152435648U, 152567488U, 152698816U,
+ 152828992U, 152960576U, 153091648U, 153222976U, 153353792U, 153484096U,
+ 153616192U, 153747008U, 153878336U, 154008256U, 154139968U, 154270912U,
+ 154402624U, 154533824U, 154663616U, 154795712U, 154926272U, 155057984U,
+ 155188928U, 155319872U, 155450816U, 155580608U, 155712064U, 155843392U,
+ 155971136U, 156106688U, 156237376U, 156367424U, 156499264U, 156630976U,
+ 156761536U, 156892352U, 157024064U, 157155008U, 157284416U, 157415872U,
+ 157545536U, 157677248U, 157810496U, 157938112U, 158071744U, 158203328U,
+ 158334656U, 158464832U, 158596288U, 158727616U, 158858048U, 158988992U,
+ 159121216U, 159252416U, 159381568U, 159513152U, 159645632U, 159776192U,
+ 159906496U, 160038464U, 160169536U, 160300352U, 160430656U, 160563008U,
+ 160693952U, 160822208U, 160956352U, 161086784U, 161217344U, 161349184U,
+ 161480512U, 161611456U, 161742272U, 161873216U, 162002752U, 162135872U,
+ 162266432U, 162397888U, 162529216U, 162660032U, 162790976U, 162922048U,
+ 163052096U, 163184576U, 163314752U, 163446592U, 163577408U, 163707968U,
+ 163839296U, 163969984U, 164100928U, 164233024U, 164364224U, 164494912U,
+ 164625856U, 164756672U, 164887616U, 165019072U, 165150016U, 165280064U,
+ 165412672U, 165543104U, 165674944U, 165805888U, 165936832U, 166067648U,
+ 166198336U, 166330048U, 166461248U, 166591552U, 166722496U, 166854208U,
+ 166985408U, 167116736U, 167246656U, 167378368U, 167508416U, 167641024U,
+ 167771584U, 167903168U, 168034112U, 168164032U, 168295744U, 168427456U,
+ 168557632U, 168688448U, 168819136U, 168951616U, 169082176U, 169213504U,
+ 169344832U, 169475648U, 169605952U, 169738048U, 169866304U, 169999552U,
+ 170131264U, 170262464U, 170393536U, 170524352U, 170655424U, 170782016U,
+ 170917696U, 171048896U, 171179072U, 171310784U, 171439936U, 171573184U,
+ 171702976U, 171835072U, 171966272U, 172097216U, 172228288U, 172359232U,
+ 172489664U, 172621376U, 172747712U, 172883264U, 173014208U, 173144512U,
+ 173275072U, 173407424U, 173539136U, 173669696U, 173800768U, 173931712U,
+ 174063424U, 174193472U, 174325696U, 174455744U, 174586816U, 174718912U,
+ 174849728U, 174977728U, 175109696U, 175242688U, 175374272U, 175504832U,
+ 175636288U, 175765696U, 175898432U, 176028992U, 176159936U, 176291264U,
+ 176422592U, 176552512U, 176684864U, 176815424U, 176946496U, 177076544U,
+ 177209152U, 177340096U, 177470528U, 177600704U, 177731648U, 177864256U,
+ 177994816U, 178126528U, 178257472U, 178387648U, 178518464U, 178650176U,
+ 178781888U, 178912064U, 179044288U, 179174848U, 179305024U, 179436736U,
+ 179568448U, 179698496U, 179830208U, 179960512U, 180092608U, 180223808U,
+ 180354752U, 180485696U, 180617152U, 180748096U, 180877504U, 181009984U,
+ 181139264U, 181272512U, 181402688U, 181532608U, 181663168U, 181795136U,
+ 181926592U, 182057536U, 182190016U, 182320192U, 182451904U, 182582336U,
+ 182713792U, 182843072U, 182976064U, 183107264U, 183237056U, 183368384U,
+ 183494848U, 183631424U, 183762752U, 183893824U, 184024768U, 184154816U,
+ 184286656U, 184417984U, 184548928U, 184680128U, 184810816U, 184941248U,
+ 185072704U, 185203904U, 185335616U, 185465408U, 185596352U, 185727296U,
+ 185859904U, 185989696U, 186121664U, 186252992U, 186383552U, 186514112U,
+ 186645952U, 186777152U, 186907328U, 187037504U, 187170112U, 187301824U,
+ 187429184U, 187562048U, 187693504U, 187825472U, 187957184U, 188087104U,
+ 188218304U, 188349376U, 188481344U, 188609728U, 188743616U, 188874304U,
+ 189005248U, 189136448U, 189265088U, 189396544U, 189528128U, 189660992U,
+ 189791936U, 189923264U, 190054208U, 190182848U, 190315072U, 190447424U,
+ 190577984U, 190709312U, 190840768U, 190971328U, 191102656U, 191233472U,
+ 191364032U, 191495872U, 191626816U, 191758016U, 191888192U, 192020288U,
+ 192148928U, 192282176U, 192413504U, 192542528U, 192674752U, 192805952U,
+ 192937792U, 193068608U, 193198912U, 193330496U, 193462208U, 193592384U,
+ 193723456U, 193854272U, 193985984U, 194116672U, 194247232U, 194379712U,
+ 194508352U, 194641856U, 194772544U, 194900672U, 195035072U, 195166016U,
+ 195296704U, 195428032U, 195558592U, 195690304U, 195818176U, 195952576U,
+ 196083392U, 196214336U, 196345792U, 196476736U, 196607552U, 196739008U,
+ 196869952U, 197000768U, 197130688U, 197262784U, 197394368U, 197523904U,
+ 197656384U, 197787584U, 197916608U, 198049472U, 198180544U, 198310208U,
+ 198442432U, 198573632U, 198705088U, 198834368U, 198967232U, 199097792U,
+ 199228352U, 199360192U, 199491392U, 199621696U, 199751744U, 199883968U,
+ 200014016U, 200146624U, 200276672U, 200408128U, 200540096U, 200671168U,
+ 200801984U, 200933312U, 201062464U, 201194944U, 201326144U, 201457472U,
+ 201588544U, 201719744U, 201850816U, 201981632U, 202111552U, 202244032U,
+ 202374464U, 202505152U, 202636352U, 202767808U, 202898368U, 203030336U,
+ 203159872U, 203292608U, 203423296U, 203553472U, 203685824U, 203816896U,
+ 203947712U, 204078272U, 204208192U, 204341056U, 204472256U, 204603328U,
+ 204733888U, 204864448U, 204996544U, 205125568U, 205258304U, 205388864U,
+ 205517632U, 205650112U, 205782208U, 205913536U, 206044736U, 206176192U,
+ 206307008U, 206434496U, 206569024U, 206700224U, 206831168U, 206961856U,
+ 207093056U, 207223616U, 207355328U, 207486784U, 207616832U, 207749056U,
+ 207879104U, 208010048U, 208141888U, 208273216U, 208404032U, 208534336U,
+ 208666048U, 208796864U, 208927424U, 209059264U, 209189824U, 209321792U,
+ 209451584U, 209582656U, 209715136U, 209845568U, 209976896U, 210106432U,
+ 210239296U, 210370112U, 210501568U, 210630976U, 210763712U, 210894272U,
+ 211024832U, 211156672U, 211287616U, 211418176U, 211549376U, 211679296U,
+ 211812032U, 211942592U, 212074432U, 212204864U, 212334016U, 212467648U,
+ 212597824U, 212727616U, 212860352U, 212991424U, 213120832U, 213253952U,
+ 213385024U, 213515584U, 213645632U, 213777728U, 213909184U, 214040128U,
+ 214170688U, 214302656U, 214433728U, 214564544U, 214695232U, 214826048U,
+ 214956992U, 215089088U, 215219776U, 215350592U, 215482304U, 215613248U,
+ 215743552U, 215874752U, 216005312U, 216137024U, 216267328U, 216399296U,
+ 216530752U, 216661696U, 216790592U, 216923968U, 217054528U, 217183168U,
+ 217316672U, 217448128U, 217579072U, 217709504U, 217838912U, 217972672U,
+ 218102848U, 218233024U, 218364736U, 218496832U, 218627776U, 218759104U,
+ 218888896U, 219021248U, 219151936U, 219281728U, 219413056U, 219545024U,
+ 219675968U, 219807296U, 219938624U, 220069312U, 220200128U, 220331456U,
+ 220461632U, 220592704U, 220725184U, 220855744U, 220987072U, 221117888U,
+ 221249216U, 221378368U, 221510336U, 221642048U, 221772736U, 221904832U,
+ 222031808U, 222166976U, 222297536U, 222428992U, 222559936U, 222690368U,
+ 222820672U, 222953152U, 223083968U, 223213376U, 223345984U, 223476928U,
+ 223608512U, 223738688U, 223869376U, 224001472U, 224132672U, 224262848U,
+ 224394944U, 224524864U, 224657344U, 224788288U, 224919488U, 225050432U,
+ 225181504U, 225312704U, 225443776U, 225574592U, 225704768U, 225834176U,
+ 225966784U, 226097216U, 226229824U, 226360384U, 226491712U, 226623424U,
+ 226754368U, 226885312U, 227015104U, 227147456U, 227278528U, 227409472U,
+ 227539904U, 227669696U, 227802944U, 227932352U, 228065216U, 228196288U,
+ 228326464U, 228457792U, 228588736U, 228720064U, 228850112U, 228981056U,
+ 229113152U, 229243328U, 229375936U, 229505344U, 229636928U, 229769152U,
+ 229894976U, 230030272U, 230162368U, 230292416U, 230424512U, 230553152U,
+ 230684864U, 230816704U, 230948416U, 231079616U, 231210944U, 231342016U,
+ 231472448U, 231603776U, 231733952U, 231866176U, 231996736U, 232127296U,
+ 232259392U, 232388672U, 232521664U, 232652608U, 232782272U, 232914496U,
+ 233043904U, 233175616U, 233306816U, 233438528U, 233569984U, 233699776U,
+ 233830592U, 233962688U, 234092224U, 234221888U, 234353984U, 234485312U,
+ 234618304U, 234749888U, 234880832U, 235011776U, 235142464U, 235274048U,
+ 235403456U, 235535936U, 235667392U, 235797568U, 235928768U, 236057152U,
+ 236190272U, 236322752U, 236453312U, 236583616U, 236715712U, 236846528U,
+ 236976448U, 237108544U, 237239104U, 237371072U, 237501632U, 237630784U,
+ 237764416U, 237895232U, 238026688U, 238157632U, 238286912U, 238419392U,
+ 238548032U, 238681024U, 238812608U, 238941632U, 239075008U, 239206336U,
+ 239335232U, 239466944U, 239599168U, 239730496U, 239861312U, 239992384U,
+ 240122816U, 240254656U, 240385856U, 240516928U, 240647872U, 240779072U,
+ 240909632U, 241040704U, 241171904U, 241302848U, 241433408U, 241565248U,
+ 241696192U, 241825984U, 241958848U, 242088256U, 242220224U, 242352064U,
+ 242481856U, 242611648U, 242744896U, 242876224U, 243005632U, 243138496U,
+ 243268672U, 243400384U, 243531712U, 243662656U, 243793856U, 243924544U,
+ 244054592U, 244187072U, 244316608U, 244448704U, 244580032U, 244710976U,
+ 244841536U, 244972864U, 245104448U, 245233984U, 245365312U, 245497792U,
+ 245628736U, 245759936U, 245889856U, 246021056U, 246152512U, 246284224U,
+ 246415168U, 246545344U, 246675904U, 246808384U, 246939584U, 247070144U,
+ 247199552U, 247331648U, 247463872U, 247593536U, 247726016U, 247857088U,
+ 247987648U, 248116928U, 248249536U, 248380736U, 248512064U, 248643008U,
+ 248773312U, 248901056U, 249036608U, 249167552U, 249298624U, 249429184U,
+ 249560512U, 249692096U, 249822784U, 249954112U, 250085312U, 250215488U,
+ 250345792U, 250478528U, 250608704U, 250739264U, 250870976U, 251002816U,
+ 251133632U, 251263552U, 251395136U, 251523904U, 251657792U, 251789248U,
+ 251919424U, 252051392U, 252182464U, 252313408U, 252444224U, 252575552U,
+ 252706624U, 252836032U, 252968512U, 253099712U, 253227584U, 253361728U,
+ 253493056U, 253623488U, 253754432U, 253885504U, 254017216U, 254148032U,
+ 254279488U, 254410432U, 254541376U, 254672576U, 254803264U, 254933824U,
+ 255065792U, 255196736U, 255326528U, 255458752U, 255589952U, 255721408U,
+ 255851072U, 255983296U, 256114624U, 256244416U, 256374208U, 256507712U,
+ 256636096U, 256768832U, 256900544U, 257031616U, 257162176U, 257294272U,
+ 257424448U, 257555776U, 257686976U, 257818432U, 257949632U, 258079552U,
+ 258211136U, 258342464U, 258473408U, 258603712U, 258734656U, 258867008U,
+ 258996544U, 259127744U, 259260224U, 259391296U, 259522112U, 259651904U,
+ 259784384U, 259915328U, 260045888U, 260175424U, 260308544U, 260438336U,
+ 260570944U, 260700992U, 260832448U, 260963776U, 261092672U, 261226304U,
+ 261356864U, 261487936U, 261619648U, 261750592U, 261879872U, 262011968U,
+ 262143424U, 262274752U, 262404416U, 262537024U, 262667968U, 262799296U,
+ 262928704U, 263061184U, 263191744U, 263322944U, 263454656U, 263585216U,
+ 263716672U, 263847872U, 263978944U, 264108608U, 264241088U, 264371648U,
+ 264501184U, 264632768U, 264764096U, 264895936U, 265024576U, 265158464U,
+ 265287488U, 265418432U, 265550528U, 265681216U, 265813312U, 265943488U,
+ 266075968U, 266206144U, 266337728U, 266468032U, 266600384U, 266731072U,
+ 266862272U, 266993344U, 267124288U, 267255616U, 267386432U, 267516992U,
+ 267648704U, 267777728U, 267910592U, 268040512U, 268172096U, 268302784U,
+ 268435264U, 268566208U, 268696256U, 268828096U, 268959296U, 269090368U,
+ 269221312U, 269352256U, 269482688U, 269614784U, 269745856U, 269876416U,
+ 270007616U, 270139328U, 270270272U, 270401216U, 270531904U, 270663616U,
+ 270791744U, 270924736U, 271056832U, 271186112U, 271317184U, 271449536U,
+ 271580992U, 271711936U, 271843136U, 271973056U, 272105408U, 272236352U,
+ 272367296U, 272498368U, 272629568U, 272759488U, 272891456U, 273022784U,
+ 273153856U, 273284672U, 273415616U, 273547072U, 273677632U, 273808448U,
+ 273937088U, 274071488U, 274200896U, 274332992U, 274463296U, 274595392U,
+ 274726208U, 274857536U, 274988992U, 275118656U, 275250496U, 275382208U,
+ 275513024U, 275643968U, 275775296U, 275906368U, 276037184U, 276167872U,
+ 276297664U, 276429376U, 276560576U, 276692672U, 276822976U, 276955072U,
+ 277085632U, 277216832U, 277347008U, 277478848U, 277609664U, 277740992U,
+ 277868608U, 278002624U, 278134336U, 278265536U, 278395328U, 278526784U,
+ 278657728U, 278789824U, 278921152U, 279052096U, 279182912U, 279313088U,
+ 279443776U, 279576256U, 279706048U, 279838528U, 279969728U, 280099648U,
+ 280230976U, 280361408U, 280493632U, 280622528U, 280755392U, 280887104U,
+ 281018176U, 281147968U, 281278912U, 281411392U, 281542592U, 281673152U,
+ 281803712U, 281935552U, 282066496U, 282197312U, 282329024U, 282458816U,
+ 282590272U, 282720832U, 282853184U, 282983744U, 283115072U, 283246144U,
+ 283377344U, 283508416U, 283639744U, 283770304U, 283901504U, 284032576U,
+ 284163136U, 284294848U, 284426176U, 284556992U, 284687296U, 284819264U,
+ 284950208U, 285081536U
};
#ifdef __cplusplus
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h
index 82421b868..a7159de65 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/ethash.h
@@ -1,18 +1,18 @@
/*
- This file is part of cpp-ethereum.
+ This file is part of ethash.
- cpp-ethereum is free software: you can redistribute it and/or modify
+ ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- cpp-ethereum is distributed in the hope that it will be useful,
+ ethash 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 General Public License for more details.
You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+ along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ethash.h
@@ -26,13 +26,15 @@
#include <stddef.h>
#include "compiler.h"
-#define REVISION 20
-#define DAGSIZE_BYTES_INIT 1073741824U // 2**30
-#define DAG_GROWTH 8388608U // 2**23
-#define CACHE_MULTIPLIER 1024
+#define REVISION 23
+#define DATASET_BYTES_INIT 1073741824U // 2**30
+#define DATASET_BYTES_GROWTH 8388608U // 2**23
+#define CACHE_BYTES_INIT 1073741824U // 2**24
+#define CACHE_BYTES_GROWTH 131072U // 2**17
#define EPOCH_LENGTH 30000U
#define MIX_BYTES 128
-#define DAG_PARENTS 256
+#define HASH_BYTES 64
+#define DATASET_PARENTS 256
#define CACHE_ROUNDS 3
#define ACCESSES 64
@@ -60,19 +62,38 @@ static inline void ethash_params_init(ethash_params *params, const uint32_t bloc
}
typedef struct ethash_cache {
- void *mem;
+ void *mem;
} ethash_cache;
void ethash_mkcache(ethash_cache *cache, ethash_params const *params, const uint8_t seed[32]);
void ethash_compute_full_data(void *mem, ethash_params const *params, ethash_cache const *cache);
void ethash_full(ethash_return_value *ret, void const *full_mem, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce);
void ethash_light(ethash_return_value *ret, ethash_cache const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce);
+void ethash_get_seedhash(uint8_t seedhash[32], const uint32_t block_number);
-static inline void ethash_prep_light(void *cache, ethash_params const *params, const uint8_t seed[32]) { ethash_cache c; c.mem = cache; ethash_mkcache(&c, params, seed); }
-static inline void ethash_compute_light(ethash_return_value *ret, void const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_cache c; c.mem = (void*)cache; ethash_light(ret, &c, params, header_hash, nonce); }
-static inline void ethash_prep_full(void *full, ethash_params const *params, void const *cache) { ethash_cache c; c.mem = (void*)cache; ethash_compute_full_data(full, params, &c); }
-static inline void ethash_compute_full(ethash_return_value *ret, void const *full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_full(ret, full, params, header_hash, nonce); }
+static inline void ethash_prep_light(void *cache, ethash_params const *params, const uint8_t seed[32]) {
+ ethash_cache c;
+ c.mem = cache;
+ ethash_mkcache(&c, params, seed);
+}
+
+static inline void ethash_compute_light(ethash_return_value *ret, void const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) {
+ ethash_cache c;
+ c.mem = (void *) cache;
+ ethash_light(ret, &c, params, header_hash, nonce);
+}
+
+static inline void ethash_prep_full(void *full, ethash_params const *params, void const *cache) {
+ ethash_cache c;
+ c.mem = (void *) cache;
+ ethash_compute_full_data(full, params, &c);
+}
+
+static inline void ethash_compute_full(ethash_return_value *ret, void const *full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) {
+ ethash_full(ret, full, params, header_hash, nonce);
+}
+// Returns if hash is less than or equal to difficulty
static inline int ethash_check_difficulty(
const uint8_t hash[32],
const uint8_t difficulty[32]) {
@@ -81,7 +102,7 @@ static inline int ethash_check_difficulty(
if (hash[i] == difficulty[i]) continue;
return hash[i] < difficulty[i];
}
- return 0;
+ return 1;
}
int ethash_quick_check_difficulty(
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
index a2b82d375..0a7e767e7 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.c
@@ -1,12 +1,12 @@
/*
- This file is part of cpp-ethereum.
+ This file is part of ethash.
- cpp-ethereum is free software: you can redistribute it and/or modify
+ ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- cpp-ethereum is distributed in the hope that it will be useful,
+ ethash 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 General Public License for more details.
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file dash.cpp
+/** @file internal.c
* @author Tim Hughes <tim@twistedfury.com>
* @author Matthew Wampler-Doty
* @date 2015
@@ -38,12 +38,12 @@
#endif // WITH_CRYPTOPP
size_t ethash_get_datasize(const uint32_t block_number) {
- assert(block_number / EPOCH_LENGTH < 500);
+ assert(block_number / EPOCH_LENGTH < 2048);
return dag_sizes[block_number / EPOCH_LENGTH];
}
size_t ethash_get_cachesize(const uint32_t block_number) {
- assert(block_number / EPOCH_LENGTH < 500);
+ assert(block_number / EPOCH_LENGTH < 2048);
return cache_sizes[block_number / EPOCH_LENGTH];
}
@@ -55,7 +55,7 @@ void static ethash_compute_cache_nodes(
ethash_params const *params,
const uint8_t seed[32]) {
assert((params->cache_size % sizeof(node)) == 0);
- uint32_t const num_nodes = (uint32_t)(params->cache_size / sizeof(node));
+ uint32_t const num_nodes = (uint32_t) (params->cache_size / sizeof(node));
SHA3_512(nodes[0].bytes, seed, 32);
@@ -68,10 +68,9 @@ void static ethash_compute_cache_nodes(
uint32_t const idx = nodes[i].words[0] % num_nodes;
node data;
data = nodes[(num_nodes - 1 + i) % num_nodes];
- for (unsigned w = 0; w != NODE_WORDS; ++w)
- {
- data.words[w] ^= nodes[idx].words[w];
- }
+ for (unsigned w = 0; w != NODE_WORDS; ++w) {
+ data.words[w] ^= nodes[idx].words[w];
+ }
SHA3_512(nodes[i].bytes, data.bytes, sizeof(data));
}
}
@@ -86,7 +85,7 @@ void static ethash_compute_cache_nodes(
}
void ethash_mkcache(
- ethash_cache *cache,
+ ethash_cache *cache,
ethash_params const *params,
const uint8_t seed[32]) {
node *nodes = (node *) cache->mem;
@@ -99,13 +98,13 @@ void ethash_calculate_dag_item(
const struct ethash_params *params,
const struct ethash_cache *cache) {
- uint32_t num_parent_nodes = (uint32_t)(params->cache_size / sizeof(node));
+ uint32_t num_parent_nodes = (uint32_t) (params->cache_size / sizeof(node));
node const *cache_nodes = (node const *) cache->mem;
node const *init = &cache_nodes[node_index % num_parent_nodes];
- memcpy(ret, init, sizeof(node));
- ret->words[0] ^= node_index;
- SHA3_512(ret->bytes, ret->bytes, sizeof(node));
+ memcpy(ret, init, sizeof(node));
+ ret->words[0] ^= node_index;
+ SHA3_512(ret->bytes, ret->bytes, sizeof(node));
#if defined(_M_X64) && ENABLE_SSE
__m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME);
@@ -115,12 +114,11 @@ void ethash_calculate_dag_item(
__m128i xmm3 = ret->xmm[3];
#endif
- for (unsigned i = 0; i != DAG_PARENTS; ++i)
- {
- uint32_t parent_index = ((node_index ^ i)*FNV_PRIME ^ ret->words[i % NODE_WORDS]) % num_parent_nodes;
+ for (unsigned i = 0; i != DATASET_PARENTS; ++i) {
+ uint32_t parent_index = ((node_index ^ i) * FNV_PRIME ^ ret->words[i % NODE_WORDS]) % num_parent_nodes;
node const *parent = &cache_nodes[parent_index];
- #if defined(_M_X64) && ENABLE_SSE
+#if defined(_M_X64) && ENABLE_SSE
{
xmm0 = _mm_mullo_epi32(xmm0, fnv_prime);
xmm1 = _mm_mullo_epi32(xmm1, fnv_prime);
@@ -143,10 +141,10 @@ void ethash_calculate_dag_item(
ret->words[w] = fnv_hash(ret->words[w], parent->words[w]);
}
}
- #endif
+#endif
}
- SHA3_512(ret->bytes, ret->bytes, sizeof(node));
+ SHA3_512(ret->bytes, ret->bytes, sizeof(node));
}
void ethash_compute_full_data(
@@ -164,7 +162,7 @@ void ethash_compute_full_data(
}
static void ethash_hash(
- ethash_return_value * ret,
+ ethash_return_value *ret,
node const *full_nodes,
ethash_cache const *cache,
ethash_params const *params,
@@ -174,7 +172,7 @@ static void ethash_hash(
assert((params->full_size % MIX_WORDS) == 0);
// pack hash and nonce together into first 40 bytes of s_mix
- assert(sizeof(node)*8 == 512);
+ assert(sizeof(node) * 8 == 512);
node s_mix[MIX_NODES + 1];
memcpy(s_mix[0].bytes, header_hash, 32);
@@ -193,23 +191,21 @@ static void ethash_hash(
}
#endif
- node* const mix = s_mix + 1;
+ node *const mix = s_mix + 1;
for (unsigned w = 0; w != MIX_WORDS; ++w) {
mix->words[w] = s_mix[0].words[w % NODE_WORDS];
}
unsigned const
page_size = sizeof(uint32_t) * MIX_WORDS,
- num_full_pages = (unsigned)(params->full_size / page_size);
+ num_full_pages = (unsigned) (params->full_size / page_size);
- for (unsigned i = 0; i != ACCESSES; ++i)
- {
- uint32_t const index = ((s_mix->words[0] ^ i)*FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages;
+ for (unsigned i = 0; i != ACCESSES; ++i) {
+ uint32_t const index = ((s_mix->words[0] ^ i) * FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages;
- for (unsigned n = 0; n != MIX_NODES; ++n)
- {
- const node * dag_node = &full_nodes[MIX_NODES * index + n];
+ for (unsigned n = 0; n != MIX_NODES; ++n) {
+ const node *dag_node = &full_nodes[MIX_NODES * index + n];
if (!full_nodes) {
node tmp_node;
@@ -217,7 +213,7 @@ static void ethash_hash(
dag_node = &tmp_node;
}
- #if defined(_M_X64) && ENABLE_SSE
+#if defined(_M_X64) && ENABLE_SSE
{
__m128i fnv_prime = _mm_set1_epi32(FNV_PRIME);
__m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]);
@@ -235,20 +231,19 @@ static void ethash_hash(
mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]);
}
}
- #endif
+#endif
}
}
- // compress mix
- for (unsigned w = 0; w != MIX_WORDS; w += 4)
- {
- uint32_t reduction = mix->words[w+0];
- reduction = reduction*FNV_PRIME ^ mix->words[w+1];
- reduction = reduction*FNV_PRIME ^ mix->words[w+2];
- reduction = reduction*FNV_PRIME ^ mix->words[w+3];
- mix->words[w/4] = reduction;
- }
+ // compress mix
+ for (unsigned w = 0; w != MIX_WORDS; w += 4) {
+ uint32_t reduction = mix->words[w + 0];
+ reduction = reduction * FNV_PRIME ^ mix->words[w + 1];
+ reduction = reduction * FNV_PRIME ^ mix->words[w + 2];
+ reduction = reduction * FNV_PRIME ^ mix->words[w + 3];
+ mix->words[w / 4] = reduction;
+ }
#if BYTE_ORDER != LITTLE_ENDIAN
for (unsigned w = 0; w != MIX_WORDS/4; ++w) {
@@ -258,7 +253,7 @@ static void ethash_hash(
memcpy(ret->mix_hash, mix->bytes, 32);
// final Keccak hash
- SHA3_256(ret->result, s_mix->bytes, 64+32); // Keccak-256(s + compressed_mix)
+ SHA3_256(ret->result, s_mix->bytes, 64 + 32); // Keccak-256(s + compressed_mix)
}
void ethash_quick_hash(
@@ -267,7 +262,7 @@ void ethash_quick_hash(
const uint64_t nonce,
const uint8_t mix_hash[32]) {
- uint8_t buf[64+32];
+ uint8_t buf[64 + 32];
memcpy(buf, header_hash, 32);
#if BYTE_ORDER != LITTLE_ENDIAN
nonce = fix_endian64(nonce);
@@ -275,7 +270,14 @@ void ethash_quick_hash(
memcpy(&(buf[32]), &nonce, 8);
SHA3_512(buf, buf, 40);
memcpy(&(buf[64]), mix_hash, 32);
- SHA3_256(return_hash, buf, 64+32);
+ SHA3_256(return_hash, buf, 64 + 32);
+}
+
+void ethash_get_seedhash(uint8_t seedhash[32], const uint32_t block_number) {
+ memset(seedhash, 0, 32);
+ const uint32_t epochs = block_number / EPOCH_LENGTH;
+ for (uint32_t i = 0; i < epochs; ++i)
+ SHA3_256(seedhash, seedhash, 32);
}
int ethash_quick_check_difficulty(
@@ -289,10 +291,10 @@ int ethash_quick_check_difficulty(
return ethash_check_difficulty(return_hash, difficulty);
}
-void ethash_full(ethash_return_value * ret, void const *full_mem, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) {
+void ethash_full(ethash_return_value *ret, void const *full_mem, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) {
ethash_hash(ret, (node const *) full_mem, NULL, params, previous_hash, nonce);
}
-void ethash_light(ethash_return_value * ret, ethash_cache const *cache, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) {
+void ethash_light(ethash_return_value *ret, ethash_cache const *cache, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) {
ethash_hash(ret, NULL, cache, params, previous_hash, nonce);
-}
+} \ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h
index bcbacdaa4..ddd06e8f4 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/internal.h
@@ -3,7 +3,7 @@
#include "endian.h"
#include "ethash.h"
-#define ENABLE_SSE 1
+#define ENABLE_SSE 0
#if defined(_M_X64) && ENABLE_SSE
#include <smmintrin.h>
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
index 9454ce04a..6cbbcad8f 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp
@@ -1,18 +1,18 @@
/*
- This file is part of cpp-ethereum.
+ This file is part of ethash.
- cpp-ethereum is free software: you can redistribute it and/or modify
+ ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- cpp-ethereum is distributed in the hope that it will be useful,
+ ethash 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 General Public License for more details.
You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+ along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file sha3.cpp
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h
index 2f59076f6..ba8957815 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/util.h
@@ -1,18 +1,18 @@
/*
- This file is part of cpp-ethereum.
+ This file is part of ethash.
- cpp-ethereum is free software: you can redistribute it and/or modify
+ ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- cpp-ethereum is distributed in the hope that it will be useful,
+ ethash 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 General Public License for more details.
You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+ along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
* @author Tim Hughes <tim@twistedfury.com>
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c b/Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c
index f7d8be156..359735998 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/python/core.c
@@ -1,64 +1,305 @@
#include <Python.h>
#include <alloca.h>
#include <stdint.h>
+#include <stdlib.h>
+#include <time.h>
#include "../libethash/ethash.h"
-static PyObject*
-get_cache_size(PyObject* self, PyObject* args)
-{
+#define MIX_WORDS (MIX_BYTES/4)
+
+static PyObject *
+get_cache_size(PyObject *self, PyObject *args) {
unsigned long block_number;
if (!PyArg_ParseTuple(args, "k", &block_number))
- return 0;
+ return 0;
+ if (block_number >= EPOCH_LENGTH * 2048) {
+ char error_message[1024];
+ sprintf(error_message, "Block number must be less than %i (was %lu)", EPOCH_LENGTH * 2048, block_number);
+
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
return Py_BuildValue("i", ethash_get_cachesize(block_number));
}
-static PyObject*
-get_full_size(PyObject* self, PyObject* args)
-{
+static PyObject *
+get_full_size(PyObject *self, PyObject *args) {
unsigned long block_number;
if (!PyArg_ParseTuple(args, "k", &block_number))
- return 0;
+ return 0;
+ if (block_number >= EPOCH_LENGTH * 2048) {
+ char error_message[1024];
+ sprintf(error_message, "Block number must be less than %i (was %lu)", EPOCH_LENGTH * 2048, block_number);
+
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
return Py_BuildValue("i", ethash_get_datasize(block_number));
}
-static PyObject*
-mkcache(PyObject* self, PyObject* args)
-{
- char * seed;
+static PyObject *
+mkcache_bytes(PyObject *self, PyObject *args) {
+ char *seed;
unsigned long cache_size;
int seed_len;
if (!PyArg_ParseTuple(args, "ks#", &cache_size, &seed, &seed_len))
- return 0;
+ return 0;
+
+ if (seed_len != 32) {
+ char error_message[1024];
+ sprintf(error_message, "Seed must be 32 bytes long (was %i)", seed_len);
- if (seed_len != 32)
- {
- PyErr_SetString(PyExc_ValueError,
- "Seed must be 32 bytes long");
- return 0;
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
}
- printf("cache size: %lu\n", cache_size);
ethash_params params;
params.cache_size = (size_t) cache_size;
ethash_cache cache;
- cache.mem = alloca(cache_size);
+ cache.mem = malloc(cache_size);
ethash_mkcache(&cache, &params, (uint8_t *) seed);
- return PyString_FromStringAndSize(cache.mem, cache_size);
+ PyObject * val = Py_BuildValue("s#", cache.mem, cache_size);
+ free(cache.mem);
+ return val;
+}
+
+
+static PyObject *
+calc_dataset_bytes(PyObject *self, PyObject *args) {
+ char *cache_bytes;
+ unsigned long full_size;
+ int cache_size;
+
+ if (!PyArg_ParseTuple(args, "ks#", &full_size, &cache_bytes, &cache_size))
+ return 0;
+
+ if (full_size % MIX_WORDS != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %lu)", MIX_WORDS, full_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (cache_size % HASH_BYTES != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of the cache must be a multiple of %i bytes (was %i)", HASH_BYTES, cache_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ ethash_params params;
+ params.cache_size = (size_t) cache_size;
+ params.full_size = (size_t) full_size;
+ ethash_cache cache;
+ cache.mem = (void *) cache_bytes;
+ void *mem = malloc(params.full_size);
+ ethash_compute_full_data(mem, &params, &cache);
+ PyObject * val = Py_BuildValue("s#", (char *) mem, full_size);
+ free(mem);
+ return val;
+}
+
+// hashimoto_light(full_size, cache, header, nonce)
+static PyObject *
+hashimoto_light(PyObject *self, PyObject *args) {
+ char *cache_bytes, *header;
+ unsigned long full_size;
+ unsigned long long nonce;
+ int cache_size, header_size;
+
+ if (!PyArg_ParseTuple(args, "ks#s#K", &full_size, &cache_bytes, &cache_size, &header, &header_size, &nonce))
+ return 0;
+
+ if (full_size % MIX_WORDS != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %lu)", MIX_WORDS, full_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (cache_size % HASH_BYTES != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of the cache must be a multiple of %i bytes (was %i)", HASH_BYTES, cache_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (header_size != 32) {
+ char error_message[1024];
+ sprintf(error_message, "Seed must be 32 bytes long (was %i)", header_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+
+ ethash_return_value out;
+ ethash_params params;
+ params.cache_size = (size_t) cache_size;
+ params.full_size = (size_t) full_size;
+ ethash_cache cache;
+ cache.mem = (void *) cache_bytes;
+ ethash_light(&out, &cache, &params, (uint8_t *) header, nonce);
+ return Py_BuildValue("{s:s#,s:s#}",
+ "mix digest", out.mix_hash, 32,
+ "result", out.result, 32);
+}
+
+// hashimoto_full(dataset, header, nonce)
+static PyObject *
+hashimoto_full(PyObject *self, PyObject *args) {
+ char *full_bytes, *header;
+ unsigned long long nonce;
+ int full_size, header_size;
+
+ if (!PyArg_ParseTuple(args, "s#s#K", &full_bytes, &full_size, &header, &header_size, &nonce))
+ return 0;
+
+ if (full_size % MIX_WORDS != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %i)", MIX_WORDS, full_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (header_size != 32) {
+ char error_message[1024];
+ sprintf(error_message, "Header must be 32 bytes long (was %i)", header_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+
+ ethash_return_value out;
+ ethash_params params;
+ params.full_size = (size_t) full_size;
+ ethash_full(&out, (void *) full_bytes, &params, (uint8_t *) header, nonce);
+ return Py_BuildValue("{s:s#, s:s#}",
+ "mix digest", out.mix_hash, 32,
+ "result", out.result, 32);
}
+// mine(dataset_bytes, header, difficulty_bytes)
+static PyObject *
+mine(PyObject *self, PyObject *args) {
+ char *full_bytes, *header, *difficulty;
+ srand(time(0));
+ uint64_t nonce = ((uint64_t) rand()) << 32 | rand();
+ int full_size, header_size, difficulty_size;
+
+ if (!PyArg_ParseTuple(args, "s#s#s#", &full_bytes, &full_size, &header, &header_size, &difficulty, &difficulty_size))
+ return 0;
+
+ if (full_size % MIX_WORDS != 0) {
+ char error_message[1024];
+ sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %i)", MIX_WORDS, full_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (header_size != 32) {
+ char error_message[1024];
+ sprintf(error_message, "Header must be 32 bytes long (was %i)", header_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ if (difficulty_size != 32) {
+ char error_message[1024];
+ sprintf(error_message, "Difficulty must be an array of 32 bytes (only had %i)", difficulty_size);
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+
+ ethash_return_value out;
+ ethash_params params;
+ params.full_size = (size_t) full_size;
+
+ // TODO: Multi threading?
+ do {
+ ethash_full(&out, (void *) full_bytes, &params, (const uint8_t *) header, nonce++);
+ // TODO: disagrees with the spec https://github.com/ethereum/wiki/wiki/Ethash#mining
+ } while (!ethash_check_difficulty(out.result, (const uint8_t *) difficulty));
+
+ return Py_BuildValue("{s:s#, s:s#, s:K}",
+ "mix digest", out.mix_hash, 32,
+ "result", out.result, 32,
+ "nonce", nonce);
+}
+
+//get_seedhash(block_number)
+static PyObject *
+get_seedhash(PyObject *self, PyObject *args) {
+ unsigned long block_number;
+ if (!PyArg_ParseTuple(args, "k", &block_number))
+ return 0;
+ if (block_number >= EPOCH_LENGTH * 2048) {
+ char error_message[1024];
+ sprintf(error_message, "Block number must be less than %i (was %lu)", EPOCH_LENGTH * 2048, block_number);
+
+ PyErr_SetString(PyExc_ValueError, error_message);
+ return 0;
+ }
+ uint8_t seedhash[32];
+ ethash_get_seedhash(seedhash, block_number);
+ return Py_BuildValue("s#", (char *) seedhash, 32);
+}
-static PyMethodDef CoreMethods[] =
-{
- {"get_cache_size", get_cache_size, METH_VARARGS, "Get the cache size for a given block number"},
- {"get_full_size", get_full_size, METH_VARARGS, "Get the full size for a given block number"},
- {"mkcache", mkcache, METH_VARARGS, "Makes the cache for given parameters and seed hash"},
- {NULL, NULL, 0, NULL}
-};
+static PyMethodDef PyethashMethods[] =
+ {
+ {"get_cache_size", get_cache_size, METH_VARARGS,
+ "get_cache_size(block_number)\n\n"
+ "Get the cache size for a given block number\n"
+ "\nExample:\n"
+ ">>> get_cache_size(0)\n"
+ "1048384"},
+ {"get_full_size", get_full_size, METH_VARARGS,
+ "get_full_size(block_number)\n\n"
+ "Get the full size for a given block number\n"
+ "\nExample:\n"
+ ">>> get_full_size(0)\n"
+ "1073739904"
+ },
+ {"get_seedhash", get_seedhash, METH_VARARGS,
+ "get_seedhash(block_number)\n\n"
+ "Gets the seedhash for a block."},
+ {"mkcache_bytes", mkcache_bytes, METH_VARARGS,
+ "mkcache_bytes(size, header)\n\n"
+ "Makes a byte array for the cache for given cache size and seed hash\n"
+ "\nExample:\n"
+ ">>> pyethash.mkcache_bytes( 1024, \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\").encode('hex')"
+ "\"2da2b506f21070e1143d908e867962486d6b0a02e31d468fd5e3a7143aafa76a14201f63374314e2a6aaf84ad2eb57105dea3378378965a1b3873453bb2b78f9a8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995c259440b89fa3481c2c33171477c305c8e1e421f8d8f6d59585449d0034f3e421808d8da6bbd0b6378f567647cc6c4ba6c434592b198ad444e7284905b7c6adaf70bf43ec2daa7bd5e8951aa609ab472c124cf9eba3d38cff5091dc3f58409edcc386c743c3bd66f92408796ee1e82dd149eaefbf52b00ce33014a6eb3e50625413b072a58bc01da28262f42cbe4f87d4abc2bf287d15618405a1fe4e386fcdafbb171064bd99901d8f81dd6789396ce5e364ac944bbbd75a7827291c70b42d26385910cd53ca535ab29433dd5c5714d26e0dce95514c5ef866329c12e958097e84462197c2b32087849dab33e88b11da61d52f9dbc0b92cc61f742c07dbbf751c49d7678624ee60dfbe62e5e8c47a03d8247643f3d16ad8c8e663953bcda1f59d7e2d4a9bf0768e789432212621967a8f41121ad1df6ae1fa78782530695414c6213942865b2730375019105cae91a4c17a558d4b63059661d9f108362143107babe0b848de412e4da59168cce82bfbff3c99e022dd6ac1e559db991f2e3f7bb910cefd173e65ed00a8d5d416534e2c8416ff23977dbf3eb7180b75c71580d08ce95efeb9b0afe904ea12285a392aff0c8561ff79fca67f694a62b9e52377485c57cc3598d84cac0a9d27960de0cc31ff9bbfe455acaa62c8aa5d2cce96f345da9afe843d258a99c4eaf3650fc62efd81c7b81cd0d534d2d71eeda7a6e315d540b4473c80f8730037dc2ae3e47b986240cfc65ccc565f0d8cde0bc68a57e39a271dda57440b3598bee19f799611d25731a96b5dbbbefdff6f4f656161462633030d62560ea4e9c161cf78fc96a2ca5aaa32453a6c5dea206f766244e8c9d9a8dc61185ce37f1fc804459c5f07434f8ecb34141b8dcae7eae704c950b55556c5f40140c3714b45eddb02637513268778cbf937a33e4e33183685f9deb31ef54e90161e76d969587dd782eaa94e289420e7c2ee908517f5893a26fdb5873d68f92d118d4bcf98d7a4916794d6ab290045e30f9ea00ca547c584b8482b0331ba1539a0f2714fddc3a0b06b0cfbb6a607b8339c39bcfd6640b1f653e9d70ef6c985b\""},
+ {"calc_dataset_bytes", calc_dataset_bytes, METH_VARARGS,
+ "calc_dataset_bytes(full_size, cache_bytes)\n\n"
+ "Makes a byte array for the dataset for a given size given cache bytes"},
+ {"hashimoto_light", hashimoto_light, METH_VARARGS,
+ "hashimoto_light(full_size, cache_bytes, header, nonce)\n\n"
+ "Runs the hashimoto hashing function just using cache bytes. Takes an int (full_size), byte array (cache_bytes), another byte array (header), and an int (nonce). Returns an object containing the mix digest, and hash result."},
+ {"hashimoto_full", hashimoto_full, METH_VARARGS,
+ "hashimoto_full(dataset_bytes, header, nonce)\n\n"
+ "Runs the hashimoto hashing function using the dataset bytes. Useful for testing. Returns an object containing the mix digest (byte array), and hash result (another byte array)."},
+ {"mine", mine, METH_VARARGS,
+ "mine(dataset_bytes, header, difficulty_bytes)\n\n"
+ "Mine for an adequate header. Returns an object containing the mix digest (byte array), hash result (another byte array) and nonce (an int)."},
+ {NULL, NULL, 0, NULL}
+ };
PyMODINIT_FUNC
-initcore(void)
-{
- (void) Py_InitModule("core", CoreMethods);
+initpyethash(void) {
+ PyObject *module = Py_InitModule("pyethash", PyethashMethods);
+ // Following Spec: https://github.com/ethereum/wiki/wiki/Ethash#definitions
+ PyModule_AddIntConstant(module, "REVISION", (long) REVISION);
+ PyModule_AddIntConstant(module, "DATASET_BYTES_INIT", (long) DATASET_BYTES_INIT);
+ PyModule_AddIntConstant(module, "DATASET_BYTES_GROWTH", (long) DATASET_BYTES_GROWTH);
+ PyModule_AddIntConstant(module, "CACHE_BYTES_INIT", (long) CACHE_BYTES_INIT);
+ PyModule_AddIntConstant(module, "CACHE_BYTES_GROWTH", (long) CACHE_BYTES_GROWTH);
+ PyModule_AddIntConstant(module, "EPOCH_LENGTH", (long) EPOCH_LENGTH);
+ PyModule_AddIntConstant(module, "MIX_BYTES", (long) MIX_BYTES);
+ PyModule_AddIntConstant(module, "HASH_BYTES", (long) HASH_BYTES);
+ PyModule_AddIntConstant(module, "DATASET_PARENTS", (long) DATASET_PARENTS);
+ PyModule_AddIntConstant(module, "CACHE_ROUNDS", (long) CACHE_ROUNDS);
+ PyModule_AddIntConstant(module, "ACCESSES", (long) ACCESSES);
}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp b/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
index 336713cb7..21cb251fc 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.cpp
@@ -4,7 +4,9 @@
#include <libethash/internal.h>
#ifdef WITH_CRYPTOPP
+
#include <libethash/sha3_cryptopp.h>
+
#else
#include <libethash/sha3.h>
#endif // WITH_CRYPTOPP
@@ -28,7 +30,7 @@ BOOST_AUTO_TEST_CASE(fnv_hash_check) {
uint32_t x = 1235U;
const uint32_t
y = 9999999U,
- expected = (FNV_PRIME * x) ^ y;
+ expected = (FNV_PRIME * x) ^y;
x = fnv_hash(x, y);
@@ -65,43 +67,50 @@ BOOST_AUTO_TEST_CASE(SHA512_check) {
BOOST_AUTO_TEST_CASE(ethash_params_init_genesis_check) {
ethash_params params;
ethash_params_init(&params, 0);
- BOOST_REQUIRE_MESSAGE(params.full_size < DAGSIZE_BYTES_INIT,
+ BOOST_REQUIRE_MESSAGE(params.full_size < DATASET_BYTES_INIT,
"\nfull size: " << params.full_size << "\n"
- << "should be less than or equal to: " << DAGSIZE_BYTES_INIT << "\n");
- BOOST_REQUIRE_MESSAGE(params.full_size + 20*MIX_BYTES >= DAGSIZE_BYTES_INIT,
- "\nfull size + 20*MIX_BYTES: " << params.full_size + 20*MIX_BYTES << "\n"
- << "should be greater than or equal to: " << DAGSIZE_BYTES_INIT << "\n");
- BOOST_REQUIRE_MESSAGE(params.cache_size < DAGSIZE_BYTES_INIT / 32,
+ << "should be less than or equal to: " << DATASET_BYTES_INIT << "\n");
+ BOOST_REQUIRE_MESSAGE(params.full_size + 20 * MIX_BYTES >= DATASET_BYTES_INIT,
+ "\nfull size + 20*MIX_BYTES: " << params.full_size + 20 * MIX_BYTES << "\n"
+ << "should be greater than or equal to: " << DATASET_BYTES_INIT << "\n");
+ BOOST_REQUIRE_MESSAGE(params.cache_size < DATASET_BYTES_INIT / 32,
"\ncache size: " << params.cache_size << "\n"
- << "should be less than or equal to: " << DAGSIZE_BYTES_INIT / 32 << "\n");
+ << "should be less than or equal to: " << DATASET_BYTES_INIT / 32 << "\n");
}
BOOST_AUTO_TEST_CASE(ethash_params_init_genesis_calcifide_check) {
ethash_params params;
ethash_params_init(&params, 0);
const uint32_t expected_full_size = 1073739904;
- const uint32_t expected_cache_size = 1048384;
- BOOST_REQUIRE_MESSAGE(params.full_size == expected_full_size,
+ const uint32_t expected_cache_size = 16776896;
+ BOOST_REQUIRE_MESSAGE(params.full_size == expected_full_size,
"\nexpected: " << expected_cache_size << "\n"
<< "actual: " << params.full_size << "\n");
- BOOST_REQUIRE_MESSAGE(params.cache_size == expected_cache_size,
+ BOOST_REQUIRE_MESSAGE(params.cache_size == expected_cache_size,
"\nexpected: " << expected_cache_size << "\n"
<< "actual: " << params.cache_size << "\n");
}
BOOST_AUTO_TEST_CASE(light_and_full_client_checks) {
ethash_params params;
- uint8_t seed[32], hash[32];
+ uint8_t seed[32], hash[32], difficulty[32];
ethash_return_value light_out, full_out;
memcpy(seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
+
+ // Set the difficulty
+ difficulty[0] = 197;
+ difficulty[1] = 90;
+ for (int i = 2; i < 32; i++)
+ difficulty[i] = (uint8_t) 255;
+
ethash_params_init(&params, 0);
params.cache_size = 1024;
params.full_size = 1024 * 32;
ethash_cache cache;
cache.mem = alloca(params.cache_size);
ethash_mkcache(&cache, &params, seed);
- node * full_mem = (node *) alloca(params.full_size);
+ node *full_mem = (node *) alloca(params.full_size);
ethash_compute_full_data(full_mem, &params, &cache);
{
@@ -115,7 +124,6 @@ BOOST_AUTO_TEST_CASE(light_and_full_client_checks) {
}
-
{
node node;
ethash_calculate_dag_item(&node, 0, &params, &cache);
@@ -128,7 +136,7 @@ BOOST_AUTO_TEST_CASE(light_and_full_client_checks) {
}
{
- for (int i = 0 ; i < params.full_size / sizeof(node) ; ++i ) {
+ for (int i = 0; i < params.full_size / sizeof(node); ++i) {
for (uint32_t j = 0; j < 32; ++j) {
node expected_node;
ethash_calculate_dag_item(&expected_node, j, &params, &cache);
@@ -187,6 +195,12 @@ BOOST_AUTO_TEST_CASE(light_and_full_client_checks) {
BOOST_REQUIRE_MESSAGE(full_mix_hash_string == light_mix_hash_string,
"\nlight mix hash: " << light_mix_hash_string.c_str() << "\n"
<< "full mix hash: " << full_mix_hash_string.c_str() << "\n");
+ BOOST_REQUIRE_MESSAGE(ethash_check_difficulty(full_out.result, difficulty),
+ "ethash_check_difficulty failed"
+ );
+ BOOST_REQUIRE_MESSAGE(ethash_quick_check_difficulty(hash, 5U, full_out.mix_hash, difficulty),
+ "ethash_quick_check_difficulty failed"
+ );
}
}
@@ -199,14 +213,14 @@ BOOST_AUTO_TEST_CASE(ethash_check_difficulty_check) {
memcpy(target, "22222222222222222222222222222222", 32);
BOOST_REQUIRE_MESSAGE(
ethash_check_difficulty(hash, target),
- "\nexpected \"" << hash << "\" to have less difficulty than \"" << target << "\"\n");
+ "\nexpected \"" << std::string((char *) hash, 32).c_str() << "\" to have the same or less difficulty than \"" << std::string((char *) target, 32).c_str() << "\"\n");
BOOST_REQUIRE_MESSAGE(
- !ethash_check_difficulty(hash, hash),
- "\nexpected \"" << hash << "\" to have the same difficulty as \"" << hash << "\"\n");
+ ethash_check_difficulty(hash, hash),
+ "\nexpected \"" << hash << "\" to have the same or less difficulty than \"" << hash << "\"\n");
memcpy(target, "11111111111111111111111111111112", 32);
BOOST_REQUIRE_MESSAGE(
ethash_check_difficulty(hash, target),
- "\nexpected \"" << hash << "\" to have less difficulty than \"" << target << "\"\n");
+ "\nexpected \"" << hash << "\" to have the same or less difficulty than \"" << target << "\"\n");
memcpy(target, "11111111111111111111111111111110", 32);
BOOST_REQUIRE_MESSAGE(
!ethash_check_difficulty(hash, target),
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go b/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go
new file mode 100644
index 000000000..67ca51702
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/ethash_test.go
@@ -0,0 +1,82 @@
+package ethashTest
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/hex"
+ "log"
+ "math/big"
+ "testing"
+
+ "github.com/ethereum/ethash"
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/ethdb"
+)
+
+func TestEthash(t *testing.T) {
+ seedHash := make([]byte, 32)
+ _, err := rand.Read(seedHash)
+ if err != nil {
+ panic(err)
+ }
+
+ db, err := ethdb.NewMemDatabase()
+ if err != nil {
+ panic(err)
+ }
+
+ blockProcessor, err := core.NewCanonical(5, db)
+ if err != nil {
+ panic(err)
+ }
+
+ log.Println("Block Number: ", blockProcessor.ChainManager().CurrentBlock().Number())
+
+ e := ethash.New(blockProcessor.ChainManager())
+
+ miningHash := make([]byte, 32)
+ if _, err := rand.Read(miningHash); err != nil {
+ panic(err)
+ }
+ diff := big.NewInt(10000)
+ log.Println("difficulty", diff)
+
+ nonce := uint64(0)
+
+ ghash_full := e.FullHash(nonce, miningHash)
+ log.Printf("ethash full (on nonce): %x %x\n", ghash_full, nonce)
+
+ ghash_light := e.LightHash(nonce, miningHash)
+ log.Printf("ethash light (on nonce): %x %x\n", ghash_light, nonce)
+
+ if bytes.Compare(ghash_full, ghash_light) != 0 {
+ t.Errorf("full: %x, light: %x", ghash_full, ghash_light)
+ }
+}
+
+func TestGetSeedHash(t *testing.T) {
+ seed0, err := ethash.GetSeedHash(0)
+ if err != nil {
+ t.Errorf("Failed to get seedHash for block 0: %v", err)
+ }
+ if bytes.Compare(seed0, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) != 0 {
+ log.Printf("seedHash for block 0 should be 0s, was: %v\n", seed0)
+ }
+ seed1, err := ethash.GetSeedHash(30000)
+ if err != nil {
+ t.Error(err)
+ }
+
+ // From python:
+ // > from pyethash import get_seedhash
+ // > get_seedhash(30000)
+ expectedSeed1, err := hex.DecodeString("290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")
+ if err != nil {
+ t.Error(err)
+ }
+
+ if bytes.Compare(seed1, expectedSeed1) != 0 {
+ log.Printf("seedHash for block 1 should be: %v,\nactual value: %v\n", expectedSeed1, seed1)
+ }
+
+}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/test.sh
new file mode 100644
index 000000000..c6224858e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/go/test.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Strict mode
+set -e
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ]; do
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+ SOURCE="$(readlink "$SOURCE")"
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
+done
+TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+
+export GOPATH=${HOME}/.go
+export PATH=$PATH:$GOPATH/bin
+echo "# getting go dependencies (can take some time)..."
+cd ${TEST_DIR}/../.. && go get
+cd ${GOPATH}/src/github.com/ethereum/go-ethereum
+git checkout poc-9
+cd ${TEST_DIR} && go test
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/requirements.txt b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/requirements.txt
index 1f38dc3c7..378263c62 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/requirements.txt
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/requirements.txt
@@ -1,2 +1,3 @@
pyethereum==0.7.522
nose==1.3.4
+pysha3==0.3 \ No newline at end of file
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
index 4a547d157..95cea0215 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
@@ -14,6 +14,6 @@ TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
[ -d $TEST_DIR/python-virtual-env ] || virtualenv --system-site-packages $TEST_DIR/python-virtual-env
source $TEST_DIR/python-virtual-env/bin/activate
pip install -r $TEST_DIR/requirements.txt > /dev/null
-pip install -e $TEST_DIR/../.. > /dev/null
+pip install --upgrade --no-deps --force-reinstall -e $TEST_DIR/../..
cd $TEST_DIR
-nosetests --with-doctest -v
+nosetests --with-doctest -v --nocapture
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test_pyethash.py b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test_pyethash.py
index ca9321e92..7eb1b60c7 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test_pyethash.py
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test_pyethash.py
@@ -4,42 +4,102 @@ from random import randint
def test_get_cache_size_not_None():
for _ in range(100):
block_num = randint(0,12456789)
- out = pyethash.core.get_cache_size(block_num)
+ out = pyethash.get_cache_size(block_num)
assert out != None
def test_get_full_size_not_None():
for _ in range(100):
block_num = randint(0,12456789)
- out = pyethash.core.get_full_size(block_num)
+ out = pyethash.get_full_size(block_num)
assert out != None
def test_get_cache_size_based_on_EPOCH():
for _ in range(100):
block_num = randint(0,12456789)
- out1 = pyethash.core.get_cache_size(block_num)
- out2 = pyethash.core.get_cache_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
+ out1 = pyethash.get_cache_size(block_num)
+ out2 = pyethash.get_cache_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
assert out1 == out2
def test_get_full_size_based_on_EPOCH():
for _ in range(100):
block_num = randint(0,12456789)
- out1 = pyethash.core.get_full_size(block_num)
- out2 = pyethash.core.get_full_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
+ out1 = pyethash.get_full_size(block_num)
+ out2 = pyethash.get_full_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
assert out1 == out2
-#def test_get_params_based_on_EPOCH():
-# block_num = 123456
-# out1 = pyethash.core.get_params(block_num)
-# out2 = pyethash.core.get_params((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
-# assert out1["DAG Size"] == out2["DAG Size"]
-# assert out1["Cache Size"] == out2["Cache Size"]
-#
-#def test_get_params_returns_different_values_based_on_different_block_input():
-# out1 = pyethash.core.get_params(123456)
-# out2 = pyethash.core.get_params(12345)
-# assert out1["DAG Size"] != out2["DAG Size"]
-# assert out1["Cache Size"] != out2["Cache Size"]
-#
-#def test_get_cache_smoke_test():
-# params = pyethash.core.get_params(123456)
-# assert pyethash.core.mkcache(params, "~~~~") != None
+# See light_and_full_client_checks in test.cpp
+def test_mkcache_is_as_expected():
+ actual = pyethash.mkcache_bytes(
+ 1024,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~").encode('hex')
+ expected = "2da2b506f21070e1143d908e867962486d6b0a02e31d468fd5e3a7143aafa76a14201f63374314e2a6aaf84ad2eb57105dea3378378965a1b3873453bb2b78f9a8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995c259440b89fa3481c2c33171477c305c8e1e421f8d8f6d59585449d0034f3e421808d8da6bbd0b6378f567647cc6c4ba6c434592b198ad444e7284905b7c6adaf70bf43ec2daa7bd5e8951aa609ab472c124cf9eba3d38cff5091dc3f58409edcc386c743c3bd66f92408796ee1e82dd149eaefbf52b00ce33014a6eb3e50625413b072a58bc01da28262f42cbe4f87d4abc2bf287d15618405a1fe4e386fcdafbb171064bd99901d8f81dd6789396ce5e364ac944bbbd75a7827291c70b42d26385910cd53ca535ab29433dd5c5714d26e0dce95514c5ef866329c12e958097e84462197c2b32087849dab33e88b11da61d52f9dbc0b92cc61f742c07dbbf751c49d7678624ee60dfbe62e5e8c47a03d8247643f3d16ad8c8e663953bcda1f59d7e2d4a9bf0768e789432212621967a8f41121ad1df6ae1fa78782530695414c6213942865b2730375019105cae91a4c17a558d4b63059661d9f108362143107babe0b848de412e4da59168cce82bfbff3c99e022dd6ac1e559db991f2e3f7bb910cefd173e65ed00a8d5d416534e2c8416ff23977dbf3eb7180b75c71580d08ce95efeb9b0afe904ea12285a392aff0c8561ff79fca67f694a62b9e52377485c57cc3598d84cac0a9d27960de0cc31ff9bbfe455acaa62c8aa5d2cce96f345da9afe843d258a99c4eaf3650fc62efd81c7b81cd0d534d2d71eeda7a6e315d540b4473c80f8730037dc2ae3e47b986240cfc65ccc565f0d8cde0bc68a57e39a271dda57440b3598bee19f799611d25731a96b5dbbbefdff6f4f656161462633030d62560ea4e9c161cf78fc96a2ca5aaa32453a6c5dea206f766244e8c9d9a8dc61185ce37f1fc804459c5f07434f8ecb34141b8dcae7eae704c950b55556c5f40140c3714b45eddb02637513268778cbf937a33e4e33183685f9deb31ef54e90161e76d969587dd782eaa94e289420e7c2ee908517f5893a26fdb5873d68f92d118d4bcf98d7a4916794d6ab290045e30f9ea00ca547c584b8482b0331ba1539a0f2714fddc3a0b06b0cfbb6a607b8339c39bcfd6640b1f653e9d70ef6c985b"
+ assert actual == expected
+
+def test_calc_dataset_is_not_None():
+ cache = pyethash.mkcache_bytes(
+ 1024,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
+ assert pyethash.calc_dataset_bytes(1024 * 32, cache) != None
+
+def test_light_and_full_agree():
+ cache = pyethash.mkcache_bytes(
+ 1024,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
+ full_size = 1024 * 32
+ header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ light_result = pyethash.hashimoto_light(full_size, cache, header, 0)
+ dataset = pyethash.calc_dataset_bytes(full_size, cache)
+ full_result = pyethash.hashimoto_full(dataset, header, 0)
+ assert light_result["mix digest"] != None
+ assert len(light_result["mix digest"]) == 32
+ assert light_result["mix digest"] == full_result["mix digest"]
+ assert light_result["result"] != None
+ assert len(light_result["result"]) == 32
+ assert light_result["result"] == full_result["result"]
+
+def int_to_bytes(i):
+ b = []
+ for _ in range(32):
+ b.append(chr(i & 0xff))
+ i >>= 8
+ b.reverse()
+ return "".join(b)
+
+def test_mining_basic():
+ easy_difficulty = int_to_bytes(2**256 - 1)
+ assert easy_difficulty.encode('hex') == 'f' * 64
+ cache = pyethash.mkcache_bytes(
+ 1024,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
+ full_size = 1024 * 32
+ header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ dataset = pyethash.calc_dataset_bytes(full_size, cache)
+ # Check type of outputs
+ assert type(pyethash.mine(dataset,header,easy_difficulty)) == dict
+ assert type(pyethash.mine(dataset,header,easy_difficulty)["nonce"]) == long
+ assert type(pyethash.mine(dataset,header,easy_difficulty)["mix digest"]) == str
+ assert type(pyethash.mine(dataset,header,easy_difficulty)["result"]) == str
+
+def test_mining_doesnt_always_return_the_same_value():
+ easy_difficulty1 = int_to_bytes(int(2**256 * 0.999))
+ # 1 in 1000 difficulty
+ easy_difficulty2 = int_to_bytes(int(2**256 * 0.001))
+ assert easy_difficulty1 != easy_difficulty2
+ cache = pyethash.mkcache_bytes(
+ 1024,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
+ full_size = 1024 * 32
+ header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ dataset = pyethash.calc_dataset_bytes(full_size, cache)
+ # Check type of outputs
+ assert pyethash.mine(dataset, header, easy_difficulty1)['nonce'] != pyethash.mine(dataset, header, easy_difficulty2)['nonce']
+
+def test_get_seedhash():
+ assert pyethash.get_seedhash(0).encode('hex') == '0' * 64
+ import hashlib, sha3
+ expected = pyethash.get_seedhash(0)
+ #print "checking seed hashes:",
+ for i in range(0, 30000*2048, 30000):
+ #print i // 30000,
+ assert pyethash.get_seedhash(i) == expected
+ expected = hashlib.sha3_256(expected).digest()
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
index eb38f6dfc..fd3508609 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
@@ -14,7 +14,12 @@ TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo -e "\n################# Testing JS ##################"
# TODO: Use mocha and real testing tools instead of rolling our own
cd $TEST_DIR/../js
-node test.js
+if [ -x "$(which nodejs)" ] ; then
+ nodejs test.js
+fi
+if [ -x "$(which node)" ] ; then
+ node test.js
+fi
echo -e "\n################# Testing C ##################"
$TEST_DIR/c/test.sh
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
index bc515b583..53746627a 100644
--- a/cmd/ethereum/main.go
+++ b/cmd/ethereum/main.go
@@ -200,7 +200,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
}
am := eth.AccountManager()
// Attempt to unlock the account
- err := am.Unlock(ethutil.Hex2Bytes(split[0]), split[1])
+ err := am.Unlock(ethutil.FromHex(split[0]), split[1])
if err != nil {
utils.Fatalf("Unlock account failed '%v'", err)
}
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index e929d1de8..bbcde4c56 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
+ "github.com/ethereum/go-ethereum/vm"
)
type Log struct {
@@ -135,7 +136,8 @@ func RunVmTest(r io.Reader) (failed int) {
rexp := helper.FromHex(test.Out)
if bytes.Compare(rexp, ret) != 0 {
- fmt.Printf("%s's return failed. Expected %x, got %x\n", name, rexp, ret)
+ fmt.Printf("FAIL: %s's return failed. Expected %x, got %x\n", name, rexp, ret)
+ failed = 1
}
for addr, account := range test.Post {
@@ -146,7 +148,8 @@ func RunVmTest(r io.Reader) (failed int) {
if len(test.Exec) == 0 {
if obj.Balance().Cmp(ethutil.Big(account.Balance)) != 0 {
- fmt.Printf("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance()))
+ fmt.Printf("FAIL: %s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance()))
+ failed = 1
}
}
@@ -155,18 +158,21 @@ func RunVmTest(r io.Reader) (failed int) {
vexp := helper.FromHex(value)
if bytes.Compare(v, vexp) != 0 {
- fmt.Printf("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address()[0:4], addr, vexp, v, ethutil.BigD(vexp), ethutil.BigD(v))
+ fmt.Printf("FAIL: %s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address()[0:4], addr, vexp, v, ethutil.BigD(vexp), ethutil.BigD(v))
+ failed = 1
}
}
}
if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
- fmt.Printf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
+ fmt.Printf("FAIL: %s's : Post state root error. Expected %s, got %x\n", name, test.PostStateRoot, statedb.Root())
+ failed = 1
}
if len(test.Logs) > 0 {
if len(test.Logs) != len(logs) {
- fmt.Printf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
+ fmt.Printf("FAIL: log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
+ failed = 1
} else {
/*
fmt.Println("A", test.Logs)
@@ -189,6 +195,7 @@ func RunVmTest(r io.Reader) (failed int) {
func main() {
helper.Logger.SetLogLevel(5)
+ vm.Debug = true
if len(os.Args) > 1 {
os.Exit(RunVmTest(strings.NewReader(os.Args[1])))
diff --git a/cmd/mist/assets/ext/ethereum.js b/cmd/mist/assets/ext/ethereum.js
new file mode 160000
+Subproject d5093606945fd871bc62f5d6adade3a903b0533
diff --git a/cmd/mist/assets/ext/ethereum.js/.bowerrc b/cmd/mist/assets/ext/ethereum.js/.bowerrc
deleted file mode 100644
index c3a8813e8..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.bowerrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "directory": "example/js/",
- "cwd": "./",
- "analytics": false
-} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/.editorconfig b/cmd/mist/assets/ext/ethereum.js/.editorconfig
deleted file mode 100644
index 60a2751d3..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.editorconfig
+++ /dev/null
@@ -1,12 +0,0 @@
-root = true
-
-[*]
-indent_style = space
-indent_size = 4
-end_of_line = lf
-charset = utf-8
-trim_trailing_whitespace = true
-insert_final_newline = true
-
-[*.md]
-trim_trailing_whitespace = false \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/.gitignore b/cmd/mist/assets/ext/ethereum.js/.gitignore
deleted file mode 100644
index 399b6dc88..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.gitignore
+++ /dev/null
@@ -1,18 +0,0 @@
-# See http://help.github.com/ignore-files/ for more about ignoring files.
-#
-# If you find yourself ignoring temporary files generated by your text editor
-# or operating system, you probably want to add a global ignore instead:
-# git config --global core.excludesfile ~/.gitignore_global
-
-*.swp
-/tmp
-*/**/*un~
-*un~
-.DS_Store
-*/**/.DS_Store
-ethereum/ethereum
-ethereal/ethereal
-example/js
-node_modules
-bower_components
-npm-debug.log
diff --git a/cmd/mist/assets/ext/ethereum.js/.jshintrc b/cmd/mist/assets/ext/ethereum.js/.jshintrc
deleted file mode 100644
index c0ec5f89d..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.jshintrc
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "predef": [
- "console",
- "require",
- "equal",
- "test",
- "testBoth",
- "testWithDefault",
- "raises",
- "deepEqual",
- "start",
- "stop",
- "ok",
- "strictEqual",
- "module",
- "expect",
- "reject",
- "impl"
- ],
-
- "esnext": true,
- "proto": true,
- "node" : true,
- "browser" : true,
- "browserify" : true,
-
- "boss" : true,
- "curly": false,
- "debug": true,
- "devel": true,
- "eqeqeq": true,
- "evil": true,
- "forin": false,
- "immed": false,
- "laxbreak": false,
- "newcap": true,
- "noarg": true,
- "noempty": false,
- "nonew": false,
- "nomen": false,
- "onevar": false,
- "plusplus": false,
- "regexp": false,
- "undef": true,
- "sub": true,
- "strict": false,
- "white": false,
- "shadow": true,
- "eqnull": true
-} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/.npmignore b/cmd/mist/assets/ext/ethereum.js/.npmignore
deleted file mode 100644
index 5bbffe4fd..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.npmignore
+++ /dev/null
@@ -1,9 +0,0 @@
-example/js
-node_modules
-test
-.gitignore
-.editorconfig
-.travis.yml
-.npmignore
-component.json
-testling.html \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/.travis.yml b/cmd/mist/assets/ext/ethereum.js/.travis.yml
deleted file mode 100644
index 83b21d840..000000000
--- a/cmd/mist/assets/ext/ethereum.js/.travis.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-language: node_js
-node_js:
- - "0.11"
- - "0.10"
-before_script:
- - npm install
- - npm install jshint
-script:
- - "jshint *.js lib"
-after_script:
- - npm run-script build
- - npm test
-
diff --git a/cmd/mist/assets/ext/ethereum.js/LICENSE b/cmd/mist/assets/ext/ethereum.js/LICENSE
deleted file mode 100644
index 0f187b873..000000000
--- a/cmd/mist/assets/ext/ethereum.js/LICENSE
+++ /dev/null
@@ -1,14 +0,0 @@
-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/>. \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/README.md b/cmd/mist/assets/ext/ethereum.js/README.md
deleted file mode 100644
index 02988fe73..000000000
--- a/cmd/mist/assets/ext/ethereum.js/README.md
+++ /dev/null
@@ -1,96 +0,0 @@
-# Ethereum JavaScript API
-
-This is the Ethereum compatible [JavaScript API](https://github.com/ethereum/wiki/wiki/JavaScript-API)
-which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js
-
-[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url]
-
-<!-- [![browser support](https://ci.testling.com/ethereum/ethereum.js.png)](https://ci.testling.com/ethereum/ethereum.js) -->
-
-## Installation
-
-### Node.js
-
- npm install ethereum.js
-
-### For browser
-Bower
-
- bower install ethereum.js
-
-Component
-
- component install ethereum/ethereum.js
-
-* Include `ethereum.min.js` in your html file.
-* Include [bignumber.js](https://github.com/MikeMcl/bignumber.js/)
-
-## Usage
-Require the library:
-
- var web3 = require('web3');
-
-Set a provider (QtProvider, WebSocketProvider, HttpRpcProvider)
-
- var web3.setProvider(new web3.providers.WebSocketProvider('ws://localhost:40404/eth'));
-
-There you go, now you can use it:
-
-```
-var coinbase = web3.eth.coinbase;
-var balance = web3.eth.balanceAt(coinbase);
-```
-
-
-For another example see `example/index.html`.
-
-## Contribute!
-
-### Requirements
-
-* Node.js
-* npm
-* gulp (build)
-* mocha (tests)
-
-```bash
-sudo apt-get update
-sudo apt-get install nodejs
-sudo apt-get install npm
-sudo apt-get install nodejs-legacy
-```
-
-### Building (gulp)
-
-```bash
-npm run-script build
-```
-
-
-### Testing (mocha)
-
-```bash
-npm test
-```
-
-**Please note this repo is in it's early stage.**
-
-If you'd like to run a WebSocket ethereum node check out
-[go-ethereum](https://github.com/ethereum/go-ethereum).
-
-To install ethereum and spawn a node:
-
-```
-go get github.com/ethereum/go-ethereum/ethereum
-ethereum -ws -loglevel=4
-```
-
-[npm-image]: https://badge.fury.io/js/ethereum.js.png
-[npm-url]: https://npmjs.org/package/ethereum.js
-[travis-image]: https://travis-ci.org/ethereum/ethereum.js.svg
-[travis-url]: https://travis-ci.org/ethereum/ethereum.js
-[dep-image]: https://david-dm.org/ethereum/ethereum.js.svg
-[dep-url]: https://david-dm.org/ethereum/ethereum.js
-[dep-dev-image]: https://david-dm.org/ethereum/ethereum.js/dev-status.svg
-[dep-dev-url]: https://david-dm.org/ethereum/ethereum.js#info=devDependencies
-
diff --git a/cmd/mist/assets/ext/ethereum.js/bower.json b/cmd/mist/assets/ext/ethereum.js/bower.json
deleted file mode 100644
index 168f1b39a..000000000
--- a/cmd/mist/assets/ext/ethereum.js/bower.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "name": "ethereum.js",
- "namespace": "ethereum",
- "version": "0.0.13",
- "description": "Ethereum Compatible JavaScript API",
- "main": ["./dist/ethereum.js", "./dist/ethereum.min.js"],
- "dependencies": {
- "bignumber.js": ">=2.0.0"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ethereum/ethereum.js.git"
- },
- "homepage": "https://github.com/ethereum/ethereum.js",
- "bugs": {
- "url": "https://github.com/ethereum/ethereum.js/issues"
- },
- "keywords": [
- "ethereum",
- "javascript",
- "API"
- ],
- "authors": [
- {
- "name": "Marek Kotewicz",
- "email": "marek@ethdev.com",
- "homepage": "https://github.com/debris"
- },
- {
- "name": "Marian Oancea",
- "email": "marian@ethdev.com",
- "homepage": "https://github.com/cubedro"
- }
- ],
- "license": "LGPL-3.0",
- "ignore": [
- "example",
- "lib",
- "node_modules",
- "package.json",
- ".bowerrc",
- ".editorconfig",
- ".gitignore",
- ".jshintrc",
- ".npmignore",
- ".travis.yml",
- "gulpfile.js",
- "index.js",
- "**/*.txt"
- ]
-}
diff --git a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js b/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
deleted file mode 100644
index c0b37641c..000000000
--- a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
+++ /dev/null
@@ -1,2799 +0,0 @@
-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){
-/*
- 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
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * 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');
-
-/**
- * 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 === 'string') // only string itself that is dynamic; stringX is static length.
- 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 === 'string')
- 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 === 'string') // only string itself that is dynamic; stringX is static length.
- 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('string')(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;
-};
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- formatInput: formatInput,
- formatOutput: formatOutput
-};
-
-},{"../utils/config":4,"../utils/utils":5,"./formatters":2,"./types":3}],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 formatters.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-if ("build" !== 'build') {/*
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-*/}
-
-var utils = require('../utils/utils');
-var c = require('../utils/config');
-
-/**
- * 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;
-};
-
-/**
- * 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 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":4,"../utils/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 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('hash'), format: f.formatInputInt },
- { type: prefixedType('string'), 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('hash'), format: f.formatOutputHash },
- { type: prefixedType('string'), 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":2}],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 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
-if ("build" !== 'build') {/*
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-*/}
-
-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'
-};
-
-
-},{}],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
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/**
- * Utils
- *
- * @module utils
- */
-
-/**
- * Utility functions
- *
- * @class [utils] utils
- * @constructor
- */
-
-if ("build" !== 'build') {/*
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-*/}
-
-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'
-};
-
-
-/** 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(' ', '') : "";
-};
-
-/**
- * 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';
- });
-};
-
-/**
- * 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:5 */
-
- if(typeof val === 'boolean')
- return val;
-
- if(isBigNumber(val))
- return fromDecimal(val);
-
- if(typeof val === 'object')
- return fromAscii(JSON.stringify(val));
-
- if(isString(val) && val.indexOf('0x') === 0)
- return val;
- // if its a negative number, pass it through fromDecimal
- if(isString(val) && val.indexOf('-0x') === 0)
- return fromDecimal(val);
-
- if(isString(val) && !isFinite(val))
- return fromAscii(val);
-
- if(isFinite(val))
- return fromDecimal(val);
-
- return 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) {
- number = number || 0;
- if (isBigNumber(number))
- return number;
-
- return (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0))
- ? new BigNumber(number.replace('0x',''), 16)
- : 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 has proper length
- *
- * @method isAddress
- * @param {String} address the given HEX adress
- * @return {Boolean}
-*/
-var isAddress = function(address) {
- if (!isString(address)) {
- return false;
- }
-
- return ((address.indexOf('0x') === 0 && address.length === 42) ||
- (address.indexOf('0x') === -1 && address.length === 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';
-};
-
-module.exports = {
- findIndex: findIndex,
- toHex: toHex,
- toDecimal: toDecimal,
- fromDecimal: fromDecimal,
- toAscii: toAscii,
- fromAscii: fromAscii,
- extractDisplayName: extractDisplayName,
- extractTypeName: extractTypeName,
- filterFunctions: filterFunctions,
- filterEvents: filterEvents,
- toWei: toWei,
- fromWei: fromWei,
- toBigNumber: toBigNumber,
- toTwosComplement: toTwosComplement,
- isBigNumber: isBigNumber,
- isAddress: isAddress,
- isFunction: isFunction,
- isString: isString
-};
-
-
-},{}],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 web3.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var net = require('./web3/net');
-var eth = require('./web3/eth');
-var db = require('./web3/db');
-var shh = require('./web3/shh');
-var watches = require('./web3/watches');
-var filter = require('./web3/filter');
-var utils = require('./utils/utils');
-var formatters = require('./solidity/formatters');
-var requestManager = require('./web3/requestmanager');
-var c = require('./utils/config');
-
-/// @returns an array of objects describing web3 api methods
-var web3Methods = function () {
- return [
- { name: 'sha3', call: 'web3_sha3' }
- ];
-};
-
-/// creates methods in a given object based on method description on input
-/// setups api calls for these methods
-var setupMethods = function (obj, methods) {
- methods.forEach(function (method) {
- // allow for object methods 'myObject.method'
- var objectMethods = method.name.split('.'),
- callFunction = function () {
- /*jshint maxcomplexity:8 */
-
- var callback = null,
- args = Array.prototype.slice.call(arguments),
- call = typeof method.call === 'function' ? method.call(args) : method.call;
-
- // get the callback if one is available
- if(typeof args[args.length-1] === 'function'){
- callback = args[args.length-1];
- Array.prototype.pop.call(args);
- }
-
- // add the defaultBlock if not given
- if(method.addDefaultblock) {
- if(args.length !== method.addDefaultblock)
- Array.prototype.push.call(args, (isFinite(c.ETH_DEFAULTBLOCK) ? utils.fromDecimal(c.ETH_DEFAULTBLOCK) : c.ETH_DEFAULTBLOCK));
- else
- args[args.length-1] = isFinite(args[args.length-1]) ? utils.fromDecimal(args[args.length-1]) : args[args.length-1];
- }
-
- // show deprecated warning
- if(method.newMethod)
- console.warn('This method is deprecated please use web3.'+ method.newMethod +'() instead.');
-
- return web3.manager.send({
- method: call,
- params: args,
- outputFormatter: method.outputFormatter,
- inputFormatter: method.inputFormatter,
- addDefaultblock: method.addDefaultblock
- }, callback);
- };
-
- if(objectMethods.length > 1) {
- if(!obj[objectMethods[0]])
- obj[objectMethods[0]] = {};
-
- obj[objectMethods[0]][objectMethods[1]] = callFunction;
-
- } else {
-
- obj[objectMethods[0]] = callFunction;
- }
-
- });
-};
-
-/// creates properties in a given object based on properties description on input
-/// setups api calls for these properties
-var setupProperties = function (obj, properties) {
- properties.forEach(function (property) {
- var proto = {};
- proto.get = function () {
-
- // show deprecated warning
- if(property.newProperty)
- console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');
-
-
- return web3.manager.send({
- method: property.getter,
- outputFormatter: property.outputFormatter
- });
- };
-
- if (property.setter) {
- proto.set = function (val) {
-
- // show deprecated warning
- if(property.newProperty)
- console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');
-
- return web3.manager.send({
- method: property.setter,
- params: [val],
- inputFormatter: property.inputFormatter
- });
- };
- }
-
- proto.enumerable = !property.newProperty;
- Object.defineProperty(obj, property.name, proto);
-
- });
-};
-
-/*jshint maxparams:4 */
-var startPolling = function (method, id, callback, uninstall) {
- web3.manager.startPolling({
- method: method,
- params: [id]
- }, id, callback, uninstall);
-};
-/*jshint maxparams:3 */
-
-var stopPolling = function (id) {
- web3.manager.stopPolling(id);
-};
-
-var ethWatch = {
- startPolling: startPolling.bind(null, 'eth_getFilterChanges'),
- stopPolling: stopPolling
-};
-
-var shhWatch = {
- startPolling: startPolling.bind(null, 'shh_getFilterChanges'),
- stopPolling: stopPolling
-};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {
- manager: requestManager(),
- providers: {},
-
- setProvider: function (provider) {
- web3.manager.setProvider(provider);
- },
-
- /// Should be called to reset state of web3 object
- /// Resets everything except manager
- reset: function () {
- web3.manager.reset();
- },
-
- /// @returns hex string of the input
- toHex: utils.toHex,
-
- /// @returns ascii string representation of hex value prefixed with 0x
- toAscii: utils.toAscii,
-
- /// @returns hex representation (prefixed by 0x) of ascii string
- fromAscii: utils.fromAscii,
-
- /// @returns decimal representaton of hex value prefixed by 0x
- toDecimal: utils.toDecimal,
-
- /// @returns hex representation (prefixed by 0x) of decimal value
- fromDecimal: utils.fromDecimal,
-
- /// @returns a BigNumber object
- toBigNumber: utils.toBigNumber,
-
- toWei: utils.toWei,
- fromWei: utils.fromWei,
- isAddress: utils.isAddress,
-
- // provide network information
- net: {
- // peerCount:
- },
-
-
- /// eth object prototype
- eth: {
- // DEPRECATED
- contractFromAbi: function (abi) {
- console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');
-
- return function(addr) {
- // Default to address of Config. TODO: rremove prior to genesis.
- addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
- var ret = web3.eth.contract(addr, abi);
- ret.address = addr;
- return ret;
- };
- },
-
- /// @param filter may be a string, object or event
- /// @param eventParams is optional, this is an object with optional event eventParams params
- /// @param options is optional, this is an object with optional event options ('max'...)
- /*jshint maxparams:4 */
- filter: function (fil, eventParams, options) {
-
- // if its event, treat it differently
- if (fil._isEvent)
- return fil(eventParams, options);
-
- return filter(fil, ethWatch, formatters.outputLogFormatter);
- },
- // DEPRECATED
- watch: function (fil, eventParams, options) {
- console.warn('eth.watch() is deprecated please use eth.filter() instead.');
- return this.filter(fil, eventParams, options);
- }
- /*jshint maxparams:3 */
- },
-
- /// db object prototype
- db: {},
-
- /// shh object prototype
- shh: {
- /// @param filter may be a string, object or event
- filter: function (fil) {
- return filter(fil, shhWatch, formatters.outputPostFormatter);
- },
- // DEPRECATED
- watch: function (fil) {
- console.warn('shh.watch() is deprecated please use shh.filter() instead.');
- return this.filter(fil);
- }
- }
-};
-
-
-// ADD defaultblock
-Object.defineProperty(web3.eth, 'defaultBlock', {
- get: function () {
- return c.ETH_DEFAULTBLOCK;
- },
- set: function (val) {
- c.ETH_DEFAULTBLOCK = val;
- return c.ETH_DEFAULTBLOCK;
- }
-});
-
-
-/// setups all api methods
-setupMethods(web3, web3Methods());
-setupMethods(web3.net, net.methods);
-setupProperties(web3.net, net.properties);
-setupMethods(web3.eth, eth.methods);
-setupProperties(web3.eth, eth.properties);
-setupMethods(web3.db, db.methods());
-setupMethods(web3.shh, shh.methods());
-setupMethods(ethWatch, watches.eth());
-setupMethods(shhWatch, watches.shh());
-
-module.exports = web3;
-
-
-},{"./solidity/formatters":2,"./utils/config":4,"./utils/utils":5,"./web3/db":8,"./web3/eth":9,"./web3/filter":11,"./web3/net":15,"./web3/requestmanager":17,"./web3/shh":18,"./web3/watches":20}],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 contract.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('../web3');
-var abi = require('../solidity/abi');
-var utils = require('../utils/utils');
-var eventImpl = require('./event');
-var signature = require('./signature');
-
-var exportNatspecGlobals = function (vars) {
- // it's used byt natspec.js
- // TODO: figure out better way to solve this
- web3._currentContractAbi = vars.abi;
- web3._currentContractAddress = vars.address;
- web3._currentContractMethodName = vars.method;
- web3._currentContractMethodParams = vars.params;
-};
-
-var addFunctionRelatedPropertiesToContract = function (contract) {
-
- contract.call = function (options) {
- contract._isTransaction = false;
- contract._options = options;
- return contract;
- };
-
-
- contract.sendTransaction = function (options) {
- contract._isTransaction = true;
- contract._options = options;
- return contract;
- };
- // DEPRECATED
- contract.transact = function (options) {
-
- console.warn('myContract.transact() is deprecated please use myContract.sendTransaction() instead.');
-
- return contract.sendTransaction(options);
- };
-
- contract._options = {};
- ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {
- contract[p] = function (v) {
- contract._options[p] = v;
- return contract;
- };
- });
-
-};
-
-var addFunctionsToContract = function (contract, desc, address) {
- var inputParser = abi.inputParser(desc);
- var outputParser = abi.outputParser(desc);
-
- // create contract functions
- utils.filterFunctions(desc).forEach(function (method) {
-
- var displayName = utils.extractDisplayName(method.name);
- var typeName = utils.extractTypeName(method.name);
-
- var impl = function () {
- /*jshint maxcomplexity:7 */
- var params = Array.prototype.slice.call(arguments);
- var sign = signature.functionSignatureFromAscii(method.name);
- var parsed = inputParser[displayName][typeName].apply(null, params);
-
- var options = contract._options || {};
- options.to = address;
- options.data = sign + parsed;
-
- var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);
- var collapse = options.collapse !== false;
-
- // reset
- contract._options = {};
- contract._isTransaction = null;
-
- if (isTransaction) {
-
- exportNatspecGlobals({
- abi: desc,
- address: address,
- method: method.name,
- params: params
- });
-
- // transactions do not have any output, cause we do not know, when they will be processed
- web3.eth.sendTransaction(options);
- return;
- }
-
- var output = web3.eth.call(options);
- var ret = outputParser[displayName][typeName](output);
- if (collapse)
- {
- if (ret.length === 1)
- ret = ret[0];
- else if (ret.length === 0)
- ret = null;
- }
- return ret;
- };
-
- if (contract[displayName] === undefined) {
- contract[displayName] = impl;
- }
-
- contract[displayName][typeName] = impl;
- });
-};
-
-var addEventRelatedPropertiesToContract = function (contract, desc, address) {
- contract.address = address;
- contract._onWatchEventResult = function (data) {
- var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));
- var parser = eventImpl.outputParser(matchingEvent);
- return parser(data);
- };
-
- Object.defineProperty(contract, 'topic', {
- get: function() {
- return utils.filterEvents(desc).map(function (e) {
- return signature.eventSignatureFromAscii(e.name);
- });
- }
- });
-
-};
-
-var addEventsToContract = function (contract, desc, address) {
- // create contract events
- utils.filterEvents(desc).forEach(function (e) {
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- var sign = signature.eventSignatureFromAscii(e.name);
- var event = eventImpl.inputParser(address, sign, e);
- var o = event.apply(null, params);
- var outputFormatter = function (data) {
- var parser = eventImpl.outputParser(e);
- return parser(data);
- };
- return web3.eth.filter(o, undefined, undefined, outputFormatter);
- };
-
- // this property should be used by eth.filter to check if object is an event
- impl._isEvent = true;
-
- var displayName = utils.extractDisplayName(e.name);
- var typeName = utils.extractTypeName(e.name);
-
- if (contract[displayName] === undefined) {
- contract[displayName] = impl;
- }
-
- contract[displayName][typeName] = impl;
-
- });
-};
-
-
-/**
- * This method should be called when we want to call / transact some solidity method from javascript
- * it returns an object which has same methods available as solidity contract description
- * usage example:
- *
- * var abi = [{
- * name: 'myMethod',
- * inputs: [{ name: 'a', type: 'string' }],
- * outputs: [{name: 'd', type: 'string' }]
- * }]; // contract abi
- *
- * var MyContract = web3.eth.contract(abi); // creation of contract prototype
- *
- * var contractInstance = new MyContract('0x0123123121');
- *
- * contractInstance.myMethod('this is test string param for call'); // myMethod call (implicit, default)
- * contractInstance.call().myMethod('this is test string param for call'); // myMethod call (explicit)
- * contractInstance.sendTransaction().myMethod('this is test string param for transact'); // myMethod sendTransaction
- *
- * @param abi - abi json description of the contract, which is being created
- * @returns contract object
- */
-var contract = function (abi) {
-
- // return prototype
- if(abi instanceof Array && arguments.length === 1) {
- return Contract.bind(null, abi);
-
- // deprecated: auto initiate contract
- } else {
-
- console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');
-
- return new Contract(arguments[1], arguments[0]);
- }
-
-};
-
-function Contract(abi, address) {
-
- // workaround for invalid assumption that method.name is the full anonymous prototype of the method.
- // it's not. it's just the name. the rest of the code assumes it's actually the anonymous
- // prototype, so we make it so as a workaround.
- // TODO: we may not want to modify input params, maybe use copy instead?
- abi.forEach(function (method) {
- if (method.name.indexOf('(') === -1) {
- var displayName = method.name;
- var typeName = method.inputs.map(function(i){return i.type; }).join();
- method.name = displayName + '(' + typeName + ')';
- }
- });
-
- var result = {};
- addFunctionRelatedPropertiesToContract(result);
- addFunctionsToContract(result, abi, address);
- addEventRelatedPropertiesToContract(result, abi, address);
- addEventsToContract(result, abi, address);
-
- return result;
-}
-
-module.exports = contract;
-
-
-},{"../solidity/abi":1,"../utils/utils":5,"../web3":6,"./event":10,"./signature":19}],8:[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 db.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/// @returns an array of objects describing web3.db api methods
-var methods = function () {
- return [
- { name: 'put', call: 'db_put' },
- { name: 'get', call: 'db_get' },
- { name: 'putString', call: 'db_putString' },
- { name: 'getString', call: 'db_getString' }
- ];
-};
-
-module.exports = {
- methods: methods
-};
-
-},{}],9:[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 eth.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/**
- * Web3
- *
- * @module web3
- */
-
-/**
- * Eth methods and properties
- *
- * An example method object can look as follows:
- *
- * {
- * name: 'getBlock',
- * call: blockCall,
- * outputFormatter: formatters.outputBlockFormatter,
- * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter
- * utils.toHex, // formats paramter 1
- * function(param){ if(!param) return false; } // formats paramter 2
- * ]
- * },
- *
- * @class [web3] eth
- * @constructor
- */
-
-
-var formatters = require('./formatters');
-var utils = require('../utils/utils');
-
-
-var blockCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
-};
-
-var transactionFromBlockCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
-};
-
-var uncleCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
-};
-
-var getBlockTransactionCountCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
-};
-
-var uncleCountCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
-};
-
-/// @returns an array of objects describing web3.eth api methods
-var methods = [
- { name: 'getBalance', call: 'eth_getBalance', addDefaultblock: 2,
- outputFormatter: formatters.convertToBigNumber},
- { name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
- { name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3,
- inputFormatter: utils.toHex},
- { name: 'getData', call: 'eth_getData', addDefaultblock: 2},
- { name: 'getBlock', call: blockCall,
- outputFormatter: formatters.outputBlockFormatter,
- inputFormatter: [utils.toHex, function(param){ return (!param) ? false : true; }]},
- { name: 'getUncle', call: uncleCall,
- outputFormatter: formatters.outputBlockFormatter,
- inputFormatter: [utils.toHex, utils.toHex, function(param){ return (!param) ? false : true; }]},
- { name: 'getCompilers', call: 'eth_getCompilers' },
- { name: 'getBlockTransactionCount', call: getBlockTransactionCountCall,
- outputFormatter: utils.toDecimal,
- inputFormatter: utils.toHex },
- { name: 'getBlockUncleCount', call: uncleCountCall,
- outputFormatter: utils.toDecimal,
- inputFormatter: utils.toHex },
- { name: 'getTransaction', call: 'eth_getTransactionByHash',
- outputFormatter: formatters.outputTransactionFormatter },
- { name: 'getTransactionFromBlock', call: transactionFromBlockCall,
- outputFormatter: formatters.outputTransactionFormatter,
- inputFormatter: utils.toHex },
- { name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2,
- outputFormatter: utils.toDecimal},
- { name: 'sendTransaction', call: 'eth_sendTransaction',
- inputFormatter: formatters.inputTransactionFormatter },
- { name: 'call', call: 'eth_call', addDefaultblock: 2,
- inputFormatter: formatters.inputCallFormatter },
- { name: 'compile.solidity', call: 'eth_compileSolidity', inputFormatter: utils.toHex },
- { name: 'compile.lll', call: 'eth_compileLLL', inputFormatter: utils.toHex },
- { name: 'compile.serpent', call: 'eth_compileSerpent', inputFormatter: utils.toHex },
- { name: 'flush', call: 'eth_flush' },
-
- // deprecated methods
- { name: 'balanceAt', call: 'eth_balanceAt', newMethod: 'eth.getBalance' },
- { name: 'stateAt', call: 'eth_stateAt', newMethod: 'eth.getStorageAt' },
- { name: 'storageAt', call: 'eth_storageAt', newMethod: 'eth.getStorage' },
- { name: 'countAt', call: 'eth_countAt', newMethod: 'eth.getTransactionCount' },
- { name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
- { name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
- { name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
- { name: 'transaction', call: transactionFromBlockCall, newMethod: 'eth.getTransaction' },
- { name: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
- { name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
- { name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
- { name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
- { name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
- { name: 'transactionCount', call: getBlockTransactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
- { name: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
- { name: 'logs', call: 'eth_logs' }
-];
-
-/// @returns an array of objects describing web3.eth api properties
-var properties = [
- { name: 'coinbase', getter: 'eth_coinbase'},
- { name: 'mining', getter: 'eth_mining'},
- { name: 'gasPrice', getter: 'eth_gasPrice', outputFormatter: formatters.convertToBigNumber},
- { name: 'accounts', getter: 'eth_accounts' },
- { name: 'blockNumber', getter: 'eth_blockNumber', outputFormatter: utils.toDecimal},
-
- // deprecated properties
- { name: 'listening', getter: 'net_listening', setter: 'eth_setListening', newProperty: 'net.listening'},
- { name: 'peerCount', getter: 'net_peerCount', newProperty: 'net.peerCount'},
- { name: 'number', getter: 'eth_number', newProperty: 'eth.blockNumber'}
-];
-
-
-module.exports = {
- methods: methods,
- properties: properties
-};
-
-
-},{"../utils/utils":5,"./formatters":12}],10:[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 event.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var abi = require('../solidity/abi');
-var utils = require('../utils/utils');
-var signature = require('./signature');
-
-/// filter inputs array && returns only indexed (or not) inputs
-/// @param inputs array
-/// @param bool if result should be an array of indexed params on not
-/// @returns array of (not?) indexed params
-var filterInputs = function (inputs, indexed) {
- return inputs.filter(function (current) {
- return current.indexed === indexed;
- });
-};
-
-var inputWithName = function (inputs, name) {
- var index = utils.findIndex(inputs, function (input) {
- return input.name === name;
- });
-
- if (index === -1) {
- console.error('indexed param with name ' + name + ' not found');
- return undefined;
- }
- return inputs[index];
-};
-
-var indexedParamsToTopics = function (event, indexed) {
- // sort keys?
- return Object.keys(indexed).map(function (key) {
- var inputs = [inputWithName(filterInputs(event.inputs, true), key)];
-
- var value = indexed[key];
- if (value instanceof Array) {
- return value.map(function (v) {
- return abi.formatInput(inputs, [v]);
- });
- }
- return abi.formatInput(inputs, [value]);
- });
-};
-
-var inputParser = function (address, sign, event) {
-
- // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'
- return function (indexed, options) {
- var o = options || {};
- o.address = address;
- o.topic = [];
- o.topic.push(sign);
- if (indexed) {
- o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));
- }
- return o;
- };
-};
-
-var getArgumentsObject = function (inputs, indexed, notIndexed) {
- var indexedCopy = indexed.slice();
- var notIndexedCopy = notIndexed.slice();
- return inputs.reduce(function (acc, current) {
- var value;
- if (current.indexed)
- value = indexedCopy.splice(0, 1)[0];
- else
- value = notIndexedCopy.splice(0, 1)[0];
-
- acc[current.name] = value;
- return acc;
- }, {});
-};
-
-var outputParser = function (event) {
-
- return function (output) {
- var result = {
- event: utils.extractDisplayName(event.name),
- number: output.number,
- hash: output.hash,
- args: {}
- };
-
- output.topics = output.topic; // fallback for go-ethereum
- if (!output.topic) {
- return result;
- }
-
- var indexedOutputs = filterInputs(event.inputs, true);
- var indexedData = "0x" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join("");
- var indexedRes = abi.formatOutput(indexedOutputs, indexedData);
-
- var notIndexedOutputs = filterInputs(event.inputs, false);
- var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);
-
- result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);
-
- return result;
- };
-};
-
-var getMatchingEvent = function (events, payload) {
- for (var i = 0; i < events.length; i++) {
- var sign = signature.eventSignatureFromAscii(events[i].name);
- if (sign === payload.topic[0]) {
- return events[i];
- }
- }
- return undefined;
-};
-
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- getMatchingEvent: getMatchingEvent
-};
-
-
-},{"../solidity/abi":1,"../utils/utils":5,"./signature":19}],11:[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 filter.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var utils = require('../utils/utils');
-
-/// Should be called to check if filter implementation is valid
-/// @returns true if it is, otherwise false
-var implementationIsValid = function (i) {
- return !!i &&
- typeof i.newFilter === 'function' &&
- typeof i.getLogs === 'function' &&
- typeof i.uninstallFilter === 'function' &&
- typeof i.startPolling === 'function' &&
- typeof i.stopPolling === 'function';
-};
-
-/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
-/// @param should be string or object
-/// @returns options string or object
-var getOptions = function (options) {
- /*jshint maxcomplexity:5 */
-
- if (typeof options === 'string') {
- return options;
- }
-
- options = options || {};
-
- if (options.topic) {
- console.warn('"topic" is deprecated, is "topics" instead');
- options.topics = options.topic;
- }
-
- if (options.earliest) {
- console.warn('"earliest" is deprecated, is "fromBlock" instead');
- options.fromBlock = options.earliest;
- }
-
- if (options.latest) {
- console.warn('"latest" is deprecated, is "toBlock" instead');
- options.toBlock = options.latest;
- }
-
- if (options.skip) {
- console.warn('"skip" is deprecated, is "offset" instead');
- options.offset = options.skip;
- }
-
- if (options.max) {
- console.warn('"max" is deprecated, is "limit" instead');
- options.limit = options.max;
- }
-
- // make sure topics, get converted to hex
- if(options.topics instanceof Array) {
- options.topics = options.topics.map(function(topic){
- return utils.toHex(topic);
- });
- }
-
-
- // evaluate lazy properties
- return {
- fromBlock: utils.toHex(options.fromBlock),
- toBlock: utils.toHex(options.toBlock),
- limit: utils.toHex(options.limit),
- offset: utils.toHex(options.offset),
- to: options.to,
- address: options.address,
- topics: options.topics
- };
-};
-
-/// Should be used when we want to watch something
-/// it's using inner polling mechanism and is notified about changes
-/// @param options are filter options
-/// @param implementation, an abstract polling implementation
-/// @param formatter (optional), callback function which formats output before 'real' callback
-var filter = function(options, implementation, formatter) {
- if (!implementationIsValid(implementation)) {
- console.error('filter implemenation is invalid');
- return;
- }
-
- options = getOptions(options);
- var callbacks = [];
- var filterId = implementation.newFilter(options);
-
- // call the callbacks
- var onMessages = function (messages) {
- messages.forEach(function (message) {
- message = formatter ? formatter(message) : message;
- callbacks.forEach(function (callback) {
- callback(message);
- });
- });
- };
-
- implementation.startPolling(filterId, onMessages, implementation.uninstallFilter);
-
- var watch = function(callback) {
- callbacks.push(callback);
- };
-
- var stopWatching = function() {
- implementation.stopPolling(filterId);
- implementation.uninstallFilter(filterId);
- callbacks = [];
- };
-
- var get = function () {
- return implementation.getLogs(filterId);
- };
-
- return {
- watch: watch,
- stopWatching: stopWatching,
- get: get,
-
- // DEPRECATED methods
- changed: function(){
- console.warn('watch().changed() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- arrived: function(){
- console.warn('watch().arrived() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- happened: function(){
- console.warn('watch().happened() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- uninstall: function(){
- console.warn('watch().uninstall() is deprecated please use filter().stopWatching() instead.');
- return stopWatching.apply(this, arguments);
- },
- messages: function(){
- console.warn('watch().messages() is deprecated please use filter().get() instead.');
- return get.apply(this, arguments);
- },
- logs: function(){
- console.warn('watch().logs() is deprecated please use filter().get() instead.');
- return get.apply(this, arguments);
- }
- };
-};
-
-module.exports = filter;
-
-
-},{"../utils/utils":5}],12:[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>
- * Fabian Vogelsteller <fabian@ethdev.com>
- * @date 2015
- */
-
-var utils = require('../utils/utils');
-
-/**
- * Should the input to a big number
- *
- * @method convertToBigNumber
- * @param {String|Number|BigNumber}
- * @returns {BigNumber} object
- */
-var convertToBigNumber = function (value) {
- return utils.toBigNumber(value);
-};
-
-/**
- * Formats the input of a transaction and converts all values to HEX
- *
- * @method inputTransactionFormatter
- * @param {Object} transaction options
- * @returns object
-*/
-var inputTransactionFormatter = function (options){
-
- // make code -> data
- if (options.code) {
- options.data = options.code;
- delete options.code;
- }
-
- ['gasPrice', 'gas', 'value'].forEach(function(key){
- options[key] = utils.fromDecimal(options[key]);
- });
-
- return options;
-};
-
-/**
- * Formats the output of a transaction to its proper values
- *
- * @method outputTransactionFormatter
- * @param {Object} transaction
- * @returns {Object} transaction
-*/
-var outputTransactionFormatter = function (tx){
- tx.gas = utils.toDecimal(tx.gas);
- tx.gasPrice = utils.toBigNumber(tx.gasPrice);
- tx.value = utils.toBigNumber(tx.value);
- return tx;
-};
-
-/**
- * Formats the input of a call and converts all values to HEX
- *
- * @method inputCallFormatter
- * @param {Object} transaction options
- * @returns object
-*/
-var inputCallFormatter = function (options){
-
- // make code -> data
- if (options.code) {
- options.data = options.code;
- delete options.code;
- }
-
- return options;
-};
-
-
-/**
- * Formats the output of a block to its proper values
- *
- * @method outputBlockFormatter
- * @param {Object} block object
- * @returns {Object} block object
-*/
-var outputBlockFormatter = function(block){
-
- // transform to number
- block.gasLimit = utils.toDecimal(block.gasLimit);
- block.gasUsed = utils.toDecimal(block.gasUsed);
- block.size = utils.toDecimal(block.size);
- block.timestamp = utils.toDecimal(block.timestamp);
- block.number = utils.toDecimal(block.number);
-
- block.minGasPrice = utils.toBigNumber(block.minGasPrice);
- block.difficulty = utils.toBigNumber(block.difficulty);
- block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
-
- if(block.transactions instanceof Array) {
- block.transactions.forEach(function(item){
- if(!utils.isString(item))
- return outputTransactionFormatter(item);
- });
- }
-
- return block;
-};
-
-/**
- * Formats the output of a log
- *
- * @method outputLogFormatter
- * @param {Object} log object
- * @returns {Object} log
-*/
-var outputLogFormatter = function(log){
- log.number = utils.toDecimal(log.number);
- return log;
-};
-
-
-/**
- * Formats the input of a whisper post and converts all values to HEX
- *
- * @method inputPostFormatter
- * @param {Object} transaction object
- * @returns {Object}
-*/
-var inputPostFormatter = function(post){
-
- post.payload = utils.toHex(post.payload);
- post.ttl = utils.fromDecimal(post.ttl);
- post.workToProve = utils.fromDecimal(post.workToProve);
-
- if(!(post.topic instanceof Array))
- post.topic = [post.topic];
-
-
- // format the following options
- post.topic = post.topic.map(function(topic){
- return utils.fromAscii(topic);
- });
-
- return post;
-};
-
-/**
- * Formats the output of a received post message
- *
- * @method outputPostFormatter
- * @param {Object}
- * @returns {Object}
- */
-var outputPostFormatter = function(post){
-
- post.expiry = utils.toDecimal(post.expiry);
- post.sent = utils.toDecimal(post.sent);
- post.ttl = utils.toDecimal(post.ttl);
- post.payloadRaw = post.payload;
- post.payload = utils.toAscii(post.payload);
-
- if(post.payload.indexOf('{') === 0 || post.payload.indexOf('[') === 0) {
- try {
- post.payload = JSON.parse(post.payload);
- } catch (e) { }
- }
-
- // format the following options
- post.topic = post.topic.map(function(topic){
- return utils.toAscii(topic);
- });
-
- return post;
-};
-
-module.exports = {
- convertToBigNumber: convertToBigNumber,
- inputTransactionFormatter: inputTransactionFormatter,
- outputTransactionFormatter: outputTransactionFormatter,
- inputCallFormatter: inputCallFormatter,
- outputBlockFormatter: outputBlockFormatter,
- outputLogFormatter: outputLogFormatter,
- inputPostFormatter: inputPostFormatter,
- outputPostFormatter: outputPostFormatter
-};
-
-
-},{"../utils/utils":5}],13:[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 httpprovider.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-if ("build" !== 'build') {/*
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-*/}
-
-var HttpProvider = function (host) {
- this.name = 'HTTP';
- this.handlers = [];
- this.host = host || 'http://localhost:8080';
-};
-
-HttpProvider.prototype.send = function (payload, callback) {
- var request = new XMLHttpRequest();
- request.open('POST', this.host, false);
-
- // ASYNC
- if(typeof callback === 'function') {
- request.onreadystatechange = function() {
- if(request.readyState === 4) {
- var result = '';
- try {
- result = JSON.parse(request.responseText)
- } catch(error) {
- result = error;
- }
- callback(result, request.status);
- }
- };
-
- request.open('POST', this.host, true);
- request.send(JSON.stringify(payload));
-
- // SYNC
- } else {
- request.open('POST', this.host, false);
- request.send(JSON.stringify(payload));
-
- // check request.status
- if(request.status !== 200)
- return;
- return JSON.parse(request.responseText);
-
- }
-};
-
-module.exports = HttpProvider;
-
-
-},{}],14:[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 jsonrpc.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-var messageId = 1;
-
-/// Should be called to valid json create payload object
-/// @param method of jsonrpc call, required
-/// @param params, an array of method params, optional
-/// @returns valid jsonrpc payload object
-var toPayload = function (method, params) {
- if (!method)
- console.error('jsonrpc method should be specified!');
-
- return {
- jsonrpc: '2.0',
- method: method,
- params: params || [],
- id: messageId++
- };
-};
-
-/// Should be called to check if jsonrpc response is valid
-/// @returns true if response is valid, otherwise false
-var isValidResponse = function (response) {
- return !!response &&
- !response.error &&
- response.jsonrpc === '2.0' &&
- typeof response.id === 'number' &&
- response.result !== undefined; // only undefined is not valid json object
-};
-
-/// Should be called to create batch payload object
-/// @param messages, an array of objects with method (required) and params (optional) fields
-var toBatchPayload = function (messages) {
- return messages.map(function (message) {
- return toPayload(message.method, message.params);
- });
-};
-
-module.exports = {
- toPayload: toPayload,
- isValidResponse: isValidResponse,
- toBatchPayload: toBatchPayload
-};
-
-
-
-},{}],15:[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 eth.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-var utils = require('../utils/utils');
-
-/// @returns an array of objects describing web3.eth api methods
-var methods = [
- // { name: 'getBalance', call: 'eth_balanceAt', outputFormatter: formatters.convertToBigNumber},
-];
-
-/// @returns an array of objects describing web3.eth api properties
-var properties = [
- { name: 'listening', getter: 'net_listening'},
- { name: 'peerCount', getter: 'net_peerCount', outputFormatter: utils.toDecimal },
-];
-
-
-module.exports = {
- methods: methods,
- properties: properties
-};
-
-
-},{"../utils/utils":5}],16:[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 qtsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-var QtSyncProvider = function () {
-};
-
-QtSyncProvider.prototype.send = function (payload) {
- var result = navigator.qt.callMethod(JSON.stringify(payload));
- return JSON.parse(result);
-};
-
-module.exports = QtSyncProvider;
-
-
-},{}],17:[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 requestmanager.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var jsonrpc = require('./jsonrpc');
-var c = require('../utils/config');
-
-/**
- * It's responsible for passing messages to providers
- * It's also responsible for polling the ethereum node for incoming messages
- * Default poll timeout is 1 second
- */
-var requestManager = function() {
- var polls = [];
- var timeout = null;
- var provider;
-
- var send = function (data, callback) {
- /*jshint maxcomplexity: 7 */
-
- // FORMAT BASED ON ONE FORMATTER function
- if(typeof data.inputFormatter === 'function') {
- data.params = Array.prototype.map.call(data.params, function(item, index){
- // format everything besides the defaultblock, which is already formated
- return (!data.addDefaultblock || index+1 < data.addDefaultblock)
- ? data.inputFormatter(item)
- : item;
- });
-
- // FORMAT BASED ON the input FORMATTER ARRAY
- } else if(data.inputFormatter instanceof Array) {
- data.params = Array.prototype.map.call(data.inputFormatter, function(formatter, index){
- // format everything besides the defaultblock, which is already formated
- return (!data.addDefaultblock || index+1 < data.addDefaultblock)
- ? formatter(data.params[index])
- : data.params[index];
- });
- }
-
-
- var payload = jsonrpc.toPayload(data.method, data.params);
-
- if (!provider) {
- console.error('provider is not set');
- return null;
- }
-
- // HTTP ASYNC (only when callback is given, and it a HttpProvidor)
- if(typeof callback === 'function' && provider.name === 'HTTP'){
- provider.send(payload, function(result, status){
-
- if (!jsonrpc.isValidResponse(result)) {
- if(typeof result === 'object' && result.error && result.error.message) {
- console.error(result.error.message);
- callback(result.error);
- } else {
- callback(new Error({
- status: status,
- error: result,
- message: 'Bad Request'
- }));
- }
- return null;
- }
-
- // format the output
- callback(null, (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result);
- });
-
- // SYNC
- } else {
- var result = provider.send(payload);
-
- if (!jsonrpc.isValidResponse(result)) {
- console.log(result);
- if(typeof result === 'object' && result.error && result.error.message)
- console.error(result.error.message);
- return null;
- }
-
- // format the output
- return (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result;
- }
-
- };
-
- var setProvider = function (p) {
- provider = p;
- };
-
- /*jshint maxparams:4 */
- var startPolling = function (data, pollId, callback, uninstall) {
- polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
- };
- /*jshint maxparams:3 */
-
- var stopPolling = function (pollId) {
- for (var i = polls.length; i--;) {
- var poll = polls[i];
- if (poll.id === pollId) {
- polls.splice(i, 1);
- }
- }
- };
-
- var reset = function () {
- polls.forEach(function (poll) {
- poll.uninstall(poll.id);
- });
- polls = [];
-
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
- }
- poll();
- };
-
- var poll = function () {
- polls.forEach(function (data) {
- // send async
- send(data.data, function(result){
- if (!(result instanceof Array) || result.length === 0) {
- return;
- }
- data.callback(result);
- });
- });
- timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
- };
-
- poll();
-
- return {
- send: send,
- setProvider: setProvider,
- startPolling: startPolling,
- stopPolling: stopPolling,
- reset: reset
- };
-};
-
-module.exports = requestManager;
-
-
-},{"../utils/config":4,"./jsonrpc":14}],18:[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 shh.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-var formatters = require('./formatters');
-
-/// @returns an array of objects describing web3.shh api methods
-var methods = function () {
- return [
- { name: 'post', call: 'shh_post', inputFormatter: formatters.inputPostFormatter },
- { name: 'newIdentity', call: 'shh_newIdentity' },
- { name: 'hasIdentity', call: 'shh_hasIdentity' },
- { name: 'newGroup', call: 'shh_newGroup' },
- { name: 'addToGroup', call: 'shh_addToGroup' },
-
- // deprecated
- { name: 'haveIdentity', call: 'shh_haveIdentity', newMethod: 'shh.hasIdentity' },
- ];
-};
-
-module.exports = {
- methods: methods
-};
-
-
-},{"./formatters":12}],19:[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 signature.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-var web3 = require('../web3');
-var c = require('../utils/config');
-
-/// @param function name for which we want to get signature
-/// @returns signature of function with given name
-var functionSignatureFromAscii = function (name) {
- return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);
-};
-
-/// @param event name for which we want to get signature
-/// @returns signature of event with given name
-var eventSignatureFromAscii = function (name) {
- return web3.sha3(web3.fromAscii(name));
-};
-
-module.exports = {
- functionSignatureFromAscii: functionSignatureFromAscii,
- eventSignatureFromAscii: eventSignatureFromAscii
-};
-
-
-},{"../utils/config":4,"../web3":6}],20:[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 watches.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/// @returns an array of objects describing web3.eth.filter api methods
-var eth = function () {
- var newFilter = function (args) {
- return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';
- };
-
- return [
- { name: 'newFilter', call: newFilter },
- { name: 'uninstallFilter', call: 'eth_uninstallFilter' },
- { name: 'getLogs', call: 'eth_getFilterLogs' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh.watch api methods
-var shh = function () {
- return [
- { name: 'newFilter', call: 'shh_newFilter' },
- { name: 'uninstallFilter', call: 'shh_uninstallFilter' },
- { name: 'getLogs', call: 'shh_getMessages' }
- ];
-};
-
-module.exports = {
- eth: eth,
- shh: shh
-};
-
-
-},{}],"web3":[function(require,module,exports){
-var web3 = require('./lib/web3');
-web3.providers.HttpProvider = require('./lib/web3/httpprovider');
-web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
-web3.eth.contract = require('./lib/web3/contract');
-web3.abi = require('./lib/solidity/abi');
-
-module.exports = web3;
-
-},{"./lib/solidity/abi":1,"./lib/web3":6,"./lib/web3/contract":7,"./lib/web3/httpprovider":13,"./lib/web3/qtsync":16}]},{},["web3"])
-
-
-//# sourceMappingURL=ethereum.js.map
diff --git a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js.map b/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js.map
deleted file mode 100644
index e441da86c..000000000
--- a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js.map
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "version": 3,
- "sources": [
- "node_modules/browserify/node_modules/browser-pack/_prelude.js",
- "lib/abi.js",
- "lib/const.js",
- "lib/contract.js",
- "lib/event.js",
- "lib/filter.js",
- "lib/formatters.js",
- "lib/httpsync.js",
- "lib/jsonrpc.js",
- "lib/providermanager.js",
- "lib/qtsync.js",
- "lib/types.js",
- "lib/utils.js",
- "lib/web3.js",
- "index.js"
- ],
- "names": [],
- "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
- "file": "generated.js",
- "sourceRoot": "",
- "sourcesContent": [
- "(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})",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file abi.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); \nvar utils = require('./utils');\nvar types = require('./types');\nvar c = require('./const');\nvar f = require('./formatters');\n\nvar displayTypeError = function (type) {\n console.error('parser does not support type: ' + type);\n};\n\n/// This method should be called if we want to check if givent type is an array type\n/// @returns true if it is, otherwise false\nvar arrayType = function (type) {\n return type.slice(-2) === '[]';\n};\n\nvar dynamicTypeBytes = function (type, value) {\n // TODO: decide what to do with array of strings\n if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.\n return f.formatInputInt(value.length); \n return \"\";\n};\n\nvar inputTypes = types.inputTypes(); \n\n/// Formats input params to bytes\n/// @param abi contract method inputs\n/// @param array of params that will be formatted to bytes\n/// @returns bytes representation of input params\nvar formatInput = function (inputs, params) {\n var bytes = \"\";\n var padding = c.ETH_PADDING * 2;\n\n /// first we iterate in search for dynamic \n inputs.forEach(function (input, index) {\n bytes += dynamicTypeBytes(input.type, params[index]);\n });\n\n inputs.forEach(function (input, i) {\n var typeMatch = false;\n for (var j = 0; j < inputTypes.length && !typeMatch; j++) {\n typeMatch = inputTypes[j].type(inputs[i].type, params[i]);\n }\n if (!typeMatch) {\n displayTypeError(inputs[i].type);\n }\n\n var formatter = inputTypes[j - 1].format;\n var toAppend = \"\";\n\n if (arrayType(inputs[i].type))\n toAppend = params[i].reduce(function (acc, curr) {\n return acc + formatter(curr);\n }, \"\");\n else\n toAppend = formatter(params[i]);\n\n bytes += toAppend; \n });\n return bytes;\n};\n\nvar dynamicBytesLength = function (type) {\n if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.\n return c.ETH_PADDING * 2;\n return 0;\n};\n\nvar outputTypes = types.outputTypes(); \n\n/// Formats output bytes back to param list\n/// @param contract abi method outputs\n/// @param bytes representtion of output \n/// @returns array of output params \nvar formatOutput = function (outs, output) {\n \n output = output.slice(2);\n var result = [];\n var padding = c.ETH_PADDING * 2;\n\n var dynamicPartLength = outs.reduce(function (acc, curr) {\n return acc + dynamicBytesLength(curr.type);\n }, 0);\n \n var dynamicPart = output.slice(0, dynamicPartLength);\n output = output.slice(dynamicPartLength);\n\n outs.forEach(function (out, i) {\n var typeMatch = false;\n for (var j = 0; j < outputTypes.length && !typeMatch; j++) {\n typeMatch = outputTypes[j].type(outs[i].type);\n }\n\n if (!typeMatch) {\n displayTypeError(outs[i].type);\n }\n\n var formatter = outputTypes[j - 1].format;\n if (arrayType(outs[i].type)) {\n var size = f.formatOutputUInt(dynamicPart.slice(0, padding));\n dynamicPart = dynamicPart.slice(padding);\n var array = [];\n for (var k = 0; k < size; k++) {\n array.push(formatter(output.slice(0, padding))); \n output = output.slice(padding);\n }\n result.push(array);\n }\n else if (types.prefixedType('string')(outs[i].type)) {\n dynamicPart = dynamicPart.slice(padding); \n result.push(formatter(output.slice(0, padding)));\n output = output.slice(padding);\n } else {\n result.push(formatter(output.slice(0, padding)));\n output = output.slice(padding);\n }\n });\n\n return result;\n};\n\n/// @param json abi for contract\n/// @returns input parser object for given json abi\n/// TODO: refactor creating the parser, do not double logic from contract\nvar inputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n var displayName = utils.extractDisplayName(method.name); \n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n return formatInput(method.inputs, params);\n };\n \n if (parser[displayName] === undefined) {\n parser[displayName] = impl;\n }\n\n parser[displayName][typeName] = impl;\n });\n\n return parser;\n};\n\n/// @param json abi for contract\n/// @returns output parser for given json abi\nvar outputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name); \n var typeName = utils.extractTypeName(method.name);\n\n var impl = function (output) {\n return formatOutput(method.outputs, output);\n };\n\n if (parser[displayName] === undefined) {\n parser[displayName] = impl;\n }\n\n parser[displayName][typeName] = impl;\n });\n\n return parser;\n};\n\n/// @param function/event name for which we want to get signature\n/// @returns signature of function/event with given name\nvar signatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);\n};\n\nvar eventSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name));\n};\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n formatInput: formatInput,\n formatOutput: formatOutput,\n signatureFromAscii: signatureFromAscii,\n eventSignatureFromAscii: eventSignatureFromAscii\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file const.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2015\n */\n\n/// required to define ETH_BIGNUMBER_ROUNDING_MODE\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\n*/}\n\nvar ETH_UNITS = [ \n 'wei', \n 'Kwei', \n 'Mwei', \n 'Gwei', \n 'szabo', \n 'finney', \n 'ether', \n 'grand', \n 'Mether', \n 'Gether', \n 'Tether', \n 'Pether', \n 'Eether', \n 'Zether', \n 'Yether', \n 'Nether', \n 'Dether', \n 'Vether', \n 'Uether' \n];\n\nmodule.exports = {\n ETH_PADDING: 32,\n ETH_SIGNATURE_LENGTH: 4,\n ETH_UNITS: ETH_UNITS,\n ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN }\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file contract.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); \nvar abi = require('./abi');\nvar utils = require('./utils');\nvar eventImpl = require('./event');\n\nvar exportNatspecGlobals = function (vars) {\n // it's used byt natspec.js\n // TODO: figure out better way to solve this\n web3._currentContractAbi = vars.abi;\n web3._currentContractAddress = vars.address;\n web3._currentContractMethodName = vars.method;\n web3._currentContractMethodParams = vars.params;\n};\n\nvar addFunctionRelatedPropertiesToContract = function (contract) {\n \n contract.call = function (options) {\n contract._isTransact = false;\n contract._options = options;\n return contract;\n };\n\n contract.transact = function (options) {\n contract._isTransact = true;\n contract._options = options;\n return contract;\n };\n\n contract._options = {};\n ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {\n contract[p] = function (v) {\n contract._options[p] = v;\n return contract;\n };\n });\n\n};\n\nvar addFunctionsToContract = function (contract, desc, address) {\n var inputParser = abi.inputParser(desc);\n var outputParser = abi.outputParser(desc);\n\n // create contract functions\n utils.filterFunctions(desc).forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var signature = abi.signatureFromAscii(method.name);\n var parsed = inputParser[displayName][typeName].apply(null, params);\n\n var options = contract._options || {};\n options.to = address;\n options.data = signature + parsed;\n \n var isTransact = contract._isTransact === true || (contract._isTransact !== false && !method.constant);\n var collapse = options.collapse !== false;\n \n // reset\n contract._options = {};\n contract._isTransact = null;\n\n if (isTransact) {\n \n exportNatspecGlobals({\n abi: desc,\n address: address,\n method: method.name,\n params: params\n });\n\n // transactions do not have any output, cause we do not know, when they will be processed\n web3.eth.transact(options);\n return;\n }\n \n var output = web3.eth.call(options);\n var ret = outputParser[displayName][typeName](output);\n if (collapse)\n {\n if (ret.length === 1)\n ret = ret[0];\n else if (ret.length === 0)\n ret = null;\n }\n return ret;\n };\n\n if (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n });\n};\n\nvar addEventRelatedPropertiesToContract = function (contract, desc, address) {\n contract.address = address;\n contract._onWatchEventResult = function (data) {\n var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));\n var parser = eventImpl.outputParser(matchingEvent);\n return parser(data);\n };\n \n Object.defineProperty(contract, 'topic', {\n get: function() {\n return utils.filterEvents(desc).map(function (e) {\n return abi.eventSignatureFromAscii(e.name);\n });\n }\n });\n\n};\n\nvar addEventsToContract = function (contract, desc, address) {\n // create contract events\n utils.filterEvents(desc).forEach(function (e) {\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var signature = abi.eventSignatureFromAscii(e.name);\n var event = eventImpl.inputParser(address, signature, e);\n var o = event.apply(null, params);\n o._onWatchEventResult = function (data) {\n var parser = eventImpl.outputParser(e);\n return parser(data);\n };\n return web3.eth.watch(o); \n };\n \n // this property should be used by eth.filter to check if object is an event\n impl._isEvent = true;\n\n var displayName = utils.extractDisplayName(e.name);\n var typeName = utils.extractTypeName(e.name);\n\n if (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n\n });\n};\n\n\n/**\n * This method should be called when we want to call / transact some solidity method from javascript\n * it returns an object which has same methods available as solidity contract description\n * usage example: \n *\n * var abi = [{\n * name: 'myMethod',\n * inputs: [{ name: 'a', type: 'string' }],\n * outputs: [{name: 'd', type: 'string' }]\n * }]; // contract abi\n *\n * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object\n *\n * myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)\n * myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)\n * myContract.transact().myMethod('this is test string param for transact'); // myMethod transact\n *\n * @param address - address of the contract, which should be called\n * @param desc - abi json description of the contract, which is being created\n * @returns contract object\n */\n\nvar contract = function (address, desc) {\n\n // workaround for invalid assumption that method.name is the full anonymous prototype of the method.\n // it's not. it's just the name. the rest of the code assumes it's actually the anonymous\n // prototype, so we make it so as a workaround.\n // TODO: we may not want to modify input params, maybe use copy instead?\n desc.forEach(function (method) {\n if (method.name.indexOf('(') === -1) {\n var displayName = method.name;\n var typeName = method.inputs.map(function(i){return i.type; }).join();\n method.name = displayName + '(' + typeName + ')';\n }\n });\n\n var result = {};\n addFunctionRelatedPropertiesToContract(result);\n addFunctionsToContract(result, desc, address);\n addEventRelatedPropertiesToContract(result, desc, address);\n addEventsToContract(result, desc, address);\n\n return result;\n};\n\nmodule.exports = contract;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file event.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2014\n */\n\nvar abi = require('./abi');\nvar utils = require('./utils');\n\n/// filter inputs array && returns only indexed (or not) inputs\n/// @param inputs array\n/// @param bool if result should be an array of indexed params on not\n/// @returns array of (not?) indexed params\nvar filterInputs = function (inputs, indexed) {\n return inputs.filter(function (current) {\n return current.indexed === indexed;\n });\n};\n\nvar inputWithName = function (inputs, name) {\n var index = utils.findIndex(inputs, function (input) {\n return input.name === name;\n });\n \n if (index === -1) {\n console.error('indexed param with name ' + name + ' not found');\n return undefined;\n }\n return inputs[index];\n};\n\nvar indexedParamsToTopics = function (event, indexed) {\n // sort keys?\n return Object.keys(indexed).map(function (key) {\n var inputs = [inputWithName(filterInputs(event.inputs, true), key)];\n\n var value = indexed[key];\n if (value instanceof Array) {\n return value.map(function (v) {\n return abi.formatInput(inputs, [v]);\n }); \n }\n return abi.formatInput(inputs, [value]);\n });\n};\n\nvar inputParser = function (address, signature, event) {\n \n // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'\n return function (indexed, options) {\n var o = options || {};\n o.address = address;\n o.topic = [];\n o.topic.push(signature);\n if (indexed) {\n o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));\n }\n return o;\n };\n};\n\nvar getArgumentsObject = function (inputs, indexed, notIndexed) {\n var indexedCopy = indexed.slice();\n var notIndexedCopy = notIndexed.slice();\n return inputs.reduce(function (acc, current) {\n var value;\n if (current.indexed)\n value = indexed.splice(0, 1)[0];\n else\n value = notIndexed.splice(0, 1)[0];\n\n acc[current.name] = value;\n return acc;\n }, {}); \n};\n \nvar outputParser = function (event) {\n \n return function (output) {\n var result = {\n event: utils.extractDisplayName(event.name),\n number: output.number,\n args: {}\n };\n\n if (!output.topic) {\n return result;\n }\n \n var indexedOutputs = filterInputs(event.inputs, true);\n var indexedData = \"0x\" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join(\"\");\n var indexedRes = abi.formatOutput(indexedOutputs, indexedData);\n\n var notIndexedOutputs = filterInputs(event.inputs, false);\n var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);\n\n result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);\n\n return result;\n };\n};\n\nvar getMatchingEvent = function (events, payload) {\n for (var i = 0; i < events.length; i++) {\n var signature = abi.eventSignatureFromAscii(events[i].name); \n if (signature === payload.topic[0]) {\n return events[i];\n }\n }\n return undefined;\n};\n\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n getMatchingEvent: getMatchingEvent\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file filter.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); // jshint ignore:line\n\n/// should be used when we want to watch something\n/// it's using inner polling mechanism and is notified about changes\n/// TODO: change 'options' name cause it may be not the best matching one, since we have events\nvar Filter = function(options, impl) {\n\n if (typeof options !== \"string\") {\n\n // topics property is deprecated, warn about it!\n if (options.topics) {\n console.warn('\"topics\" is deprecated, use \"topic\" instead');\n }\n \n this._onWatchResult = options._onWatchEventResult;\n\n // evaluate lazy properties\n options = {\n to: options.to,\n topic: options.topic,\n earliest: options.earliest,\n latest: options.latest,\n max: options.max,\n skip: options.skip,\n address: options.address\n };\n\n }\n \n this.impl = impl;\n this.callbacks = [];\n\n this.id = impl.newFilter(options);\n web3.provider.startPolling({method: impl.changed, params: [this.id]}, this.id, this.trigger.bind(this));\n};\n\n/// alias for changed*\nFilter.prototype.arrived = function(callback) {\n this.changed(callback);\n};\nFilter.prototype.happened = function(callback) {\n this.changed(callback);\n};\n\n/// gets called when there is new eth/shh message\nFilter.prototype.changed = function(callback) {\n this.callbacks.push(callback);\n};\n\n/// trigger calling new message from people\nFilter.prototype.trigger = function(messages) {\n for (var i = 0; i < this.callbacks.length; i++) {\n for (var j = 0; j < messages.length; j++) {\n var message = this._onWatchResult ? this._onWatchResult(messages[j]) : messages[j];\n this.callbacks[i].call(this, message);\n }\n }\n};\n\n/// should be called to uninstall current filter\nFilter.prototype.uninstall = function() {\n this.impl.uninstallFilter(this.id);\n web3.provider.stopPolling(this.id);\n};\n\n/// should be called to manually trigger getting latest messages from the client\nFilter.prototype.messages = function() {\n return this.impl.getMessages(this.id);\n};\n\n/// alias for messages\nFilter.prototype.logs = function () {\n return this.messages();\n};\n\nmodule.exports = Filter;\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file formatters.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2015\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\n*/}\n\nvar utils = require('./utils');\nvar c = require('./const');\n\n/// @param string string to be padded\n/// @param number of characters that result string should have\n/// @param sign, by default 0\n/// @returns right aligned string\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/// Formats input value to byte representation of int\n/// If value is negative, return it's two's complement\n/// If the value is floating point, round it down\n/// @returns right-aligned byte representation of int\nvar formatInputInt = function (value) {\n var padding = c.ETH_PADDING * 2;\n if (value instanceof BigNumber || typeof value === 'number') {\n if (typeof value === 'number')\n value = new BigNumber(value);\n BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);\n value = value.round();\n\n if (value.lessThan(0)) \n value = new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(value).plus(1);\n value = value.toString(16);\n }\n else if (value.indexOf('0x') === 0)\n value = value.substr(2);\n else if (typeof value === 'string')\n value = formatInputInt(new BigNumber(value));\n else\n value = (+value).toString(16);\n return padLeft(value, padding);\n};\n\n/// Formats input value to byte representation of string\n/// @returns left-algined byte representation of string\nvar formatInputString = function (value) {\n return utils.fromAscii(value, c.ETH_PADDING).substr(2);\n};\n\n/// Formats input value to byte representation of bool\n/// @returns right-aligned byte representation bool\nvar formatInputBool = function (value) {\n return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');\n};\n\n/// Formats input value to byte representation of real\n/// Values are multiplied by 2^m and encoded as integers\n/// @returns byte representation of real\nvar formatInputReal = function (value) {\n return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128))); \n};\n\n\n/// Check if input value is negative\n/// @param value is hex format\n/// @returns true if it is negative, otherwise false\nvar signedIsNegative = function (value) {\n return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';\n};\n\n/// Formats input right-aligned input bytes to int\n/// @returns right-aligned input bytes formatted to int\nvar formatOutputInt = function (value) {\n value = value || \"0\";\n // check if it's negative number\n // it it is, return two's complement\n if (signedIsNegative(value)) {\n return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);\n }\n return new BigNumber(value, 16);\n};\n\n/// Formats big right-aligned input bytes to uint\n/// @returns right-aligned input bytes formatted to uint\nvar formatOutputUInt = function (value) {\n value = value || \"0\";\n return new BigNumber(value, 16);\n};\n\n/// @returns input bytes formatted to real\nvar formatOutputReal = function (value) {\n return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/// @returns input bytes formatted to ureal\nvar formatOutputUReal = function (value) {\n return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/// @returns right-aligned input bytes formatted to hex\nvar formatOutputHash = function (value) {\n return \"0x\" + value;\n};\n\n/// @returns right-aligned input bytes formatted to bool\nvar formatOutputBool = function (value) {\n return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;\n};\n\n/// @returns left-aligned input bytes formatted to ascii string\nvar formatOutputString = function (value) {\n return utils.toAscii(value);\n};\n\n/// @returns right-aligned input bytes formatted to address\nvar formatOutputAddress = function (value) {\n return \"0x\" + value.slice(value.length - 40, value.length);\n};\n\n\nmodule.exports = {\n formatInputInt: formatInputInt,\n formatInputString: formatInputString,\n formatInputBool: formatInputBool,\n formatInputReal: formatInputReal,\n formatOutputInt: formatOutputInt,\n formatOutputUInt: formatOutputUInt,\n formatOutputReal: formatOutputReal,\n formatOutputUReal: formatOutputUReal,\n formatOutputHash: formatOutputHash,\n formatOutputBool: formatOutputBool,\n formatOutputString: formatOutputString,\n formatOutputAddress: formatOutputAddress\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file httpsync.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line\n*/}\n\nvar HttpSyncProvider = function (host) {\n this.handlers = [];\n this.host = host || 'http://localhost:8080';\n};\n\nHttpSyncProvider.prototype.send = function (payload) {\n //var data = formatJsonRpcObject(payload);\n \n var request = new XMLHttpRequest();\n request.open('POST', this.host, false);\n request.send(JSON.stringify(payload));\n \n // check request.status\n var result = request.responseText;\n return JSON.parse(result);\n};\n\nmodule.exports = HttpSyncProvider;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file jsonrpc.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2015\n */\n\nvar messageId = 1;\n\n/// Should be called to valid json create payload object\n/// @param method of jsonrpc call, required\n/// @param params, an array of method params, optional\n/// @returns valid jsonrpc payload object\nvar toPayload = function (method, params) {\n if (!method)\n console.error('jsonrpc method should be specified!');\n\n return {\n jsonrpc: '2.0',\n method: method,\n params: params || [],\n id: messageId++\n }; \n};\n\n/// Should be called to check if jsonrpc response is valid\n/// @returns true if response is valid, otherwise false \nvar isValidResponse = function (response) {\n return !!response &&\n !response.error &&\n response.jsonrpc === '2.0' &&\n typeof response.id === 'number' &&\n response.result !== undefined; // only undefined is not valid json object\n};\n\n/// Should be called to create batch payload object\n/// @param messages, an array of objects with method (required) and params (optional) fields\nvar toBatchPayload = function (messages) {\n return messages.map(function (message) {\n return toPayload(message.method, message.params);\n }); \n};\n\nmodule.exports = {\n toPayload: toPayload,\n isValidResponse: isValidResponse,\n toBatchPayload: toBatchPayload\n};\n\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file providermanager.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); \nvar jsonrpc = require('./jsonrpc');\n\n\n/**\n * Provider manager object prototype\n * It's responsible for passing messages to providers\n * If no provider is set it's responsible for queuing requests\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 12 seconds\n * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling,\n * and provider manager polling mechanism is not used\n */\nvar ProviderManager = function() {\n this.polls = [];\n this.provider = undefined;\n\n var self = this;\n var poll = function () {\n self.polls.forEach(function (data) {\n var result = self.send(data.data);\n\n if (!(result instanceof Array) || result.length === 0) {\n return;\n }\n\n data.callback(result);\n });\n\n setTimeout(poll, 1000);\n };\n poll();\n};\n\n/// sends outgoing requests\n/// @params data - an object with at least 'method' property\nProviderManager.prototype.send = function(data) {\n var payload = jsonrpc.toPayload(data.method, data.params);\n\n if (this.provider === undefined) {\n console.error('provider is not set');\n return null; \n }\n\n var result = this.provider.send(payload);\n\n if (!jsonrpc.isValidResponse(result)) {\n console.log(result);\n return null;\n }\n\n return result.result;\n};\n\n/// setups provider, which will be used for sending messages\nProviderManager.prototype.set = function(provider) {\n this.provider = provider;\n};\n\n/// this method is only used, when we do not have native qt bindings and have to do polling on our own\n/// should be callled, on start watching for eth/shh changes\nProviderManager.prototype.startPolling = function (data, pollId, callback) {\n this.polls.push({data: data, id: pollId, callback: callback});\n};\n\n/// should be called to stop polling for certain watch changes\nProviderManager.prototype.stopPolling = function (pollId) {\n for (var i = this.polls.length; i--;) {\n var poll = this.polls[i];\n if (poll.id === pollId) {\n this.polls.splice(i, 1);\n }\n }\n};\n\nmodule.exports = ProviderManager;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n var result = navigator.qt.callMethod(JSON.stringify(payload));\n return JSON.parse(result);\n};\n\nmodule.exports = QtSyncProvider;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file types.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2015\n */\n\nvar f = require('./formatters');\n\n/// @param expected type prefix (string)\n/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false\nvar prefixedType = function (prefix) {\n return function (type) {\n return type.indexOf(prefix) === 0;\n };\n};\n\n/// @param expected type name (string)\n/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false\nvar namedType = function (name) {\n return function (type) {\n return name === type;\n };\n};\n\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar inputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: f.formatInputInt },\n { type: prefixedType('int'), format: f.formatInputInt },\n { type: prefixedType('hash'), format: f.formatInputInt },\n { type: prefixedType('string'), format: f.formatInputString }, \n { type: prefixedType('real'), format: f.formatInputReal },\n { type: prefixedType('ureal'), format: f.formatInputReal },\n { type: namedType('address'), format: f.formatInputInt },\n { type: namedType('bool'), format: f.formatInputBool }\n ];\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar outputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: f.formatOutputUInt },\n { type: prefixedType('int'), format: f.formatOutputInt },\n { type: prefixedType('hash'), format: f.formatOutputHash },\n { type: prefixedType('string'), format: f.formatOutputString },\n { type: prefixedType('real'), format: f.formatOutputReal },\n { type: prefixedType('ureal'), format: f.formatOutputUReal },\n { type: namedType('address'), format: f.formatOutputAddress },\n { type: namedType('bool'), format: f.formatOutputBool }\n ];\n};\n\nmodule.exports = {\n prefixedType: prefixedType,\n namedType: namedType,\n inputTypes: inputTypes,\n outputTypes: outputTypes\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file utils.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2015\n */\n\nvar c = require('./const');\n\n/// Finds first index of array element matching pattern\n/// @param array\n/// @param callback pattern\n/// @returns index of element\nvar findIndex = function (array, callback) {\n var end = false;\n var i = 0;\n for (; i < array.length && !end; i++) {\n end = callback(array[i]);\n }\n return end ? i - 1 : -1;\n};\n\n/// @returns ascii string representation of hex value prefixed with 0x\nvar toAscii = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n if (code === 0) {\n break;\n }\n\n str += String.fromCharCode(code);\n }\n\n return str;\n};\n \nvar toHex = function(str) {\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var n = str.charCodeAt(i).toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return hex;\n};\n\n/// @returns hex representation (prefixed by 0x) of ascii string\nvar fromAscii = function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = toHex(str);\n while (hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n};\n\n/// @returns display name for function/event eg. multiply(uint256) -> multiply\nvar extractDisplayName = function (name) {\n var length = name.indexOf('('); \n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/// Filters all function from input abi\n/// @returns abi array with filtered objects of type 'function'\nvar filterFunctions = function (json) {\n return json.filter(function (current) {\n return current.type === 'function'; \n }); \n};\n\n/// Filters all events form input abi\n/// @returns abi array with filtered objects of type 'event'\nvar filterEvents = function (json) {\n return json.filter(function (current) {\n return current.type === 'event';\n });\n};\n\n/// used to transform value/string to eth string\n/// TODO: use BigNumber.js to parse int\n/// TODO: add tests for it!\nvar toEth = function (str) {\n var val = typeof str === \"string\" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;\n var unit = 0;\n var units = c.ETH_UNITS;\n while (val > 3000 && unit < units.length - 1)\n {\n val /= 1000;\n unit++;\n }\n var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);\n var replaceFunction = function($0, $1, $2) {\n return $1 + ',' + $2;\n };\n\n while (true) {\n var o = s;\n s = s.replace(/(\\d)(\\d\\d\\d[\\.\\,])/, replaceFunction);\n if (o === s)\n break;\n }\n return s + ' ' + units[unit];\n};\n\nmodule.exports = {\n findIndex: findIndex,\n toAscii: toAscii,\n fromAscii: fromAscii,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n filterFunctions: filterFunctions,\n filterEvents: filterEvents,\n toEth: toEth\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js');\n*/}\n\nvar utils = require('./utils');\n\n/// @returns an array of objects describing web3 api methods\nvar web3Methods = function () {\n return [\n { name: 'sha3', call: 'web3_sha3' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth api methods\nvar ethMethods = function () {\n var blockCall = function (args) {\n return typeof args[0] === \"string\" ? \"eth_blockByHash\" : \"eth_blockByNumber\";\n };\n\n var transactionCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_transactionByHash' : 'eth_transactionByNumber';\n };\n\n var uncleCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_uncleByHash' : 'eth_uncleByNumber';\n };\n\n var methods = [\n { name: 'balanceAt', call: 'eth_balanceAt' },\n { name: 'stateAt', call: 'eth_stateAt' },\n { name: 'storageAt', call: 'eth_storageAt' },\n { name: 'countAt', call: 'eth_countAt'},\n { name: 'codeAt', call: 'eth_codeAt' },\n { name: 'transact', call: 'eth_transact' },\n { name: 'call', call: 'eth_call' },\n { name: 'block', call: blockCall },\n { name: 'transaction', call: transactionCall },\n { name: 'uncle', call: uncleCall },\n { name: 'compilers', call: 'eth_compilers' },\n { name: 'flush', call: 'eth_flush' },\n { name: 'lll', call: 'eth_lll' },\n { name: 'solidity', call: 'eth_solidity' },\n { name: 'serpent', call: 'eth_serpent' },\n { name: 'logs', call: 'eth_logs' }\n ];\n return methods;\n};\n\n/// @returns an array of objects describing web3.eth api properties\nvar ethProperties = function () {\n return [\n { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },\n { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },\n { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },\n { name: 'gasPrice', getter: 'eth_gasPrice' },\n { name: 'accounts', getter: 'eth_accounts' },\n { name: 'peerCount', getter: 'eth_peerCount' },\n { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },\n { name: 'number', getter: 'eth_number'}\n ];\n};\n\n/// @returns an array of objects describing web3.db api methods\nvar dbMethods = function () {\n return [\n { name: 'put', call: 'db_put' },\n { name: 'get', call: 'db_get' },\n { name: 'putString', call: 'db_putString' },\n { name: 'getString', call: 'db_getString' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh api methods\nvar shhMethods = function () {\n return [\n { name: 'post', call: 'shh_post' },\n { name: 'newIdentity', call: 'shh_newIdentity' },\n { name: 'haveIdentity', call: 'shh_haveIdentity' },\n { name: 'newGroup', call: 'shh_newGroup' },\n { name: 'addToGroup', call: 'shh_addToGroup' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth.watch api methods\nvar ethWatchMethods = function () {\n var newFilter = function (args) {\n return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';\n };\n\n return [\n { name: 'newFilter', call: newFilter },\n { name: 'uninstallFilter', call: 'eth_uninstallFilter' },\n { name: 'getMessages', call: 'eth_filterLogs' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shhWatchMethods = function () {\n return [\n { name: 'newFilter', call: 'shh_newFilter' },\n { name: 'uninstallFilter', call: 'shh_uninstallFilter' },\n { name: 'getMessages', call: 'shh_getMessages' }\n ];\n};\n\n/// creates methods in a given object based on method description on input\n/// setups api calls for these methods\nvar setupMethods = function (obj, methods) {\n methods.forEach(function (method) {\n obj[method.name] = function () {\n var args = Array.prototype.slice.call(arguments);\n var call = typeof method.call === 'function' ? method.call(args) : method.call;\n return web3.provider.send({\n method: call,\n params: args\n });\n };\n });\n};\n\n/// creates properties in a given object based on properties description on input\n/// setups api calls for these properties\nvar setupProperties = function (obj, properties) {\n properties.forEach(function (property) {\n var proto = {};\n proto.get = function () {\n return web3.provider.send({\n method: property.getter\n });\n };\n\n if (property.setter) {\n proto.set = function (val) {\n return web3.provider.send({\n method: property.setter,\n params: [val]\n });\n };\n }\n Object.defineProperty(obj, property.name, proto);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {\n _callbacks: {},\n _events: {},\n providers: {},\n\n /// @returns ascii string representation of hex value prefixed with 0x\n toAscii: utils.toAscii,\n\n /// @returns hex representation (prefixed by 0x) of ascii string\n fromAscii: utils.fromAscii,\n\n /// @returns decimal representaton of hex value prefixed by 0x\n toDecimal: function (val) {\n // remove 0x and place 0, if it's required\n val = val.length > 2 ? val.substring(2) : \"0\";\n return (new BigNumber(val, 16).toString(10));\n },\n\n /// @returns hex representation (prefixed by 0x) of decimal value\n fromDecimal: function (val) {\n return \"0x\" + (new BigNumber(val).toString(16));\n },\n\n /// used to transform value/string to eth string\n toEth: utils.toEth,\n\n /// eth object prototype\n eth: {\n contractFromAbi: function (abi) {\n return function(addr) {\n // Default to address of Config. TODO: rremove prior to genesis.\n addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';\n var ret = web3.eth.contract(addr, abi);\n ret.address = addr;\n return ret;\n };\n },\n\n /// @param filter may be a string, object or event\n /// @param indexed is optional, this is an object with optional event indexed params\n /// @param options is optional, this is an object with optional event options ('max'...)\n watch: function (filter, indexed, options) {\n if (filter._isEvent) {\n return filter(indexed, options);\n }\n return new web3.filter(filter, ethWatch);\n }\n },\n\n /// db object prototype\n db: {},\n\n /// shh object prototype\n shh: {\n \n /// @param filter may be a string, object or event\n watch: function (filter, indexed) {\n return new web3.filter(filter, shhWatch);\n }\n },\n};\n\n/// setups all api methods\nsetupMethods(web3, web3Methods());\nsetupMethods(web3.eth, ethMethods());\nsetupProperties(web3.eth, ethProperties());\nsetupMethods(web3.db, dbMethods());\nsetupMethods(web3.shh, shhMethods());\n\nvar ethWatch = {\n changed: 'eth_changed'\n};\n\nsetupMethods(ethWatch, ethWatchMethods());\n\nvar shhWatch = {\n changed: 'shh_changed'\n};\n\nsetupMethods(shhWatch, shhWatchMethods());\n\nweb3.setProvider = function(provider) {\n web3.provider.set(provider);\n};\n\nmodule.exports = web3;\n\n",
- "var web3 = require('./lib/web3');\nvar ProviderManager = require('./lib/providermanager');\nweb3.provider = new ProviderManager();\nweb3.filter = require('./lib/filter');\nweb3.providers.HttpSyncProvider = require('./lib/httpsync');\nweb3.providers.QtSyncProvider = require('./lib/qtsync');\nweb3.eth.contract = require('./lib/contract');\nweb3.abi = require('./lib/abi');\n\n\nmodule.exports = web3;\n"
- ]
-} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.min.js b/cmd/mist/assets/ext/ethereum.js/dist/ethereum.min.js
deleted file mode 100644
index df408d3e4..000000000
--- a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.min.js
+++ /dev/null
@@ -1 +0,0 @@
-require=function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e){var n=t("./web3"),r=t("./utils"),i=t("./types"),o=t("./const"),a=t("./formatters"),u=function(t){console.error("parser does not support type: "+t)},s=function(t){return"[]"===t.slice(-2)},f=function(t,e){return s(t)||"string"===t?a.formatInputInt(e.length):""},c=i.inputTypes(),l=function(t,e){{var n="";2*o.ETH_PADDING}return t.forEach(function(t,r){n+=f(t.type,e[r])}),t.forEach(function(r,i){for(var o=!1,a=0;a<c.length&&!o;a++)o=c[a].type(t[i].type,e[i]);o||u(t[i].type);var f=c[a-1].format,l="";l=s(t[i].type)?e[i].reduce(function(t,e){return t+f(e)},""):f(e[i]),n+=l}),n},p=function(t){return s(t)||"string"===t?2*o.ETH_PADDING:0},m=i.outputTypes(),h=function(t,e){e=e.slice(2);var n=[],r=2*o.ETH_PADDING,f=t.reduce(function(t,e){return t+p(e.type)},0),c=e.slice(0,f);return e=e.slice(f),t.forEach(function(o,f){for(var l=!1,p=0;p<m.length&&!l;p++)l=m[p].type(t[f].type);l||u(t[f].type);var h=m[p-1].format;if(s(t[f].type)){var d=a.formatOutputUInt(c.slice(0,r));c=c.slice(r);for(var g=[],v=0;d>v;v++)g.push(h(e.slice(0,r))),e=e.slice(r);n.push(g)}else i.prefixedType("string")(t[f].type)?(c=c.slice(r),n.push(h(e.slice(0,r))),e=e.slice(r)):(n.push(h(e.slice(0,r))),e=e.slice(r))}),n},d=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},g=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(e){return h(t.outputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},v=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*o.ETH_SIGNATURE_LENGTH)},y=function(t){return n.sha3(n.fromAscii(t))};e.exports={inputParser:d,outputParser:g,formatInput:l,formatOutput:h,signatureFromAscii:v,eventSignatureFromAscii:y}},{"./const":2,"./formatters":6,"./types":11,"./utils":12,"./web3":13}],2:[function(t,e){var n=["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:n,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN}}},{}],3:[function(t,e){var n=t("./web3"),r=t("./abi"),i=t("./utils"),o=t("./event"),a=function(t){n._currentContractAbi=t.abi,n._currentContractAddress=t.address,n._currentContractMethodName=t.method,n._currentContractMethodParams=t.params},u=function(t){t.call=function(e){return t._isTransact=!1,t._options=e,t},t.transact=function(e){return t._isTransact=!0,t._options=e,t},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},s=function(t,e,o){var u=r.inputParser(e),s=r.outputParser(e);i.filterFunctions(e).forEach(function(f){var c=i.extractDisplayName(f.name),l=i.extractTypeName(f.name),p=function(){var i=Array.prototype.slice.call(arguments),p=r.signatureFromAscii(f.name),m=u[c][l].apply(null,i),h=t._options||{};h.to=o,h.data=p+m;var d=t._isTransact===!0||t._isTransact!==!1&&!f.constant,g=h.collapse!==!1;if(t._options={},t._isTransact=null,d)return a({abi:e,address:o,method:f.name,params:i}),void n.eth.transact(h);var v=n.eth.call(h),y=s[c][l](v);return g&&(1===y.length?y=y[0]:0===y.length&&(y=null)),y};void 0===t[c]&&(t[c]=p),t[c][l]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(i.filterEvents(e)),r=o.outputParser(n);return r(t)},Object.defineProperty(t,"topic",{get:function(){return i.filterEvents(e).map(function(t){return r.eventSignatureFromAscii(t.name)})}})},c=function(t,e,a){i.filterEvents(e).forEach(function(e){var u=function(){var t=Array.prototype.slice.call(arguments),i=r.eventSignatureFromAscii(e.name),u=o.inputParser(a,i,e),s=u.apply(null,t);return s._onWatchEventResult=function(t){var n=o.outputParser(e);return n(t)},n.eth.watch(s)};u._isEvent=!0;var s=i.extractDisplayName(e.name),f=i.extractTypeName(e.name);void 0===t[s]&&(t[s]=u),t[s][f]=u})},l=function(t,e){e.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n={};return u(n),s(n,e,t),f(n,e,t),c(n,e,t),n};e.exports=l},{"./abi":1,"./event":4,"./utils":12,"./web3":13}],4:[function(t,e){var n=t("./abi"),r=t("./utils"),i=function(t,e){return t.filter(function(t){return t.indexed===e})},o=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},a=function(t,e){return Object.keys(e).map(function(r){var a=[o(i(t.inputs,!0),r)],u=e[r];return u instanceof Array?u.map(function(t){return n.formatInput(a,[t])}):n.formatInput(a,[u])})},u=function(t,e,n){return function(r,i){var o=i||{};return o.address=t,o.topic=[],o.topic.push(e),r&&(o.topic=o.topic.concat(a(n,r))),o}},s=function(t,e,n){e.slice(),n.slice();return t.reduce(function(t,r){var i;return i=r.indexed?e.splice(0,1)[0]:n.splice(0,1)[0],t[r.name]=i,t},{})},f=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,args:{}};if(!e.topic)return o;var a=i(t.inputs,!0),u="0x"+e.topic.slice(1,e.topic.length).map(function(t){return t.slice(2)}).join(""),f=n.formatOutput(a,u),c=i(t.inputs,!1),l=n.formatOutput(c,e.data);return o.args=s(t.inputs,f,l),o}},c=function(t,e){for(var r=0;r<t.length;r++){var i=n.eventSignatureFromAscii(t[r].name);if(i===e.topic[0])return t[r]}return void 0};e.exports={inputParser:u,outputParser:f,getMatchingEvent:c}},{"./abi":1,"./utils":12}],5:[function(t,e){var n=t("./web3"),r=function(t,e){"string"!=typeof t&&(t.topics&&console.warn('"topics" is deprecated, use "topic" instead'),this._onWatchResult=t._onWatchEventResult,t={to:t.to,topic:t.topic,earliest:t.earliest,latest:t.latest,max:t.max,skip:t.skip,address:t.address}),this.impl=e,this.callbacks=[],this.id=e.newFilter(t),n.provider.startPolling({method:e.changed,params:[this.id]},this.id,this.trigger.bind(this))};r.prototype.arrived=function(t){this.changed(t)},r.prototype.happened=function(t){this.changed(t)},r.prototype.changed=function(t){this.callbacks.push(t)},r.prototype.trigger=function(t){for(var e=0;e<this.callbacks.length;e++)for(var n=0;n<t.length;n++){var r=this._onWatchResult?this._onWatchResult(t[n]):t[n];this.callbacks[e].call(this,r)}},r.prototype.uninstall=function(){this.impl.uninstallFilter(this.id),n.provider.stopPolling(this.id)},r.prototype.messages=function(){return this.impl.getMessages(this.id)},r.prototype.logs=function(){return this.messages()},e.exports=r},{"./web3":13}],6:[function(t,e){var n=t("./utils"),r=t("./const"),i=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},o=function(t){var e=2*r.ETH_PADDING;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),BigNumber.config(r.ETH_BIGNUMBER_ROUNDING_MODE),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?o(new BigNumber(t)):(+t).toString(16),i(t,e)},a=function(t){return n.fromAscii(t,r.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},s=function(t){return o(new BigNumber(t).times(new BigNumber(2).pow(128)))},f=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},c=function(t){return t=t||"0",f(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},l=function(t){return t=t||"0",new BigNumber(t,16)},p=function(t){return c(t).dividedBy(new BigNumber(2).pow(128))},m=function(t){return l(t).dividedBy(new BigNumber(2).pow(128))},h=function(t){return"0x"+t},d=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},g=function(t){return n.toAscii(t)},v=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:o,formatInputString:a,formatInputBool:u,formatInputReal:s,formatOutputInt:c,formatOutputUInt:l,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:h,formatOutputBool:d,formatOutputString:g,formatOutputAddress:v}},{"./const":2,"./utils":12}],7:[function(t,e){var n=function(t){this.handlers=[],this.host=t||"http://localhost:8080"};n.prototype.send=function(t){var e=new XMLHttpRequest;e.open("POST",this.host,!1),e.send(JSON.stringify(t));var n=e.responseText;return JSON.parse(n)},e.exports=n},{}],8:[function(t,e){var n=1,r=function(t,e){return t||console.error("jsonrpc method should be specified!"),{jsonrpc:"2.0",method:t,params:e||[],id:n++}},i=function(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result},o=function(t){return t.map(function(t){return r(t.method,t.params)})};e.exports={toPayload:r,isValidResponse:i,toBatchPayload:o}},{}],9:[function(t,e){var n=(t("./web3"),t("./jsonrpc")),r=function(){this.polls=[],this.provider=void 0;var t=this,e=function(){t.polls.forEach(function(e){var n=t.send(e.data);n instanceof Array&&0!==n.length&&e.callback(n)}),setTimeout(e,1e3)};e()};r.prototype.send=function(t){var e=n.toPayload(t.method,t.params);if(void 0===this.provider)return console.error("provider is not set"),null;var r=this.provider.send(e);return n.isValidResponse(r)?r.result:(console.log(r),null)},r.prototype.set=function(t){this.provider=t},r.prototype.startPolling=function(t,e,n){this.polls.push({data:t,id:e,callback:n})},r.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},e.exports=r},{"./jsonrpc":8,"./web3":13}],10:[function(t,e){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],11:[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}]},a=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:a}},{"./formatters":6}],12:[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},a=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(" ",""):""},f=function(t){return t.filter(function(t){return"function"===t.type})},c=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),a=function(t,e,n){return e+","+n};;){var u=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,a),u===o)break}return o+" "+i[r]};e.exports={findIndex:r,toAscii:i,fromAscii:a,extractDisplayName:u,extractTypeName:s,filterFunctions:f,filterEvents:c,toEth:l}},{"./const":2}],13:[function(t,e){var n=t("./utils"),r=function(){return[{name:"sha3",call:"web3_sha3"}]},i=function(){var t=function(t){return"string"==typeof t[0]?"eth_blockByHash":"eth_blockByNumber"},e=function(t){return"string"==typeof t[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(t){return"string"==typeof t[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:t},{name:"transaction",call:e},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"flush",call:"eth_flush"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"},{name:"logs",call:"eth_logs"}];return r},o=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},a=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},u=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},s=function(){var t=function(t){return"string"==typeof t[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_filterLogs"}]},f=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessages",call:"shh_getMessages"}]},c=function(t,e){e.forEach(function(e){t[e.name]=function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof e.call?e.call(t):e.call;return p.provider.send({method:n,params:t})}})},l=function(t,e){e.forEach(function(e){var n={};n.get=function(){return p.provider.send({method:e.getter})},e.setter&&(n.set=function(t){return p.provider.send({method:e.setter,params:[t]})}),Object.defineProperty(t,e.name,n)})},p={_callbacks:{},_events:{},providers:{},toAscii:n.toAscii,fromAscii:n.fromAscii,toDecimal:function(t){return t=t.length>2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:n.toEth,eth:{contractFromAbi:function(t){return function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=p.eth.contract(e,t);return n.address=e,n}},watch:function(t,e,n){return t._isEvent?t(e,n):new p.filter(t,m)}},db:{},shh:{watch:function(t){return new p.filter(t,h)}}};c(p,r()),c(p.eth,i()),l(p.eth,o()),c(p.db,a()),c(p.shh,u());var m={changed:"eth_changed"};c(m,s());var h={changed:"shh_changed"};c(h,f()),p.setProvider=function(t){p.provider.set(t)},e.exports=p},{"./utils":12}],web3:[function(t,e){var n=t("./lib/web3"),r=t("./lib/providermanager");n.provider=new r,n.filter=t("./lib/filter"),n.providers.HttpSyncProvider=t("./lib/httpsync"),n.providers.QtSyncProvider=t("./lib/qtsync"),n.eth.contract=t("./lib/contract"),n.abi=t("./lib/abi"),e.exports=n},{"./lib/abi":1,"./lib/contract":3,"./lib/filter":5,"./lib/httpsync":7,"./lib/providermanager":9,"./lib/qtsync":10,"./lib/web3":13}]},{},["web3"]); \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js/example/balance.html b/cmd/mist/assets/ext/ethereum.js/example/balance.html
deleted file mode 100644
index 616d4eb6f..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/balance.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
- function watchBalance() {
- var coinbase = web3.eth.coinbase;
- var originalBalance = 0;
-
- var balance = web3.eth.balanceAt(coinbase);
- var originalBalance = web3.toDecimal(balance);
- document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
-
-<<<<<<< HEAD:cmd/mist/assets/ext/ethereum.js/example/balance.html
- var filter = web3.eth.watch({address: coinbase}).changed(function() {
-=======
- web3.eth.watch('pending').changed(function() {
->>>>>>> 859a1999cb204d2c6fcb08d6569c738c5af5cd86:example/balance.html
- balance = web3.eth.balanceAt(coinbase)
- var currentBalance = web3.toDecimal(balance);
- document.getElementById("current").innerText = 'current: ' + currentBalance;
- document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
- });
- }
-
-</script>
-</head>
-<body>
- <h1>coinbase balance</h1>
- <button type="button" onClick="watchBalance();">watch balance</button>
- <div></div>
- <div id="original"></div>
- <div id="current"></div>
- <div id="diff"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/ethereum.js/example/contract.html b/cmd/mist/assets/ext/ethereum.js/example/contract.html
deleted file mode 100644
index a534f68d8..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/contract.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider());
-
- // solidity source code
- var source = "" +
- "contract test {\n" +
- " function multiply(uint a) returns(uint d) {\n" +
- " return a * 7;\n" +
- " }\n" +
- "}\n";
-
- // contract description, this will be autogenerated somehow
- var desc = [{
- "name": "multiply(uint256)",
- "type": "function",
- "inputs": [
- {
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- }];
-
- var contract;
-
- function createExampleContract() {
- // hide create button
- document.getElementById('create').style.visibility = 'hidden';
- document.getElementById('source').innerText = source;
-
- // create contract
- var address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- }
-
- function callExampleContract() {
- // this should be generated by ethereum
- var param = parseInt(document.getElementById('value').value);
-
- // call the contract
- var res = contract.call().multiply(param);
- document.getElementById('result').innerText = res.toString(10);
- }
-
-</script>
-</head>
-<body>
- <h1>contract</h1>
- <div id="source"></div>
- <div id='create'>
- <button type="button" onClick="createExampleContract();">create example contract</button>
- </div>
- <div id='call' style='visibility: hidden;'>
- <input type="number" id="value" onkeyup='callExampleContract()'></input>
- </div>
- <div id="result"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/ethereum.js/example/contract_with_array.html b/cmd/mist/assets/ext/ethereum.js/example/contract_with_array.html
deleted file mode 100644
index a3dfc8a24..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/contract_with_array.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider());
-
- // solidity source code
- var source = "" +
- "contract test {\n" +
- " function multiply(uint[] a) returns(uint d) {\n" +
- " return a[0] + a[1];\n" +
- " }\n" +
- "}\n";
-
- // contract description, this will be autogenerated somehow
- var desc = [{
- "name": "multiply(uint256[])",
- "type": "function",
- "inputs": [
- {
- "name": "a",
- "type": "uint256[]"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- }];
-
- var contract;
-
- function createExampleContract() {
- // hide create button
- document.getElementById('create').style.visibility = 'hidden';
- document.getElementById('source').innerText = source;
-
- // create contract
- var address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- }
-
- function callExampleContract() {
- // this should be generated by ethereum
- var param = parseInt(document.getElementById('value').value);
- var param2 = parseInt(document.getElementById('value2').value);
-
- // call the contract
- var res = contract.call().multiply([param, param2]);
- document.getElementById('result').innerText = res.toString(10);
- }
-
-</script>
-</head>
-<body>
- <h1>contract</h1>
- <div id="source"></div>
- <div id='create'>
- <button type="button" onClick="createExampleContract();">create example contract</button>
- </div>
- <div id='call' style='visibility: hidden;'>
- <input type="number" id="value" onkeyup='callExampleContract()'></input>
- <input type="number" id="value2" onkeyup='callExampleContract()'></input>
- </div>
- <div id="result"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/ethereum.js/example/event.html b/cmd/mist/assets/ext/ethereum.js/example/event.html
deleted file mode 100644
index 84d302437..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/event.html
+++ /dev/null
@@ -1,120 +0,0 @@
-<!doctype>
-<html>
- <head>
- <script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
- <script type="text/javascript" src="../dist/ethereum.js"></script>
- <script type="text/javascript">
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
- var desc = [{
- "type":"event",
- "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}],
- "name":"Event"
- }, {
- "type":"event",
- "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}],
- "name":"Event2"
- }, {
- "type":"function",
- "inputs": [{"name":"a","type":"uint256"}],
- "name":"foo",
- "outputs": []
- }];
-
- var address = '0x01';
-
- var contract = web3.eth.contract(address, desc);
-
- function test1() {
- // "{"topic":["0x83c9849c","0xc4d76332"],"address":"0x01"}"
- web3.eth.watch(contract).changed(function (res) {
-
- });
- };
-
- function test2() {
- // "{"topic":["0x83c9849c"],"address":"0x01"}"
- web3.eth.watch(contract.Event).changed(function (res) {
-
- });
- };
-
- function test3() {
- // "{"topic":["0x83c9849c"],"address":"0x01"}"
- contract.Event().changed(function (res) {
-
- });
- };
-
- function test4() {
- // "{"topic":["0x83c9849c","0000000000000000000000000000000000000000000000000000000000000045"],"address":"0x01"}"
- contract.Event({a: 69}).changed(function (res) {
-
- });
- };
-
- function test5() {
- // "{"topic":["0x83c9849c",["0000000000000000000000000000000000000000000000000000000000000045","000000000000000000000000000000000000000000000000000000000000002a"]],"address":"0x01"}"
- contract.Event({a: [69, 42]}).changed(function (res) {
-
- });
- };
-
- function test6() {
- // "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"max":100,"address":"0x01"}"
- contract.Event({a: 30}, {max: 100}).changed(function (res) {
-
- });
- };
-
- function test7() {
- // "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"address":"0x01"}"
- web3.eth.watch(contract.Event, {a: 30}).changed(function (res) {
-
- });
- };
-
- function test8() {
- // "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"max":100,"address":"0x01"}"
- web3.eth.watch(contract.Event, {a: 30}, {max: 100}).changed(function (res) {
-
- });
- };
-
- // not valid
- // function testX() {
- // web3.eth.watch([contract.Event, contract.Event2]).changed(function (res) {
- // });
- // };
-
- </script>
- </head>
-
- <body>
- <div>
- <button type="button" onClick="test1();">test1</button>
- </div>
- <div>
- <button type="button" onClick="test2();">test2</button>
- </div>
- <div>
- <button type="button" onClick="test3();">test3</button>
- </div>
- <div>
- <button type="button" onClick="test4();">test4</button>
- </div>
- <div>
- <button type="button" onClick="test5();">test5</button>
- </div>
- <div>
- <button type="button" onClick="test6();">test6</button>
- </div>
- <div>
- <button type="button" onClick="test7();">test7</button>
- </div>
- <div>
- <button type="button" onClick="test8();">test8</button>
- </div>
- </body>
-</html>
diff --git a/cmd/mist/assets/ext/ethereum.js/example/event_inc.html b/cmd/mist/assets/ext/ethereum.js/example/event_inc.html
deleted file mode 100644
index 17df9d681..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/event_inc.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<!doctype>
-<html>
- <head>
- <script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
- <script type="text/javascript" src="../dist/ethereum.js"></script>
- <script type="text/javascript">
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
- var source = "" +
- "contract Contract { " +
- " event Incremented(bool indexed odd, uint x); " +
- " function Contract() { " +
- " x = 69; " +
- " } " +
- " function inc() { " +
- " ++x; " +
- " Incremented(x % 2 == 1, x); " +
- " } " +
- " uint x; " +
- "}";
-
- var desc = [{
- "type":"event",
- "name":"Incremented",
- "inputs": [{"name":"odd","type":"bool","indexed":true},{"name":"x","type":"uint","indexed":false}],
- }, {
- "type":"function",
- "name":"inc",
- "inputs": [],
- "outputs": []
- }];
-
- var address;
- var contract;
-
- var update = function (x) {
- document.getElementById('result').innerText = JSON.stringify(x);
- };
-
- var createContract = function () {
- address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- contract.Incremented({odd: true}).changed(update);
-
- };
-
- var callContract = function () {
- contract.call().inc();
- };
-
-
- </script>
- </head>
-
- <body>
- <div>
- <button type="button" onClick="createContract();">create contract</button>
- </div>
- <div>
- <button type="button" onClick="callContract();">test1</button>
- </div>
- <div id="result">
- </div>
- </body>
-</html>
diff --git a/cmd/mist/assets/ext/ethereum.js/example/natspec_contract.html b/cmd/mist/assets/ext/ethereum.js/example/natspec_contract.html
deleted file mode 100644
index 212e582dc..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/natspec_contract.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.QtSyncProvider());
-
- // solidity source code
- var source = "" +
- "contract test {\n" +
- " /// @notice Will multiply `a` by 7. \n" +
- " function multiply(uint a) returns(uint d) {\n" +
- " return a * 7;\n" +
- " }\n" +
- "}\n";
-
- // contract description, this will be autogenerated somehow
- var desc = [{
- "name": "multiply(uint256)",
- "type": "function",
- "inputs": [
- {
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- }];
-
- var contract;
-
- function createExampleContract() {
- // hide create button
- document.getElementById('create').style.visibility = 'hidden';
- document.getElementById('source').innerText = source;
-
- // create contract
- var address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- }
-
- function callExampleContract() {
- // this should be generated by ethereum
- var param = parseInt(document.getElementById('value').value);
-
- // transaction does not return any result, cause it's not synchronous and we don't know,
- // when it will be processed
- contract.transact().multiply(param);
- document.getElementById('result').innerText = 'transaction made';
- }
-
-</script>
-</head>
-<body>
- <h1>contract</h1>
- <div id="source"></div>
- <div id='create'>
- <button type="button" onClick="createExampleContract();">create example contract</button>
- </div>
- <div id='call' style='visibility: hidden;'>
- <input type="number" id="value"></input>
- <button type="button" onClick="callExampleContract()">Call Contract</button>
- </div>
- <div id="result"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/ethereum.js/example/node-app.js b/cmd/mist/assets/ext/ethereum.js/example/node-app.js
deleted file mode 100644
index 8c2fc0ba3..000000000
--- a/cmd/mist/assets/ext/ethereum.js/example/node-app.js
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env node
-
-var web3 = require("../index.js");
-
-web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
-var coinbase = web3.eth.coinbase;
-console.log(coinbase);
-
-var balance = web3.eth.balanceAt(coinbase);
-console.log(balance);
-
diff --git a/cmd/mist/assets/ext/ethereum.js/gulpfile.js b/cmd/mist/assets/ext/ethereum.js/gulpfile.js
deleted file mode 100644
index f8f6c96ce..000000000
--- a/cmd/mist/assets/ext/ethereum.js/gulpfile.js
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-var path = require('path');
-
-var del = require('del');
-var gulp = require('gulp');
-var browserify = require('browserify');
-var jshint = require('gulp-jshint');
-var uglify = require('gulp-uglify');
-var rename = require('gulp-rename');
-var envify = require('envify/custom');
-var unreach = require('unreachable-branch-transform');
-var source = require('vinyl-source-stream');
-var exorcist = require('exorcist');
-var bower = require('bower');
-
-var DEST = './dist/';
-
-var build = function(src, dst, ugly) {
- var result = browserify({
- debug: true,
- insert_global_vars: false,
- detectGlobals: false,
- bundleExternal: false
- })
- .require('./' + src + '.js', {expose: 'web3'})
- .add('./' + src + '.js')
- .transform('envify', {
- NODE_ENV: 'build'
- })
- .transform('unreachable-branch-transform');
-
- if (ugly) {
- result = result.transform('uglifyify', {
- mangle: false,
- compress: {
- dead_code: false,
- conditionals: true,
- unused: false,
- hoist_funs: true,
- hoist_vars: true,
- negate_iife: false
- },
- beautify: true,
- warnings: true
- });
- }
-
- return result.bundle()
- .pipe(exorcist(path.join( DEST, dst + '.js.map')))
- .pipe(source(dst + '.js'))
- .pipe(gulp.dest( DEST ));
-};
-
-var uglifyFile = function(file) {
- return gulp.src( DEST + file + '.js')
- .pipe(uglify())
- .pipe(rename(file + '.min.js'))
- .pipe(gulp.dest( DEST ));
-};
-
-gulp.task('bower', function(cb){
- bower.commands.install().on('end', function (installed){
- console.log(installed);
- cb();
- });
-});
-
-gulp.task('clean', ['lint'], function(cb) {
- del([ DEST ], cb);
-});
-
-gulp.task('lint', function(){
- return gulp.src(['./*.js', './lib/*.js'])
- .pipe(jshint())
- .pipe(jshint.reporter('default'));
-});
-
-gulp.task('build', ['clean'], function () {
- return build('index', 'ethereum', true);
-});
-
-gulp.task('buildDev', ['clean'], function () {
- return build('index', 'ethereum', false);
-});
-
-gulp.task('uglify', ['build'], function(){
- return uglifyFile('ethereum');
-});
-
-gulp.task('uglifyDev', ['buildDev'], function(){
- return uglifyFile('ethereum');
-});
-
-gulp.task('watch', function() {
- gulp.watch(['./lib/*.js'], ['lint', 'prepare', 'build']);
-});
-
-gulp.task('release', ['bower', 'lint', 'build', 'uglify']);
-gulp.task('dev', ['bower', 'lint', 'buildDev', 'uglifyDev']);
-gulp.task('default', ['dev']);
-
diff --git a/cmd/mist/assets/ext/ethereum.js/index.js b/cmd/mist/assets/ext/ethereum.js/index.js
deleted file mode 100644
index 76c923722..000000000
--- a/cmd/mist/assets/ext/ethereum.js/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var web3 = require('./lib/web3');
-var ProviderManager = require('./lib/providermanager');
-web3.provider = new ProviderManager();
-web3.filter = require('./lib/filter');
-web3.providers.HttpSyncProvider = require('./lib/httpsync');
-web3.providers.QtSyncProvider = require('./lib/qtsync');
-web3.eth.contract = require('./lib/contract');
-web3.abi = require('./lib/abi');
-
-
-module.exports = web3;
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/abi.js b/cmd/mist/assets/ext/ethereum.js/lib/abi.js
deleted file mode 100644
index 1a92bf5e6..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/abi.js
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- 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
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3');
-var utils = require('./utils');
-var types = require('./types');
-var c = require('./const');
-var f = require('./formatters');
-
-var displayTypeError = function (type) {
- console.error('parser does not support type: ' + type);
-};
-
-/// This method should be called if we want to check if givent type is an array type
-/// @returns true if it is, otherwise false
-var arrayType = function (type) {
- return type.slice(-2) === '[]';
-};
-
-var dynamicTypeBytes = function (type, value) {
- // TODO: decide what to do with array of strings
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return f.formatInputInt(value.length);
- return "";
-};
-
-var inputTypes = types.inputTypes();
-
-/// Formats input params to bytes
-/// @param abi contract method inputs
-/// @param array of params that will be formatted to bytes
-/// @returns bytes representation of input params
-var formatInput = function (inputs, params) {
- var bytes = "";
- var padding = c.ETH_PADDING * 2;
-
- /// first we iterate in search for dynamic
- inputs.forEach(function (input, index) {
- bytes += dynamicTypeBytes(input.type, params[index]);
- });
-
- inputs.forEach(function (input, i) {
- var typeMatch = false;
- for (var j = 0; j < inputTypes.length && !typeMatch; j++) {
- typeMatch = inputTypes[j].type(inputs[i].type, params[i]);
- }
- if (!typeMatch) {
- displayTypeError(inputs[i].type);
- }
-
- var formatter = inputTypes[j - 1].format;
- var toAppend = "";
-
- if (arrayType(inputs[i].type))
- toAppend = params[i].reduce(function (acc, curr) {
- return acc + formatter(curr);
- }, "");
- else
- toAppend = formatter(params[i]);
-
- bytes += toAppend;
- });
- return bytes;
-};
-
-var dynamicBytesLength = function (type) {
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return c.ETH_PADDING * 2;
- return 0;
-};
-
-var outputTypes = types.outputTypes();
-
-/// Formats output bytes back to param list
-/// @param contract abi method outputs
-/// @param bytes representtion of output
-/// @returns array of 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) {
- var typeMatch = false;
- for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
- typeMatch = outputTypes[j].type(outs[i].type);
- }
-
- if (!typeMatch) {
- displayTypeError(outs[i].type);
- }
-
- var formatter = outputTypes[j - 1].format;
- if (arrayType(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('string')(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;
-};
-
-/// @param json abi for contract
-/// @returns 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;
-};
-
-/// @param json abi for contract
-/// @returns 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;
-};
-
-/// @param function/event name for which we want to get signature
-/// @returns signature of function/event with given name
-var signatureFromAscii = function (name) {
- return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);
-};
-
-var eventSignatureFromAscii = function (name) {
- return web3.sha3(web3.fromAscii(name));
-};
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- formatInput: formatInput,
- formatOutput: formatOutput,
- signatureFromAscii: signatureFromAscii,
- eventSignatureFromAscii: eventSignatureFromAscii
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/const.js b/cmd/mist/assets/ext/ethereum.js/lib/const.js
deleted file mode 100644
index 8a17b794d..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/const.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- 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 const.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/// required to define ETH_BIGNUMBER_ROUNDING_MODE
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-}
-
-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 }
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/contract.js b/cmd/mist/assets/ext/ethereum.js/lib/contract.js
deleted file mode 100644
index a0525bd9d..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/contract.js
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- 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 contract.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3');
-var abi = require('./abi');
-var utils = require('./utils');
-var eventImpl = require('./event');
-
-var exportNatspecGlobals = function (vars) {
- // it's used byt natspec.js
- // TODO: figure out better way to solve this
- web3._currentContractAbi = vars.abi;
- web3._currentContractAddress = vars.address;
- web3._currentContractMethodName = vars.method;
- web3._currentContractMethodParams = vars.params;
-};
-
-var addFunctionRelatedPropertiesToContract = function (contract) {
-
- contract.call = function (options) {
- contract._isTransact = false;
- contract._options = options;
- return contract;
- };
-
- contract.transact = function (options) {
- contract._isTransact = true;
- contract._options = options;
- return contract;
- };
-
- contract._options = {};
- ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {
- contract[p] = function (v) {
- contract._options[p] = v;
- return contract;
- };
- });
-
-};
-
-var addFunctionsToContract = function (contract, desc, address) {
- var inputParser = abi.inputParser(desc);
- var outputParser = abi.outputParser(desc);
-
- // create contract functions
- utils.filterFunctions(desc).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);
- var signature = abi.signatureFromAscii(method.name);
- var parsed = inputParser[displayName][typeName].apply(null, params);
-
- var options = contract._options || {};
- options.to = address;
- options.data = signature + parsed;
-
- var isTransact = contract._isTransact === true || (contract._isTransact !== false && !method.constant);
- var collapse = options.collapse !== false;
-
- // reset
- contract._options = {};
- contract._isTransact = null;
-
- if (isTransact) {
-
- exportNatspecGlobals({
- abi: desc,
- address: address,
- method: method.name,
- params: params
- });
-
- // transactions do not have any output, cause we do not know, when they will be processed
- web3.eth.transact(options);
- return;
- }
-
- var output = web3.eth.call(options);
- var ret = outputParser[displayName][typeName](output);
- if (collapse)
- {
- if (ret.length === 1)
- ret = ret[0];
- else if (ret.length === 0)
- ret = null;
- }
- return ret;
- };
-
- if (contract[displayName] === undefined) {
- contract[displayName] = impl;
- }
-
- contract[displayName][typeName] = impl;
- });
-};
-
-var addEventRelatedPropertiesToContract = function (contract, desc, address) {
- contract.address = address;
- contract._onWatchEventResult = function (data) {
- var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));
- var parser = eventImpl.outputParser(matchingEvent);
- return parser(data);
- };
-
- Object.defineProperty(contract, 'topic', {
- get: function() {
- return utils.filterEvents(desc).map(function (e) {
- return abi.eventSignatureFromAscii(e.name);
- });
- }
- });
-
-};
-
-var addEventsToContract = function (contract, desc, address) {
- // create contract events
- utils.filterEvents(desc).forEach(function (e) {
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- var signature = abi.eventSignatureFromAscii(e.name);
- var event = eventImpl.inputParser(address, signature, e);
- var o = event.apply(null, params);
- o._onWatchEventResult = function (data) {
- var parser = eventImpl.outputParser(e);
- return parser(data);
- };
- return web3.eth.watch(o);
- };
-
- // this property should be used by eth.filter to check if object is an event
- impl._isEvent = true;
-
- var displayName = utils.extractDisplayName(e.name);
- var typeName = utils.extractTypeName(e.name);
-
- if (contract[displayName] === undefined) {
- contract[displayName] = impl;
- }
-
- contract[displayName][typeName] = impl;
-
- });
-};
-
-
-/**
- * This method should be called when we want to call / transact some solidity method from javascript
- * it returns an object which has same methods available as solidity contract description
- * usage example:
- *
- * var abi = [{
- * name: 'myMethod',
- * inputs: [{ name: 'a', type: 'string' }],
- * outputs: [{name: 'd', type: 'string' }]
- * }]; // contract abi
- *
- * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
- *
- * myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
- * myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)
- * myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
- *
- * @param address - address of the contract, which should be called
- * @param desc - abi json description of the contract, which is being created
- * @returns contract object
- */
-
-var contract = function (address, desc) {
-
- // workaround for invalid assumption that method.name is the full anonymous prototype of the method.
- // it's not. it's just the name. the rest of the code assumes it's actually the anonymous
- // prototype, so we make it so as a workaround.
- // TODO: we may not want to modify input params, maybe use copy instead?
- desc.forEach(function (method) {
- if (method.name.indexOf('(') === -1) {
- var displayName = method.name;
- var typeName = method.inputs.map(function(i){return i.type; }).join();
- method.name = displayName + '(' + typeName + ')';
- }
- });
-
- var result = {};
- addFunctionRelatedPropertiesToContract(result);
- addFunctionsToContract(result, desc, address);
- addEventRelatedPropertiesToContract(result, desc, address);
- addEventsToContract(result, desc, address);
-
- return result;
-};
-
-module.exports = contract;
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/event.js b/cmd/mist/assets/ext/ethereum.js/lib/event.js
deleted file mode 100644
index 0c41e0a39..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/event.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- 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 event.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var abi = require('./abi');
-var utils = require('./utils');
-
-/// filter inputs array && returns only indexed (or not) inputs
-/// @param inputs array
-/// @param bool if result should be an array of indexed params on not
-/// @returns array of (not?) indexed params
-var filterInputs = function (inputs, indexed) {
- return inputs.filter(function (current) {
- return current.indexed === indexed;
- });
-};
-
-var inputWithName = function (inputs, name) {
- var index = utils.findIndex(inputs, function (input) {
- return input.name === name;
- });
-
- if (index === -1) {
- console.error('indexed param with name ' + name + ' not found');
- return undefined;
- }
- return inputs[index];
-};
-
-var indexedParamsToTopics = function (event, indexed) {
- // sort keys?
- return Object.keys(indexed).map(function (key) {
- var inputs = [inputWithName(filterInputs(event.inputs, true), key)];
-
- var value = indexed[key];
- if (value instanceof Array) {
- return value.map(function (v) {
- return abi.formatInput(inputs, [v]);
- });
- }
- return abi.formatInput(inputs, [value]);
- });
-};
-
-var inputParser = function (address, signature, event) {
-
- // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'
- return function (indexed, options) {
- var o = options || {};
- o.address = address;
- o.topic = [];
- o.topic.push(signature);
- if (indexed) {
- o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));
- }
- return o;
- };
-};
-
-var getArgumentsObject = function (inputs, indexed, notIndexed) {
- var indexedCopy = indexed.slice();
- var notIndexedCopy = notIndexed.slice();
- return inputs.reduce(function (acc, current) {
- var value;
- if (current.indexed)
- value = indexed.splice(0, 1)[0];
- else
- value = notIndexed.splice(0, 1)[0];
-
- acc[current.name] = value;
- return acc;
- }, {});
-};
-
-var outputParser = function (event) {
-
- return function (output) {
- var result = {
- event: utils.extractDisplayName(event.name),
- number: output.number,
- args: {}
- };
-
- if (!output.topic) {
- return result;
- }
-
- var indexedOutputs = filterInputs(event.inputs, true);
- var indexedData = "0x" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join("");
- var indexedRes = abi.formatOutput(indexedOutputs, indexedData);
-
- var notIndexedOutputs = filterInputs(event.inputs, false);
- var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);
-
- result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);
-
- return result;
- };
-};
-
-var getMatchingEvent = function (events, payload) {
- for (var i = 0; i < events.length; i++) {
- var signature = abi.eventSignatureFromAscii(events[i].name);
- if (signature === payload.topic[0]) {
- return events[i];
- }
- }
- return undefined;
-};
-
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- getMatchingEvent: getMatchingEvent
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/filter.js b/cmd/mist/assets/ext/ethereum.js/lib/filter.js
deleted file mode 100644
index 6ab2b7edc..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/filter.js
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- 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 filter.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-
-/// should be used when we want to watch something
-/// it's using inner polling mechanism and is notified about changes
-/// TODO: change 'options' name cause it may be not the best matching one, since we have events
-var Filter = function(options, impl) {
-
- if (typeof options !== "string") {
-
- // topics property is deprecated, warn about it!
- if (options.topics) {
- console.warn('"topics" is deprecated, use "topic" instead');
- }
-
- this._onWatchResult = options._onWatchEventResult;
-
- // evaluate lazy properties
- options = {
- to: options.to,
- topic: options.topic,
- earliest: options.earliest,
- latest: options.latest,
- max: options.max,
- skip: options.skip,
- address: options.address
- };
-
- }
-
- this.impl = impl;
- this.callbacks = [];
-
- this.id = impl.newFilter(options);
- web3.provider.startPolling({method: impl.changed, params: [this.id]}, this.id, this.trigger.bind(this));
-};
-
-/// alias for changed*
-Filter.prototype.arrived = function(callback) {
- this.changed(callback);
-};
-Filter.prototype.happened = function(callback) {
- this.changed(callback);
-};
-
-/// gets called when there is new eth/shh message
-Filter.prototype.changed = function(callback) {
- this.callbacks.push(callback);
-};
-
-/// trigger calling new message from people
-Filter.prototype.trigger = function(messages) {
- for (var i = 0; i < this.callbacks.length; i++) {
- for (var j = 0; j < messages.length; j++) {
- var message = this._onWatchResult ? this._onWatchResult(messages[j]) : messages[j];
- this.callbacks[i].call(this, message);
- }
- }
-};
-
-/// should be called to uninstall current filter
-Filter.prototype.uninstall = function() {
- this.impl.uninstallFilter(this.id);
- web3.provider.stopPolling(this.id);
-};
-
-/// should be called to manually trigger getting latest messages from the client
-Filter.prototype.messages = function() {
- return this.impl.getMessages(this.id);
-};
-
-/// alias for messages
-Filter.prototype.logs = function () {
- return this.messages();
-};
-
-module.exports = Filter;
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/formatters.js b/cmd/mist/assets/ext/ethereum.js/lib/formatters.js
deleted file mode 100644
index 857a01a40..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/formatters.js
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- 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
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-}
-
-var utils = require('./utils');
-var c = require('./const');
-
-/// @param string string to be padded
-/// @param number of characters that result string should have
-/// @param sign, by default 0
-/// @returns right aligned string
-var padLeft = function (string, chars, sign) {
- return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
-};
-
-/// 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
-/// @returns right-aligned byte representation of int
-var formatInputInt = function (value) {
- var padding = c.ETH_PADDING * 2;
- if (value instanceof BigNumber || typeof value === 'number') {
- if (typeof value === 'number')
- value = new BigNumber(value);
- BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
- value = value.round();
-
- if (value.lessThan(0))
- value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
- value = value.toString(16);
- }
- else if (value.indexOf('0x') === 0)
- value = value.substr(2);
- else if (typeof value === 'string')
- value = formatInputInt(new BigNumber(value));
- else
- value = (+value).toString(16);
- return padLeft(value, padding);
-};
-
-/// Formats input value to byte representation of string
-/// @returns 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
-/// @returns 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
-/// @returns 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
-/// @param value is hex format
-/// @returns 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 input right-aligned input bytes to int
-/// @returns right-aligned input bytes formatted to int
-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 big right-aligned input bytes to uint
-/// @returns right-aligned input bytes formatted to uint
-var formatOutputUInt = function (value) {
- value = value || "0";
- return new BigNumber(value, 16);
-};
-
-/// @returns input bytes formatted to real
-var formatOutputReal = function (value) {
- return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns input bytes formatted to ureal
-var formatOutputUReal = function (value) {
- return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns right-aligned input bytes formatted to hex
-var formatOutputHash = function (value) {
- return "0x" + value;
-};
-
-/// @returns right-aligned input bytes formatted to bool
-var formatOutputBool = function (value) {
- return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
-};
-
-/// @returns left-aligned input bytes formatted to ascii string
-var formatOutputString = function (value) {
- return utils.toAscii(value);
-};
-
-/// @returns right-aligned input bytes formatted to 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
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/httpsync.js b/cmd/mist/assets/ext/ethereum.js/lib/httpsync.js
deleted file mode 100644
index 06e410ca8..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/httpsync.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- 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 httpsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-}
-
-var HttpSyncProvider = function (host) {
- this.handlers = [];
- this.host = host || 'http://localhost:8080';
-};
-
-HttpSyncProvider.prototype.send = function (payload) {
- //var data = formatJsonRpcObject(payload);
-
- var request = new XMLHttpRequest();
- request.open('POST', this.host, false);
- request.send(JSON.stringify(payload));
-
- // check request.status
- var result = request.responseText;
- return JSON.parse(result);
-};
-
-module.exports = HttpSyncProvider;
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/jsonrpc.js b/cmd/mist/assets/ext/ethereum.js/lib/jsonrpc.js
deleted file mode 100644
index b2d6922c0..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/jsonrpc.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- 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 jsonrpc.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-var messageId = 1;
-
-/// Should be called to valid json create payload object
-/// @param method of jsonrpc call, required
-/// @param params, an array of method params, optional
-/// @returns valid jsonrpc payload object
-var toPayload = function (method, params) {
- if (!method)
- console.error('jsonrpc method should be specified!');
-
- return {
- jsonrpc: '2.0',
- method: method,
- params: params || [],
- id: messageId++
- };
-};
-
-/// Should be called to check if jsonrpc response is valid
-/// @returns true if response is valid, otherwise false
-var isValidResponse = function (response) {
- return !!response &&
- !response.error &&
- response.jsonrpc === '2.0' &&
- typeof response.id === 'number' &&
- response.result !== undefined; // only undefined is not valid json object
-};
-
-/// Should be called to create batch payload object
-/// @param messages, an array of objects with method (required) and params (optional) fields
-var toBatchPayload = function (messages) {
- return messages.map(function (message) {
- return toPayload(message.method, message.params);
- });
-};
-
-module.exports = {
- toPayload: toPayload,
- isValidResponse: isValidResponse,
- toBatchPayload: toBatchPayload
-};
-
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/local.js b/cmd/mist/assets/ext/ethereum.js/lib/local.js
deleted file mode 100644
index 30cd14df2..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/local.js
+++ /dev/null
@@ -1,18 +0,0 @@
-var addressName = {"0x12378912345789": "Gav", "0x57835893478594739854": "Jeff"};
-var nameAddress = {};
-
-for (var prop in addressName) {
- if (addressName.hasOwnProperty(prop)) {
- nameAddress[addressName[prop]] = prop;
- }
-}
-
-var local = {
- addressBook:{
- byName: addressName,
- byAddress: nameAddress
- }
-};
-
-if (typeof(module) !== "undefined")
- module.exports = local;
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/providermanager.js b/cmd/mist/assets/ext/ethereum.js/lib/providermanager.js
deleted file mode 100644
index 55b072634..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/providermanager.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- 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 providermanager.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3');
-var jsonrpc = require('./jsonrpc');
-
-
-/**
- * Provider manager object prototype
- * It's responsible for passing messages to providers
- * If no provider is set it's responsible for queuing requests
- * It's also responsible for polling the ethereum node for incoming messages
- * Default poll timeout is 12 seconds
- * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling,
- * and provider manager polling mechanism is not used
- */
-var ProviderManager = function() {
- this.polls = [];
- this.provider = undefined;
-
- var self = this;
- var poll = function () {
- self.polls.forEach(function (data) {
- var result = self.send(data.data);
-
- if (!(result instanceof Array) || result.length === 0) {
- return;
- }
-
- data.callback(result);
- });
-
- setTimeout(poll, 1000);
- };
- poll();
-};
-
-/// sends outgoing requests
-/// @params data - an object with at least 'method' property
-ProviderManager.prototype.send = function(data) {
- var payload = jsonrpc.toPayload(data.method, data.params);
-
- if (this.provider === undefined) {
- console.error('provider is not set');
- return null;
- }
-
- var result = this.provider.send(payload);
-
- if (!jsonrpc.isValidResponse(result)) {
- console.log(result);
- return null;
- }
-
- return result.result;
-};
-
-/// setups provider, which will be used for sending messages
-ProviderManager.prototype.set = function(provider) {
- this.provider = provider;
-};
-
-/// this method is only used, when we do not have native qt bindings and have to do polling on our own
-/// should be callled, on start watching for eth/shh changes
-ProviderManager.prototype.startPolling = function (data, pollId, callback) {
- this.polls.push({data: data, id: pollId, callback: callback});
-};
-
-/// should be called to stop polling for certain watch changes
-ProviderManager.prototype.stopPolling = function (pollId) {
- for (var i = this.polls.length; i--;) {
- var poll = this.polls[i];
- if (poll.id === pollId) {
- this.polls.splice(i, 1);
- }
- }
-};
-
-module.exports = ProviderManager;
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/qtsync.js b/cmd/mist/assets/ext/ethereum.js/lib/qtsync.js
deleted file mode 100644
index 75dcb43ab..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/qtsync.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- 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 qtsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-var QtSyncProvider = function () {
-};
-
-QtSyncProvider.prototype.send = function (payload) {
- var result = navigator.qt.callMethod(JSON.stringify(payload));
- return JSON.parse(result);
-};
-
-module.exports = QtSyncProvider;
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/types.js b/cmd/mist/assets/ext/ethereum.js/lib/types.js
deleted file mode 100644
index a39f2f1fc..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/types.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- 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('hash'), format: f.formatInputInt },
- { type: prefixedType('string'), 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('hash'), format: f.formatOutputHash },
- { type: prefixedType('string'), 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
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/utils.js b/cmd/mist/assets/ext/ethereum.js/lib/utils.js
deleted file mode 100644
index 7cc1917e1..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/utils.js
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- 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
- */
-
-var c = require('./const');
-
-/// Finds first index of array element matching pattern
-/// @param array
-/// @param callback pattern
-/// @returns 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;
-};
-
-/// @returns ascii string representation of hex value prefixed with 0x
-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;
-};
-
-var toHex = 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;
-};
-
-/// @returns hex representation (prefixed by 0x) of ascii string
-var fromAscii = function(str, pad) {
- pad = pad === undefined ? 0 : pad;
- var hex = toHex(str);
- while (hex.length < pad*2)
- hex += "00";
- return "0x" + hex;
-};
-
-/// @returns 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(' ', '') : "";
-};
-
-/// Filters all function from input abi
-/// @returns abi array with filtered objects of type 'function'
-var filterFunctions = function (json) {
- return json.filter(function (current) {
- return current.type === 'function';
- });
-};
-
-/// Filters all events form input abi
-/// @returns abi array with filtered objects of type 'event'
-var filterEvents = function (json) {
- return json.filter(function (current) {
- return current.type === 'event';
- });
-};
-
-/// used to transform value/string to eth string
-/// TODO: use BigNumber.js to parse int
-/// TODO: add tests for it!
-var toEth = function (str) {
- var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
- var unit = 0;
- var units = c.ETH_UNITS;
- while (val > 3000 && unit < units.length - 1)
- {
- val /= 1000;
- unit++;
- }
- var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
- var replaceFunction = function($0, $1, $2) {
- return $1 + ',' + $2;
- };
-
- while (true) {
- var o = s;
- s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
- if (o === s)
- break;
- }
- return s + ' ' + units[unit];
-};
-
-module.exports = {
- findIndex: findIndex,
- toAscii: toAscii,
- fromAscii: fromAscii,
- extractDisplayName: extractDisplayName,
- extractTypeName: extractTypeName,
- filterFunctions: filterFunctions,
- filterEvents: filterEvents,
- toEth: toEth
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/lib/web3.js b/cmd/mist/assets/ext/ethereum.js/lib/web3.js
deleted file mode 100644
index 41df75051..000000000
--- a/cmd/mist/assets/ext/ethereum.js/lib/web3.js
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- 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 web3.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js');
-}
-
-var utils = require('./utils');
-
-/// @returns an array of objects describing web3 api methods
-var web3Methods = function () {
- return [
- { name: 'sha3', call: 'web3_sha3' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth api methods
-var ethMethods = function () {
- var blockCall = function (args) {
- return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber";
- };
-
- var transactionCall = function (args) {
- return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber';
- };
-
- var uncleCall = function (args) {
- return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber';
- };
-
- var methods = [
- { name: 'balanceAt', call: 'eth_balanceAt' },
- { name: 'stateAt', call: 'eth_stateAt' },
- { name: 'storageAt', call: 'eth_storageAt' },
- { name: 'countAt', call: 'eth_countAt'},
- { name: 'codeAt', call: 'eth_codeAt' },
- { name: 'transact', call: 'eth_transact' },
- { name: 'call', call: 'eth_call' },
- { name: 'block', call: blockCall },
- { name: 'transaction', call: transactionCall },
- { name: 'uncle', call: uncleCall },
- { name: 'compilers', call: 'eth_compilers' },
- { name: 'flush', call: 'eth_flush' },
- { name: 'lll', call: 'eth_lll' },
- { name: 'solidity', call: 'eth_solidity' },
- { name: 'serpent', call: 'eth_serpent' },
- { name: 'logs', call: 'eth_logs' }
- ];
- return methods;
-};
-
-/// @returns an array of objects describing web3.eth api properties
-var ethProperties = function () {
- return [
- { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },
- { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },
- { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },
- { name: 'gasPrice', getter: 'eth_gasPrice' },
- { name: 'accounts', getter: 'eth_accounts' },
- { name: 'peerCount', getter: 'eth_peerCount' },
- { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },
- { name: 'number', getter: 'eth_number'}
- ];
-};
-
-/// @returns an array of objects describing web3.db api methods
-var dbMethods = function () {
- return [
- { name: 'put', call: 'db_put' },
- { name: 'get', call: 'db_get' },
- { name: 'putString', call: 'db_putString' },
- { name: 'getString', call: 'db_getString' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh api methods
-var shhMethods = function () {
- return [
- { name: 'post', call: 'shh_post' },
- { name: 'newIdentity', call: 'shh_newIdentity' },
- { name: 'haveIdentity', call: 'shh_haveIdentity' },
- { name: 'newGroup', call: 'shh_newGroup' },
- { name: 'addToGroup', call: 'shh_addToGroup' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth.watch api methods
-var ethWatchMethods = function () {
- var newFilter = function (args) {
- return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';
- };
-
- return [
- { name: 'newFilter', call: newFilter },
- { name: 'uninstallFilter', call: 'eth_uninstallFilter' },
- { name: 'getMessages', call: 'eth_filterLogs' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh.watch api methods
-var shhWatchMethods = function () {
- return [
- { name: 'newFilter', call: 'shh_newFilter' },
- { name: 'uninstallFilter', call: 'shh_uninstallFilter' },
- { name: 'getMessages', call: 'shh_getMessages' }
- ];
-};
-
-/// creates methods in a given object based on method description on input
-/// setups api calls for these methods
-var setupMethods = function (obj, methods) {
- methods.forEach(function (method) {
- obj[method.name] = function () {
- var args = Array.prototype.slice.call(arguments);
- var call = typeof method.call === 'function' ? method.call(args) : method.call;
- return web3.provider.send({
- method: call,
- params: args
- });
- };
- });
-};
-
-/// creates properties in a given object based on properties description on input
-/// setups api calls for these properties
-var setupProperties = function (obj, properties) {
- properties.forEach(function (property) {
- var proto = {};
- proto.get = function () {
- return web3.provider.send({
- method: property.getter
- });
- };
-
- if (property.setter) {
- proto.set = function (val) {
- return web3.provider.send({
- method: property.setter,
- params: [val]
- });
- };
- }
- Object.defineProperty(obj, property.name, proto);
- });
-};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {
- _callbacks: {},
- _events: {},
- providers: {},
-
- /// @returns ascii string representation of hex value prefixed with 0x
- toAscii: utils.toAscii,
-
- /// @returns hex representation (prefixed by 0x) of ascii string
- fromAscii: utils.fromAscii,
-
- /// @returns decimal representaton of hex value prefixed by 0x
- toDecimal: function (val) {
- // remove 0x and place 0, if it's required
- val = val.length > 2 ? val.substring(2) : "0";
- return (new BigNumber(val, 16).toString(10));
- },
-
- /// @returns hex representation (prefixed by 0x) of decimal value
- fromDecimal: function (val) {
- return "0x" + (new BigNumber(val).toString(16));
- },
-
- /// used to transform value/string to eth string
- toEth: utils.toEth,
-
- /// eth object prototype
- eth: {
- contractFromAbi: function (abi) {
- return function(addr) {
- // Default to address of Config. TODO: rremove prior to genesis.
- addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
- var ret = web3.eth.contract(addr, abi);
- ret.address = addr;
- return ret;
- };
- },
-
- /// @param filter may be a string, object or event
- /// @param indexed is optional, this is an object with optional event indexed params
- /// @param options is optional, this is an object with optional event options ('max'...)
- watch: function (filter, indexed, options) {
- if (filter._isEvent) {
- return filter(indexed, options);
- }
- return new web3.filter(filter, ethWatch);
- }
- },
-
- /// db object prototype
- db: {},
-
- /// shh object prototype
- shh: {
-
- /// @param filter may be a string, object or event
- watch: function (filter, indexed) {
- return new web3.filter(filter, shhWatch);
- }
- },
-};
-
-/// setups all api methods
-setupMethods(web3, web3Methods());
-setupMethods(web3.eth, ethMethods());
-setupProperties(web3.eth, ethProperties());
-setupMethods(web3.db, dbMethods());
-setupMethods(web3.shh, shhMethods());
-
-var ethWatch = {
- changed: 'eth_changed'
-};
-
-setupMethods(ethWatch, ethWatchMethods());
-
-var shhWatch = {
- changed: 'shh_changed'
-};
-
-setupMethods(shhWatch, shhWatchMethods());
-
-web3.setProvider = function(provider) {
- web3.provider.set(provider);
-};
-
-module.exports = web3;
-
diff --git a/cmd/mist/assets/ext/ethereum.js/package.json b/cmd/mist/assets/ext/ethereum.js/package.json
deleted file mode 100644
index 8102a2592..000000000
--- a/cmd/mist/assets/ext/ethereum.js/package.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
- "name": "ethereum.js",
- "namespace": "ethereum",
- "version": "0.0.13",
- "description": "Ethereum Compatible JavaScript API",
- "main": "./index.js",
- "directories": {
- "lib": "./lib"
- },
- "dependencies": {
- "ws": "*",
- "xmlhttprequest": "*",
- "bignumber.js": ">=2.0.0"
- },
- "devDependencies": {
- "bower": ">=1.3.0",
- "browserify": ">=6.0",
- "del": ">=0.1.1",
- "envify": "^3.0.0",
- "exorcist": "^0.1.6",
- "gulp": ">=3.4.0",
- "gulp-jshint": ">=1.5.0",
- "gulp-rename": ">=1.2.0",
- "gulp-uglify": ">=1.0.0",
- "jshint": ">=2.5.0",
- "uglifyify": "^2.6.0",
- "unreachable-branch-transform": "^0.1.0",
- "vinyl-source-stream": "^1.0.0",
- "mocha": ">=2.1.0"
- },
- "scripts": {
- "build": "gulp",
- "watch": "gulp watch",
- "lint": "gulp lint",
- "test": "mocha"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ethereum/ethereum.js.git"
- },
- "homepage": "https://github.com/ethereum/ethereum.js",
- "bugs": {
- "url": "https://github.com/ethereum/ethereum.js/issues"
- },
- "keywords": [
- "ethereum",
- "javascript",
- "API"
- ],
- "author": "ethdev.com",
- "authors": [
- {
- "name": "Jeffery Wilcke",
- "email": "jeff@ethdev.com",
- "url": "https://github.com/obscuren"
- },
- {
- "name": "Marek Kotewicz",
- "email": "marek@ethdev.com",
- "url": "https://github.com/debris"
- },
- {
- "name": "Marian Oancea",
- "email": "marian@ethdev.com",
- "url": "https://github.com/cubedro"
- }
- ],
- "license": "LGPL-3.0"
-}
diff --git a/cmd/mist/assets/ext/ethereum.js/test/abi.parsers.js b/cmd/mist/assets/ext/ethereum.js/test/abi.parsers.js
deleted file mode 100644
index b7a05cea3..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/abi.parsers.js
+++ /dev/null
@@ -1,860 +0,0 @@
-var assert = require('assert');
-var BigNumber = require('bignumber.js');
-var abi = require('../lib/abi.js');
-var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
-
-var description = [{
- "name": "test",
- "inputs": [{
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
-}];
-
-describe('abi', function() {
- describe('inputParser', function() {
- it('should parse input uint', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input uint128', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint128" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input uint256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input int', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
- });
-
- it('should parse input int128', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int128" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input int256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input bool', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'bool' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(true), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(false), "0000000000000000000000000000000000000000000000000000000000000000");
-
- });
-
- it('should parse input hash', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
- it('should parse input hash256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
-
- it('should parse input hash160', function() {
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash160" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
- });
-
- it('should parse input address', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "address" }
- ];
-
- // when
- var parser = abi.inputParser(d)
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
- it('should parse input string', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "string" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(
- parser.test('hello'),
- "000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
- );
- assert.equal(
- parser.test('world'),
- "0000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000"
- );
- });
-
- it('should use proper method name', function () {
-
- // given
- var d = clone(description);
- d[0].name = 'helloworld(int)';
- d[0].inputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.helloworld(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.helloworld['int'](1), "0000000000000000000000000000000000000000000000000000000000000001");
-
- });
-
- it('should parse multiple methods', function () {
-
- // given
- var d = [{
- name: "test",
- inputs: [{ type: "int" }],
- outputs: [{ type: "int" }]
- },{
- name: "test2",
- inputs: [{ type: "string" }],
- outputs: [{ type: "string" }]
- }];
-
- // when
- var parser = abi.inputParser(d);
-
- //then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(
- parser.test2('hello'),
- "000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
- );
-
- });
-
- it('should parse input array of ints', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int[]" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(
- parser.test([5, 6]),
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006"
- );
- });
-
- it('should parse input real', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'real' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000");
- assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000");
- assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000");
- assert.equal(parser.test([-1]), "ffffffffffffffffffffffffffffffff00000000000000000000000000000000");
-
- });
-
- it('should parse input ureal', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'ureal' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000");
- assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000");
- assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000");
-
- });
-
- });
-
- describe('outputParser', function() {
- it('should parse output string', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: "string" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000")[0],
- 'hello'
- );
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[0],
- 'world'
- );
-
- });
-
- it('should parse output uint', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output uint256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output uint128', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint128' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output int', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output int256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output int128', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int128' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output hash', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output hash256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output hash160', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash160' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- // TODO shouldnt' the expected hash be shorter?
- });
-
- it('should parse output address', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'address' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output bool', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'bool' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], true);
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000000")[0], false);
-
-
- });
-
- it('should parse output real', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'real' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1);
- assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125);
- assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffff00000000000000000000000000000000")[0], -1);
-
- });
-
- it('should parse output ureal', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'ureal' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1);
- assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125);
- assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5);
-
- });
-
-
- it('should parse multiple output strings', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: "string" },
- { type: "string" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[0],
- 'hello'
- );
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[1],
- 'world'
- );
-
- });
-
- it('should use proper method name', function () {
-
- // given
- var d = clone(description);
- d[0].name = 'helloworld(int)';
- d[0].outputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.helloworld("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.helloworld['int']("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
-
- });
-
-
- it('should parse multiple methods', function () {
-
- // given
- var d = [{
- name: "test",
- inputs: [{ type: "int" }],
- outputs: [{ type: "int" }]
- },{
- name: "test2",
- inputs: [{ type: "string" }],
- outputs: [{ type: "string" }]
- }];
-
- // when
- var parser = abi.outputParser(d);
-
- //then
- assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test2("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000")[0],
- "hello"
- );
-
- });
-
- it('should parse output array', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'int[]' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006")[0][0],
- 5
- );
- assert.equal(parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006")[0][1],
- 6
- );
-
- });
-
- it('should parse 0x value', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'int' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x")[0], 0);
-
- });
-
- it('should parse 0x value', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'uint' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x")[0], 0);
-
- });
-
- });
-});
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/db.methods.js b/cmd/mist/assets/ext/ethereum.js/test/db.methods.js
deleted file mode 100644
index 2ad384579..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/db.methods.js
+++ /dev/null
@@ -1,14 +0,0 @@
-
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./test.utils.js');
-
-describe('web3', function() {
- describe('db', function() {
- u.methodExists(web3.db, 'put');
- u.methodExists(web3.db, 'get');
- u.methodExists(web3.db, 'putString');
- u.methodExists(web3.db, 'getString');
- });
-});
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/eth.methods.js b/cmd/mist/assets/ext/ethereum.js/test/eth.methods.js
deleted file mode 100644
index 8f10b441d..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/eth.methods.js
+++ /dev/null
@@ -1,34 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./test.utils.js');
-
-describe('web3', function() {
- describe('eth', function() {
- u.methodExists(web3.eth, 'balanceAt');
- u.methodExists(web3.eth, 'stateAt');
- u.methodExists(web3.eth, 'storageAt');
- u.methodExists(web3.eth, 'countAt');
- u.methodExists(web3.eth, 'codeAt');
- u.methodExists(web3.eth, 'transact');
- u.methodExists(web3.eth, 'call');
- u.methodExists(web3.eth, 'block');
- u.methodExists(web3.eth, 'transaction');
- u.methodExists(web3.eth, 'uncle');
- u.methodExists(web3.eth, 'compilers');
- u.methodExists(web3.eth, 'lll');
- u.methodExists(web3.eth, 'solidity');
- u.methodExists(web3.eth, 'serpent');
- u.methodExists(web3.eth, 'logs');
-
- u.propertyExists(web3.eth, 'coinbase');
- u.propertyExists(web3.eth, 'listening');
- u.propertyExists(web3.eth, 'mining');
- u.propertyExists(web3.eth, 'gasPrice');
- u.propertyExists(web3.eth, 'accounts');
- u.propertyExists(web3.eth, 'peerCount');
- u.propertyExists(web3.eth, 'defaultBlock');
- u.propertyExists(web3.eth, 'number');
- });
-});
-
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/mocha.opts b/cmd/mist/assets/ext/ethereum.js/test/mocha.opts
deleted file mode 100644
index c4a633d64..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/mocha.opts
+++ /dev/null
@@ -1,2 +0,0 @@
---reporter spec
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/shh.methods.js b/cmd/mist/assets/ext/ethereum.js/test/shh.methods.js
deleted file mode 100644
index 91ca3caba..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/shh.methods.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./test.utils.js');
-
-describe('web3', function() {
- describe('shh', function() {
- u.methodExists(web3.shh, 'post');
- u.methodExists(web3.shh, 'newIdentity');
- u.methodExists(web3.shh, 'haveIdentity');
- u.methodExists(web3.shh, 'newGroup');
- u.methodExists(web3.shh, 'addToGroup');
- });
-});
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/utils.js b/cmd/mist/assets/ext/ethereum.js/test/utils.js
deleted file mode 100644
index 8a1e9a0b6..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/utils.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var assert = require('assert');
-
-var methodExists = function (object, method) {
- it('should have method ' + method + ' implemented', function() {
- assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented');
- });
-};
-
-var propertyExists = function (object, property) {
- it('should have property ' + property + ' implemented', function() {
- assert.notEqual('undefined', typeof object[property], 'property ' + property + ' is not implemented');
- });
-};
-
-module.exports = {
- methodExists: methodExists,
- propertyExists: propertyExists
-};
-
diff --git a/cmd/mist/assets/ext/ethereum.js/test/web3.methods.js b/cmd/mist/assets/ext/ethereum.js/test/web3.methods.js
deleted file mode 100644
index 06de41da4..000000000
--- a/cmd/mist/assets/ext/ethereum.js/test/web3.methods.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./test.utils.js');
-
-describe('web3', function() {
- u.methodExists(web3, 'sha3');
- u.methodExists(web3, 'toAscii');
- u.methodExists(web3, 'fromAscii');
-});
-
diff --git a/cmd/mist/assets/qml/depricated_browser.qml b/cmd/mist/assets/qml/depricated_browser.qml
index 7056dbbf3..7fb1f2068 100644
--- a/cmd/mist/assets/qml/depricated_browser.qml
+++ b/cmd/mist/assets/qml/depricated_browser.qml
@@ -205,7 +205,7 @@ Rectangle {
itemSelector.popup()
}
}
- experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/lib/web3.js", "../ext/ethereum.js/lib/qt.js", "../ext/setup.js"]
+ experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/dist/ethereum.min.js", "../ext/setup.js"]
experimental.onMessageReceived: {
//console.log("[onMessageReceived]: ", message.data)
var data = JSON.parse(message.data)
diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go
index 2679e0f95..cc213b49a 100644
--- a/cmd/mist/ui_lib.go
+++ b/cmd/mist/ui_lib.go
@@ -149,7 +149,8 @@ func (self *UiLib) Compile(code string) (string, error) {
func (self *UiLib) Call(params map[string]interface{}) (string, error) {
object := mapToTxParams(params)
- return self.XEth.Execute(
+ return self.XEth.Call(
+ object["from"],
object["to"],
object["value"],
object["gas"],
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 2db071148..6bcd7e811 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -18,7 +18,6 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
@@ -194,7 +193,7 @@ func GetNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey) {
func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
return &eth.Config{
- Name: p2p.MakeName(clientID, version),
+ Name: ethutil.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
LogFile: ctx.GlobalString(LogFileFlag.Name),
LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
diff --git a/core/block_processor.go b/core/block_processor.go
index 7ac8a1bd2..f421c3539 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
+ "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
"gopkg.in/fatih/set.v0"
)
@@ -23,7 +24,8 @@ type PendingBlockEvent struct {
var statelogger = logger.NewLogger("BLOCK")
type BlockProcessor struct {
- db ethutil.Database
+ db ethutil.Database
+ extraDb ethutil.Database
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
// Canonical block chain
@@ -45,9 +47,10 @@ type BlockProcessor struct {
eventMux *event.TypeMux
}
-func NewBlockProcessor(db ethutil.Database, pow pow.PoW, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func NewBlockProcessor(db, extra ethutil.Database, pow pow.PoW, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
db: db,
+ extraDb: extra,
mem: make(map[string]*big.Int),
Pow: pow,
bc: chainManager,
@@ -75,21 +78,18 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
// If we are mining this block and validating we want to set the logs back to 0
statedb.EmptyLogs()
- txGas := new(big.Int).Set(tx.Gas())
-
cb := statedb.GetStateObject(coinbase.Address())
- st := NewStateTransition(NewEnv(statedb, self.bc, tx, block), tx, cb)
- _, err := st.TransitionState()
+ _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, block), tx, cb)
if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) {
+ // If the account is managed, remove the invalid nonce.
+ self.bc.TxState().RemoveNonce(tx.From(), tx.Nonce())
return nil, nil, err
}
- txGas.Sub(txGas, st.gas)
-
// Update the state with pending changes
- statedb.Update(txGas)
+ statedb.Update(nil)
- cumulative := new(big.Int).Set(usedGas.Add(usedGas, txGas))
+ cumulative := new(big.Int).Set(usedGas.Add(usedGas, gas))
receipt := types.NewReceipt(statedb.Root(), cumulative)
receipt.SetLogs(statedb.Logs())
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
@@ -102,7 +102,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
go self.eventMux.Post(logs)
}
- return receipt, txGas, err
+ return receipt, gas, err
}
func (self *BlockProcessor) ChainManager() *ChainManager {
return self.bc
@@ -230,6 +230,10 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// Remove transactions from the pool
sm.txpool.RemoveSet(block.Transactions())
+ for _, tx := range block.Transactions() {
+ putTx(sm.extraDb, tx)
+ }
+
chainlogger.Infof("processed block #%d (%x...)\n", header.Number, block.Hash()[0:4])
return td, nil
@@ -347,3 +351,12 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
return state.Logs(), nil
}
+
+func putTx(db ethutil.Database, tx *types.Transaction) {
+ rlpEnc, err := rlp.EncodeToBytes(tx)
+ if err != nil {
+ statelogger.Infoln("Failed encoding tx", err)
+ return
+ }
+ db.Put(tx.Hash(), rlpEnc)
+}
diff --git a/core/block_processor_test.go b/core/block_processor_test.go
index a031c2669..ad29404e1 100644
--- a/core/block_processor_test.go
+++ b/core/block_processor_test.go
@@ -14,7 +14,7 @@ func proc() (*BlockProcessor, *ChainManager) {
var mux event.TypeMux
chainMan := NewChainManager(db, db, &mux)
- return NewBlockProcessor(db, ezp.New(), nil, chainMan, &mux), chainMan
+ return NewBlockProcessor(db, db, ezp.New(), nil, chainMan, &mux), chainMan
}
func TestNumber(t *testing.T) {
diff --git a/core/chain_makers.go b/core/chain_makers.go
index b5c50dc3d..f140b5c7e 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -120,7 +120,7 @@ func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Dat
// block processor with fake pow
func newBlockProcessor(db ethutil.Database, txpool *TxPool, cman *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
- bman := NewBlockProcessor(db, FakePow{}, txpool, newChainManager(nil, eventMux, db), eventMux)
+ bman := NewBlockProcessor(db, db, FakePow{}, txpool, newChainManager(nil, eventMux, db), eventMux)
return bman
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 97c61395e..0b7dcf293 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -17,6 +17,9 @@ import (
var (
chainlogger = logger.NewLogger("CHAIN")
jsonlogger = logger.NewJsonLogger()
+
+ blockHashPre = []byte("block-hash-")
+ blockNumPre = []byte("block-num-")
)
type StateQuery interface {
@@ -68,9 +71,7 @@ func CalcGasLimit(parent, block *types.Block) *big.Int {
result := new(big.Int).Add(previous, curInt)
result.Div(result, big.NewInt(1024))
- min := big.NewInt(125000)
-
- return ethutil.BigMax(min, result)
+ return ethutil.BigMax(GenesisGasLimit, result)
}
type ChainManager struct {
@@ -88,7 +89,7 @@ type ChainManager struct {
lastBlockHash []byte
transState *state.StateDB
- txState *state.StateDB
+ txState *state.ManagedState
quit chan struct{}
}
@@ -97,7 +98,8 @@ func NewChainManager(blockDb, stateDb ethutil.Database, mux *event.TypeMux) *Cha
bc := &ChainManager{blockDb: blockDb, stateDb: stateDb, genesisBlock: GenesisBlock(stateDb), eventMux: mux, quit: make(chan struct{})}
bc.setLastBlock()
bc.transState = bc.State().Copy()
- bc.txState = bc.State().Copy()
+ // Take ownership of this particular state
+ bc.txState = state.ManageState(bc.State().Copy())
go bc.update()
return bc
@@ -146,17 +148,17 @@ func (self *ChainManager) TransState() *state.StateDB {
return self.transState
}
-func (self *ChainManager) TxState() *state.StateDB {
+func (self *ChainManager) TxState() *state.ManagedState {
self.tsmu.RLock()
defer self.tsmu.RUnlock()
return self.txState
}
-func (self *ChainManager) setTxState(state *state.StateDB) {
+func (self *ChainManager) setTxState(statedb *state.StateDB) {
self.tsmu.Lock()
defer self.tsmu.Unlock()
- self.txState = state
+ self.txState = state.ManageState(statedb)
}
func (self *ChainManager) setTransState(statedb *state.StateDB) {
@@ -166,9 +168,8 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) {
func (bc *ChainManager) setLastBlock() {
data, _ := bc.blockDb.Get([]byte("LastBlock"))
if len(data) != 0 {
- var block types.Block
- rlp.Decode(bytes.NewReader(data), &block)
- bc.currentBlock = &block
+ block := bc.GetBlock(data)
+ bc.currentBlock = block
bc.lastBlockHash = block.Hash()
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
@@ -221,7 +222,7 @@ func (bc *ChainManager) Reset() {
defer bc.mu.Unlock()
for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
- bc.blockDb.Delete(block.Hash())
+ bc.removeBlock(block)
}
// Prepare the genesis block
@@ -232,12 +233,16 @@ func (bc *ChainManager) Reset() {
bc.setTotalDifficulty(ethutil.Big("0"))
}
+func (bc *ChainManager) removeBlock(block *types.Block) {
+ bc.blockDb.Delete(append(blockHashPre, block.Hash()...))
+}
+
func (bc *ChainManager) ResetWithGenesisBlock(gb *types.Block) {
bc.mu.Lock()
defer bc.mu.Unlock()
for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
- bc.blockDb.Delete(block.Hash())
+ bc.removeBlock(block)
}
// Prepare the genesis block
@@ -262,15 +267,20 @@ func (self *ChainManager) Export() []byte {
}
func (bc *ChainManager) insert(block *types.Block) {
- encodedBlock := ethutil.Encode(block)
- bc.blockDb.Put([]byte("LastBlock"), encodedBlock)
+ //encodedBlock := ethutil.Encode(block)
+ bc.blockDb.Put([]byte("LastBlock"), block.Hash())
bc.currentBlock = block
bc.lastBlockHash = block.Hash()
+
+ key := append(blockNumPre, block.Number().Bytes()...)
+ bc.blockDb.Put(key, bc.lastBlockHash)
}
func (bc *ChainManager) write(block *types.Block) {
encodedBlock := ethutil.Encode(block.RlpDataForStorage())
- bc.blockDb.Put(block.Hash(), encodedBlock)
+
+ key := append(blockHashPre, block.Hash()...)
+ bc.blockDb.Put(key, encodedBlock)
}
// Accessors
@@ -280,7 +290,7 @@ func (bc *ChainManager) Genesis() *types.Block {
// Block fetching methods
func (bc *ChainManager) HasBlock(hash []byte) bool {
- data, _ := bc.blockDb.Get(hash)
+ data, _ := bc.blockDb.Get(append(blockHashPre, hash...))
return len(data) != 0
}
@@ -308,7 +318,7 @@ func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain
}
func (self *ChainManager) GetBlock(hash []byte) *types.Block {
- data, _ := self.blockDb.Get(hash)
+ data, _ := self.blockDb.Get(append(blockHashPre, hash...))
if len(data) == 0 {
return nil
}
@@ -321,6 +331,18 @@ func (self *ChainManager) GetBlock(hash []byte) *types.Block {
return &block
}
+func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block {
+ self.mu.RLock()
+ defer self.mu.RUnlock()
+
+ key, _ := self.blockDb.Get(append(blockNumPre, big.NewInt(int64(num)).Bytes()...))
+ if len(key) == 0 {
+ return nil
+ }
+
+ return self.GetBlock(key)
+}
+
func (self *ChainManager) GetUnclesInChain(block *types.Block, length int) (uncles []*types.Header) {
for i := 0; block != nil && i < length; i++ {
uncles = append(uncles, block.Uncles()...)
@@ -343,24 +365,6 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
return
}
-func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block {
- self.mu.RLock()
- defer self.mu.RUnlock()
-
- var block *types.Block
-
- if num <= self.currentBlock.Number().Uint64() {
- block = self.currentBlock
- for ; block != nil; block = self.GetBlock(block.Header().ParentHash) {
- if block.Header().Number.Uint64() == num {
- break
- }
- }
- }
-
- return block
-}
-
func (bc *ChainManager) setTotalDifficulty(td *big.Int) {
bc.blockDb.Put([]byte("LTD"), td.Bytes())
bc.td = td
@@ -414,9 +418,9 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
h := block.Header()
- chainlogger.Infof("block #%v process failed (%x)\n", h.Number, h.Hash()[:4])
- chainlogger.Infoln(block)
+ chainlogger.Infof("INVALID block #%v (%x)\n", h.Number, h.Hash()[:4])
chainlogger.Infoln(err)
+ chainlogger.Debugln(block)
return err
}
block.Td = td
@@ -450,6 +454,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
*/
self.setTransState(state.New(block.Root(), self.stateDb))
+ self.setTxState(state.New(block.Root(), self.stateDb))
+
queue[i] = ChainEvent{block}
queueEvent.canonicalCount++
} else {
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go
index 91822f9e2..898d37f9c 100644
--- a/core/chain_manager_test.go
+++ b/core/chain_manager_test.go
@@ -257,7 +257,7 @@ func TestChainInsertions(t *testing.T) {
var eventMux event.TypeMux
chainMan := NewChainManager(db, db, &eventMux)
txPool := NewTxPool(&eventMux)
- blockMan := NewBlockProcessor(db, nil, txPool, chainMan, &eventMux)
+ blockMan := NewBlockProcessor(db, db, nil, txPool, chainMan, &eventMux)
chainMan.SetProcessor(blockMan)
const max = 2
@@ -303,7 +303,7 @@ func TestChainMultipleInsertions(t *testing.T) {
var eventMux event.TypeMux
chainMan := NewChainManager(db, db, &eventMux)
txPool := NewTxPool(&eventMux)
- blockMan := NewBlockProcessor(db, nil, txPool, chainMan, &eventMux)
+ blockMan := NewBlockProcessor(db, db, nil, txPool, chainMan, &eventMux)
chainMan.SetProcessor(blockMan)
done := make(chan bool, max)
for i, chain := range chains {
diff --git a/core/error.go b/core/error.go
index 04e40646c..69e320eb0 100644
--- a/core/error.go
+++ b/core/error.go
@@ -78,7 +78,7 @@ func (err *NonceErr) Error() string {
}
func NonceError(is, exp uint64) *NonceErr {
- return &NonceErr{Message: fmt.Sprintf("Nonce err. Is %d, expected %d", is, exp), Is: is, Exp: exp}
+ return &NonceErr{Message: fmt.Sprintf("Transaction w/ invalid nonce (%d / %d)", is, exp), Is: is, Exp: exp}
}
func IsNonceErr(err error) bool {
diff --git a/core/execution.go b/core/execution.go
index 4a69cce09..be45eeeb4 100644
--- a/core/execution.go
+++ b/core/execution.go
@@ -25,10 +25,7 @@ func (self *Execution) Addr() []byte {
func (self *Execution) Call(codeAddr []byte, caller vm.ContextRef) ([]byte, error) {
// Retrieve the executing code
- var code []byte
- if self.env.State().GetStateObject(codeAddr) != nil {
- code = self.env.State().GetCode(codeAddr)
- }
+ code := self.env.State().GetCode(codeAddr)
return self.exec(code, codeAddr, caller)
}
@@ -62,7 +59,11 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret
snapshot := env.State().Copy()
start := time.Now()
- ret, err = evm.Run(to, caller, code, self.value, self.Gas, self.price, self.input)
+
+ context := vm.NewContext(caller, to, self.value, self.Gas, self.price)
+ context.SetCallCode(contextAddr, code)
+
+ ret, err = evm.Run(context, self.input) //self.value, self.Gas, self.price, self.input)
chainlogger.Debugf("vm took %v\n", time.Since(start))
if err != nil {
env.State().Set(snapshot)
diff --git a/core/genesis.go b/core/genesis.go
index a3f5dfb38..9c82a28c8 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -23,14 +23,14 @@ var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
var GenesisDiff = big.NewInt(131072)
+var GenesisGasLimit = big.NewInt(3141592)
func GenesisBlock(db ethutil.Database) *types.Block {
genesis := types.NewBlock(ZeroHash256, ZeroHash160, nil, GenesisDiff, 42, "")
genesis.Header().Number = ethutil.Big0
- genesis.Header().GasLimit = big.NewInt(1000000)
+ genesis.Header().GasLimit = GenesisGasLimit
genesis.Header().GasUsed = ethutil.Big0
genesis.Header().Time = 0
- genesis.Header().SeedHash = make([]byte, 32)
genesis.Header().MixDigest = make([]byte, 32)
genesis.Td = ethutil.Big0
diff --git a/core/state_transition.go b/core/state_transition.go
index 7659e3d50..f49aed874 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -69,6 +69,10 @@ func MessageGasValue(msg Message) *big.Int {
return new(big.Int).Mul(msg.Gas(), msg.GasPrice())
}
+func ApplyMessage(env vm.Environment, msg Message, coinbase *state.StateObject) ([]byte, *big.Int, error) {
+ return NewStateTransition(env, msg, coinbase).transitionState()
+}
+
func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateObject) *StateTransition {
return &StateTransition{
coinbase: coinbase.Address(),
@@ -144,13 +148,16 @@ func (self *StateTransition) preCheck() (err error) {
// Pre-pay gas / Buy gas of the coinbase account
if err = self.BuyGas(); err != nil {
+ if state.IsGasLimitErr(err) {
+ return err
+ }
return InvalidTxError(err)
}
return nil
}
-func (self *StateTransition) TransitionState() (ret []byte, err error) {
+func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, err error) {
// statelogger.Debugf("(~) %x\n", self.msg.Hash())
// XXX Transactions after this point are considered valid.
@@ -163,11 +170,9 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
sender = self.From()
)
- defer self.RefundGas()
-
// Transaction gas
if err = self.UseGas(vm.GasTx); err != nil {
- return nil, InvalidTxError(err)
+ return nil, nil, InvalidTxError(err)
}
// Increment the nonce for the next transaction
@@ -184,15 +189,13 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
}
}
if err = self.UseGas(big.NewInt(dgas)); err != nil {
- println("2")
- return nil, InvalidTxError(err)
+ return nil, nil, InvalidTxError(err)
}
- //stateCopy := self.env.State().Copy()
vmenv := self.env
var ref vm.ContextRef
if MessageCreatesContract(msg) {
- contract := MakeContract(msg, self.state)
+ contract := makeContract(msg, self.state)
ret, err, ref = vmenv.Create(sender, contract.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
if err == nil {
dataGas := big.NewInt(int64(len(ret)))
@@ -208,29 +211,22 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
}
if err != nil && IsValueTransferErr(err) {
- return nil, InvalidTxError(err)
+ return nil, nil, InvalidTxError(err)
}
- return
-}
-
-// Converts an transaction in to a state object
-func MakeContract(msg Message, state *state.StateDB) *state.StateObject {
- addr := AddressFromMessage(msg)
-
- contract := state.GetOrNewStateObject(addr)
- contract.SetInitCode(msg.Data())
+ self.refundGas()
+ self.state.AddBalance(self.coinbase, new(big.Int).Mul(self.gasUsed(), self.gasPrice))
- return contract
+ return ret, self.gasUsed(), err
}
-func (self *StateTransition) RefundGas() {
+func (self *StateTransition) refundGas() {
coinbase, sender := self.Coinbase(), self.From()
// Return remaining gas
remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice())
sender.AddBalance(remaining)
- uhalf := new(big.Int).Div(self.GasUsed(), ethutil.Big2)
+ uhalf := new(big.Int).Div(self.gasUsed(), ethutil.Big2)
for addr, ref := range self.state.Refunds() {
refund := ethutil.BigMin(uhalf, ref)
self.gas.Add(self.gas, refund)
@@ -240,6 +236,16 @@ func (self *StateTransition) RefundGas() {
coinbase.RefundGas(self.gas, self.msg.GasPrice())
}
-func (self *StateTransition) GasUsed() *big.Int {
+func (self *StateTransition) gasUsed() *big.Int {
return new(big.Int).Sub(self.initialGas, self.gas)
}
+
+// Converts an message in to a state object
+func makeContract(msg Message, state *state.StateDB) *state.StateObject {
+ addr := AddressFromMessage(msg)
+
+ contract := state.GetOrNewStateObject(addr)
+ contract.SetInitCode(msg.Data())
+
+ return contract
+}
diff --git a/core/types/block.go b/core/types/block.go
index f13a0b8f9..ba6ef6014 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -40,8 +40,6 @@ type Header struct {
Time uint64
// Extra data
Extra string
- // SeedHash used for light client verification
- SeedHash []byte
// Mix digest for quick checking to prevent DOS
MixDigest []byte
// Nonce
@@ -63,7 +61,6 @@ func (self *Header) rlpData(withNonce bool) []interface{} {
self.GasUsed,
self.Time,
self.Extra,
- self.SeedHash,
}
if withNonce {
fields = append(fields, self.MixDigest, self.Nonce)
@@ -202,7 +199,6 @@ func (self *Block) RlpDataForStorage() interface{} {
func (self *Block) Number() *big.Int { return self.header.Number }
func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() }
func (self *Block) MixDigest() []byte { return self.header.MixDigest }
-func (self *Block) SeedHash() []byte { return self.header.SeedHash }
func (self *Block) Nonce() uint64 {
return binary.BigEndian.Uint64(self.header.Nonce)
}
@@ -281,10 +277,9 @@ func (self *Header) String() string {
GasUsed: %v
Time: %v
Extra: %v
- SeedHash: %x
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.SeedHash, self.MixDigest, self.Nonce)
+ 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/eth/backend.go b/eth/backend.go
index 7a30902c9..346fc43bc 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -112,9 +112,10 @@ type Ethereum struct {
// Channel for shutting down the ethereum
shutdownChan chan bool
- // DB interface
- blockDb ethutil.Database
- stateDb ethutil.Database
+ // DB interfaces
+ blockDb ethutil.Database // Block chain database
+ stateDb ethutil.Database // State changes database
+ extraDb ethutil.Database // Extra database (txs, etc)
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
@@ -136,6 +137,7 @@ type Ethereum struct {
Mining bool
DataDir string
+ version string
}
func New(config *Config) (*Ethereum, error) {
@@ -154,6 +156,7 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
+ extraDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "extra"))
// Perform database sanity checks
d, _ := blockDb.Get([]byte("ProtocolVersion"))
@@ -162,24 +165,24 @@ func New(config *Config) (*Ethereum, error) {
path := path.Join(config.DataDir, "blockchain")
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path)
}
-
- saveProtocolVersion(blockDb)
- //ethutil.Config.Db = db
+ saveProtocolVersion(extraDb)
eth := &Ethereum{
shutdownChan: make(chan bool),
blockDb: blockDb,
stateDb: stateDb,
+ extraDb: extraDb,
eventMux: &event.TypeMux{},
logger: servlogger,
accountManager: config.AccountManager,
DataDir: config.DataDir,
+ version: config.Name, // TODO should separate from Name
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
eth.pow = ethash.New(eth.chainManager)
eth.txPool = core.NewTxPool(eth.EventMux())
- eth.blockProcessor = core.NewBlockProcessor(stateDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
+ eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
eth.miner = miner.New(eth, eth.pow, config.MinerThreads)
@@ -245,10 +248,12 @@ func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) BlockDb() ethutil.Database { return s.blockDb }
func (s *Ethereum) StateDb() ethutil.Database { return s.stateDb }
+func (s *Ethereum) ExtraDb() ethutil.Database { return s.extraDb }
func (s *Ethereum) IsListening() bool { return true } // Always listening
func (s *Ethereum) PeerCount() int { return s.net.PeerCount() }
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
+func (s *Ethereum) Version() string { return s.version }
// Start the ethereum
func (s *Ethereum) Start() error {
diff --git a/eth/protocol.go b/eth/protocol.go
index b9b485292..708e22087 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -14,7 +14,7 @@ import (
)
const (
- ProtocolVersion = 56
+ ProtocolVersion = 58
NetworkId = 0
ProtocolLength = uint64(8)
ProtocolMaxMsgSize = 10 * 1024 * 1024
diff --git a/ethutil/common.go b/ethutil/common.go
index 9b66763b8..29854c882 100644
--- a/ethutil/common.go
+++ b/ethutil/common.go
@@ -13,6 +13,13 @@ import (
"github.com/kardianos/osext"
)
+// MakeName creates a node name that follows the ethereum convention
+// for such names. It adds the operation system name and Go runtime version
+// the name.
+func MakeName(name, version string) string {
+ return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version())
+}
+
func DefaultAssetPath() string {
var assetPath string
pwd, _ := os.Getwd()
@@ -57,6 +64,19 @@ func DefaultDataDir() string {
return path.Join(usr.HomeDir, ".ethereum")
}
}
+
+func FromHex(s string) []byte {
+ if len(s) > 1 {
+ if s[0:2] == "0x" {
+ s = s[2:]
+ }
+ if len(s)%2 == 1 {
+ s = "0" + s
+ }
+ return Hex2Bytes(s)
+ }
+ return nil
+}
func IsWindows() bool {
return runtime.GOOS == "windows"
}
diff --git a/ethutil/common_test.go b/ethutil/common_test.go
index c2b6077e9..20064b1e7 100644
--- a/ethutil/common_test.go
+++ b/ethutil/common_test.go
@@ -1,8 +1,10 @@
package ethutil
import (
+ "bytes"
"math/big"
"os"
+ "testing"
checker "gopkg.in/check.v1"
)
@@ -66,3 +68,22 @@ func (s *CommonSuite) TestLarge(c *checker.C) {
c.Assert(adalarge, checker.Equals, "10000E7 Einstein")
c.Assert(weilarge, checker.Equals, "100 Babbage")
}
+
+//fromHex
+func TestFromHex(t *testing.T) {
+ input := "0x01"
+ expected := []byte{1}
+ result := FromHex(input)
+ if bytes.Compare(expected, result) != 0 {
+ t.Errorf("Expected % x got % x", expected, result)
+ }
+}
+
+func TestFromHexOddLength(t *testing.T) {
+ input := "0x1"
+ expected := []byte{1}
+ result := FromHex(input)
+ if bytes.Compare(expected, result) != 0 {
+ t.Errorf("Expected % x got % x", expected, result)
+ }
+}
diff --git a/ethutil/natspec/natspec_js.go b/ethutil/natspec/natspec_js.go
index 7acaaee4f..96d8204fb 100644
--- a/ethutil/natspec/natspec_js.go
+++ b/ethutil/natspec/natspec_js.go
@@ -1,3520 +1,4 @@
package natspec
-const natspecJS = `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){
-// shim for using process in browser
-
-var process = module.exports = {};
-var queue = [];
-var draining = false;
-
-function drainQueue() {
- if (draining) {
- return;
- }
- draining = true;
- var currentQueue;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- var i = -1;
- while (++i < len) {
- currentQueue[i]();
- }
- len = queue.length;
- }
- draining = false;
-}
-process.nextTick = function (fun) {
- queue.push(fun);
- if (!draining) {
- setTimeout(drainQueue, 0);
- }
-};
-
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-
-function noop() {}
-
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
-
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
-
-// TODO(shtylman)
-process.cwd = function () { return '/' };
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function() { return 0; };
-
-},{}],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 abi.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var utils = require('./utils');
-var types = require('./types');
-var c = require('./const');
-var f = require('./formatters');
-
-var displayTypeError = function (type) {
- console.error('parser does not support type: ' + type);
-};
-
-/// This method should be called if we want to check if givent type is an array type
-/// @returns true if it is, otherwise false
-var arrayType = function (type) {
- return type.slice(-2) === '[]';
-};
-
-var dynamicTypeBytes = function (type, value) {
- // TODO: decide what to do with array of strings
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return f.formatInputInt(value.length);
- return "";
-};
-
-var inputTypes = types.inputTypes();
-
-/// Formats input params to bytes
-/// @param abi contract method inputs
-/// @param array of 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) {
- displayTypeError(inputs[i].type);
- }
-
- var formatter = inputTypes[j - 1].format;
-
- if (arrayType(inputs[i].type))
- toAppendArrayContent += params[i].reduce(function (acc, curr) {
- return acc + formatter(curr);
- }, "");
- else if (inputs[i].type === 'string')
- toAppendArrayContent += formatter(params[i]);
- else
- toAppendConstant += formatter(params[i]);
- });
-
- bytes += toAppendConstant + toAppendArrayContent;
-
- return bytes;
-};
-
-var dynamicBytesLength = function (type) {
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return c.ETH_PADDING * 2;
- return 0;
-};
-
-var outputTypes = types.outputTypes();
-
-/// Formats output bytes back to param list
-/// @param contract abi method outputs
-/// @param bytes representtion of output
-/// @returns array of 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) {
- displayTypeError(outs[i].type);
- }
-
- var formatter = outputTypes[j - 1].format;
- if (arrayType(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('string')(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;
-};
-
-/// @param json abi for contract
-/// @returns 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;
-};
-
-/// @param json abi for contract
-/// @returns 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;
-};
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- formatInput: formatInput,
- formatOutput: formatOutput
-};
-
-},{"./const":4,"./formatters":5,"./types":6,"./utils":7}],4:[function(require,module,exports){
-(function (process){
-/*
- 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 const.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2015
- */
-
-/// required to define ETH_BIGNUMBER_ROUNDING_MODE
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-}
-
-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
-};
-
-
-}).call(this,require('_process'))
-},{"_process":2,"bignumber.js":8}],5:[function(require,module,exports){
-(function (process){
-/*
- 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
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-}
-
-var utils = require('./utils');
-var c = require('./const');
-
-/// @param string string to be padded
-/// @param number of characters that result string should have
-/// @param sign, by default 0
-/// @returns right aligned string
-var padLeft = function (string, chars, sign) {
- return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
-};
-
-/// 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
-/// @returns right-aligned byte representation of int
-var formatInputInt = function (value) {
- /*jshint maxcomplexity:7 */
- var padding = c.ETH_PADDING * 2;
- if (value instanceof BigNumber || typeof value === 'number') {
- if (typeof value === 'number')
- value = new BigNumber(value);
- BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
- value = value.round();
-
- if (value.lessThan(0))
- value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
- value = value.toString(16);
- }
- else if (value.indexOf('0x') === 0)
- value = value.substr(2);
- else if (typeof value === 'string')
- value = formatInputInt(new BigNumber(value));
- else
- value = (+value).toString(16);
- return padLeft(value, padding);
-};
-
-/// Formats input value to byte representation of string
-/// @returns 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
-/// @returns 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
-/// @returns 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
-/// @param value is hex format
-/// @returns 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 input right-aligned input bytes to int
-/// @returns right-aligned input bytes formatted to int
-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 big right-aligned input bytes to uint
-/// @returns right-aligned input bytes formatted to uint
-var formatOutputUInt = function (value) {
- value = value || "0";
- return new BigNumber(value, 16);
-};
-
-/// @returns input bytes formatted to real
-var formatOutputReal = function (value) {
- return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns input bytes formatted to ureal
-var formatOutputUReal = function (value) {
- return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns right-aligned input bytes formatted to hex
-var formatOutputHash = function (value) {
- return "0x" + value;
-};
-
-/// @returns right-aligned input bytes formatted to bool
-var formatOutputBool = function (value) {
- return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
-};
-
-/// @returns left-aligned input bytes formatted to ascii string
-var formatOutputString = function (value) {
- return utils.toAscii(value);
-};
-
-/// @returns right-aligned input bytes formatted to 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
-};
-
-
-}).call(this,require('_process'))
-},{"./const":4,"./utils":7,"_process":2,"bignumber.js":8}],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 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('hash'), format: f.formatInputInt },
- { type: prefixedType('string'), 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('hash'), format: f.formatOutputHash },
- { type: prefixedType('string'), 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":5}],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
- */
-
-var c = require('./const');
-
-/// Finds first index of array element matching pattern
-/// @param array
-/// @param callback pattern
-/// @returns 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;
-};
-
-/// @returns ascii string representation of hex value prefixed with 0x
-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;
-};
-
-var toHex = 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;
-};
-
-/// @returns hex representation (prefixed by 0x) of ascii string
-var fromAscii = function(str, pad) {
- pad = pad === undefined ? 0 : pad;
- var hex = toHex(str);
- while (hex.length < pad*2)
- hex += "00";
- return "0x" + hex;
-};
-
-/// @returns 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(' ', '') : "";
-};
-
-/// Filters all function from input abi
-/// @returns abi array with filtered objects of type 'function'
-var filterFunctions = function (json) {
- return json.filter(function (current) {
- return current.type === 'function';
- });
-};
-
-/// Filters all events form input abi
-/// @returns abi array with filtered objects of type 'event'
-var filterEvents = function (json) {
- return json.filter(function (current) {
- return current.type === 'event';
- });
-};
-
-/// used to transform value/string to eth string
-/// TODO: use BigNumber.js to parse int
-/// TODO: add tests for it!
-var toEth = function (str) {
- /*jshint maxcomplexity:7 */
- var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
- var unit = 0;
- var units = c.ETH_UNITS;
- while (val > 3000 && unit < units.length - 1)
- {
- val /= 1000;
- unit++;
- }
- var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
- var replaceFunction = function($0, $1, $2) {
- return $1 + ',' + $2;
- };
-
- while (true) {
- var o = s;
- s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
- if (o === s)
- break;
- }
- return s + ' ' + units[unit];
-};
-
-module.exports = {
- findIndex: findIndex,
- toAscii: toAscii,
- fromAscii: fromAscii,
- extractDisplayName: extractDisplayName,
- extractTypeName: extractTypeName,
- filterFunctions: filterFunctions,
- filterEvents: filterEvents,
- toEth: toEth
-};
-
-
-},{"./const":4}],8:[function(require,module,exports){
-/*! bignumber.js v2.0.3 https://github.com/MikeMcl/bignumber.js/LICENCE */
-
-;(function (global) {
- 'use strict';
-
- /*
- bignumber.js v2.0.3
- 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 ) );
-
- 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++;
-
- 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 ) {
- 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.
- cmp = compare( prod, rem, prodL, remL );
-
- // product > remainder.
- if ( cmp == 1 ) {
- n--;
-
- // Subtract divisor from product.
- subtract( prod, yL < prodL ? yz : yc, prodL, base );
- }
- } else {
-
- // 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, compare yc and rem again below.
- if ( n == 0 ) cmp = n = 1;
- prod = yc.slice();
- }
-
- prodL = prod.length;
- if ( prodL < remL ) prod.unshift(0);
-
- // Subtract product from remainder.
- subtract( rem, prod, remL, base );
-
- // If product was < previous remainder.
- if ( cmp == -1 ) {
- remL = rem.length;
-
- // Compare divisor and new remainder.
- cmp = compare( yc, rem, yL, remL );
-
- // If divisor < new remainder, subtract divisor from remainder.
- if ( cmp < 1 ) {
- n++;
-
- // Subtract divisor from remainder.
- subtract( rem, yL < remL ? yz : yc, remL, base );
- }
- }
- remL = rem.length;
- } else if ( cmp === 0 ) {
- n++;
- rem = [0];
- }
- // if cmp === 1, n will be 0
-
- // Add the next digit, n, to the result array.
- qc[i++] = n;
-
- // Update the remainder.
- if ( cmp && 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])(?=\w[\w.]*$)/i,
- var basePrefix = /^(-?)0([xbo])/i,
- dotAfter = /^([^.]+)\.$/,
- dotBefore = /^\.([^.]+)$/,
- isInfinityOrNaN = /^-?(Infinity|NaN)$/,
-// whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
- whitespaceOrPlus = /^\s*\+[\w.]|^\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/ethereum.js/lib/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
- var copyToContext = function (obj, context) {
- Object.keys(obj).forEach(function (key) {
- context[key] = obj[key];
- });
- }
-
- /// generate codes, which will be evaluated
- 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
- /// @param contract's abi
- /// @param name of the method that we are looking for
- var getMethodWithName = function(abi, name) {
- return abi.filter(function (method) {
- return method.name === name;
- })[0];
- };
-
- /// Function called to get all contract method input variables
- /// @returns hashmap 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 to evaluate expression
- var mapExpressionsToEvaluate = function (expression, cb) {
- var evaluatedExpression = "";
-
- // match everything in backtick
- var pattern = /\` + "`" + `(?:\\.|[^` + "`" + `\\])*\` + "`" + `/gim
- var match;
- var lastIndex = 0;
- 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);
-
- return evaluatedExpression;
- };
-
- /// Should be called to evaluate single expression
- /// Is internally using javascript's 'eval' method
- /// @param expression which should be evaluated
- /// @param [call] object containing contract abi, transaction, called method
- /// TODO: separate evaluation from getting input params, so as not to spoil 'evaluateExpression' function
- 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) {
- return "Natspec evaluation failed, wrong input params";
- }
- }
-
- var code = generateCode(context);
-
- var evaluatedExpression = mapExpressionsToEvaluate(expression, function (toEval) {
- try {
- var fn = new Function("context", code + "return " + toEval + ";");
- return fn(context).toString();
- }
- catch (err) {
- return 'undefined';
- }
- });
-
- return evaluatedExpression;
- };
-
- return {
- evaluateExpression: evaluateExpression
- };
-
-})();
-
-module.exports = natspec;
-
-
-},{"./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}]},{},[]);
+//# sourceMappingURL=natspec.js.map`
diff --git a/ethutil/natspec/natspec_test.go b/ethutil/natspec/natspec_test.go
index 498f8d78e..330dc831d 100644
--- a/ethutil/natspec/natspec_test.go
+++ b/ethutil/natspec/natspec_test.go
@@ -69,22 +69,22 @@ func TestNotice(t *testing.T) {
}
// 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)
+ badDesc := "Will multiply `e` by 7 and return `a * 7`."
+ notice, err = ns.Notice(tx, abi, method, badDesc)
- // expected = "natspec.js error evaluating expression: wrong input param in expression ''"
+ expected = "natspec.js error evaluating expression: Error: Natspec evaluation failed, wrong input params"
- // if err == nil {
- // 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)
- // }
- // }
+ if err == nil {
+ 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)
+ }
+ }
notice, err = ns.Notice(tx, abi, "missing_method", desc)
- expected = "natspec.js error evaluating expression: wrong input params in expression 'Will multiply `a` by 7 and return `a * 7`.'"
+ expected = "natspec.js error evaluating expression: Error: Natspec evaluation failed, method does not exist"
if err == nil {
t.Errorf("expected error, got nothing (notice: '%v')", notice)
diff --git a/miner/worker.go b/miner/worker.go
index 61091f3c0..5c4a13698 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -7,7 +7,6 @@ import (
"sync"
"time"
- "github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
@@ -154,7 +153,6 @@ func (self *worker) wait() {
if block.Number().Uint64() == work.Number && block.Nonce() == 0 {
self.current.block.SetNonce(work.Nonce)
self.current.block.Header().MixDigest = work.MixDigest
- self.current.block.Header().SeedHash = work.SeedHash
jsonlogger.LogJson(&logger.EthMinerNewBlock{
BlockHash: ethutil.Bytes2Hex(block.Hash()),
@@ -191,8 +189,6 @@ func (self *worker) commitNewWork() {
defer self.mu.Unlock()
block := self.chain.NewBlock(self.coinbase)
- seednum := ethash.GetSeedBlockNum(block.NumberU64())
- block.Header().SeedHash = self.chain.GetBlockByNumber(seednum).SeedHash()
self.current = env(block, self.eth)
parent := self.chain.GetBlock(self.current.block.ParentHash())
@@ -205,22 +201,21 @@ func (self *worker) commitNewWork() {
// Keep track of transactions which return errors so they can be removed
var remove types.Transactions
gasLimit:
- for _, tx := range transactions {
+ for i, tx := range transactions {
err := self.commitTransaction(tx)
switch {
case core.IsNonceErr(err):
fallthrough
case core.IsInvalidTxErr(err):
// Remove invalid transactions
+ self.chain.TxState().RemoveNonce(tx.From(), tx.Nonce())
remove = append(remove, tx)
+ minerlogger.Infof("TX (%x) failed. Transaction will be removed\n", tx.Hash()[:4])
case state.IsGasLimitErr(err):
+ minerlogger.Infof("Gas limit reached for block. %d TXs included in this block\n", i)
// Break on gas limit
break gasLimit
}
-
- if err != nil {
- minerlogger.Infoln(err)
- }
}
self.eth.TxPool().RemoveSet(remove)
@@ -261,7 +256,6 @@ func (self *worker) commitUncle(uncle *types.Header) error {
func (self *worker) commitTransaction(tx *types.Transaction) error {
snap := self.current.state.Copy()
- //fmt.Printf("proc %x %v\n", tx.Hash()[:3], tx.Nonce())
receipt, _, err := self.proc.ApplyTransaction(self.current.coinbase, self.current.state, self.current.block, tx, self.current.totalUsedGas, true)
if err != nil && (core.IsNonceErr(err) || state.IsGasLimitErr(err) || core.IsInvalidTxErr(err)) {
self.current.state.Set(snap)
diff --git a/p2p/server.go b/p2p/server.go
index 34000cb4c..9762fcc6d 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"net"
- "runtime"
"sync"
"time"
@@ -33,13 +32,6 @@ const (
var srvlog = logger.NewLogger("P2P Server")
var srvjslog = logger.NewJsonLogger()
-// MakeName creates a node name that follows the ethereum convention
-// for such names. It adds the operation system name and Go runtime version
-// the name.
-func MakeName(name, version string) string {
- return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version())
-}
-
// Server manages all peer connections.
//
// The fields of Server are used as configuration parameters.
@@ -54,7 +46,7 @@ type Server struct {
MaxPeers int
// Name sets the node name of this server.
- // Use MakeName to create a name that follows existing conventions.
+ // Use ethutil.MakeName to create a name that follows existing conventions.
Name string
// Bootstrap nodes are used to establish connectivity
diff --git a/pow/block.go b/pow/block.go
index 3bc63978b..136e4bf8d 100644
--- a/pow/block.go
+++ b/pow/block.go
@@ -11,7 +11,6 @@ type Block interface {
HashNoNonce() []byte
Nonce() uint64
MixDigest() []byte
- SeedHash() []byte
NumberU64() uint64
}
diff --git a/rpc/api.go b/rpc/api.go
index 8bbe80bd8..2137de356 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -23,7 +23,7 @@ import (
var (
defaultGasPrice = big.NewInt(150000000000)
defaultGas = big.NewInt(500000)
- filterTickerTime = 15 * time.Second
+ filterTickerTime = 5 * time.Minute
)
type EthereumApi struct {
@@ -167,13 +167,16 @@ func (self *EthereumApi) NewFilter(args *FilterOptions, reply *interface{}) erro
}
func (self *EthereumApi) UninstallFilter(id int, reply *interface{}) error {
- delete(self.logs, id)
+ if _, ok := self.logs[id]; ok {
+ delete(self.logs, id)
+ }
+
self.filterManager.UninstallFilter(id)
*reply = true
return nil
}
-func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error {
+func (self *EthereumApi) NewFilterString(args *FilterStringArgs, reply *interface{}) error {
var id int
filter := core.NewFilter(self.xeth().Backend())
@@ -183,10 +186,14 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
self.logs[id].add(&state.StateLog{})
}
- if args == "pending" {
+
+ switch args.Word {
+ case "pending":
filter.PendingCallback = callback
- } else if args == "chain" {
+ case "latest":
filter.BlockCallback = callback
+ default:
+ return NewValidationError("Word", "Must be `latest` or `pending`")
}
id = self.filterManager.InstallFilter(filter)
@@ -234,7 +241,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
// p.register[args.From] = append(p.register[args.From], args)
//} else {
/*
- account := accounts.Get(fromHex(args.From))
+ account := accounts.Get(ethutil.FromHex(args.From))
if account != nil {
if account.Unlocked() {
if !unlockAccount(account) {
@@ -242,7 +249,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
}
}
- result, _ := account.Transact(fromHex(args.To), fromHex(args.Value), fromHex(args.Gas), fromHex(args.GasPrice), fromHex(args.Data))
+ result, _ := account.Transact(ethutil.FromHex(args.To), ethutil.FromHex(args.Value), ethutil.FromHex(args.Gas), ethutil.FromHex(args.GasPrice), ethutil.FromHex(args.Data))
if len(result) > 0 {
*reply = toHex(result)
}
@@ -377,7 +384,13 @@ func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface
}
id = p.xeth().Whisper().Watch(opts)
p.messages[id] = &whisperFilter{timeout: time.Now()}
- *reply = id
+ *reply = toHex(big.NewInt(int64(id)).Bytes())
+ return nil
+}
+
+func (p *EthereumApi) UninstallWhisperFilter(id int, reply *interface{}) error {
+ delete(p.messages, id)
+ *reply = true
return nil
}
@@ -412,6 +425,14 @@ func (p *EthereumApi) WhisperMessages(id int, reply *interface{}) error {
return nil
}
+func (p *EthereumApi) GetTransactionByHash(hash string, reply *interface{}) error {
+ tx := p.xeth().EthTransactionByHash(hash)
+ if tx != nil {
+ *reply = NewTransactionRes(tx)
+ }
+ return nil
+}
+
func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) {
block := p.xeth().EthBlockByHash(blockhash)
br := NewBlockRes(block)
@@ -459,13 +480,23 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- *reply = toHex(crypto.Sha3(fromHex(args.Data)))
+ *reply = toHex(crypto.Sha3(ethutil.FromHex(args.Data)))
+ case "web3_clientVersion":
+ *reply = p.xeth().Backend().Version()
+ case "net_version":
+ return NewNotImplementedError(req.Method)
case "net_listening":
*reply = p.xeth().IsListening()
case "net_peerCount":
*reply = toHex(big.NewInt(int64(p.xeth().PeerCount())).Bytes())
case "eth_coinbase":
- *reply = p.xeth().Coinbase()
+ // TODO handling of empty coinbase due to lack of accounts
+ res := p.xeth().Coinbase()
+ if res == "0x" || res == "0x0" {
+ *reply = nil
+ } else {
+ *reply = res
+ }
case "eth_mining":
*reply = p.xeth().IsMining()
case "eth_gasPrice":
@@ -542,7 +573,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
*reply = toHex(big.NewInt(v).Bytes())
- case "eth_getData":
+ case "eth_getData", "eth_getCode":
args := new(GetDataArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
@@ -561,7 +592,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return p.Call(args, reply)
case "eth_flush":
- return errNotImplemented
+ return NewNotImplementedError(req.Method)
case "eth_getBlockByHash":
args := new(GetBlockByHashArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -585,19 +616,23 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
*reply = v
case "eth_getTransactionByHash":
- return errNotImplemented
+ // HashIndexArgs used, but only the "Hash" part we need.
+ args := new(HashIndexArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ }
+ return p.GetTransactionByHash(args.Hash, reply)
case "eth_getTransactionByBlockHashAndIndex":
args := new(HashIndexArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- v, err := p.GetBlockByHash(args.BlockHash, true)
+ v, err := p.GetBlockByHash(args.Hash, true)
if err != nil {
return err
}
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
+ return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
case "eth_getTransactionByBlockNumberAndIndex":
@@ -611,7 +646,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Transaction index does not exist")
+ return NewValidationError("Index", "does not exist")
}
*reply = v.Transactions[args.Index]
case "eth_getUncleByBlockHashAndIndex":
@@ -620,12 +655,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
- v, err := p.GetBlockByHash(args.BlockHash, false)
+ v, err := p.GetBlockByHash(args.Hash, false)
if err != nil {
return err
}
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ return NewValidationError("Index", "does not exist")
}
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
@@ -644,7 +679,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
- return NewErrorWithMessage(errDecodeArgs, "Uncle index does not exist")
+ return NewValidationError("Index", "does not exist")
}
uncle, err := p.GetBlockByHash(toHex(v.Uncles[args.Index]), false)
@@ -654,10 +689,8 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
*reply = uncle
case "eth_getCompilers":
return p.GetCompilers(reply)
- case "eth_compileSolidity":
- case "eth_compileLLL":
- case "eth_compileSerpent":
- return errNotImplemented
+ case "eth_compileSolidity", "eth_compileLLL", "eth_compileSerpent":
+ return NewNotImplementedError(req.Method)
case "eth_newFilter":
args := new(FilterOptions)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -669,7 +702,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- return p.NewFilterString(args.Word, reply)
+ return p.NewFilterString(args, reply)
case "eth_uninstallFilter":
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -694,21 +727,22 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.AllLogs(args, reply)
- case "eth_getWork":
- case "eth_submitWork":
- return errNotImplemented
- case "db_put":
+ case "eth_getWork", "eth_submitWork":
+ return NewNotImplementedError(req.Method)
+ case "db_putString":
args := new(DbArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
return p.DbPut(args, reply)
- case "db_get":
+ case "db_getString":
args := new(DbArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
return p.DbGet(args, reply)
+ case "db_putHex", "db_getHex":
+ return NewNotImplementedError(req.Method)
case "shh_post":
args := new(WhisperMessageArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -723,9 +757,8 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.HasWhisperIdentity(args.Identity, reply)
- case "shh_newGroup":
- case "shh_addToGroup":
- return errNotImplemented
+ case "shh_newGroup", "shh_addToGroup":
+ return NewNotImplementedError(req.Method)
case "shh_newFilter":
args := new(WhisperFilterArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -733,7 +766,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return p.NewWhisperFilter(args, reply)
case "shh_uninstallFilter":
- return errNotImplemented
+ args := new(FilterIdArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+ return p.UninstallWhisperFilter(args.Id, reply)
case "shh_getFilterChanges":
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -765,7 +802,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
// }
// return p.WatchTx(args, reply)
default:
- return NewErrorWithMessage(errNotImplemented, req.Method)
+ return NewNotImplementedError(req.Method)
}
rpclogger.DebugDetailf("Reply: %T %s", reply, reply)
@@ -784,12 +821,12 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions {
// Convert optional address slice/string to byte slice
if str, ok := options.Address.(string); ok {
- opts.Address = [][]byte{fromHex(str)}
+ opts.Address = [][]byte{ethutil.FromHex(str)}
} else if slice, ok := options.Address.([]interface{}); ok {
bslice := make([][]byte, len(slice))
for i, addr := range slice {
if saddr, ok := addr.(string); ok {
- bslice[i] = fromHex(saddr)
+ bslice[i] = ethutil.FromHex(saddr)
}
}
opts.Address = bslice
@@ -803,11 +840,11 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions {
if slice, ok := topicDat.([]interface{}); ok {
topics[i] = make([][]byte, len(slice))
for j, topic := range slice {
- topics[i][j] = fromHex(topic.(string))
+ topics[i][j] = ethutil.FromHex(topic.(string))
}
} else if str, ok := topicDat.(string); ok {
topics[i] = make([][]byte, 1)
- topics[i][0] = fromHex(str)
+ topics[i][0] = ethutil.FromHex(str)
}
}
opts.Topics = topics
diff --git a/rpc/args.go b/rpc/args.go
index d4d807060..b935c5007 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -11,7 +11,7 @@ import (
func blockNumber(raw json.RawMessage, number *int64) (err error) {
var str string
if err = json.Unmarshal(raw, &str); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
switch str {
@@ -34,16 +34,16 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
argstr, ok := obj[0].(string)
if !ok {
- return errDecodeArgs
+ return NewDecodeParamError("BlockHash not a string")
}
args.BlockHash = argstr
@@ -63,11 +63,11 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
if v, ok := obj[0].(float64); ok {
@@ -117,7 +117,7 @@ type GetStorageArgs struct {
func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
return nil
@@ -125,7 +125,7 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
func (args *GetStorageArgs) requirements() error {
if len(args.Address) == 0 {
- return NewErrorWithMessage(errArguments, "Address cannot be blank")
+ return NewValidationError("Address", "cannot be blank")
}
return nil
}
@@ -139,10 +139,10 @@ type GetStorageAtArgs struct {
func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
var obj []string
if err = UnmarshalRawMessages(b, &obj, &args.BlockNumber); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 2 {
- return errDecodeArgs
+ return NewInsufficientParamsError(len(obj), 2)
}
args.Address = obj[0]
@@ -153,11 +153,11 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
func (args *GetStorageAtArgs) requirements() error {
if len(args.Address) == 0 {
- return NewErrorWithMessage(errArguments, "Address cannot be blank")
+ return NewValidationError("Address", "cannot be blank")
}
if len(args.Key) == 0 {
- return NewErrorWithMessage(errArguments, "Key cannot be blank")
+ return NewValidationError("Key", "cannot be blank")
}
return nil
}
@@ -169,7 +169,7 @@ type GetTxCountArgs struct {
func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
return nil
@@ -177,7 +177,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
func (args *GetTxCountArgs) requirements() error {
if len(args.Address) == 0 {
- return NewErrorWithMessage(errArguments, "Address cannot be blank")
+ return NewValidationError("Address", "cannot be blank")
}
return nil
}
@@ -188,16 +188,40 @@ type GetBalanceArgs struct {
}
func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
- if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
- return errDecodeArgs
+ var obj []interface{}
+ r := bytes.NewReader(b)
+ if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ return NewDecodeParamError(err.Error())
}
+ if len(obj) < 1 {
+ return NewInsufficientParamsError(len(obj), 1)
+ }
+
+ addstr, ok := obj[0].(string)
+ if !ok {
+ return NewDecodeParamError("Address is not a string")
+ }
+ args.Address = addstr
+
+ if len(obj) > 1 {
+ if obj[1].(string) == "latest" {
+ args.BlockNumber = -1
+ } else {
+ args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()
+ }
+ }
+
+ // if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
+ // return NewDecodeParamError(err.Error())
+ // }
+
return nil
}
func (args *GetBalanceArgs) requirements() error {
if len(args.Address) == 0 {
- return NewErrorWithMessage(errArguments, "Address cannot be blank")
+ return NewValidationError("Address", "cannot be blank")
}
return nil
}
@@ -209,7 +233,7 @@ type GetDataArgs struct {
func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
return nil
@@ -217,7 +241,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
func (args *GetDataArgs) requirements() error {
if len(args.Address) == 0 {
- return NewErrorWithMessage(errArguments, "Address cannot be blank")
+ return NewValidationError("Address", "cannot be blank")
}
return nil
}
@@ -227,9 +251,65 @@ type BlockNumIndexArgs struct {
Index int64
}
+func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ r := bytes.NewReader(b)
+ if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return NewInsufficientParamsError(len(obj), 1)
+ }
+
+ arg0, ok := obj[0].(string)
+ if !ok {
+ return NewDecodeParamError("BlockNumber is not string")
+ }
+ args.BlockNumber = ethutil.Big(arg0).Int64()
+
+ if len(obj) > 1 {
+ arg1, ok := obj[1].(string)
+ if !ok {
+ return NewDecodeParamError("Index not a string")
+ }
+ args.Index = ethutil.Big(arg1).Int64()
+ }
+
+ return nil
+}
+
type HashIndexArgs struct {
- BlockHash string
- Index int64
+ Hash string
+ Index int64
+}
+
+func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ r := bytes.NewReader(b)
+ if err := json.NewDecoder(r).Decode(&obj); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return NewInsufficientParamsError(len(obj), 1)
+ }
+
+ arg0, ok := obj[0].(string)
+ if !ok {
+ return NewDecodeParamError("Hash not a string")
+ }
+ args.Hash = arg0
+
+ if len(obj) > 1 {
+ arg1, ok := obj[1].(string)
+ if !ok {
+ return NewDecodeParamError("Index not a string")
+ }
+ args.Index = ethutil.Big(arg1).Int64()
+ }
+
+ return nil
}
type Sha3Args struct {
@@ -240,11 +320,11 @@ func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return NewErrorWithMessage(errDecodeArgs, err.Error())
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
args.Data = obj[0].(string)
@@ -307,12 +387,13 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
}
if err = json.Unmarshal(b, &obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
+
args.Earliest = int64(ethutil.Big(obj[0].FromBlock).Int64())
args.Latest = int64(ethutil.Big(obj[0].ToBlock).Int64())
args.Max = int(ethutil.Big(obj[0].Limit).Int64())
@@ -337,11 +418,11 @@ func (args *DbArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 2 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 2)
}
args.Database = obj[0].(string)
args.Key = obj[1].(string)
@@ -355,10 +436,10 @@ func (args *DbArgs) UnmarshalJSON(b []byte) (err error) {
func (a *DbArgs) requirements() error {
if len(a.Database) == 0 {
- return NewErrorWithMessage(errArguments, "Database cannot be blank")
+ return NewValidationError("Database", "cannot be blank")
}
if len(a.Key) == 0 {
- return NewErrorWithMessage(errArguments, "Key cannot be blank")
+ return NewValidationError("Key", "cannot be blank")
}
return nil
}
@@ -383,11 +464,11 @@ func (args *WhisperMessageArgs) UnmarshalJSON(b []byte) (err error) {
}
if err = json.Unmarshal(b, &obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
args.Payload = obj[0].Payload
args.To = obj[0].To
@@ -407,7 +488,7 @@ func (args *CompileArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) > 0 {
@@ -422,17 +503,22 @@ type FilterStringArgs struct {
}
func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
- var obj []string
+ var obj []interface{}
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errDecodeArgs
+ return NewInsufficientParamsError(len(obj), 1)
}
- args.Word = obj[0]
+ var argstr string
+ argstr, ok := obj[0].(string)
+ if !ok {
+ return NewDecodeParamError("Filter is not a string")
+ }
+ args.Word = argstr
return nil
}
@@ -445,11 +531,11 @@ func (args *FilterIdArgs) UnmarshalJSON(b []byte) (err error) {
var obj []string
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errDecodeArgs
+ return NewInsufficientParamsError(len(obj), 1)
}
args.Id = int(ethutil.Big(obj[0]).Int64())
@@ -465,11 +551,11 @@ func (args *WhisperIdentityArgs) UnmarshalJSON(b []byte) (err error) {
var obj []string
r := bytes.NewReader(b)
if err := json.NewDecoder(r).Decode(&obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errDecodeArgs
+ return NewInsufficientParamsError(len(obj), 1)
}
args.Identity = obj[0]
@@ -491,11 +577,11 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
}
if err = json.Unmarshal(b, &obj); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
if len(obj) < 1 {
- return errArguments
+ return NewInsufficientParamsError(len(obj), 1)
}
args.To = obj[0].To
@@ -504,3 +590,31 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+
+// func (req *RpcRequest) ToRegisterArgs() (string, error) {
+// if len(req.Params) < 1 {
+// return "", errArguments
+// }
+
+// var args string
+// err := json.Unmarshal(req.Params, &args)
+// if err != nil {
+// return "", err
+// }
+
+// return args, nil
+// }
+
+// func (req *RpcRequest) ToWatchTxArgs() (string, error) {
+// if len(req.Params) < 1 {
+// return "", errArguments
+// }
+
+// var args string
+// err := json.Unmarshal(req.Params, &args)
+// if err != nil {
+// return "", err
+// }
+
+// return args, nil
+// }
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 027624500..47d79cc32 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -43,6 +43,17 @@ func TestGetBalanceArgs(t *testing.T) {
}
}
+func TestGetBalanceEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(GetBalanceArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+
+}
+
func TestGetBlockByHashArgs(t *testing.T) {
input := `["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]`
expected := new(GetBlockByHashArgs)
@@ -418,6 +429,16 @@ func TestFilterStringArgs(t *testing.T) {
}
}
+func TestFilterStringEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(FilterStringArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestWhisperIdentityArgs(t *testing.T) {
input := `["0xc931d93e97ab07fe42d923478ba2465f283"]`
expected := new(WhisperIdentityArgs)
@@ -432,3 +453,43 @@ func TestWhisperIdentityArgs(t *testing.T) {
t.Errorf("Identity shoud be %#v but is %#v", expected.Identity, args.Identity)
}
}
+
+func TestBlockNumIndexArgs(t *testing.T) {
+ input := `["0x29a", "0x0"]`
+ expected := new(BlockNumIndexArgs)
+ expected.BlockNumber = 666
+ expected.Index = 0
+
+ args := new(BlockNumIndexArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.BlockNumber != args.BlockNumber {
+ t.Errorf("BlockNumber shoud be %#v but is %#v", expected.BlockNumber, args.BlockNumber)
+ }
+
+ if expected.Index != args.Index {
+ t.Errorf("Index shoud be %#v but is %#v", expected.Index, args.Index)
+ }
+}
+
+func TestHashIndexArgs(t *testing.T) {
+ input := `["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x1"]`
+ expected := new(HashIndexArgs)
+ expected.Hash = "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"
+ expected.Index = 1
+
+ args := new(HashIndexArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.Hash != args.Hash {
+ t.Errorf("Hash shoud be %#v but is %#v", expected.Hash, args.Hash)
+ }
+
+ if expected.Index != args.Index {
+ t.Errorf("Index shoud be %#v but is %#v", expected.Index, args.Index)
+ }
+}
diff --git a/rpc/http.go b/rpc/http.go
index 857cf3221..8dcd55ad1 100644
--- a/rpc/http.go
+++ b/rpc/http.go
@@ -25,22 +25,39 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler {
rpchttplogger.DebugDetailln("Handling request")
if req.ContentLength > maxSizeReqLength {
- jsonerr := &RpcErrorObject{-32700, "Error: Request too large"}
+ jsonerr := &RpcErrorObject{-32700, "Request too large"}
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
return
}
reqParsed, reqerr := json.ParseRequestBody(req)
- if reqerr != nil {
- jsonerr := &RpcErrorObject{-32700, "Error: Could not parse request"}
+ switch reqerr.(type) {
+ case nil:
+ break
+ case *DecodeParamError, *InsufficientParamsError, *ValidationError:
+ jsonerr := &RpcErrorObject{-32602, reqerr.Error()}
+ json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
+ return
+ default:
+ jsonerr := &RpcErrorObject{-32700, "Could not parse request"}
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
return
}
var response interface{}
reserr := api.GetRequestReply(&reqParsed, &response)
- if reserr != nil {
- rpchttplogger.Warnln(reserr)
+ switch reserr.(type) {
+ case nil:
+ break
+ case *NotImplementedError:
+ jsonerr := &RpcErrorObject{-32601, reserr.Error()}
+ json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
+ return
+ case *DecodeParamError, *InsufficientParamsError, *ValidationError:
+ jsonerr := &RpcErrorObject{-32602, reserr.Error()}
+ json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
+ return
+ default:
jsonerr := &RpcErrorObject{-32603, reserr.Error()}
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
return
diff --git a/rpc/messages.go b/rpc/messages.go
index a3ebbf330..781394196 100644
--- a/rpc/messages.go
+++ b/rpc/messages.go
@@ -18,16 +18,69 @@ package rpc
import (
"encoding/json"
- "errors"
"fmt"
)
-var (
- errArguments = errors.New("Error: Insufficient arguments")
- errNotImplemented = errors.New("Error: Method not implemented")
- errUnknown = errors.New("Error: Unknown error")
- errDecodeArgs = errors.New("Error: Could not decode arguments")
-)
+type InsufficientParamsError struct {
+ have int
+ want int
+}
+
+func (e *InsufficientParamsError) Error() string {
+ return fmt.Sprintf("insufficient params, want %d have %d", e.want, e.have)
+}
+
+func NewInsufficientParamsError(have int, want int) *InsufficientParamsError {
+ return &InsufficientParamsError{
+ have: have,
+ want: want,
+ }
+}
+
+type NotImplementedError struct {
+ Method string
+}
+
+func (e *NotImplementedError) Error() string {
+ return fmt.Sprintf("%s method not implemented", e.Method)
+}
+
+func NewNotImplementedError(method string) *NotImplementedError {
+ return &NotImplementedError{
+ Method: method,
+ }
+}
+
+type DecodeParamError struct {
+ err string
+}
+
+func (e *DecodeParamError) Error() string {
+ return fmt.Sprintf("could not decode, %s", e.err)
+
+}
+
+func NewDecodeParamError(errstr string) error {
+ return &DecodeParamError{
+ err: errstr,
+ }
+}
+
+type ValidationError struct {
+ ParamName string
+ msg string
+}
+
+func (e *ValidationError) Error() string {
+ return fmt.Sprintf("%s not valid, %s", e.ParamName, e.msg)
+}
+
+func NewValidationError(param string, msg string) error {
+ return &ValidationError{
+ ParamName: param,
+ msg: msg,
+ }
+}
type RpcRequest struct {
ID interface{} `json:"id"`
@@ -53,35 +106,3 @@ type RpcErrorObject struct {
Message string `json:"message"`
// Data interface{} `json:"data"`
}
-
-func NewErrorWithMessage(err error, msg string) error {
- return fmt.Errorf("%s: %s", err.Error(), msg)
-}
-
-// func (req *RpcRequest) ToRegisterArgs() (string, error) {
-// if len(req.Params) < 1 {
-// return "", errArguments
-// }
-
-// var args string
-// err := json.Unmarshal(req.Params, &args)
-// if err != nil {
-// return "", err
-// }
-
-// return args, nil
-// }
-
-// func (req *RpcRequest) ToWatchTxArgs() (string, error) {
-// if len(req.Params) < 1 {
-// return "", errArguments
-// }
-
-// var args string
-// err := json.Unmarshal(req.Params, &args)
-// if err != nil {
-// return "", err
-// }
-
-// return args, nil
-// }
diff --git a/rpc/util.go b/rpc/util.go
index 8ff3c6d31..4acd90284 100644
--- a/rpc/util.go
+++ b/rpc/util.go
@@ -42,7 +42,7 @@ type JsonWrapper struct{}
func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error) {
var data []json.RawMessage
if err = json.Unmarshal(b, &data); err != nil && len(data) == 0 {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
// Number index determines the index in the array for a possible block number
@@ -74,7 +74,7 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error
fallthrough
default:
if err = json.Unmarshal(data[0], iface); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
numberIndex = 1
}
@@ -82,7 +82,7 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error
// <0 index means out of bound for block number
if numberIndex >= 0 && len(data) > numberIndex {
if err = blockNumber(data[numberIndex], number); err != nil {
- return errDecodeArgs
+ return NewDecodeParamError(err.Error())
}
}
@@ -128,19 +128,6 @@ func toHex(b []byte) string {
return "0x" + hex
}
-func fromHex(s string) []byte {
- if len(s) > 1 {
- if s[0:2] == "0x" {
- s = s[2:]
- }
- if len(s)%2 == 1 {
- s = "0" + s
- }
- return ethutil.Hex2Bytes(s)
- }
- return nil
-}
-
func i2hex(n int) string {
return toHex(big.NewInt(int64(n)).Bytes())
}
diff --git a/rpc/util_test.go b/rpc/util_test.go
deleted file mode 100644
index b0a4979b5..000000000
--- a/rpc/util_test.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package rpc
-
-import (
- "bytes"
- "testing"
-)
-
-//fromHex
-func TestFromHex(t *testing.T) {
- input := "0x01"
- expected := []byte{1}
- result := fromHex(input)
- if bytes.Compare(expected, result) != 0 {
- t.Errorf("Expected % x got % x", expected, result)
- }
-}
-
-func TestFromHexOddLength(t *testing.T) {
- input := "0x1"
- expected := []byte{1}
- result := fromHex(input)
- if bytes.Compare(expected, result) != 0 {
- t.Errorf("Expected % x got % x", expected, result)
- }
-}
diff --git a/state/managed_state.go b/state/managed_state.go
new file mode 100644
index 000000000..aff0206b2
--- /dev/null
+++ b/state/managed_state.go
@@ -0,0 +1,84 @@
+package state
+
+import "sync"
+
+type account struct {
+ stateObject *StateObject
+ nstart uint64
+ nonces []bool
+}
+
+type ManagedState struct {
+ *StateDB
+
+ mu sync.RWMutex
+
+ accounts map[string]*account
+}
+
+func ManageState(statedb *StateDB) *ManagedState {
+ return &ManagedState{
+ StateDB: statedb,
+ accounts: make(map[string]*account),
+ }
+}
+
+func (ms *ManagedState) SetState(statedb *StateDB) {
+ ms.mu.Lock()
+ defer ms.mu.Unlock()
+ ms.StateDB = statedb
+}
+
+func (ms *ManagedState) RemoveNonce(addr []byte, n uint64) {
+ if ms.hasAccount(addr) {
+ ms.mu.Lock()
+ defer ms.mu.Unlock()
+
+ account := ms.getAccount(addr)
+ if n-account.nstart <= uint64(len(account.nonces)) {
+ reslice := make([]bool, n-account.nstart)
+ copy(reslice, account.nonces[:n-account.nstart])
+ account.nonces = reslice
+ }
+ }
+}
+
+func (ms *ManagedState) NewNonce(addr []byte) uint64 {
+ ms.mu.RLock()
+ defer ms.mu.RUnlock()
+
+ account := ms.getAccount(addr)
+ for i, nonce := range account.nonces {
+ if !nonce {
+ return account.nstart + uint64(i)
+ }
+ }
+ account.nonces = append(account.nonces, true)
+ return uint64(len(account.nonces)) + account.nstart
+}
+
+func (ms *ManagedState) hasAccount(addr []byte) bool {
+ _, ok := ms.accounts[string(addr)]
+ return ok
+}
+
+func (ms *ManagedState) getAccount(addr []byte) *account {
+ if account, ok := ms.accounts[string(addr)]; !ok {
+ so := ms.GetOrNewStateObject(addr)
+ ms.accounts[string(addr)] = newAccount(so)
+ } else {
+ // Always make sure the state account nonce isn't actually higher
+ // than the tracked one.
+ so := ms.StateDB.GetStateObject(addr)
+ if so != nil && uint64(len(account.nonces))+account.nstart < so.nonce {
+ ms.accounts[string(addr)] = newAccount(so)
+ }
+
+ }
+
+ return ms.accounts[string(addr)]
+}
+
+func newAccount(so *StateObject) *account {
+ return &account{so, so.nonce - 1, nil}
+}
diff --git a/state/managed_state_test.go b/state/managed_state_test.go
new file mode 100644
index 000000000..f819d8ad3
--- /dev/null
+++ b/state/managed_state_test.go
@@ -0,0 +1,89 @@
+package state
+
+import (
+ "testing"
+
+ "github.com/ethereum/go-ethereum/ethutil"
+)
+
+var addr = ethutil.Address([]byte("test"))
+
+func create() (*ManagedState, *account) {
+ ms := ManageState(&StateDB{stateObjects: make(map[string]*StateObject)})
+ so := &StateObject{address: addr, nonce: 100}
+ ms.StateDB.stateObjects[string(addr)] = so
+ ms.accounts[string(addr)] = newAccount(so)
+
+ return ms, ms.accounts[string(addr)]
+}
+
+func TestNewNonce(t *testing.T) {
+ ms, _ := create()
+
+ nonce := ms.NewNonce(addr)
+ if nonce != 100 {
+ t.Error("expected nonce 100. got", nonce)
+ }
+
+ nonce = ms.NewNonce(addr)
+ if nonce != 101 {
+ t.Error("expected nonce 101. got", nonce)
+ }
+}
+
+func TestRemove(t *testing.T) {
+ ms, account := create()
+
+ nn := make([]bool, 10)
+ for i, _ := range nn {
+ nn[i] = true
+ }
+ account.nonces = append(account.nonces, nn...)
+
+ i := uint64(5)
+ ms.RemoveNonce(addr, account.nstart+i)
+ if len(account.nonces) != 5 {
+ t.Error("expected", i, "'th index to be false")
+ }
+}
+
+func TestReuse(t *testing.T) {
+ ms, account := create()
+
+ nn := make([]bool, 10)
+ for i, _ := range nn {
+ nn[i] = true
+ }
+ account.nonces = append(account.nonces, nn...)
+
+ i := uint64(5)
+ ms.RemoveNonce(addr, account.nstart+i)
+ nonce := ms.NewNonce(addr)
+ if nonce != 105 {
+ t.Error("expected nonce to be 105. got", nonce)
+ }
+}
+
+func TestRemoteNonceChange(t *testing.T) {
+ ms, account := create()
+ nn := make([]bool, 10)
+ for i, _ := range nn {
+ nn[i] = true
+ }
+ account.nonces = append(account.nonces, nn...)
+ nonce := ms.NewNonce(addr)
+
+ ms.StateDB.stateObjects[string(addr)].nonce = 200
+ nonce = ms.NewNonce(addr)
+ if nonce != 200 {
+ t.Error("expected nonce after remote update to be", 201, "got", nonce)
+ }
+ ms.NewNonce(addr)
+ ms.NewNonce(addr)
+ ms.NewNonce(addr)
+ ms.StateDB.stateObjects[string(addr)].nonce = 200
+ nonce = ms.NewNonce(addr)
+ if nonce != 204 {
+ t.Error("expected nonce after remote update to be", 201, "got", nonce)
+ }
+}
diff --git a/state/state_object.go b/state/state_object.go
index ccbfea391..dccbe8dad 100644
--- a/state/state_object.go
+++ b/state/state_object.go
@@ -38,19 +38,27 @@ func (self Storage) Copy() Storage {
}
type StateObject struct {
+ // State database for storing state changes
db ethutil.Database
- // Address of the object
+ // The state object
+ State *StateDB
+
+ // Address belonging to this account
address []byte
- // Shared attributes
- balance *big.Int
+ // The balance of the account
+ balance *big.Int
+ // The nonce of the account
+ nonce uint64
+ // The code hash if code is present (i.e. a contract)
codeHash []byte
- nonce uint64
- // Contract related attributes
- State *StateDB
- code Code
+ // The code for this account
+ code Code
+ // Temporarily initialisation code
initCode Code
-
+ // Cached storage (flushed when updated)
storage Storage
+ // Temporary prepaid gas, reward after transition
+ prepaid *big.Int
// Total gas pool is the total amount of gas currently
// left if this object is the coinbase. Gas is directly
@@ -77,6 +85,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
object.State = New(nil, db) //New(trie.New(ethutil.Config.Db, ""))
object.storage = make(Storage)
object.gasPool = new(big.Int)
+ object.prepaid = new(big.Int)
return object
}
@@ -103,6 +112,7 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
object.State = New(extobject.Root, db)
object.storage = make(map[string]*ethutil.Value)
object.gasPool = new(big.Int)
+ object.prepaid = new(big.Int)
object.code, _ = db.Get(extobject.CodeHash)
return object
@@ -230,8 +240,6 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
rGas := new(big.Int).Set(gas)
rGas.Mul(rGas, price)
- self.AddBalance(rGas)
-
self.dirty = true
return nil
@@ -239,11 +247,6 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
func (self *StateObject) RefundGas(gas, price *big.Int) {
self.gasPool.Add(self.gasPool, gas)
-
- rGas := new(big.Int).Set(gas)
- rGas.Mul(rGas, price)
-
- self.balance.Sub(self.balance, rGas)
}
func (self *StateObject) Copy() *StateObject {
diff --git a/state/statedb.go b/state/statedb.go
index 0a4156461..a0dc7732f 100644
--- a/state/statedb.go
+++ b/state/statedb.go
@@ -54,7 +54,7 @@ func (self *StateDB) Refund(addr []byte, gas *big.Int) {
// Retrieve the balance from the given address or 0 if object not found
func (self *StateDB) GetBalance(addr []byte) *big.Int {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.balance
}
@@ -63,14 +63,14 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
}
func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.AddBalance(amount)
}
}
func (self *StateDB) GetNonce(addr []byte) uint64 {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.nonce
}
@@ -79,7 +79,7 @@ func (self *StateDB) GetNonce(addr []byte) uint64 {
}
func (self *StateDB) GetCode(addr []byte) []byte {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.code
}
@@ -88,7 +88,7 @@ func (self *StateDB) GetCode(addr []byte) []byte {
}
func (self *StateDB) GetState(a, b []byte) []byte {
- stateObject := self.GetOrNewStateObject(a)
+ stateObject := self.GetStateObject(a)
if stateObject != nil {
return stateObject.GetState(b).Bytes()
}
@@ -97,28 +97,28 @@ func (self *StateDB) GetState(a, b []byte) []byte {
}
func (self *StateDB) SetNonce(addr []byte, nonce uint64) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetNonce(nonce)
}
}
func (self *StateDB) SetCode(addr, code []byte) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetCode(code)
}
}
func (self *StateDB) SetState(addr, key []byte, value interface{}) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetState(key, ethutil.NewValue(value))
}
}
func (self *StateDB) Delete(addr []byte) bool {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.MarkForDeletion()
stateObject.balance = new(big.Int)
diff --git a/tests/blocktest.go b/tests/blocktest.go
index 4bb066c3d..6a9cf5f6d 100644
--- a/tests/blocktest.go
+++ b/tests/blocktest.go
@@ -154,7 +154,7 @@ func mustConvertGenesis(testGenesis btHeader) *types.Block {
func mustConvertHeader(in btHeader) *types.Header {
// hex decode these fields
return &types.Header{
- SeedHash: mustConvertBytes(in.SeedHash),
+ //SeedHash: mustConvertBytes(in.SeedHash),
MixDigest: mustConvertBytes(in.MixHash),
Bloom: mustConvertBytes(in.Bloom),
ReceiptHash: mustConvertBytes(in.ReceiptTrie),
diff --git a/tests/files/StateTests/RandomTests/st201503121046CPPJIT.json b/tests/files/StateTests/RandomTests/st201503121046CPPJIT.json
new file mode 100644
index 000000000..7d956a68a
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121046CPPJIT.json
@@ -0,0 +1,64 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000100000",
+ "code" : "0x414144404543f3425b19a186088a4255",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
+ "balance" : "400000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999500000",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "9f6a63cd47208716f61436ed1c7c32ea01203d3d5bd95cbadab6a7418506418c",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x414144404543f3425b19a186088a4255",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121739CPPJIT.json b/tests/files/StateTests/RandomTests/st201503121739CPPJIT.json
new file mode 100644
index 000000000..204541a57
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121739CPPJIT.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" : "1000000000000100000",
+ "code" : "0x9e4545404544444192980655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "400046",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999500000",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "a1e17dd82625da4c8bbba2c64a149960fdc1b425abdaf8454800f33cee37d9ef",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x9e4545404544444192980655",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121803PYTHON.json b/tests/files/StateTests/RandomTests/st201503121803PYTHON.json
new file mode 100644
index 000000000..aa6ade198
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121803PYTHON.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" : "1000000000000100000",
+ "code" : "0x76404140424242458c1f11410b",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21117",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999878929",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "c5fd66cfd27414f0b06ab651ee27bfa757aab2358d1688ad57d16942674f8c5e",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x76404140424242458c1f11410b",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121806PYTHON.json b/tests/files/StateTests/RandomTests/st201503121806PYTHON.json
new file mode 100644
index 000000000..4cff23f02
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121806PYTHON.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" : "1000000000000100000",
+ "code" : "0x45424043404545456b689f9b7055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21169",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999878877",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "e51e7523b966a480e432cdd171646148589c372a005dd6a0a475ff128ca057e7",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x45424043404545456b689f9b7055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121848GO.json b/tests/files/StateTests/RandomTests/st201503121848GO.json
new file mode 100644
index 000000000..8c339ebce
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121848GO.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" : "1000000000000100000",
+ "code" : "0x414144401a0745423b55",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41172",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858874",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "2831da52e99ecb98f98d52a4fb635681b6e3c37f6cc1ea2c63531c8b5ef31fcb",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x414144401a0745423b55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121849GO.json b/tests/files/StateTests/RandomTests/st201503121849GO.json
new file mode 100644
index 000000000..6f4f716d8
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121849GO.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" : "1000000000000100000",
+ "code" : "0x43444042454340443b8155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "26189",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999873857",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "71a87aad1a3e9876a76602dae704f893a347fd2463486348229ea6de3628ad14",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x43444042454340443b8155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121850GO.json b/tests/files/StateTests/RandomTests/st201503121850GO.json
new file mode 100644
index 000000000..a25986314
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121850GO.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" : "1000000000000100000",
+ "code" : "0x41434543454541443b5455",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41200",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858846",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "567a8e4b4ae0c146b8e8b1fa7281df52329f0dd0a4917cc9e6ee53291b266204",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x41434543454541443b5455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121851GO.json b/tests/files/StateTests/RandomTests/st201503121851GO.json
new file mode 100644
index 000000000..b14f68a2f
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121851GO.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" : "1000000000000100000",
+ "code" : "0x4440444245414045913c63087c55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21198",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999878848",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "feb2e64b425b9cffdd2d3860d61c1d11955dd06ebb76bd532a211c659dd8fcea",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4440444245414045913c63087c55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503121953GO.json b/tests/files/StateTests/RandomTests/st201503121953GO.json
new file mode 100644
index 000000000..d1c10f7f2
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503121953GO.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" : "1000000000000100000",
+ "code" : "0x41414444424143448231537241317f55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21165",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999878881",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "3d03bc1c45759cac030d4352629c83013c6f475445189fa2b4b38fad8e11c021",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x41414444424143448231537241317f55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122023GO.json b/tests/files/StateTests/RandomTests/st201503122023GO.json
new file mode 100644
index 000000000..a809a6888
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122023GO.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" : "1000000000000100000",
+ "code" : "0x434243434444424350303614f20a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "30192",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999869854",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "3ec3270c32b915349f7f0be6bc50eab148c225596906df7ead581b41267a9262",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x434243434444424350303614f20a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122023PYTHON.json b/tests/files/StateTests/RandomTests/st201503122023PYTHON.json
new file mode 100644
index 000000000..a809a6888
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122023PYTHON.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" : "1000000000000100000",
+ "code" : "0x434243434444424350303614f20a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "30192",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999869854",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "3ec3270c32b915349f7f0be6bc50eab148c225596906df7ead581b41267a9262",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x434243434444424350303614f20a",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122027GO.json b/tests/files/StateTests/RandomTests/st201503122027GO.json
new file mode 100644
index 000000000..3ad4ebee0
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122027GO.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" : "1000000000000100000",
+ "code" : "0x45454340424244444131599455",
+ "nonce" : "0",
+ "storage" : {
+ "0x01" : "0x2e"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41175",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858871",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "3ad979f420fe31052177c7d9b16c5b5e0e70cd4680e1a9603aeb5b5d7dc97a08",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x45454340424244444131599455",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122054GO.json b/tests/files/StateTests/RandomTests/st201503122054GO.json
new file mode 100644
index 000000000..ff92b2efc
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122054GO.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" : "1000000000000100000",
+ "code" : "0x4444424131424055",
+ "nonce" : "0",
+ "storage" : {
+ "0x" : "0x2e"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41164",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858882",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "576f7d7b1a8ec643bb0405183cf6c183ecf088a60820306bc4d48c91ad1e34bb",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4444424131424055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122055GO.json b/tests/files/StateTests/RandomTests/st201503122055GO.json
new file mode 100644
index 000000000..cd9e4fcfa
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122055GO.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" : "1000000000000100000",
+ "code" : "0x4240444141454542530855",
+ "nonce" : "0",
+ "storage" : {
+ "0x19fce28896ccf741526ab2b315679be64e8570e7" : "0x051d6a3cd647"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41162",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858884",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "6352dbf5277b52b7b21075dab123fb4ca306c7c65102d4f90e80be9db115229b",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4240444141454542530855",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122115CPPJIT.json b/tests/files/StateTests/RandomTests/st201503122115CPPJIT.json
new file mode 100644
index 000000000..7e99b5d82
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122115CPPJIT.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000100000",
+ "code" : "0x413443f3404242433389ff723810",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "49568",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999850478",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "921517cc33b5f4267a76b110e54b0578754d4ffb748085d8b4ed4195ad2d0af9",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x413443f3404242433389ff723810",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122115GO.json b/tests/files/StateTests/RandomTests/st201503122115GO.json
new file mode 100644
index 000000000..7e99b5d82
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122115GO.json
@@ -0,0 +1,71 @@
+{
+ "randomStatetest" : {
+ "env" : {
+ "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
+ "currentDifficulty" : "5623894562375",
+ "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "logs" : [
+ ],
+ "out" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "post" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000100000",
+ "code" : "0x413443f3404242433389ff723810",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "49568",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999850478",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "921517cc33b5f4267a76b110e54b0578754d4ffb748085d8b4ed4195ad2d0af9",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x413443f3404242433389ff723810",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122123GO.json b/tests/files/StateTests/RandomTests/st201503122123GO.json
new file mode 100644
index 000000000..f3edd668c
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122123GO.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" : "1000000000000100000",
+ "code" : "0x41314555",
+ "nonce" : "0",
+ "storage" : {
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" : "0x2e"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41138",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858908",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "b053b0835b8da7f3a105910186ea3646d2f4b87a4f742e4950f6748a2cf8b4ae",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x41314555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122124GO.json b/tests/files/StateTests/RandomTests/st201503122124GO.json
new file mode 100644
index 000000000..96bb8c03e
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122124GO.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" : "1000000000000100000",
+ "code" : "0x41413155",
+ "nonce" : "0",
+ "storage" : {
+ "0x2e" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41138",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858908",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "b0d06d7f17ae4205bbae17bff580ed2ac8a1a57c9e8e0693bccc4c8495aa644c",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x41413155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122128PYTHON.json b/tests/files/StateTests/RandomTests/st201503122128PYTHON.json
new file mode 100644
index 000000000..6d79b7584
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122128PYTHON.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" : "1000000000000100000",
+ "code" : "0x387b414543444043899e863a628b55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "21119",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999878927",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "1dab5ba92043d9382e5987e2efa9a15ae8e4bee0ee5b5b730edcd5d7d5d9c1ba",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x387b414543444043899e863a628b55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122140GO.json b/tests/files/StateTests/RandomTests/st201503122140GO.json
new file mode 100644
index 000000000..89e4d9765
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122140GO.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" : "1000000000000100000",
+ "code" : "0x424061434444413155",
+ "nonce" : "0",
+ "storage" : {
+ "0x2e" : "0x051d6a3cd647"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41163",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858883",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "591a753382903db2ec4acf2c749c6f473da62a988025c16d2bc2e90981f83e23",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x424061434444413155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122159GO.json b/tests/files/StateTests/RandomTests/st201503122159GO.json
new file mode 100644
index 000000000..c9e7c7f9a
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122159GO.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" : "1000000000000100000",
+ "code" : "0x36416045454040410a922055",
+ "nonce" : "0",
+ "storage" : {
+ "0x3e327054f60b9c38a1c3fafb23d155d0f971a83a616685eb79c73127b3dfbcc5" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41235",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858811",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "d6f1cabd73ae571074e9b2f5afb893192abf14a41694b2df2c27e545604d1623",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x36416045454040410a922055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122204GO.json b/tests/files/StateTests/RandomTests/st201503122204GO.json
new file mode 100644
index 000000000..c888af2ad
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122204GO.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" : "1000000000000100000",
+ "code" : "0x584143404243404107204155",
+ "nonce" : "0",
+ "storage" : {
+ "0x945304eb96065b2a98b57a48a06ae28d285a71b5" : "0xbc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41212",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858834",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "aa12d41c4489f07bf7694911769cf889fd07221683aa992100fff908ce6d91ed",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x584143404243404107204155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/StateTests/RandomTests/st201503122212GO.json b/tests/files/StateTests/RandomTests/st201503122212GO.json
new file mode 100644
index 000000000..90d652955
--- /dev/null
+++ b/tests/files/StateTests/RandomTests/st201503122212GO.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" : "1000000000000100000",
+ "code" : "0x41314155",
+ "nonce" : "0",
+ "storage" : {
+ "0x945304eb96065b2a98b57a48a06ae28d285a71b5" : "0x2e"
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "41138",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "999999999999858908",
+ "code" : "0x",
+ "nonce" : "1",
+ "storage" : {
+ }
+ }
+ },
+ "postStateRoot" : "b2b265a8f3197237d108257414212611077d8ad4ea9d9b0f8e455d73ff6f552c",
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x41314155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
+ "balance" : "46",
+ "code" : "0x6000355415600957005b60203560003555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" : {
+ "data" : "0x42",
+ "gasLimit" : "400000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "100000"
+ }
+ }
+}
diff --git a/tests/files/VMTests/RandomTests/201503112218PYTHON.json b/tests/files/VMTests/RandomTests/201503112218PYTHON.json
new file mode 100644
index 000000000..fdc43998e
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/201503112218PYTHON.json
@@ -0,0 +1,31 @@
+{
+ "randomVMtest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "300",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x4041",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4041",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/VMTests/RandomTests/201503120317PYTHON.json b/tests/files/VMTests/RandomTests/201503120317PYTHON.json
new file mode 100644
index 000000000..7c0338da6
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/201503120317PYTHON.json
@@ -0,0 +1,31 @@
+{
+ "randomVMtest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "300",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x4440584437454145a219977cf032",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4440584437454145a219977cf032",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/VMTests/RandomTests/201503120525PYTHON.json b/tests/files/VMTests/RandomTests/201503120525PYTHON.json
new file mode 100644
index 000000000..1d827a175
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/201503120525PYTHON.json
@@ -0,0 +1,31 @@
+{
+ "randomVMtest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "300",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x87584242",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x87584242",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/VMTests/RandomTests/201503120547PYTHON.json b/tests/files/VMTests/RandomTests/201503120547PYTHON.json
new file mode 100644
index 000000000..d3dcdbe04
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/201503120547PYTHON.json
@@ -0,0 +1,31 @@
+{
+ "randomVMtest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "300",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x444245454141434007576c9c03f19334",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x444245454141434007576c9c03f19334",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/VMTests/RandomTests/201503120909PYTHON.json b/tests/files/VMTests/RandomTests/201503120909PYTHON.json
new file mode 100644
index 000000000..29d575dcf
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/201503120909PYTHON.json
@@ -0,0 +1,31 @@
+{
+ "randomVMtest" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "300",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x4445444440500442829d55",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4445444440500442829d55",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+}
diff --git a/tests/files/VMTests/vmArithmeticTest.json b/tests/files/VMTests/vmArithmeticTest.json
index ba2718674..6431b2060 100644
--- a/tests/files/VMTests/vmArithmeticTest.json
+++ b/tests/files/VMTests/vmArithmeticTest.json
@@ -5644,6 +5644,35 @@
}
}
},
+ "mulUnderFlow" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "code" : "0x600102600155",
+ "data" : "0x",
+ "gas" : "100000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x600102600155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"mulmod0" : {
"callcreates" : [
],
@@ -6618,6 +6647,50 @@
}
}
},
+ "sdiv_dejavu" : {
+ "callcreates" : [
+ ],
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "code" : "0x60805060a05060055060a05060095060a05060005060c05060e0506101005060a050600050610120",
+ "data" : "0x",
+ "gas" : "10000000",
+ "gasPrice" : "1",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "gas" : "9999937",
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x60805060a05060055060a05060095060a05060005060c05060e0506101005060a050600050610120",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x60805060a05060055060a05060095060a05060005060c05060e0506101005060a050600050610120",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"sdiv_i256min" : {
"callcreates" : [
],
@@ -6708,12 +6781,12 @@
"caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"code" : "0x7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05600055",
"data" : "0x",
- "gas" : "10000",
- "gasPrice" : "100000000000000",
+ "gas" : "1000000",
+ "gasPrice" : "1",
"origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
- "gas" : "4980",
+ "gas" : "994980",
"logs" : [
],
"out" : "0x",
@@ -7184,6 +7257,50 @@
}
}
},
+ "signextend_Overflow_dj42" : {
+ "callcreates" : [
+ ],
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "10000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "code" : "0x6005565b005b61800080680100000000000000010b6180011160035763badf000d601155",
+ "data" : "0x",
+ "gas" : "1000000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "gas" : "999954",
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x6005565b005b61800080680100000000000000010b6180011160035763badf000d601155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x6005565b005b61800080680100000000000000010b6180011160035763badf000d601155",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"signextend_bigBytePlus1" : {
"callcreates" : [
],
diff --git a/tests/files/VMTests/vmBlockInfoTest.json b/tests/files/VMTests/vmBlockInfoTest.json
index 7aee6a0cf..e8b81dc98 100644
--- a/tests/files/VMTests/vmBlockInfoTest.json
+++ b/tests/files/VMTests/vmBlockInfoTest.json
@@ -266,6 +266,35 @@
}
}
},
+ "blockhashUnderFlow" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "1",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x40",
+ "data" : "0x",
+ "gas" : "100000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "100000000000000000000000",
+ "code" : "0x40",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"coinbase" : {
"callcreates" : [
],
diff --git a/tests/files/VMTests/vmEnvironmentalInfoTest.json b/tests/files/VMTests/vmEnvironmentalInfoTest.json
index d43630c08..7b91a32f5 100644
--- a/tests/files/VMTests/vmEnvironmentalInfoTest.json
+++ b/tests/files/VMTests/vmEnvironmentalInfoTest.json
@@ -791,6 +791,35 @@
}
}
},
+ "calldatacopyUnderFlow" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x6001600237",
+ "data" : "0x01234567890abcdef01234567890abcdef",
+ "gas" : "100000000000",
+ "gasPrice" : "1000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "100000000000000000000000",
+ "code" : "0x6001600237",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"calldatacopyZeroMemExpansion" : {
"callcreates" : [
],
@@ -2089,6 +2118,42 @@
}
}
},
+ "extcodesizeUnderFlow" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x3b",
+ "data" : "0x01234567890abcdef01234567890abcdef",
+ "gas" : "100000000000",
+ "gasPrice" : "123456789",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "100000000000000000000000",
+ "code" : "0x3b",
+ "nonce" : "0",
+ "storage" : {
+ }
+ },
+ "cd1722f3947def4cf144679da39c4c32bdc35681" : {
+ "balance" : "100000000000000000000000",
+ "code" : "0x38333b14600055",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
"gasprice" : {
"callcreates" : [
],
diff --git a/tests/helper/vm.go b/tests/helper/vm.go
index 9ebf8f8b6..f1aaf74b8 100644
--- a/tests/helper/vm.go
+++ b/tests/helper/vm.go
@@ -173,9 +173,8 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
message := NewMessage(keyPair.Address(), to, data, value, gas, price)
vmenv := NewEnvFromMap(statedb, env, tx)
- st := core.NewStateTransition(vmenv, message, coinbase)
vmenv.origin = keyPair.Address()
- ret, err := st.TransitionState()
+ ret, _, err := core.ApplyMessage(vmenv, message, coinbase)
if core.IsNonceErr(err) || core.IsInvalidTxErr(err) {
statedb.Set(snapshot)
}
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index 959f20463..1e8cd5b51 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -116,7 +116,6 @@ func RunVmTest(p string, t *testing.T) {
} else {
ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction)
}
- statedb.Sync()
rexp := helper.FromHex(test.Out)
if bytes.Compare(rexp, ret) != 0 {
@@ -157,6 +156,7 @@ func RunVmTest(p string, t *testing.T) {
}
if !isVmTest {
+ statedb.Sync()
if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
t.Errorf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
}
diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go
index 2bc455b0b..7fef1929f 100644
--- a/ui/qt/qwhisper/whisper.go
+++ b/ui/qt/qwhisper/whisper.go
@@ -13,12 +13,6 @@ import (
var qlogger = logger.NewLogger("QSHH")
-func fromHex(s string) []byte {
- if len(s) > 1 {
- return ethutil.Hex2Bytes(s[2:])
- }
- return nil
-}
func toHex(b []byte) string { return "0x" + ethutil.Bytes2Hex(b) }
type Whisper struct {
@@ -39,15 +33,15 @@ func (self *Whisper) SetView(view qml.Object) {
func (self *Whisper) Post(payload []string, to, from string, topics []string, priority, ttl uint32) {
var data []byte
for _, d := range payload {
- data = append(data, fromHex(d)...)
+ data = append(data, ethutil.FromHex(d)...)
}
- pk := crypto.ToECDSAPub(fromHex(from))
+ pk := crypto.ToECDSAPub(ethutil.FromHex(from))
if key := self.Whisper.GetIdentity(pk); key != nil {
msg := whisper.NewMessage(data)
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
Ttl: time.Duration(ttl) * time.Second,
- To: crypto.ToECDSAPub(fromHex(to)),
+ To: crypto.ToECDSAPub(ethutil.FromHex(to)),
From: key,
Topics: whisper.TopicsFromString(topics...),
})
@@ -76,7 +70,7 @@ func (self *Whisper) NewIdentity() string {
}
func (self *Whisper) HasIdentity(key string) bool {
- return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key)))
+ return self.Whisper.HasIdentity(crypto.ToECDSAPub(ethutil.FromHex(key)))
}
func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int {
@@ -106,10 +100,10 @@ func (self *Whisper) Messages(id int) (messages *ethutil.List) {
func filterFromMap(opts map[string]interface{}) (f whisper.Filter) {
if to, ok := opts["to"].(string); ok {
- f.To = crypto.ToECDSAPub(fromHex(to))
+ f.To = crypto.ToECDSAPub(ethutil.FromHex(to))
}
if from, ok := opts["from"].(string); ok {
- f.From = crypto.ToECDSAPub(fromHex(from))
+ f.From = crypto.ToECDSAPub(ethutil.FromHex(from))
}
if topicList, ok := opts["topics"].(*qml.List); ok {
var topics []string
diff --git a/vm/common.go b/vm/common.go
index b391bb8c2..1cb549228 100644
--- a/vm/common.go
+++ b/vm/common.go
@@ -1,6 +1,7 @@
package vm
import (
+ "math"
"math/big"
"github.com/ethereum/go-ethereum/ethutil"
@@ -117,3 +118,10 @@ func toValue(val *big.Int) interface{} {
return val
}
+
+func getCode(code []byte, start, size uint64) []byte {
+ x := uint64(math.Min(float64(start), float64(len(code))))
+ y := uint64(math.Min(float64(x+size), float64(len(code))))
+
+ return ethutil.RightPadBytes(code[x:y], int(size))
+}
diff --git a/vm/context.go b/vm/context.go
index 9ce07bc4a..78712f561 100644
--- a/vm/context.go
+++ b/vm/context.go
@@ -15,21 +15,24 @@ type ContextRef interface {
type Context struct {
caller ContextRef
- object ContextRef
- Code []byte
+ self ContextRef
- Gas, UsedGas, Price *big.Int
+ Code []byte
+ CodeAddr []byte
+
+ value, Gas, UsedGas, Price *big.Int
Args []byte
}
// Create a new context for the given data items
-func NewContext(caller ContextRef, object ContextRef, code []byte, gas, price *big.Int) *Context {
- c := &Context{caller: caller, object: object, Code: code, Args: nil}
+func NewContext(caller ContextRef, object ContextRef, value, gas, price *big.Int) *Context {
+ c := &Context{caller: caller, self: object, Args: nil}
// Gas should be a pointer so it can safely be reduced through the run
// This pointer will be off the state transition
c.Gas = gas //new(big.Int).Set(gas)
+ c.value = new(big.Int).Set(value)
// In most cases price and value are pointers to transaction objects
// and we don't want the transaction's values to change.
c.Price = new(big.Int).Set(price)
@@ -62,10 +65,7 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
}
func (c *Context) GetCode(x, size uint64) []byte {
- x = uint64(math.Min(float64(x), float64(len(c.Code))))
- y := uint64(math.Min(float64(x+size), float64(len(c.Code))))
-
- return ethutil.RightPadBytes(c.Code[x:y], int(size))
+ return getCode(c.Code, x, size)
}
func (c *Context) Return(ret []byte) []byte {
@@ -101,9 +101,14 @@ func (c *Context) ReturnGas(gas, price *big.Int) {
* Set / Get
*/
func (c *Context) Address() []byte {
- return c.object.Address()
+ return c.self.Address()
}
func (self *Context) SetCode(code []byte) {
self.Code = code
}
+
+func (self *Context) SetCallCode(addr, code []byte) {
+ self.Code = code
+ self.CodeAddr = addr
+}
diff --git a/vm/environment.go b/vm/environment.go
index 5b4d6c8f0..69832241f 100644
--- a/vm/environment.go
+++ b/vm/environment.go
@@ -36,10 +36,12 @@ type Account interface {
SubBalance(amount *big.Int)
AddBalance(amount *big.Int)
Balance() *big.Int
+ Address() []byte
}
// generic transfer method
func Transfer(from, to Account, amount *big.Int) error {
+ //fmt.Printf(":::%x::: %v < %v\n", from.Address(), from.Balance(), amount)
if from.Balance().Cmp(amount) < 0 {
return errors.New("Insufficient balance in account")
}
diff --git a/vm/virtual_machine.go b/vm/virtual_machine.go
index 23ac4878f..6db284f42 100644
--- a/vm/virtual_machine.go
+++ b/vm/virtual_machine.go
@@ -1,10 +1,8 @@
package vm
-import "math/big"
-
type VirtualMachine interface {
Env() Environment
- Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, data []byte) ([]byte, error)
+ Run(context *Context, data []byte) ([]byte, error)
Printf(string, ...interface{}) VirtualMachine
Endl() VirtualMachine
}
diff --git a/vm/vm.go b/vm/vm.go
index 6e4a54844..58aebeedb 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -32,10 +32,17 @@ func New(env Environment) *Vm {
return &Vm{debug: Debug, env: env, logTy: lt, Recoverable: true}
}
-func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
+func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
+ //func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
self.env.SetDepth(self.env.Depth() + 1)
- context := NewContext(caller, me, code, gas, price)
+ //context := NewContext(caller, me, code, gas, price)
+ var (
+ caller = context.caller
+ code = context.Code
+ value = context.value
+ price = context.Price
+ )
self.Printf("(%d) (%x) %x (code=%d) gas: %v (d) %x", self.env.Depth(), caller.Address()[:4], context.Address(), len(code), context.Gas, callData).Endl()
@@ -55,7 +62,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
}()
}
- if p := Precompiled[string(me.Address())]; p != nil {
+ if p := Precompiled[string(context.CodeAddr)]; p != nil {
return self.RunPrecompiled(p, callData, context)
}
@@ -235,9 +242,9 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack.push(base)
case SIGNEXTEND:
- back := stack.pop().Uint64()
- if back < 31 {
- bit := uint(back*8 + 7)
+ back := stack.pop()
+ if back.Cmp(big.NewInt(31)) < 0 {
+ bit := uint(back.Uint64()*8 + 7)
num := stack.pop()
mask := new(big.Int).Lsh(ethutil.Big1, bit)
mask.Sub(mask, ethutil.Big1)
@@ -254,12 +261,10 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack.push(num)
}
case NOT:
- base.Sub(Pow256, stack.pop()).Sub(base, ethutil.Big1)
-
- // Not needed
- base = U256(base)
-
- stack.push(base)
+ stack.push(U256(new(big.Int).Not(stack.pop())))
+ //base.Sub(Pow256, stack.pop()).Sub(base, ethutil.Big1)
+ //base = U256(base)
+ //stack.push(base)
case LT:
x, y := stack.pop(), stack.pop()
self.Printf(" %v < %v", x, y)
@@ -349,29 +354,27 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack.push(base)
case ADDMOD:
-
x := stack.pop()
y := stack.pop()
z := stack.pop()
- add := new(big.Int).Add(x, y)
- if len(z.Bytes()) > 0 { // NOT 0x0
+ if z.Cmp(Zero) > 0 {
+ add := new(big.Int).Add(x, y)
base.Mod(add, z)
- U256(base)
+ base = U256(base)
}
self.Printf(" %v + %v %% %v = %v", x, y, z, base)
stack.push(base)
case MULMOD:
-
x := stack.pop()
y := stack.pop()
z := stack.pop()
- mul := new(big.Int).Mul(x, y)
- if len(z.Bytes()) > 0 { // NOT 0x0
+ if z.Cmp(Zero) > 0 {
+ mul := new(big.Int).Mul(x, y)
base.Mod(mul, z)
U256(base)
@@ -383,7 +386,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
// 0x20 range
case SHA3:
- size, offset := stack.pop(), stack.pop()
+ offset, size := stack.pop(), stack.pop()
data := crypto.Sha3(mem.Get(offset.Int64(), size.Int64()))
stack.push(ethutil.BigD(data))
@@ -395,14 +398,8 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
self.Printf(" => %x", context.Address())
case BALANCE:
-
addr := stack.pop().Bytes()
- var balance *big.Int
- if statedb.GetStateObject(addr) != nil {
- balance = statedb.GetBalance(addr)
- } else {
- balance = base
- }
+ balance := statedb.GetBalance(addr)
stack.push(balance)
@@ -485,13 +482,12 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
} else {
code = context.Code
}
- context := NewContext(nil, nil, code, ethutil.Big0, ethutil.Big0)
var (
mOff = stack.pop().Uint64()
cOff = stack.pop().Uint64()
l = stack.pop().Uint64()
)
- codeCopy := context.GetCode(cOff, l)
+ codeCopy := getCode(code, cOff, l)
mem.Set(mOff, l, codeCopy)
diff --git a/xeth/state.go b/xeth/state.go
index 0f6a042b3..bb729db33 100644
--- a/xeth/state.go
+++ b/xeth/state.go
@@ -1,6 +1,9 @@
package xeth
-import "github.com/ethereum/go-ethereum/state"
+import (
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/state"
+)
type State struct {
xeth *XEth
@@ -16,7 +19,7 @@ func (self *State) State() *state.StateDB {
}
func (self *State) Get(addr string) *Object {
- return &Object{self.state.GetStateObject(fromHex(addr))}
+ return &Object{self.state.GetStateObject(ethutil.FromHex(addr))}
}
func (self *State) SafeGet(addr string) *Object {
@@ -24,9 +27,9 @@ func (self *State) SafeGet(addr string) *Object {
}
func (self *State) safeGet(addr string) *state.StateObject {
- object := self.state.GetStateObject(fromHex(addr))
+ object := self.state.GetStateObject(ethutil.FromHex(addr))
if object == nil {
- object = state.NewStateObject(fromHex(addr), self.xeth.eth.StateDb())
+ object = state.NewStateObject(ethutil.FromHex(addr), self.xeth.eth.StateDb())
}
return object
diff --git a/xeth/types.go b/xeth/types.go
index 5b2d16018..3dc25a2ea 100644
--- a/xeth/types.go
+++ b/xeth/types.go
@@ -17,15 +17,6 @@ import (
func toHex(b []byte) string {
return "0x" + ethutil.Bytes2Hex(b)
}
-func fromHex(s string) []byte {
- if len(s) > 1 {
- if s[0:2] == "0x" {
- s = s[2:]
- }
- return ethutil.Hex2Bytes(s)
- }
- return nil
-}
type Object struct {
*state.StateObject
@@ -123,7 +114,7 @@ func (self *Block) ToString() string {
}
func (self *Block) GetTransaction(hash string) *Transaction {
- tx := self.ref.Transaction(fromHex(hash))
+ tx := self.ref.Transaction(ethutil.FromHex(hash))
if tx == nil {
return nil
}
diff --git a/xeth/whisper.go b/xeth/whisper.go
index d9c7e1614..f5c26faae 100644
--- a/xeth/whisper.go
+++ b/xeth/whisper.go
@@ -5,6 +5,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -28,12 +29,12 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
ttl = 100
}
- pk := crypto.ToECDSAPub(fromHex(from))
+ pk := crypto.ToECDSAPub(ethutil.FromHex(from))
if key := self.Whisper.GetIdentity(pk); key != nil || len(from) == 0 {
- msg := whisper.NewMessage(fromHex(payload))
+ msg := whisper.NewMessage(ethutil.FromHex(payload))
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
Ttl: time.Duration(ttl) * time.Second,
- To: crypto.ToECDSAPub(fromHex(to)),
+ To: crypto.ToECDSAPub(ethutil.FromHex(to)),
From: key,
Topics: whisper.TopicsFromString(topics...),
})
@@ -59,13 +60,13 @@ func (self *Whisper) NewIdentity() string {
}
func (self *Whisper) HasIdentity(key string) bool {
- return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key)))
+ return self.Whisper.HasIdentity(crypto.ToECDSAPub(ethutil.FromHex(key)))
}
func (self *Whisper) Watch(opts *Options) int {
filter := whisper.Filter{
- To: crypto.ToECDSAPub(fromHex(opts.To)),
- From: crypto.ToECDSAPub(fromHex(opts.From)),
+ To: crypto.ToECDSAPub(ethutil.FromHex(opts.To)),
+ From: crypto.ToECDSAPub(ethutil.FromHex(opts.From)),
Topics: whisper.TopicsFromString(opts.Topics...),
}
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 70172a1c8..cf500cd59 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -32,12 +32,14 @@ type Backend interface {
Peers() []*p2p.Peer
BlockDb() ethutil.Database
StateDb() ethutil.Database
+ ExtraDb() ethutil.Database
EventMux() *event.TypeMux
Whisper() *whisper.Whisper
IsMining() bool
StartMining() error
StopMining()
+ Version() string
}
// Frontend should be implemented by users of XEth. Its methods are
@@ -114,19 +116,27 @@ func (self *XEth) State() *State { return self.state }
func (self *XEth) Whisper() *Whisper { return self.whisper }
func (self *XEth) BlockByHash(strHash string) *Block {
- hash := fromHex(strHash)
+ hash := ethutil.FromHex(strHash)
block := self.chainManager.GetBlock(hash)
return NewBlock(block)
}
func (self *XEth) EthBlockByHash(strHash string) *types.Block {
- hash := fromHex(strHash)
+ hash := ethutil.FromHex(strHash)
block := self.chainManager.GetBlock(hash)
return block
}
+func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
+ data, _ := self.eth.ExtraDb().Get(ethutil.FromHex(hash))
+ if len(data) != 0 {
+ return types.NewTransactionFromBytes(data)
+ }
+ return nil
+}
+
func (self *XEth) BlockByNumber(num int64) *Block {
if num == -1 {
return NewBlock(self.chainManager.CurrentBlock())
@@ -223,7 +233,7 @@ func (self *XEth) IsContract(address string) bool {
}
func (self *XEth) SecretToAddress(key string) string {
- pair, err := crypto.NewKeyPairFromSec(fromHex(key))
+ pair, err := crypto.NewKeyPairFromSec(ethutil.FromHex(key))
if err != nil {
return ""
}
@@ -231,10 +241,6 @@ func (self *XEth) SecretToAddress(key string) string {
return toHex(pair.Address())
}
-func (self *XEth) Execute(addr, value, gas, price, data string) (string, error) {
- return "", nil
-}
-
type KeyVal struct {
Key string `json:"key"`
Value string `json:"value"`
@@ -267,7 +273,7 @@ func (self *XEth) FromAscii(str string) string {
str = str[2:]
}
- return string(bytes.Trim(fromHex(str), "\x00"))
+ return string(bytes.Trim(ethutil.FromHex(str), "\x00"))
}
func (self *XEth) FromNumber(str string) string {
@@ -275,11 +281,11 @@ func (self *XEth) FromNumber(str string) string {
str = str[2:]
}
- return ethutil.BigD(fromHex(str)).String()
+ return ethutil.BigD(ethutil.FromHex(str)).String()
}
func (self *XEth) PushTx(encodedTx string) (string, error) {
- tx := types.NewTransactionFromBytes(fromHex(encodedTx))
+ tx := types.NewTransactionFromBytes(ethutil.FromHex(encodedTx))
err := self.eth.TxPool().Add(tx)
if err != nil {
return "", err
@@ -300,12 +306,12 @@ var (
func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
statedb := self.State().State() //self.chainManager.TransState()
msg := callmsg{
- from: statedb.GetOrNewStateObject(fromHex(fromStr)),
- to: fromHex(toStr),
+ from: statedb.GetOrNewStateObject(ethutil.FromHex(fromStr)),
+ to: ethutil.FromHex(toStr),
gas: ethutil.Big(gasStr),
gasPrice: ethutil.Big(gasPriceStr),
value: ethutil.Big(valueStr),
- data: fromHex(dataStr),
+ data: ethutil.FromHex(dataStr),
}
if msg.gas.Cmp(big.NewInt(0)) == 0 {
msg.gas = defaultGas
@@ -333,9 +339,9 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
contractCreation bool
)
- from = fromHex(fromStr)
- data = fromHex(codeStr)
- to = fromHex(toStr)
+ from = ethutil.FromHex(fromStr)
+ data = ethutil.FromHex(codeStr)
+ to = ethutil.FromHex(toStr)
if len(to) == 0 {
contractCreation = true
}
@@ -348,7 +354,7 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
}
state := self.chainManager.TxState()
- nonce := state.GetNonce(from)
+ nonce := state.NewNonce(from) //state.GetNonce(from)
tx.SetNonce(nonce)
if err := self.sign(tx, from, false); err != nil {
@@ -357,7 +363,7 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
if err := self.eth.TxPool().Add(tx); err != nil {
return "", err
}
- state.SetNonce(from, nonce+1)
+ //state.IncrementNonce(from)
if contractCreation {
addr := core.AddressFromMessage(tx)