Merge branch 'master' into tracing
This commit is contained in:
commit
b4c2505eab
@ -33,7 +33,7 @@ env:
|
|||||||
global:
|
global:
|
||||||
# GH_TOKEN
|
# GH_TOKEN
|
||||||
- secure: bumJASbZSU8bxJ0EyPUJmu16AiV9EXOpyOj86Jlq/Ty9CfwGqsSXt96uDyE+OUJf34RUFQMsw0nk37/zC4lcn6kqk2wpuH3N/o85Zo/cVZY/NusBWLQqtT5VbYWsV+u2Ua4Tmmsw8yVYQhYwU2ZOejNpflL+Cs9XGgORp1L+/gMRMC2y5Se6ZhwnKPQlRJ8LGsG1dzjQULxzADIt3/zuspNBS8a2urJwlHfGMkvHDoUWCviP/GXoSqw3TZR7FmKyxE19I8n9+iSvm9+oZZquvcgfUxMHn8Gq/b44UbPvjtFOg2yam4xdWXF/RyWCHdc/R9EHorSABeCbefIsm+zcUF3/YQxwpSxM4IZEeH2rTiC7dcrsKw3XsO16xFQz5YI5Bay+CT/wTdMmJd7DdYz7Dyf+pOvcM9WOf/zorxYWSBOMYy0uzbusU2iyIghQ82s7E/Ahg+WARtPgkuTLSB5aL1oCTBKHqQscMr7lo5Ti6RpWLxEdTQMBznc+bMr+6dEtkEcG9zqc6cE9XX+ox3wTU6+HVMfQ1ltCntJ4UKcw3A6INEbw9wgocQa812CIASQ2fE+SCAbz6JxBjIAlFUnD1lUB7S8PdMPwn9plfQgKQ2A5YZqg6FnBdf0rQXIJYxQWKHXj/rBHSUCT0tHACDlzTA+EwWggvkP5AGIxRxm8jhw=
|
- secure: bumJASbZSU8bxJ0EyPUJmu16AiV9EXOpyOj86Jlq/Ty9CfwGqsSXt96uDyE+OUJf34RUFQMsw0nk37/zC4lcn6kqk2wpuH3N/o85Zo/cVZY/NusBWLQqtT5VbYWsV+u2Ua4Tmmsw8yVYQhYwU2ZOejNpflL+Cs9XGgORp1L+/gMRMC2y5Se6ZhwnKPQlRJ8LGsG1dzjQULxzADIt3/zuspNBS8a2urJwlHfGMkvHDoUWCviP/GXoSqw3TZR7FmKyxE19I8n9+iSvm9+oZZquvcgfUxMHn8Gq/b44UbPvjtFOg2yam4xdWXF/RyWCHdc/R9EHorSABeCbefIsm+zcUF3/YQxwpSxM4IZEeH2rTiC7dcrsKw3XsO16xFQz5YI5Bay+CT/wTdMmJd7DdYz7Dyf+pOvcM9WOf/zorxYWSBOMYy0uzbusU2iyIghQ82s7E/Ahg+WARtPgkuTLSB5aL1oCTBKHqQscMr7lo5Ti6RpWLxEdTQMBznc+bMr+6dEtkEcG9zqc6cE9XX+ox3wTU6+HVMfQ1ltCntJ4UKcw3A6INEbw9wgocQa812CIASQ2fE+SCAbz6JxBjIAlFUnD1lUB7S8PdMPwn9plfQgKQ2A5YZqg6FnBdf0rQXIJYxQWKHXj/rBHSUCT0tHACDlzTA+EwWggvkP5AGIxRxm8jhw=
|
||||||
- TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer"
|
- TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer -p ethjson"
|
||||||
- ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
|
- ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
|
||||||
- KCOV_FEATURES=""
|
- KCOV_FEATURES=""
|
||||||
- KCOV_CMD="./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /usr/,/.cargo,/root/.multirust,src/tests,util/json-tests,util/src/network/tests,sync/src/tests,ethcore/src/tests,ethcore/src/evm/tests target/kcov"
|
- KCOV_CMD="./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /usr/,/.cargo,/root/.multirust,src/tests,util/json-tests,util/src/network/tests,sync/src/tests,ethcore/src/tests,ethcore/src/evm/tests target/kcov"
|
||||||
@ -70,6 +70,7 @@ after_success: |
|
|||||||
$KCOV_CMD target/debug/deps/ethsync-* &&
|
$KCOV_CMD target/debug/deps/ethsync-* &&
|
||||||
$KCOV_CMD target/debug/deps/ethcore_rpc-* &&
|
$KCOV_CMD target/debug/deps/ethcore_rpc-* &&
|
||||||
$KCOV_CMD target/debug/deps/ethminer-* &&
|
$KCOV_CMD target/debug/deps/ethminer-* &&
|
||||||
|
$KCOV_CMD target/debug/deps/ethjson-* &&
|
||||||
$KCOV_CMD target/debug/parity-* &&
|
$KCOV_CMD target/debug/parity-* &&
|
||||||
[ $TRAVIS_BRANCH = master ] &&
|
[ $TRAVIS_BRANCH = master ] &&
|
||||||
[ $TRAVIS_PULL_REQUEST = false ] &&
|
[ $TRAVIS_PULL_REQUEST = false ] &&
|
||||||
|
131
Cargo.lock
generated
131
Cargo.lock
generated
@ -11,7 +11,6 @@ dependencies = [
|
|||||||
"ethcore-devtools 1.1.0",
|
"ethcore-devtools 1.1.0",
|
||||||
"ethcore-rpc 1.1.0",
|
"ethcore-rpc 1.1.0",
|
||||||
"ethcore-util 1.1.0",
|
"ethcore-util 1.1.0",
|
||||||
"ethjson 0.1.0",
|
|
||||||
"ethminer 1.1.0",
|
"ethminer 1.1.0",
|
||||||
"ethsync 1.1.0",
|
"ethsync 1.1.0",
|
||||||
"fdlimit 0.1.0",
|
"fdlimit 0.1.0",
|
||||||
@ -42,10 +41,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aster"
|
name = "aster"
|
||||||
version = "0.13.1"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -53,7 +52,7 @@ name = "bigint"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -140,7 +139,7 @@ source = "git+https://github.com/tomusdrw/rust-ctrlc.git#f4927770f89eca80ec25091
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -164,7 +163,7 @@ name = "docopt"
|
|||||||
version = "0.6.78"
|
version = "0.6.78"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -180,7 +179,7 @@ version = "0.3.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -216,7 +215,8 @@ dependencies = [
|
|||||||
"ethash 1.1.0",
|
"ethash 1.1.0",
|
||||||
"ethcore-devtools 1.1.0",
|
"ethcore-devtools 1.1.0",
|
||||||
"ethcore-util 1.1.0",
|
"ethcore-util 1.1.0",
|
||||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ethjson 0.1.0",
|
||||||
|
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -242,14 +242,14 @@ dependencies = [
|
|||||||
"ethcore-util 1.1.0",
|
"ethcore-util 1.1.0",
|
||||||
"ethminer 1.1.0",
|
"ethminer 1.1.0",
|
||||||
"ethsync 1.1.0",
|
"ethsync 1.1.0",
|
||||||
"jsonrpc-core 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-http-server 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-http-server 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_codegen 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"transient-hashmap 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ dependencies = [
|
|||||||
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
||||||
"ethcore-devtools 1.1.0",
|
"ethcore-devtools 1.1.0",
|
||||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itertools 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itertools 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"json-tests 0.1.0",
|
"json-tests 0.1.0",
|
||||||
@ -295,9 +295,9 @@ dependencies = [
|
|||||||
"ethcore-util 1.1.0",
|
"ethcore-util 1.1.0",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_codegen 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -323,7 +323,7 @@ dependencies = [
|
|||||||
"ethcore 1.1.0",
|
"ethcore 1.1.0",
|
||||||
"ethcore-util 1.1.0",
|
"ethcore-util 1.1.0",
|
||||||
"ethminer 1.1.0",
|
"ethminer 1.1.0",
|
||||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -353,11 +353,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heapsize"
|
name = "heapsize"
|
||||||
version = "0.3.3"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -389,27 +388,27 @@ dependencies = [
|
|||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicase 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper"
|
name = "hyper"
|
||||||
version = "0.7.2"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"httparse 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"httparse 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicase 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -420,7 +419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xml-rs 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
"xml-rs 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xmltree 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"xmltree 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -440,23 +439,23 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-core"
|
name = "jsonrpc-core"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_codegen 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-http-server"
|
name = "jsonrpc-http-server"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-core 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicase 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -464,7 +463,7 @@ name = "kernel32-sys"
|
|||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -496,7 +495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "librocksdb-sys"
|
name = "librocksdb-sys"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
source = "git+https://github.com/arkpar/rust-rocksdb.git#ebb602fc74b4067f9f51310bdc0401b8e59b7156"
|
source = "git+https://github.com/arkpar/rust-rocksdb.git#ae44ef33ed1358ffc79aa05ed77839d555daba33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -531,6 +530,14 @@ dependencies = [
|
|||||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -540,11 +547,11 @@ dependencies = [
|
|||||||
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miow 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miow 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"net2 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"nix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -553,20 +560,20 @@ version = "0.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"net2 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "net2"
|
name = "net2"
|
||||||
version = "0.2.22"
|
version = "0.2.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -665,20 +672,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quasi"
|
name = "quasi"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quasi_codegen"
|
name = "quasi_codegen"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aster 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -701,7 +708,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "0.1.56"
|
version = "0.1.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -718,7 +725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rocksdb"
|
name = "rocksdb"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
source = "git+https://github.com/arkpar/rust-rocksdb.git#ebb602fc74b4067f9f51310bdc0401b8e59b7156"
|
source = "git+https://github.com/arkpar/rust-rocksdb.git#ae44ef33ed1358ffc79aa05ed77839d555daba33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"librocksdb-sys 0.2.3 (git+https://github.com/arkpar/rust-rocksdb.git)",
|
"librocksdb-sys 0.2.3 (git+https://github.com/arkpar/rust-rocksdb.git)",
|
||||||
@ -732,7 +739,7 @@ dependencies = [
|
|||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -788,14 +795,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_codegen"
|
name = "serde_codegen"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aster 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quasi 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quasi_codegen 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -835,18 +842,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syntex"
|
name = "syntex"
|
||||||
version = "0.29.0"
|
version = "0.30.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntex_syntax 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syntex_syntax"
|
name = "syntex_syntax"
|
||||||
version = "0.29.1"
|
version = "0.30.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -865,7 +872,7 @@ version = "0.2.14"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -883,7 +890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -919,7 +926,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -990,7 +997,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1003,7 +1010,7 @@ name = "ws2_32-sys"
|
|||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ ethsync = { path = "sync" }
|
|||||||
ethminer = { path = "miner" }
|
ethminer = { path = "miner" }
|
||||||
ethcore-devtools = { path = "devtools" }
|
ethcore-devtools = { path = "devtools" }
|
||||||
ethcore-rpc = { path = "rpc", optional = true }
|
ethcore-rpc = { path = "rpc", optional = true }
|
||||||
ethjson = { path = "json" }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rpc"]
|
default = ["rpc"]
|
||||||
|
@ -21,6 +21,7 @@ clippy = { version = "0.0.54", optional = true }
|
|||||||
crossbeam = "0.1.5"
|
crossbeam = "0.1.5"
|
||||||
lazy_static = "0.1"
|
lazy_static = "0.1"
|
||||||
ethcore-devtools = { path = "../devtools" }
|
ethcore-devtools = { path = "../devtools" }
|
||||||
|
ethjson = { path = "../json" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
jit = ["evmjit"]
|
jit = ["evmjit"]
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
"enode://248f12bc8b18d5289358085520ac78cd8076485211e6d96ab0bc93d6cd25442db0ce3a937dc404f64f207b0b9aed50e25e98ce32af5ac7cb321ff285b97de485@parity-node-zero.ethcore.io:30303"
|
"enode://248f12bc8b18d5289358085520ac78cd8076485211e6d96ab0bc93d6cd25442db0ce3a937dc404f64f207b0b9aed50e25e98ce32af5ac7cb321ff285b97de485@parity-node-zero.ethcore.io:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||||
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
|
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
|
||||||
"balance": "1337000000000000000000"
|
"balance": "1337000000000000000000"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"engineName": "Frontier (Test)",
|
"name": "Frontier (Test)",
|
||||||
"engineName": "Ethash",
|
"engineName": "Ethash",
|
||||||
"params": {
|
"params": {
|
||||||
"accountStartNonce": "0x00",
|
"accountStartNonce": "0x00",
|
||||||
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"engineName": "Frontier (Test)",
|
"name": "Frontier (Test)",
|
||||||
"engineName": "Ethash",
|
"engineName": "Ethash",
|
||||||
"params": {
|
"params": {
|
||||||
"accountStartNonce": "0x00",
|
"accountStartNonce": "0x00",
|
||||||
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
"gasLimit": "0x2fefd8"
|
"gasLimit": "0x2fefd8"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||||
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
"e6716f9544a56c530d868e4bfbacb172315bdead": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"e6716f9544a56c530d868e4bfbacb172315bdead": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
"b9c015918bdaba24b4ff057a92a3873d6eb201be": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"b9c015918bdaba24b4ff057a92a3873d6eb201be": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
"gasLimit": "0x2fefd8"
|
"gasLimit": "0x2fefd8"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,16 @@ impl Builtin {
|
|||||||
|
|
||||||
/// Create a builtin from JSON.
|
/// Create a builtin from JSON.
|
||||||
///
|
///
|
||||||
/// JSON must be of the form `{ "name": "identity", "linear": {"base": 10, "word": 20} }`.
|
/// JSON must be of the form `{ "name": "identity", "pricing": {"base": 10, "word": 20} }`.
|
||||||
pub fn from_json(json: &Json) -> Option<Builtin> {
|
pub fn from_json(json: &Json) -> Option<Builtin> {
|
||||||
// NICE: figure out a more convenient means of handing errors here.
|
// NICE: figure out a more convenient means of handing errors here.
|
||||||
if let Json::String(ref name) = json["name"] {
|
if let Json::String(ref name) = json["name"] {
|
||||||
if let Json::Object(ref o) = json["linear"] {
|
if let Json::Object(ref o) = json["pricing"] {
|
||||||
if let Json::U64(ref word) = o["word"] {
|
if let Json::Object(ref o) = o["linear"] {
|
||||||
if let Json::U64(ref base) = o["base"] {
|
if let Json::U64(ref word) = o["word"] {
|
||||||
return Self::from_named_linear(&name[..], *base as usize, *word as usize);
|
if let Json::U64(ref base) = o["base"] {
|
||||||
|
return Self::from_named_linear(&name[..], *base as usize, *word as usize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +276,7 @@ fn from_named_linear() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_json() {
|
fn from_json() {
|
||||||
let text = "{ \"name\": \"identity\", \"linear\": {\"base\": 10, \"word\": 20} }";
|
let text = r#"{"name": "identity", "pricing": {"linear": {"base": 10, "word": 20}}}"#;
|
||||||
let json = Json::from_str(text).unwrap();
|
let json = Json::from_str(text).unwrap();
|
||||||
let b = Builtin::from_json(&json).unwrap();
|
let b = Builtin::from_json(&json).unwrap();
|
||||||
assert_eq!((*b.cost)(0), U256::from(10));
|
assert_eq!((*b.cost)(0), U256::from(10));
|
||||||
|
@ -37,6 +37,8 @@ use log_entry::LocalizedLogEntry;
|
|||||||
use block_queue::{BlockQueue, BlockQueueInfo};
|
use block_queue::{BlockQueue, BlockQueueInfo};
|
||||||
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute};
|
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute};
|
||||||
use client::{BlockId, TransactionId, ClientConfig, BlockChainClient};
|
use client::{BlockId, TransactionId, ClientConfig, BlockChainClient};
|
||||||
|
use env_info::EnvInfo;
|
||||||
|
use executive::{Executive, Executed};
|
||||||
pub use blockchain::CacheSize as BlockChainCacheSize;
|
pub use blockchain::CacheSize as BlockChainCacheSize;
|
||||||
|
|
||||||
/// General block status
|
/// General block status
|
||||||
@ -385,6 +387,29 @@ impl<V> Client<V> where V: Verifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<V> BlockChainClient for Client<V> where V: Verifier {
|
impl<V> BlockChainClient for Client<V> where V: Verifier {
|
||||||
|
fn call(&self, t: &SignedTransaction) -> Result<Executed, Error> {
|
||||||
|
let header = self.block_header(BlockId::Latest).unwrap();
|
||||||
|
let view = HeaderView::new(&header);
|
||||||
|
let last_hashes = self.build_last_hashes(view.hash());
|
||||||
|
let env_info = EnvInfo {
|
||||||
|
number: view.number(),
|
||||||
|
author: view.author(),
|
||||||
|
timestamp: view.timestamp(),
|
||||||
|
difficulty: view.difficulty(),
|
||||||
|
last_hashes: last_hashes,
|
||||||
|
gas_used: U256::zero(),
|
||||||
|
gas_limit: U256::max_value(),
|
||||||
|
};
|
||||||
|
// that's just a copy of the state.
|
||||||
|
let mut state = self.state();
|
||||||
|
let sender = try!(t.sender());
|
||||||
|
let balance = state.balance(&sender);
|
||||||
|
// give the sender max balance
|
||||||
|
state.sub_balance(&sender, &balance);
|
||||||
|
state.add_balance(&sender, &U256::max_value());
|
||||||
|
Executive::new(&mut state, &env_info, self.engine.deref().deref()).transact(t, false)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO [todr] Should be moved to miner crate eventually.
|
// TODO [todr] Should be moved to miner crate eventually.
|
||||||
fn try_seal(&self, block: ClosedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock> {
|
fn try_seal(&self, block: ClosedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock> {
|
||||||
block.try_seal(self.engine.deref().deref(), seal)
|
block.try_seal(self.engine.deref().deref(), seal)
|
||||||
|
@ -25,6 +25,7 @@ pub use self::client::*;
|
|||||||
pub use self::config::{ClientConfig, BlockQueueConfig, BlockChainConfig};
|
pub use self::config::{ClientConfig, BlockQueueConfig, BlockChainConfig};
|
||||||
pub use self::ids::{BlockId, TransactionId};
|
pub use self::ids::{BlockId, TransactionId};
|
||||||
pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
||||||
|
pub use executive::Executed;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use util::bytes::Bytes;
|
use util::bytes::Bytes;
|
||||||
@ -37,7 +38,7 @@ use header::BlockNumber;
|
|||||||
use transaction::{LocalizedTransaction, SignedTransaction};
|
use transaction::{LocalizedTransaction, SignedTransaction};
|
||||||
use log_entry::LocalizedLogEntry;
|
use log_entry::LocalizedLogEntry;
|
||||||
use filter::Filter;
|
use filter::Filter;
|
||||||
use error::{ImportResult};
|
use error::{ImportResult, Error};
|
||||||
|
|
||||||
/// Blockchain database client. Owns and manages a blockchain and a block queue.
|
/// Blockchain database client. Owns and manages a blockchain and a block queue.
|
||||||
pub trait BlockChainClient : Sync + Send {
|
pub trait BlockChainClient : Sync + Send {
|
||||||
@ -118,5 +119,7 @@ pub trait BlockChainClient : Sync + Send {
|
|||||||
/// Attempts to seal given block. Returns `SealedBlock` on success and the same block in case of error.
|
/// Attempts to seal given block. Returns `SealedBlock` on success and the same block in case of error.
|
||||||
fn try_seal(&self, block: ClosedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock>;
|
fn try_seal(&self, block: ClosedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock>;
|
||||||
|
|
||||||
|
/// Makes a non-persistent transaction call.
|
||||||
|
fn call(&self, t: &SignedTransaction) -> Result<Executed, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ use error::{ImportResult};
|
|||||||
|
|
||||||
use block_queue::BlockQueueInfo;
|
use block_queue::BlockQueueInfo;
|
||||||
use block::{SealedBlock, ClosedBlock};
|
use block::{SealedBlock, ClosedBlock};
|
||||||
|
use executive::Executed;
|
||||||
|
use error::Error;
|
||||||
|
|
||||||
/// Test client.
|
/// Test client.
|
||||||
pub struct TestBlockChainClient {
|
pub struct TestBlockChainClient {
|
||||||
@ -48,6 +50,8 @@ pub struct TestBlockChainClient {
|
|||||||
pub storage: RwLock<HashMap<(Address, H256), H256>>,
|
pub storage: RwLock<HashMap<(Address, H256), H256>>,
|
||||||
/// Code.
|
/// Code.
|
||||||
pub code: RwLock<HashMap<Address, Bytes>>,
|
pub code: RwLock<HashMap<Address, Bytes>>,
|
||||||
|
/// Execution result.
|
||||||
|
pub execution_result: RwLock<Option<Executed>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -82,12 +86,18 @@ impl TestBlockChainClient {
|
|||||||
balances: RwLock::new(HashMap::new()),
|
balances: RwLock::new(HashMap::new()),
|
||||||
storage: RwLock::new(HashMap::new()),
|
storage: RwLock::new(HashMap::new()),
|
||||||
code: RwLock::new(HashMap::new()),
|
code: RwLock::new(HashMap::new()),
|
||||||
|
execution_result: RwLock::new(None),
|
||||||
};
|
};
|
||||||
client.add_blocks(1, EachBlockWith::Nothing); // add genesis block
|
client.add_blocks(1, EachBlockWith::Nothing); // add genesis block
|
||||||
client.genesis_hash = client.last_hash.read().unwrap().clone();
|
client.genesis_hash = client.last_hash.read().unwrap().clone();
|
||||||
client
|
client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the execution result.
|
||||||
|
pub fn set_execution_result(&self, result: Executed) {
|
||||||
|
*self.execution_result.write().unwrap() = Some(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the balance of account `address` to `balance`.
|
/// Set the balance of account `address` to `balance`.
|
||||||
pub fn set_balance(&self, address: Address, balance: U256) {
|
pub fn set_balance(&self, address: Address, balance: U256) {
|
||||||
self.balances.write().unwrap().insert(address, balance);
|
self.balances.write().unwrap().insert(address, balance);
|
||||||
@ -182,6 +192,10 @@ impl TestBlockChainClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlockChainClient for TestBlockChainClient {
|
impl BlockChainClient for TestBlockChainClient {
|
||||||
|
fn call(&self, _t: &SignedTransaction) -> Result<Executed, Error> {
|
||||||
|
Ok(self.execution_result.read().unwrap().clone().unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
fn block_total_difficulty(&self, _id: BlockId) -> Option<U256> {
|
fn block_total_difficulty(&self, _id: BlockId) -> Option<U256> {
|
||||||
Some(U256::zero())
|
Some(U256::zero())
|
||||||
}
|
}
|
||||||
@ -219,11 +233,11 @@ impl BlockChainClient for TestBlockChainClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_sealing(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes, _transactions: Vec<SignedTransaction>) -> Option<(ClosedBlock, HashSet<H256>)> {
|
fn prepare_sealing(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes, _transactions: Vec<SignedTransaction>) -> Option<(ClosedBlock, HashSet<H256>)> {
|
||||||
unimplemented!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_seal(&self, _block: ClosedBlock, _seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock> {
|
fn try_seal(&self, block: ClosedBlock, _seal: Vec<Bytes>) -> Result<SealedBlock, ClosedBlock> {
|
||||||
unimplemented!()
|
Err(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_header(&self, id: BlockId) -> Option<Bytes> {
|
fn block_header(&self, id: BlockId) -> Option<Bytes> {
|
||||||
|
@ -65,6 +65,10 @@ pub enum ExecutionError {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Errors concerning transaction processing.
|
/// Errors concerning transaction processing.
|
||||||
pub enum TransactionError {
|
pub enum TransactionError {
|
||||||
|
/// Transaction is already imported to the queue
|
||||||
|
AlreadyImported,
|
||||||
|
/// Transaction is not valid anymore (state already has higher nonce)
|
||||||
|
Old,
|
||||||
/// Transaction's gas price is below threshold.
|
/// Transaction's gas price is below threshold.
|
||||||
InsufficientGasPrice {
|
InsufficientGasPrice {
|
||||||
/// Minimal expected gas price
|
/// Minimal expected gas price
|
||||||
|
@ -37,7 +37,7 @@ pub fn contract_address(address: &Address, nonce: &U256) -> Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transaction execution receipt.
|
/// Transaction execution receipt.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct Executed {
|
pub struct Executed {
|
||||||
/// Gas paid up front for execution of transaction.
|
/// Gas paid up front for execution of transaction.
|
||||||
pub gas: U256,
|
pub gas: U256,
|
||||||
@ -66,7 +66,8 @@ pub struct Executed {
|
|||||||
///
|
///
|
||||||
/// B creation ends first, and it will be the first element of the vector.
|
/// B creation ends first, and it will be the first element of the vector.
|
||||||
pub contracts_created: Vec<Address>,
|
pub contracts_created: Vec<Address>,
|
||||||
|
/// Transaction output.
|
||||||
|
pub output: Bytes,
|
||||||
/// The trace of this transaction.
|
/// The trace of this transaction.
|
||||||
pub trace: Option<Trace>,
|
pub trace: Option<Trace>,
|
||||||
}
|
}
|
||||||
@ -152,7 +153,7 @@ impl<'a> Executive<'a> {
|
|||||||
|
|
||||||
let mut substate = Substate::new(tracing);
|
let mut substate = Substate::new(tracing);
|
||||||
|
|
||||||
let res = match t.action {
|
let (gas_left, output) = match t.action {
|
||||||
Action::Create => {
|
Action::Create => {
|
||||||
let new_address = contract_address(&sender, &nonce);
|
let new_address = contract_address(&sender, &nonce);
|
||||||
let params = ActionParams {
|
let params = ActionParams {
|
||||||
@ -166,7 +167,7 @@ impl<'a> Executive<'a> {
|
|||||||
code: Some(t.data.clone()),
|
code: Some(t.data.clone()),
|
||||||
data: None,
|
data: None,
|
||||||
};
|
};
|
||||||
self.create(params, &mut substate)
|
(self.create(params, &mut substate), vec![])
|
||||||
},
|
},
|
||||||
Action::Call(ref address) => {
|
Action::Call(ref address) => {
|
||||||
let params = ActionParams {
|
let params = ActionParams {
|
||||||
@ -182,12 +183,12 @@ impl<'a> Executive<'a> {
|
|||||||
};
|
};
|
||||||
// TODO: move output upstream
|
// TODO: move output upstream
|
||||||
let mut out = vec![];
|
let mut out = vec![];
|
||||||
self.call(params, &mut substate, BytesRef::Flexible(&mut out))
|
(self.call(params, &mut substate, BytesRef::Flexible(&mut out)), out)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// finalize here!
|
// finalize here!
|
||||||
Ok(try!(self.finalize(t, substate, res)))
|
Ok(try!(self.finalize(t, substate, gas_left, output)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec_vm(&mut self, params: ActionParams, unconfirmed_substate: &mut Substate, output_policy: OutputPolicy) -> evm::Result {
|
fn exec_vm(&mut self, params: ActionParams, unconfirmed_substate: &mut Substate, output_policy: OutputPolicy) -> evm::Result {
|
||||||
@ -314,7 +315,7 @@ impl<'a> Executive<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Finalizes the transaction (does refunds and suicides).
|
/// Finalizes the transaction (does refunds and suicides).
|
||||||
fn finalize(&mut self, t: &SignedTransaction, substate: Substate, result: evm::Result) -> ExecutionResult {
|
fn finalize(&mut self, t: &SignedTransaction, substate: Substate, result: evm::Result, output: Bytes) -> ExecutionResult {
|
||||||
let schedule = self.engine.schedule(self.info);
|
let schedule = self.engine.schedule(self.info);
|
||||||
|
|
||||||
// refunds from SSTORE nonzero -> zero
|
// refunds from SSTORE nonzero -> zero
|
||||||
@ -357,6 +358,7 @@ impl<'a> Executive<'a> {
|
|||||||
cumulative_gas_used: self.info.gas_used + t.gas,
|
cumulative_gas_used: self.info.gas_used + t.gas,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
contracts_created: vec![],
|
contracts_created: vec![],
|
||||||
|
output: output,
|
||||||
trace: trace,
|
trace: trace,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -368,6 +370,7 @@ impl<'a> Executive<'a> {
|
|||||||
cumulative_gas_used: self.info.gas_used + gas_used,
|
cumulative_gas_used: self.info.gas_used + gas_used,
|
||||||
logs: substate.logs,
|
logs: substate.logs,
|
||||||
contracts_created: substate.contracts_created,
|
contracts_created: substate.contracts_created,
|
||||||
|
output: output,
|
||||||
trace: trace,
|
trace: trace,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -16,18 +16,19 @@
|
|||||||
|
|
||||||
use super::test_common::*;
|
use super::test_common::*;
|
||||||
use client::{BlockChainClient, Client, ClientConfig};
|
use client::{BlockChainClient, Client, ClientConfig};
|
||||||
use pod_state::*;
|
|
||||||
use block::Block;
|
use block::Block;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
use devtools::*;
|
use devtools::*;
|
||||||
|
use spec::Genesis;
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
||||||
init_log();
|
init_log();
|
||||||
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
|
let tests = ethjson::blockchain::Test::load(json_data).unwrap();
|
||||||
let mut failed = Vec::new();
|
let mut failed = Vec::new();
|
||||||
|
|
||||||
for (name, test) in json.as_object().unwrap() {
|
for (name, blockchain) in tests.deref() {
|
||||||
let mut fail = false;
|
let mut fail = false;
|
||||||
{
|
{
|
||||||
let mut fail_unless = |cond: bool| if !cond && !fail {
|
let mut fail_unless = |cond: bool| if !cond && !fail {
|
||||||
@ -39,37 +40,36 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
|||||||
|
|
||||||
flush!(" - {}...", name);
|
flush!(" - {}...", name);
|
||||||
|
|
||||||
let blocks: Vec<(Bytes, bool)> = test["blocks"].as_array().unwrap().iter().map(|e| (xjson!(&e["rlp"]), e.find("blockHeader").is_some())).collect();
|
|
||||||
let mut spec = match era {
|
let mut spec = match era {
|
||||||
ChainEra::Frontier => ethereum::new_frontier_test(),
|
ChainEra::Frontier => ethereum::new_frontier_test(),
|
||||||
ChainEra::Homestead => ethereum::new_homestead_test(),
|
ChainEra::Homestead => ethereum::new_homestead_test(),
|
||||||
};
|
};
|
||||||
let s = PodState::from_json(test.find("pre").unwrap());
|
|
||||||
spec.set_genesis_state(s);
|
let genesis = Genesis::from(blockchain.genesis());
|
||||||
spec.overwrite_genesis(test.find("genesisBlockHeader").unwrap());
|
let state = From::from(blockchain.pre_state.clone());
|
||||||
|
spec.set_genesis_state(state);
|
||||||
|
spec.overwrite_genesis_params(genesis);
|
||||||
assert!(spec.is_state_root_valid());
|
assert!(spec.is_state_root_valid());
|
||||||
let genesis_hash = spec.genesis_header().hash();
|
|
||||||
assert_eq!(genesis_hash, H256::from_json(&test.find("genesisBlockHeader").unwrap()["hash"]));
|
|
||||||
|
|
||||||
let temp = RandomTempPath::new();
|
let temp = RandomTempPath::new();
|
||||||
{
|
{
|
||||||
let client = Client::new(ClientConfig::default(), spec, temp.as_path(), IoChannel::disconnected()).unwrap();
|
let client = Client::new(ClientConfig::default(), spec, temp.as_path(), IoChannel::disconnected()).unwrap();
|
||||||
assert_eq!(client.chain_info().best_block_hash, genesis_hash);
|
for b in &blockchain.blocks_rlp() {
|
||||||
for (b, is_valid) in blocks.into_iter() {
|
|
||||||
if Block::is_good(&b) {
|
if Block::is_good(&b) {
|
||||||
let _ = client.import_block(b.clone());
|
let _ = client.import_block(b.clone());
|
||||||
|
client.flush_queue();
|
||||||
|
client.import_verified_blocks(&IoChannel::disconnected());
|
||||||
}
|
}
|
||||||
client.flush_queue();
|
|
||||||
let imported_ok = client.import_verified_blocks(&IoChannel::disconnected()) > 0;
|
|
||||||
assert_eq!(imported_ok, is_valid);
|
|
||||||
}
|
}
|
||||||
fail_unless(client.chain_info().best_block_hash == H256::from_json(&test["lastblockhash"]));
|
fail_unless(client.chain_info().best_block_hash == blockchain.best_block.clone().into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fail {
|
if !fail {
|
||||||
flushln!("ok");
|
flushln!("ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("!!! {:?} tests from failed.", failed.len());
|
println!("!!! {:?} tests from failed.", failed.len());
|
||||||
failed
|
failed
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ extern crate time;
|
|||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
extern crate crossbeam;
|
extern crate crossbeam;
|
||||||
|
extern crate ethjson;
|
||||||
|
|
||||||
#[cfg(test)] extern crate ethcore_devtools as devtools;
|
#[cfg(test)] extern crate ethcore_devtools as devtools;
|
||||||
#[cfg(feature = "jit" )] extern crate evmjit;
|
#[cfg(feature = "jit" )] extern crate evmjit;
|
||||||
@ -101,13 +102,13 @@ pub mod spec;
|
|||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
pub mod views;
|
pub mod views;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
|
pub mod pod_state;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
mod basic_types;
|
mod basic_types;
|
||||||
#[macro_use] mod evm;
|
#[macro_use] mod evm;
|
||||||
mod env_info;
|
mod env_info;
|
||||||
mod pod_account;
|
mod pod_account;
|
||||||
mod pod_state;
|
|
||||||
mod account_diff;
|
mod account_diff;
|
||||||
mod state_diff;
|
mod state_diff;
|
||||||
mod engine;
|
mod engine;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
use util::*;
|
use util::*;
|
||||||
use account::*;
|
use account::*;
|
||||||
use account_db::*;
|
use account_db::*;
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Eq)]
|
#[derive(Debug,Clone,PartialEq,Eq)]
|
||||||
/// An account, expressed as Plain-Old-Data (hence the name).
|
/// An account, expressed as Plain-Old-Data (hence the name).
|
||||||
@ -73,6 +74,22 @@ impl PodAccount {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ethjson::blockchain::Account> for PodAccount {
|
||||||
|
fn from(a: ethjson::blockchain::Account) -> Self {
|
||||||
|
PodAccount {
|
||||||
|
balance: a.balance.into(),
|
||||||
|
nonce: a.nonce.into(),
|
||||||
|
code: a.code.into(),
|
||||||
|
storage: a.storage.into_iter().fold(BTreeMap::new(), |mut acc, (key, value)| {
|
||||||
|
let key: U256 = key.into();
|
||||||
|
let value: U256 = value.into();
|
||||||
|
acc.insert(H256::from(key), H256::from(value));
|
||||||
|
acc
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for PodAccount {
|
impl fmt::Display for PodAccount {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "(bal={}; nonce={}; code={} bytes, #{}; storage={} items)", self.balance, self.nonce, self.code.len(), self.code.sha3(), self.storage.len())
|
write!(f, "(bal={}; nonce={}; code={} bytes, #{}; storage={} items)", self.balance, self.nonce, self.code.len(), self.code.sha3(), self.storage.len())
|
||||||
|
@ -14,11 +14,14 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! State of all accounts in the system expressed in Plain Old Data.
|
||||||
|
|
||||||
use util::*;
|
use util::*;
|
||||||
use pod_account::*;
|
use pod_account::*;
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Eq,Default)]
|
|
||||||
/// State of all accounts in the system expressed in Plain Old Data.
|
/// State of all accounts in the system expressed in Plain Old Data.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||||
pub struct PodState (BTreeMap<Address, PodAccount>);
|
pub struct PodState (BTreeMap<Address, PodAccount>);
|
||||||
|
|
||||||
impl PodState {
|
impl PodState {
|
||||||
@ -64,6 +67,15 @@ impl FromJson for PodState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ethjson::blockchain::State> for PodState {
|
||||||
|
fn from(s: ethjson::blockchain::State) -> PodState {
|
||||||
|
PodState(s.0.into_iter().fold(BTreeMap::new(), |mut acc, (key, value)| {
|
||||||
|
acc.insert(key.into(), PodAccount::from(value));
|
||||||
|
acc
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for PodState {
|
impl fmt::Display for PodState {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
for (add, acc) in &self.0 {
|
for (add, acc) in &self.0 {
|
||||||
|
91
ethcore/src/spec/genesis.rs
Normal file
91
ethcore/src/spec/genesis.rs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use util::rlp::*;
|
||||||
|
use util::numbers::{Uint, U256};
|
||||||
|
use util::hash::{H64, Address, H256};
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
|
/// Genesis seal type.
|
||||||
|
pub enum Seal {
|
||||||
|
/// Classic ethereum seal.
|
||||||
|
Ethereum {
|
||||||
|
/// Seal nonce.
|
||||||
|
nonce: H64,
|
||||||
|
/// Seal mix hash.
|
||||||
|
mix_hash: H256,
|
||||||
|
},
|
||||||
|
/// Generic seal.
|
||||||
|
Generic {
|
||||||
|
/// Number of seal fields.
|
||||||
|
fields: usize,
|
||||||
|
/// Seal rlp.
|
||||||
|
rlp: Vec<u8>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Genesis components.
|
||||||
|
pub struct Genesis {
|
||||||
|
/// Seal.
|
||||||
|
pub seal: Seal,
|
||||||
|
/// Difficulty.
|
||||||
|
pub difficulty: U256,
|
||||||
|
/// Author.
|
||||||
|
pub author: Address,
|
||||||
|
/// Timestamp.
|
||||||
|
pub timestamp: u64,
|
||||||
|
/// Parent hash.
|
||||||
|
pub parent_hash: H256,
|
||||||
|
/// Gas limit.
|
||||||
|
pub gas_limit: U256,
|
||||||
|
/// Transactions root.
|
||||||
|
pub transactions_root: H256,
|
||||||
|
/// Receipts root.
|
||||||
|
pub receipts_root: H256,
|
||||||
|
/// State root.
|
||||||
|
pub state_root: Option<H256>,
|
||||||
|
/// Gas used.
|
||||||
|
pub gas_used: U256,
|
||||||
|
/// Extra data.
|
||||||
|
pub extra_data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ethjson::spec::Genesis> for Genesis {
|
||||||
|
fn from(g: ethjson::spec::Genesis) -> Self {
|
||||||
|
Genesis {
|
||||||
|
seal: match (g.nonce, g.mix_hash) {
|
||||||
|
(Some(nonce), Some(mix_hash)) => Seal::Ethereum {
|
||||||
|
nonce: nonce.into(),
|
||||||
|
mix_hash: mix_hash.into(),
|
||||||
|
},
|
||||||
|
_ => Seal::Generic {
|
||||||
|
fields: g.seal_fields.unwrap(),
|
||||||
|
rlp: g.seal_rlp.unwrap().into(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
difficulty: g.difficulty.into(),
|
||||||
|
author: g.author.into(),
|
||||||
|
timestamp: g.timestamp.into(),
|
||||||
|
parent_hash: g.parent_hash.into(),
|
||||||
|
gas_limit: g.gas_limit.into(),
|
||||||
|
transactions_root: g.transactions_root.map_or_else(|| SHA3_NULL_RLP.clone(), Into::into),
|
||||||
|
receipts_root: g.receipts_root.map_or_else(|| SHA3_NULL_RLP.clone(), Into::into),
|
||||||
|
state_root: g.state_root.map(Into::into),
|
||||||
|
gas_used: g.gas_used.map_or_else(U256::zero, Into::into),
|
||||||
|
extra_data: g.extra_data.map_or_else(Vec::new, Into::into),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
ethcore/src/spec/mod.rs
Normal file
23
ethcore/src/spec/mod.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Blockchain params.
|
||||||
|
|
||||||
|
mod genesis;
|
||||||
|
pub mod spec;
|
||||||
|
|
||||||
|
pub use self::spec::*;
|
||||||
|
pub use self::genesis::Genesis;
|
@ -21,6 +21,8 @@ use engine::*;
|
|||||||
use pod_state::*;
|
use pod_state::*;
|
||||||
use null_engine::*;
|
use null_engine::*;
|
||||||
use account_db::*;
|
use account_db::*;
|
||||||
|
use ethereum;
|
||||||
|
use super::genesis::{Seal as GenesisSeal, Genesis};
|
||||||
|
|
||||||
/// Convert JSON value to equivalent RLP representation.
|
/// Convert JSON value to equivalent RLP representation.
|
||||||
// TODO: handle container types.
|
// TODO: handle container types.
|
||||||
@ -106,7 +108,7 @@ impl Spec {
|
|||||||
pub fn to_engine(self) -> Result<Box<Engine>, Error> {
|
pub fn to_engine(self) -> Result<Box<Engine>, Error> {
|
||||||
match self.engine_name.as_ref() {
|
match self.engine_name.as_ref() {
|
||||||
"NullEngine" => Ok(NullEngine::new_boxed(self)),
|
"NullEngine" => Ok(NullEngine::new_boxed(self)),
|
||||||
"Ethash" => Ok(super::ethereum::Ethash::new_boxed(self)),
|
"Ethash" => Ok(ethereum::Ethash::new_boxed(self)),
|
||||||
_ => Err(Error::UnknownEngineName(self.engine_name.clone()))
|
_ => Err(Error::UnknownEngineName(self.engine_name.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,6 +199,32 @@ impl Spec {
|
|||||||
self.state_root_memo = RwLock::new(genesis.find("stateRoot").and_then(|_| Some(H256::from_json(&genesis["stateRoot"]))));
|
self.state_root_memo = RwLock::new(genesis.find("stateRoot").and_then(|_| Some(H256::from_json(&genesis["stateRoot"]))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Overwrite the genesis components.
|
||||||
|
pub fn overwrite_genesis_params(&mut self, g: Genesis) {
|
||||||
|
let (seal_fields, seal_rlp) = match g.seal {
|
||||||
|
GenesisSeal::Generic { fields, rlp } => (fields, rlp),
|
||||||
|
GenesisSeal::Ethereum { nonce, mix_hash } => {
|
||||||
|
let mut s = RlpStream::new();
|
||||||
|
s.append(&mix_hash);
|
||||||
|
s.append(&nonce);
|
||||||
|
(2, s.out())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.parent_hash = g.parent_hash;
|
||||||
|
self.transactions_root = g.transactions_root;
|
||||||
|
self.receipts_root = g.receipts_root;
|
||||||
|
self.author = g.author;
|
||||||
|
self.difficulty = g.difficulty;
|
||||||
|
self.gas_limit = g.gas_limit;
|
||||||
|
self.gas_used = g.gas_used;
|
||||||
|
self.timestamp = g.timestamp;
|
||||||
|
self.extra_data = g.extra_data;
|
||||||
|
self.seal_fields = seal_fields;
|
||||||
|
self.seal_rlp = seal_rlp;
|
||||||
|
self.state_root_memo = RwLock::new(g.state_root);
|
||||||
|
}
|
||||||
|
|
||||||
/// Alter the value of the genesis state.
|
/// Alter the value of the genesis state.
|
||||||
pub fn set_genesis_state(&mut self, s: PodState) {
|
pub fn set_genesis_state(&mut self, s: PodState) {
|
||||||
self.genesis_state = s;
|
self.genesis_state = s;
|
||||||
@ -304,7 +332,7 @@ impl Spec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Spec which conforms to the Morden chain except that it's a NullEngine consensus.
|
/// Create a new Spec which conforms to the Morden chain except that it's a NullEngine consensus.
|
||||||
pub fn new_test() -> Spec { Self::from_json_utf8(include_bytes!("../res/null_morden.json")) }
|
pub fn new_test() -> Spec { Self::from_json_utf8(include_bytes!("../../res/null_morden.json")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
@ -256,6 +256,9 @@ impl<'a> HeaderView<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns header hash.
|
||||||
|
pub fn hash(&self) -> H256 { self.sha3() }
|
||||||
|
|
||||||
/// Returns raw rlp.
|
/// Returns raw rlp.
|
||||||
pub fn rlp(&self) -> &Rlp<'a> { &self.rlp }
|
pub fn rlp(&self) -> &Rlp<'a> { &self.rlp }
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ clippy = { version = "0.0.54", optional = true }
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_codegen = { version = "0.7.0", optional = true }
|
serde_codegen = { version = "0.7.0", optional = true }
|
||||||
syntex = "0.29.0"
|
syntex = "0.30.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde_codegen"]
|
default = ["serde_codegen"]
|
||||||
|
@ -21,12 +21,16 @@ use uint::Uint;
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
/// Blockchain test account deserializer.
|
/// Blockchain test account deserializer.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
balance: Uint,
|
/// Balance.
|
||||||
code: Bytes,
|
pub balance: Uint,
|
||||||
nonce: Uint,
|
/// Code.
|
||||||
storage: BTreeMap<Uint, Bytes>,
|
pub code: Bytes,
|
||||||
|
/// Nonce.
|
||||||
|
pub nonce: Uint,
|
||||||
|
/// Storage.
|
||||||
|
pub storage: BTreeMap<Uint, Uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -35,7 +39,7 @@ mod tests {
|
|||||||
use blockchain::account::Account;
|
use blockchain::account::Account;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn header_deserialization() {
|
fn account_deserialization() {
|
||||||
let s = r#"{
|
let s = r#"{
|
||||||
"balance" : "0x09184e72a078",
|
"balance" : "0x09184e72a078",
|
||||||
"code" : "0x600140600155",
|
"code" : "0x600140600155",
|
||||||
|
@ -24,11 +24,18 @@ use blockchain::transaction::Transaction;
|
|||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
#[serde(rename="blockHeader")]
|
#[serde(rename="blockHeader")]
|
||||||
header: Header,
|
header: Option<Header>,
|
||||||
rlp: Bytes,
|
rlp: Bytes,
|
||||||
transactions: Vec<Transaction>,
|
transactions: Option<Vec<Transaction>>,
|
||||||
#[serde(rename="uncleHeaders")]
|
#[serde(rename="uncleHeaders")]
|
||||||
uncles: Vec<Header>,
|
uncles: Option<Vec<Header>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Block {
|
||||||
|
/// Returns block rlp.
|
||||||
|
pub fn rlp(&self) -> Vec<u8> {
|
||||||
|
self.rlp.clone().into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -17,22 +17,59 @@
|
|||||||
//! Blockchain deserialization.
|
//! Blockchain deserialization.
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use hash::H256;
|
||||||
use blockchain::state::State;
|
use blockchain::state::State;
|
||||||
use blockchain::header::Header;
|
use blockchain::header::Header;
|
||||||
use blockchain::block::Block;
|
use blockchain::block::Block;
|
||||||
|
use spec::Genesis;
|
||||||
|
|
||||||
/// Blockchain deserialization.
|
/// Blockchain deserialization.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct BlockChain {
|
pub struct BlockChain {
|
||||||
|
/// Genesis block header.
|
||||||
#[serde(rename="genesisBlockHeader")]
|
#[serde(rename="genesisBlockHeader")]
|
||||||
genesis_block: Header,
|
pub genesis_block: Header,
|
||||||
|
/// Genesis block rlp.
|
||||||
#[serde(rename="genesisRLP")]
|
#[serde(rename="genesisRLP")]
|
||||||
genesis_rlp: Bytes,
|
pub genesis_rlp: Option<Bytes>,
|
||||||
blocks: Vec<Block>,
|
/// Blocks.
|
||||||
|
pub blocks: Vec<Block>,
|
||||||
|
/// Post state.
|
||||||
#[serde(rename="postState")]
|
#[serde(rename="postState")]
|
||||||
post_state: State,
|
pub post_state: State,
|
||||||
|
/// Pre state.
|
||||||
#[serde(rename="pre")]
|
#[serde(rename="pre")]
|
||||||
pre_state: State,
|
pub pre_state: State,
|
||||||
|
/// Hash of best block.
|
||||||
|
#[serde(rename="lastblockhash")]
|
||||||
|
pub best_block: H256
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BlockChain {
|
||||||
|
/// Returns blocks rlp.
|
||||||
|
pub fn blocks_rlp(&self) -> Vec<Vec<u8>> {
|
||||||
|
self.blocks.iter().map(|block| block.rlp()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns spec compatible genesis struct.
|
||||||
|
pub fn genesis(&self) -> Genesis {
|
||||||
|
Genesis {
|
||||||
|
nonce: Some(self.genesis_block.nonce.clone()),
|
||||||
|
mix_hash: Some(self.genesis_block.mix_hash.clone()),
|
||||||
|
seal_fields: None,
|
||||||
|
seal_rlp: None,
|
||||||
|
difficulty: self.genesis_block.difficulty,
|
||||||
|
author: self.genesis_block.author.clone(),
|
||||||
|
timestamp: self.genesis_block.timestamp,
|
||||||
|
parent_hash: self.genesis_block.parent_hash.clone(),
|
||||||
|
gas_limit: self.genesis_block.gas_limit,
|
||||||
|
transactions_root: Some(self.genesis_block.transactions_root.clone()),
|
||||||
|
receipts_root: Some(self.genesis_block.receipts_root.clone()),
|
||||||
|
state_root: Some(self.genesis_block.state_root.clone()),
|
||||||
|
gas_used: Some(self.genesis_block.gas_used),
|
||||||
|
extra_data: Some(self.genesis_block.extra_data.clone()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -23,31 +23,48 @@ use bytes::Bytes;
|
|||||||
/// Blockchain test header deserializer.
|
/// Blockchain test header deserializer.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
bloom: Bloom,
|
/// Blocks bloom.
|
||||||
coinbase: Address,
|
pub bloom: Bloom,
|
||||||
difficulty: Uint,
|
/// Blocks author.
|
||||||
|
#[serde(rename="coinbase")]
|
||||||
|
pub author: Address,
|
||||||
|
/// Difficulty.
|
||||||
|
pub difficulty: Uint,
|
||||||
#[serde(rename="extraData")]
|
#[serde(rename="extraData")]
|
||||||
extra_data: Bytes,
|
/// Extra data.
|
||||||
|
pub extra_data: Bytes,
|
||||||
|
/// Gas limit.
|
||||||
#[serde(rename="gasLimit")]
|
#[serde(rename="gasLimit")]
|
||||||
gas_limit: Uint,
|
pub gas_limit: Uint,
|
||||||
|
/// Gas used.
|
||||||
#[serde(rename="gasUsed")]
|
#[serde(rename="gasUsed")]
|
||||||
gas_used: Uint,
|
pub gas_used: Uint,
|
||||||
hash: H256,
|
/// Hash.
|
||||||
|
pub hash: H256,
|
||||||
#[serde(rename="mixHash")]
|
#[serde(rename="mixHash")]
|
||||||
mix_hash: H256,
|
/// Mix hash.
|
||||||
nonce: H64,
|
pub mix_hash: H256,
|
||||||
number: Uint,
|
/// Seal nonce.
|
||||||
|
pub nonce: H64,
|
||||||
|
/// Block number.
|
||||||
|
pub number: Uint,
|
||||||
|
/// Parent hash.
|
||||||
#[serde(rename="parentHash")]
|
#[serde(rename="parentHash")]
|
||||||
parent_hash: H256,
|
pub parent_hash: H256,
|
||||||
|
/// Receipt root.
|
||||||
#[serde(rename="receiptTrie")]
|
#[serde(rename="receiptTrie")]
|
||||||
receipt_trie: H256,
|
pub receipts_root: H256,
|
||||||
|
/// State root.
|
||||||
#[serde(rename="stateRoot")]
|
#[serde(rename="stateRoot")]
|
||||||
state_root: H256,
|
pub state_root: H256,
|
||||||
timestamp: Uint,
|
/// Timestamp.
|
||||||
|
pub timestamp: Uint,
|
||||||
|
/// Transactions root.
|
||||||
#[serde(rename="transactionsTrie")]
|
#[serde(rename="transactionsTrie")]
|
||||||
transactions_trie: H256,
|
pub transactions_root: H256,
|
||||||
|
/// Uncles hash.
|
||||||
#[serde(rename="uncleHash")]
|
#[serde(rename="uncleHash")]
|
||||||
uncle_hash: H256,
|
pub uncles_hash: H256,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -23,3 +23,11 @@ pub mod header;
|
|||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
|
pub use self::account::Account;
|
||||||
|
pub use self::block::Block;
|
||||||
|
pub use self::blockchain::BlockChain;
|
||||||
|
pub use self::header::Header;
|
||||||
|
pub use self::state::State;
|
||||||
|
pub use self::test::Test;
|
||||||
|
pub use self::transaction::Transaction;
|
||||||
|
@ -22,8 +22,8 @@ use hash::Address;
|
|||||||
use blockchain::account::Account;
|
use blockchain::account::Account;
|
||||||
|
|
||||||
/// Blockchain test state deserializer.
|
/// Blockchain test state deserializer.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||||
pub struct State(BTreeMap<Address, Account>);
|
pub struct State(pub BTreeMap<Address, Account>);
|
||||||
|
|
||||||
impl Deref for State {
|
impl Deref for State {
|
||||||
type Target = BTreeMap<Address, Account>;
|
type Target = BTreeMap<Address, Account>;
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
use std::io::Read;
|
||||||
|
use serde_json;
|
||||||
|
use serde_json::Error;
|
||||||
use blockchain::blockchain::BlockChain;
|
use blockchain::blockchain::BlockChain;
|
||||||
|
|
||||||
/// Blockchain test deserializer.
|
/// Blockchain test deserializer.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct Test(BTreeMap<String, BlockChain>);
|
pub struct Test(BTreeMap<String, BlockChain>);
|
||||||
|
|
||||||
impl Deref for Test {
|
impl Deref for Test {
|
||||||
@ -30,3 +34,10 @@ impl Deref for Test {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Test {
|
||||||
|
/// Loads test from json.
|
||||||
|
pub fn load<R>(reader: R) -> Result<Self, Error> where R: Read {
|
||||||
|
serde_json::from_reader(reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ use serde::{Deserialize, Deserializer, Error};
|
|||||||
use serde::de::Visitor;
|
use serde::de::Visitor;
|
||||||
|
|
||||||
/// Lenient bytes json deserialization for test json files.
|
/// Lenient bytes json deserialization for test json files.
|
||||||
#[derive(Default, Debug, PartialEq)]
|
#[derive(Default, Debug, PartialEq, Clone)]
|
||||||
pub struct Bytes(Vec<u8>);
|
pub struct Bytes(Vec<u8>);
|
||||||
|
|
||||||
impl Into<Vec<u8>> for Bytes {
|
impl Into<Vec<u8>> for Bytes {
|
||||||
@ -46,12 +46,8 @@ impl Visitor for BytesVisitor {
|
|||||||
let v = match value.len() {
|
let v = match value.len() {
|
||||||
0 => vec![],
|
0 => vec![],
|
||||||
2 if value.starts_with("0x") => vec![],
|
2 if value.starts_with("0x") => vec![],
|
||||||
_ if value.starts_with("0x") => try!(FromHex::from_hex(&value[2..]).map_err(|_| {
|
_ if value.starts_with("0x") => FromHex::from_hex(&value[2..]).unwrap_or(vec![]),
|
||||||
Error::custom(format!("Invalid hex value {}.", value).as_ref())
|
_ => FromHex::from_hex(value).unwrap_or(vec![]),
|
||||||
})),
|
|
||||||
_ => try!(FromHex::from_hex(value).map_err(|_| {
|
|
||||||
Error::custom(format!("Invalid hex value {}.", value).as_ref())
|
|
||||||
}))
|
|
||||||
};
|
};
|
||||||
Ok(Bytes(v))
|
Ok(Bytes(v))
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use util::hash::{H64 as Hash64, Address as Hash160, H256 as Hash256, H2048 as Ha
|
|||||||
macro_rules! impl_hash {
|
macro_rules! impl_hash {
|
||||||
($name: ident, $inner: ident) => {
|
($name: ident, $inner: ident) => {
|
||||||
/// Lenient hash json deserialization for test json files.
|
/// Lenient hash json deserialization for test json files.
|
||||||
#[derive(Default, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Default, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone)]
|
||||||
pub struct $name($inner);
|
pub struct $name($inner);
|
||||||
|
|
||||||
impl Into<$inner> for $name {
|
impl Into<$inner> for $name {
|
||||||
@ -46,6 +46,10 @@ macro_rules! impl_hash {
|
|||||||
fn visit_str<E>(&mut self, value: &str) -> Result<Self::Value, E> where E: Error {
|
fn visit_str<E>(&mut self, value: &str) -> Result<Self::Value, E> where E: Error {
|
||||||
let value = match value.len() {
|
let value = match value.len() {
|
||||||
0 => $inner::from(0),
|
0 => $inner::from(0),
|
||||||
|
2 if value == "0x" => $inner::from(0),
|
||||||
|
_ if value.starts_with("0x") => try!($inner::from_str(&value[2..]).map_err(|_| {
|
||||||
|
Error::custom(format!("Invalid hex value {}.", value).as_ref())
|
||||||
|
})),
|
||||||
_ => try!($inner::from_str(value).map_err(|_| {
|
_ => try!($inner::from_str(value).map_err(|_| {
|
||||||
Error::custom(format!("Invalid hex value {}.", value).as_ref())
|
Error::custom(format!("Invalid hex value {}.", value).as_ref())
|
||||||
}))
|
}))
|
||||||
|
@ -23,3 +23,4 @@ pub mod hash;
|
|||||||
pub mod uint;
|
pub mod uint;
|
||||||
pub mod bytes;
|
pub mod bytes;
|
||||||
pub mod blockchain;
|
pub mod blockchain;
|
||||||
|
pub mod spec;
|
||||||
|
44
json/src/spec/account.rs
Normal file
44
json/src/spec/account.rs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec account deserialization.
|
||||||
|
|
||||||
|
use uint::Uint;
|
||||||
|
use spec::builtin::Builtin;
|
||||||
|
|
||||||
|
/// Spec account.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Account {
|
||||||
|
builtin: Option<Builtin>,
|
||||||
|
balance: Option<Uint>,
|
||||||
|
nonce: Option<Uint>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json;
|
||||||
|
use spec::account::Account;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn account_deserialization() {
|
||||||
|
let s = r#"{
|
||||||
|
"balance": "1",
|
||||||
|
"builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }
|
||||||
|
}"#;
|
||||||
|
let _deserialized: Account = serde_json::from_str(s).unwrap();
|
||||||
|
// TODO: validate all fields
|
||||||
|
}
|
||||||
|
}
|
55
json/src/spec/builtin.rs
Normal file
55
json/src/spec/builtin.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec builtin deserialization.
|
||||||
|
|
||||||
|
/// Linear pricing.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Linear {
|
||||||
|
base: u64,
|
||||||
|
word: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pricing variants.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub enum Pricing {
|
||||||
|
/// Linear pricing.
|
||||||
|
#[serde(rename="linear")]
|
||||||
|
Linear(Linear),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spec builtin.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Builtin {
|
||||||
|
name: String,
|
||||||
|
pricing: Pricing,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json;
|
||||||
|
use spec::builtin::Builtin;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn builtin_deserialization() {
|
||||||
|
let s = r#"{
|
||||||
|
"name": "ecrecover",
|
||||||
|
"pricing": { "linear": { "base": 3000, "word": 0 } }
|
||||||
|
}"#;
|
||||||
|
let _deserialized: Builtin = serde_json::from_str(s).unwrap();
|
||||||
|
// TODO: validate all fields
|
||||||
|
}
|
||||||
|
}
|
91
json/src/spec/genesis.rs
Normal file
91
json/src/spec/genesis.rs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec genesis deserialization.
|
||||||
|
|
||||||
|
use uint::Uint;
|
||||||
|
use hash::{H64, Address, H256};
|
||||||
|
use bytes::Bytes;
|
||||||
|
|
||||||
|
/// Spec genesis.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Genesis {
|
||||||
|
// old seal
|
||||||
|
/// Seal nonce.
|
||||||
|
pub nonce: Option<H64>,
|
||||||
|
#[serde(rename="mixHash")]
|
||||||
|
/// Seal mix hash.
|
||||||
|
pub mix_hash: Option<H256>,
|
||||||
|
|
||||||
|
// new seal // TODO: consider moving it to a separate seal structure
|
||||||
|
#[serde(rename="sealFields")]
|
||||||
|
/// Number of seal fields.
|
||||||
|
pub seal_fields: Option<usize>,
|
||||||
|
#[serde(rename="sealRlp")]
|
||||||
|
/// Seal rlp.
|
||||||
|
pub seal_rlp: Option<Bytes>,
|
||||||
|
|
||||||
|
/// Difficulty.
|
||||||
|
pub difficulty: Uint,
|
||||||
|
/// Block author.
|
||||||
|
pub author: Address,
|
||||||
|
/// Block timestamp.
|
||||||
|
pub timestamp: Uint,
|
||||||
|
/// Parent hash.
|
||||||
|
#[serde(rename="parentHash")]
|
||||||
|
pub parent_hash: H256,
|
||||||
|
/// Gas limit.
|
||||||
|
#[serde(rename="gasLimit")]
|
||||||
|
pub gas_limit: Uint,
|
||||||
|
/// Transactions root.
|
||||||
|
#[serde(rename="transactionsRoot")]
|
||||||
|
pub transactions_root: Option<H256>,
|
||||||
|
/// Receipts root.
|
||||||
|
#[serde(rename="receiptsRoot")]
|
||||||
|
pub receipts_root: Option<H256>,
|
||||||
|
/// State root.
|
||||||
|
#[serde(rename="stateRoot")]
|
||||||
|
pub state_root: Option<H256>,
|
||||||
|
/// Gas used.
|
||||||
|
#[serde(rename="gasUsed")]
|
||||||
|
pub gas_used: Option<Uint>,
|
||||||
|
/// Extra data.
|
||||||
|
#[serde(rename="extraData")]
|
||||||
|
pub extra_data: Option<Bytes>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json;
|
||||||
|
use spec::genesis::Genesis;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn genesis_deserialization() {
|
||||||
|
let s = r#"{
|
||||||
|
"nonce": "0x0000000000000042",
|
||||||
|
"difficulty": "0x400000000",
|
||||||
|
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"author": "0x0000000000000000000000000000000000000000",
|
||||||
|
"timestamp": "0x00",
|
||||||
|
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
|
||||||
|
"gasLimit": "0x1388",
|
||||||
|
"stateRoot": "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"
|
||||||
|
}"#;
|
||||||
|
let _deserialized: Genesis = serde_json::from_str(s).unwrap();
|
||||||
|
// TODO: validate all fields
|
||||||
|
}
|
||||||
|
}
|
29
json/src/spec/mod.rs
Normal file
29
json/src/spec/mod.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec deserialization.
|
||||||
|
|
||||||
|
pub mod account;
|
||||||
|
pub mod builtin;
|
||||||
|
pub mod genesis;
|
||||||
|
pub mod params;
|
||||||
|
pub mod spec;
|
||||||
|
|
||||||
|
pub use self::account::Account;
|
||||||
|
pub use self::builtin::Builtin;
|
||||||
|
pub use self::genesis::Genesis;
|
||||||
|
pub use self::params::Params;
|
||||||
|
pub use self::spec::Spec;
|
74
json/src/spec/params.rs
Normal file
74
json/src/spec/params.rs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec params deserialization.
|
||||||
|
|
||||||
|
use uint::Uint;
|
||||||
|
use hash::Address;
|
||||||
|
|
||||||
|
/// Spec params.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Params {
|
||||||
|
#[serde(rename="accountStartNonce")]
|
||||||
|
account_start_nonce: Uint,
|
||||||
|
#[serde(rename="frontierCompatibilityModeLimit")]
|
||||||
|
frontier_compatibility_mode_limit: Uint,
|
||||||
|
#[serde(rename="maximumExtraDataSize")]
|
||||||
|
maximum_extra_data_size: Uint,
|
||||||
|
#[serde(rename="tieBreakingGas")]
|
||||||
|
tie_breaking_gas: bool,
|
||||||
|
#[serde(rename="minGasLimit")]
|
||||||
|
min_gas_limit: Uint,
|
||||||
|
#[serde(rename="gasLimitBoundDivisor")]
|
||||||
|
gas_limit_bound_divisor: Uint,
|
||||||
|
#[serde(rename="minimumDifficulty")]
|
||||||
|
minimum_difficulty: Uint,
|
||||||
|
#[serde(rename="difficultyBoundDivisor")]
|
||||||
|
difficulty_bound_divisor: Uint,
|
||||||
|
#[serde(rename="durationLimit")]
|
||||||
|
duration_limit: Uint,
|
||||||
|
#[serde(rename="blockReward")]
|
||||||
|
block_reward: Uint,
|
||||||
|
registrar: Address,
|
||||||
|
#[serde(rename="networkID")]
|
||||||
|
network_id: Uint,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json;
|
||||||
|
use spec::params::Params;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn params_deserialization() {
|
||||||
|
let s = r#"{
|
||||||
|
"accountStartNonce": "0x00",
|
||||||
|
"frontierCompatibilityModeLimit": "0x118c30",
|
||||||
|
"maximumExtraDataSize": "0x20",
|
||||||
|
"tieBreakingGas": false,
|
||||||
|
"minGasLimit": "0x1388",
|
||||||
|
"gasLimitBoundDivisor": "0x0400",
|
||||||
|
"minimumDifficulty": "0x020000",
|
||||||
|
"difficultyBoundDivisor": "0x0800",
|
||||||
|
"durationLimit": "0x0d",
|
||||||
|
"blockReward": "0x4563918244F40000",
|
||||||
|
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
|
||||||
|
"networkID" : "0x1"
|
||||||
|
}"#;
|
||||||
|
let _deserialized: Params = serde_json::from_str(s).unwrap();
|
||||||
|
// TODO: validate all fields
|
||||||
|
}
|
||||||
|
}
|
84
json/src/spec/spec.rs
Normal file
84
json/src/spec/spec.rs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Spec deserialization.
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use hash::Address;
|
||||||
|
use spec::account::Account;
|
||||||
|
use spec::params::Params;
|
||||||
|
use spec::genesis::Genesis;
|
||||||
|
|
||||||
|
/// Spec deserialization.
|
||||||
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
pub struct Spec {
|
||||||
|
name: String,
|
||||||
|
#[serde(rename="engineName")]
|
||||||
|
engine_name: String, // TODO: consider making it an enum
|
||||||
|
params: Params,
|
||||||
|
genesis: Genesis,
|
||||||
|
accounts: BTreeMap<Address, Account>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json;
|
||||||
|
use spec::spec::Spec;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn spec_deserialization() {
|
||||||
|
let s = r#"{
|
||||||
|
"name": "Morden",
|
||||||
|
"engineName": "Ethash",
|
||||||
|
"params": {
|
||||||
|
"accountStartNonce": "0x0100000",
|
||||||
|
"frontierCompatibilityModeLimit": "0x789b0",
|
||||||
|
"maximumExtraDataSize": "0x20",
|
||||||
|
"tieBreakingGas": false,
|
||||||
|
"minGasLimit": "0x1388",
|
||||||
|
"gasLimitBoundDivisor": "0x0400",
|
||||||
|
"minimumDifficulty": "0x020000",
|
||||||
|
"difficultyBoundDivisor": "0x0800",
|
||||||
|
"durationLimit": "0x0d",
|
||||||
|
"blockReward": "0x4563918244F40000",
|
||||||
|
"registrar": "",
|
||||||
|
"networkID" : "0x2"
|
||||||
|
},
|
||||||
|
"genesis": {
|
||||||
|
"nonce": "0x00006d6f7264656e",
|
||||||
|
"difficulty": "0x20000",
|
||||||
|
"mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
|
||||||
|
"author": "0x0000000000000000000000000000000000000000",
|
||||||
|
"timestamp": "0x00",
|
||||||
|
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"extraData": "0x",
|
||||||
|
"gasLimit": "0x2fefd8"
|
||||||
|
},
|
||||||
|
"nodes": [
|
||||||
|
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
||||||
|
],
|
||||||
|
"accounts": {
|
||||||
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
|
||||||
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
|
||||||
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
|
||||||
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
|
||||||
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
|
}
|
||||||
|
}"#;
|
||||||
|
let _deserialized: Spec = serde_json::from_str(s).unwrap();
|
||||||
|
// TODO: validate all fields
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ use serde::de::Visitor;
|
|||||||
use util::numbers::{U256, Uint as U};
|
use util::numbers::{U256, Uint as U};
|
||||||
|
|
||||||
/// Lenient uint json deserialization for test json files.
|
/// Lenient uint json deserialization for test json files.
|
||||||
#[derive(Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
||||||
pub struct Uint(U256);
|
pub struct Uint(U256);
|
||||||
|
|
||||||
impl Into<U256> for Uint {
|
impl Into<U256> for Uint {
|
||||||
@ -31,6 +31,12 @@ impl Into<U256> for Uint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<u64> for Uint {
|
||||||
|
fn into(self) -> u64 {
|
||||||
|
u64::from(self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deserialize for Uint {
|
impl Deserialize for Uint {
|
||||||
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
|
||||||
where D: Deserializer {
|
where D: Deserializer {
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
|
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
|
||||||
//!
|
//!
|
||||||
//! // Check block for sealing
|
//! // Check block for sealing
|
||||||
//! miner.prepare_sealing(client.deref());
|
|
||||||
//! assert!(miner.sealing_block(client.deref()).lock().unwrap().is_some());
|
//! assert!(miner.sealing_block(client.deref()).lock().unwrap().is_some());
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
@ -79,7 +78,7 @@ pub trait MinerService : Send + Sync {
|
|||||||
fn status(&self) -> MinerStatus;
|
fn status(&self) -> MinerStatus;
|
||||||
|
|
||||||
/// Imports transactions to transaction queue.
|
/// Imports transactions to transaction queue.
|
||||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Result<(), Error>
|
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails;
|
where T: Fn(&Address) -> AccountDetails;
|
||||||
|
|
||||||
/// Returns hashes of transactions currently in pending
|
/// Returns hashes of transactions currently in pending
|
||||||
@ -92,7 +91,7 @@ pub trait MinerService : Send + Sync {
|
|||||||
fn chain_new_blocks(&self, chain: &BlockChainClient, imported: &[H256], invalid: &[H256], enacted: &[H256], retracted: &[H256]);
|
fn chain_new_blocks(&self, chain: &BlockChainClient, imported: &[H256], invalid: &[H256], enacted: &[H256], retracted: &[H256]);
|
||||||
|
|
||||||
/// New chain head event. Restart mining operation.
|
/// New chain head event. Restart mining operation.
|
||||||
fn prepare_sealing(&self, chain: &BlockChainClient);
|
fn update_sealing(&self, chain: &BlockChainClient);
|
||||||
|
|
||||||
/// Grab the `ClosedBlock` that we want to be sealed. Comes as a mutex that you have to lock.
|
/// Grab the `ClosedBlock` that we want to be sealed. Comes as a mutex that you have to lock.
|
||||||
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>>;
|
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>>;
|
||||||
|
@ -34,6 +34,7 @@ pub struct Miner {
|
|||||||
|
|
||||||
// for sealing...
|
// for sealing...
|
||||||
sealing_enabled: AtomicBool,
|
sealing_enabled: AtomicBool,
|
||||||
|
sealing_block_last_request: Mutex<u64>,
|
||||||
sealing_block: Mutex<Option<ClosedBlock>>,
|
sealing_block: Mutex<Option<ClosedBlock>>,
|
||||||
gas_floor_target: RwLock<U256>,
|
gas_floor_target: RwLock<U256>,
|
||||||
author: RwLock<Address>,
|
author: RwLock<Address>,
|
||||||
@ -46,6 +47,7 @@ impl Default for Miner {
|
|||||||
Miner {
|
Miner {
|
||||||
transaction_queue: Mutex::new(TransactionQueue::new()),
|
transaction_queue: Mutex::new(TransactionQueue::new()),
|
||||||
sealing_enabled: AtomicBool::new(false),
|
sealing_enabled: AtomicBool::new(false),
|
||||||
|
sealing_block_last_request: Mutex::new(0),
|
||||||
sealing_block: Mutex::new(None),
|
sealing_block: Mutex::new(None),
|
||||||
gas_floor_target: RwLock::new(U256::zero()),
|
gas_floor_target: RwLock::new(U256::zero()),
|
||||||
author: RwLock::new(Address::default()),
|
author: RwLock::new(Address::default()),
|
||||||
@ -95,41 +97,7 @@ impl Miner {
|
|||||||
self.transaction_queue.lock().unwrap().set_minimal_gas_price(min_gas_price);
|
self.transaction_queue.lock().unwrap().set_minimal_gas_price(min_gas_price);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_gas_limit(&self, chain: &BlockChainClient) {
|
/// Prepares new block for sealing including top transactions from queue.
|
||||||
let gas_limit = HeaderView::new(&chain.best_block_header()).gas_limit();
|
|
||||||
let mut queue = self.transaction_queue.lock().unwrap();
|
|
||||||
queue.set_gas_limit(gas_limit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MinerService for Miner {
|
|
||||||
|
|
||||||
fn clear_and_reset(&self, chain: &BlockChainClient) {
|
|
||||||
self.transaction_queue.lock().unwrap().clear();
|
|
||||||
self.prepare_sealing(chain);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn status(&self) -> MinerStatus {
|
|
||||||
let status = self.transaction_queue.lock().unwrap().status();
|
|
||||||
let block = self.sealing_block.lock().unwrap();
|
|
||||||
MinerStatus {
|
|
||||||
transactions_in_pending_queue: status.pending,
|
|
||||||
transactions_in_future_queue: status.future,
|
|
||||||
transactions_in_pending_block: block.as_ref().map_or(0, |b| b.transactions().len()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Result<(), Error>
|
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
|
||||||
let mut transaction_queue = self.transaction_queue.lock().unwrap();
|
|
||||||
transaction_queue.add_all(transactions, fetch_account)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pending_transactions_hashes(&self) -> Vec<H256> {
|
|
||||||
let transaction_queue = self.transaction_queue.lock().unwrap();
|
|
||||||
transaction_queue.pending_hashes()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_sealing(&self, chain: &BlockChainClient) {
|
fn prepare_sealing(&self, chain: &BlockChainClient) {
|
||||||
let transactions = self.transaction_queue.lock().unwrap().top_transactions();
|
let transactions = self.transaction_queue.lock().unwrap().top_transactions();
|
||||||
let b = chain.prepare_sealing(
|
let b = chain.prepare_sealing(
|
||||||
@ -152,12 +120,66 @@ impl MinerService for Miner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_gas_limit(&self, chain: &BlockChainClient) {
|
||||||
|
let gas_limit = HeaderView::new(&chain.best_block_header()).gas_limit();
|
||||||
|
let mut queue = self.transaction_queue.lock().unwrap();
|
||||||
|
queue.set_gas_limit(gas_limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const SEALING_TIMEOUT_IN_BLOCKS : u64 = 5;
|
||||||
|
|
||||||
|
impl MinerService for Miner {
|
||||||
|
|
||||||
|
fn clear_and_reset(&self, chain: &BlockChainClient) {
|
||||||
|
self.transaction_queue.lock().unwrap().clear();
|
||||||
|
self.update_sealing(chain);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn status(&self) -> MinerStatus {
|
||||||
|
let status = self.transaction_queue.lock().unwrap().status();
|
||||||
|
let block = self.sealing_block.lock().unwrap();
|
||||||
|
MinerStatus {
|
||||||
|
transactions_in_pending_queue: status.pending,
|
||||||
|
transactions_in_future_queue: status.future,
|
||||||
|
transactions_in_pending_block: block.as_ref().map_or(0, |b| b.transactions().len()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
|
||||||
|
where T: Fn(&Address) -> AccountDetails {
|
||||||
|
let mut transaction_queue = self.transaction_queue.lock().unwrap();
|
||||||
|
transaction_queue.add_all(transactions, fetch_account)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pending_transactions_hashes(&self) -> Vec<H256> {
|
||||||
|
let transaction_queue = self.transaction_queue.lock().unwrap();
|
||||||
|
transaction_queue.pending_hashes()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_sealing(&self, chain: &BlockChainClient) {
|
||||||
|
let should_disable_sealing = {
|
||||||
|
let current_no = chain.chain_info().best_block_number;
|
||||||
|
let last_request = self.sealing_block_last_request.lock().unwrap();
|
||||||
|
let is_greater = current_no > *last_request;
|
||||||
|
is_greater && current_no - *last_request > SEALING_TIMEOUT_IN_BLOCKS
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_disable_sealing {
|
||||||
|
self.sealing_enabled.store(false, atomic::Ordering::Relaxed);
|
||||||
|
*self.sealing_block.lock().unwrap() = None;
|
||||||
|
} else if self.sealing_enabled.load(atomic::Ordering::Relaxed) {
|
||||||
|
self.prepare_sealing(chain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
fn sealing_block(&self, chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
||||||
if self.sealing_block.lock().unwrap().is_none() {
|
if self.sealing_block.lock().unwrap().is_none() {
|
||||||
self.sealing_enabled.store(true, atomic::Ordering::Relaxed);
|
self.sealing_enabled.store(true, atomic::Ordering::Relaxed);
|
||||||
// TODO: Above should be on a timer that resets after two blocks have arrived without being asked for.
|
|
||||||
self.prepare_sealing(chain);
|
self.prepare_sealing(chain);
|
||||||
}
|
}
|
||||||
|
*self.sealing_block_last_request.lock().unwrap() = chain.chain_info().best_block_number;
|
||||||
&self.sealing_block
|
&self.sealing_block
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,9 +261,45 @@ impl MinerService for Miner {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update mined block
|
self.update_sealing(chain);
|
||||||
if self.sealing_enabled.load(atomic::Ordering::Relaxed) {
|
}
|
||||||
self.prepare_sealing(chain);
|
}
|
||||||
}
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
|
||||||
|
use MinerService;
|
||||||
|
use super::{Miner};
|
||||||
|
use ethcore::client::{TestBlockChainClient, EachBlockWith};
|
||||||
|
|
||||||
|
// TODO [ToDr] To uncomment client is cleaned from mining stuff.
|
||||||
|
#[ignore]
|
||||||
|
#[test]
|
||||||
|
fn should_prepare_block_to_seal() {
|
||||||
|
// given
|
||||||
|
let client = TestBlockChainClient::default();
|
||||||
|
let miner = Miner::default();
|
||||||
|
|
||||||
|
// when
|
||||||
|
let res = miner.sealing_block(&client);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assert!(res.lock().unwrap().is_some(), "Expected closed block");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_reset_seal_after_couple_of_blocks() {
|
||||||
|
// given
|
||||||
|
let client = TestBlockChainClient::default();
|
||||||
|
let miner = Miner::default();
|
||||||
|
let res = miner.sealing_block(&client);
|
||||||
|
// TODO [ToDr] Uncomment after fixing TestBlockChainClient
|
||||||
|
// assert!(res.lock().unwrap().is_some(), "Expected closed block");
|
||||||
|
|
||||||
|
// when
|
||||||
|
client.add_blocks(10, EachBlockWith::Uncle);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assert!(res.lock().unwrap().is_none(), "Expected to remove sealed block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,12 +333,12 @@ impl TransactionQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds all signed transactions to queue to be verified and imported
|
/// Adds all signed transactions to queue to be verified and imported
|
||||||
pub fn add_all<T>(&mut self, txs: Vec<SignedTransaction>, fetch_account: T) -> Result<(), Error>
|
pub fn add_all<T>(&mut self, txs: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
where T: Fn(&Address) -> AccountDetails {
|
||||||
for tx in txs.into_iter() {
|
|
||||||
try!(self.add(tx, &fetch_account));
|
txs.into_iter()
|
||||||
}
|
.map(|tx| self.add(tx, &fetch_account))
|
||||||
Ok(())
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add signed transaction to queue to be verified and imported
|
/// Add signed transaction to queue to be verified and imported
|
||||||
@ -385,8 +385,7 @@ impl TransactionQueue {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.import_tx(vtx, account.nonce);
|
self.import_tx(vtx, account.nonce).map_err(Error::Transaction)
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all transactions identified by hashes given in slice
|
/// Removes all transactions identified by hashes given in slice
|
||||||
@ -540,12 +539,14 @@ impl TransactionQueue {
|
|||||||
///
|
///
|
||||||
/// It ignores transactions that has already been imported (same `hash`) and replaces the transaction
|
/// It ignores transactions that has already been imported (same `hash`) and replaces the transaction
|
||||||
/// iff `(address, nonce)` is the same but `gas_price` is higher.
|
/// iff `(address, nonce)` is the same but `gas_price` is higher.
|
||||||
fn import_tx(&mut self, tx: VerifiedTransaction, state_nonce: U256) {
|
///
|
||||||
|
/// Returns `true` when transaction was imported successfuly
|
||||||
|
fn import_tx(&mut self, tx: VerifiedTransaction, state_nonce: U256) -> Result<(), TransactionError> {
|
||||||
|
|
||||||
if self.by_hash.get(&tx.hash()).is_some() {
|
if self.by_hash.get(&tx.hash()).is_some() {
|
||||||
// Transaction is already imported.
|
// Transaction is already imported.
|
||||||
trace!(target: "miner", "Dropping already imported transaction: {:?}", tx.hash());
|
trace!(target: "miner", "Dropping already imported transaction: {:?}", tx.hash());
|
||||||
return;
|
return Err(TransactionError::AlreadyImported);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -562,11 +563,11 @@ impl TransactionQueue {
|
|||||||
// We have a gap - put to future
|
// We have a gap - put to future
|
||||||
Self::replace_transaction(tx, next_nonce, &mut self.future, &mut self.by_hash);
|
Self::replace_transaction(tx, next_nonce, &mut self.future, &mut self.by_hash);
|
||||||
self.future.enforce_limit(&mut self.by_hash);
|
self.future.enforce_limit(&mut self.by_hash);
|
||||||
return;
|
return Ok(());
|
||||||
} else if nonce < state_nonce {
|
} else if nonce < state_nonce {
|
||||||
// Droping transaction
|
// Droping transaction
|
||||||
trace!(target: "miner", "Dropping old transaction: {:?} (nonce: {} < {})", tx.hash(), nonce, next_nonce);
|
trace!(target: "miner", "Dropping old transaction: {:?} (nonce: {} < {})", tx.hash(), nonce, next_nonce);
|
||||||
return;
|
return Err(TransactionError::Old);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::replace_transaction(tx, state_nonce, &mut self.current, &mut self.by_hash);
|
Self::replace_transaction(tx, state_nonce, &mut self.current, &mut self.by_hash);
|
||||||
@ -576,6 +577,7 @@ impl TransactionQueue {
|
|||||||
self.current.enforce_limit(&mut self.by_hash);
|
self.current.enforce_limit(&mut self.by_hash);
|
||||||
|
|
||||||
trace!(target: "miner", "status: {:?}", self.status());
|
trace!(target: "miner", "status: {:?}", self.status());
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Replaces transaction in given set (could be `future` or `current`).
|
/// Replaces transaction in given set (could be `future` or `current`).
|
||||||
@ -1008,7 +1010,7 @@ mod test {
|
|||||||
let fetch_last_nonce = |_a: &Address| AccountDetails{ nonce: last_nonce, balance: !U256::zero() };
|
let fetch_last_nonce = |_a: &Address| AccountDetails{ nonce: last_nonce, balance: !U256::zero() };
|
||||||
|
|
||||||
// when
|
// when
|
||||||
txq.add(tx, &fetch_last_nonce).unwrap();
|
txq.add(tx, &fetch_last_nonce).unwrap_err();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
let stats = txq.status();
|
let stats = txq.status();
|
||||||
@ -1028,7 +1030,7 @@ mod test {
|
|||||||
assert_eq!(txq.status().pending, 0);
|
assert_eq!(txq.status().pending, 0);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
txq.add(tx2.clone(), &nonce).unwrap();
|
txq.add(tx2.clone(), &nonce).unwrap_err();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
let stats = txq.status();
|
let stats = txq.status();
|
||||||
|
@ -46,6 +46,7 @@ use env_logger::LogBuilder;
|
|||||||
use ctrlc::CtrlC;
|
use ctrlc::CtrlC;
|
||||||
use util::*;
|
use util::*;
|
||||||
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
||||||
|
use util::keys::store::*;
|
||||||
use ethcore::spec::*;
|
use ethcore::spec::*;
|
||||||
use ethcore::client::*;
|
use ethcore::client::*;
|
||||||
use ethcore::service::{ClientService, NetSyncMessage};
|
use ethcore::service::{ClientService, NetSyncMessage};
|
||||||
@ -55,7 +56,6 @@ use ethminer::{Miner, MinerService};
|
|||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use daemonize::Daemonize;
|
use daemonize::Daemonize;
|
||||||
use number_prefix::{binary_prefix, Standalone, Prefixed};
|
use number_prefix::{binary_prefix, Standalone, Prefixed};
|
||||||
use util::keys::store::*;
|
|
||||||
|
|
||||||
fn die_with_message(msg: &str) -> ! {
|
fn die_with_message(msg: &str) -> ! {
|
||||||
println!("ERROR: {}", msg);
|
println!("ERROR: {}", msg);
|
||||||
@ -105,8 +105,9 @@ Networking Options:
|
|||||||
|
|
||||||
API and Console Options:
|
API and Console Options:
|
||||||
-j --jsonrpc Enable the JSON-RPC API sever.
|
-j --jsonrpc Enable the JSON-RPC API sever.
|
||||||
--jsonrpc-addr HOST Specify the hostname portion of the JSONRPC API
|
--jsonrpc-interface IP Specify the hostname portion of the JSONRPC API
|
||||||
server [default: 127.0.0.1].
|
server, IP should be an interface's IP address, or
|
||||||
|
all (all interfaces) or local [default: local].
|
||||||
--jsonrpc-port PORT Specify the port portion of the JSONRPC API server
|
--jsonrpc-port PORT Specify the port portion of the JSONRPC API server
|
||||||
[default: 8545].
|
[default: 8545].
|
||||||
--jsonrpc-cors URL Specify CORS header for JSON-RPC API responses
|
--jsonrpc-cors URL Specify CORS header for JSON-RPC API responses
|
||||||
@ -149,7 +150,7 @@ Geth-compatibility Options:
|
|||||||
--nodekey KEY Equivalent to --node-key KEY.
|
--nodekey KEY Equivalent to --node-key KEY.
|
||||||
--nodiscover Equivalent to --no-discovery.
|
--nodiscover Equivalent to --no-discovery.
|
||||||
--rpc Equivalent to --jsonrpc.
|
--rpc Equivalent to --jsonrpc.
|
||||||
--rpcaddr HOST Equivalent to --jsonrpc-addr HOST.
|
--rpcaddr IP Equivalent to --jsonrpc-interface IP.
|
||||||
--rpcport PORT Equivalent to --jsonrpc-port PORT.
|
--rpcport PORT Equivalent to --jsonrpc-port PORT.
|
||||||
--rpcapi APIS Equivalent to --jsonrpc-apis APIS.
|
--rpcapi APIS Equivalent to --jsonrpc-apis APIS.
|
||||||
--rpccorsdomain URL Equivalent to --jsonrpc-cors URL.
|
--rpccorsdomain URL Equivalent to --jsonrpc-cors URL.
|
||||||
@ -188,7 +189,7 @@ struct Args {
|
|||||||
flag_cache_max_size: usize,
|
flag_cache_max_size: usize,
|
||||||
flag_queue_max_size: usize,
|
flag_queue_max_size: usize,
|
||||||
flag_jsonrpc: bool,
|
flag_jsonrpc: bool,
|
||||||
flag_jsonrpc_addr: String,
|
flag_jsonrpc_interface: String,
|
||||||
flag_jsonrpc_port: u16,
|
flag_jsonrpc_port: u16,
|
||||||
flag_jsonrpc_cors: String,
|
flag_jsonrpc_cors: String,
|
||||||
flag_jsonrpc_apis: String,
|
flag_jsonrpc_apis: String,
|
||||||
@ -315,7 +316,7 @@ impl Configuration {
|
|||||||
|
|
||||||
fn author(&self) -> Address {
|
fn author(&self) -> Address {
|
||||||
let d = self.args.flag_etherbase.as_ref().unwrap_or(&self.args.flag_author);
|
let d = self.args.flag_etherbase.as_ref().unwrap_or(&self.args.flag_author);
|
||||||
Address::from_str(d).unwrap_or_else(|_| {
|
Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
|
||||||
die!("{}: Invalid address for --author. Must be 40 hex characters, without the 0x at the beginning.", d)
|
die!("{}: Invalid address for --author. Must be 40 hex characters, without the 0x at the beginning.", d)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -523,7 +524,11 @@ impl Configuration {
|
|||||||
// Setup rpc
|
// Setup rpc
|
||||||
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
||||||
let url = format!("{}:{}",
|
let url = format!("{}:{}",
|
||||||
self.args.flag_rpcaddr.as_ref().unwrap_or(&self.args.flag_jsonrpc_addr),
|
match self.args.flag_rpcaddr.as_ref().unwrap_or(&self.args.flag_jsonrpc_interface).as_str() {
|
||||||
|
"all" => "0.0.0.0",
|
||||||
|
"local" => "127.0.0.1",
|
||||||
|
x => x,
|
||||||
|
},
|
||||||
self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port)
|
self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port)
|
||||||
);
|
);
|
||||||
SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url));
|
SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url));
|
||||||
|
@ -26,7 +26,7 @@ clippy = { version = "0.0.54", optional = true }
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_codegen = { version = "0.7.0", optional = true }
|
serde_codegen = { version = "0.7.0", optional = true }
|
||||||
syntex = "0.29.0"
|
syntex = "0.30.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde_codegen"]
|
default = ["serde_codegen"]
|
||||||
|
17
rpc/rpctest/Cargo.toml
Normal file
17
rpc/rpctest/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[package]
|
||||||
|
description = "Rpc test client."
|
||||||
|
name = "rpctest"
|
||||||
|
version = "1.1.0"
|
||||||
|
license = "GPL-3.0"
|
||||||
|
authors = ["Ethcore <admin@ethcore.io>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
|
||||||
|
docopt = "0.6"
|
||||||
|
rustc-serialize = "0.3"
|
||||||
|
ethcore = { path = "../../ethcore" }
|
||||||
|
ethcore-devtools = { path = "../../devtools" }
|
||||||
|
ethcore-rpc = { path = ".." }
|
||||||
|
ethcore-util = { path = "../../util" }
|
||||||
|
ethjson = { path = "../../json" }
|
||||||
|
serde_json = "0.7.0"
|
148
rpc/rpctest/src/main.rs
Normal file
148
rpc/rpctest/src/main.rs
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity 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.
|
||||||
|
|
||||||
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
extern crate ctrlc;
|
||||||
|
extern crate docopt;
|
||||||
|
extern crate rustc_serialize;
|
||||||
|
extern crate serde_json;
|
||||||
|
extern crate ethjson;
|
||||||
|
extern crate ethcore_util as util;
|
||||||
|
extern crate ethcore;
|
||||||
|
extern crate ethcore_devtools as devtools;
|
||||||
|
extern crate ethcore_rpc as rpc;
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::sync::{Arc, Mutex, Condvar};
|
||||||
|
use std::process;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::path::Path;
|
||||||
|
use docopt::Docopt;
|
||||||
|
use ctrlc::CtrlC;
|
||||||
|
use ethcore::spec::Genesis;
|
||||||
|
use ethcore::pod_state::PodState;
|
||||||
|
use ethcore::ethereum;
|
||||||
|
use ethcore::client::{BlockChainClient, Client, ClientConfig};
|
||||||
|
use devtools::RandomTempPath;
|
||||||
|
use util::IoChannel;
|
||||||
|
use rpc::v1::tests::helpers::{TestSyncProvider, Config as SyncConfig, TestMinerService, TestAccountProvider, TestAccount};
|
||||||
|
use rpc::v1::{Eth, EthClient, EthFilter, EthFilterClient};
|
||||||
|
use util::panics::MayPanic;
|
||||||
|
use util::hash::Address;
|
||||||
|
|
||||||
|
const USAGE: &'static str = r#"
|
||||||
|
Parity rpctest client.
|
||||||
|
By Wood/Paronyan/Kotewicz/Drwięga/Volf.
|
||||||
|
Copyright 2015, 2016 Ethcore (UK) Limited
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
rpctest --json <test-file> --name <test-name> [options]
|
||||||
|
rpctest --help
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--jsonrpc-addr HOST Specify the hostname portion of the JSONRPC API
|
||||||
|
server [default: 127.0.0.1].
|
||||||
|
--jsonrpc-port PORT Specify the port portion of the JSONRPC API server
|
||||||
|
[default: 8545].
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[derive(Debug, RustcDecodable)]
|
||||||
|
struct Args {
|
||||||
|
arg_test_file: String,
|
||||||
|
arg_test_name: String,
|
||||||
|
flag_jsonrpc_addr: String,
|
||||||
|
flag_jsonrpc_port: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Configuration {
|
||||||
|
args: Args,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Configuration {
|
||||||
|
fn parse() -> Self {
|
||||||
|
Configuration {
|
||||||
|
args: Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute(&self) {
|
||||||
|
println!("file path: {:?}", self.args.arg_test_file);
|
||||||
|
println!("test name: {:?}", self.args.arg_test_name);
|
||||||
|
|
||||||
|
let path = Path::new(&self.args.arg_test_file);
|
||||||
|
let file = File::open(path).unwrap_or_else(|_| {
|
||||||
|
println!("Cannot open file.");
|
||||||
|
process::exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
let tests: ethjson::blockchain::Test = serde_json::from_reader(file).unwrap_or_else(|err| {
|
||||||
|
println!("Invalid json file.");
|
||||||
|
println!("{:?}", err);
|
||||||
|
process::exit(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
let blockchain = tests.get(&self.args.arg_test_name).unwrap_or_else(|| {
|
||||||
|
println!("Invalid test name.");
|
||||||
|
process::exit(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
let genesis = Genesis::from(blockchain.genesis());
|
||||||
|
let state = PodState::from(blockchain.pre_state.clone());
|
||||||
|
let mut spec = ethereum::new_frontier_test();
|
||||||
|
spec.set_genesis_state(state);
|
||||||
|
spec.overwrite_genesis_params(genesis);
|
||||||
|
assert!(spec.is_state_root_valid());
|
||||||
|
|
||||||
|
let temp = RandomTempPath::new();
|
||||||
|
{
|
||||||
|
let client: Arc<Client> = Client::new(ClientConfig::default(), spec, temp.as_path(), IoChannel::disconnected()).unwrap();
|
||||||
|
for b in &blockchain.blocks_rlp() {
|
||||||
|
let _ = client.import_block(b.clone());
|
||||||
|
client.flush_queue();
|
||||||
|
client.import_verified_blocks(&IoChannel::disconnected());
|
||||||
|
}
|
||||||
|
let sync = Arc::new(TestSyncProvider::new(SyncConfig {
|
||||||
|
protocol_version: 65,
|
||||||
|
num_peers: 120
|
||||||
|
}));
|
||||||
|
|
||||||
|
let miner = Arc::new(TestMinerService::default());
|
||||||
|
let mut accs = HashMap::new();
|
||||||
|
accs.insert(Address::from(1), TestAccount::new("test"));
|
||||||
|
let accounts = Arc::new(TestAccountProvider::new(accs));
|
||||||
|
let server = rpc::RpcServer::new();
|
||||||
|
server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate());
|
||||||
|
server.add_delegate(EthFilterClient::new(&client, &miner).to_delegate());
|
||||||
|
|
||||||
|
let url = format!("{}:{}", self.args.flag_jsonrpc_addr, self.args.flag_jsonrpc_port);
|
||||||
|
let panic_handler = server.start_http(url.as_ref(), "*", 1);
|
||||||
|
let exit = Arc::new(Condvar::new());
|
||||||
|
|
||||||
|
let e = exit.clone();
|
||||||
|
CtrlC::set_handler(move || { e.notify_all(); });
|
||||||
|
|
||||||
|
let e = exit.clone();
|
||||||
|
panic_handler.on_panic(move |_reason| { e.notify_all(); });
|
||||||
|
|
||||||
|
let mutex = Mutex::new(());
|
||||||
|
let _ = exit.wait(mutex.lock().unwrap()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
Configuration::parse().execute();
|
||||||
|
}
|
@ -103,7 +103,8 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
timestamp: U256::from(view.timestamp()),
|
timestamp: U256::from(view.timestamp()),
|
||||||
difficulty: view.difficulty(),
|
difficulty: view.difficulty(),
|
||||||
total_difficulty: total_difficulty,
|
total_difficulty: total_difficulty,
|
||||||
uncles: vec![],
|
nonce: view.seal().get(1).map_or_else(H64::zero, |r| H64::from_slice(r)),
|
||||||
|
uncles: block_view.uncle_hashes(),
|
||||||
transactions: {
|
transactions: {
|
||||||
if include_txs {
|
if include_txs {
|
||||||
BlockTransactions::Full(block_view.localized_transactions().into_iter().map(From::from).collect())
|
BlockTransactions::Full(block_view.localized_transactions().into_iter().map(From::from).collect())
|
||||||
@ -111,7 +112,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
BlockTransactions::Hashes(block_view.transaction_hashes())
|
BlockTransactions::Hashes(block_view.transaction_hashes())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extra_data: Bytes::default()
|
extra_data: Bytes::new(view.extra_data())
|
||||||
};
|
};
|
||||||
to_value(&block)
|
to_value(&block)
|
||||||
},
|
},
|
||||||
@ -229,8 +230,8 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
fn block_transaction_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
fn block_transaction_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||||
from_params::<(H256,)>(params)
|
from_params::<(H256,)>(params)
|
||||||
.and_then(|(hash,)| // match
|
.and_then(|(hash,)| // match
|
||||||
to_value(&take_weak!(self.client).block(BlockId::Hash(hash))
|
take_weak!(self.client).block(BlockId::Hash(hash))
|
||||||
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count()))))
|
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count()))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||||
@ -239,24 +240,24 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
BlockNumber::Pending => to_value(
|
BlockNumber::Pending => to_value(
|
||||||
&U256::from(take_weak!(self.miner).status().transactions_in_pending_block)
|
&U256::from(take_weak!(self.miner).status().transactions_in_pending_block)
|
||||||
),
|
),
|
||||||
_ => to_value(&take_weak!(self.client).block(block_number.into())
|
_ => take_weak!(self.client).block(block_number.into())
|
||||||
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count())))
|
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count())))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_uncles_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
fn block_uncles_count_by_hash(&self, params: Params) -> Result<Value, Error> {
|
||||||
from_params::<(H256,)>(params)
|
from_params::<(H256,)>(params)
|
||||||
.and_then(|(hash,)|
|
.and_then(|(hash,)|
|
||||||
to_value(&take_weak!(self.client).block(BlockId::Hash(hash))
|
take_weak!(self.client).block(BlockId::Hash(hash))
|
||||||
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).uncles_count()))))
|
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count()))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_uncles_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
fn block_uncles_count_by_number(&self, params: Params) -> Result<Value, Error> {
|
||||||
from_params::<(BlockNumber,)>(params)
|
from_params::<(BlockNumber,)>(params)
|
||||||
.and_then(|(block_number,)| match block_number {
|
.and_then(|(block_number,)| match block_number {
|
||||||
BlockNumber::Pending => to_value(&U256::from(0)),
|
BlockNumber::Pending => to_value(&U256::from(0)),
|
||||||
_ => to_value(&take_weak!(self.client).block(block_number.into())
|
_ => take_weak!(self.client).block(block_number.into())
|
||||||
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).uncles_count())))
|
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count())))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +386,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
nonce: client.nonce(a),
|
nonce: client.nonce(a),
|
||||||
balance: client.balance(a),
|
balance: client.balance(a),
|
||||||
});
|
});
|
||||||
match import {
|
match import.into_iter().collect::<Result<Vec<_>, _>>() {
|
||||||
Ok(_) => to_value(&hash),
|
Ok(_) => to_value(&hash),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("Error sending transaction: {:?}", e);
|
warn!("Error sending transaction: {:?}", e);
|
||||||
@ -397,6 +398,50 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn call(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(TransactionRequest, BlockNumber)>(params)
|
||||||
|
.and_then(|(transaction_request, _block_number)| {
|
||||||
|
let accounts = take_weak!(self.accounts);
|
||||||
|
match accounts.account_secret(&transaction_request.from) {
|
||||||
|
Ok(secret) => {
|
||||||
|
let client = take_weak!(self.client);
|
||||||
|
|
||||||
|
let transaction: EthTransaction = transaction_request.into();
|
||||||
|
let signed_transaction = transaction.sign(&secret);
|
||||||
|
|
||||||
|
let output = client.call(&signed_transaction)
|
||||||
|
.map(|e| Bytes::new(e.output))
|
||||||
|
.unwrap_or(Bytes::default());
|
||||||
|
|
||||||
|
to_value(&output)
|
||||||
|
},
|
||||||
|
Err(_) => { to_value(&Bytes::default()) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn estimate_gas(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(TransactionRequest, BlockNumber)>(params)
|
||||||
|
.and_then(|(transaction_request, _block_number)| {
|
||||||
|
let accounts = take_weak!(self.accounts);
|
||||||
|
match accounts.account_secret(&transaction_request.from) {
|
||||||
|
Ok(secret) => {
|
||||||
|
let client = take_weak!(self.client);
|
||||||
|
|
||||||
|
let transaction: EthTransaction = transaction_request.into();
|
||||||
|
let signed_transaction = transaction.sign(&secret);
|
||||||
|
|
||||||
|
let gas_used = client.call(&signed_transaction)
|
||||||
|
.map(|e| e.gas_used + e.refunded)
|
||||||
|
.unwrap_or(U256::zero());
|
||||||
|
|
||||||
|
to_value(&gas_used)
|
||||||
|
},
|
||||||
|
Err(_) => { to_value(&U256::zero()) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Eth filter rpc implementation.
|
/// Eth filter rpc implementation.
|
||||||
|
@ -23,8 +23,7 @@ mod impls;
|
|||||||
mod types;
|
mod types;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
pub mod tests;
|
||||||
mod tests;
|
|
||||||
|
|
||||||
pub use self::traits::{Web3, Eth, EthFilter, Personal, Net};
|
pub use self::traits::{Web3, Eth, EthFilter, Personal, Net};
|
||||||
pub use self::impls::*;
|
pub use self::impls::*;
|
||||||
|
@ -18,8 +18,8 @@ use std::collections::HashMap;
|
|||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use jsonrpc_core::IoHandler;
|
use jsonrpc_core::IoHandler;
|
||||||
use util::hash::{Address, H256};
|
use util::hash::{Address, H256};
|
||||||
use util::numbers::U256;
|
use util::numbers::{Uint, U256};
|
||||||
use ethcore::client::{TestBlockChainClient, EachBlockWith};
|
use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed};
|
||||||
use v1::{Eth, EthClient};
|
use v1::{Eth, EthClient};
|
||||||
use v1::tests::helpers::{TestAccount, TestAccountProvider, TestSyncProvider, Config, TestMinerService, TestExternalMiner};
|
use v1::tests::helpers::{TestAccount, TestAccountProvider, TestSyncProvider, Config, TestMinerService, TestExternalMiner};
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ fn rpc_eth_block_transaction_count_by_hash() {
|
|||||||
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
||||||
"id": 1
|
"id": 1
|
||||||
}"#;
|
}"#;
|
||||||
let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#;
|
let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
|
||||||
|
|
||||||
assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned()));
|
assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ fn rpc_eth_uncle_count_by_block_hash() {
|
|||||||
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
||||||
"id": 1
|
"id": 1
|
||||||
}"#;
|
}"#;
|
||||||
let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#;
|
let response = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
|
||||||
|
|
||||||
assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned()));
|
assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
@ -299,9 +299,69 @@ fn rpc_eth_code() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
|
||||||
fn rpc_eth_call() {
|
fn rpc_eth_call() {
|
||||||
unimplemented!()
|
let tester = EthTester::default();
|
||||||
|
tester.client.set_execution_result(Executed {
|
||||||
|
gas: U256::zero(),
|
||||||
|
gas_used: U256::from(0xff30),
|
||||||
|
refunded: U256::from(0x5),
|
||||||
|
cumulative_gas_used: U256::zero(),
|
||||||
|
logs: vec![],
|
||||||
|
contracts_created: vec![],
|
||||||
|
output: vec![0x12, 0x34, 0xff],
|
||||||
|
trace: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
let request = r#"{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "eth_call",
|
||||||
|
"params": [{
|
||||||
|
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
||||||
|
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
||||||
|
"gas": "0x76c0",
|
||||||
|
"gasPrice": "0x9184e72a000",
|
||||||
|
"value": "0x9184e72a",
|
||||||
|
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||||
|
},
|
||||||
|
"latest"],
|
||||||
|
"id": 1
|
||||||
|
}"#;
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":"0x1234ff","id":1}"#;
|
||||||
|
|
||||||
|
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rpc_eth_estimate_gas() {
|
||||||
|
let tester = EthTester::default();
|
||||||
|
tester.client.set_execution_result(Executed {
|
||||||
|
gas: U256::zero(),
|
||||||
|
gas_used: U256::from(0xff30),
|
||||||
|
refunded: U256::from(0x5),
|
||||||
|
cumulative_gas_used: U256::zero(),
|
||||||
|
logs: vec![],
|
||||||
|
contracts_created: vec![],
|
||||||
|
output: vec![0x12, 0x34, 0xff],
|
||||||
|
trace: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
let request = r#"{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "eth_estimateGas",
|
||||||
|
"params": [{
|
||||||
|
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
||||||
|
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
||||||
|
"gas": "0x76c0",
|
||||||
|
"gasPrice": "0x9184e72a000",
|
||||||
|
"value": "0x9184e72a",
|
||||||
|
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||||
|
},
|
||||||
|
"latest"],
|
||||||
|
"id": 1
|
||||||
|
}"#;
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":"0xff35","id":1}"#;
|
||||||
|
|
||||||
|
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -322,12 +382,6 @@ fn rpc_eth_sign() {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[ignore]
|
|
||||||
fn rpc_eth_estimate_gas() {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rpc_eth_compilers() {
|
fn rpc_eth_compilers() {
|
||||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_getCompilers", "params": [], "id": 1}"#;
|
let request = r#"{"jsonrpc": "2.0", "method": "eth_getCompilers", "params": [], "id": 1}"#;
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Test implementation of account provider.
|
||||||
|
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io;
|
use std::io;
|
||||||
use util::hash::{Address, H256};
|
use util::hash::{Address, H256, FixedHash};
|
||||||
use util::crypto::{Secret, Signature};
|
use util::crypto::{Secret, Signature};
|
||||||
use util::keys::store::{AccountProvider, SigningError, EncryptedHashMapError};
|
use util::keys::store::{AccountProvider, SigningError, EncryptedHashMapError};
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ pub struct TestAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TestAccount {
|
impl TestAccount {
|
||||||
|
/// Creates new test account.
|
||||||
pub fn new(password: &str) -> Self {
|
pub fn new(password: &str) -> Self {
|
||||||
TestAccount {
|
TestAccount {
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
@ -42,6 +45,7 @@ impl TestAccount {
|
|||||||
/// Test account provider.
|
/// Test account provider.
|
||||||
pub struct TestAccountProvider {
|
pub struct TestAccountProvider {
|
||||||
accounts: RwLock<HashMap<Address, TestAccount>>,
|
accounts: RwLock<HashMap<Address, TestAccount>>,
|
||||||
|
/// Added accounts passwords.
|
||||||
pub adds: RwLock<Vec<String>>,
|
pub adds: RwLock<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +83,7 @@ impl AccountProvider for TestAccountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn account_secret(&self, _account: &Address) -> Result<Secret, SigningError> {
|
fn account_secret(&self, _account: &Address) -> Result<Secret, SigningError> {
|
||||||
unimplemented!()
|
Ok(Secret::random())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sign(&self, _account: &Address, _message: &H256) -> Result<Signature, SigningError> {
|
fn sign(&self, _account: &Address, _message: &H256) -> Result<Signature, SigningError> {
|
||||||
|
@ -22,10 +22,12 @@ use v1::helpers::ExternalMinerService;
|
|||||||
|
|
||||||
/// Test ExternalMinerService;
|
/// Test ExternalMinerService;
|
||||||
pub struct TestExternalMiner {
|
pub struct TestExternalMiner {
|
||||||
|
/// External miners hashrates.
|
||||||
pub hashrates: Arc<RwLock<HashMap<H256, U256>>>
|
pub hashrates: Arc<RwLock<HashMap<H256, U256>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestExternalMiner {
|
impl TestExternalMiner {
|
||||||
|
/// Creates new external miner.
|
||||||
pub fn new(hashrates: Arc<RwLock<HashMap<H256, U256>>>) -> Self {
|
pub fn new(hashrates: Arc<RwLock<HashMap<H256, U256>>>) -> Self {
|
||||||
TestExternalMiner {
|
TestExternalMiner {
|
||||||
hashrates: hashrates,
|
hashrates: hashrates,
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Test implementation of miner service.
|
||||||
|
|
||||||
use util::{Address, H256, Bytes};
|
use util::{Address, H256, Bytes};
|
||||||
use util::standard::*;
|
use util::standard::*;
|
||||||
use ethcore::error::Error;
|
use ethcore::error::Error;
|
||||||
@ -22,8 +24,11 @@ use ethcore::block::ClosedBlock;
|
|||||||
use ethcore::transaction::SignedTransaction;
|
use ethcore::transaction::SignedTransaction;
|
||||||
use ethminer::{MinerService, MinerStatus, AccountDetails};
|
use ethminer::{MinerService, MinerStatus, AccountDetails};
|
||||||
|
|
||||||
|
/// Test miner service.
|
||||||
pub struct TestMinerService {
|
pub struct TestMinerService {
|
||||||
|
/// Imported transactions.
|
||||||
pub imported_transactions: RwLock<Vec<H256>>,
|
pub imported_transactions: RwLock<Vec<H256>>,
|
||||||
|
/// Latest closed block.
|
||||||
pub latest_closed_block: Mutex<Option<ClosedBlock>>,
|
pub latest_closed_block: Mutex<Option<ClosedBlock>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,11 +53,11 @@ impl MinerService for TestMinerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Imports transactions to transaction queue.
|
/// Imports transactions to transaction queue.
|
||||||
fn import_transactions<T>(&self, _transactions: Vec<SignedTransaction>, _fetch_account: T) -> Result<(), Error>
|
fn import_transactions<T>(&self, _transactions: Vec<SignedTransaction>, _fetch_account: T) -> Vec<Result<(), Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails { unimplemented!(); }
|
where T: Fn(&Address) -> AccountDetails { unimplemented!(); }
|
||||||
|
|
||||||
/// Returns hashes of transactions currently in pending
|
/// Returns hashes of transactions currently in pending
|
||||||
fn pending_transactions_hashes(&self) -> Vec<H256> { unimplemented!(); }
|
fn pending_transactions_hashes(&self) -> Vec<H256> { vec![] }
|
||||||
|
|
||||||
/// Removes all transactions from the queue and restart mining operation.
|
/// Removes all transactions from the queue and restart mining operation.
|
||||||
fn clear_and_reset(&self, _chain: &BlockChainClient) { unimplemented!(); }
|
fn clear_and_reset(&self, _chain: &BlockChainClient) { unimplemented!(); }
|
||||||
@ -61,7 +66,7 @@ impl MinerService for TestMinerService {
|
|||||||
fn chain_new_blocks(&self, _chain: &BlockChainClient, _imported: &[H256], _invalid: &[H256], _enacted: &[H256], _retracted: &[H256]) { unimplemented!(); }
|
fn chain_new_blocks(&self, _chain: &BlockChainClient, _imported: &[H256], _invalid: &[H256], _enacted: &[H256], _retracted: &[H256]) { unimplemented!(); }
|
||||||
|
|
||||||
/// New chain head event. Restart mining operation.
|
/// New chain head event. Restart mining operation.
|
||||||
fn prepare_sealing(&self, _chain: &BlockChainClient) { unimplemented!(); }
|
fn update_sealing(&self, _chain: &BlockChainClient) { unimplemented!(); }
|
||||||
|
|
||||||
/// Grab the `ClosedBlock` that we want to be sealed. Comes as a mutex that you have to lock.
|
/// Grab the `ClosedBlock` that we want to be sealed. Comes as a mutex that you have to lock.
|
||||||
fn sealing_block(&self, _chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
fn sealing_block(&self, _chain: &BlockChainClient) -> &Mutex<Option<ClosedBlock>> {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Test rpc services.
|
||||||
|
|
||||||
mod account_provider;
|
mod account_provider;
|
||||||
mod sync_provider;
|
mod sync_provider;
|
||||||
mod miner_service;
|
mod miner_service;
|
||||||
|
@ -14,19 +14,27 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Test implementation of SyncProvider.
|
||||||
|
|
||||||
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
||||||
use std::sync::{RwLock};
|
use std::sync::{RwLock};
|
||||||
|
|
||||||
|
/// TestSyncProvider config.
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// Protocol version.
|
||||||
pub protocol_version: u8,
|
pub protocol_version: u8,
|
||||||
|
/// Number of peers.
|
||||||
pub num_peers: usize,
|
pub num_peers: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test sync provider.
|
||||||
pub struct TestSyncProvider {
|
pub struct TestSyncProvider {
|
||||||
|
/// Sync status.
|
||||||
pub status: RwLock<SyncStatus>,
|
pub status: RwLock<SyncStatus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestSyncProvider {
|
impl TestSyncProvider {
|
||||||
|
/// Creates new sync provider.
|
||||||
pub fn new(config: Config) -> Self {
|
pub fn new(config: Config) -> Self {
|
||||||
TestSyncProvider {
|
TestSyncProvider {
|
||||||
status: RwLock::new(SyncStatus {
|
status: RwLock::new(SyncStatus {
|
||||||
|
@ -16,8 +16,12 @@
|
|||||||
|
|
||||||
//!TODO: load custom blockchain state and test
|
//!TODO: load custom blockchain state and test
|
||||||
|
|
||||||
|
pub mod helpers;
|
||||||
|
#[cfg(test)]
|
||||||
mod eth;
|
mod eth;
|
||||||
|
#[cfg(test)]
|
||||||
mod net;
|
mod net;
|
||||||
|
#[cfg(test)]
|
||||||
mod web3;
|
mod web3;
|
||||||
mod helpers;
|
#[cfg(test)]
|
||||||
mod personal;
|
mod personal;
|
||||||
|
@ -63,7 +63,8 @@ pub struct Block {
|
|||||||
pub difficulty: U256,
|
pub difficulty: U256,
|
||||||
#[serde(rename="totalDifficulty")]
|
#[serde(rename="totalDifficulty")]
|
||||||
pub total_difficulty: U256,
|
pub total_difficulty: U256,
|
||||||
pub uncles: Vec<U256>,
|
pub nonce: H64,
|
||||||
|
pub uncles: Vec<H256>,
|
||||||
pub transactions: BlockTransactions
|
pub transactions: BlockTransactions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ mod tests {
|
|||||||
fn test_serialize_block_transactions() {
|
fn test_serialize_block_transactions() {
|
||||||
let t = BlockTransactions::Full(vec![Transaction::default()]);
|
let t = BlockTransactions::Full(vec![Transaction::default()]);
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x00"}]"#);
|
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x"}]"#);
|
||||||
|
|
||||||
let t = BlockTransactions::Hashes(vec![H256::default()]);
|
let t = BlockTransactions::Hashes(vec![H256::default()]);
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
@ -104,11 +105,12 @@ mod tests {
|
|||||||
timestamp: U256::default(),
|
timestamp: U256::default(),
|
||||||
difficulty: U256::default(),
|
difficulty: U256::default(),
|
||||||
total_difficulty: U256::default(),
|
total_difficulty: U256::default(),
|
||||||
|
nonce: H64::default(),
|
||||||
uncles: vec![],
|
uncles: vec![],
|
||||||
transactions: BlockTransactions::Hashes(vec![])
|
transactions: BlockTransactions::Hashes(vec![])
|
||||||
};
|
};
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&block).unwrap();
|
let serialized = serde_json::to_string(&block).unwrap();
|
||||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x00","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","uncles":[],"transactions":[]}"#);
|
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","nonce":"0x0000000000000000","uncles":[],"transactions":[]}"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ use serde::de::Visitor;
|
|||||||
use util::common::FromHex;
|
use util::common::FromHex;
|
||||||
|
|
||||||
/// Wrapper structure around vector of bytes.
|
/// Wrapper structure around vector of bytes.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Default)]
|
||||||
pub struct Bytes(Vec<u8>);
|
pub struct Bytes(Vec<u8>);
|
||||||
|
|
||||||
impl Bytes {
|
impl Bytes {
|
||||||
@ -31,13 +31,6 @@ impl Bytes {
|
|||||||
pub fn to_vec(self) -> Vec<u8> { let Bytes(x) = self; x }
|
pub fn to_vec(self) -> Vec<u8> { let Bytes(x) = self; x }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Bytes {
|
|
||||||
fn default() -> Self {
|
|
||||||
// default serialized value is 0x00
|
|
||||||
Bytes(vec![0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Bytes {
|
impl Serialize for Bytes {
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer {
|
where S: Serializer {
|
||||||
|
@ -67,7 +67,7 @@ mod tests {
|
|||||||
fn test_transaction_serialize() {
|
fn test_transaction_serialize() {
|
||||||
let t = Transaction::default();
|
let t = Transaction::default();
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x00"}"#);
|
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x"}"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ impl Into<Transaction> for TransactionRequest {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::str::FromStr;
|
||||||
|
use rustc_serialize::hex::FromHex;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use util::numbers::{Uint, U256};
|
use util::numbers::{Uint, U256};
|
||||||
use util::hash::Address;
|
use util::hash::Address;
|
||||||
@ -121,6 +123,29 @@ mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn transaction_request_deserialize2() {
|
||||||
|
let s = r#"{
|
||||||
|
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
||||||
|
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
||||||
|
"gas": "0x76c0",
|
||||||
|
"gasPrice": "0x9184e72a000",
|
||||||
|
"value": "0x9184e72a",
|
||||||
|
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||||
|
}"#;
|
||||||
|
let deserialized: TransactionRequest = serde_json::from_str(s).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(deserialized, TransactionRequest {
|
||||||
|
from: Address::from_str("b60e8dd61c5d32be8058bb8eb970870f07233155").unwrap(),
|
||||||
|
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||||
|
gas_price: Some(U256::from_str("9184e72a000").unwrap()),
|
||||||
|
gas: Some(U256::from_str("76c0").unwrap()),
|
||||||
|
value: Some(U256::from_str("9184e72a").unwrap()),
|
||||||
|
data: Some(Bytes::new("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675".from_hex().unwrap())),
|
||||||
|
nonce: None
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_request_deserialize_empty() {
|
fn transaction_request_deserialize_empty() {
|
||||||
let s = r#"{"from":"0x0000000000000000000000000000000000000001"}"#;
|
let s = r#"{"from":"0x0000000000000000000000000000000000000001"}"#;
|
||||||
|
@ -1297,7 +1297,7 @@ impl ChainSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn chain_new_head(&mut self, io: &mut SyncIo) {
|
pub fn chain_new_head(&mut self, io: &mut SyncIo) {
|
||||||
self.miner.prepare_sealing(io.chain());
|
self.miner.update_sealing(io.chain());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,6 +490,8 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + fmt::Debug + fmt::Displa
|
|||||||
fn zero() -> Self;
|
fn zero() -> Self;
|
||||||
/// Returns new instance equalling one.
|
/// Returns new instance equalling one.
|
||||||
fn one() -> Self;
|
fn one() -> Self;
|
||||||
|
/// Returns the largest value that can be represented by this integer type.
|
||||||
|
fn max_value() -> Self;
|
||||||
|
|
||||||
/// Error type for converting from a decimal string.
|
/// Error type for converting from a decimal string.
|
||||||
type FromDecStrErr;
|
type FromDecStrErr;
|
||||||
@ -647,6 +649,15 @@ macro_rules! construct_uint {
|
|||||||
From::from(1u64)
|
From::from(1u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn max_value() -> Self {
|
||||||
|
let mut result = [0; $n_words];
|
||||||
|
for i in 0..$n_words {
|
||||||
|
result[i] = u64::max_value();
|
||||||
|
}
|
||||||
|
$name(result)
|
||||||
|
}
|
||||||
|
|
||||||
/// Fast exponentation by squaring
|
/// Fast exponentation by squaring
|
||||||
/// https://en.wikipedia.org/wiki/Exponentiation_by_squaring
|
/// https://en.wikipedia.org/wiki/Exponentiation_by_squaring
|
||||||
fn pow(self, expon: Self) -> Self {
|
fn pow(self, expon: Self) -> Self {
|
||||||
|
@ -63,7 +63,8 @@ pub trait FixedHash: Sized + BytesConvertable + Populatable + FromStr + Default
|
|||||||
fn low_u64(&self) -> u64;
|
fn low_u64(&self) -> u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_0x(s: &str) -> &str {
|
/// Return `s` without the `0x` at the beginning of it, if any.
|
||||||
|
pub fn clean_0x(s: &str) -> &str {
|
||||||
if s.len() >= 2 && &s[0..2] == "0x" {
|
if s.len() >= 2 && &s[0..2] == "0x" {
|
||||||
&s[2..]
|
&s[2..]
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user