Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adabd8198c | ||
|
|
c2487cfe07 | ||
|
|
e0141f8324 | ||
|
|
b52ac20660 | ||
|
|
3c85f29f11 |
@@ -34,37 +34,58 @@ variables:
|
|||||||
.docker-cache-status: &docker-cache-status
|
.docker-cache-status: &docker-cache-status
|
||||||
variables:
|
variables:
|
||||||
CARGO_HOME: "/ci-cache/parity-ethereum/cargo/${CI_JOB_NAME}"
|
CARGO_HOME: "/ci-cache/parity-ethereum/cargo/${CI_JOB_NAME}"
|
||||||
|
dependencies: []
|
||||||
before_script:
|
before_script:
|
||||||
- SCCACHE_ERROR_LOG=/builds/parity/parity-ethereum/sccache_error.log RUST_LOG=sccache::server=debug sccache --start-server
|
- SCCACHE_ERROR_LOG=/builds/parity/parity-ethereum/sccache_debug.log
|
||||||
|
RUST_LOG=sccache=debug
|
||||||
|
sccache --start-server
|
||||||
- sccache -s
|
- sccache -s
|
||||||
after_script:
|
after_script:
|
||||||
- echo "All crate-types:"
|
# sccache debug info
|
||||||
- grep 'parse_arguments.*--crate-type' sccache_error.log | sed -re 's/.*"--crate-type", "([^"]+)".*/\1/' | sort | uniq -c
|
- if test -e sccache_debug.log;
|
||||||
- echo "Non-cacheable reasons:"
|
then
|
||||||
- grep CannotCache sccache_error.log | sed -re 's/.*CannotCache\((.+)\).*/\1/' | sort | uniq -c
|
echo "_____sccache_debug.log listing start:_____";
|
||||||
|
cat sccache_debug.log;
|
||||||
|
echo "_____sccache_debug.log listing end_____";
|
||||||
|
echo "All crate-types:";
|
||||||
|
grep 'parse_arguments.*--crate-type' sccache_debug.log | sed -re 's/.*"--crate-type", "([^"]+)".*/\1/' | sort | uniq -c;
|
||||||
|
echo "_____Non-cacheable reasons:_____";
|
||||||
|
grep CannotCache sccache_debug.log | sed -re 's/.*CannotCache\((.+)\).*/\1/' | sort | uniq -c;
|
||||||
|
else
|
||||||
|
echo "_____No logs from sccache_____";
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
tags:
|
tags:
|
||||||
- linux-docker
|
- linux-docker
|
||||||
|
|
||||||
|
.build-on-linux: &build-on-linux
|
||||||
|
stage: build
|
||||||
|
<<: *docker-cache-status
|
||||||
|
<<: *collect_artifacts
|
||||||
|
script:
|
||||||
|
- scripts/gitlab/build-linux.sh
|
||||||
|
- sccache -s
|
||||||
|
|
||||||
|
|
||||||
cargo-check 0 3:
|
cargo-check 0 3:
|
||||||
stage: test
|
stage: test
|
||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
script:
|
script:
|
||||||
- time cargo check --target $CARGO_TARGET --locked --no-default-features
|
- time cargo check --target $CARGO_TARGET --locked --no-default-features --verbose --color=always
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
cargo-check 1 3:
|
cargo-check 1 3:
|
||||||
stage: test
|
stage: test
|
||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
script:
|
script:
|
||||||
- time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --no-default-features
|
- time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --no-default-features --verbose --color=always
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
cargo-check 2 3:
|
cargo-check 2 3:
|
||||||
stage: test
|
stage: test
|
||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
script:
|
script:
|
||||||
- time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --features "mio"
|
- time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --features "mio" --verbose --color=always
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
cargo-audit:
|
cargo-audit:
|
||||||
@@ -72,7 +93,6 @@ cargo-audit:
|
|||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
script:
|
script:
|
||||||
- cargo audit
|
- cargo audit
|
||||||
- sccache -s
|
|
||||||
|
|
||||||
validate-chainspecs:
|
validate-chainspecs:
|
||||||
stage: test
|
stage: test
|
||||||
@@ -92,55 +112,64 @@ test-linux:
|
|||||||
stage: build
|
stage: build
|
||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
script:
|
script:
|
||||||
- ./scripts/gitlab/test-linux.sh
|
- ./scripts/gitlab/test-linux.sh stable
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
build-android:
|
test-linux-beta:
|
||||||
stage: build
|
|
||||||
image: parity/rust-parity-ethereum-android-build:stretch
|
|
||||||
variables:
|
|
||||||
CARGO_TARGET: armv7-linux-androideabi
|
|
||||||
<<: *docker-cache-status
|
|
||||||
<<: *collect_artifacts
|
|
||||||
script:
|
|
||||||
- scripts/gitlab/build-linux.sh
|
|
||||||
tags:
|
|
||||||
- linux-docker
|
|
||||||
|
|
||||||
build-linux: &build-linux
|
|
||||||
stage: build
|
stage: build
|
||||||
only: *releaseable_branches
|
only: *releaseable_branches
|
||||||
<<: *docker-cache-status
|
<<: *docker-cache-status
|
||||||
<<: *collect_artifacts
|
|
||||||
script:
|
script:
|
||||||
- scripts/gitlab/build-linux.sh
|
- ./scripts/gitlab/test-linux.sh beta
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
|
test-linux-nightly:
|
||||||
|
stage: build
|
||||||
|
only: *releaseable_branches
|
||||||
|
<<: *docker-cache-status
|
||||||
|
script:
|
||||||
|
- ./scripts/gitlab/test-linux.sh nightly
|
||||||
|
- sccache -s
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
build-android:
|
||||||
|
<<: *build-on-linux
|
||||||
|
image: parity/rust-parity-ethereum-android-build:stretch
|
||||||
|
variables:
|
||||||
|
CARGO_TARGET: armv7-linux-androideabi
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
<<: *build-on-linux
|
||||||
|
only: *releaseable_branches
|
||||||
|
|
||||||
build-linux-i386:
|
build-linux-i386:
|
||||||
<<: *build-linux
|
<<: *build-on-linux
|
||||||
|
only: *releaseable_branches
|
||||||
image: parity/rust-parity-ethereum-build:i386
|
image: parity/rust-parity-ethereum-build:i386
|
||||||
variables:
|
variables:
|
||||||
CARGO_TARGET: i686-unknown-linux-gnu
|
CARGO_TARGET: i686-unknown-linux-gnu
|
||||||
|
|
||||||
build-linux-arm64:
|
build-linux-arm64:
|
||||||
<<: *build-linux
|
<<: *build-on-linux
|
||||||
|
only: *releaseable_branches
|
||||||
image: parity/rust-parity-ethereum-build:arm64
|
image: parity/rust-parity-ethereum-build:arm64
|
||||||
variables:
|
variables:
|
||||||
CARGO_TARGET: aarch64-unknown-linux-gnu
|
CARGO_TARGET: aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
build-linux-armhf:
|
build-linux-armhf:
|
||||||
<<: *build-linux
|
<<: *build-on-linux
|
||||||
|
only: *releaseable_branches
|
||||||
image: parity/rust-parity-ethereum-build:armhf
|
image: parity/rust-parity-ethereum-build:armhf
|
||||||
variables:
|
variables:
|
||||||
CARGO_TARGET: armv7-unknown-linux-gnueabihf
|
CARGO_TARGET: armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
build-darwin:
|
build-darwin:
|
||||||
stage: build
|
stage: build
|
||||||
only: *releaseable_branches
|
|
||||||
<<: *collect_artifacts
|
<<: *collect_artifacts
|
||||||
|
only: *releaseable_branches
|
||||||
variables:
|
variables:
|
||||||
CARGO_TARGET: x86_64-apple-darwin
|
CARGO_TARGET: x86_64-apple-darwin
|
||||||
CARGO_HOME: "${CI_PROJECT_DIR}/.cargo"
|
CARGO_HOME: "${CI_PROJECT_DIR}/.cargo"
|
||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
script:
|
script:
|
||||||
@@ -255,7 +284,9 @@ publish-docs:
|
|||||||
except:
|
except:
|
||||||
- nightly
|
- nightly
|
||||||
cache: {}
|
cache: {}
|
||||||
|
dependencies: []
|
||||||
script:
|
script:
|
||||||
- scripts/gitlab/publish-docs.sh
|
- scripts/gitlab/publish-docs.sh
|
||||||
tags:
|
tags:
|
||||||
- linux-docker
|
- linux-docker
|
||||||
|
allow_failure: true
|
||||||
|
|||||||
23
Cargo.lock
generated
23
Cargo.lock
generated
@@ -1282,6 +1282,7 @@ dependencies = [
|
|||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"memory-cache 0.1.0",
|
"memory-cache 0.1.0",
|
||||||
|
"num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2346,6 +2347,15 @@ dependencies = [
|
|||||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.39"
|
version = "0.1.39"
|
||||||
@@ -2447,7 +2457,7 @@ dependencies = [
|
|||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jni 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jni 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"panic_hook 0.1.0",
|
"panic_hook 0.1.0",
|
||||||
"parity-ethereum 2.5.0",
|
"parity-ethereum 2.5.1",
|
||||||
"tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio-current-thread 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio-current-thread 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@@ -2477,7 +2487,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-ethereum"
|
name = "parity-ethereum"
|
||||||
version = "2.5.0"
|
version = "2.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2530,7 +2540,7 @@ dependencies = [
|
|||||||
"parity-rpc 1.12.0",
|
"parity-rpc 1.12.0",
|
||||||
"parity-runtime 0.1.0",
|
"parity-runtime 0.1.0",
|
||||||
"parity-updater 1.12.0",
|
"parity-updater 1.12.0",
|
||||||
"parity-version 2.5.0",
|
"parity-version 2.5.1",
|
||||||
"parity-whisper 0.1.0",
|
"parity-whisper 0.1.0",
|
||||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2673,7 +2683,7 @@ dependencies = [
|
|||||||
"parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-runtime 0.1.0",
|
"parity-runtime 0.1.0",
|
||||||
"parity-updater 1.12.0",
|
"parity-updater 1.12.0",
|
||||||
"parity-version 2.5.0",
|
"parity-version 2.5.1",
|
||||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2771,7 +2781,7 @@ dependencies = [
|
|||||||
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-hash-fetch 1.12.0",
|
"parity-hash-fetch 1.12.0",
|
||||||
"parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-version 2.5.0",
|
"parity-version 2.5.1",
|
||||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -2781,7 +2791,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-version"
|
name = "parity-version"
|
||||||
version = "2.5.0"
|
version = "2.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -4633,6 +4643,7 @@ dependencies = [
|
|||||||
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
|
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
|
||||||
"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
|
"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
|
||||||
"checksum num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1"
|
"checksum num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1"
|
||||||
|
"checksum num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "57450397855d951f1a41305e54851b1a7b8f5d2e349543a02a2effe25459f718"
|
||||||
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
|
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
|
||||||
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
|
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
|
||||||
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
description = "Parity Ethereum client"
|
description = "Parity Ethereum client"
|
||||||
name = "parity-ethereum"
|
name = "parity-ethereum"
|
||||||
# NOTE Make sure to update util/version/Cargo.toml as well
|
# NOTE Make sure to update util/version/Cargo.toml as well
|
||||||
version = "2.5.0"
|
version = "2.5.1"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ vm = { path = "../vm" }
|
|||||||
keccak-hash = "0.1"
|
keccak-hash = "0.1"
|
||||||
parking_lot = "0.7"
|
parking_lot = "0.7"
|
||||||
memory-cache = { path = "../../util/memory-cache" }
|
memory-cache = { path = "../../util/memory-cache" }
|
||||||
|
num-bigint = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rustc-hex = "1.0"
|
rustc-hex = "1.0"
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ criterion_group!(
|
|||||||
mem_gas_calculation_same_usize,
|
mem_gas_calculation_same_usize,
|
||||||
mem_gas_calculation_same_u256,
|
mem_gas_calculation_same_u256,
|
||||||
mem_gas_calculation_increasing_usize,
|
mem_gas_calculation_increasing_usize,
|
||||||
mem_gas_calculation_increasing_u256
|
mem_gas_calculation_increasing_u256,
|
||||||
|
blockhash_mulmod_small,
|
||||||
|
blockhash_mulmod_large,
|
||||||
);
|
);
|
||||||
criterion_main!(basic);
|
criterion_main!(basic);
|
||||||
|
|
||||||
@@ -150,6 +152,54 @@ fn mem_gas_calculation_increasing(gas: U256, b: &mut Bencher) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn blockhash_mulmod_small(b: &mut Criterion) {
|
||||||
|
b.bench_function("blockhash_mulmod_small", |b| {
|
||||||
|
let factory = Factory::default();
|
||||||
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
let code = black_box(
|
||||||
|
"6080604052348015600f57600080fd5b5060005a90505b60c881111560de5760017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8009505a90506016565b506035806100ed6000396000f3fe6080604052600080fdfea165627a7a72305820bde4a0ac6d0fac28fc879244baf8a6a0eda514bc95fb7ecbcaaebf2556e2687c0029".from_hex().unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut params = ActionParams::default();
|
||||||
|
params.address = address.clone();
|
||||||
|
params.gas = U256::from(4_000u64);
|
||||||
|
params.code = Some(Arc::new(code.clone()));
|
||||||
|
|
||||||
|
let vm = factory.create(params, ext.schedule(), 0);
|
||||||
|
|
||||||
|
result(vm.exec(&mut ext).ok().unwrap())
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn blockhash_mulmod_large(b: &mut Criterion) {
|
||||||
|
b.bench_function("blockhash_mulmod_large", |b| {
|
||||||
|
let factory = Factory::default();
|
||||||
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
let code = black_box(
|
||||||
|
"608060405234801561001057600080fd5b5060005a90505b60c8811115610177577efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009505a9050610017565b506035806101866000396000f3fe6080604052600080fdfea165627a7a72305820dcaec306f67bb96f3044fff25c9af2ec66f01d0954d0656964f046f42f2780670029".from_hex().unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut params = ActionParams::default();
|
||||||
|
params.address = address.clone();
|
||||||
|
params.gas = U256::from(4_000u64);
|
||||||
|
params.code = Some(Arc::new(code.clone()));
|
||||||
|
|
||||||
|
let vm = factory.create(params, ext.schedule(), 0);
|
||||||
|
|
||||||
|
result(vm.exec(&mut ext).ok().unwrap())
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn result(r: Result<evm::GasLeft>) -> U256 {
|
fn result(r: Result<evm::GasLeft>) -> U256 {
|
||||||
match r {
|
match r {
|
||||||
Ok(GasLeft::Known(gas_left)) => gas_left,
|
Ok(GasLeft::Known(gas_left)) => gas_left,
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ use std::{cmp, mem};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::{U256, U512, H256, Address};
|
use ethereum_types::{U256, H256, Address};
|
||||||
|
use num_bigint::BigUint;
|
||||||
|
|
||||||
use vm::{
|
use vm::{
|
||||||
self, ActionParams, ParamsType, ActionValue, CallType, MessageCallResult,
|
self, ActionParams, ParamsType, ActionValue, CallType, MessageCallResult,
|
||||||
@@ -61,6 +62,17 @@ const TWO_POW_96: U256 = U256([0, 0x100000000, 0, 0]); //0x1 00000000 00000000 0
|
|||||||
const TWO_POW_224: U256 = U256([0, 0, 0, 0x100000000]); //0x1 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
const TWO_POW_224: U256 = U256([0, 0, 0, 0x100000000]); //0x1 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
||||||
const TWO_POW_248: U256 = U256([0, 0, 0, 0x100000000000000]); //0x1 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000
|
const TWO_POW_248: U256 = U256([0, 0, 0, 0x100000000000000]); //0x1 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000
|
||||||
|
|
||||||
|
fn to_biguint(x: U256) -> BigUint {
|
||||||
|
let mut bytes = [0u8; 32];
|
||||||
|
x.to_little_endian(&mut bytes);
|
||||||
|
BigUint::from_bytes_le(&bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_biguint(x: BigUint) -> U256 {
|
||||||
|
let bytes = x.to_bytes_le();
|
||||||
|
U256::from_little_endian(&bytes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Abstraction over raw vector of Bytes. Easier state management of PC.
|
/// Abstraction over raw vector of Bytes. Easier state management of PC.
|
||||||
struct CodeReader {
|
struct CodeReader {
|
||||||
position: ProgramCounter,
|
position: ProgramCounter,
|
||||||
@@ -1009,11 +1021,12 @@ impl<Cost: CostType> Interpreter<Cost> {
|
|||||||
let c = self.stack.pop_back();
|
let c = self.stack.pop_back();
|
||||||
|
|
||||||
self.stack.push(if !c.is_zero() {
|
self.stack.push(if !c.is_zero() {
|
||||||
// upcast to 512
|
let a_num = to_biguint(a);
|
||||||
let a5 = U512::from(a);
|
let b_num = to_biguint(b);
|
||||||
let res = a5.overflowing_add(U512::from(b)).0;
|
let c_num = to_biguint(c);
|
||||||
let x = res % U512::from(c);
|
let res = a_num + b_num;
|
||||||
U256::from(x)
|
let x = res % c_num;
|
||||||
|
from_biguint(x)
|
||||||
} else {
|
} else {
|
||||||
U256::zero()
|
U256::zero()
|
||||||
});
|
});
|
||||||
@@ -1024,10 +1037,12 @@ impl<Cost: CostType> Interpreter<Cost> {
|
|||||||
let c = self.stack.pop_back();
|
let c = self.stack.pop_back();
|
||||||
|
|
||||||
self.stack.push(if !c.is_zero() {
|
self.stack.push(if !c.is_zero() {
|
||||||
let a5 = U512::from(a);
|
let a_num = to_biguint(a);
|
||||||
let res = a5.overflowing_mul(U512::from(b)).0;
|
let b_num = to_biguint(b);
|
||||||
let x = res % U512::from(c);
|
let c_num = to_biguint(c);
|
||||||
U256::from(x)
|
let res = a_num * b_num;
|
||||||
|
let x = res % c_num;
|
||||||
|
from_biguint(x)
|
||||||
} else {
|
} else {
|
||||||
U256::zero()
|
U256::zero()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ extern crate vm;
|
|||||||
extern crate keccak_hash as hash;
|
extern crate keccak_hash as hash;
|
||||||
extern crate memory_cache;
|
extern crate memory_cache;
|
||||||
extern crate parity_bytes as bytes;
|
extern crate parity_bytes as bytes;
|
||||||
|
extern crate num_bigint;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|||||||
@@ -48,8 +48,14 @@
|
|||||||
"timestamp": "0x5c51a607"
|
"timestamp": "0x5c51a607"
|
||||||
},
|
},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
"enode://011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a@51.141.78.53:30303",
|
"enode://06333009fc9ef3c9e174768e495722a7f98fe7afd4660542e983005f85e556028410fd03278944f44cfe5437b1750b5e6bd1738f700fe7da3626d52010d2954c@51.141.15.254:30303",
|
||||||
"enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303"
|
"enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303",
|
||||||
|
"enode://573b6607cd59f241e30e4c4943fd50e99e2b6f42f9bd5ca111659d309c06741247f4f1e93843ad3e8c8c18b6e2d94c161b7ef67479b3938780a97134b618b5ce@52.56.136.200:30303",
|
||||||
|
"enode://67913271d14f445689e8310270c304d42f268428f2de7a4ac0275bea97690e021df6f549f462503ff4c7a81d9dd27288867bbfa2271477d0911378b8944fae55@157.230.239.163:30303",
|
||||||
|
"enode://a87685902a0622e9cf18c68e73a0ea45156ec53e857ef049b185a9db2296ca04d776417bf1901c0b4eacb5b26271d8694e88e3f17c20d49eb77e1a41ab26b5b3@51.141.78.53:30303",
|
||||||
|
"enode://ae8658da8d255d1992c3ec6e62e11d6e1c5899aa1566504bc1ff96a0c9c8bd44838372be643342553817f5cc7d78f1c83a8093dee13d77b3b0a583c050c81940@18.232.185.151:30303",
|
||||||
|
"enode://ae8658da8d255d1992c3ec6e62e11d6e1c5899aa1566504bc1ff96a0c9c8bd44838372be643342553817f5cc7d78f1c83a8093dee13d77b3b0a583c050c81940@18.232.185.151:30303",
|
||||||
|
"enode://b477ca6d507a3f57070783eb62ba838847635f8b1a0cbffb8b7f8173f5894cf550f0225a5c279341e2d862a606e778b57180a4f1db3db78c51eadcfa4fdc6963@40.68.240.160:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0x0000000000000000000000000000000000000000": {
|
"0x0000000000000000000000000000000000000000": {
|
||||||
|
|||||||
@@ -38,7 +38,9 @@
|
|||||||
},
|
},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
"enode://06333009fc9ef3c9e174768e495722a7f98fe7afd4660542e983005f85e556028410fd03278944f44cfe5437b1750b5e6bd1738f700fe7da3626d52010d2954c@51.141.15.254:30303",
|
"enode://06333009fc9ef3c9e174768e495722a7f98fe7afd4660542e983005f85e556028410fd03278944f44cfe5437b1750b5e6bd1738f700fe7da3626d52010d2954c@51.141.15.254:30303",
|
||||||
"enode://ae8658da8d255d1992c3ec6e62e11d6e1c5899aa1566504bc1ff96a0c9c8bd44838372be643342553817f5cc7d78f1c83a8093dee13d77b3b0a583c050c81940@18.232.185.151:30303"
|
"enode://93c94e999be5dd854c5d82a7cf5c14822973b5d9badb56ad4974586ec4d4f1995c815af795c20bb6e0a6226d3ee55808435c4dc89baf94ee581141b064d19dfc@80.187.116.161:25720",
|
||||||
|
"enode://ae8658da8d255d1992c3ec6e62e11d6e1c5899aa1566504bc1ff96a0c9c8bd44838372be643342553817f5cc7d78f1c83a8093dee13d77b3b0a583c050c81940@18.232.185.151:30303",
|
||||||
|
"enode://b477ca6d507a3f57070783eb62ba838847635f8b1a0cbffb8b7f8173f5894cf550f0225a5c279341e2d862a606e778b57180a4f1db3db78c51eadcfa4fdc6963@40.68.240.160:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0x0000000000000000000000000000000000000000": {
|
"0x0000000000000000000000000000000000000000": {
|
||||||
|
|||||||
@@ -7,17 +7,31 @@
|
|||||||
"stepDuration": "0x4",
|
"stepDuration": "0x4",
|
||||||
"blockReward": "0x4563918244F40000",
|
"blockReward": "0x4563918244F40000",
|
||||||
"validators": {
|
"validators": {
|
||||||
"list": [
|
"multi": {
|
||||||
"0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED",
|
"0": {
|
||||||
"0x00427feae2419c15b89d1c21af10d1b6650a4d3d",
|
"list": [
|
||||||
"0x4Ed9B08e6354C70fE6F8CB0411b0d3246b424d6c",
|
"0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED",
|
||||||
"0x0020ee4Be0e2027d76603cB751eE069519bA81A1",
|
"0x00427feae2419c15b89d1c21af10d1b6650a4d3d",
|
||||||
"0x0010f94b296a852aaac52ea6c5ac72e03afd032d",
|
"0x4Ed9B08e6354C70fE6F8CB0411b0d3246b424d6c",
|
||||||
"0x007733a1FE69CF3f2CF989F81C7b4cAc1693387A",
|
"0x0020ee4Be0e2027d76603cB751eE069519bA81A1",
|
||||||
"0x00E6d2b931F55a3f1701c7389d592a7778897879",
|
"0x0010f94b296a852aaac52ea6c5ac72e03afd032d",
|
||||||
"0x00e4a10650e5a6D6001C38ff8E64F97016a1645c",
|
"0x007733a1FE69CF3f2CF989F81C7b4cAc1693387A",
|
||||||
"0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de"
|
"0x00E6d2b931F55a3f1701c7389d592a7778897879",
|
||||||
]
|
"0x00e4a10650e5a6D6001C38ff8E64F97016a1645c",
|
||||||
|
"0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"10960440": {
|
||||||
|
"list": [
|
||||||
|
"0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED",
|
||||||
|
"0x0010f94b296a852aaac52ea6c5ac72e03afd032d",
|
||||||
|
"0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"10960500": {
|
||||||
|
"safeContract": "0xaE71807C1B0a093cB1547b682DC78316D945c9B8"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"validateScoreTransition": "0x41a3c4",
|
"validateScoreTransition": "0x41a3c4",
|
||||||
"validateStepTransition": "0x16e360",
|
"validateStepTransition": "0x16e360",
|
||||||
@@ -5367,6 +5381,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
|
"enode://f6e37b943bad3a78cb8589b1798d30d210ffd39cfcd2c8f2de4f098467fd49c667980100d919da7ca46cd50505d30989abda87f0b9339377de13d6592c22caf8@34.198.49.72:30303",
|
||||||
"enode://56abaf065581a5985b8c5f4f88bd202526482761ba10be9bfdcd14846dd01f652ec33fde0f8c0fd1db19b59a4c04465681fcef50e11380ca88d25996191c52de@40.71.221.215:30303",
|
"enode://56abaf065581a5985b8c5f4f88bd202526482761ba10be9bfdcd14846dd01f652ec33fde0f8c0fd1db19b59a4c04465681fcef50e11380ca88d25996191c52de@40.71.221.215:30303",
|
||||||
"enode://d07827483dc47b368eaf88454fb04b41b7452cf454e194e2bd4c14f98a3278fed5d819dbecd0d010407fc7688d941ee1e58d4f9c6354d3da3be92f55c17d7ce3@52.166.117.77:30303",
|
"enode://d07827483dc47b368eaf88454fb04b41b7452cf454e194e2bd4c14f98a3278fed5d819dbecd0d010407fc7688d941ee1e58d4f9c6354d3da3be92f55c17d7ce3@52.166.117.77:30303",
|
||||||
"enode://38e6e7fd416293ed120d567a2675fe078c0205ab0671abf16982ce969823bd1f3443d590c18b321dfae7dcbe1f6ba98ef8702f255c3c9822a188abb82c53adca@51.77.66.187:30303",
|
"enode://38e6e7fd416293ed120d567a2675fe078c0205ab0671abf16982ce969823bd1f3443d590c18b321dfae7dcbe1f6ba98ef8702f255c3c9822a188abb82c53adca@51.77.66.187:30303",
|
||||||
|
|||||||
@@ -34,7 +34,10 @@
|
|||||||
"eip140Transition": "0x0",
|
"eip140Transition": "0x0",
|
||||||
"eip211Transition": "0x0",
|
"eip211Transition": "0x0",
|
||||||
"eip214Transition": "0x0",
|
"eip214Transition": "0x0",
|
||||||
"eip658Transition": "0x0"
|
"eip658Transition": "0x0",
|
||||||
|
"eip145Transition": 8582254,
|
||||||
|
"eip1014Transition": 8582254,
|
||||||
|
"eip1052Transition": 8582254
|
||||||
},
|
},
|
||||||
"genesis": {
|
"genesis": {
|
||||||
"seal": {
|
"seal": {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
"eip1014Transition": "0x37db77",
|
"eip1014Transition": "0x37db77",
|
||||||
"eip1052Transition": "0x37db77",
|
"eip1052Transition": "0x37db77",
|
||||||
"eip1283Transition": "0x37db77",
|
"eip1283Transition": "0x37db77",
|
||||||
|
"eip1283DisableTransition": "0x41efd2",
|
||||||
"gasLimitBoundDivisor": "0x400",
|
"gasLimitBoundDivisor": "0x400",
|
||||||
"maxCodeSize": "0x6000",
|
"maxCodeSize": "0x6000",
|
||||||
"maxCodeSizeTransition": "0x0",
|
"maxCodeSizeTransition": "0x0",
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ use std::time;
|
|||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
|
use bytes::Bytes;
|
||||||
use client::{BlockId, EngineClient};
|
use client::{BlockId, EngineClient};
|
||||||
use engines::clique::util::{extract_signers, recover_creator};
|
use engines::clique::util::{extract_signers, recover_creator};
|
||||||
use engines::{Engine, EngineError, Seal};
|
use engines::{Engine, EngineError, Seal};
|
||||||
@@ -713,6 +714,13 @@ impl Engine<EthereumMachine> for Clique {
|
|||||||
header.set_difficulty(DIFF_NOTURN);
|
header.set_difficulty(DIFF_NOTURN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let zero_padding_len = VANITY_LENGTH - header.extra_data().len();
|
||||||
|
if zero_padding_len > 0 {
|
||||||
|
let mut resized_extra_data = header.extra_data().clone();
|
||||||
|
resized_extra_data.resize(VANITY_LENGTH, 0);
|
||||||
|
header.set_extra_data(resized_extra_data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
trace!(target: "engine", "populate_from_parent: no signer registered");
|
trace!(target: "engine", "populate_from_parent: no signer registered");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
//! Block header.
|
//! Block header.
|
||||||
|
|
||||||
use std::cmp;
|
|
||||||
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak};
|
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak};
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
use ethereum_types::{H256, U256, Address, Bloom};
|
use ethereum_types::{H256, U256, Address, Bloom};
|
||||||
@@ -342,7 +341,7 @@ impl Decodable for Header {
|
|||||||
number: r.val_at(8)?,
|
number: r.val_at(8)?,
|
||||||
gas_limit: r.val_at(9)?,
|
gas_limit: r.val_at(9)?,
|
||||||
gas_used: r.val_at(10)?,
|
gas_used: r.val_at(10)?,
|
||||||
timestamp: cmp::min(r.val_at::<U256>(11)?, u64::max_value().into()).as_u64(),
|
timestamp: r.val_at(11)?,
|
||||||
extra_data: r.val_at(12)?,
|
extra_data: r.val_at(12)?,
|
||||||
seal: vec![],
|
seal: vec![],
|
||||||
hash: keccak(r.as_raw()).into(),
|
hash: keccak(r.as_raw()).into(),
|
||||||
@@ -412,4 +411,15 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(header_rlp, encoded_header);
|
assert_eq!(header_rlp, encoded_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reject_header_with_large_timestamp() {
|
||||||
|
// that's rlp of block header created with ethash engine.
|
||||||
|
// The encoding contains a large timestamp (295147905179352825856)
|
||||||
|
let header_rlp = "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d891000000000000000000080a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23".from_hex().unwrap();
|
||||||
|
|
||||||
|
// This should fail decoding timestamp
|
||||||
|
let header: Result<Header, _> = rlp::decode(&header_rlp);
|
||||||
|
assert_eq!(header.unwrap_err(), rlp::DecoderError::RlpIsTooBig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,5 @@
|
|||||||
//! Utilities and helpers for the light client.
|
//! Utilities and helpers for the light client.
|
||||||
|
|
||||||
mod epoch_fetch;
|
mod epoch_fetch;
|
||||||
mod queue_cull;
|
|
||||||
|
|
||||||
pub use self::epoch_fetch::EpochFetch;
|
pub use self::epoch_fetch::EpochFetch;
|
||||||
pub use self::queue_cull::QueueCull;
|
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity Ethereum.
|
|
||||||
|
|
||||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! Service for culling the light client's transaction queue.
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use ethcore::client::ClientIoMessage;
|
|
||||||
use sync::{LightSync, LightNetworkDispatcher};
|
|
||||||
use io::{IoContext, IoHandler, TimerToken};
|
|
||||||
|
|
||||||
use light::client::LightChainClient;
|
|
||||||
use light::on_demand::{request, OnDemand, OnDemandRequester};
|
|
||||||
use light::TransactionQueue;
|
|
||||||
|
|
||||||
use futures::{future, Future};
|
|
||||||
|
|
||||||
use parity_runtime::Executor;
|
|
||||||
|
|
||||||
use parking_lot::RwLock;
|
|
||||||
|
|
||||||
// Attepmt to cull once every 10 minutes.
|
|
||||||
const TOKEN: TimerToken = 1;
|
|
||||||
const TIMEOUT: Duration = Duration::from_secs(60 * 10);
|
|
||||||
|
|
||||||
// But make each attempt last only 9 minutes
|
|
||||||
const PURGE_TIMEOUT: Duration = Duration::from_secs(60 * 9);
|
|
||||||
|
|
||||||
/// Periodically culls the transaction queue of mined transactions.
|
|
||||||
pub struct QueueCull<T> {
|
|
||||||
/// A handle to the client, for getting the latest block header.
|
|
||||||
pub client: Arc<T>,
|
|
||||||
/// A handle to the sync service.
|
|
||||||
pub sync: Arc<LightSync>,
|
|
||||||
/// The on-demand request service.
|
|
||||||
pub on_demand: Arc<OnDemand>,
|
|
||||||
/// The transaction queue.
|
|
||||||
pub txq: Arc<RwLock<TransactionQueue>>,
|
|
||||||
/// Event loop executor.
|
|
||||||
pub executor: Executor,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: LightChainClient + 'static> IoHandler<ClientIoMessage> for QueueCull<T> {
|
|
||||||
fn initialize(&self, io: &IoContext<ClientIoMessage>) {
|
|
||||||
io.register_timer(TOKEN, TIMEOUT).expect("Error registering timer");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn timeout(&self, _io: &IoContext<ClientIoMessage>, timer: TimerToken) {
|
|
||||||
if timer != TOKEN { return }
|
|
||||||
|
|
||||||
let senders = self.txq.read().queued_senders();
|
|
||||||
if senders.is_empty() { return }
|
|
||||||
|
|
||||||
let (sync, on_demand, txq) = (self.sync.clone(), self.on_demand.clone(), self.txq.clone());
|
|
||||||
let best_header = self.client.best_block_header();
|
|
||||||
let start_nonce = self.client.engine().account_start_nonce(best_header.number());
|
|
||||||
|
|
||||||
info!(target: "cull", "Attempting to cull queued transactions from {} senders.", senders.len());
|
|
||||||
self.executor.spawn_with_timeout(move || {
|
|
||||||
let maybe_fetching = sync.with_context(move |ctx| {
|
|
||||||
// fetch the nonce of each sender in the queue.
|
|
||||||
let nonce_reqs = senders.iter()
|
|
||||||
.map(|&address| request::Account { header: best_header.clone().into(), address: address })
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// when they come in, update each sender to the new nonce.
|
|
||||||
on_demand.request(ctx, nonce_reqs)
|
|
||||||
.expect("No back-references; therefore all back-references are valid; qed")
|
|
||||||
.map(move |accs| {
|
|
||||||
let txq = txq.write();
|
|
||||||
let _ = accs.into_iter()
|
|
||||||
.map(|maybe_acc| maybe_acc.map_or(start_nonce, |acc| acc.nonce))
|
|
||||||
.zip(senders)
|
|
||||||
.fold(txq, |mut txq, (nonce, addr)| {
|
|
||||||
txq.cull(addr, nonce);
|
|
||||||
txq
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.map_err(|_| debug!(target: "cull", "OnDemand prematurely closed channel."))
|
|
||||||
});
|
|
||||||
|
|
||||||
match maybe_fetching {
|
|
||||||
Some(fut) => future::Either::A(fut),
|
|
||||||
None => {
|
|
||||||
debug!(target: "cull", "Unable to acquire network context; qed");
|
|
||||||
future::Either::B(future::ok(()))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}, PURGE_TIMEOUT, || {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -252,6 +252,7 @@ pub struct FullDependencies {
|
|||||||
pub gas_price_percentile: usize,
|
pub gas_price_percentile: usize,
|
||||||
pub poll_lifetime: u32,
|
pub poll_lifetime: u32,
|
||||||
pub allow_missing_blocks: bool,
|
pub allow_missing_blocks: bool,
|
||||||
|
pub no_ancient_blocks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FullDependencies {
|
impl FullDependencies {
|
||||||
@@ -303,6 +304,7 @@ impl FullDependencies {
|
|||||||
gas_price_percentile: self.gas_price_percentile,
|
gas_price_percentile: self.gas_price_percentile,
|
||||||
allow_missing_blocks: self.allow_missing_blocks,
|
allow_missing_blocks: self.allow_missing_blocks,
|
||||||
allow_experimental_rpcs: self.experimental_rpcs,
|
allow_experimental_rpcs: self.experimental_rpcs,
|
||||||
|
no_ancient_blocks: self.no_ancient_blocks
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
handler.extend_with(client.to_delegate());
|
handler.extend_with(client.to_delegate());
|
||||||
|
|||||||
@@ -295,17 +295,6 @@ fn execute_light_impl<Cr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq
|
|||||||
// spin up event loop
|
// spin up event loop
|
||||||
let runtime = Runtime::with_default_thread_count();
|
let runtime = Runtime::with_default_thread_count();
|
||||||
|
|
||||||
// queue cull service.
|
|
||||||
let queue_cull = Arc::new(::light_helpers::QueueCull {
|
|
||||||
client: client.clone(),
|
|
||||||
sync: light_sync.clone(),
|
|
||||||
on_demand: on_demand.clone(),
|
|
||||||
txq: txq.clone(),
|
|
||||||
executor: runtime.executor(),
|
|
||||||
});
|
|
||||||
|
|
||||||
service.register_handler(queue_cull).map_err(|e| format!("Error attaching service: {:?}", e))?;
|
|
||||||
|
|
||||||
// start the network.
|
// start the network.
|
||||||
light_sync.start_network();
|
light_sync.start_network();
|
||||||
|
|
||||||
@@ -753,6 +742,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
|
|||||||
gas_price_percentile: cmd.gas_price_percentile,
|
gas_price_percentile: cmd.gas_price_percentile,
|
||||||
poll_lifetime: cmd.poll_lifetime,
|
poll_lifetime: cmd.poll_lifetime,
|
||||||
allow_missing_blocks: cmd.allow_missing_blocks,
|
allow_missing_blocks: cmd.allow_missing_blocks,
|
||||||
|
no_ancient_blocks: !cmd.download_old_blocks,
|
||||||
});
|
});
|
||||||
|
|
||||||
let dependencies = rpc::Dependencies {
|
let dependencies = rpc::Dependencies {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use light::on_demand::error::{Error as OnDemandError, ErrorKind as OnDemandError
|
|||||||
use ethcore::client::BlockChainClient;
|
use ethcore::client::BlockChainClient;
|
||||||
use types::blockchain_info::BlockChainInfo;
|
use types::blockchain_info::BlockChainInfo;
|
||||||
use v1::types::BlockNumber;
|
use v1::types::BlockNumber;
|
||||||
|
use v1::impls::EthClientOptions;
|
||||||
|
|
||||||
mod codes {
|
mod codes {
|
||||||
// NOTE [ToDr] Codes from [-32099, -32000]
|
// NOTE [ToDr] Codes from [-32099, -32000]
|
||||||
@@ -221,18 +222,34 @@ pub fn cannot_submit_work(err: EthcoreError) -> Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unavailable_block() -> Error {
|
pub fn unavailable_block(no_ancient_block: bool, by_hash: bool) -> Error {
|
||||||
Error {
|
if no_ancient_block {
|
||||||
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
Error {
|
||||||
message: "Ancient block sync is still in progress".into(),
|
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
||||||
data: None,
|
message: "Looks like you disabled ancient block download, unfortunately the information you're \
|
||||||
|
trying to fetch doesn't exist in the db and is probably in the ancient blocks.".into(),
|
||||||
|
data: None,
|
||||||
|
}
|
||||||
|
} else if by_hash {
|
||||||
|
Error {
|
||||||
|
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
||||||
|
message: "Block information is incomplete while ancient block sync is still in progress, before \
|
||||||
|
it's finished we can't determine the existence of requested item.".into(),
|
||||||
|
data: None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Error {
|
||||||
|
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
||||||
|
message: "Requested block number is in a range that is not available yet, because the ancient block sync is still in progress.".into(),
|
||||||
|
data: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_block_number_existence<'a, T, C>(
|
pub fn check_block_number_existence<'a, T, C>(
|
||||||
client: &'a C,
|
client: &'a C,
|
||||||
num: BlockNumber,
|
num: BlockNumber,
|
||||||
allow_missing_blocks: bool,
|
options: EthClientOptions,
|
||||||
) ->
|
) ->
|
||||||
impl Fn(Option<T>) -> RpcResult<Option<T>> + 'a
|
impl Fn(Option<T>) -> RpcResult<Option<T>> + 'a
|
||||||
where C: BlockChainClient,
|
where C: BlockChainClient,
|
||||||
@@ -242,8 +259,8 @@ pub fn check_block_number_existence<'a, T, C>(
|
|||||||
if let BlockNumber::Num(block_number) = num {
|
if let BlockNumber::Num(block_number) = num {
|
||||||
// tried to fetch block number and got nothing even though the block number is
|
// tried to fetch block number and got nothing even though the block number is
|
||||||
// less than the latest block number
|
// less than the latest block number
|
||||||
if block_number < client.chain_info().best_block_number && !allow_missing_blocks {
|
if block_number < client.chain_info().best_block_number && !options.allow_missing_blocks {
|
||||||
return Err(unavailable_block());
|
return Err(unavailable_block(options.no_ancient_blocks, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,22 +270,17 @@ pub fn check_block_number_existence<'a, T, C>(
|
|||||||
|
|
||||||
pub fn check_block_gap<'a, T, C>(
|
pub fn check_block_gap<'a, T, C>(
|
||||||
client: &'a C,
|
client: &'a C,
|
||||||
allow_missing_blocks: bool,
|
options: EthClientOptions,
|
||||||
) -> impl Fn(Option<T>) -> RpcResult<Option<T>> + 'a
|
) -> impl Fn(Option<T>) -> RpcResult<Option<T>> + 'a
|
||||||
where C: BlockChainClient,
|
where C: BlockChainClient,
|
||||||
{
|
{
|
||||||
move |response| {
|
move |response| {
|
||||||
if response.is_none() && !allow_missing_blocks {
|
if response.is_none() && !options.allow_missing_blocks {
|
||||||
let BlockChainInfo { ancient_block_hash, .. } = client.chain_info();
|
let BlockChainInfo { ancient_block_hash, .. } = client.chain_info();
|
||||||
// block information was requested, but unfortunately we couldn't find it and there
|
// block information was requested, but unfortunately we couldn't find it and there
|
||||||
// are gaps in the database ethcore/src/blockchain/blockchain.rs
|
// are gaps in the database ethcore/src/blockchain/blockchain.rs
|
||||||
if ancient_block_hash.is_some() {
|
if ancient_block_hash.is_some() {
|
||||||
return Err(Error {
|
return Err(unavailable_block(options.no_ancient_blocks, true))
|
||||||
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
|
||||||
message: "Block information is incomplete while ancient block sync is still in progress, before \
|
|
||||||
it's finished we can't determine the existence of requested item.".into(),
|
|
||||||
data: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(response)
|
Ok(response)
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
//! Helpers for fetching blockchain data either from the light client or the network.
|
//! Helpers for fetching blockchain data either from the light client or the network.
|
||||||
|
|
||||||
use std::cmp;
|
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
|
use std::cmp;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use types::basic_account::BasicAccount;
|
use types::basic_account::BasicAccount;
|
||||||
@@ -48,7 +49,6 @@ use ethereum_types::{Address, U256};
|
|||||||
use hash::H256;
|
use hash::H256;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use fastmap::H256FastMap;
|
use fastmap::H256FastMap;
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use types::transaction::{Action, Transaction as EthTransaction, PendingTransaction, SignedTransaction, LocalizedTransaction};
|
use types::transaction::{Action, Transaction as EthTransaction, PendingTransaction, SignedTransaction, LocalizedTransaction};
|
||||||
|
|
||||||
use v1::helpers::{CallRequest as CallRequestHelper, errors, dispatch};
|
use v1::helpers::{CallRequest as CallRequestHelper, errors, dispatch};
|
||||||
@@ -523,6 +523,46 @@ where
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper to cull the `light` transaction queue of mined transactions
|
||||||
|
pub fn light_cull(&self, txq: Arc<RwLock<TransactionQueue>>) -> impl Future <Item = (), Error = Error> + Send {
|
||||||
|
let senders = txq.read().queued_senders();
|
||||||
|
if senders.is_empty() {
|
||||||
|
return Either::B(future::err(errors::internal("No pending local transactions", "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
let sync = self.sync.clone();
|
||||||
|
let on_demand = self.on_demand.clone();
|
||||||
|
let best_header = self.client.best_block_header();
|
||||||
|
let start_nonce = self.client.engine().account_start_nonce(best_header.number());
|
||||||
|
|
||||||
|
let account_request = sync.with_context(move |ctx| {
|
||||||
|
// fetch the nonce of each sender in the queue.
|
||||||
|
let nonce_reqs = senders.iter()
|
||||||
|
.map(|&address| request::Account { header: best_header.clone().into(), address })
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// when they come in, update each sender to the new nonce.
|
||||||
|
on_demand.request(ctx, nonce_reqs)
|
||||||
|
.expect(NO_INVALID_BACK_REFS_PROOF)
|
||||||
|
.map(move |accs| {
|
||||||
|
let mut txq = txq.write();
|
||||||
|
accs.into_iter()
|
||||||
|
.map(|maybe_acc| maybe_acc.map_or(start_nonce, |acc| acc.nonce))
|
||||||
|
.zip(senders)
|
||||||
|
.for_each(|(nonce, addr)| {
|
||||||
|
txq.cull(addr, nonce);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.map_err(errors::on_demand_error)
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(fut) = account_request {
|
||||||
|
Either::A(fut)
|
||||||
|
} else {
|
||||||
|
Either::B(future::err(errors::network_disabled()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send_requests<T, F>(&self, reqs: Vec<OnDemandRequest>, parse_response: F) -> impl Future<Item = T, Error = Error> + Send where
|
fn send_requests<T, F>(&self, reqs: Vec<OnDemandRequest>, parse_response: F) -> impl Future<Item = T, Error = Error> + Send where
|
||||||
F: FnOnce(Vec<OnDemandResponse>) -> T + Send + 'static,
|
F: FnOnce(Vec<OnDemandResponse>) -> T + Send + 'static,
|
||||||
T: Send + 'static,
|
T: Send + 'static,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ use v1::metadata::Metadata;
|
|||||||
const EXTRA_INFO_PROOF: &str = "Object exists in blockchain (fetched earlier), extra_info is always available if object exists; qed";
|
const EXTRA_INFO_PROOF: &str = "Object exists in blockchain (fetched earlier), extra_info is always available if object exists; qed";
|
||||||
|
|
||||||
/// Eth RPC options
|
/// Eth RPC options
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct EthClientOptions {
|
pub struct EthClientOptions {
|
||||||
/// Return nonce from transaction queue when pending block not available.
|
/// Return nonce from transaction queue when pending block not available.
|
||||||
pub pending_nonce_from_queue: bool,
|
pub pending_nonce_from_queue: bool,
|
||||||
@@ -68,6 +69,8 @@ pub struct EthClientOptions {
|
|||||||
pub allow_missing_blocks: bool,
|
pub allow_missing_blocks: bool,
|
||||||
/// Enable Experimental RPC-Calls
|
/// Enable Experimental RPC-Calls
|
||||||
pub allow_experimental_rpcs: bool,
|
pub allow_experimental_rpcs: bool,
|
||||||
|
/// flag for ancient block sync
|
||||||
|
pub no_ancient_blocks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EthClientOptions {
|
impl EthClientOptions {
|
||||||
@@ -89,6 +92,7 @@ impl Default for EthClientOptions {
|
|||||||
gas_price_percentile: 50,
|
gas_price_percentile: 50,
|
||||||
allow_missing_blocks: false,
|
allow_missing_blocks: false,
|
||||||
allow_experimental_rpcs: false,
|
allow_experimental_rpcs: false,
|
||||||
|
no_ancient_blocks: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -669,7 +673,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
let trx_count = self.client.block(BlockId::Hash(hash))
|
let trx_count = self.client.block(BlockId::Hash(hash))
|
||||||
.map(|block| block.transactions_count().into());
|
.map(|block| block.transactions_count().into());
|
||||||
let result = Ok(trx_count)
|
let result = Ok(trx_count)
|
||||||
.and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
.and_then(errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,7 +688,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
.and_then(errors::check_block_number_existence(
|
.and_then(errors::check_block_number_existence(
|
||||||
&*self.client,
|
&*self.client,
|
||||||
num,
|
num,
|
||||||
self.options.allow_missing_blocks
|
self.options
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -694,7 +698,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
let uncle_count = self.client.block(BlockId::Hash(hash))
|
let uncle_count = self.client.block(BlockId::Hash(hash))
|
||||||
.map(|block| block.uncles_count().into());
|
.map(|block| block.uncles_count().into());
|
||||||
let result = Ok(uncle_count)
|
let result = Ok(uncle_count)
|
||||||
.and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
.and_then(errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +712,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
.and_then(errors::check_block_number_existence(
|
.and_then(errors::check_block_number_existence(
|
||||||
&*self.client,
|
&*self.client,
|
||||||
num,
|
num,
|
||||||
self.options.allow_missing_blocks
|
self.options
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -730,13 +734,13 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
|
|
||||||
fn block_by_hash(&self, hash: H256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
fn block_by_hash(&self, hash: H256, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||||
let result = self.rich_block(BlockId::Hash(hash).into(), include_txs)
|
let result = self.rich_block(BlockId::Hash(hash).into(), include_txs)
|
||||||
.and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
.and_then(errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>> {
|
||||||
let result = self.rich_block(num.clone().into(), include_txs).and_then(
|
let result = self.rich_block(num.clone().into(), include_txs).and_then(
|
||||||
errors::check_block_number_existence(&*self.client, num, self.options.allow_missing_blocks));
|
errors::check_block_number_existence(&*self.client, num, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,14 +750,14 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
.map(|t| Transaction::from_pending(t.pending().clone()))
|
.map(|t| Transaction::from_pending(t.pending().clone()))
|
||||||
});
|
});
|
||||||
let result = Ok(tx).and_then(
|
let result = Ok(tx).and_then(
|
||||||
errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_by_block_hash_and_index(&self, hash: H256, index: Index) -> BoxFuture<Option<Transaction>> {
|
fn transaction_by_block_hash_and_index(&self, hash: H256, index: Index) -> BoxFuture<Option<Transaction>> {
|
||||||
let id = PendingTransactionId::Location(PendingOrBlock::Block(BlockId::Hash(hash)), index.value());
|
let id = PendingTransactionId::Location(PendingOrBlock::Block(BlockId::Hash(hash)), index.value());
|
||||||
let result = self.transaction(id).and_then(
|
let result = self.transaction(id).and_then(
|
||||||
errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,7 +771,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
|
|
||||||
let transaction_id = PendingTransactionId::Location(block_id, index.value());
|
let transaction_id = PendingTransactionId::Location(block_id, index.value());
|
||||||
let result = self.transaction(transaction_id).and_then(
|
let result = self.transaction(transaction_id).and_then(
|
||||||
errors::check_block_number_existence(&*self.client, num, self.options.allow_missing_blocks));
|
errors::check_block_number_existence(&*self.client, num, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,7 +785,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
|
|
||||||
let receipt = self.client.transaction_receipt(TransactionId::Hash(hash));
|
let receipt = self.client.transaction_receipt(TransactionId::Hash(hash));
|
||||||
let result = Ok(receipt.map(Into::into))
|
let result = Ok(receipt.map(Into::into))
|
||||||
.and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
.and_then(errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,7 +793,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
let result = self.uncle(PendingUncleId {
|
let result = self.uncle(PendingUncleId {
|
||||||
id: PendingOrBlock::Block(BlockId::Hash(hash)),
|
id: PendingOrBlock::Block(BlockId::Hash(hash)),
|
||||||
position: index.value()
|
position: index.value()
|
||||||
}).and_then(errors::check_block_gap(&*self.client, self.options.allow_missing_blocks));
|
}).and_then(errors::check_block_gap(&*self.client, self.options));
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,7 +810,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
|
|||||||
.and_then(errors::check_block_number_existence(
|
.and_then(errors::check_block_number_existence(
|
||||||
&*self.client,
|
&*self.client,
|
||||||
num,
|
num,
|
||||||
self.options.allow_missing_blocks
|
self.options
|
||||||
));
|
));
|
||||||
|
|
||||||
Box::new(future::done(result))
|
Box::new(future::done(result))
|
||||||
|
|||||||
@@ -420,15 +420,22 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_by_hash(&self, hash: H256) -> BoxFuture<Option<Transaction>> {
|
fn transaction_by_hash(&self, hash: H256) -> BoxFuture<Option<Transaction>> {
|
||||||
{
|
let in_txqueue = self.transaction_queue.read().get(&hash).is_some();
|
||||||
let tx_queue = self.transaction_queue.read();
|
|
||||||
if let Some(tx) = tx_queue.get(&hash) {
|
// The transaction is in the `local txqueue` then fetch the latest state from the network and attempt
|
||||||
|
// to cull the transaction queue.
|
||||||
|
if in_txqueue {
|
||||||
|
// Note, this will block (relies on HTTP timeout) to make sure `cull` will finish to avoid having to call
|
||||||
|
// `eth_getTransactionByHash` more than once to ensure the `txqueue` is up to `date` when it is called
|
||||||
|
if let Err(e) = self.fetcher().light_cull(self.transaction_queue.clone()).wait() {
|
||||||
|
debug!(target: "cull", "failed because of: {:?}", e);
|
||||||
|
}
|
||||||
|
if let Some(tx) = self.transaction_queue.read().get(&hash) {
|
||||||
return Box::new(future::ok(Some(Transaction::from_pending(
|
return Box::new(future::ok(Some(Transaction::from_pending(
|
||||||
tx.clone(),
|
tx.clone(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box::new(self.fetcher().transaction_by_hash(hash).map(|x| x.map(|(tx, _)| tx)))
|
Box::new(self.fetcher().transaction_by_hash(hash).map(|x| x.map(|(tx, _)| tx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ impl EthTester {
|
|||||||
send_block_number_in_get_work: true,
|
send_block_number_in_get_work: true,
|
||||||
gas_price_percentile: 50,
|
gas_price_percentile: 50,
|
||||||
allow_experimental_rpcs: true,
|
allow_experimental_rpcs: true,
|
||||||
allow_missing_blocks: false
|
allow_missing_blocks: false,
|
||||||
|
no_ancient_blocks: false
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ cat .cargo/config
|
|||||||
echo "_____ Building target: "$CARGO_TARGET" _____"
|
echo "_____ Building target: "$CARGO_TARGET" _____"
|
||||||
if [ "${CARGO_TARGET}" = "armv7-linux-androideabi" ]
|
if [ "${CARGO_TARGET}" = "armv7-linux-androideabi" ]
|
||||||
then
|
then
|
||||||
time cargo build --target $CARGO_TARGET --release -p parity-clib --features final
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release -p parity-clib --features final
|
||||||
else
|
else
|
||||||
time cargo build --target $CARGO_TARGET --release --features final
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release --features final
|
||||||
time cargo build --target $CARGO_TARGET --release -p evmbin
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release -p evmbin
|
||||||
time cargo build --target $CARGO_TARGET --release -p ethstore-cli
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release -p ethstore-cli
|
||||||
time cargo build --target $CARGO_TARGET --release -p ethkey-cli
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release -p ethkey-cli
|
||||||
time cargo build --target $CARGO_TARGET --release -p whisper-cli
|
time cargo build --target $CARGO_TARGET --verbose --color=always --release -p whisper-cli
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "_____ Post-processing binaries _____"
|
echo "_____ Post-processing binaries _____"
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ echo "RUSTC_WRAPPER: " $RUSTC_WRAPPER
|
|||||||
echo "SCCACHE_DIR: " $SCCACHE_DIR
|
echo "SCCACHE_DIR: " $SCCACHE_DIR
|
||||||
|
|
||||||
echo "_____ Building target: "$CARGO_TARGET" _____"
|
echo "_____ Building target: "$CARGO_TARGET" _____"
|
||||||
time cargo build --target $CARGO_TARGET --release --features final
|
time cargo build --target $CARGO_TARGET --verbose --release --features final
|
||||||
time cargo build --target $CARGO_TARGET --release -p evmbin
|
time cargo build --target $CARGO_TARGET --verbose --release -p evmbin
|
||||||
time cargo build --target $CARGO_TARGET --release -p ethstore-cli
|
time cargo build --target $CARGO_TARGET --verbose --release -p ethstore-cli
|
||||||
time cargo build --target $CARGO_TARGET --release -p ethkey-cli
|
time cargo build --target $CARGO_TARGET --verbose --release -p ethkey-cli
|
||||||
time cargo build --target $CARGO_TARGET --release -p whisper-cli
|
time cargo build --target $CARGO_TARGET --verbose --release -p whisper-cli
|
||||||
|
|
||||||
echo "__________Sign binaries__________"
|
echo "__________Sign binaries__________"
|
||||||
scripts/gitlab/sign-win.cmd $keyfile $certpass target/$CARGO_TARGET/release/parity.exe
|
scripts/gitlab/sign-win.cmd $keyfile $certpass target/$CARGO_TARGET/release/parity.exe
|
||||||
|
|||||||
@@ -51,8 +51,11 @@ commit_files() {
|
|||||||
|
|
||||||
upload_files() {
|
upload_files() {
|
||||||
echo "__________Upload files__________"
|
echo "__________Upload files__________"
|
||||||
git push -q origin HEAD
|
# this version of git (2.7.4) will dump the token on failure
|
||||||
git push -q -f --tags
|
git push -q origin HEAD 2>&1 \
|
||||||
|
| sed -r "s|(${GITHUB_USER}):[a-f0-9]+@|\1:REDACTED@|g"
|
||||||
|
git push -q -f --tags 2>&1 \
|
||||||
|
| sed -r "s|(${GITHUB_USER}):[a-f0-9]+@|\1:REDACTED@|g"
|
||||||
}
|
}
|
||||||
|
|
||||||
RPC_TRAITS_DIR="rpc/src/v1/traits"
|
RPC_TRAITS_DIR="rpc/src/v1/traits"
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# ARGUMENT $1 Rust flavor to run test with (stable/beta/nightly)
|
||||||
|
|
||||||
echo "________Running test-linux.sh________"
|
echo "________Running test-linux.sh________"
|
||||||
set -e # fail on any error
|
set -e # fail on any error
|
||||||
set -u # treat unset variables as error
|
set -u # treat unset variables as error
|
||||||
@@ -8,5 +10,8 @@ OPTIONS="--release"
|
|||||||
#use nproc `linux only
|
#use nproc `linux only
|
||||||
THREADS=$(nproc)
|
THREADS=$(nproc)
|
||||||
|
|
||||||
|
rustup default $1
|
||||||
|
rustup show
|
||||||
|
|
||||||
echo "________Running Parity Full Test Suite________"
|
echo "________Running Parity Full Test Suite________"
|
||||||
time cargo test $OPTIONS --features "$FEATURES" --locked --all --target $CARGO_TARGET -- --test-threads $THREADS
|
time cargo test $OPTIONS --features "$FEATURES" --locked --all --target $CARGO_TARGET --verbose --color=always -- --test-threads $THREADS
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ echo "________Running validate_chainspecs.sh________"
|
|||||||
ERR=0
|
ERR=0
|
||||||
|
|
||||||
echo "________Validate chainspecs________"
|
echo "________Validate chainspecs________"
|
||||||
time cargo build --release -p chainspec
|
time cargo build --release -p chainspec --verbose --color=always
|
||||||
|
|
||||||
for spec in ethcore/res/*.json; do
|
for spec in ethcore/res/*.json; do
|
||||||
if ! ./target/release/chainspec "$spec"; then ERR=1; fi
|
if ! ./target/release/chainspec "$spec"; then ERR=1; fi
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "parity-version"
|
name = "parity-version"
|
||||||
# NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION)
|
# NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION)
|
||||||
version = "2.5.0"
|
version = "2.5.1"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
# This versions track. Should be changed to `stable` or `beta` when on respective branches.
|
# This versions track. Should be changed to `stable` or `beta` when on respective branches.
|
||||||
# Used by auto-updater and for Parity version string.
|
# Used by auto-updater and for Parity version string.
|
||||||
track = "nightly"
|
track = "beta"
|
||||||
|
|
||||||
# Network specific settings, used ONLY by auto-updater.
|
# Network specific settings, used ONLY by auto-updater.
|
||||||
# Latest supported fork blocks.
|
# Latest supported fork blocks.
|
||||||
|
|||||||
@@ -264,17 +264,17 @@ impl Message {
|
|||||||
|
|
||||||
let mut rng = {
|
let mut rng = {
|
||||||
let mut thread_rng = ::rand::thread_rng();
|
let mut thread_rng = ::rand::thread_rng();
|
||||||
|
|
||||||
XorShiftRng::from_seed(thread_rng.gen::<[u32; 4]>())
|
XorShiftRng::from_seed(thread_rng.gen::<[u32; 4]>())
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(params.ttl > 0);
|
assert!(params.ttl > 0);
|
||||||
|
|
||||||
let expiry = {
|
let expiry = {
|
||||||
let after_mining = SystemTime::now().checked_sub(Duration::from_millis(params.work))
|
let since_epoch = SystemTime::now()
|
||||||
.ok_or(Error::TimestampOverflow)?;
|
.checked_add(Duration::from_secs(params.ttl))
|
||||||
let since_epoch = after_mining.duration_since(time::UNIX_EPOCH)
|
.and_then(|t| t.checked_add(Duration::from_millis(params.work)))
|
||||||
.expect("time after now is after unix epoch; qed");
|
.ok_or(Error::TimestampOverflow)?
|
||||||
|
.duration_since(time::UNIX_EPOCH).expect("time after now is after unix epoch; qed");
|
||||||
|
|
||||||
// round up the sub-second to next whole second.
|
// round up the sub-second to next whole second.
|
||||||
since_epoch.as_secs() + if since_epoch.subsec_nanos() == 0 { 0 } else { 1 }
|
since_epoch.as_secs() + if since_epoch.subsec_nanos() == 0 { 0 } else { 1 }
|
||||||
|
|||||||
Reference in New Issue
Block a user