diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d152114c..366b89d20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,10 +31,12 @@ linux-stable: - md5sum "parity_"$VER"_amd64.deb" > "parity_"$VER"_amd64.deb.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5 - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/"parity_"$VER"_amd64.deb" --body "parity_"$VER"_amd64.deb" - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/"parity_"$VER"_amd64.deb.md5" --body "parity_"$VER"_amd64.deb.md5" + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/"parity_"$VER"_amd64.deb" --body "parity_"$VER"_amd64.deb" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/"parity_"$VER"_amd64.deb.md5" --body "parity_"$VER"_amd64.deb.md5" tags: - rust - rust-stable @@ -96,6 +98,8 @@ linux-centos: - md5sum target/release/parity > parity.md5 - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity --body target/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity.md5 --body parity.md5 tags: @@ -126,10 +130,12 @@ linux-i686: - md5sum "parity_"$VER"_i386.deb" > "parity_"$VER"_i386.deb.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity --body target/i686-unknown-linux-gnu/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity.md5 --body parity.md5 - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/"parity_"$VER"_i386.deb" --body "parity_"$VER"_i386.deb" - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/"parity_"$VER"_i386.deb.md5" --body "parity_"$VER"_i386.deb.md5" + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/i686-unknown-linux-gnu + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity --body target/i686-unknown-linux-gnu/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/"parity_"$VER"_i386.deb" --body "parity_"$VER"_i386.deb" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/"parity_"$VER"_i386.deb.md5" --body "parity_"$VER"_i386.deb.md5" tags: - rust - rust-i686 @@ -166,10 +172,12 @@ linux-armv7: - md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5 - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb" --body "parity_"$VER"_armhf.deb" - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb.md5" --body "parity_"$VER"_armhf.deb.md5" + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb" --body "parity_"$VER"_armhf.deb" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb.md5" --body "parity_"$VER"_armhf.deb.md5" tags: - rust - rust-arm @@ -206,10 +214,12 @@ linux-arm: - md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5 - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb" --body "parity_"$VER"_armhf.deb" - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb.md5" --body "parity_"$VER"_armhf.deb.md5" + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb" --body "parity_"$VER"_armhf.deb" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/"parity_"$VER"_armhf.deb.md5" --body "parity_"$VER"_armhf.deb.md5" tags: - rust - rust-arm @@ -241,8 +251,10 @@ linux-armv6: - md5sum target/arm-unknown-linux-gnueabi/release/parity > parity.md5 - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5 + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5 tags: - rust - rust-arm @@ -279,10 +291,12 @@ linux-aarch64: - md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5 - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb" --body "parity_"$VER"_arm64.deb" - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb.md5" --body "parity_"$VER"_arm64.deb.md5" + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb" --body "parity_"$VER"_arm64.deb" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb.md5" --body "parity_"$VER"_arm64.deb.md5" tags: - rust - rust-arm @@ -291,6 +305,41 @@ linux-aarch64: - target/aarch64-unknown-linux-gnu/release/parity name: "aarch64-unknown-linux-gnu_parity" allow_failure: true +#linux-alpine: +# stage: build +# image: ethcore/rust-alpine:latest +# only: +# - beta +# - tags +# - stable +# - triggers +# script: +# - export HOST_CC=gcc +# - export HOST_CXX=g++ +# - cargo build --release $CARGOFLAGS +# - strip target/release/parity +# - md5sum target/release/parity > parity.md5 +# - sh scripts/deb-build.sh arm64 +# - cp target/aarch64-unknown-linux-gnu/release/parity deb/usr/bin/parity +# - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") +# - dpkg-deb -b deb "parity_"$VER"_arm64.deb" +# - md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5" +# - aws configure set aws_access_key_id $s3_key +# - aws configure set aws_secret_access_key $s3_secret +# - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi +# - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu +# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity +# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5 +# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb" --body "parity_"$VER"_arm64.deb" +# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb.md5" --body "parity_"$VER"_arm64.deb.md5" +# tags: +# - rust +# - rust-alpine +# artifacts: +# paths: +# - target/aarch64-unknown-linux-gnu/release/parity +# name: "aarch64-unknown-linux-gnu_parity" +# allow_failure: true darwin: stage: build only: @@ -299,13 +348,22 @@ darwin: - stable - triggers script: + - cargo build --release -p ethstore $CARGOFLAGS - cargo build --release $CARGOFLAGS - rm -rf parity.md5 - md5sum target/release/parity > parity.md5 + - packagesbuild -v mac/Parity.pkgproj + - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") + - mv target/release/Parity\ Ethereum.pkg "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" + - md5sum "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" >> "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity - - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5 + - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi + - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-apple-darwin + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5 + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" + - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" tags: - osx artifacts: @@ -349,14 +407,20 @@ windows: - cd ..\.. - aws configure set aws_access_key_id %s3_key% - aws configure set aws_secret_access_key %s3_secret% - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe --body target\release\parity.exe - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe.md5 --body target\release\parity.exe.md5 - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip --body target\release\parity.zip - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip.md5 --body target\release\parity.zip.md5 - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/InstallParity.exe --body nsis\InstallParity.exe - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/InstallParity.exe.md5 --body nsis\InstallParity.exe.md5 - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/win-installer.zip --body nsis\win-installer.zip - - aws s3api put-object --bucket builds-parity --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/win-installer.zip.md5 --body nsis\win-installer.zip.md5 + - echo %CI_BUILD_REF_NAME% + - echo %CI_BUILD_REF_NAME% | findstr /R "master" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity + - echo %CI_BUILD_REF_NAME% | findstr /R "beta" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity + - echo %CI_BUILD_REF_NAME% | findstr /R "stable" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity + - echo %S3_BUCKET% + - aws s3 rm --recursive s3://%S3_BUCKET%/%CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe --body target\release\parity.exe + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe.md5 --body target\release\parity.exe.md5 + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip --body target\release\parity.zip + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip.md5 --body target\release\parity.zip.md5 + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/InstallParity.exe --body nsis\InstallParity.exe + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/InstallParity.exe.md5 --body nsis\InstallParity.exe.md5 + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/win-installer.zip --body nsis\win-installer.zip + - aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/win-installer.zip.md5 --body nsis\win-installer.zip.md5 tags: - rust-windows artifacts: @@ -394,13 +458,13 @@ test-rust-stable: image: ethcore/rust:stable before_script: - git submodule update --init --recursive - - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only CI_BUILD_REF CI_BUILD_REF@{1} | grep \.js | wc -l) + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi script: - export RUST_BACKTRACE=1 - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi tags: - rust - rust-stable @@ -411,13 +475,13 @@ test-rust-beta: image: ethcore/rust:beta before_script: - git submodule update --init --recursive - - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only CI_BUILD_REF CI_BUILD_REF@{1} | grep \.js | wc -l) + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi script: - export RUST_BACKTRACE=1 - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi tags: - rust - rust-beta @@ -429,28 +493,17 @@ test-rust-nightly: image: ethcore/rust:nightly before_script: - git submodule update --init --recursive - - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only CI_BUILD_REF CI_BUILD_REF@{1} | grep \.js | wc -l) + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi script: - export RUST_BACKTRACE=1 - echo $JS_FILES_MODIFIED - - if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi tags: - rust - rust-nightly allow_failure: true -js-tests: - stage: test - image: ethcore/rust:stable - before_script: - - ./js/scripts/install-deps.sh - script: - - ./js/scripts/lint.sh - - ./js/scripts/test.sh - - ./js/scripts/build.sh - tags: - - javascript-test js-release: stage: js-build only: @@ -459,9 +512,11 @@ js-release: - stable image: ethcore/rust:stable before_script: - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/install-deps.sh; fi + - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l) + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/install-deps.sh;fi script: - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/build.sh; fi - - if [[ $NIGHTLY != "master" ]]; then ./js/scripts/release.sh; fi + - echo $JS_FILES_MODIFIED + - if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/build.sh&./js/scripts/release.sh; fi tags: - javascript diff --git a/Cargo.lock b/Cargo.lock index 02e45b49e..809e5a07a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -385,7 +385,7 @@ version = "1.5.0" dependencies = [ "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.1 (git+https://github.com/carllerche/mio)", + "mio 0.6.1 (git+https://github.com/ethcore/mio)", "parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -475,7 +475,7 @@ dependencies = [ "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.1 (git+https://github.com/carllerche/mio)", + "mio 0.6.1 (git+https://github.com/ethcore/mio)", "parking_lot 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)", "rlp 0.1.0", @@ -1026,7 +1026,7 @@ dependencies = [ [[package]] name = "mio" version = "0.6.1" -source = "git+https://github.com/carllerche/mio#56f8663510196fdca04bdf7c5f4d60b24297826f" +source = "git+https://github.com/ethcore/mio#ef182bae193a9c7457cd2cf661fcaffb226e3eef" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1263,7 +1263,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.4.0" -source = "git+https://github.com/ethcore/js-precompiled.git#587684374a12bf715151dd987a552a3d61e42972" +source = "git+https://github.com/ethcore/js-precompiled.git#f1de5e5612d8237143b37aebf237a49475c2c4e6" dependencies = [ "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2053,7 +2053,7 @@ dependencies = [ "checksum mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)" = "" "checksum mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a637d1ca14eacae06296a008fa7ad955347e34efcb5891cfd8ba05491a37907e" "checksum mio 0.6.0-dev (git+https://github.com/ethcore/mio?branch=timer-fix)" = "" -"checksum mio 0.6.1 (git+https://github.com/carllerche/mio)" = "" +"checksum mio 0.6.1 (git+https://github.com/ethcore/mio)" = "" "checksum miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5bfc6782530ac8ace97af10a540054a37126b63b0702ddaaa243b73b5745b9a" "checksum msdos_time 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c04b68cc63a8480fb2550343695f7be72effdec953a9d4508161c3e69041c7d8" "checksum nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)" = "" diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index ad23b461f..9ab782395 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -21,8 +21,8 @@ "genesis": { "seal": { "generic": { - "fields": 1, - "rlp": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa" + "fields": 2, + "rlp": "0x200" } }, "difficulty": "0x20000", diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index c92676161..62282801d 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -8,7 +8,7 @@ "difficultyBoundDivisor": "0x0800", "durationLimit": "0x0d", "blockReward": "0x4563918244F40000", - "registrar": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d", + "registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2", "homesteadTransition": 0, "eip150Transition": 0, "eip155Transition": 10, @@ -47,258 +47,258 @@ "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "0", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "0", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "0", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "0000000000000000000000000000000000000000": { "balance": "1" }, - "0000000000000000000000000000000000000005": { "balance": "1" }, - "0000000000000000000000000000000000000006": { "balance": "1" }, - "0000000000000000000000000000000000000007": { "balance": "1" }, - "0000000000000000000000000000000000000008": { "balance": "1" }, - "0000000000000000000000000000000000000009": { "balance": "1" }, - "000000000000000000000000000000000000000a": { "balance": "0" }, - "000000000000000000000000000000000000000b": { "balance": "0" }, - "000000000000000000000000000000000000000c": { "balance": "0" }, - "000000000000000000000000000000000000000d": { "balance": "0" }, - "000000000000000000000000000000000000000e": { "balance": "0" }, - "000000000000000000000000000000000000000f": { "balance": "0" }, - "0000000000000000000000000000000000000010": { "balance": "0" }, - "0000000000000000000000000000000000000011": { "balance": "0" }, - "0000000000000000000000000000000000000012": { "balance": "0" }, - "0000000000000000000000000000000000000013": { "balance": "0" }, - "0000000000000000000000000000000000000014": { "balance": "0" }, - "0000000000000000000000000000000000000015": { "balance": "0" }, - "0000000000000000000000000000000000000016": { "balance": "0" }, - "0000000000000000000000000000000000000017": { "balance": "0" }, - "0000000000000000000000000000000000000018": { "balance": "0" }, - "0000000000000000000000000000000000000019": { "balance": "0" }, - "000000000000000000000000000000000000001a": { "balance": "0" }, - "000000000000000000000000000000000000001b": { "balance": "0" }, - "000000000000000000000000000000000000001c": { "balance": "0" }, - "000000000000000000000000000000000000001d": { "balance": "0" }, - "000000000000000000000000000000000000001e": { "balance": "0" }, - "000000000000000000000000000000000000001f": { "balance": "0" }, - "0000000000000000000000000000000000000020": { "balance": "0" }, - "0000000000000000000000000000000000000021": { "balance": "0" }, - "0000000000000000000000000000000000000022": { "balance": "0" }, - "0000000000000000000000000000000000000023": { "balance": "0" }, - "0000000000000000000000000000000000000024": { "balance": "0" }, - "0000000000000000000000000000000000000025": { "balance": "0" }, - "0000000000000000000000000000000000000026": { "balance": "0" }, - "0000000000000000000000000000000000000027": { "balance": "0" }, - "0000000000000000000000000000000000000028": { "balance": "0" }, - "0000000000000000000000000000000000000029": { "balance": "0" }, - "000000000000000000000000000000000000002a": { "balance": "0" }, - "000000000000000000000000000000000000002b": { "balance": "0" }, - "000000000000000000000000000000000000002c": { "balance": "0" }, - "000000000000000000000000000000000000002d": { "balance": "0" }, - "000000000000000000000000000000000000002e": { "balance": "0" }, - "000000000000000000000000000000000000002f": { "balance": "0" }, - "0000000000000000000000000000000000000030": { "balance": "0" }, - "0000000000000000000000000000000000000031": { "balance": "0" }, - "0000000000000000000000000000000000000032": { "balance": "0" }, - "0000000000000000000000000000000000000033": { "balance": "0" }, - "0000000000000000000000000000000000000034": { "balance": "0" }, - "0000000000000000000000000000000000000035": { "balance": "0" }, - "0000000000000000000000000000000000000036": { "balance": "0" }, - "0000000000000000000000000000000000000037": { "balance": "0" }, - "0000000000000000000000000000000000000038": { "balance": "0" }, - "0000000000000000000000000000000000000039": { "balance": "0" }, - "000000000000000000000000000000000000003a": { "balance": "0" }, - "000000000000000000000000000000000000003b": { "balance": "0" }, - "000000000000000000000000000000000000003c": { "balance": "0" }, - "000000000000000000000000000000000000003d": { "balance": "0" }, - "000000000000000000000000000000000000003e": { "balance": "0" }, - "000000000000000000000000000000000000003f": { "balance": "0" }, - "0000000000000000000000000000000000000040": { "balance": "0" }, - "0000000000000000000000000000000000000041": { "balance": "0" }, - "0000000000000000000000000000000000000042": { "balance": "0" }, - "0000000000000000000000000000000000000043": { "balance": "0" }, - "0000000000000000000000000000000000000044": { "balance": "0" }, - "0000000000000000000000000000000000000045": { "balance": "0" }, - "0000000000000000000000000000000000000046": { "balance": "0" }, - "0000000000000000000000000000000000000047": { "balance": "0" }, - "0000000000000000000000000000000000000048": { "balance": "0" }, - "0000000000000000000000000000000000000049": { "balance": "0" }, - "000000000000000000000000000000000000004a": { "balance": "0" }, - "000000000000000000000000000000000000004b": { "balance": "0" }, - "000000000000000000000000000000000000004c": { "balance": "0" }, - "000000000000000000000000000000000000004d": { "balance": "0" }, - "000000000000000000000000000000000000004e": { "balance": "0" }, - "000000000000000000000000000000000000004f": { "balance": "0" }, - "0000000000000000000000000000000000000050": { "balance": "0" }, - "0000000000000000000000000000000000000051": { "balance": "0" }, - "0000000000000000000000000000000000000052": { "balance": "0" }, - "0000000000000000000000000000000000000053": { "balance": "0" }, - "0000000000000000000000000000000000000054": { "balance": "0" }, - "0000000000000000000000000000000000000055": { "balance": "0" }, - "0000000000000000000000000000000000000056": { "balance": "0" }, - "0000000000000000000000000000000000000057": { "balance": "0" }, - "0000000000000000000000000000000000000058": { "balance": "0" }, - "0000000000000000000000000000000000000059": { "balance": "0" }, - "000000000000000000000000000000000000005a": { "balance": "0" }, - "000000000000000000000000000000000000005b": { "balance": "0" }, - "000000000000000000000000000000000000005c": { "balance": "0" }, - "000000000000000000000000000000000000005d": { "balance": "0" }, - "000000000000000000000000000000000000005e": { "balance": "0" }, - "000000000000000000000000000000000000005f": { "balance": "0" }, - "0000000000000000000000000000000000000060": { "balance": "0" }, - "0000000000000000000000000000000000000061": { "balance": "0" }, - "0000000000000000000000000000000000000062": { "balance": "0" }, - "0000000000000000000000000000000000000063": { "balance": "0" }, - "0000000000000000000000000000000000000064": { "balance": "0" }, - "0000000000000000000000000000000000000065": { "balance": "0" }, - "0000000000000000000000000000000000000066": { "balance": "0" }, - "0000000000000000000000000000000000000067": { "balance": "0" }, - "0000000000000000000000000000000000000068": { "balance": "0" }, - "0000000000000000000000000000000000000069": { "balance": "0" }, - "000000000000000000000000000000000000006a": { "balance": "0" }, - "000000000000000000000000000000000000006b": { "balance": "0" }, - "000000000000000000000000000000000000006c": { "balance": "0" }, - "000000000000000000000000000000000000006d": { "balance": "0" }, - "000000000000000000000000000000000000006e": { "balance": "0" }, - "000000000000000000000000000000000000006f": { "balance": "0" }, - "0000000000000000000000000000000000000070": { "balance": "0" }, - "0000000000000000000000000000000000000071": { "balance": "0" }, - "0000000000000000000000000000000000000072": { "balance": "0" }, - "0000000000000000000000000000000000000073": { "balance": "0" }, - "0000000000000000000000000000000000000074": { "balance": "0" }, - "0000000000000000000000000000000000000075": { "balance": "0" }, - "0000000000000000000000000000000000000076": { "balance": "0" }, - "0000000000000000000000000000000000000077": { "balance": "0" }, - "0000000000000000000000000000000000000078": { "balance": "0" }, - "0000000000000000000000000000000000000079": { "balance": "0" }, - "000000000000000000000000000000000000007a": { "balance": "0" }, - "000000000000000000000000000000000000007b": { "balance": "0" }, - "000000000000000000000000000000000000007c": { "balance": "0" }, - "000000000000000000000000000000000000007d": { "balance": "0" }, - "000000000000000000000000000000000000007e": { "balance": "0" }, - "000000000000000000000000000000000000007f": { "balance": "0" }, - "0000000000000000000000000000000000000080": { "balance": "0" }, - "0000000000000000000000000000000000000081": { "balance": "0" }, - "0000000000000000000000000000000000000082": { "balance": "0" }, - "0000000000000000000000000000000000000083": { "balance": "0" }, - "0000000000000000000000000000000000000084": { "balance": "0" }, - "0000000000000000000000000000000000000085": { "balance": "0" }, - "0000000000000000000000000000000000000086": { "balance": "0" }, - "0000000000000000000000000000000000000087": { "balance": "0" }, - "0000000000000000000000000000000000000088": { "balance": "0" }, - "0000000000000000000000000000000000000089": { "balance": "0" }, - "000000000000000000000000000000000000008a": { "balance": "0" }, - "000000000000000000000000000000000000008b": { "balance": "0" }, - "000000000000000000000000000000000000008c": { "balance": "0" }, - "000000000000000000000000000000000000008d": { "balance": "0" }, - "000000000000000000000000000000000000008e": { "balance": "0" }, - "000000000000000000000000000000000000008f": { "balance": "0" }, - "0000000000000000000000000000000000000090": { "balance": "0" }, - "0000000000000000000000000000000000000091": { "balance": "0" }, - "0000000000000000000000000000000000000092": { "balance": "0" }, - "0000000000000000000000000000000000000093": { "balance": "0" }, - "0000000000000000000000000000000000000094": { "balance": "0" }, - "0000000000000000000000000000000000000095": { "balance": "0" }, - "0000000000000000000000000000000000000096": { "balance": "0" }, - "0000000000000000000000000000000000000097": { "balance": "0" }, - "0000000000000000000000000000000000000098": { "balance": "0" }, - "0000000000000000000000000000000000000099": { "balance": "0" }, - "000000000000000000000000000000000000009a": { "balance": "0" }, - "000000000000000000000000000000000000009b": { "balance": "0" }, - "000000000000000000000000000000000000009c": { "balance": "0" }, - "000000000000000000000000000000000000009d": { "balance": "0" }, - "000000000000000000000000000000000000009e": { "balance": "0" }, - "000000000000000000000000000000000000009f": { "balance": "0" }, - "00000000000000000000000000000000000000a0": { "balance": "0" }, - "00000000000000000000000000000000000000a1": { "balance": "0" }, - "00000000000000000000000000000000000000a2": { "balance": "0" }, - "00000000000000000000000000000000000000a3": { "balance": "0" }, - "00000000000000000000000000000000000000a4": { "balance": "0" }, - "00000000000000000000000000000000000000a5": { "balance": "0" }, - "00000000000000000000000000000000000000a6": { "balance": "0" }, - "00000000000000000000000000000000000000a7": { "balance": "0" }, - "00000000000000000000000000000000000000a8": { "balance": "0" }, - "00000000000000000000000000000000000000a9": { "balance": "0" }, - "00000000000000000000000000000000000000aa": { "balance": "0" }, - "00000000000000000000000000000000000000ab": { "balance": "0" }, - "00000000000000000000000000000000000000ac": { "balance": "0" }, - "00000000000000000000000000000000000000ad": { "balance": "0" }, - "00000000000000000000000000000000000000ae": { "balance": "0" }, - "00000000000000000000000000000000000000af": { "balance": "0" }, - "00000000000000000000000000000000000000b0": { "balance": "0" }, - "00000000000000000000000000000000000000b1": { "balance": "0" }, - "00000000000000000000000000000000000000b2": { "balance": "0" }, - "00000000000000000000000000000000000000b3": { "balance": "0" }, - "00000000000000000000000000000000000000b4": { "balance": "0" }, - "00000000000000000000000000000000000000b5": { "balance": "0" }, - "00000000000000000000000000000000000000b6": { "balance": "0" }, - "00000000000000000000000000000000000000b7": { "balance": "0" }, - "00000000000000000000000000000000000000b8": { "balance": "0" }, - "00000000000000000000000000000000000000b9": { "balance": "0" }, - "00000000000000000000000000000000000000ba": { "balance": "0" }, - "00000000000000000000000000000000000000bb": { "balance": "0" }, - "00000000000000000000000000000000000000bc": { "balance": "0" }, - "00000000000000000000000000000000000000bd": { "balance": "0" }, - "00000000000000000000000000000000000000be": { "balance": "0" }, - "00000000000000000000000000000000000000bf": { "balance": "0" }, - "00000000000000000000000000000000000000c0": { "balance": "0" }, - "00000000000000000000000000000000000000c1": { "balance": "0" }, - "00000000000000000000000000000000000000c2": { "balance": "0" }, - "00000000000000000000000000000000000000c3": { "balance": "0" }, - "00000000000000000000000000000000000000c4": { "balance": "0" }, - "00000000000000000000000000000000000000c5": { "balance": "0" }, - "00000000000000000000000000000000000000c6": { "balance": "0" }, - "00000000000000000000000000000000000000c7": { "balance": "0" }, - "00000000000000000000000000000000000000c8": { "balance": "0" }, - "00000000000000000000000000000000000000c9": { "balance": "0" }, - "00000000000000000000000000000000000000ca": { "balance": "0" }, - "00000000000000000000000000000000000000cb": { "balance": "0" }, - "00000000000000000000000000000000000000cc": { "balance": "0" }, - "00000000000000000000000000000000000000cd": { "balance": "0" }, - "00000000000000000000000000000000000000ce": { "balance": "0" }, - "00000000000000000000000000000000000000cf": { "balance": "0" }, - "00000000000000000000000000000000000000d0": { "balance": "0" }, - "00000000000000000000000000000000000000d1": { "balance": "0" }, - "00000000000000000000000000000000000000d2": { "balance": "0" }, - "00000000000000000000000000000000000000d3": { "balance": "0" }, - "00000000000000000000000000000000000000d4": { "balance": "0" }, - "00000000000000000000000000000000000000d5": { "balance": "0" }, - "00000000000000000000000000000000000000d6": { "balance": "0" }, - "00000000000000000000000000000000000000d7": { "balance": "0" }, - "00000000000000000000000000000000000000d8": { "balance": "0" }, - "00000000000000000000000000000000000000d9": { "balance": "0" }, + "0000000000000000000000000000000000000000": { "balance": "1" }, + "0000000000000000000000000000000000000005": { "balance": "1" }, + "0000000000000000000000000000000000000006": { "balance": "1" }, + "0000000000000000000000000000000000000007": { "balance": "1" }, + "0000000000000000000000000000000000000008": { "balance": "1" }, + "0000000000000000000000000000000000000009": { "balance": "1" }, + "000000000000000000000000000000000000000a": { "balance": "0" }, + "000000000000000000000000000000000000000b": { "balance": "0" }, + "000000000000000000000000000000000000000c": { "balance": "0" }, + "000000000000000000000000000000000000000d": { "balance": "0" }, + "000000000000000000000000000000000000000e": { "balance": "0" }, + "000000000000000000000000000000000000000f": { "balance": "0" }, + "0000000000000000000000000000000000000010": { "balance": "0" }, + "0000000000000000000000000000000000000011": { "balance": "0" }, + "0000000000000000000000000000000000000012": { "balance": "0" }, + "0000000000000000000000000000000000000013": { "balance": "0" }, + "0000000000000000000000000000000000000014": { "balance": "0" }, + "0000000000000000000000000000000000000015": { "balance": "0" }, + "0000000000000000000000000000000000000016": { "balance": "0" }, + "0000000000000000000000000000000000000017": { "balance": "0" }, + "0000000000000000000000000000000000000018": { "balance": "0" }, + "0000000000000000000000000000000000000019": { "balance": "0" }, + "000000000000000000000000000000000000001a": { "balance": "0" }, + "000000000000000000000000000000000000001b": { "balance": "0" }, + "000000000000000000000000000000000000001c": { "balance": "0" }, + "000000000000000000000000000000000000001d": { "balance": "0" }, + "000000000000000000000000000000000000001e": { "balance": "0" }, + "000000000000000000000000000000000000001f": { "balance": "0" }, + "0000000000000000000000000000000000000020": { "balance": "0" }, + "0000000000000000000000000000000000000021": { "balance": "0" }, + "0000000000000000000000000000000000000022": { "balance": "0" }, + "0000000000000000000000000000000000000023": { "balance": "0" }, + "0000000000000000000000000000000000000024": { "balance": "0" }, + "0000000000000000000000000000000000000025": { "balance": "0" }, + "0000000000000000000000000000000000000026": { "balance": "0" }, + "0000000000000000000000000000000000000027": { "balance": "0" }, + "0000000000000000000000000000000000000028": { "balance": "0" }, + "0000000000000000000000000000000000000029": { "balance": "0" }, + "000000000000000000000000000000000000002a": { "balance": "0" }, + "000000000000000000000000000000000000002b": { "balance": "0" }, + "000000000000000000000000000000000000002c": { "balance": "0" }, + "000000000000000000000000000000000000002d": { "balance": "0" }, + "000000000000000000000000000000000000002e": { "balance": "0" }, + "000000000000000000000000000000000000002f": { "balance": "0" }, + "0000000000000000000000000000000000000030": { "balance": "0" }, + "0000000000000000000000000000000000000031": { "balance": "0" }, + "0000000000000000000000000000000000000032": { "balance": "0" }, + "0000000000000000000000000000000000000033": { "balance": "0" }, + "0000000000000000000000000000000000000034": { "balance": "0" }, + "0000000000000000000000000000000000000035": { "balance": "0" }, + "0000000000000000000000000000000000000036": { "balance": "0" }, + "0000000000000000000000000000000000000037": { "balance": "0" }, + "0000000000000000000000000000000000000038": { "balance": "0" }, + "0000000000000000000000000000000000000039": { "balance": "0" }, + "000000000000000000000000000000000000003a": { "balance": "0" }, + "000000000000000000000000000000000000003b": { "balance": "0" }, + "000000000000000000000000000000000000003c": { "balance": "0" }, + "000000000000000000000000000000000000003d": { "balance": "0" }, + "000000000000000000000000000000000000003e": { "balance": "0" }, + "000000000000000000000000000000000000003f": { "balance": "0" }, + "0000000000000000000000000000000000000040": { "balance": "0" }, + "0000000000000000000000000000000000000041": { "balance": "0" }, + "0000000000000000000000000000000000000042": { "balance": "0" }, + "0000000000000000000000000000000000000043": { "balance": "0" }, + "0000000000000000000000000000000000000044": { "balance": "0" }, + "0000000000000000000000000000000000000045": { "balance": "0" }, + "0000000000000000000000000000000000000046": { "balance": "0" }, + "0000000000000000000000000000000000000047": { "balance": "0" }, + "0000000000000000000000000000000000000048": { "balance": "0" }, + "0000000000000000000000000000000000000049": { "balance": "0" }, + "000000000000000000000000000000000000004a": { "balance": "0" }, + "000000000000000000000000000000000000004b": { "balance": "0" }, + "000000000000000000000000000000000000004c": { "balance": "0" }, + "000000000000000000000000000000000000004d": { "balance": "0" }, + "000000000000000000000000000000000000004e": { "balance": "0" }, + "000000000000000000000000000000000000004f": { "balance": "0" }, + "0000000000000000000000000000000000000050": { "balance": "0" }, + "0000000000000000000000000000000000000051": { "balance": "0" }, + "0000000000000000000000000000000000000052": { "balance": "0" }, + "0000000000000000000000000000000000000053": { "balance": "0" }, + "0000000000000000000000000000000000000054": { "balance": "0" }, + "0000000000000000000000000000000000000055": { "balance": "0" }, + "0000000000000000000000000000000000000056": { "balance": "0" }, + "0000000000000000000000000000000000000057": { "balance": "0" }, + "0000000000000000000000000000000000000058": { "balance": "0" }, + "0000000000000000000000000000000000000059": { "balance": "0" }, + "000000000000000000000000000000000000005a": { "balance": "0" }, + "000000000000000000000000000000000000005b": { "balance": "0" }, + "000000000000000000000000000000000000005c": { "balance": "0" }, + "000000000000000000000000000000000000005d": { "balance": "0" }, + "000000000000000000000000000000000000005e": { "balance": "0" }, + "000000000000000000000000000000000000005f": { "balance": "0" }, + "0000000000000000000000000000000000000060": { "balance": "0" }, + "0000000000000000000000000000000000000061": { "balance": "0" }, + "0000000000000000000000000000000000000062": { "balance": "0" }, + "0000000000000000000000000000000000000063": { "balance": "0" }, + "0000000000000000000000000000000000000064": { "balance": "0" }, + "0000000000000000000000000000000000000065": { "balance": "0" }, + "0000000000000000000000000000000000000066": { "balance": "0" }, + "0000000000000000000000000000000000000067": { "balance": "0" }, + "0000000000000000000000000000000000000068": { "balance": "0" }, + "0000000000000000000000000000000000000069": { "balance": "0" }, + "000000000000000000000000000000000000006a": { "balance": "0" }, + "000000000000000000000000000000000000006b": { "balance": "0" }, + "000000000000000000000000000000000000006c": { "balance": "0" }, + "000000000000000000000000000000000000006d": { "balance": "0" }, + "000000000000000000000000000000000000006e": { "balance": "0" }, + "000000000000000000000000000000000000006f": { "balance": "0" }, + "0000000000000000000000000000000000000070": { "balance": "0" }, + "0000000000000000000000000000000000000071": { "balance": "0" }, + "0000000000000000000000000000000000000072": { "balance": "0" }, + "0000000000000000000000000000000000000073": { "balance": "0" }, + "0000000000000000000000000000000000000074": { "balance": "0" }, + "0000000000000000000000000000000000000075": { "balance": "0" }, + "0000000000000000000000000000000000000076": { "balance": "0" }, + "0000000000000000000000000000000000000077": { "balance": "0" }, + "0000000000000000000000000000000000000078": { "balance": "0" }, + "0000000000000000000000000000000000000079": { "balance": "0" }, + "000000000000000000000000000000000000007a": { "balance": "0" }, + "000000000000000000000000000000000000007b": { "balance": "0" }, + "000000000000000000000000000000000000007c": { "balance": "0" }, + "000000000000000000000000000000000000007d": { "balance": "0" }, + "000000000000000000000000000000000000007e": { "balance": "0" }, + "000000000000000000000000000000000000007f": { "balance": "0" }, + "0000000000000000000000000000000000000080": { "balance": "0" }, + "0000000000000000000000000000000000000081": { "balance": "0" }, + "0000000000000000000000000000000000000082": { "balance": "0" }, + "0000000000000000000000000000000000000083": { "balance": "0" }, + "0000000000000000000000000000000000000084": { "balance": "0" }, + "0000000000000000000000000000000000000085": { "balance": "0" }, + "0000000000000000000000000000000000000086": { "balance": "0" }, + "0000000000000000000000000000000000000087": { "balance": "0" }, + "0000000000000000000000000000000000000088": { "balance": "0" }, + "0000000000000000000000000000000000000089": { "balance": "0" }, + "000000000000000000000000000000000000008a": { "balance": "0" }, + "000000000000000000000000000000000000008b": { "balance": "0" }, + "000000000000000000000000000000000000008c": { "balance": "0" }, + "000000000000000000000000000000000000008d": { "balance": "0" }, + "000000000000000000000000000000000000008e": { "balance": "0" }, + "000000000000000000000000000000000000008f": { "balance": "0" }, + "0000000000000000000000000000000000000090": { "balance": "0" }, + "0000000000000000000000000000000000000091": { "balance": "0" }, + "0000000000000000000000000000000000000092": { "balance": "0" }, + "0000000000000000000000000000000000000093": { "balance": "0" }, + "0000000000000000000000000000000000000094": { "balance": "0" }, + "0000000000000000000000000000000000000095": { "balance": "0" }, + "0000000000000000000000000000000000000096": { "balance": "0" }, + "0000000000000000000000000000000000000097": { "balance": "0" }, + "0000000000000000000000000000000000000098": { "balance": "0" }, + "0000000000000000000000000000000000000099": { "balance": "0" }, + "000000000000000000000000000000000000009a": { "balance": "0" }, + "000000000000000000000000000000000000009b": { "balance": "0" }, + "000000000000000000000000000000000000009c": { "balance": "0" }, + "000000000000000000000000000000000000009d": { "balance": "0" }, + "000000000000000000000000000000000000009e": { "balance": "0" }, + "000000000000000000000000000000000000009f": { "balance": "0" }, + "00000000000000000000000000000000000000a0": { "balance": "0" }, + "00000000000000000000000000000000000000a1": { "balance": "0" }, + "00000000000000000000000000000000000000a2": { "balance": "0" }, + "00000000000000000000000000000000000000a3": { "balance": "0" }, + "00000000000000000000000000000000000000a4": { "balance": "0" }, + "00000000000000000000000000000000000000a5": { "balance": "0" }, + "00000000000000000000000000000000000000a6": { "balance": "0" }, + "00000000000000000000000000000000000000a7": { "balance": "0" }, + "00000000000000000000000000000000000000a8": { "balance": "0" }, + "00000000000000000000000000000000000000a9": { "balance": "0" }, + "00000000000000000000000000000000000000aa": { "balance": "0" }, + "00000000000000000000000000000000000000ab": { "balance": "0" }, + "00000000000000000000000000000000000000ac": { "balance": "0" }, + "00000000000000000000000000000000000000ad": { "balance": "0" }, + "00000000000000000000000000000000000000ae": { "balance": "0" }, + "00000000000000000000000000000000000000af": { "balance": "0" }, + "00000000000000000000000000000000000000b0": { "balance": "0" }, + "00000000000000000000000000000000000000b1": { "balance": "0" }, + "00000000000000000000000000000000000000b2": { "balance": "0" }, + "00000000000000000000000000000000000000b3": { "balance": "0" }, + "00000000000000000000000000000000000000b4": { "balance": "0" }, + "00000000000000000000000000000000000000b5": { "balance": "0" }, + "00000000000000000000000000000000000000b6": { "balance": "0" }, + "00000000000000000000000000000000000000b7": { "balance": "0" }, + "00000000000000000000000000000000000000b8": { "balance": "0" }, + "00000000000000000000000000000000000000b9": { "balance": "0" }, + "00000000000000000000000000000000000000ba": { "balance": "0" }, + "00000000000000000000000000000000000000bb": { "balance": "0" }, + "00000000000000000000000000000000000000bc": { "balance": "0" }, + "00000000000000000000000000000000000000bd": { "balance": "0" }, + "00000000000000000000000000000000000000be": { "balance": "0" }, + "00000000000000000000000000000000000000bf": { "balance": "0" }, + "00000000000000000000000000000000000000c0": { "balance": "0" }, + "00000000000000000000000000000000000000c1": { "balance": "0" }, + "00000000000000000000000000000000000000c2": { "balance": "0" }, + "00000000000000000000000000000000000000c3": { "balance": "0" }, + "00000000000000000000000000000000000000c4": { "balance": "0" }, + "00000000000000000000000000000000000000c5": { "balance": "0" }, + "00000000000000000000000000000000000000c6": { "balance": "0" }, + "00000000000000000000000000000000000000c7": { "balance": "0" }, + "00000000000000000000000000000000000000c8": { "balance": "0" }, + "00000000000000000000000000000000000000c9": { "balance": "0" }, + "00000000000000000000000000000000000000ca": { "balance": "0" }, + "00000000000000000000000000000000000000cb": { "balance": "0" }, + "00000000000000000000000000000000000000cc": { "balance": "0" }, + "00000000000000000000000000000000000000cd": { "balance": "0" }, + "00000000000000000000000000000000000000ce": { "balance": "0" }, + "00000000000000000000000000000000000000cf": { "balance": "0" }, + "00000000000000000000000000000000000000d0": { "balance": "0" }, + "00000000000000000000000000000000000000d1": { "balance": "0" }, + "00000000000000000000000000000000000000d2": { "balance": "0" }, + "00000000000000000000000000000000000000d3": { "balance": "0" }, + "00000000000000000000000000000000000000d4": { "balance": "0" }, + "00000000000000000000000000000000000000d5": { "balance": "0" }, + "00000000000000000000000000000000000000d6": { "balance": "0" }, + "00000000000000000000000000000000000000d7": { "balance": "0" }, + "00000000000000000000000000000000000000d8": { "balance": "0" }, + "00000000000000000000000000000000000000d9": { "balance": "0" }, "00000000000000000000000000000000000000da": { "balance": "0" }, - "00000000000000000000000000000000000000db": { "balance": "0" }, - "00000000000000000000000000000000000000dc": { "balance": "0" }, - "00000000000000000000000000000000000000dd": { "balance": "0" }, - "00000000000000000000000000000000000000de": { "balance": "0" }, - "00000000000000000000000000000000000000df": { "balance": "0" }, - "00000000000000000000000000000000000000e0": { "balance": "0" }, - "00000000000000000000000000000000000000e1": { "balance": "0" }, - "00000000000000000000000000000000000000e2": { "balance": "0" }, - "00000000000000000000000000000000000000e3": { "balance": "0" }, - "00000000000000000000000000000000000000e4": { "balance": "0" }, - "00000000000000000000000000000000000000e5": { "balance": "0" }, - "00000000000000000000000000000000000000e6": { "balance": "0" }, - "00000000000000000000000000000000000000e7": { "balance": "0" }, - "00000000000000000000000000000000000000e8": { "balance": "0" }, - "00000000000000000000000000000000000000e9": { "balance": "0" }, - "00000000000000000000000000000000000000ea": { "balance": "0" }, - "00000000000000000000000000000000000000eb": { "balance": "0" }, - "00000000000000000000000000000000000000ec": { "balance": "0" }, - "00000000000000000000000000000000000000ed": { "balance": "0" }, - "00000000000000000000000000000000000000ee": { "balance": "0" }, - "00000000000000000000000000000000000000ef": { "balance": "0" }, - "00000000000000000000000000000000000000f0": { "balance": "0" }, - "00000000000000000000000000000000000000f1": { "balance": "0" }, - "00000000000000000000000000000000000000f2": { "balance": "0" }, - "00000000000000000000000000000000000000f3": { "balance": "0" }, - "00000000000000000000000000000000000000f4": { "balance": "0" }, - "00000000000000000000000000000000000000f5": { "balance": "0" }, - "00000000000000000000000000000000000000f6": { "balance": "0" }, - "00000000000000000000000000000000000000f7": { "balance": "0" }, - "00000000000000000000000000000000000000f8": { "balance": "0" }, - "00000000000000000000000000000000000000f9": { "balance": "0" }, - "00000000000000000000000000000000000000fa": { "balance": "0" }, - "00000000000000000000000000000000000000fb": { "balance": "0" }, - "00000000000000000000000000000000000000fc": { "balance": "0" }, - "00000000000000000000000000000000000000fd": { "balance": "0" }, - "00000000000000000000000000000000000000fe": { "balance": "0" }, - "00000000000000000000000000000000000000ff": { "balance": "0" }, + "00000000000000000000000000000000000000db": { "balance": "0" }, + "00000000000000000000000000000000000000dc": { "balance": "0" }, + "00000000000000000000000000000000000000dd": { "balance": "0" }, + "00000000000000000000000000000000000000de": { "balance": "0" }, + "00000000000000000000000000000000000000df": { "balance": "0" }, + "00000000000000000000000000000000000000e0": { "balance": "0" }, + "00000000000000000000000000000000000000e1": { "balance": "0" }, + "00000000000000000000000000000000000000e2": { "balance": "0" }, + "00000000000000000000000000000000000000e3": { "balance": "0" }, + "00000000000000000000000000000000000000e4": { "balance": "0" }, + "00000000000000000000000000000000000000e5": { "balance": "0" }, + "00000000000000000000000000000000000000e6": { "balance": "0" }, + "00000000000000000000000000000000000000e7": { "balance": "0" }, + "00000000000000000000000000000000000000e8": { "balance": "0" }, + "00000000000000000000000000000000000000e9": { "balance": "0" }, + "00000000000000000000000000000000000000ea": { "balance": "0" }, + "00000000000000000000000000000000000000eb": { "balance": "0" }, + "00000000000000000000000000000000000000ec": { "balance": "0" }, + "00000000000000000000000000000000000000ed": { "balance": "0" }, + "00000000000000000000000000000000000000ee": { "balance": "0" }, + "00000000000000000000000000000000000000ef": { "balance": "0" }, + "00000000000000000000000000000000000000f0": { "balance": "0" }, + "00000000000000000000000000000000000000f1": { "balance": "0" }, + "00000000000000000000000000000000000000f2": { "balance": "0" }, + "00000000000000000000000000000000000000f3": { "balance": "0" }, + "00000000000000000000000000000000000000f4": { "balance": "0" }, + "00000000000000000000000000000000000000f5": { "balance": "0" }, + "00000000000000000000000000000000000000f6": { "balance": "0" }, + "00000000000000000000000000000000000000f7": { "balance": "0" }, + "00000000000000000000000000000000000000f8": { "balance": "0" }, + "00000000000000000000000000000000000000f9": { "balance": "0" }, + "00000000000000000000000000000000000000fa": { "balance": "0" }, + "00000000000000000000000000000000000000fb": { "balance": "0" }, + "00000000000000000000000000000000000000fc": { "balance": "0" }, + "00000000000000000000000000000000000000fd": { "balance": "0" }, + "00000000000000000000000000000000000000fe": { "balance": "0" }, + "00000000000000000000000000000000000000ff": { "balance": "0" }, "874b54a8bd152966d63f706bae1ffeb0411921e5": { "balance": "1000000000000000000000000000000" } } } diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index 2d5b38659..a6b24faf9 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -11,9 +11,9 @@ }, "genesis": { "seal": { - "ethereum": { - "nonce": "0x00006d6f7264656e", - "mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578" + "generic": { + "fields": 0, + "rlp": "0x0" } }, "difficulty": "0x20000", diff --git a/ethcore/src/account_provider.rs b/ethcore/src/account_provider.rs index e906aefe9..917ae8b8b 100644 --- a/ethcore/src/account_provider.rs +++ b/ethcore/src/account_provider.rs @@ -276,14 +276,20 @@ impl AccountProvider { } /// Returns `true` if the password for `account` is `password`. `false` if not. - pub fn test_password(&self, account: &Address, password: String) -> Result { - match self.sstore.sign(account, &password, &Default::default()) { + pub fn test_password(&self, account: &Address, password: &str) -> Result { + match self.sstore.sign(account, password, &Default::default()) { Ok(_) => Ok(true), Err(SSError::InvalidPassword) => Ok(false), Err(e) => Err(Error::SStore(e)), } } + /// Permanently removes an account. + pub fn kill_account(&self, account: &Address, password: &str) -> Result<(), Error> { + try!(self.sstore.remove_account(account, &password)); + Ok(()) + } + /// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given. pub fn change_password(&self, account: &Address, password: String, new_password: String) -> Result<(), Error> { self.sstore.change_password(account, &password, &new_password).map_err(Error::SStore) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 5efd1de40..84285c945 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -141,7 +141,7 @@ pub trait BlockProvider { fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockNumber, to_block: BlockNumber) -> Vec; /// Returns logs matching given filter. - fn logs(&self, mut blocks: Vec, matches: F, limit: Option) -> Vec + fn logs(&self, blocks: Vec, matches: F, limit: Option) -> Vec where F: Fn(&LogEntry) -> bool, Self: Sized; } diff --git a/ethcore/src/engines/authority_round.rs b/ethcore/src/engines/authority_round.rs index e90bc73f2..e55f1e5f9 100644 --- a/ethcore/src/engines/authority_round.rs +++ b/ethcore/src/engines/authority_round.rs @@ -256,8 +256,8 @@ impl Engine for AuthorityRound { /// Check if the signature belongs to the correct proposer. fn verify_block_unordered(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> { - let header_step = try!(header_step(header)); - // Give one step slack if step is lagging, double vote is still not possible. + let header_step = try!(header_step(header)); + // Give one step slack if step is lagging, double vote is still not possible. if header_step <= self.step() + 1 { let proposer_signature = try!(header_signature(header)); let ok_sig = try!(verify_address(self.step_proposer(header_step), &proposer_signature, &header.bare_hash())); @@ -423,13 +423,13 @@ mod tests { let engine = Spec::new_test_round().engine; let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); - let mut step = UNIX_EPOCH.elapsed().unwrap().as_secs(); + let time = UNIX_EPOCH.elapsed().unwrap().as_secs(); + // Two authorities. + let mut step = time - time % 2; header.set_seal(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); - let first_ok = engine.verify_block_seal(&header).is_ok(); + assert!(engine.verify_block_seal(&header).is_err()); step = step + 1; header.set_seal(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); - let second_ok = engine.verify_block_seal(&header).is_ok(); - - assert!(first_ok ^ second_ok); + assert!(engine.verify_block_seal(&header).is_ok()); } } diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 664b2f4e9..5aaa5b479 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -577,29 +577,29 @@ impl Miner { let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into(); let best_block_header: Header = ::rlp::decode(&chain.best_block_header()); transactions.into_iter() - .filter(|tx| match self.engine.verify_transaction_basic(tx, &best_block_header) { - Ok(()) => true, + .map(|tx| { + match self.engine.verify_transaction_basic(&tx, &best_block_header) { Err(e) => { debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e); - false - } - } - ) - .map(|tx| { - let origin = accounts.as_ref().and_then(|accounts| { - tx.sender().ok().and_then(|sender| match accounts.contains(&sender) { - true => Some(TransactionOrigin::Local), - false => None, - }) - }).unwrap_or(default_origin); - - match origin { - TransactionOrigin::Local | TransactionOrigin::RetractedBlock => { - transaction_queue.add(tx, origin, &fetch_account, &gas_required) + Err(e) + }, + Ok(()) => { + let origin = accounts.as_ref().and_then(|accounts| { + tx.sender().ok().and_then(|sender| match accounts.contains(&sender) { + true => Some(TransactionOrigin::Local), + false => None, + }) + }).unwrap_or(default_origin); + + match origin { + TransactionOrigin::Local | TransactionOrigin::RetractedBlock => { + transaction_queue.add(tx, origin, &fetch_account, &gas_required) + }, + TransactionOrigin::External => { + transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required) + } + } }, - TransactionOrigin::External => { - transaction_queue.add_with_banlist(tx, &fetch_account, &gas_required) - } } }) .collect() diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 6a1b55a1b..14129d4d9 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -128,6 +128,9 @@ impl TraceDB where T: DatabaseExtras { /// Creates new instance of `TraceDB`. pub fn new(config: Config, tracesdb: Arc, extras: Arc) -> Self { let mut batch = DBTransaction::new(&tracesdb); + let genesis = extras.block_hash(0) + .expect("Genesis block is always inserted upon extras db creation qed"); + batch.write(db::COL_TRACE, &genesis, &FlatBlockTraces::default()); batch.put(db::COL_TRACE, b"version", TRACE_DB_VER); tracesdb.write(batch).expect("failed to update version"); @@ -413,8 +416,12 @@ mod tests { struct NoopExtras; impl DatabaseExtras for NoopExtras { - fn block_hash(&self, _block_number: BlockNumber) -> Option { - unimplemented!(); + fn block_hash(&self, block_number: BlockNumber) -> Option { + if block_number == 0 { + Some(H256::default()) + } else { + unimplemented!() + } } fn transaction_hash(&self, _block_number: BlockNumber, _tx_position: usize) -> Option { @@ -581,35 +588,21 @@ mod tests { let db = Arc::new(Database::open(&DatabaseConfig::with_columns(::db::NUM_COLUMNS), temp.as_str()).unwrap()); let mut config = Config::default(); config.enabled = true; - let block_0 = H256::from(0xa1); - let block_1 = H256::from(0xa2); - let tx_0 = H256::from(0xff); - let tx_1 = H256::from(0xaf); + let block_1 = H256::from(0xa1); + let block_2 = H256::from(0xa2); + let tx_1 = H256::from(0xff); + let tx_2 = H256::from(0xaf); let mut extras = Extras::default(); - extras.block_hashes.insert(0, block_0.clone()); + extras.block_hashes.insert(0, H256::default()); + extras.block_hashes.insert(1, block_1.clone()); - extras.transaction_hashes.insert(0, vec![tx_0.clone()]); + extras.block_hashes.insert(2, block_2.clone()); extras.transaction_hashes.insert(1, vec![tx_1.clone()]); + extras.transaction_hashes.insert(2, vec![tx_2.clone()]); let tracedb = TraceDB::new(config, db.clone(), Arc::new(extras)); - // import block 0 - let request = create_simple_import_request(0, block_0.clone()); - let mut batch = DBTransaction::new(&db); - tracedb.import(&mut batch, request); - db.write(batch).unwrap(); - - let filter = Filter { - range: (0..0), - from_address: AddressesFilter::from(vec![Address::from(1)]), - to_address: AddressesFilter::from(vec![]), - }; - - let traces = tracedb.filter(&filter); - assert_eq!(traces.len(), 1); - assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); - // import block 1 let request = create_simple_import_request(1, block_1.clone()); let mut batch = DBTransaction::new(&db); @@ -617,38 +610,56 @@ mod tests { db.write(batch).unwrap(); let filter = Filter { - range: (0..1), + range: (1..1), + from_address: AddressesFilter::from(vec![Address::from(1)]), + to_address: AddressesFilter::from(vec![]), + }; + + let traces = tracedb.filter(&filter); + assert_eq!(traces.len(), 1); + assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); + + // import block 2 + let request = create_simple_import_request(2, block_2.clone()); + let mut batch = DBTransaction::new(&db); + tracedb.import(&mut batch, request); + db.write(batch).unwrap(); + + let filter = Filter { + range: (1..2), from_address: AddressesFilter::from(vec![Address::from(1)]), to_address: AddressesFilter::from(vec![]), }; let traces = tracedb.filter(&filter); assert_eq!(traces.len(), 2); - assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); - assert_eq!(traces[1], create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); + assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); + assert_eq!(traces[1], create_simple_localized_trace(2, block_2.clone(), tx_2.clone())); - let traces = tracedb.block_traces(0).unwrap(); - assert_eq!(traces.len(), 1); - assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); + assert!(tracedb.block_traces(0).is_some(), "Genesis trace should be always present."); let traces = tracedb.block_traces(1).unwrap(); assert_eq!(traces.len(), 1); assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); - assert_eq!(None, tracedb.block_traces(2)); - - let traces = tracedb.transaction_traces(0, 0).unwrap(); + let traces = tracedb.block_traces(2).unwrap(); assert_eq!(traces.len(), 1); - assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); + assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone())); + + assert_eq!(None, tracedb.block_traces(3)); let traces = tracedb.transaction_traces(1, 0).unwrap(); assert_eq!(traces.len(), 1); assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); - assert_eq!(None, tracedb.transaction_traces(1, 1)); + let traces = tracedb.transaction_traces(2, 0).unwrap(); + assert_eq!(traces.len(), 1); + assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone())); + + assert_eq!(None, tracedb.transaction_traces(2, 1)); - assert_eq!(tracedb.trace(0, 0, vec![]).unwrap(), create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); + assert_eq!(tracedb.trace(2, 0, vec![]).unwrap(), create_simple_localized_trace(2, block_2.clone(), tx_2.clone())); } #[test] @@ -660,8 +671,10 @@ mod tests { let block_0 = H256::from(0xa1); let tx_0 = H256::from(0xff); - extras.block_hashes.insert(0, block_0.clone()); - extras.transaction_hashes.insert(0, vec![tx_0.clone()]); + extras.block_hashes.insert(0, H256::default()); + extras.transaction_hashes.insert(0, vec![]); + extras.block_hashes.insert(1, block_0.clone()); + extras.transaction_hashes.insert(1, vec![tx_0.clone()]); // set tracing on config.enabled = true; @@ -669,8 +682,8 @@ mod tests { { let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone())); - // import block 0 - let request = create_simple_import_request(0, block_0.clone()); + // import block 1 + let request = create_simple_import_request(1, block_0.clone()); let mut batch = DBTransaction::new(&db); tracedb.import(&mut batch, request); db.write(batch).unwrap(); @@ -678,8 +691,28 @@ mod tests { { let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras)); - let traces = tracedb.transaction_traces(0, 0); - assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(0, block_0, tx_0)]); + let traces = tracedb.transaction_traces(1, 0); + assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(1, block_0, tx_0)]); } } + + #[test] + fn query_genesis() { + let temp = RandomTempPath::new(); + let db = new_db(temp.as_str()); + let mut config = Config::default(); + let mut extras = Extras::default(); + let block_0 = H256::from(0xa1); + + extras.block_hashes.insert(0, block_0.clone()); + extras.transaction_hashes.insert(0, vec![]); + + // set tracing on + config.enabled = true; + + let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone())); + let traces = tracedb.block_traces(0).unwrap(); + + assert_eq!(traces.len(), 0); + } } diff --git a/ethcore/src/types/trace_types/flat.rs b/ethcore/src/types/trace_types/flat.rs index 58983558d..d0c7cbe9b 100644 --- a/ethcore/src/types/trace_types/flat.rs +++ b/ethcore/src/types/trace_types/flat.rs @@ -119,7 +119,7 @@ impl Into> for FlatTransactionTraces { } /// Represents all traces produced by transactions in a single block. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, Default)] pub struct FlatBlockTraces(Vec); impl HeapSizeOf for FlatBlockTraces { diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 99e09784d..686a1d093 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -35,6 +35,9 @@ pub mod kind; const MIN_MEM_LIMIT: usize = 16384; const MIN_QUEUE_LIMIT: usize = 512; +// maximum possible number of verification threads. +const MAX_VERIFIERS: usize = 8; + /// Type alias for block queue convenience. pub type BlockQueue = VerificationQueue; @@ -61,6 +64,37 @@ impl Default for Config { } } +struct VerifierHandle { + deleting: Arc, + sleep: Arc, + thread: JoinHandle<()>, +} + +impl VerifierHandle { + // signal to the verifier thread that it should sleep. + fn sleep(&self) { + self.sleep.store(true, AtomicOrdering::SeqCst); + } + + // signal to the verifier thread that it should wake up. + fn wake_up(&self) { + self.sleep.store(false, AtomicOrdering::SeqCst); + self.thread.thread().unpark(); + } + + // signal to the verifier thread that it should conclude its + // operations. + fn conclude(&self) { + self.wake_up(); + self.deleting.store(true, AtomicOrdering::Release); + } + + // join the verifier thread. + fn join(self) { + self.thread.join().expect("Verifier thread panicked"); + } +} + /// An item which is in the process of being verified. pub struct Verifying { hash: H256, @@ -97,11 +131,12 @@ pub struct VerificationQueue { engine: Arc, more_to_verify: Arc, verification: Arc>, - verifiers: Vec>, + verifiers: Mutex<(Vec, usize)>, deleting: Arc, ready_signal: Arc, empty: Arc, processing: RwLock>, + ticks_since_adjustment: AtomicUsize, max_queue_size: usize, max_mem_use: usize, } @@ -157,6 +192,7 @@ struct Verification { more_to_verify: SMutex<()>, empty: SMutex<()>, sizes: Sizes, + check_seal: bool, } impl VerificationQueue { @@ -173,7 +209,8 @@ impl VerificationQueue { unverified: AtomicUsize::new(0), verifying: AtomicUsize::new(0), verified: AtomicUsize::new(0), - } + }, + check_seal: check_seal, }); let more_to_verify = Arc::new(SCondvar::new()); let deleting = Arc::new(AtomicBool::new(false)); @@ -185,44 +222,82 @@ impl VerificationQueue { let empty = Arc::new(SCondvar::new()); let panic_handler = PanicHandler::new_in_arc(); - let mut verifiers: Vec> = Vec::new(); - let thread_count = max(::num_cpus::get(), 3) - 2; - for i in 0..thread_count { - let verification = verification.clone(); - let engine = engine.clone(); - let more_to_verify = more_to_verify.clone(); - let ready_signal = ready_signal.clone(); - let empty = empty.clone(); + let max_verifiers = min(::num_cpus::get(), MAX_VERIFIERS); + let default_amount = max(::num_cpus::get(), 3) - 2; + let mut verifiers = Vec::with_capacity(max_verifiers); + + debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, default_amount); + + for i in 0..max_verifiers { + debug!(target: "verification", "Adding verification thread #{}", i); + let deleting = deleting.clone(); let panic_handler = panic_handler.clone(); - verifiers.push( - thread::Builder::new() - .name(format!("Verifier #{}", i)) - .spawn(move || { - panic_handler.catch_panic(move || { - VerificationQueue::verify(verification, engine, more_to_verify, ready_signal, deleting, empty, check_seal) - }).unwrap() - }) - .expect("Error starting block verification thread") - ); + let verification = verification.clone(); + let engine = engine.clone(); + let wait = more_to_verify.clone(); + let ready = ready_signal.clone(); + let empty = empty.clone(); + + // enable only the first few verifiers. + let sleep = if i < default_amount { + Arc::new(AtomicBool::new(false)) + } else { + Arc::new(AtomicBool::new(true)) + }; + + verifiers.push(VerifierHandle { + deleting: deleting.clone(), + sleep: sleep.clone(), + thread: thread::Builder::new() + .name(format!("Verifier #{}", i)) + .spawn(move || { + panic_handler.catch_panic(move || { + VerificationQueue::verify(verification, engine, wait, ready, deleting, empty, sleep) + }).unwrap() + }) + .expect("Failed to create verifier thread.") + }); } + VerificationQueue { engine: engine, panic_handler: panic_handler, - ready_signal: ready_signal.clone(), - more_to_verify: more_to_verify.clone(), - verification: verification.clone(), - verifiers: verifiers, - deleting: deleting.clone(), + ready_signal: ready_signal, + more_to_verify: more_to_verify, + verification: verification, + verifiers: Mutex::new((verifiers, default_amount)), + deleting: deleting, processing: RwLock::new(HashSet::new()), - empty: empty.clone(), + empty: empty, + ticks_since_adjustment: AtomicUsize::new(0), max_queue_size: max(config.max_queue_size, MIN_QUEUE_LIMIT), max_mem_use: max(config.max_mem_use, MIN_MEM_LIMIT), } } - fn verify(verification: Arc>, engine: Arc, wait: Arc, ready: Arc, deleting: Arc, empty: Arc, check_seal: bool) { + fn verify( + verification: Arc>, + engine: Arc, + wait: Arc, + ready: Arc, + deleting: Arc, + empty: Arc, + sleep: Arc, + ) { while !deleting.load(AtomicOrdering::Acquire) { + { + while sleep.load(AtomicOrdering::SeqCst) { + trace!(target: "verification", "Verifier sleeping"); + ::std::thread::park(); + trace!(target: "verification", "Verifier waking up"); + + if deleting.load(AtomicOrdering::Acquire) { + return; + } + } + } + { let mut more_to_verify = verification.more_to_verify.lock().unwrap(); @@ -255,7 +330,7 @@ impl VerificationQueue { }; let hash = item.hash(); - let is_ready = match K::verify(item, &*engine, check_seal) { + let is_ready = match K::verify(item, &*engine, verification.check_seal) { Ok(verified) => { let mut verifying = verification.verifying.lock(); let mut idx = None; @@ -302,9 +377,15 @@ impl VerificationQueue { } } - fn drain_verifying(verifying: &mut VecDeque>, verified: &mut VecDeque, bad: &mut HashSet, sizes: &Sizes) { + fn drain_verifying( + verifying: &mut VecDeque>, + verified: &mut VecDeque, + bad: &mut HashSet, + sizes: &Sizes, + ) { let mut removed_size = 0; let mut inserted_size = 0; + while let Some(output) = verifying.front_mut().and_then(|x| x.output.take()) { assert!(verifying.pop_front().is_some()); let size = output.heap_size_of_children(); @@ -487,14 +568,85 @@ impl VerificationQueue { } } - /// Optimise memory footprint of the heap fields. + /// Optimise memory footprint of the heap fields, and adjust the number of threads + /// to better suit the workload. pub fn collect_garbage(&self) { - { - self.verification.unverified.lock().shrink_to_fit(); + // number of ticks to average queue stats over + // when deciding whether to change the number of verifiers. + #[cfg(not(test))] + const READJUSTMENT_PERIOD: usize = 12; + + #[cfg(test)] + const READJUSTMENT_PERIOD: usize = 1; + + let (u_len, v_len) = { + let u_len = { + let mut q = self.verification.unverified.lock(); + q.shrink_to_fit(); + q.len() + }; self.verification.verifying.lock().shrink_to_fit(); - self.verification.verified.lock().shrink_to_fit(); - } + + let v_len = { + let mut q = self.verification.verified.lock(); + q.shrink_to_fit(); + q.len() + }; + + (u_len as isize, v_len as isize) + }; + self.processing.write().shrink_to_fit(); + + if self.ticks_since_adjustment.fetch_add(1, AtomicOrdering::SeqCst) + 1 >= READJUSTMENT_PERIOD { + self.ticks_since_adjustment.store(0, AtomicOrdering::SeqCst); + } else { + return; + } + + let current = self.verifiers.lock().1; + + let diff = (v_len - u_len).abs(); + let total = v_len + u_len; + + self.scale_verifiers( + if u_len < 20 { + 1 + } else if diff <= total / 10 { + current + } else if v_len > u_len { + current - 1 + } else { + current + 1 + } + ); + } + + // wake up or sleep verifiers to get as close to the target as + // possible, never going over the amount of initially allocated threads + // or below 1. + fn scale_verifiers(&self, target: usize) { + let mut verifiers = self.verifiers.lock(); + let &mut (ref mut verifiers, ref mut verifier_count) = &mut *verifiers; + + let target = min(verifiers.len(), target); + let target = max(1, target); + + debug!(target: "verification", "Scaling from {} to {} verifiers", verifier_count, target); + + // scaling up + for i in *verifier_count..target { + debug!(target: "verification", "Waking up verifier {}", i); + verifiers[i].wake_up(); + } + + // scaling down. + for i in target..*verifier_count { + debug!(target: "verification", "Putting verifier {} to sleep", i); + verifiers[i].sleep(); + } + + *verifier_count = target; } } @@ -509,10 +661,23 @@ impl Drop for VerificationQueue { trace!(target: "shutdown", "[VerificationQueue] Closing..."); self.clear(); self.deleting.store(true, AtomicOrdering::Release); - self.more_to_verify.notify_all(); - for t in self.verifiers.drain(..) { - t.join().unwrap(); + + let mut verifiers = self.verifiers.get_mut(); + let mut verifiers = &mut verifiers.0; + + // first pass to signal conclusion. must be done before + // notify or deadlock possible. + for handle in verifiers.iter() { + handle.conclude(); } + + self.more_to_verify.notify_all(); + + // second pass to join. + for handle in verifiers.drain(..) { + handle.join(); + } + trace!(target: "shutdown", "[VerificationQueue] Closed."); } } @@ -611,4 +776,56 @@ mod tests { } assert!(queue.queue_info().is_full()); } + + #[test] + fn scaling_limits() { + use super::MAX_VERIFIERS; + + let queue = get_test_queue(); + queue.scale_verifiers(MAX_VERIFIERS + 1); + + assert!(queue.verifiers.lock().1 < MAX_VERIFIERS + 1); + + queue.scale_verifiers(0); + + assert!(queue.verifiers.lock().1 == 1); + } + + #[test] + fn readjust_verifiers() { + let queue = get_test_queue(); + + // put all the verifiers to sleep to ensure + // the test isn't timing sensitive. + let num_verifiers = { + let verifiers = queue.verifiers.lock(); + for i in 0..verifiers.1 { + verifiers.0[i].sleep(); + } + + verifiers.1 + }; + + for block in get_good_dummy_block_seq(5000) { + queue.import(Unverified::new(block)).expect("Block good by definition; qed"); + } + + // almost all unverified == bump verifier count. + queue.collect_garbage(); + assert_eq!(queue.verifiers.lock().1, num_verifiers + 1); + + // wake them up again and verify everything. + { + let verifiers = queue.verifiers.lock(); + for i in 0..verifiers.1 { + verifiers.0[i].wake_up(); + } + } + + queue.flush(); + + // nothing to verify == use minimum number of verifiers. + queue.collect_garbage(); + assert_eq!(queue.verifiers.lock().1, 1); + } } diff --git a/js/package.json b/js/package.json index 7f4157cad..6d8c37165 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "parity.js", - "version": "0.2.58", + "version": "0.2.73", "main": "release/index.js", "jsnext:main": "src/index.js", "author": "Parity Team ", @@ -102,6 +102,7 @@ "postcss-nested": "^1.0.0", "postcss-simple-vars": "^3.0.0", "raw-loader": "^0.5.1", + "react-addons-perf": "~15.3.2", "react-addons-test-utils": "~15.3.2", "react-copy-to-clipboard": "^4.2.3", "react-dom": "~15.3.2", diff --git a/js/src/3rdparty/shapeshift/shapeshift.js b/js/src/3rdparty/shapeshift/shapeshift.js index 344a44802..8f388d0a7 100644 --- a/js/src/3rdparty/shapeshift/shapeshift.js +++ b/js/src/3rdparty/shapeshift/shapeshift.js @@ -15,7 +15,8 @@ // along with Parity. If not, see . export default function (rpc) { - const subscriptions = []; + let subscriptions = []; + let pollStatusIntervalId = null; function getCoins () { return rpc.get('getcoins'); @@ -45,6 +46,24 @@ export default function (rpc) { callback, idx }); + + // Only poll if there are subscriptions... + if (!pollStatusIntervalId) { + pollStatusIntervalId = setInterval(_pollStatus, 2000); + } + } + + function unsubscribe (depositAddress) { + const newSubscriptions = [] + .concat(subscriptions) + .filter((sub) => sub.depositAddress !== depositAddress); + + subscriptions = newSubscriptions; + + if (subscriptions.length === 0) { + clearInterval(pollStatusIntervalId); + pollStatusIntervalId = null; + } } function _getSubscriptionStatus (subscription) { @@ -81,13 +100,12 @@ export default function (rpc) { subscriptions.forEach(_getSubscriptionStatus); } - setInterval(_pollStatus, 2000); - return { getCoins, getMarketInfo, getStatus, shift, - subscribe + subscribe, + unsubscribe }; } diff --git a/js/src/modals/SMSVerification/terms-of-service.js b/js/src/3rdparty/sms-verification/index.js similarity index 81% rename from js/src/modals/SMSVerification/terms-of-service.js rename to js/src/3rdparty/sms-verification/index.js index f61b3c97d..9b113f364 100644 --- a/js/src/modals/SMSVerification/terms-of-service.js +++ b/js/src/3rdparty/sms-verification/index.js @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { stringify } from 'querystring'; import React from 'react'; -export default ( +export const termsOfService = (
  • This privacy notice relates to your use of the Parity SMS verification service. We take your privacy seriously and deal in an honest, direct and transparent way when it comes to your data.
  • We collect your phone number when you use this service. This is temporarily kept in memory, and then encrypted and stored in our EU servers. We only retain the cryptographic hash of the number to prevent duplicated accounts. You consent to this use.
  • @@ -25,3 +26,18 @@ export default (
  • Parity Technology Limited is registered in England and Wales under company number 09760015 and complies with the Data Protection Act 1998 (UK). You may contact us via email at admin@parity.io. Our general privacy policy can be found here: https://ethcore.io/legal.html.
); + +export const postToServer = (query) => { + query = stringify(query); + return fetch('https://sms-verification.parity.io/?' + query, { + method: 'POST', mode: 'cors', cache: 'no-store' + }) + .then((res) => { + return res.json().then((data) => { + if (res.ok) { + return data.message; + } + throw new Error(data.message || 'unknown error'); + }); + }); +}; diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js index 06afb0d9d..6fe497551 100644 --- a/js/src/api/contract/contract.js +++ b/js/src/api/contract/contract.js @@ -48,7 +48,11 @@ export default class Contract { this._instance[fn.signature] = fn; }); - this._sendSubscriptionChanges(); + this._subscribedToPendings = false; + this._pendingsSubscriptionId = null; + + this._subscribedToBlock = false; + this._blockSubscriptionId = null; } get address () { @@ -239,44 +243,71 @@ export default class Contract { return event; } - subscribe (eventName = null, options = {}, callback) { - return new Promise((resolve, reject) => { - let event = null; + _findEvent (eventName = null) { + const event = eventName + ? this._events.find((evt) => evt.name === eventName) + : null; - if (eventName) { - event = this._events.find((evt) => evt.name === eventName); + if (eventName && !event) { + const events = this._events.map((evt) => evt.name).join(', '); + throw new Error(`${eventName} is not a valid eventName, subscribe using one of ${events} (or null to include all)`); + } - if (!event) { - const events = this._events.map((evt) => evt.name).join(', '); - reject(new Error(`${eventName} is not a valid eventName, subscribe using one of ${events} (or null to include all)`)); - return; - } - } + return event; + } - return this._subscribe(event, options, callback).then(resolve).catch(reject); + _createEthFilter (event = null, _options) { + const optionTopics = _options.topics || []; + const signature = event && event.signature || null; + + // If event provided, remove the potential event signature + // as the first element of the topics + const topics = signature + ? [ signature ].concat(optionTopics.filter((t, idx) => idx > 0 || t !== signature)) + : optionTopics; + + const options = Object.assign({}, _options, { + address: this._address, + topics }); + + return this._api.eth.newFilter(options); + } + + subscribe (eventName = null, options = {}, callback) { + try { + const event = this._findEvent(eventName); + return this._subscribe(event, options, callback); + } catch (e) { + return Promise.reject(e); + } } _subscribe (event = null, _options, callback) { const subscriptionId = nextSubscriptionId++; - const options = Object.assign({}, _options, { - address: this._address, - topics: [event ? event.signature : null] - }); + const { skipInitFetch } = _options; + delete _options['skipInitFetch']; - return this._api.eth - .newFilter(options) + return this + ._createEthFilter(event, _options) .then((filterId) => { + this._subscriptions[subscriptionId] = { + options: _options, + callback, + filterId + }; + + if (skipInitFetch) { + this._subscribeToChanges(); + return subscriptionId; + } + return this._api.eth .getFilterLogs(filterId) .then((logs) => { callback(null, this.parseEventLogs(logs)); - this._subscriptions[subscriptionId] = { - options, - callback, - filterId - }; + this._subscribeToChanges(); return subscriptionId; }); }); @@ -285,19 +316,89 @@ export default class Contract { unsubscribe (subscriptionId) { return this._api.eth .uninstallFilter(this._subscriptions[subscriptionId].filterId) - .then(() => { - delete this._subscriptions[subscriptionId]; - }) .catch((error) => { console.error('unsubscribe', error); + }) + .then(() => { + delete this._subscriptions[subscriptionId]; + this._unsubscribeFromChanges(); }); } - _sendSubscriptionChanges = () => { + _subscribeToChanges = () => { const subscriptions = Object.values(this._subscriptions); - const timeout = () => setTimeout(this._sendSubscriptionChanges, 1000); - Promise + const pendingSubscriptions = subscriptions + .filter((s) => s.options.toBlock && s.options.toBlock === 'pending'); + + const otherSubscriptions = subscriptions + .filter((s) => !(s.options.toBlock && s.options.toBlock === 'pending')); + + if (pendingSubscriptions.length > 0 && !this._subscribedToPendings) { + this._subscribedToPendings = true; + this._subscribeToPendings(); + } + + if (otherSubscriptions.length > 0 && !this._subscribedToBlock) { + this._subscribedToBlock = true; + this._subscribeToBlock(); + } + } + + _unsubscribeFromChanges = () => { + const subscriptions = Object.values(this._subscriptions); + + const pendingSubscriptions = subscriptions + .filter((s) => s.options.toBlock && s.options.toBlock === 'pending'); + + const otherSubscriptions = subscriptions + .filter((s) => !(s.options.toBlock && s.options.toBlock === 'pending')); + + if (pendingSubscriptions.length === 0 && this._subscribedToPendings) { + this._subscribedToPendings = false; + clearTimeout(this._pendingsSubscriptionId); + } + + if (otherSubscriptions.length === 0 && this._subscribedToBlock) { + this._subscribedToBlock = false; + this._api.unsubscribe(this._blockSubscriptionId); + } + } + + _subscribeToBlock = () => { + this._api + .subscribe('eth_blockNumber', (error) => { + if (error) { + console.error('::_subscribeToBlock', error, error && error.stack); + } + + const subscriptions = Object.values(this._subscriptions) + .filter((s) => !(s.options.toBlock && s.options.toBlock === 'pending')); + + this._sendSubscriptionChanges(subscriptions); + }) + .then((blockSubId) => { + this._blockSubscriptionId = blockSubId; + }) + .catch((e) => { + console.error('::_subscribeToBlock', e, e && e.stack); + }); + } + + _subscribeToPendings = () => { + const subscriptions = Object.values(this._subscriptions) + .filter((s) => s.options.toBlock && s.options.toBlock === 'pending'); + + const timeout = () => setTimeout(() => this._subscribeToPendings(), 1000); + + this._sendSubscriptionChanges(subscriptions) + .then(() => { + this._pendingsSubscriptionId = timeout(); + }); + } + + _sendSubscriptionChanges = (subscriptions) => { + return Promise .all( subscriptions.map((subscription) => { return this._api.eth.getFilterChanges(subscription.filterId); @@ -315,12 +416,9 @@ export default class Contract { console.error('_sendSubscriptionChanges', error); } }); - - timeout(); }) .catch((error) => { console.error('_sendSubscriptionChanges', error); - timeout(); }); } } diff --git a/js/src/api/contract/contract.spec.js b/js/src/api/contract/contract.spec.js index 9c08024a9..970dd606d 100644 --- a/js/src/api/contract/contract.spec.js +++ b/js/src/api/contract/contract.spec.js @@ -437,6 +437,7 @@ describe('api/contract/Contract', () => { ] } ]; + const logs = [{ address: '0x22bff18ec62281850546a664bb63a5c06ac5f76c', blockHash: '0xa9280530a3b47bee2fc80f2862fd56502ae075350571d724d6442ea4c597347b', @@ -450,6 +451,7 @@ describe('api/contract/Contract', () => { transactionHash: '0xca16f537d761d13e4e80953b754e2b15541f267d6cad9381f750af1bae1e4917', transactionIndex: '0x0' }]; + const parsed = [{ address: '0x22bfF18ec62281850546a664bb63a5C06AC5F76C', blockHash: '0xa9280530a3b47bee2fc80f2862fd56502ae075350571d724d6442ea4c597347b', @@ -466,11 +468,13 @@ describe('api/contract/Contract', () => { sender: { type: 'address', value: '0x63Cf90D3f0410092FC0fca41846f596223979195' } }, topics: [ - '0x954ba6c157daf8a26539574ffa64203c044691aa57251af95f4b48d85ec00dd5', '0x0000000000000000000000000000000000000000000000000001000000004fe0' + '0x954ba6c157daf8a26539574ffa64203c044691aa57251af95f4b48d85ec00dd5', + '0x0000000000000000000000000000000000000000000000000001000000004fe0' ], transactionHash: '0xca16f537d761d13e4e80953b754e2b15541f267d6cad9381f750af1bae1e4917', transactionIndex: new BigNumber(0) }]; + let contract; beforeEach(() => { @@ -496,18 +500,19 @@ describe('api/contract/Contract', () => { scope = mockHttp([ { method: 'eth_newFilter', reply: { result: '0x123' } }, { method: 'eth_getFilterLogs', reply: { result: logs } }, + { method: 'eth_getFilterChanges', reply: { result: logs } }, { method: 'eth_newFilter', reply: { result: '0x123' } }, { method: 'eth_getFilterLogs', reply: { result: logs } } ]); cbb = sinon.stub(); cbe = sinon.stub(); - return contract.subscribe('Message', {}, cbb); + return contract.subscribe('Message', { toBlock: 'pending' }, cbb); }); it('sets the subscriptionId returned', () => { return contract - .subscribe('Message', {}, cbe) + .subscribe('Message', { toBlock: 'pending' }, cbe) .then((subscriptionId) => { expect(subscriptionId).to.equal(1); }); @@ -515,7 +520,7 @@ describe('api/contract/Contract', () => { it('creates a new filter and retrieves the logs on it', () => { return contract - .subscribe('Message', {}, cbe) + .subscribe('Message', { toBlock: 'pending' }, cbe) .then((subscriptionId) => { expect(scope.isDone()).to.be.true; }); @@ -523,7 +528,7 @@ describe('api/contract/Contract', () => { it('returns the logs to the callback', () => { return contract - .subscribe('Message', {}, cbe) + .subscribe('Message', { toBlock: 'pending' }, cbe) .then((subscriptionId) => { expect(cbe).to.have.been.calledWith(null, parsed); }); diff --git a/js/src/api/format/input.js b/js/src/api/format/input.js index 4cd1c8a56..55c85e4f3 100644 --- a/js/src/api/format/input.js +++ b/js/src/api/format/input.js @@ -15,6 +15,7 @@ // along with Parity. If not, see . import BigNumber from 'bignumber.js'; +import { range } from 'lodash'; import { isArray, isHex, isInstanceOf, isString } from '../util/types'; @@ -50,14 +51,19 @@ export function inHash (hash) { return inHex(hash); } +export function pad (input, length) { + const value = inHex(input).substr(2, length * 2); + return '0x' + value + range(length * 2 - value.length).map(() => '0').join(''); +} + export function inTopics (_topics) { let topics = (_topics || []) - .filter((topic) => topic) - .map(inHex); + .filter((topic) => topic === null || topic) + .map((topic) => topic === null ? null : pad(topic, 32)); - while (topics.length < 4) { - topics.push(null); - } + // while (topics.length < 4) { + // topics.push(null); + // } return topics; } diff --git a/js/src/api/rpc/parity/parity.js b/js/src/api/rpc/parity/parity.js index d14cc6554..ac16eb9b0 100644 --- a/js/src/api/rpc/parity/parity.js +++ b/js/src/api/rpc/parity/parity.js @@ -123,6 +123,11 @@ export default class Parity { .then((accounts) => (accounts || []).map(outAddress)); } + killAccount (account, password) { + return this._transport + .execute('parity_killAccount', inAddress(account), password); + } + listGethAccounts () { return this._transport .execute('parity_listGethAccounts') diff --git a/js/src/api/subscriptions/personal.js b/js/src/api/subscriptions/personal.js index 58428895b..2cb0c3ea0 100644 --- a/js/src/api/subscriptions/personal.js +++ b/js/src/api/subscriptions/personal.js @@ -59,6 +59,7 @@ export default class Personal { } switch (data.method) { + case 'parity_killAccount': case 'parity_importGethAccounts': case 'personal_newAccount': case 'parity_newAccountFromPhrase': diff --git a/js/src/api/transport/ws/ws.js b/js/src/api/transport/ws/ws.js index 7b214fded..c30c910e6 100644 --- a/js/src/api/transport/ws/ws.js +++ b/js/src/api/transport/ws/ws.js @@ -29,21 +29,33 @@ export default class Ws extends JsonRpcBase { this._token = token; this._messages = {}; - this._connecting = true; + this._connecting = false; + this._connected = false; this._lastError = null; - this._autoConnect = false; + this._autoConnect = true; + this._retries = 0; + this._reconnectTimeoutId = null; this._connect(); } updateToken (token) { this._token = token; - this._autoConnect = false; + this._autoConnect = true; this._connect(); } _connect () { + if (this._connecting) { + return; + } + + if (this._reconnectTimeoutId) { + window.clearTimeout(this._reconnectTimeoutId); + this._reconnectTimeoutId = null; + } + const time = parseInt(new Date().getTime() / 1000, 10); const sha3 = keccak_256(`${this._token}:${time}`); const hash = `${sha3}_${time}`; @@ -53,6 +65,7 @@ export default class Ws extends JsonRpcBase { this._ws.onopen = null; this._ws.onclose = null; this._ws.onmessage = null; + this._ws.close(); this._ws = null; } @@ -65,6 +78,27 @@ export default class Ws extends JsonRpcBase { this._ws.onopen = this._onOpen; this._ws.onclose = this._onClose; this._ws.onmessage = this._onMessage; + + // Get counts in dev mode + if (process.env.NODE_ENV === 'development') { + this._count = 0; + this._lastCount = { + timestamp: Date.now(), + count: 0 + }; + + window.setInterval(() => { + const n = this._count - this._lastCount.count; + const t = (Date.now() - this._lastCount.timestamp) / 1000; + const s = Math.round(1000 * n / t) / 1000; + + if (this._debug) { + console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`); + } + }, 5000); + + window._parityWS = this; + } } _onOpen = (event) => { @@ -72,6 +106,7 @@ export default class Ws extends JsonRpcBase { this._connected = true; this._connecting = false; this._autoConnect = true; + this._retries = 0; Object.keys(this._messages) .filter((id) => this._messages[id].queued) @@ -79,18 +114,39 @@ export default class Ws extends JsonRpcBase { } _onClose = (event) => { - console.log('ws:onClose', event); this._connected = false; this._connecting = false; + this._lastError = event; + if (this._autoConnect) { - setTimeout(() => this._connect(), 500); + const timeout = this.retryTimeout; + + const time = timeout < 1000 + ? Math.round(timeout) + 'ms' + : (Math.round(timeout / 10) / 100) + 's'; + + console.log('ws:onClose', `trying again in ${time}...`); + + this._reconnectTimeoutId = setTimeout(() => { + this._connect(); + }, timeout); + + return; } + + console.log('ws:onClose', event); } _onError = (event) => { - console.error('ws:onError', event); - this._lastError = event; + // Only print error if the WS is connected + // ie. don't print if error == closed + window.setTimeout(() => { + if (this._connected) { + console.error('ws:onError', event); + this._lastError = event; + } + }, 50); } _onMessage = (event) => { @@ -127,11 +183,16 @@ export default class Ws extends JsonRpcBase { _send = (id) => { const message = this._messages[id]; - message.queued = !this._connected; - if (this._connected) { - this._ws.send(message.json); + if (process.env.NODE_ENV === 'development') { + this._count++; + } + + return this._ws.send(message.json); } + + message.queued = !this._connected; + message.timestamp = Date.now(); } execute (method, ...params) { @@ -159,4 +220,27 @@ export default class Ws extends JsonRpcBase { get lastError () { return this._lastError; } + + /** + * Exponential Timeout for Retries + * + * @see http://dthain.blogspot.de/2009/02/exponential-backoff-in-distributed.html + */ + get retryTimeout () { + // R between 1 and 2 + const R = Math.random() + 1; + // Initial timeout (100ms) + const T = 100; + // Exponential Factor + const F = 2; + // Max timeout (4s) + const M = 4000; + // Current number of retries + const N = this._retries; + + // Increase retries number + this._retries++; + + return Math.min(R * T * Math.pow(F, N), M); + } } diff --git a/js/src/api/util/format.js b/js/src/api/util/format.js index 198e456ee..93f31a161 100644 --- a/js/src/api/util/format.js +++ b/js/src/api/util/format.js @@ -29,3 +29,7 @@ export function hex2Ascii (_hex) { return str; } + +export function asciiToHex (string) { + return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join(''); +} diff --git a/js/src/api/util/index.js b/js/src/api/util/index.js index 55cf008c5..2058cd011 100644 --- a/js/src/api/util/index.js +++ b/js/src/api/util/index.js @@ -16,7 +16,7 @@ import { isAddress as isAddressValid, toChecksumAddress } from '../../abi/util/address'; import { decodeCallData, decodeMethodInput, methodToAbi } from './decode'; -import { bytesToHex, hex2Ascii } from './format'; +import { bytesToHex, hex2Ascii, asciiToHex } from './format'; import { fromWei, toWei } from './wei'; import { sha3 } from './sha3'; import { isArray, isFunction, isHex, isInstanceOf, isString } from './types'; @@ -31,6 +31,7 @@ export default { isString, bytesToHex, hex2Ascii, + asciiToHex, createIdentityImg, decodeCallData, decodeMethodInput, diff --git a/js/src/contracts/registry.js b/js/src/contracts/registry.js index d52b20718..2f61f7f4a 100644 --- a/js/src/contracts/registry.js +++ b/js/src/contracts/registry.js @@ -21,25 +21,39 @@ export default class Registry { this._api = api; this._contracts = []; this._instance = null; + this._fetching = false; + this._queue = []; this.getInstance(); } getInstance () { - return new Promise((resolve, reject) => { - if (this._instance) { - resolve(this._instance); - return; - } + if (this._instance) { + return Promise.resolve(this._instance); + } - this._api.parity - .registryAddress() - .then((address) => { - this._instance = this._api.newContract(abis.registry, address).instance; - resolve(this._instance); - }) - .catch(reject); - }); + if (this._fetching) { + return new Promise((resolve) => { + this._queue.push({ resolve }); + }); + } + + this._fetching = true; + + return this._api.parity + .registryAddress() + .then((address) => { + this._fetching = false; + this._instance = this._api.newContract(abis.registry, address).instance; + + this._queue.forEach((queued) => { + queued.resolve(this._instance); + }); + + this._queue = []; + + return this._instance; + }); } getContract (_name) { diff --git a/js/src/contracts/sms-verification.js b/js/src/contracts/sms-verification.js index e93d57ffc..2d32556ea 100644 --- a/js/src/contracts/sms-verification.js +++ b/js/src/contracts/sms-verification.js @@ -14,39 +14,39 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { stringify } from 'querystring'; - export const checkIfVerified = (contract, account) => { return contract.instance.certified.call({}, [account]); }; export const checkIfRequested = (contract, account) => { - return new Promise((resolve, reject) => { - contract.subscribe('Requested', { - fromBlock: 0, toBlock: 'pending' - }, (err, logs) => { - if (err) { - return reject(err); - } - const e = logs.find((l) => { - return l.type === 'mined' && l.params.who && l.params.who.value === account; - }); - resolve(e ? e.transactionHash : false); - }); - }); -}; + let subId = null; + let resolved = false; -export const postToServer = (query) => { - query = stringify(query); - return fetch('https://sms-verification.parity.io/?' + query, { - method: 'POST', mode: 'cors', cache: 'no-store' - }) - .then((res) => { - return res.json().then((data) => { - if (res.ok) { - return data.message; - } - throw new Error(data.message || 'unknown error'); - }); + return new Promise((resolve, reject) => { + contract + .subscribe('Requested', { + fromBlock: 0, toBlock: 'pending' + }, (err, logs) => { + if (err) { + return reject(err); + } + const e = logs.find((l) => { + return l.type === 'mined' && l.params.who && l.params.who.value === account; + }); + + resolve(e ? e.transactionHash : false); + resolved = true; + + if (subId) { + contract.unsubscribe(subId); + } + }) + .then((_subId) => { + subId = _subId; + + if (resolved) { + contract.unsubscribe(subId); + } + }); }); }; diff --git a/js/src/dapps/basiccoin/services.js b/js/src/dapps/basiccoin/services.js index 4aed4199f..3dd5202a7 100644 --- a/js/src/dapps/basiccoin/services.js +++ b/js/src/dapps/basiccoin/services.js @@ -105,7 +105,7 @@ export function attachInstances () { ]) .then(([registryAddress, netChain]) => { const registry = api.newContract(abis.registry, registryAddress).instance; - isTest = netChain === 'morden' || netChain === 'testnet'; + isTest = ['morden', 'ropsten', 'testnet'].includes(netChain); console.log(`contract was found at registry=${registryAddress}`); console.log(`running on ${netChain}, isTest=${isTest}`); diff --git a/js/src/dapps/dappreg.html b/js/src/dapps/dappreg.html new file mode 100644 index 000000000..89c95c472 --- /dev/null +++ b/js/src/dapps/dappreg.html @@ -0,0 +1,17 @@ + + + + + + + + Dapp Registry + + +
+ + + + + + diff --git a/js/src/dapps/dappreg.js b/js/src/dapps/dappreg.js new file mode 100644 index 000000000..243576a34 --- /dev/null +++ b/js/src/dapps/dappreg.js @@ -0,0 +1,35 @@ +// 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 . + +import React from 'react'; +import ReactDOM from 'react-dom'; +import injectTapEventPlugin from 'react-tap-event-plugin'; +import { useStrict } from 'mobx'; + +injectTapEventPlugin(); +useStrict(true); + +import Application from './dappreg/Application'; + +import '../../assets/fonts/Roboto/font.css'; +import '../../assets/fonts/RobotoMono/font.css'; +import './style.css'; +import './dappreg.html'; + +ReactDOM.render( + , + document.querySelector('#container') +); diff --git a/js/src/dapps/dappreg/Application/application.css b/js/src/dapps/dappreg/Application/application.css new file mode 100644 index 000000000..f171d8127 --- /dev/null +++ b/js/src/dapps/dappreg/Application/application.css @@ -0,0 +1,58 @@ +/* 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 . +*/ + +.body { + color: #333; + background: #eee; + padding: 4.5em 0; + text-align: center; +} + +.apps { + background: #fff; + border-radius: 0.5em; + margin: 0 auto; + max-width: 980px; + padding: 1.5em; + text-align: left; +} + +.footer { + font-size: 0.75em; + margin: 1em; + padding: 1.5em; + text-align: center; +} + +.header { + background: #44e; + border-radius: 0 0 0.25em 0.25em; + color: #fff; + left: 0; + padding: 1em; + position: fixed; + right: 0; + top: 0; + z-index: 25; +} + +.loading { + text-align: center; + padding-top: 5em; + font-size: 2em; + color: #999; +} diff --git a/js/src/dapps/dappreg/Application/application.js b/js/src/dapps/dappreg/Application/application.js new file mode 100644 index 000000000..b5e4d5a97 --- /dev/null +++ b/js/src/dapps/dappreg/Application/application.js @@ -0,0 +1,64 @@ +// 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 . + +import React, { Component } from 'react'; +import { observer } from 'mobx-react'; + +import DappsStore from '../dappsStore'; + +import ButtonBar from '../ButtonBar'; +import Dapp from '../Dapp'; +import ModalDelete from '../ModalDelete'; +import ModalRegister from '../ModalRegister'; +import ModalUpdate from '../ModalUpdate'; +import SelectDapp from '../SelectDapp'; +import Warning from '../Warning'; +import styles from './application.css'; + +@observer +export default class Application extends Component { + dappsStore = DappsStore.instance(); + + render () { + if (this.dappsStore.isLoading) { + return ( +
+ Loading application +
+ ); + } + + return ( +
+
+ DAPP REGISTRY, a global view of distributed applications available on the network. Putting the puzzle together. +
+
+ + + +
+
+ { this.dappsStore.count } applications registered, { this.dappsStore.ownedCount } owned by user +
+ + + + +
+ ); + } +} diff --git a/js/src/views/Signer/components/RequestPendingWeb3/index.js b/js/src/dapps/dappreg/Application/index.js similarity index 94% rename from js/src/views/Signer/components/RequestPendingWeb3/index.js rename to js/src/dapps/dappreg/Application/index.js index f664b571c..236578226 100644 --- a/js/src/views/Signer/components/RequestPendingWeb3/index.js +++ b/js/src/dapps/dappreg/Application/index.js @@ -14,4 +14,4 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -export default from './RequestPendingWeb3'; +export default from './application'; diff --git a/js/src/dapps/dappreg/Button/button.css b/js/src/dapps/dappreg/Button/button.css new file mode 100644 index 000000000..a66736e46 --- /dev/null +++ b/js/src/dapps/dappreg/Button/button.css @@ -0,0 +1,38 @@ +/* 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 . +*/ + +.button { + background: #44e; + border: none; + border-radius: 0.25em; + color: #fff; + cursor: pointer; + font-size: 1em; + margin: 1em 0.375em; + opacity: 0.85; + padding: 0.75em 2em; + + &[disabled] { + opacity: 0.5; + cursor: default; + background: #aaa; + } + + &[data-warning="true"] { + background: #e44; + } +} diff --git a/js/src/dapps/dappreg/Button/button.js b/js/src/dapps/dappreg/Button/button.js new file mode 100644 index 000000000..1f3b67b4c --- /dev/null +++ b/js/src/dapps/dappreg/Button/button.js @@ -0,0 +1,52 @@ +// 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 . + +import React, { Component, PropTypes } from 'react'; + +import styles from './button.css'; + +export default class Button extends Component { + static propTypes = { + className: PropTypes.string, + disabled: PropTypes.bool, + label: PropTypes.string.isRequired, + warning: PropTypes.bool, + onClick: PropTypes.func.isRequired + } + + render () { + const { className, disabled, label, warning } = this.props; + const classes = `${styles.button} ${className}`; + + return ( + + ); + } + + onClick = (event) => { + if (this.props.disabled) { + return; + } + + this.props.onClick(event); + } +} diff --git a/js/src/views/Signer/components/RequestFinishedWeb3/index.js b/js/src/dapps/dappreg/Button/index.js similarity index 93% rename from js/src/views/Signer/components/RequestFinishedWeb3/index.js rename to js/src/dapps/dappreg/Button/index.js index bcf7341bb..f69a65e3d 100644 --- a/js/src/views/Signer/components/RequestFinishedWeb3/index.js +++ b/js/src/dapps/dappreg/Button/index.js @@ -14,4 +14,4 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -export default from './RequestFinishedWeb3'; +export default from './button'; diff --git a/js/src/dapps/dappreg/ButtonBar/buttonBar.css b/js/src/dapps/dappreg/ButtonBar/buttonBar.css new file mode 100644 index 000000000..0aa84ee29 --- /dev/null +++ b/js/src/dapps/dappreg/ButtonBar/buttonBar.css @@ -0,0 +1,21 @@ +/* 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 . +*/ + +.buttonbar { + text-align: center; + margin: 1em 0 0 0; +} diff --git a/js/src/dapps/dappreg/ButtonBar/buttonBar.js b/js/src/dapps/dappreg/ButtonBar/buttonBar.js new file mode 100644 index 000000000..289def0ea --- /dev/null +++ b/js/src/dapps/dappreg/ButtonBar/buttonBar.js @@ -0,0 +1,101 @@ +// 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 . + +import React, { Component } from 'react'; +import { observer } from 'mobx-react'; + +import DappsStore from '../dappsStore'; +import ModalStore from '../modalStore'; + +import Button from '../Button'; +import styles from './buttonBar.css'; + +@observer +export default class ButtonBar extends Component { + dappsStore = DappsStore.instance(); + modalStore = ModalStore.instance(); + + render () { + let buttons = []; + + if (this.dappsStore.isEditing || this.dappsStore.isNew) { + buttons = [ +