diff --git a/.gitignore b/.gitignore index 4caeb6cc533a35a4f14e5b4ca8e038fe6f60b61b..d9ba8ac2b411f21befe040b38e08732c5ead9d28 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ node/runtime/wasm/target/ polkadot.* .DS_Store .idea/ +nohup.out +rls*.log +*.orig +*.rej diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 12c019b3e260a66280a2d7dd9bba8e1545366f87..f4f42ef49ae1dda63a300a450f80ea5cc220bbc3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,9 @@ # .gitlab-ci.yml - +# +# substrate +# +# pipelines can be triggered manually in the web +# setting DEPLOY_TAG will only deploy the tagged image stages: @@ -22,7 +26,7 @@ variables: cache: {} -.collect_artifacts: &collect_artifacts +.collect-artifacts: &collect-artifacts artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" when: on_success @@ -32,7 +36,7 @@ cache: {} -.kubernetes_build: &kubernetes_build +.kubernetes-build: &kubernetes-build tags: - kubernetes-parity-build environment: @@ -42,11 +46,11 @@ cache: {} #### stage: merge-test -check:merge:conflict: +check-merge-conflict: stage: merge-test image: parity/tools:latest cache: {} - <<: *kubernetes_build + <<: *kubernetes-build only: - /^[0-9]+$/ variables: @@ -61,11 +65,11 @@ check:merge:conflict: #### stage: test -check:runtime: +check-runtime: stage: test image: parity/tools:latest cache: {} - <<: *kubernetes_build + <<: *kubernetes-build only: - /^[0-9]+$/ variables: @@ -77,10 +81,10 @@ check:runtime: -test:rust:stable: &test +test-linux-stable: &test stage: test cache: - key: "${CI_JOB_NAME}-test" + key: "${CI_JOB_NAME}" paths: - ${CARGO_HOME} - ./target @@ -98,6 +102,9 @@ test:rust:stable: &test - schedules - web - /^[0-9]+$/ + except: + variables: + - $DEPLOY_TAG before_script: - test -d ${CARGO_HOME} -a -d ./target && echo "build cache size:" && @@ -110,7 +117,7 @@ test:rust:stable: &test -.build_only: &build_only +.build-only: &build-only only: - master - tags @@ -119,15 +126,18 @@ test:rust:stable: &test #### stage: build -build:rust:linux:release: &build +build-linux-release: &build stage: build cache: - key: "${CI_JOB_NAME}-build" + key: "${CI_JOB_NAME}" paths: - ${CARGO_HOME} - ./target - <<: *collect_artifacts - <<: *build_only + <<: *collect-artifacts + <<: *build-only + except: + variables: + - $DEPLOY_TAG tags: - linux-docker before_script: @@ -151,7 +161,7 @@ build:rust:linux:release: &build -build:rust:doc:release: &build +build-rust-doc-release: &build stage: build allow_failure: true artifacts: @@ -160,12 +170,12 @@ build:rust:doc:release: &build expire_in: 7 days paths: - ./crate-docs - <<: *build_only + <<: *build-only tags: - linux-docker script: - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds - - time cargo doc --release --verbose + - time cargo +nightly doc --release --verbose - cp -R ./target/doc ./crate-docs - echo "" > ./crate-docs/index.html @@ -174,35 +184,38 @@ build:rust:doc:release: &build #### stage: publish -.publish_build: &publish_build +.publish-build: &publish-build stage: publish dependencies: - - build:rust:linux:release + - build-linux-release cache: {} - <<: *build_only - <<: *kubernetes_build + <<: *build-only + <<: *kubernetes-build -publish:docker:release: - <<: *publish_build +publish-docker-release: + <<: *publish-build image: docker:stable services: - docker:dind # collect VERSION artifact here to pass it on to kubernetes - <<: *collect_artifacts + <<: *collect-artifacts variables: DOCKER_HOST: tcp://localhost:2375 DOCKER_DRIVER: overlay2 GIT_STRATEGY: none # DOCKERFILE: scripts/docker/Dockerfile CONTAINER_IMAGE: parity/substrate - script: - - VERSION="$(cat ./artifacts/VERSION)" + before_script: - test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" || ( echo "no docker credentials provided"; exit 1 ) - docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity" - docker info + script: + - VERSION="$(cat ./artifacts/VERSION)" + - echo "Substrate version = ${VERSION}" + - test -z "${VERSION}" && exit 1 - cd ./artifacts - docker build --tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:latest . - docker push $CONTAINER_IMAGE:$VERSION @@ -215,8 +228,8 @@ publish:docker:release: -publish:s3:release: - <<: *publish_build +publish-s3-release: + <<: *publish-build image: parity/awscli:latest variables: GIT_STRATEGY: none @@ -237,14 +250,14 @@ publish:s3:release: -publish:s3:doc: +publish-s3-doc: stage: publish allow_failure: true dependencies: - - build:rust:doc:release + - build-rust-doc-release cache: {} - <<: *build_only - <<: *kubernetes_build + <<: *build-only + <<: *kubernetes-build variables: GIT_STRATEGY: none BUCKET: "releases.parity.io" @@ -264,20 +277,15 @@ publish:s3:doc: - - -.deploy:template: &deploy +.deploy-template: &deploy stage: deploy when: manual cache: {} - dependencies: - - publish:docker:release retry: 1 image: parity/kubectl-helm:$HELM_VERSION - <<: *build_only - # variables: - # DEPLOY_TAG: "latest" + <<: *build-only tags: + # this is the runner that is used to deploy it - kubernetes-parity-build before_script: - test -z "${DEPLOY_TAG}" && @@ -292,28 +300,56 @@ publish:s3:doc: --set image.tag=${DEPLOY_TAG} --set validator.keys=${VALIDATOR_KEYS} ./scripts/kubernetes | kubectl apply -f - --dry-run=false - - echo "# substrate namespace" - - kubectl -n substrate get all + - echo "# substrate namespace ${KUBE_NAMESPACE}" + - kubectl -n ${KUBE_NAMESPACE} get all - echo "# substrate's nodes' external ip addresses:" - kubectl get nodes -l node=substrate -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{range @.status.addresses[?(@.type=="ExternalIP")]}{.address}{"\n"}{end}' - echo "# substrate' nodes" - - kubectl -n substrate get pods + - kubectl -n ${KUBE_NAMESPACE} get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}' + - echo "# wait for the rollout to complete" + - kubectl -n ${KUBE_NAMESPACE} rollout status statefulset/substrate # have environment:url eventually point to the logs -deploy:ew3: + +.deploy-cibuild: &deploy-cibuild + <<: *deploy + dependencies: + - publish-docker-release + +.deploy-tag: &deploy-tag <<: *deploy + only: + variables: + - $DEPLOY_TAG + + + +# have environment:url eventually point to the logs +deploy-ew3: + <<: *deploy-cibuild environment: name: parity-prod-ew3 -deploy:ue1: - <<: *deploy +deploy-ue1: + <<: *deploy-cibuild environment: name: parity-prod-ue1 +deploy-ew3-tag: + <<: *deploy-tag + environment: + name: parity-prod-ew3 + +deploy-ue1-tag: + <<: *deploy-tag + environment: + name: parity-prod-ue1 + + diff --git a/CODE_OF_CONDUCT.adoc b/CODE_OF_CONDUCT.adoc index 811e83e9fa973d4a35d791beebafc37602ba18c1..7cb0210e8efac2575e23bd46a000af59bb36cb3e 100644 --- a/CODE_OF_CONDUCT.adoc +++ b/CODE_OF_CONDUCT.adoc @@ -24,7 +24,7 @@ Examples of unacceptable behavior by participants include: === Facilitation, Not Strongarming -We recognise that this software is merely a tool for users to create and maintain their blockchain of preference. We see that blockchains are naturally community platforms with users being the ultimate decision makers. We assert that good software will maximise user agency by facilitate user-expression on the network. As such: +We recognize that this software is merely a tool for users to create and maintain their blockchain of preference. We see that blockchains are naturally community platforms with users being the ultimate decision makers. We assert that good software will maximize user agency by facilitate user-expression on the network. As such: * This project will strive to give users as much choice as is both reasonable and possible over what protocol they adhere to; but * use of the project's technical forums, commenting systems, pull requests and issue trackers as a means to express individual protocol preferences is forbidden. diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 30bf3a1bb2cb63e2988d041f3304677d6b563a27..b797e72e82b542fa06724a0d0eceaa7a92b6e779 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -33,10 +33,10 @@ Merging pull requests once CI is successful: When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in: -. Buggy behaviour. +. Buggy behavior. . Undue maintenance burden. . Breaking with house coding style. -. Pessimisation (i.e. reduction of speed as measured in the projects benchmarks). +. Pessimization (i.e. reduction of speed as measured in the projects benchmarks). . Feature reduction (i.e. it removes some aspect of functionality that a significant minority of users rely on). . Uselessness (i.e. it does not strictly add a feature or fix a known issue). @@ -47,7 +47,7 @@ When reviewing a pull request, the end-goal is to suggest useful changes to the == Helping out -We use https://github.com/paritytech/substrate/labels[labels] to manage PRs and issues and communicate state of a PR. Please familiarize yourself with them. Further more we are organising issues in https://github.com/paritytech/substrate/milestones[milestones]. Best way to get started is to a pick a ticket from the current milestone tagged https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ2-easy[`easy`] or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ3-medium[`medium`] and get going or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AX1-mentor[`mentor`] and get in contact with the mentor offering their support on that larger task. +We use https://github.com/paritytech/substrate/labels[labels] to manage PRs and issues and communicate state of a PR. Please familiarize yourself with them. Furthermore we are organizing issues in https://github.com/paritytech/substrate/milestones[milestones]. Best way to get started is to a pick a ticket from the current milestone tagged https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ2-easy[`easy`] or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ3-medium[`medium`] and get going or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AX1-mentor[`mentor`] and get in contact with the mentor offering their support on that larger task. == Releases diff --git a/Cargo.lock b/Cargo.lock index 7b7cdd902113b6ede422005384128f8bc6840338..9666ce55eaad5c37e4731118f2915258df49ae9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,7 +136,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -194,11 +194,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -212,6 +212,11 @@ name = "bitflags" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitmask" +version = "0.5.0" +source = "git+https://github.com/paritytech/bitmask#c2d8d196e30b018d1385be8357fdca61b978facf" + [[package]] name = "blake2" version = "0.8.0" @@ -325,7 +330,7 @@ dependencies = [ [[package]] name = "cfg-if" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -420,7 +425,7 @@ dependencies = [ "criterion-plot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -448,12 +453,12 @@ name = "crossbeam" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -491,9 +496,9 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -505,9 +510,9 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -517,7 +522,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -525,8 +530,8 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -692,7 +697,7 @@ dependencies = [ [[package]] name = "environmental" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -753,7 +758,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -793,7 +798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "fork-tree" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -801,7 +806,7 @@ name = "fs-swap" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -898,17 +903,26 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "heapsize" version = "0.4.2" @@ -1058,7 +1072,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1161,7 +1175,7 @@ dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1190,11 +1204,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "keccak-hasher" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1248,7 +1262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1272,29 +1286,29 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-websocket 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1307,34 +1321,42 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "multistream-select 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core-derive" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1343,11 +1365,11 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1356,7 +1378,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1364,7 +1386,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1375,13 +1397,13 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1396,18 +1418,19 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1424,13 +1447,13 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1445,13 +1468,13 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1461,28 +1484,31 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curve25519-dalek 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1495,22 +1521,22 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1518,23 +1544,22 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "stdweb 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1545,11 +1570,11 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1559,11 +1584,11 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1571,14 +1596,14 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "stdweb 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.22.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1586,14 +1611,14 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "yamux 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "yamux 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1661,7 +1686,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1687,7 +1712,7 @@ name = "memchr" version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1698,10 +1723,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memory-db" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1782,7 +1807,7 @@ dependencies = [ [[package]] name = "multistream-select" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1807,7 +1832,7 @@ name = "native-tls" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1824,7 +1849,7 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1836,7 +1861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1852,8 +1877,7 @@ dependencies = [ "node-executor 0.1.0", "node-primitives 0.1.0", "node-runtime 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1879,13 +1903,12 @@ version = "0.1.0" dependencies = [ "node-primitives 0.1.0", "node-runtime 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "srml-balances 0.1.0", "srml-consensus 0.1.0", "srml-contract 0.1.0", - "srml-fees 0.1.0", "srml-grandpa 0.1.0", "srml-indices 0.1.0", "srml-session 0.1.0", @@ -1899,7 +1922,7 @@ dependencies = [ "substrate-primitives 0.1.0", "substrate-state-machine 0.1.0", "substrate-trie 0.4.0", - "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1907,7 +1930,7 @@ dependencies = [ name = "node-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1925,7 +1948,7 @@ dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1939,7 +1962,6 @@ dependencies = [ "srml-council 0.1.0", "srml-democracy 0.1.0", "srml-executive 0.1.0", - "srml-fees 0.1.0", "srml-finality-tracker 0.1.0", "srml-grandpa 0.1.0", "srml-indices 0.1.0", @@ -1950,10 +1972,11 @@ dependencies = [ "srml-system 0.1.0", "srml-timestamp 0.1.0", "srml-treasury 0.1.0", - "srml-upgrade-key 0.1.0", "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", + "substrate-consensus-authorities 0.1.0", "substrate-keyring 0.1.0", + "substrate-offchain-primitives 0.1.0", "substrate-primitives 0.1.0", ] @@ -1967,11 +1990,9 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "node-executor 0.1.0", "node-template-runtime 0.9.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "substrate-basic-authorship 0.1.0", "substrate-cli 0.3.0", @@ -1984,7 +2005,7 @@ dependencies = [ "substrate-service 0.3.0", "substrate-transaction-pool 0.1.0", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1992,7 +2013,7 @@ dependencies = [ name = "node-template-runtime" version = "0.9.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2004,7 +2025,6 @@ dependencies = [ "srml-balances 0.1.0", "srml-consensus 0.1.0", "srml-executive 0.1.0", - "srml-fees 0.1.0", "srml-indices 0.1.0", "srml-sudo 0.1.0", "srml-support 0.1.0", @@ -2012,6 +2032,8 @@ dependencies = [ "srml-timestamp 0.1.0", "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", + "substrate-consensus-authorities 0.1.0", + "substrate-offchain-primitives 0.1.0", "substrate-primitives 0.1.0", ] @@ -2068,6 +2090,9 @@ dependencies = [ name = "once_cell" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "opaque-debug" @@ -2080,9 +2105,9 @@ version = "0.10.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2126,7 +2151,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2290,6 +2315,16 @@ dependencies = [ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pbkdf2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -2567,7 +2602,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2634,7 +2669,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2644,7 +2679,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2697,7 +2732,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2736,13 +2771,13 @@ name = "schannel" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "schnorrkel" -version = "0.0.0" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2752,6 +2787,7 @@ dependencies = [ "merlin 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2915,7 +2951,7 @@ version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2970,10 +3006,10 @@ dependencies = [ name = "sr-io" version = "0.1.0" dependencies = [ - "environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -2989,7 +3025,7 @@ dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3003,7 +3039,7 @@ name = "sr-sandbox" version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -3023,7 +3059,7 @@ name = "sr-version" version = "0.1.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -3035,7 +3071,7 @@ name = "srml-assets" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3050,8 +3086,9 @@ name = "srml-aura" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3072,7 +3109,7 @@ name = "srml-balances" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3089,7 +3126,7 @@ name = "srml-consensus" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3107,7 +3144,7 @@ version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3118,7 +3155,6 @@ dependencies = [ "sr-std 0.1.0", "srml-balances 0.1.0", "srml-consensus 0.1.0", - "srml-fees 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "srml-timestamp 0.1.0", @@ -3131,7 +3167,7 @@ name = "srml-council" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3150,7 +3186,7 @@ name = "srml-democracy" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3168,7 +3204,7 @@ name = "srml-example" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3183,51 +3219,32 @@ name = "srml-executive" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-balances 0.1.0", - "srml-fees 0.1.0", "srml-indices 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-primitives 0.1.0", ] -[[package]] -name = "srml-fees" -version = "0.1.0" -dependencies = [ - "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", - "sr-primitives 0.1.0", - "sr-std 0.1.0", - "srml-support 0.1.0", - "srml-system 0.1.0", - "substrate-primitives 0.1.0", -] - [[package]] name = "srml-finality-tracker" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-session 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-inherents 0.1.0", @@ -3238,12 +3255,13 @@ dependencies = [ name = "srml-grandpa" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", + "srml-consensus 0.1.0", "srml-finality-tracker 0.1.0", "srml-session 0.1.0", "srml-support 0.1.0", @@ -3257,7 +3275,7 @@ name = "srml-indices" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3275,7 +3293,7 @@ dependencies = [ name = "srml-metadata" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -3287,7 +3305,8 @@ name = "srml-session" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3306,7 +3325,7 @@ name = "srml-staking" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3327,7 +3346,7 @@ name = "srml-sudo" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3343,9 +3362,10 @@ dependencies = [ name = "srml-support" version = "0.1.0" dependencies = [ + "bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3389,12 +3409,25 @@ dependencies = [ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "srml-support-test" +version = "0.1.0" +dependencies = [ + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 0.1.0", + "srml-support 0.1.0", + "substrate-inherents 0.1.0", + "substrate-primitives 0.1.0", +] + [[package]] name = "srml-system" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3410,12 +3443,11 @@ name = "srml-timestamp" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-consensus 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-inherents 0.1.0", @@ -3427,7 +3459,7 @@ name = "srml-treasury" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3439,19 +3471,6 @@ dependencies = [ "substrate-primitives 0.1.0", ] -[[package]] -name = "srml-upgrade-key" -version = "0.1.0" -dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 0.1.0", - "sr-std 0.1.0", - "srml-consensus 0.1.0", - "srml-support 0.1.0", - "srml-system 0.1.0", -] - [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -3549,18 +3568,39 @@ dependencies = [ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "strum" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "strum_macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "subkey" -version = "0.1.0" +version = "0.2.0" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "substrate-primitives 0.1.0", + "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate" -version = "0.10.0" +version = "0.11.0" dependencies = [ "ctrlc 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3574,17 +3614,29 @@ name = "substrate-basic-authorship" version = "0.1.0" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", "substrate-consensus-common 0.1.0", "substrate-inherents 0.1.0", "substrate-primitives 0.1.0", + "substrate-telemetry 0.3.1", "substrate-test-client 0.1.0", "substrate-transaction-pool 0.1.0", ] +[[package]] +name = "substrate-bip39" +version = "0.2.0" +source = "git+https://github.com/paritytech/substrate-bip39#080da45923885cfec2379cef3dee4e7f43e6c260" +dependencies = [ + "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "substrate-cli" version = "0.3.0" @@ -3598,13 +3650,15 @@ dependencies = [ "exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client 0.1.0", + "substrate-keyring 0.1.0", "substrate-network 0.1.0", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", @@ -3612,6 +3666,7 @@ dependencies = [ "substrate-state-machine 0.1.0", "substrate-telemetry 0.3.1", "sysinfo 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3623,13 +3678,13 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 0.1.0", "sr-primitives 0.1.0", @@ -3651,16 +3706,17 @@ name = "substrate-client-db" version = "0.1.0" dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", + "substrate-consensus-common 0.1.0", "substrate-executor 0.1.0", "substrate-keyring 0.1.0", "substrate-primitives 0.1.0", @@ -3678,7 +3734,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3689,6 +3745,7 @@ dependencies = [ "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", "substrate-consensus-aura-slots 0.1.0", + "substrate-consensus-authorities 0.1.0", "substrate-consensus-common 0.1.0", "substrate-executor 0.1.0", "substrate-inherents 0.1.0", @@ -3705,6 +3762,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "0.1.0" dependencies = [ + "sr-primitives 0.1.0", "substrate-client 0.1.0", ] @@ -3715,7 +3773,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", @@ -3726,6 +3784,20 @@ dependencies = [ "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "substrate-consensus-authorities" +version = "0.1.0" +dependencies = [ + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 0.1.0", + "sr-primitives 0.1.0", + "sr-std 0.1.0", + "sr-version 0.1.0", + "srml-support 0.1.0", + "substrate-client 0.1.0", + "substrate-primitives 0.1.0", +] + [[package]] name = "substrate-consensus-common" version = "0.1.0" @@ -3733,8 +3805,9 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-version 0.1.0", @@ -3752,7 +3825,7 @@ dependencies = [ "exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rhododendron 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3777,10 +3850,10 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3805,7 +3878,7 @@ dependencies = [ "fork-tree 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -3827,7 +3900,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", "substrate-client 0.1.0", @@ -3838,7 +3911,7 @@ dependencies = [ name = "substrate-inherents" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -3849,7 +3922,9 @@ name = "substrate-keyring" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 0.1.0", ] @@ -3883,7 +3958,7 @@ dependencies = [ "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3892,6 +3967,7 @@ dependencies = [ "substrate-consensus-common 0.1.0", "substrate-keyring 0.1.0", "substrate-network-libp2p 0.1.0", + "substrate-peerset 0.1.0", "substrate-primitives 0.1.0", "substrate-test-client 0.1.0", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3906,8 +3982,8 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3915,6 +3991,8 @@ dependencies = [ "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-peerset 0.1.0", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3922,6 +4000,33 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "substrate-offchain" +version = "0.1.0" +dependencies = [ + "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 0.1.0", + "substrate-client 0.1.0", + "substrate-consensus-common 0.1.0", + "substrate-inherents 0.1.0", + "substrate-offchain-primitives 0.1.0", + "substrate-primitives 0.1.0", + "substrate-test-client 0.1.0", + "substrate-transaction-pool 0.1.0", + "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "substrate-offchain-primitives" +version = "0.1.0" +dependencies = [ + "sr-primitives 0.1.0", + "substrate-client 0.1.0", +] + [[package]] name = "substrate-panic-handler" version = "0.1.0" @@ -3930,6 +4035,22 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "substrate-peerset" +version = "0.1.0" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "substrate-primitives" version = "0.1.0" @@ -3937,23 +4058,27 @@ dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "substrate-serializer 0.1.0", + "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3971,12 +4096,13 @@ dependencies = [ "jsonrpc-derive 10.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-version 0.1.0", "substrate-client 0.1.0", @@ -3986,6 +4112,7 @@ dependencies = [ "substrate-primitives 0.1.0", "substrate-state-machine 0.1.0", "substrate-test-client 0.1.0", + "substrate-test-runtime 0.1.0", "substrate-transaction-pool 0.1.0", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4018,9 +4145,9 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4032,8 +4159,10 @@ dependencies = [ "substrate-client-db 0.1.0", "substrate-consensus-common 0.1.0", "substrate-executor 0.1.0", + "substrate-inherents 0.1.0", "substrate-keystore 0.1.0", "substrate-network 0.1.0", + "substrate-offchain 0.1.0", "substrate-primitives 0.1.0", "substrate-rpc-servers 0.1.0", "substrate-telemetry 0.3.1", @@ -4067,7 +4196,7 @@ version = "0.1.0" dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 0.1.0", ] @@ -4076,24 +4205,24 @@ dependencies = [ name = "substrate-state-machine" version = "0.1.0" dependencies = [ - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", "substrate-trie 0.4.0", - "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-telemetry" version = "0.3.1" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4111,7 +4240,7 @@ name = "substrate-test-client" version = "0.1.0" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", "substrate-client-db 0.1.0", @@ -4127,23 +4256,27 @@ dependencies = [ name = "substrate-test-runtime" version = "0.1.0" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "sr-version 0.1.0", + "srml-executive 0.1.0", "srml-support 0.1.0", "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", + "substrate-consensus-authorities 0.1.0", "substrate-executor 0.1.0", "substrate-inherents 0.1.0", "substrate-keyring 0.1.0", + "substrate-offchain-primitives 0.1.0", "substrate-primitives 0.1.0", + "substrate-test-client 0.1.0", ] [[package]] @@ -4151,14 +4284,16 @@ name = "substrate-transaction-graph" version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", + "substrate-primitives 0.1.0", "substrate-test-runtime 0.1.0", ] @@ -4169,7 +4304,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", @@ -4184,16 +4319,16 @@ name = "substrate-trie" version = "0.4.0" dependencies = [ "criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 0.1.0", - "trie-bench 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-bench 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4232,7 +4367,7 @@ name = "sysinfo" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4262,7 +4397,7 @@ name = "tempfile" version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4301,7 +4436,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4314,6 +4449,20 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tiny-bip39" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tiny-keccak" version = "1.4.2" @@ -4391,7 +4540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4431,7 +4580,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4546,46 +4695,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trie-bench" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trie-db" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trie-root" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trie-standardmap" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4608,7 +4757,7 @@ name = "twox-hash" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4903,6 +5052,16 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "x25519-dalek" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "xdg" version = "2.2.0" @@ -4915,7 +5074,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "yamux" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4929,6 +5088,11 @@ dependencies = [ "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zeroize" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" @@ -4954,6 +5118,7 @@ dependencies = [ "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bindgen 0.43.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d52d263eacd15d26cbcf215d254b410bd58212aaa2d3c453a04b2d3b3adcf41" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)" = "" "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" @@ -4969,7 +5134,7 @@ dependencies = [ "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" "checksum cexpr 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "644d693ecfa91955ed32dcc7eda4914e1be97a641fb6f0645a37348e20b230da" -"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" +"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -5009,7 +5174,7 @@ dependencies = [ "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" "checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" -"checksum environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db746025e3ea695bfa0ae744dbacd5fcfc8db51b9760cf8bd0ab69708bb93c49" +"checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "87559b08e99a81a92bbb867d237543e43495857749f688e0773390a20d56c61c" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" @@ -5033,8 +5198,9 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4743617a7464bbda3c8aec8558ff2f9429047e025771037df561d383337ff865" "checksum h2 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddb2b25a33e231484694267af28fec74ac63b5ccf51ee2065a5e313b834d836e" -"checksum hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03501f6e1a2a97f1618879aba3156f14ca2847faa530c4e28859638bd11483" -"checksum hash256-std-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5c13dbac3cc50684760f54af18545c9e80fb75e93a3e586d71ebdc13138f6a4" +"checksum hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07463834729d0ce8d475e7dd6d302e407093ad9a9c02d77eb07fb74b5373829d" +"checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" +"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" @@ -5064,34 +5230,34 @@ dependencies = [ "checksum jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5521613b31ea22d36d9f95ad642058dccec846a94ed8690957652d479f620707" "checksum jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20b8333a5a6e6ccbcf5c90f90919de557cba4929efa164e9bd0e8e497eb20e46" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -"checksum keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9d3670023f4c04153d90b8a557a822d1b27ed702bb015a87cf7bffead5b611" +"checksum keccak-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a02fb74dc1b613522069b5f2023c014756ce121c6c6fb39364c139b0efc39a2d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum libp2p 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395d54c4c96fa175eabf4505e8a7bd616d916fa49fa27c60ceaa6d5d9b51bc" -"checksum libp2p-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c8dc95c7fda9de223bc195b637290918e8decb18e63fd3d03005f84b8ce380b" -"checksum libp2p-core-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e9ff3bb639d0be41e1aff9d0d28715e54474e4d15e43aa4865bdec44867d8d3" -"checksum libp2p-dns 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d310aa56671539a2bce6124cf4326482278b0d0b841c3ba1514e44d8597096" -"checksum libp2p-floodsub 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8256d778f0dc087be409d8cbd081a11bc41ea27ddcd4862814e50e8cfa9c6df0" -"checksum libp2p-identify 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d128febfc8fe57b597e627f545bafea43ae009bf85cc9480b583996f244ab685" -"checksum libp2p-kad 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0691fcca7648369798c6466c61139d31dbb7e2afad311e44fcc4e220ce1e4d78" -"checksum libp2p-mdns 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63289f296e39752180d8a45e024cc38d1028a6db41deab3943ff2ccb9d1224cd" -"checksum libp2p-mplex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "791e375a6a230568f0d8f56f6236403de8e4bf4bd870c3c5f605fd1778da70b2" -"checksum libp2p-noise 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70d28b0ca9eb9818d45e037b4a8a0915553c5c1f8d878d8d6170f60451ad37d2" -"checksum libp2p-ping 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53db5fafd4ca0a32f339371198196795b8e14d8ecb360d8d03ada03299c12a10" -"checksum libp2p-plaintext 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4383404cba7e4483e0b7d78b3ac5e66f8b024233a5095df9da65d5a1e975d692" -"checksum libp2p-ratelimit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bad4fe925d50cc886608ab3b3a7a962b5064ecc49db8b66fd063a950d469c757" -"checksum libp2p-secio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f9a7641a314d54ad7797f0445685818edb4d3c2f21690cea900f12ea73501b" -"checksum libp2p-tcp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4625bedbb083d676903a8ede4c5c42f9bf7bd5dee788f3cba29d8e01b785d253" -"checksum libp2p-uds 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac5f5d900e381b02ebea2f0621555a2f25a7735772355291aeb70fd9e0da3692" -"checksum libp2p-websocket 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96b6dfdd776a248d7494aeaf22f149b4d5f6784146546bc34f7b094c7162e141" -"checksum libp2p-yamux 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5a6197ae647c963f5a711c6fb00ba07b9a2812df26f6284870221f654fe9313" +"checksum libp2p 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5b9cd37b1ca54fa2fd0bbf0486adf2f55f8994f2be9410b65265050b24709b2" +"checksum libp2p-core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf9c56e6f04cb649fdeb806e963d2da223e3ed17748d9e924fdb836c09f76307" +"checksum libp2p-core-derive 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "debea88a3d5de9fdaf7082bd6d238f2c4c6a0420f14bdf9e1c1083b3e7c69286" +"checksum libp2p-dns 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350d0018af3668d954f61ce7311e7d64ab7c40f19a8eb895e4750efe24c3455f" +"checksum libp2p-floodsub 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bfbcf36cc58ad5d0252d8ebe9c1a87190693fe2cdbe40fb01d8046779f9a75ad" +"checksum libp2p-identify 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82e98435973e958d7dea3f5074d7fca53d0dfce2e1ac6924119a21c2991fe443" +"checksum libp2p-kad 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92bb0153418eaf0ea549008d1e22748a956c9c36af9374fbe7189d44607c14be" +"checksum libp2p-mdns 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc915d0cde68a05d26a0dcb125eddce7dd2a425e97c5172ac300c1ee8716f55a" +"checksum libp2p-mplex 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "355bb370dd12809792dc020638b280e7aaf8625318018abd311c51affd0a612d" +"checksum libp2p-noise 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e86291401f4a83f9fa81c03f8a7ccf0b03ce6aaa40cba058a7ec1026a65a6fe4" +"checksum libp2p-ping 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3277f1f7eaadf5cdde6a76fb4afbf24e0eda6e2b04f288f526c6fa2e4293a6e" +"checksum libp2p-plaintext 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4842a7ab54c12459b58b9e59cbeb03e3e1fd393fef48079472856f934352772" +"checksum libp2p-ratelimit 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32ba52ee76aaa94af533526ce5a22fbfcc69a560174fccee82f4cdb557411d33" +"checksum libp2p-secio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00f416e1e3d0214bd7df2be2b6be8ef61771d44292b973c9e02bfbbd7f62fe46" +"checksum libp2p-tcp 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af47af9997d69fc70aa13e6e7cd0d766614ebe74005e69e763221a64d9a0a5ef" +"checksum libp2p-uds 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa72d81501aad6998d3b1b964f68f438ef99c3aaf54d921e144e0477fa87568" +"checksum libp2p-websocket 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "647bd8862afe6e912eb34b7614f731c0ff89e8777b57d9f2f5f0fd593ecc8d9a" +"checksum libp2p-yamux 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbb8d08cb536a964727e77b868a026c6d92993f08e387d49163565575a478d9" "checksum librocksdb-sys 5.14.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b9024327233e7fac7982440f73301c00046d438c5b1011e8f4e394226ce19007" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" @@ -5105,7 +5271,7 @@ dependencies = [ "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94da53143d45f6bad3753f532e56ad57a6a26c0ca6881794583310c7cb4c885f" +"checksum memory-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dd87d4d64f7b86d8804bbb419f8ecb187cb8f40a50e91c72848075c604ba88d" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum merlin 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a9e97b439f6d38cbe2a4a4aa93f6770c5305f62761b78b1851406c09c87ee2a" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" @@ -5113,7 +5279,7 @@ dependencies = [ "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multistream-select 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ed84364f0e921a32204896952ee80c7befc14a7a39f2c56cd955d71e8dae6" +"checksum multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f989d40aab0ed0d83c1cdb4856b5790e980b96548d1a921f280e985eb049f38d" "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" @@ -5133,7 +5299,7 @@ dependencies = [ "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" -"checksum parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b9db194dfbcfe3b398d63d765437a5c7232d59906e203055f0e993f6458ff1" "checksum parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61ae6944d4435d41f4d0f12108c5cbb9207cbb14bc8f2b4984c6e930dc9c8e41" @@ -5148,6 +5314,7 @@ dependencies = [ "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f50392d1265092fbee9273414cc40eb6d47d307bd66222c477bb8450c8504f9d" "checksum paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3cd512fe3a55e8933b2dcad913e365639db86d512e4004c3084b86864d9467a" +"checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" @@ -5196,13 +5363,13 @@ dependencies = [ "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rw-stream-sink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "108ad7c3d65ba866ec50a224b7b3b0cb6c682c3d805015cea859d491232346a5" +"checksum rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d548a40fe17c3a77d54b82457b79fcc9b8a288d509ca20fbf5aa1dac386d22d6" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaccd3a23619349e0878d9a241f34b1982343cdf67367058cd7d078d326b63e" "checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05" @@ -5237,6 +5404,9 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" +"checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" +"checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" @@ -5251,6 +5421,7 @@ dependencies = [ "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1415431cb2398d84da64173f8473c792808314427d4a6f2f3ea85ae67239fe3" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" "checksum tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7655088894274afb52b807bd3c87072daa1fedd155068b8705cabfd628956115" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" @@ -5271,10 +5442,10 @@ dependencies = [ "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" -"checksum trie-bench 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77087d1bce467cf8371a5c0e10e4d925b065ec6cfad8b9cdff1fad4f218c6750" -"checksum trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7319e28ca295f27359d944a682f7f65b419158bf1590c92cadc0000258d788" -"checksum trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c6fef2705af3258ec46a7e22286090394a44216201a1cf7d04b78db825e543" -"checksum trie-standardmap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4729504b8102acb1bef3f16e6b64d41aeb1ff0e329081451e8191df0f61ab2" +"checksum trie-bench 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eafa32a8662c06f5bf135984bc1a12821fd38770b5c2f2f9e8750327fcbe3955" +"checksum trie-db 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "843af112ba3a8c919cd961edf3cac9272353f5e277ad8678c7023fa70e5c0e2d" +"checksum trie-root 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e45632ecaf2b8b4a40b5208383cd659b4e66f58ccd40086467a4614b45781430" +"checksum trie-standardmap 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006314f54f2ea7944a878e66fd93ad7978095bc355f30a2f26ec40f664d86c86" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" "checksum twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "555cd4909480122bbbf21e34faac4cb08a171f324775670447ed116726c474af" @@ -5315,6 +5486,8 @@ dependencies = [ "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +"checksum x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4aca1ba6bec2719576bd20dfe5b24d9359552e616d10bff257e50cd85f745d17" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" -"checksum yamux 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "2269402a82beb59192319ad64a199850b6dcf3a14ef941206cdad3d7b9cfb598" +"checksum yamux 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "302defd1bed8a9a6d43b82f0e5a50510dfdfbbd02c270c93ff9d6f3f5e2dea89" +"checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" diff --git a/Cargo.toml b/Cargo.toml index 699f9a158981f0b98c9e511cb81b95892343da1b..b6eac3e381e075e69c457d732a353b287023b16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ path = "node/src/main.rs" [package] name = "substrate" -version = "0.10.0" +version = "0.11.0" authors = ["Parity Technologies "] build = "build.rs" edition = "2018" @@ -57,6 +57,7 @@ members = [ "srml/support/procedural", "srml/support/procedural/tools", "srml/support/procedural/tools/derive", + "srml/support/test", "srml/assets", "srml/aura", "srml/balances", @@ -66,7 +67,6 @@ members = [ "srml/democracy", "srml/example", "srml/executive", - "srml/fees", "srml/finality-tracker", "srml/grandpa", "srml/indices", @@ -77,7 +77,6 @@ members = [ "srml/system", "srml/timestamp", "srml/treasury", - "srml/upgrade-key", "node/cli", "node/executor", "node/primitives", @@ -101,3 +100,4 @@ is-it-maintained-open-issues = { repository = "paritytech/substrate" } [profile.release] # Substrate runtime requires unwinding. panic = "unwind" + diff --git a/README.adoc b/README.adoc index 4c3fdaf6cc63389052aa8862068426461c8baa82..92a5418170fb961f69424645d8bdb0b3626e7322 100644 --- a/README.adoc +++ b/README.adoc @@ -10,9 +10,9 @@ Substrate is a next-generation framework for blockchain innovation. == Description -At its heart, Substrate is a combination of three technologies: https://webassembly.org/[WebAssembly], https://libp2p.io/[Libp2p] and GRANDPA Consensus. About GRANDPA, see this https://hackmd.io/Jd0byWX0RiqFiXUVC78Bdw?view#GRANDPA[definition], https://medium.com/polkadot-network/grandpa-block-finality-in-polkadot-an-introduction-part-1-d08a24a021b5[introduction] and https://github.com/w3f/consensus/blob/master/pdf/grandpa.pdf[formal specification]. It is both a library for building new blockchains and a "skeleton key" of a blockchain client, able to synchronise to any Substrate-based chain. +At its heart, Substrate is a combination of three technologies: https://webassembly.org/[WebAssembly], https://libp2p.io/[Libp2p] and GRANDPA Consensus. About GRANDPA, see this https://hackmd.io/Jd0byWX0RiqFiXUVC78Bdw?view#GRANDPA[definition], https://medium.com/polkadot-network/grandpa-block-finality-in-polkadot-an-introduction-part-1-d08a24a021b5[introduction] and https://github.com/w3f/consensus/blob/master/pdf/grandpa.pdf[formal specification]. It is both a library for building new blockchains and a "skeleton key" of a blockchain client, able to synchronize to any Substrate-based chain. -Substrate chains have three distinct features that make them "next-generation": a dynamic, self-defining state-transition function; light-client functionality from day one; and a progressive consensus algorithm with fast block production and adaptive, definite finality. The STF, encoded in WebAssembly, is known as the "runtime". This defines the `execute_block` function, and can specify everything from the staking algorithm, transaction semantics, logging mechanisms and procedures for replacing any aspect of itself or of the blockchain's state ("governance"). Because the runtime is entirely dynamic all of these can be switched out or upgraded at any time. A Substrate chain is very much a "living organism". +Substrate chains have three distinct features that make them "next-generation": a dynamic, self-defining state-transition function; light-client functionality from day one; and a progressive consensus algorithm with fast block production and adaptive, definite finality. The STF, encoded in WebAssembly, is known as the "runtime". This defines the `execute_block` function, and can specify everything from the staking algorithm, transaction semantics, logging mechanisms and procedures for replacing any aspect of itself or of the blockchain's state ("governance"). Because the runtime is entirely dynamic all of these can be switched out or upgraded at any time. A Substrate chain is very much a "living organizm". See also https://www.parity.io/what-is-substrate/. @@ -39,7 +39,7 @@ Block := Header + Extrinsics + Justifications === Extrinsics -Extrinsics in Substrate are pieces of information from "the outside world" that are contained in the blocks of the chain. You might think "ahh, that means *transactions*": in fact, no. Extrinsics fall into two broad categories of which only one is *transactions*. The other is known as *inherents*. The difference between these two is that transactions are signed and gossipped on the network and can be deemed useful *per se*. This fits the mould of what you would call transactions in Bitcoin or Ethereum. +Extrinsics in Substrate are pieces of information from "the outside world" that are contained in the blocks of the chain. You might think "ahh, that means *transactions*": in fact, no. Extrinsics fall into two broad categories of which only one is *transactions*. The other is known as *inherents*. The difference between these two is that transactions are signed and gossipped on the network and can be deemed useful *per se*. This fits the mold of what you would call transactions in Bitcoin or Ethereum. Inherents, meanwhile, are not passed on the network and are not signed. They represent data which describes the environment but which cannot call upon anything to prove it such as a signature. Rather they are assumed to be "true" simply because a sufficiently large number of validators have agreed on them being reasonable. @@ -63,16 +63,12 @@ impl_runtime_apis! { VERSION } - fn authorities() -> Vec { - Consensus::authorities() - } - fn execute_block(block: Block) { Executive::execute_block(block) } - fn initialise_block(header: ::Header) { - Executive::initialise_block(&header) + fn initialize_block(header: ::Header) { + Executive::initialize_block(&header) } } // ---snip--- @@ -86,9 +82,9 @@ The Substrate Runtime Module Library includes functionality for timestamps and s === Block-authoring Logic -In Substrate, there is a major distinction between blockchain *syncing* and block *authoring* ("authoring" is a more general term for what is called "mining" in Bitcoin). The first case might be referred to as a "full node" (or "light node" - Substrate supports both): authoring necessarily requires a synced node and, therefore, all authoring clients must necessarily be able to synchronise. However, the reverse is not true. The primary functionality that authoring nodes have which is not in "sync nodes" is threefold: transaction queue logic, inherent transaction knowledge and BFT consensus logic. BFT consensus logic is provided as a core element of Substrate and can be ignored since it is only exposed in the SDK under the `authorities()` API entry. +In Substrate, there is a major distinction between blockchain *syncing* and block *authoring* ("authoring" is a more general term for what is called "mining" in Bitcoin). The first case might be referred to as a "full node" (or "light node" - Substrate supports both): authoring necessarily requires a synced node and, therefore, all authoring clients must necessarily be able to synchronize. However, the reverse is not true. The primary functionality that authoring nodes have which is not in "sync nodes" is threefold: transaction queue logic, inherent transaction knowledge and BFT consensus logic. BFT consensus logic is provided as a core element of Substrate and can be ignored since it is only exposed in the SDK under the `authorities()` API entry. -Transaction queue logic in Substrate is designed to be as generic as possible, allowing a runtime to express which transactions are fit for inclusion in a block through the `initialize_block` and `apply_extrinsic` calls. However, more subtle aspects like prioritisation and replacement policy must currently be expressed "hard coded" as part of the blockchain's authoring code. That said, Substrate's reference implementation for a transaction queue should be sufficient for an initial chain implementation. +Transaction queue logic in Substrate is designed to be as generic as possible, allowing a runtime to express which transactions are fit for inclusion in a block through the `initialize_block` and `apply_extrinsic` calls. However, more subtle aspects like prioritization and replacement policy must currently be expressed "hard coded" as part of the blockchain's authoring code. That said, Substrate's reference implementation for a transaction queue should be sufficient for an initial chain implementation. Inherent extrinsic knowledge is again somewhat generic, and the actual construction of the extrinsics is, by convention, delegated to the "soft code" in the runtime. If ever there needs to be additional extrinsic information in the chain, then both the block authoring logic will need to be altered to provide it into the runtime and the runtime's `inherent_extrinsics` call will need to use this extra information in order to construct any additional extrinsic transactions for inclusion in the block. @@ -167,7 +163,7 @@ It won't do much until you start producing blocks though, so to do that you'll n substrate --chain ~/mychain.json --validator --key ... ---- -You can distribute `mychain.json` so that everyone can synchronise and (depending on your authorities list) validate on your chain. +You can distribute `mychain.json` so that everyone can synchronize and (depending on your authorities list) validate on your chain. == Building @@ -237,11 +233,13 @@ Then build the code: cargo build # Builds all native code ---- -You can run the tests if you like: +You can run all the tests if you like: [source, shell] cargo test --all +Or just run the tests of a specific package (i.e. `cargo test -p srml-assets`) + You can start a development chain with: [source, shell] @@ -257,8 +255,7 @@ We'll start Alice's substrate node first on default TCP port 30333 with her chai cargo run --release \-- \ --base-path /tmp/alice \ --chain=local \ - --key Alice \ - --name "ALICE" \ + --alice \ --node-key 0000000000000000000000000000000000000000000000000000000000000001 \ --telemetry-url ws://telemetry.polkadot.io:1024 \ --validator @@ -270,8 +267,7 @@ cargo run --release \-- \ --base-path /tmp/bob \ --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN \ --chain=local \ - --key Bob \ - --name "BOB" \ + --bob \ --port 30334 \ --telemetry-url ws://telemetry.polkadot.io:1024 \ --validator diff --git a/build.rs b/build.rs index 7dd666310f77449dcc2605bd58b50cef763722a4..273700c525c883579880be28b231a5f14e43c6d7 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ use vergen::{ConstantsFlags, generate_cargo_keys}; -const ERROR_MSG: &'static str = "Failed to generate metadata files"; +const ERROR_MSG: &str = "Failed to generate metadata files"; fn main() { generate_cargo_keys(ConstantsFlags::all()).expect(ERROR_MSG); diff --git a/core/basic-authorship/Cargo.toml b/core/basic-authorship/Cargo.toml index 82187db8031f853dd0518e2c2aaf3d9e185803e2..d173ac66ee2439da99f2257663c030bbe58c13e3 100644 --- a/core/basic-authorship/Cargo.toml +++ b/core/basic-authorship/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] log = "0.4" -codec = { package = "parity-codec", version = "3.0" } +codec = { package = "parity-codec", version = "3.2" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } client = { package = "substrate-client", path = "../../core/client" } aura_primitives = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives" } @@ -14,6 +14,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../../core/ primitives = { package = "substrate-primitives", path = "../../core/primitives" } inherents = { package = "substrate-inherents", path = "../inherents" } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } +substrate-telemetry = { path = "../telemetry" } [dev-dependencies] test-client = { package = "substrate-test-client", path = "../../core/test-client" } diff --git a/core/basic-authorship/src/basic_authorship.rs b/core/basic-authorship/src/basic_authorship.rs index 728ef3c0679952e263d451d13effd52474f125ac..e9b6c909ad41f556488bd8ad6cb6ca7452896450 100644 --- a/core/basic-authorship/src/basic_authorship.rs +++ b/core/basic-authorship/src/basic_authorship.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Parity Technologies (UK) Ltd. +// Copyright 2018-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ // use std::{self, time, sync::Arc}; -use log::{info, debug}; +use log::{info, debug, warn, trace}; use client::{ self, error, Client as SubstrateClient, CallExecutor, @@ -28,15 +28,15 @@ use client::{ }; use codec::Decode; use consensus_common::{self, evaluation}; -use primitives::{H256, Blake2Hasher}; +use primitives::{H256, Blake2Hasher, ExecutionContext}; use runtime_primitives::traits::{ Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, AuthorityIdFor }; -use runtime_primitives::ExecutionContext; use runtime_primitives::generic::BlockId; use runtime_primitives::ApplyError; use transaction_pool::txpool::{self, Pool as TransactionPool}; -use inherents::InherentData; +use inherents::{InherentData, pool::InherentsPool}; +use substrate_telemetry::{telemetry, CONSENSUS_INFO}; /// Build new blocks. pub trait BlockBuilder { @@ -114,6 +114,8 @@ pub struct ProposerFactory where A: txpool::ChainApi { pub client: Arc, /// The transaction pool. pub transaction_pool: Arc>, + /// The inherents pool + pub inherents_pool: Arc::Extrinsic>>, } impl consensus_common::Environment<::Block> for ProposerFactory where @@ -143,6 +145,7 @@ impl consensus_common::Environment<::Block> for Propose parent_id: id, parent_number: *parent_header.number(), transaction_pool: self.transaction_pool.clone(), + inherents_pool: self.inherents_pool.clone(), now: Box::new(time::Instant::now), }; @@ -157,6 +160,7 @@ pub struct Proposer { parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, transaction_pool: Arc>, + inherents_pool: Arc::Extrinsic>>, now: Box time::Instant>, } @@ -173,7 +177,7 @@ impl consensus_common::Proposer<::Block> for Pro fn propose(&self, inherent_data: InherentData, max_duration: time::Duration) -> Result<::Block, error::Error> { - // leave some time for evaluation and block finalisation (33%) + // leave some time for evaluation and block finalization (33%) let deadline = (self.now)() + max_duration - max_duration / 3; self.propose_with(inherent_data, deadline) } @@ -193,24 +197,37 @@ impl Proposer where /// If the block is full we will attempt to push at most /// this number of transactions before quitting for real. - /// It allows us to increase block utilisation. + /// It allows us to increase block utilization. const MAX_SKIPPED_TRANSACTIONS: usize = 8; let block = self.client.build_block( &self.parent_id, inherent_data, |block_builder| { + // Add inherents from the internal pool + + let inherents = self.inherents_pool.drain(); + debug!("Pushing {} queued inherents.", inherents.len()); + for i in inherents { + if let Err(e) = block_builder.push_extrinsic(i) { + warn!("Error while pushing inherent extrinsic from the pool: {:?}", e); + } + } + + // proceed with transactions let mut is_first = true; let mut skipped = 0; let mut unqueue_invalid = Vec::new(); let pending_iterator = self.transaction_pool.ready(); + debug!("Attempting to push transactions from the pool."); for pending in pending_iterator { if (self.now)() > deadline { debug!("Consensus deadline reached when pushing block transactions, proceeding with proposing."); break; } + trace!("[{:?}] Pushing to the block.", pending.hash); match block_builder.push_extrinsic(pending.data.clone()) { Ok(()) => { debug!("[{:?}] Pushed to the block.", pending.hash); @@ -252,6 +269,10 @@ impl Proposer where .collect::>() .join(", ") ); + telemetry!(CONSENSUS_INFO; "prepared_block_for_proposing"; + "number" => ?block.header().number(), + "hash" => ?<::Block as BlockT>::Hash::from(block.header().hash()), + ); let substrate_block = Decode::decode(&mut block.encode().as_slice()) .expect("blocks are defined to serialize to substrate blocks correctly; qed"); @@ -273,17 +294,16 @@ mod tests { use codec::Encode; use std::cell::RefCell; use consensus_common::{Environment, Proposer}; - use test_client::keyring::Keyring; - use test_client::{self, runtime::{Extrinsic, Transfer}}; + use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; fn extrinsic(nonce: u64) -> Extrinsic { let tx = Transfer { amount: Default::default(), nonce, - from: Keyring::Alice.to_raw_public().into(), + from: AccountKeyring::Alice.into(), to: Default::default(), }; - let signature = Keyring::from_raw_public(tx.from.to_fixed_bytes()).unwrap().sign(&tx.encode()).into(); + let signature = AccountKeyring::from_public(&tx.from).unwrap().sign(&tx.encode()).into(); Extrinsic::Transfer(tx, signature) } @@ -299,6 +319,7 @@ mod tests { let proposer_factory = ProposerFactory { client: client.clone(), transaction_pool: txpool.clone(), + inherents_pool: Default::default(), }; let mut proposer = proposer_factory.init( @@ -321,4 +342,32 @@ mod tests { assert_eq!(txpool.ready().count(), 2); } + #[test] + fn should_include_inherents_from_the_pool() { + // given + let client = Arc::new(test_client::new()); + let chain_api = transaction_pool::ChainApi::new(client.clone()); + let txpool = Arc::new(TransactionPool::new(Default::default(), chain_api)); + let inpool = Arc::new(InherentsPool::default()); + + let proposer_factory = ProposerFactory { + client: client.clone(), + transaction_pool: txpool.clone(), + inherents_pool: inpool.clone(), + }; + + inpool.add(extrinsic(0)); + + let proposer = proposer_factory.init( + &client.header(&BlockId::number(0)).unwrap().unwrap(), + &[] + ).unwrap(); + + // when + let deadline = time::Duration::from_secs(3); + let block = proposer.propose(Default::default(), deadline).unwrap(); + + // then + assert_eq!(block.extrinsics().len(), 1); + } } diff --git a/core/basic-authorship/src/lib.rs b/core/basic-authorship/src/lib.rs index a4f6afb8f86102ce137eb99cf5d85802c28d8e89..88a55c3bac4fa22bb21e42e9c66398a6e286b575 100644 --- a/core/basic-authorship/src/lib.rs +++ b/core/basic-authorship/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/cli/Cargo.toml b/core/cli/Cargo.toml index fa117969026a6c30cad62aa6859e2eb48393a9d1..c5bf34063d8066fff85fd6954b3d67c52399f9e8 100644 --- a/core/cli/Cargo.toml +++ b/core/cli/Cargo.toml @@ -14,12 +14,13 @@ atty = "0.2" regex = "1" time = "0.1" ansi_term = "0.11" -lazy_static = "1.0" +lazy_static = "1.3" app_dirs = "1.2" tokio = "0.1.7" futures = "0.1.17" fdlimit = "0.1" exit-future = "0.1" +serde_json = "1.0" sysinfo = "0.8.0" panic-handler = { package = "substrate-panic-handler", path = "../../core/panic-handler" } client = { package = "substrate-client", path = "../../core/client" } @@ -29,5 +30,9 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives" service = { package = "substrate-service", path = "../../core/service" } state-machine = { package = "substrate-state-machine", path = "../../core/state-machine" } substrate-telemetry = { path = "../../core/telemetry" } +keyring = { package = "substrate-keyring", path = "../keyring" } names = "0.11.0" structopt = "0.2" + +[dev-dependencies] +tempdir = "0.3" diff --git a/core/cli/src/error.rs b/core/cli/src/error.rs index b9a036ce1c7a2e02550be81f16317c858f54e124..e368cc6d9670a59adaf2975de4f69421948fbb14 100644 --- a/core/cli/src/error.rs +++ b/core/cli/src/error.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/cli/src/informant.rs b/core/cli/src/informant.rs index 6b65606bba5332173df917c70a6eaeab5502483f..260615b2c1cb626429c14e95cc51baceda08d4b1 100644 --- a/core/cli/src/informant.rs +++ b/core/cli/src/informant.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -82,9 +82,12 @@ pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExe (proc.cpu_usage(), proc.memory()) } else { (0.0, 0) }; + let network_state = serde_json::to_string(&network.network_state()).unwrap_or_default(); + telemetry!( SUBSTRATE_INFO; "system.interval"; + "network_state" => network_state, "status" => format!("{}{}", status, target), "peers" => num_peers, "height" => best_number, diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 4fb0647cad303a95a473d511aba0eda266e15ae1..d2c3cccebeccb8ffc1705090540421ae3b3e4551 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -32,7 +32,8 @@ use service::{ FactoryGenesis, PruningMode, ChainSpec, }; use network::{ - Protocol, config::{NetworkConfiguration, NonReservedPeerMode, Secret}, + self, multiaddr::Protocol, + config::{NetworkConfiguration, NonReservedPeerMode, NodeKeyConfig}, build_multiaddr, }; use primitives::H256; @@ -50,6 +51,7 @@ pub use structopt::clap::App; use params::{ RunCmd, PurgeChainCmd, RevertCmd, ImportBlocksCmd, ExportBlocksCmd, BuildSpecCmd, NetworkConfigurationParams, SharedParams, MergeParameters, TransactionPoolParams, + NodeKeyParams, NodeKeyType }; pub use params::{NoCustom, CoreParams}; pub use traits::{GetLogFilter, AugmentClap}; @@ -61,7 +63,18 @@ use lazy_static::lazy_static; use futures::Future; use substrate_telemetry::TelemetryEndpoints; -const MAX_NODE_NAME_LENGTH: usize = 32; +/// The maximum number of characters for a node name. +const NODE_NAME_MAX_LENGTH: usize = 32; + +/// The file name of the node's Secp256k1 secret key inside the chain-specific +/// network config directory, if neither `--node-key` nor `--node-key-file` +/// is specified in combination with `--node-key-type=secp256k1`. +const NODE_KEY_SECP256K1_FILE: &str = "secret"; + +/// The file name of the node's Ed25519 secret key inside the chain-specific +/// network config directory, if neither `--node-key` nor `--node-key-file` +/// is specified in combination with `--node-key-type=ed25519`. +const NODE_KEY_ED25519_FILE: &str = "secret_ed25519"; /// Executable version. Used to pass version information from the root crate. pub struct VersionInfo { @@ -101,7 +114,7 @@ fn generate_node_name() -> String { let node_name = Generator::with_naming(Name::Numbered).next().unwrap(); let count = node_name.chars().count(); - if count < MAX_NODE_NAME_LENGTH { + if count < NODE_NAME_MAX_LENGTH { break node_name } }; @@ -133,14 +146,14 @@ fn base_path(cli: &SharedParams, version: &VersionInfo) -> PathBuf { ) } -fn create_input_err>(msg: T) -> error::Error { +fn input_err>(msg: T) -> error::Error { error::ErrorKind::Input(msg.into()).into() } /// Check whether a node name is considered as valid fn is_node_name_valid(_name: &str) -> Result<(), &str> { let name = _name.to_string(); - if name.chars().count() >= MAX_NODE_NAME_LENGTH { + if name.chars().count() >= NODE_NAME_MAX_LENGTH { return Err("Node name too long"); } @@ -231,14 +244,60 @@ where } } -fn parse_node_key(key: Option) -> error::Result> { - match key.map(|k| H256::from_str(&k)) { - Some(Ok(secret)) => Ok(Some(secret.into())), - Some(Err(err)) => Err(create_input_err(format!("Error parsing node key: {}", err))), - None => Ok(None), +/// Create a `NodeKeyConfig` from the given `NodeKeyParams` in the context +/// of an optional network config storage directory. +fn node_key_config(params: NodeKeyParams, net_config_dir: &Option) + -> error::Result +where + P: AsRef +{ + match params.node_key_type { + NodeKeyType::Secp256k1 => + params.node_key.as_ref().map(parse_secp256k1_secret).unwrap_or_else(|| + Ok(params.node_key_file + .or_else(|| net_config_file(net_config_dir, NODE_KEY_SECP256K1_FILE)) + .map(network::Secret::File) + .unwrap_or(network::Secret::New))) + .map(NodeKeyConfig::Secp256k1), + + NodeKeyType::Ed25519 => + params.node_key.as_ref().map(parse_ed25519_secret).unwrap_or_else(|| + Ok(params.node_key_file + .or_else(|| net_config_file(net_config_dir, NODE_KEY_ED25519_FILE)) + .map(network::Secret::File) + .unwrap_or(network::Secret::New))) + .map(NodeKeyConfig::Ed25519) } } +fn net_config_file(net_config_dir: &Option, name: &str) -> Option +where + P: AsRef +{ + net_config_dir.as_ref().map(|d| d.as_ref().join(name)) +} + +/// Create an error caused by an invalid node key argument. +fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { + input_err(format!("Invalid node key: {}", e)) +} + +/// Parse a Secp256k1 secret key from a hex string into a `network::Secret`. +fn parse_secp256k1_secret(hex: &String) -> error::Result { + H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::secp256k1::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + +/// Parse a Ed25519 secret key from a hex string into a `network::Secret`. +fn parse_ed25519_secret(hex: &String) -> error::Result { + H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::ed25519::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + /// Fill the given `PoolConfiguration` by looking at the cli parameters. fn fill_transaction_pool_configuration( options: &mut FactoryFullConfiguration, @@ -295,11 +354,13 @@ fn fill_network_configuration( config.public_addresses = Vec::new(); config.client_version = client_id; - config.use_secret = parse_node_key(cli.node_key)?; + config.node_key = node_key_config(cli.node_key_params, &config.net_config_path)?; config.in_peers = cli.in_peers; config.out_peers = cli.out_peers; + config.enable_mdns = !cli.no_mdns; + Ok(()) } @@ -317,14 +378,14 @@ where config.impl_commit = version.commit; config.impl_version = version.version; - config.name = match cli.name { + config.name = match cli.name.or(cli.keyring.account.map(|a| a.to_string())) { None => generate_node_name(), Some(name) => name, }; match is_node_name_valid(&config.name) { Ok(_) => (), Err(msg) => bail!( - create_input_err( + input_err( format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", config.name, msg @@ -347,7 +408,7 @@ where Some(ref s) if s == "archive" => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => PruningMode::keep_blocks( - s.parse().map_err(|_| create_input_err("Invalid pruning mode specified"))? + s.parse().map_err(|_| input_err("Invalid pruning mode specified"))? ), }; @@ -360,14 +421,25 @@ where service::Roles::FULL }; + let exec = cli.execution_strategies; config.execution_strategies = ExecutionStrategies { - syncing: cli.syncing_execution.into(), - importing: cli.importing_execution.into(), - block_construction: cli.block_construction_execution.into(), - other: cli.other_execution.into(), + syncing: exec.syncing_execution.into(), + importing: exec.importing_execution.into(), + block_construction: exec.block_construction_execution.into(), + offchain_worker: exec.offchain_worker_execution.into(), + other: exec.other_execution.into(), + }; + + config.offchain_worker = match (cli.offchain_worker, role) { + (params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true, + (params::OffchainWorkerEnabled::Always, _) => true, + (params::OffchainWorkerEnabled::Never, _) => false, + (params::OffchainWorkerEnabled::WhenValidating, _) => false, }; config.roles = role; + config.disable_grandpa = cli.no_grandpa; + let client_id = config.client_id(); fill_network_configuration( cli.network_config, @@ -387,7 +459,11 @@ where } if cli.shared_params.dev { - config.keys.push("Alice".into()); + config.keys.push("//Alice".into()); + } + + if let Some(account) = cli.keyring.account { + config.keys.push(format!("//{}", account)); } let rpc_interface: &str = if cli.rpc_external { "0.0.0.0" } else { "127.0.0.1" }; @@ -407,6 +483,8 @@ where config.telemetry_endpoints = Some(TelemetryEndpoints::new(cli.telemetry_endpoints)); } + config.force_authoring = cli.force_authoring; + Ok(config) } @@ -439,23 +517,19 @@ where // 9926-9949 Unassigned fn with_default_boot_node( - mut spec: ChainSpec>, - cli: &BuildSpecCmd, + spec: &mut ChainSpec>, + cli: BuildSpecCmd, version: &VersionInfo, -) -> error::Result>> +) -> error::Result<()> where F: ServiceFactory { if spec.boot_nodes().is_empty() { - let network_path = - Some(network_path(&base_path(&cli.shared_params, version), spec.id()).to_string_lossy().into()); - let network_key = parse_node_key(cli.node_key.clone())?; - - let network_keys = - network::obtain_private_key(&network_key, &network_path) - .map_err(|err| format!("Error obtaining network key: {}", err))?; - - let peer_id = network_keys.to_peer_id(); + let base_path = base_path(&cli.shared_params, version); + let storage_path = network_path(&base_path, spec.id()); + let node_key = node_key_config(cli.node_key_params, &Some(storage_path))?; + let keys = node_key.into_keypair()?; + let peer_id = keys.public().into_peer_id(); let addr = build_multiaddr![ Ip4([127, 0, 0, 1]), Tcp(30333u16), @@ -463,7 +537,7 @@ where ]; spec.add_boot_node(addr) } - Ok(spec) + Ok(()) } fn build_spec( @@ -476,9 +550,10 @@ where S: FnOnce(&str) -> Result>>, String>, { info!("Building chain spec"); - let spec = load_spec(&cli.shared_params, spec_factory)?; - let spec = with_default_boot_node::(spec, &cli, version)?; - let json = service::chain_ops::build_spec::>(spec, cli.raw)?; + let raw_output = cli.raw; + let mut spec = load_spec(&cli.shared_params, spec_factory)?; + with_default_boot_node::(&mut spec, cli, version)?; + let json = service::chain_ops::build_spec::>(spec, raw_output)?; print!("{}", json); @@ -574,23 +649,28 @@ where S: FnOnce(&str) -> Result>>, String>, { let config = create_config_with_db_path::(spec_factory, &cli.shared_params, version)?; - let db_path = config.database_path; - print!("Are you sure to remove {:?}? (y/n)", &db_path); - stdout().flush().expect("failed to flush stdout"); - - let mut input = String::new(); - stdin().read_line(&mut input)?; - let input = input.trim(); - - match input.chars().nth(0) { - Some('y') | Some('Y') => { - fs::remove_dir_all(&db_path)?; - println!("{:?} removed.", &db_path); - }, - _ => println!("Aborted"), + + if cli.yes == false { + print!("Are you sure to remove {:?}? (y/n)", &db_path); + stdout().flush().expect("failed to flush stdout"); + + let mut input = String::new(); + stdin().read_line(&mut input)?; + let input = input.trim(); + + match input.chars().nth(0) { + Some('y') | Some('Y') => {}, + _ => { + println!("Aborted"); + return Ok(()); + }, + } } + fs::remove_dir_all(&db_path)?; + println!("{:?} removed.", &db_path); + Ok(()) } @@ -698,6 +778,8 @@ fn kill_color(s: &str) -> String { #[cfg(test)] mod tests { use super::*; + use tempdir::TempDir; + use network::identity::{secp256k1, ed25519}; #[test] fn tests_node_name_good() { @@ -713,4 +795,111 @@ mod tests { assert!(is_node_name_valid("www.visit.me").is_err()); assert!(is_node_name_valid("email@domain").is_err()); } + + #[test] + fn test_node_key_config_input() { + fn secret_input(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let sk = match node_key_type { + NodeKeyType::Secp256k1 => secp256k1::SecretKey::generate().as_ref().to_vec(), + NodeKeyType::Ed25519 => ed25519::SecretKey::generate().as_ref().to_vec() + }; + let params = NodeKeyParams { + node_key_type, + node_key: Some(format!("{:x}", H256::from_slice(sk.as_ref()))), + node_key_file: None + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Secp256k1 && + &sk[..] == ski.as_ref() => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Ed25519 && + &sk[..] == ski.as_ref() => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_input(None).is_ok()); + assert!(secret_input(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_file() { + fn secret_file(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let tmp = TempDir::new("alice")?; + let file = tmp.path().join(format!("{}_mysecret", t)).to_path_buf(); + let params = NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: Some(file.clone()) + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Secp256k1 && f == &file => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_file(None).is_ok()); + assert!(secret_file(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_default() { + fn with_def_params(f: F) -> error::Result<()> + where + F: Fn(NodeKeyParams) -> error::Result<()> + { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + f(NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: None + }) + }) + } + + fn no_config_dir() -> error::Result<()> { + with_def_params(|params| { + let typ = params.node_key_type; + node_key_config::(params, &None) + .and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::New) + if typ == NodeKeyType::Secp256k1 => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::New) + if typ == NodeKeyType::Ed25519 => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + fn some_config_dir(net_config_dir: String) -> error::Result<()> { + with_def_params(|params| { + let dir = PathBuf::from(net_config_dir.clone()); + let typ = params.node_key_type; + node_key_config(params, &Some(net_config_dir.clone())) + .and_then(move |c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if typ == NodeKeyType::Secp256k1 && + f == &dir.join(NODE_KEY_SECP256K1_FILE) => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if typ == NodeKeyType::Ed25519 && + f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(no_config_dir().is_ok()); + assert!(some_config_dir("x".to_string()).is_ok()); + } } diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 26a9a00ebf0a00d271b0036a2ff2958054962680..321cf17efb39cff59dd950dcd4d6b95df4cb7388 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Parity Technologies (UK) Ltd. +// Copyright 2018-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ use crate::traits::{AugmentClap, GetLogFilter}; use std::path::PathBuf; -use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand}}; +use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand, Arg}}; use client; /// Auxialary macro to implement `GetLogFilter` for all types that have the `shared_params` field. @@ -39,6 +39,7 @@ arg_enum! { Wasm, Both, NativeElseWasm, + NativeWhenPossible, } } @@ -49,10 +50,21 @@ impl Into for ExecutionStrategy { ExecutionStrategy::Wasm => client::ExecutionStrategy::AlwaysWasm, ExecutionStrategy::Both => client::ExecutionStrategy::Both, ExecutionStrategy::NativeElseWasm => client::ExecutionStrategy::NativeElseWasm, + ExecutionStrategy::NativeWhenPossible => client::ExecutionStrategy::NativeWhenPossible, } } } +arg_enum! { + /// How to execute blocks + #[derive(Debug, Clone)] + pub enum OffchainWorkerEnabled { + Always, + Never, + WhenValidating, + } +} + /// Shared parameters used by all `CoreParams`. #[derive(Debug, StructOpt, Clone)] pub struct SharedParams { @@ -68,7 +80,7 @@ pub struct SharedParams { #[structopt(long = "base-path", short = "d", value_name = "PATH", parse(from_os_str))] pub base_path: Option, - ///Sets a custom logging filter + /// Sets a custom logging filter #[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")] pub log: Option, } @@ -98,10 +110,6 @@ pub struct NetworkConfigurationParams { #[structopt(long = "port", value_name = "PORT")] pub port: Option, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, - /// Specify the number of outgoing connections we're trying to maintain #[structopt(long = "out-peers", value_name = "OUT_PEERS", default_value = "25")] pub out_peers: u32, @@ -109,6 +117,98 @@ pub struct NetworkConfigurationParams { /// Specify the maximum number of incoming connections we're accepting #[structopt(long = "in-peers", value_name = "IN_PEERS", default_value = "25")] pub in_peers: u32, + + /// By default, the network will use mDNS to discover other nodes on the local network. This + /// disables it. + #[structopt(long = "no-mdns")] + pub no_mdns: bool, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams +} + +arg_enum! { + #[derive(Debug, Copy, Clone, PartialEq, Eq)] + pub enum NodeKeyType { + Secp256k1, + Ed25519 + } +} + +/// Parameters used to create the `NodeKeyConfig`, which determines the keypair +/// used for libp2p networking. +#[derive(Debug, StructOpt, Clone)] +pub struct NodeKeyParams { + /// The secret key to use for libp2p networking. + /// + /// The value is a string that is parsed according to the choice of + /// `--node-key-type` as follows: + /// + /// `secp256k1`: + /// The value is parsed as a hex-encoded Secp256k1 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// `ed25519`: + /// The value is parsed as a hex-encoded Ed25519 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// The value of this option takes precedence over `--node-key-file`. + /// + /// WARNING: Secrets provided as command-line arguments are easily exposed. + /// Use of this option should be limited to development and testing. To use + /// an externally managed secret key, use `--node-key-file` instead. + #[structopt(long = "node-key", value_name = "KEY")] + pub node_key: Option, + + /// The type of secret key to use for libp2p networking. + /// + /// The secret key of the node is obtained as follows: + /// + /// * If the `--node-key` option is given, the value is parsed as a secret key + /// according to the type. See the documentation for `--node-key`. + /// + /// * If the `--node-key-file` option is given, the secret key is read from the + /// specified file. See the documentation for `--node-key-file`. + /// + /// * Otherwise, the secret key is read from a file with a predetermined, + /// type-specific name from the chain-specific network config directory + /// inside the base directory specified by `--base-dir`. If this file does + /// not exist, it is created with a newly generated secret key of the + /// chosen type. + /// + /// The node's secret key determines the corresponding public key and hence the + /// node's peer ID in the context of libp2p. + /// + /// NOTE: The current default key type is `secp256k1` for a transition period only + /// but will eventually change to `ed25519` in a future release. To continue using + /// `secp256k1` keys, use `--node-key-type=secp256k1`. + #[structopt( + long = "node-key-type", + value_name = "TYPE", + raw( + possible_values = "&NodeKeyType::variants()", + case_insensitive = "true", + default_value = r#""Secp256k1""# + ) + )] + pub node_key_type: NodeKeyType, + + /// The file from which to read the node's secret key to use for libp2p networking. + /// + /// The contents of the file are parsed according to the choice of `--node-key-type` + /// as follows: + /// + /// `secp256k1`: + /// The file must contain an unencoded 32 bytes Secp256k1 secret key. + /// + /// `ed25519`: + /// The file must contain an unencoded 32 bytes Ed25519 secret key. + /// + /// If the file does not exist, it is created with a newly generated secret key of + /// the chosen type. + #[structopt(long = "node-key-file", value_name = "FILE")] + pub node_key_file: Option } /// Parameters used to create the pool configuration. @@ -122,6 +222,70 @@ pub struct TransactionPoolParams { pub pool_kbytes: usize, } +/// Execution strategies parameters. +#[derive(Debug, StructOpt, Clone)] +pub struct ExecutionStrategies { + /// The means of execution used when calling into the runtime while syncing blocks. + #[structopt( + long = "syncing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub syncing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while importing blocks. + #[structopt( + long = "importing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub importing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "block-construction-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub block_construction_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "offchain-worker-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeWhenPossible""# + ) + )] + pub offchain_worker_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. + #[structopt( + long = "other-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub other_execution: ExecutionStrategy, +} + /// The `run` command used to run a node. #[derive(Debug, StructOpt, Clone)] pub struct RunCmd { @@ -137,6 +301,10 @@ pub struct RunCmd { #[structopt(long = "validator")] pub validator: bool, + /// Disable GRANDPA when running in validator mode + #[structopt(long = "no-grandpa")] + pub no_grandpa: bool, + /// Run in light client mode #[structopt(long = "light")] pub light: bool, @@ -169,7 +337,7 @@ pub struct RunCmd { #[structopt(long = "name", value_name = "NAME")] pub name: Option, - /// Should not connect to the Substrate telemetry server (telemetry is on by default on global chains) + /// Disable connecting to the Substrate telemetry server (telemetry is on by default on global chains). #[structopt(long = "no-telemetry")] pub no_telemetry: bool, @@ -179,55 +347,23 @@ pub struct RunCmd { #[structopt(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = "parse_telemetry_endpoints"))] pub telemetry_endpoints: Vec<(String, u8)>, - /// The means of execution used when calling into the runtime while syncing blocks. + /// Should execute offchain workers on every block. By default it's only enabled for nodes that are authoring new + /// blocks. #[structopt( - long = "syncing-execution", - value_name = "STRATEGY", + long = "offchain-worker", + value_name = "ENABLED", raw( - possible_values = "&ExecutionStrategy::variants()", + possible_values = "&OffchainWorkerEnabled::variants()", case_insensitive = "true", - default_value = r#""NativeElseWasm""# + default_value = r#""WhenValidating""# ) )] - pub syncing_execution: ExecutionStrategy, + pub offchain_worker: OffchainWorkerEnabled, - /// The means of execution used when calling into the runtime while importing blocks. - #[structopt( - long = "importing-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""NativeElseWasm""# - ) - )] - pub importing_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while constructing blocks. - #[structopt( - long = "block-construction-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub block_construction_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. - #[structopt( - long = "other-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub other_execution: ExecutionStrategy, + #[allow(missing_docs)] + #[structopt(flatten)] + pub execution_strategies: ExecutionStrategies, - #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, @@ -239,6 +375,84 @@ pub struct RunCmd { #[allow(missing_docs)] #[structopt(flatten)] pub pool_config: TransactionPoolParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub keyring: Keyring, + + /// Enable authoring even when offline. + #[structopt(long = "force-authoring")] + pub force_authoring: bool, +} + +/// Stores all required Cli values for a keyring test account. +struct KeyringTestAccountCliValues { + help: String, + conflicts_with: Vec, + name: String, + variant: keyring::AuthorityKeyring, +} + +lazy_static::lazy_static! { + /// The Cli values for all test accounts. + static ref TEST_ACCOUNTS_CLI_VALUES: Vec = { + keyring::AuthorityKeyring::iter().map(|a| { + let help = format!("Shortcut for `--key //{} --name {}`.", a, a); + let conflicts_with = keyring::AuthorityKeyring::iter() + .filter(|b| a != *b) + .map(|b| b.to_string().to_lowercase()) + .chain(["name", "key"].iter().map(|s| s.to_string())) + .collect::>(); + let name = a.to_string().to_lowercase(); + + KeyringTestAccountCliValues { + help, + conflicts_with, + name, + variant: a, + } + }).collect() + }; +} + +/// Wrapper for exposing the keyring test accounts into the Cli. +#[derive(Debug, Clone)] +pub struct Keyring { + pub account: Option, +} + +impl StructOpt for Keyring { + fn clap<'a, 'b>() -> App<'a, 'b> { + unimplemented!("Should not be called for `TestAccounts`.") + } + + fn from_clap(m: &::structopt::clap::ArgMatches) -> Self { + Keyring { + account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant), + } + } +} + +impl AugmentClap for Keyring { + fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| { + let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::>(); + + app.arg( + Arg::with_name(&a.name) + .long(&a.name) + .help(&a.help) + .conflicts_with_all(&conflicts_with_strs) + .takes_value(false) + ) + }) + } +} + +impl Keyring { + fn is_subcommand() -> bool { + false + } } /// Default to verbosity level 0, if none is provided. @@ -270,9 +484,9 @@ pub struct BuildSpecCmd { #[structopt(flatten)] pub shared_params: SharedParams, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams, } impl_get_log_filter!(BuildSpecCmd); @@ -338,6 +552,10 @@ impl_get_log_filter!(RevertCmd); /// The `purge-chain` command used to remove the whole chain. #[derive(Debug, StructOpt, Clone)] pub struct PurgeChainCmd { + /// Skip interactive prompt by answering yes automatically. + #[structopt(short = "y")] + pub yes: bool, + #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, diff --git a/core/client/Cargo.toml b/core/client/Cargo.toml index 495b11b61d5b8aa0ecda2a9507b608db280b254d..cfc7eb3e3447e4f4c2a39d46fb5dcbadac9bdeef 100644 --- a/core/client/Cargo.toml +++ b/core/client/Cargo.toml @@ -18,9 +18,9 @@ state-machine = { package = "substrate-state-machine", path = "../state-machine" keyring = { package = "substrate-keyring", path = "../keyring", optional = true } trie = { package = "substrate-trie", path = "../trie", optional = true } substrate-telemetry = { path = "../telemetry", optional = true } -hash-db = { version = "0.11", optional = true } +hash-db = { version = "0.12", optional = true } kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } runtime-primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } runtime-version = { package = "sr-version", path = "../sr-version", default-features = false } diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 8828eefa4fbf391d21bb4d8fbc3ef2396461c486..2944ab533b551c924d55c7fbf2adc81b36b5857b 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -12,15 +12,16 @@ kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } lru-cache = "0.1.1" -hash-db = { version = "0.11" } +hash-db = { version = "0.12" } primitives = { package = "substrate-primitives", path = "../../primitives" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } client = { package = "substrate-client", path = "../../client" } state-machine = { package = "substrate-state-machine", path = "../../state-machine" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } executor = { package = "substrate-executor", path = "../../executor" } state_db = { package = "substrate-state-db", path = "../../state-db" } trie = { package = "substrate-trie", path = "../../trie" } +consensus_common = { package = "substrate-consensus-common", path = "../../consensus/common" } [dev-dependencies] kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } diff --git a/core/client/db/src/cache/list_cache.rs b/core/client/db/src/cache/list_cache.rs index f8e52e14c630f07b421eaff4b69ca1bd0071c4fc..1e641534f969c0d63eefe387e98c9ded8bb3c81a 100644 --- a/core/client/db/src/cache/list_cache.rs +++ b/core/client/db/src/cache/list_cache.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_entry.rs b/core/client/db/src/cache/list_entry.rs index d2d88ab12f38ab341a6b69b51d35fbe989ac23e5..237ae9a268026744b87f6d85b7c6301cb82ee204 100644 --- a/core/client/db/src/cache/list_entry.rs +++ b/core/client/db/src/cache/list_entry.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_storage.rs b/core/client/db/src/cache/list_storage.rs index b9bf99f67b884fba4ae85f358cb9c0b731cb834b..659a30507e136576a844624fa167eb1cfb08ddb9 100644 --- a/core/client/db/src/cache/list_storage.rs +++ b/core/client/db/src/cache/list_storage.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index 12f8c5e519782a9b2db3e7842176665e41b120f5..b5dd45f11dd52e69ea715243924ac5e799e038b1 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! DB-backed cache of blockchain data. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -25,7 +25,8 @@ use client::blockchain::Cache as BlockchainCache; use client::error::Result as ClientResult; use parity_codec::{Encode, Decode}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As}; +use consensus_common::well_known_cache_keys::Id as CacheKeyId; use crate::utils::{self, COLUMN_META}; use self::list_cache::ListCache; @@ -64,7 +65,12 @@ impl CacheItemT for T where T: Clone + Decode + Encode + PartialEq {} /// Database-backed blockchain data cache. pub struct DbCache { - authorities_at: ListCache>, self::list_storage::DbStorage>, + cache_at: HashMap, self::list_storage::DbStorage>>, + db: Arc, + key_lookup_column: Option, + header_column: Option, + authorities_column: Option, + best_finalized_block: ComplexBlockId, } impl DbCache { @@ -76,19 +82,13 @@ impl DbCache { authorities_column: Option, best_finalized_block: ComplexBlockId, ) -> Self { - DbCache { - authorities_at: ListCache::new( - self::list_storage::DbStorage::new(b"auth".to_vec(), db, - self::list_storage::DbColumns { - meta: COLUMN_META, - key_lookup: key_lookup_column, - header: header_column, - cache: authorities_column, - }, - ), - As::sa(PRUNE_DEPTH), - best_finalized_block, - ), + Self { + cache_at: HashMap::new(), + db, + key_lookup_column, + header_column, + authorities_column, + best_finalized_block, } } @@ -97,35 +97,82 @@ impl DbCache { DbCacheTransaction { cache: self, tx, - authorities_at_op: None, + cache_at_op: HashMap::new(), + best_finalized_block: None, } } /// Run post-commit cache operations. pub fn commit(&mut self, ops: DbCacheTransactionOps) { - if let Some(authorities_at_op) = ops.authorities_at_op { - self.authorities_at.on_transaction_commit(authorities_at_op); + for (name, op) in ops.cache_at_op.into_iter() { + self.get_cache(name).on_transaction_commit(op); + } + if let Some(best_finalized_block) = ops.best_finalized_block { + self.best_finalized_block = best_finalized_block; } } + + /// Creates `ListCache` with the given name or returns a reference to the existing. + fn get_cache(&mut self, name: CacheKeyId) -> &mut ListCache, self::list_storage::DbStorage> { + get_cache_helper( + &mut self.cache_at, + name, + &self.db, + self.key_lookup_column, + self.header_column, + self.authorities_column, + &self.best_finalized_block + ) + } +} + +// This helper is needed because otherwise the borrow checker will require to +// clone all parameters outside of the closure. +fn get_cache_helper<'a, Block: BlockT>( + cache_at: &'a mut HashMap, self::list_storage::DbStorage>>, + name: CacheKeyId, + db: &Arc, + key_lookup: Option, + header: Option, + cache: Option, + best_finalized_block: &ComplexBlockId, +) -> &'a mut ListCache, self::list_storage::DbStorage> { + cache_at.entry(name).or_insert_with(|| { + ListCache::new( + self::list_storage::DbStorage::new(name.to_vec(), db.clone(), + self::list_storage::DbColumns { + meta: COLUMN_META, + key_lookup, + header, + cache, + }, + ), + As::sa(PRUNE_DEPTH), + best_finalized_block.clone(), + ) + }) } /// Cache operations that are to be committed after database transaction is committed. pub struct DbCacheTransactionOps { - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } /// Database-backed blockchain data cache transaction valid for single block import. pub struct DbCacheTransaction<'a, Block: BlockT> { cache: &'a mut DbCache, tx: &'a mut DBTransaction, - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { /// Convert transaction into post-commit operations set. pub fn into_ops(self) -> DbCacheTransactionOps { DbCacheTransactionOps { - authorities_at_op: self.authorities_at_op, + cache_at_op: self.cache_at_op, + best_finalized_block: self.best_finalized_block, } } @@ -134,21 +181,42 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { mut self, parent: ComplexBlockId, block: ComplexBlockId, - authorities_at: Option>>, + data_at: HashMap>, is_final: bool, ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_insert( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - authorities_at, - is_final, - )?; + // prepare list of caches that are not update + // (we might still need to do some cache maintenance in this case) + let missed_caches = self.cache.cache_at.keys() + .filter(|cache| !data_at.contains_key(cache.clone())) + .cloned() + .collect::>(); + + let mut insert_op = |name: CacheKeyId, value: Option>| -> Result<(), client::error::Error> { + let cache = self.cache.get_cache(name); + let op = cache.on_block_insert( + &mut self::list_storage::DbStorageTransaction::new( + cache.storage(), + &mut self.tx, + ), + parent.clone(), + block.clone(), + value.or(cache.value_at_block(&parent)?), + is_final, + )?; + if let Some(op) = op { + self.cache_at_op.insert(name, op); + } + Ok(()) + }; + + data_at.into_iter().try_for_each(|(name, data)| insert_op(name, Some(data)))?; + missed_caches.into_iter().try_for_each(|name| insert_op(name, None))?; + + if is_final { + self.best_finalized_block = Some(block); + } Ok(self) } @@ -159,16 +227,24 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { parent: ComplexBlockId, block: ComplexBlockId ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_finalize( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - )?; + for (name, cache_at) in self.cache.cache_at.iter() { + let op = cache_at.on_block_finalize( + &mut self::list_storage::DbStorageTransaction::new( + cache_at.storage(), + &mut self.tx + ), + parent.clone(), + block.clone(), + )?; + + if let Some(op) = op { + self.cache_at_op.insert(name.to_owned(), op); + } + } + + self.best_finalized_block = Some(block); Ok(self) } @@ -178,12 +254,12 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { pub struct DbCacheSync(pub RwLock>); impl BlockchainCache for DbCacheSync { - fn authorities_at(&self, at: BlockId) -> Option>> { + fn get_at(&self, key: &CacheKeyId, at: &BlockId) -> Option> { let cache = self.0.read(); - let storage = cache.authorities_at.storage(); + let storage = cache.cache_at.get(key)?.storage(); let db = storage.db(); let columns = storage.columns(); - let at = match at { + let at = match *at { BlockId::Hash(hash) => { let header = utils::read_header::( &**db, @@ -202,6 +278,7 @@ impl BlockchainCache for DbCacheSync { }, }; - cache.authorities_at.value_at_block(&at).ok()? + cache.cache_at.get(key)?.value_at_block(&at).ok()? } } + diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 36ac3cc3450552cc8e6f4280898ca413a8fb3ec3..7657bfd39691a0e2bec1e89e8ed7d84339ae1446 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -33,6 +33,7 @@ mod utils; use std::sync::Arc; use std::path::PathBuf; use std::io; +use std::collections::HashMap; use client::backend::NewBlockState; use client::blockchain::HeaderBackend; @@ -40,12 +41,12 @@ use client::ExecutionStrategies; use parity_codec::{Decode, Encode}; use hash_db::Hasher; use kvdb::{KeyValueDB, DBTransaction}; -use trie::MemoryDB; +use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::RwLock; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash}; use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem}; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; @@ -54,6 +55,7 @@ use crate::utils::{Meta, db_err, meta_keys, open_database, read_db, block_id_to_ use client::leaves::{LeafSet, FinalizationDisplaced}; use client::children; use state_db::StateDb; +use consensus_common::well_known_cache_keys; use crate::storage_cache::{CachingState, SharedCache, new_shared_cache}; use log::{trace, debug, warn}; pub use state_db::PruningMode; @@ -243,7 +245,7 @@ impl client::blockchain::Backend for BlockchainDb { Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&client::blockchain::Cache> { + fn cache(&self) -> Option>> { None } @@ -256,10 +258,16 @@ impl client::blockchain::Backend for BlockchainDb { } } +impl client::blockchain::ProvideCache for BlockchainDb { + fn cache(&self) -> Option>> { + None + } +} + /// Database transaction pub struct BlockImportOperation { old_state: CachingState, - db_updates: MemoryDB, + db_updates: PrefixedMemoryDB, storage_updates: Vec<(Vec, Option>)>, changes_trie_updates: MemoryDB, pending_block: Option>, @@ -306,11 +314,11 @@ where Block: BlockT, Ok(()) } - fn update_authorities(&mut self, _authorities: Vec>) { - // currently authorities are not cached on full nodes + fn update_cache(&mut self, _cache: HashMap>) { + // Currently cache isn't implemented on full nodes. } - fn update_db_storage(&mut self, update: MemoryDB) -> Result<(), client::error::Error> { + fn update_db_storage(&mut self, update: PrefixedMemoryDB) -> Result<(), client::error::Error> { self.db_updates = update; Ok(()) } @@ -321,7 +329,7 @@ where Block: BlockT, return Err(client::error::ErrorKind::GenesisInvalid.into()); } - let mut transaction: MemoryDB = Default::default(); + let mut transaction: PrefixedMemoryDB = Default::default(); for (child_key, child_map) in children { if !well_known_keys::is_child_storage_key(&child_key) { @@ -374,22 +382,23 @@ where Block: BlockT, struct StorageDb { pub db: Arc, - pub state_db: StateDb, + pub state_db: StateDb>, } impl state_machine::Storage for StorageDb { - fn get(&self, key: &H256) -> Result, String> { - self.state_db.get(key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) + fn get(&self, key: &H256, prefix: &[u8]) -> Result, String> { + let key = prefixed_key::(key, prefix); + self.state_db.get(&key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) .map_err(|e| format!("Database backend error: {:?}", e)) } } -impl state_db::HashDb for StorageDb { +impl state_db::NodeDb for StorageDb { type Error = io::Error; - type Hash = H256; + type Key = [u8]; - fn get(&self, key: &H256) -> Result>, Self::Error> { - self.db.get(columns::STATE, key.as_bytes()).map(|r| r.map(|v| v.to_vec())) + fn get(&self, key: &[u8]) -> Result>, Self::Error> { + self.db.get(columns::STATE, key).map(|r| r.map(|v| v.to_vec())) } } @@ -405,7 +414,7 @@ impl DbGenesisStorage { } impl state_machine::Storage for DbGenesisStorage { - fn get(&self, _key: &H256) -> Result, String> { + fn get(&self, _key: &H256, _prefix: &[u8]) -> Result, String> { Ok(None) } } @@ -515,7 +524,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC } impl state_machine::ChangesTrieStorage for DbChangesTrieStorage { - fn get(&self, key: &H256) -> Result, String> { + fn get(&self, key: &H256, _prefix: &[u8]) -> Result, String> { self.db.get(columns::CHANGES_TRIE, &key[..]) .map_err(|err| format!("{}", err)) } @@ -559,7 +568,7 @@ impl> Backend { let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); - let state_db: StateDb = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; + let state_db: StateDb<_, _> = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db: db.clone(), state_db, @@ -832,7 +841,7 @@ impl> Backend { transaction.put(columns::META, meta_keys::GENESIS_HASH, hash.as_ref()); } - let mut changeset: state_db::ChangeSet = state_db::ChangeSet::default(); + let mut changeset: state_db::ChangeSet> = state_db::ChangeSet::default(); for (key, (val, rc)) in operation.db_updates.drain() { if rc > 0 { changeset.inserted.push((key, val.to_vec())); @@ -981,7 +990,7 @@ impl> Backend { } } -fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet) { +fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet>) { for (key, val) in commit.data.inserted.into_iter() { transaction.put(columns::STATE, &key[..], &val); } @@ -1031,7 +1040,7 @@ impl client::backend::Backend for Backend whe Ok(BlockImportOperation { pending_block: None, old_state, - db_updates: MemoryDB::default(), + db_updates: PrefixedMemoryDB::default(), storage_updates: Default::default(), changes_trie_updates: MemoryDB::default(), aux_ops: Vec::new(), @@ -1169,6 +1178,10 @@ impl client::backend::Backend for Backend whe } } + fn have_state_at(&self, hash: &Block::Hash, number: NumberFor) -> bool { + !self.storage.state_db.is_pruned(hash, number.as_()) + } + fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> { if let Some(hash) = state.parent_hash.clone() { let is_best = || self.blockchain.meta.read().best_hash == hash; @@ -1410,7 +1423,7 @@ mod tests { op.reset_storage(storage.iter().cloned().collect(), Default::default()).unwrap(); - key = op.db_updates.insert(b"hello"); + key = op.db_updates.insert(&[], b"hello"); op.set_block_data( header, Some(vec![]), @@ -1444,8 +1457,8 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.insert(b"hello"); - op.db_updates.remove(&key); + op.db_updates.insert(&[], b"hello"); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1479,7 +1492,7 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.remove(&key); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1545,7 +1558,7 @@ mod tests { assert_eq!(backend.changes_tries_storage.root(&anchor, block), Ok(Some(changes_root))); for (key, (val, _)) in changes_trie_update.drain() { - assert_eq!(backend.changes_trie_storage().unwrap().get(&key), Ok(Some(val))); + assert_eq!(backend.changes_trie_storage().unwrap().get(&key, &[]), Ok(Some(val))); } }; @@ -1671,23 +1684,23 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 12); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root4).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root4, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_some()); // now simulate finalization of block#16, causing prune of tries at #5..#8 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 16); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_none()); // now "change" pruning mode to archive && simulate finalization of block#20 // => no changes tries are pruned, because we never prune in archive mode @@ -1695,10 +1708,10 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config), &mut tx, Default::default(), 20); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root9).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root10).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root11).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root12).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root9, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root10, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root11, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root12, &[]).unwrap().is_some()); } #[test] @@ -1737,15 +1750,15 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block5, 5); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_some()); // now simulate finalization of block#6, causing prune of tries at #2 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block6, 6); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_some()); } #[test] diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 8a3456df69a305c55870617c4147950a517c0da5..62b6486f54d7ea28ac5561a33aa5b374943e26ec 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! RocksDB-based light client blockchain storage. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -32,7 +32,8 @@ use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, - Zero, One, As, NumberFor, Digest, DigestItem, AuthorityIdFor}; + Zero, One, As, NumberFor, Digest, DigestItem}; +use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId}; use crate::utils::{self, meta_keys, Meta, db_err, open_database, read_db, block_id_to_lookup_key, read_meta}; @@ -59,7 +60,7 @@ pub struct LightStorage { db: Arc, meta: RwLock, Block::Hash>>, leaves: RwLock>>, - cache: DbCacheSync, + cache: Arc>, } impl LightStorage @@ -96,7 +97,7 @@ impl LightStorage Ok(LightStorage { db, meta: RwLock::new(meta), - cache: DbCacheSync(RwLock::new(cache)), + cache: Arc::new(DbCacheSync(RwLock::new(cache))), leaves: RwLock::new(leaves), }) } @@ -370,7 +371,7 @@ impl LightBlockchainStorage for LightStorage fn import_header( &self, header: Block::Header, - authorities: Option>>, + cache_at: HashMap>, leaf_state: NewBlockState, aux_ops: Vec<(Vec, Option>)>, ) -> ClientResult<()> { @@ -432,7 +433,7 @@ impl LightBlockchainStorage for LightStorage .on_block_insert( ComplexBlockId::new(*header.parent_hash(), if number.is_zero() { Zero::zero() } else { number - One::one() }), ComplexBlockId::new(hash, number), - authorities, + cache_at, finalized, )? .into_ops(); @@ -521,8 +522,8 @@ impl LightBlockchainStorage for LightStorage Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&BlockchainCache> { - Some(&self.cache) + fn cache(&self) -> Option>> { + Some(self.cache.clone()) } } @@ -538,9 +539,11 @@ pub(crate) mod tests { use client::cht; use runtime_primitives::generic::DigestItem; use runtime_primitives::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; + use runtime_primitives::traits::AuthorityIdFor; use super::*; type Block = RawBlock>; + type AuthorityId = AuthorityIdFor; pub fn default_header(parent: &Hash, number: u64) -> Header { Header { @@ -566,41 +569,41 @@ pub(crate) mod tests { pub fn insert_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Best, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Best, Vec::new()).unwrap(); hash } fn insert_final_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Final, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Final, Vec::new()).unwrap(); hash } fn insert_non_best_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Normal, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Normal, Vec::new()).unwrap(); hash } #[test] fn returns_known_header() { let db = LightStorage::new_test(); - let known_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let known_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let header_by_hash = db.header(BlockId::Hash(known_hash)).unwrap().unwrap(); let header_by_number = db.header(BlockId::Number(0)).unwrap().unwrap(); assert_eq!(header_by_hash, header_by_number); @@ -616,12 +619,12 @@ pub(crate) mod tests { #[test] fn returns_info() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let info = db.info().unwrap(); assert_eq!(info.best_hash, genesis_hash); assert_eq!(info.best_number, 0); assert_eq!(info.genesis_hash, genesis_hash); - let best_hash = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let best_hash = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); let info = db.info().unwrap(); assert_eq!(info.best_hash, best_hash); assert_eq!(info.best_number, 1); @@ -631,7 +634,7 @@ pub(crate) mod tests { #[test] fn returns_block_status() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.status(BlockId::Hash(genesis_hash)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Number(0)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Hash(Hash::from_low_u64_be(1))).unwrap(), BlockStatus::Unknown); @@ -641,7 +644,7 @@ pub(crate) mod tests { #[test] fn returns_block_hash() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.hash(0).unwrap(), Some(genesis_hash)); assert_eq!(db.hash(1).unwrap(), None); } @@ -650,11 +653,11 @@ pub(crate) mod tests { fn import_header_works() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.db.iter(columns::HEADER).count(), 1); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 2); - let _ = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let _ = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); assert_eq!(db.db.iter(columns::HEADER).count(), 2); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 4); } @@ -665,25 +668,25 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert genesis block header (never pruned) - let mut prev_hash = insert_final_block(&db, None, || header_producer(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_producer(&Default::default(), 0)); // insert SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert next SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert block #{2 * cht::SIZE + 1} && check that new CHT is created + headers of this CHT are pruned // nothing is yet finalized, so nothing is pruned. - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); assert_eq!(db.db.iter(columns::HEADER).count(), (2 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); @@ -732,9 +735,9 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert 1 + SIZE + SIZE + 1 blocks so that CHT#0 is created - let mut prev_hash = insert_final_block(&db, None, || header_with_changes_trie(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_with_changes_trie(&Default::default(), 0)); for i in 1..1 + cht::SIZE + cht::SIZE + 1 { - prev_hash = insert_block(&db, None, || header_with_changes_trie(&prev_hash, i as u64)); + prev_hash = insert_block(&db, HashMap::new(), || header_with_changes_trie(&prev_hash, i as u64)); db.finalize_header(BlockId::Hash(prev_hash)).unwrap(); } @@ -754,16 +757,16 @@ pub(crate) mod tests { #[test] fn tree_route_works() { let db = LightStorage::new_test(); - let block0 = insert_block(&db, None, || default_header(&Default::default(), 0)); + let block0 = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); // fork from genesis: 3 prong. - let a1 = insert_block(&db, None, || default_header(&block0, 1)); - let a2 = insert_block(&db, None, || default_header(&a1, 2)); - let a3 = insert_block(&db, None, || default_header(&a2, 3)); + let a1 = insert_block(&db, HashMap::new(), || default_header(&block0, 1)); + let a2 = insert_block(&db, HashMap::new(), || default_header(&a1, 2)); + let a3 = insert_block(&db, HashMap::new(), || default_header(&a2, 3)); // fork from genesis: 2 prong. - let b1 = insert_block(&db, None, || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); - let b2 = insert_block(&db, None, || default_header(&b1, 2)); + let b1 = insert_block(&db, HashMap::new(), || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); + let b2 = insert_block(&db, HashMap::new(), || default_header(&b1, 2)); { let tree_route = ::client::blockchain::tree_route( @@ -815,44 +818,64 @@ pub(crate) mod tests { } #[test] - fn authorites_are_cached() { + fn authorities_are_cached() { let db = LightStorage::new_test(); fn run_checks(db: &LightStorage, max: u64, checks: &[(u64, Option>>)]) { for (at, expected) in checks.iter().take_while(|(at, _)| *at <= max) { - let actual = db.cache().authorities_at(BlockId::Number(*at)); + let actual = get_authorities(db.cache(), BlockId::Number(*at)); assert_eq!(*expected, actual); } } + fn same_authorities() -> HashMap> { + HashMap::new() + } + + fn make_authorities(authorities: Vec) -> HashMap> { + let mut map = HashMap::new(); + map.insert(well_known_cache_keys::AUTHORITIES, authorities.encode()); + map + } + + fn get_authorities(cache: &BlockchainCache, at: BlockId) -> Option
(params: NodeKeyParams, net_config_dir: &Option
) + -> error::Result +where + P: AsRef +{ + match params.node_key_type { + NodeKeyType::Secp256k1 => + params.node_key.as_ref().map(parse_secp256k1_secret).unwrap_or_else(|| + Ok(params.node_key_file + .or_else(|| net_config_file(net_config_dir, NODE_KEY_SECP256K1_FILE)) + .map(network::Secret::File) + .unwrap_or(network::Secret::New))) + .map(NodeKeyConfig::Secp256k1), + + NodeKeyType::Ed25519 => + params.node_key.as_ref().map(parse_ed25519_secret).unwrap_or_else(|| + Ok(params.node_key_file + .or_else(|| net_config_file(net_config_dir, NODE_KEY_ED25519_FILE)) + .map(network::Secret::File) + .unwrap_or(network::Secret::New))) + .map(NodeKeyConfig::Ed25519) } } +fn net_config_file(net_config_dir: &Option, name: &str) -> Option +where + P: AsRef +{ + net_config_dir.as_ref().map(|d| d.as_ref().join(name)) +} + +/// Create an error caused by an invalid node key argument. +fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { + input_err(format!("Invalid node key: {}", e)) +} + +/// Parse a Secp256k1 secret key from a hex string into a `network::Secret`. +fn parse_secp256k1_secret(hex: &String) -> error::Result { + H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::secp256k1::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + +/// Parse a Ed25519 secret key from a hex string into a `network::Secret`. +fn parse_ed25519_secret(hex: &String) -> error::Result { + H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::ed25519::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + /// Fill the given `PoolConfiguration` by looking at the cli parameters. fn fill_transaction_pool_configuration( options: &mut FactoryFullConfiguration, @@ -295,11 +354,13 @@ fn fill_network_configuration( config.public_addresses = Vec::new(); config.client_version = client_id; - config.use_secret = parse_node_key(cli.node_key)?; + config.node_key = node_key_config(cli.node_key_params, &config.net_config_path)?; config.in_peers = cli.in_peers; config.out_peers = cli.out_peers; + config.enable_mdns = !cli.no_mdns; + Ok(()) } @@ -317,14 +378,14 @@ where config.impl_commit = version.commit; config.impl_version = version.version; - config.name = match cli.name { + config.name = match cli.name.or(cli.keyring.account.map(|a| a.to_string())) { None => generate_node_name(), Some(name) => name, }; match is_node_name_valid(&config.name) { Ok(_) => (), Err(msg) => bail!( - create_input_err( + input_err( format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", config.name, msg @@ -347,7 +408,7 @@ where Some(ref s) if s == "archive" => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => PruningMode::keep_blocks( - s.parse().map_err(|_| create_input_err("Invalid pruning mode specified"))? + s.parse().map_err(|_| input_err("Invalid pruning mode specified"))? ), }; @@ -360,14 +421,25 @@ where service::Roles::FULL }; + let exec = cli.execution_strategies; config.execution_strategies = ExecutionStrategies { - syncing: cli.syncing_execution.into(), - importing: cli.importing_execution.into(), - block_construction: cli.block_construction_execution.into(), - other: cli.other_execution.into(), + syncing: exec.syncing_execution.into(), + importing: exec.importing_execution.into(), + block_construction: exec.block_construction_execution.into(), + offchain_worker: exec.offchain_worker_execution.into(), + other: exec.other_execution.into(), + }; + + config.offchain_worker = match (cli.offchain_worker, role) { + (params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true, + (params::OffchainWorkerEnabled::Always, _) => true, + (params::OffchainWorkerEnabled::Never, _) => false, + (params::OffchainWorkerEnabled::WhenValidating, _) => false, }; config.roles = role; + config.disable_grandpa = cli.no_grandpa; + let client_id = config.client_id(); fill_network_configuration( cli.network_config, @@ -387,7 +459,11 @@ where } if cli.shared_params.dev { - config.keys.push("Alice".into()); + config.keys.push("//Alice".into()); + } + + if let Some(account) = cli.keyring.account { + config.keys.push(format!("//{}", account)); } let rpc_interface: &str = if cli.rpc_external { "0.0.0.0" } else { "127.0.0.1" }; @@ -407,6 +483,8 @@ where config.telemetry_endpoints = Some(TelemetryEndpoints::new(cli.telemetry_endpoints)); } + config.force_authoring = cli.force_authoring; + Ok(config) } @@ -439,23 +517,19 @@ where // 9926-9949 Unassigned fn with_default_boot_node( - mut spec: ChainSpec>, - cli: &BuildSpecCmd, + spec: &mut ChainSpec>, + cli: BuildSpecCmd, version: &VersionInfo, -) -> error::Result>> +) -> error::Result<()> where F: ServiceFactory { if spec.boot_nodes().is_empty() { - let network_path = - Some(network_path(&base_path(&cli.shared_params, version), spec.id()).to_string_lossy().into()); - let network_key = parse_node_key(cli.node_key.clone())?; - - let network_keys = - network::obtain_private_key(&network_key, &network_path) - .map_err(|err| format!("Error obtaining network key: {}", err))?; - - let peer_id = network_keys.to_peer_id(); + let base_path = base_path(&cli.shared_params, version); + let storage_path = network_path(&base_path, spec.id()); + let node_key = node_key_config(cli.node_key_params, &Some(storage_path))?; + let keys = node_key.into_keypair()?; + let peer_id = keys.public().into_peer_id(); let addr = build_multiaddr![ Ip4([127, 0, 0, 1]), Tcp(30333u16), @@ -463,7 +537,7 @@ where ]; spec.add_boot_node(addr) } - Ok(spec) + Ok(()) } fn build_spec( @@ -476,9 +550,10 @@ where S: FnOnce(&str) -> Result>>, String>, { info!("Building chain spec"); - let spec = load_spec(&cli.shared_params, spec_factory)?; - let spec = with_default_boot_node::(spec, &cli, version)?; - let json = service::chain_ops::build_spec::>(spec, cli.raw)?; + let raw_output = cli.raw; + let mut spec = load_spec(&cli.shared_params, spec_factory)?; + with_default_boot_node::(&mut spec, cli, version)?; + let json = service::chain_ops::build_spec::>(spec, raw_output)?; print!("{}", json); @@ -574,23 +649,28 @@ where S: FnOnce(&str) -> Result>>, String>, { let config = create_config_with_db_path::(spec_factory, &cli.shared_params, version)?; - let db_path = config.database_path; - print!("Are you sure to remove {:?}? (y/n)", &db_path); - stdout().flush().expect("failed to flush stdout"); - - let mut input = String::new(); - stdin().read_line(&mut input)?; - let input = input.trim(); - - match input.chars().nth(0) { - Some('y') | Some('Y') => { - fs::remove_dir_all(&db_path)?; - println!("{:?} removed.", &db_path); - }, - _ => println!("Aborted"), + + if cli.yes == false { + print!("Are you sure to remove {:?}? (y/n)", &db_path); + stdout().flush().expect("failed to flush stdout"); + + let mut input = String::new(); + stdin().read_line(&mut input)?; + let input = input.trim(); + + match input.chars().nth(0) { + Some('y') | Some('Y') => {}, + _ => { + println!("Aborted"); + return Ok(()); + }, + } } + fs::remove_dir_all(&db_path)?; + println!("{:?} removed.", &db_path); + Ok(()) } @@ -698,6 +778,8 @@ fn kill_color(s: &str) -> String { #[cfg(test)] mod tests { use super::*; + use tempdir::TempDir; + use network::identity::{secp256k1, ed25519}; #[test] fn tests_node_name_good() { @@ -713,4 +795,111 @@ mod tests { assert!(is_node_name_valid("www.visit.me").is_err()); assert!(is_node_name_valid("email@domain").is_err()); } + + #[test] + fn test_node_key_config_input() { + fn secret_input(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let sk = match node_key_type { + NodeKeyType::Secp256k1 => secp256k1::SecretKey::generate().as_ref().to_vec(), + NodeKeyType::Ed25519 => ed25519::SecretKey::generate().as_ref().to_vec() + }; + let params = NodeKeyParams { + node_key_type, + node_key: Some(format!("{:x}", H256::from_slice(sk.as_ref()))), + node_key_file: None + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Secp256k1 && + &sk[..] == ski.as_ref() => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Ed25519 && + &sk[..] == ski.as_ref() => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_input(None).is_ok()); + assert!(secret_input(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_file() { + fn secret_file(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let tmp = TempDir::new("alice")?; + let file = tmp.path().join(format!("{}_mysecret", t)).to_path_buf(); + let params = NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: Some(file.clone()) + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Secp256k1 && f == &file => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_file(None).is_ok()); + assert!(secret_file(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_default() { + fn with_def_params(f: F) -> error::Result<()> + where + F: Fn(NodeKeyParams) -> error::Result<()> + { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + f(NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: None + }) + }) + } + + fn no_config_dir() -> error::Result<()> { + with_def_params(|params| { + let typ = params.node_key_type; + node_key_config::(params, &None) + .and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::New) + if typ == NodeKeyType::Secp256k1 => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::New) + if typ == NodeKeyType::Ed25519 => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + fn some_config_dir(net_config_dir: String) -> error::Result<()> { + with_def_params(|params| { + let dir = PathBuf::from(net_config_dir.clone()); + let typ = params.node_key_type; + node_key_config(params, &Some(net_config_dir.clone())) + .and_then(move |c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if typ == NodeKeyType::Secp256k1 && + f == &dir.join(NODE_KEY_SECP256K1_FILE) => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if typ == NodeKeyType::Ed25519 && + f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(no_config_dir().is_ok()); + assert!(some_config_dir("x".to_string()).is_ok()); + } } diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 26a9a00ebf0a00d271b0036a2ff2958054962680..321cf17efb39cff59dd950dcd4d6b95df4cb7388 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Parity Technologies (UK) Ltd. +// Copyright 2018-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ use crate::traits::{AugmentClap, GetLogFilter}; use std::path::PathBuf; -use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand}}; +use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand, Arg}}; use client; /// Auxialary macro to implement `GetLogFilter` for all types that have the `shared_params` field. @@ -39,6 +39,7 @@ arg_enum! { Wasm, Both, NativeElseWasm, + NativeWhenPossible, } } @@ -49,10 +50,21 @@ impl Into for ExecutionStrategy { ExecutionStrategy::Wasm => client::ExecutionStrategy::AlwaysWasm, ExecutionStrategy::Both => client::ExecutionStrategy::Both, ExecutionStrategy::NativeElseWasm => client::ExecutionStrategy::NativeElseWasm, + ExecutionStrategy::NativeWhenPossible => client::ExecutionStrategy::NativeWhenPossible, } } } +arg_enum! { + /// How to execute blocks + #[derive(Debug, Clone)] + pub enum OffchainWorkerEnabled { + Always, + Never, + WhenValidating, + } +} + /// Shared parameters used by all `CoreParams`. #[derive(Debug, StructOpt, Clone)] pub struct SharedParams { @@ -68,7 +80,7 @@ pub struct SharedParams { #[structopt(long = "base-path", short = "d", value_name = "PATH", parse(from_os_str))] pub base_path: Option, - ///Sets a custom logging filter + /// Sets a custom logging filter #[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")] pub log: Option, } @@ -98,10 +110,6 @@ pub struct NetworkConfigurationParams { #[structopt(long = "port", value_name = "PORT")] pub port: Option, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, - /// Specify the number of outgoing connections we're trying to maintain #[structopt(long = "out-peers", value_name = "OUT_PEERS", default_value = "25")] pub out_peers: u32, @@ -109,6 +117,98 @@ pub struct NetworkConfigurationParams { /// Specify the maximum number of incoming connections we're accepting #[structopt(long = "in-peers", value_name = "IN_PEERS", default_value = "25")] pub in_peers: u32, + + /// By default, the network will use mDNS to discover other nodes on the local network. This + /// disables it. + #[structopt(long = "no-mdns")] + pub no_mdns: bool, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams +} + +arg_enum! { + #[derive(Debug, Copy, Clone, PartialEq, Eq)] + pub enum NodeKeyType { + Secp256k1, + Ed25519 + } +} + +/// Parameters used to create the `NodeKeyConfig`, which determines the keypair +/// used for libp2p networking. +#[derive(Debug, StructOpt, Clone)] +pub struct NodeKeyParams { + /// The secret key to use for libp2p networking. + /// + /// The value is a string that is parsed according to the choice of + /// `--node-key-type` as follows: + /// + /// `secp256k1`: + /// The value is parsed as a hex-encoded Secp256k1 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// `ed25519`: + /// The value is parsed as a hex-encoded Ed25519 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// The value of this option takes precedence over `--node-key-file`. + /// + /// WARNING: Secrets provided as command-line arguments are easily exposed. + /// Use of this option should be limited to development and testing. To use + /// an externally managed secret key, use `--node-key-file` instead. + #[structopt(long = "node-key", value_name = "KEY")] + pub node_key: Option, + + /// The type of secret key to use for libp2p networking. + /// + /// The secret key of the node is obtained as follows: + /// + /// * If the `--node-key` option is given, the value is parsed as a secret key + /// according to the type. See the documentation for `--node-key`. + /// + /// * If the `--node-key-file` option is given, the secret key is read from the + /// specified file. See the documentation for `--node-key-file`. + /// + /// * Otherwise, the secret key is read from a file with a predetermined, + /// type-specific name from the chain-specific network config directory + /// inside the base directory specified by `--base-dir`. If this file does + /// not exist, it is created with a newly generated secret key of the + /// chosen type. + /// + /// The node's secret key determines the corresponding public key and hence the + /// node's peer ID in the context of libp2p. + /// + /// NOTE: The current default key type is `secp256k1` for a transition period only + /// but will eventually change to `ed25519` in a future release. To continue using + /// `secp256k1` keys, use `--node-key-type=secp256k1`. + #[structopt( + long = "node-key-type", + value_name = "TYPE", + raw( + possible_values = "&NodeKeyType::variants()", + case_insensitive = "true", + default_value = r#""Secp256k1""# + ) + )] + pub node_key_type: NodeKeyType, + + /// The file from which to read the node's secret key to use for libp2p networking. + /// + /// The contents of the file are parsed according to the choice of `--node-key-type` + /// as follows: + /// + /// `secp256k1`: + /// The file must contain an unencoded 32 bytes Secp256k1 secret key. + /// + /// `ed25519`: + /// The file must contain an unencoded 32 bytes Ed25519 secret key. + /// + /// If the file does not exist, it is created with a newly generated secret key of + /// the chosen type. + #[structopt(long = "node-key-file", value_name = "FILE")] + pub node_key_file: Option } /// Parameters used to create the pool configuration. @@ -122,6 +222,70 @@ pub struct TransactionPoolParams { pub pool_kbytes: usize, } +/// Execution strategies parameters. +#[derive(Debug, StructOpt, Clone)] +pub struct ExecutionStrategies { + /// The means of execution used when calling into the runtime while syncing blocks. + #[structopt( + long = "syncing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub syncing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while importing blocks. + #[structopt( + long = "importing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub importing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "block-construction-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub block_construction_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "offchain-worker-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeWhenPossible""# + ) + )] + pub offchain_worker_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. + #[structopt( + long = "other-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub other_execution: ExecutionStrategy, +} + /// The `run` command used to run a node. #[derive(Debug, StructOpt, Clone)] pub struct RunCmd { @@ -137,6 +301,10 @@ pub struct RunCmd { #[structopt(long = "validator")] pub validator: bool, + /// Disable GRANDPA when running in validator mode + #[structopt(long = "no-grandpa")] + pub no_grandpa: bool, + /// Run in light client mode #[structopt(long = "light")] pub light: bool, @@ -169,7 +337,7 @@ pub struct RunCmd { #[structopt(long = "name", value_name = "NAME")] pub name: Option, - /// Should not connect to the Substrate telemetry server (telemetry is on by default on global chains) + /// Disable connecting to the Substrate telemetry server (telemetry is on by default on global chains). #[structopt(long = "no-telemetry")] pub no_telemetry: bool, @@ -179,55 +347,23 @@ pub struct RunCmd { #[structopt(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = "parse_telemetry_endpoints"))] pub telemetry_endpoints: Vec<(String, u8)>, - /// The means of execution used when calling into the runtime while syncing blocks. + /// Should execute offchain workers on every block. By default it's only enabled for nodes that are authoring new + /// blocks. #[structopt( - long = "syncing-execution", - value_name = "STRATEGY", + long = "offchain-worker", + value_name = "ENABLED", raw( - possible_values = "&ExecutionStrategy::variants()", + possible_values = "&OffchainWorkerEnabled::variants()", case_insensitive = "true", - default_value = r#""NativeElseWasm""# + default_value = r#""WhenValidating""# ) )] - pub syncing_execution: ExecutionStrategy, + pub offchain_worker: OffchainWorkerEnabled, - /// The means of execution used when calling into the runtime while importing blocks. - #[structopt( - long = "importing-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""NativeElseWasm""# - ) - )] - pub importing_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while constructing blocks. - #[structopt( - long = "block-construction-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub block_construction_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. - #[structopt( - long = "other-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub other_execution: ExecutionStrategy, + #[allow(missing_docs)] + #[structopt(flatten)] + pub execution_strategies: ExecutionStrategies, - #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, @@ -239,6 +375,84 @@ pub struct RunCmd { #[allow(missing_docs)] #[structopt(flatten)] pub pool_config: TransactionPoolParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub keyring: Keyring, + + /// Enable authoring even when offline. + #[structopt(long = "force-authoring")] + pub force_authoring: bool, +} + +/// Stores all required Cli values for a keyring test account. +struct KeyringTestAccountCliValues { + help: String, + conflicts_with: Vec, + name: String, + variant: keyring::AuthorityKeyring, +} + +lazy_static::lazy_static! { + /// The Cli values for all test accounts. + static ref TEST_ACCOUNTS_CLI_VALUES: Vec = { + keyring::AuthorityKeyring::iter().map(|a| { + let help = format!("Shortcut for `--key //{} --name {}`.", a, a); + let conflicts_with = keyring::AuthorityKeyring::iter() + .filter(|b| a != *b) + .map(|b| b.to_string().to_lowercase()) + .chain(["name", "key"].iter().map(|s| s.to_string())) + .collect::>(); + let name = a.to_string().to_lowercase(); + + KeyringTestAccountCliValues { + help, + conflicts_with, + name, + variant: a, + } + }).collect() + }; +} + +/// Wrapper for exposing the keyring test accounts into the Cli. +#[derive(Debug, Clone)] +pub struct Keyring { + pub account: Option, +} + +impl StructOpt for Keyring { + fn clap<'a, 'b>() -> App<'a, 'b> { + unimplemented!("Should not be called for `TestAccounts`.") + } + + fn from_clap(m: &::structopt::clap::ArgMatches) -> Self { + Keyring { + account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant), + } + } +} + +impl AugmentClap for Keyring { + fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| { + let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::>(); + + app.arg( + Arg::with_name(&a.name) + .long(&a.name) + .help(&a.help) + .conflicts_with_all(&conflicts_with_strs) + .takes_value(false) + ) + }) + } +} + +impl Keyring { + fn is_subcommand() -> bool { + false + } } /// Default to verbosity level 0, if none is provided. @@ -270,9 +484,9 @@ pub struct BuildSpecCmd { #[structopt(flatten)] pub shared_params: SharedParams, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams, } impl_get_log_filter!(BuildSpecCmd); @@ -338,6 +552,10 @@ impl_get_log_filter!(RevertCmd); /// The `purge-chain` command used to remove the whole chain. #[derive(Debug, StructOpt, Clone)] pub struct PurgeChainCmd { + /// Skip interactive prompt by answering yes automatically. + #[structopt(short = "y")] + pub yes: bool, + #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, diff --git a/core/client/Cargo.toml b/core/client/Cargo.toml index 495b11b61d5b8aa0ecda2a9507b608db280b254d..cfc7eb3e3447e4f4c2a39d46fb5dcbadac9bdeef 100644 --- a/core/client/Cargo.toml +++ b/core/client/Cargo.toml @@ -18,9 +18,9 @@ state-machine = { package = "substrate-state-machine", path = "../state-machine" keyring = { package = "substrate-keyring", path = "../keyring", optional = true } trie = { package = "substrate-trie", path = "../trie", optional = true } substrate-telemetry = { path = "../telemetry", optional = true } -hash-db = { version = "0.11", optional = true } +hash-db = { version = "0.12", optional = true } kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } runtime-primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } runtime-version = { package = "sr-version", path = "../sr-version", default-features = false } diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 8828eefa4fbf391d21bb4d8fbc3ef2396461c486..2944ab533b551c924d55c7fbf2adc81b36b5857b 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -12,15 +12,16 @@ kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } lru-cache = "0.1.1" -hash-db = { version = "0.11" } +hash-db = { version = "0.12" } primitives = { package = "substrate-primitives", path = "../../primitives" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } client = { package = "substrate-client", path = "../../client" } state-machine = { package = "substrate-state-machine", path = "../../state-machine" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } executor = { package = "substrate-executor", path = "../../executor" } state_db = { package = "substrate-state-db", path = "../../state-db" } trie = { package = "substrate-trie", path = "../../trie" } +consensus_common = { package = "substrate-consensus-common", path = "../../consensus/common" } [dev-dependencies] kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } diff --git a/core/client/db/src/cache/list_cache.rs b/core/client/db/src/cache/list_cache.rs index f8e52e14c630f07b421eaff4b69ca1bd0071c4fc..1e641534f969c0d63eefe387e98c9ded8bb3c81a 100644 --- a/core/client/db/src/cache/list_cache.rs +++ b/core/client/db/src/cache/list_cache.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_entry.rs b/core/client/db/src/cache/list_entry.rs index d2d88ab12f38ab341a6b69b51d35fbe989ac23e5..237ae9a268026744b87f6d85b7c6301cb82ee204 100644 --- a/core/client/db/src/cache/list_entry.rs +++ b/core/client/db/src/cache/list_entry.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_storage.rs b/core/client/db/src/cache/list_storage.rs index b9bf99f67b884fba4ae85f358cb9c0b731cb834b..659a30507e136576a844624fa167eb1cfb08ddb9 100644 --- a/core/client/db/src/cache/list_storage.rs +++ b/core/client/db/src/cache/list_storage.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index 12f8c5e519782a9b2db3e7842176665e41b120f5..b5dd45f11dd52e69ea715243924ac5e799e038b1 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! DB-backed cache of blockchain data. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -25,7 +25,8 @@ use client::blockchain::Cache as BlockchainCache; use client::error::Result as ClientResult; use parity_codec::{Encode, Decode}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As}; +use consensus_common::well_known_cache_keys::Id as CacheKeyId; use crate::utils::{self, COLUMN_META}; use self::list_cache::ListCache; @@ -64,7 +65,12 @@ impl CacheItemT for T where T: Clone + Decode + Encode + PartialEq {} /// Database-backed blockchain data cache. pub struct DbCache { - authorities_at: ListCache>, self::list_storage::DbStorage>, + cache_at: HashMap, self::list_storage::DbStorage>>, + db: Arc, + key_lookup_column: Option, + header_column: Option, + authorities_column: Option, + best_finalized_block: ComplexBlockId, } impl DbCache { @@ -76,19 +82,13 @@ impl DbCache { authorities_column: Option, best_finalized_block: ComplexBlockId, ) -> Self { - DbCache { - authorities_at: ListCache::new( - self::list_storage::DbStorage::new(b"auth".to_vec(), db, - self::list_storage::DbColumns { - meta: COLUMN_META, - key_lookup: key_lookup_column, - header: header_column, - cache: authorities_column, - }, - ), - As::sa(PRUNE_DEPTH), - best_finalized_block, - ), + Self { + cache_at: HashMap::new(), + db, + key_lookup_column, + header_column, + authorities_column, + best_finalized_block, } } @@ -97,35 +97,82 @@ impl DbCache { DbCacheTransaction { cache: self, tx, - authorities_at_op: None, + cache_at_op: HashMap::new(), + best_finalized_block: None, } } /// Run post-commit cache operations. pub fn commit(&mut self, ops: DbCacheTransactionOps) { - if let Some(authorities_at_op) = ops.authorities_at_op { - self.authorities_at.on_transaction_commit(authorities_at_op); + for (name, op) in ops.cache_at_op.into_iter() { + self.get_cache(name).on_transaction_commit(op); + } + if let Some(best_finalized_block) = ops.best_finalized_block { + self.best_finalized_block = best_finalized_block; } } + + /// Creates `ListCache` with the given name or returns a reference to the existing. + fn get_cache(&mut self, name: CacheKeyId) -> &mut ListCache, self::list_storage::DbStorage> { + get_cache_helper( + &mut self.cache_at, + name, + &self.db, + self.key_lookup_column, + self.header_column, + self.authorities_column, + &self.best_finalized_block + ) + } +} + +// This helper is needed because otherwise the borrow checker will require to +// clone all parameters outside of the closure. +fn get_cache_helper<'a, Block: BlockT>( + cache_at: &'a mut HashMap, self::list_storage::DbStorage>>, + name: CacheKeyId, + db: &Arc, + key_lookup: Option, + header: Option, + cache: Option, + best_finalized_block: &ComplexBlockId, +) -> &'a mut ListCache, self::list_storage::DbStorage> { + cache_at.entry(name).or_insert_with(|| { + ListCache::new( + self::list_storage::DbStorage::new(name.to_vec(), db.clone(), + self::list_storage::DbColumns { + meta: COLUMN_META, + key_lookup, + header, + cache, + }, + ), + As::sa(PRUNE_DEPTH), + best_finalized_block.clone(), + ) + }) } /// Cache operations that are to be committed after database transaction is committed. pub struct DbCacheTransactionOps { - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } /// Database-backed blockchain data cache transaction valid for single block import. pub struct DbCacheTransaction<'a, Block: BlockT> { cache: &'a mut DbCache, tx: &'a mut DBTransaction, - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { /// Convert transaction into post-commit operations set. pub fn into_ops(self) -> DbCacheTransactionOps { DbCacheTransactionOps { - authorities_at_op: self.authorities_at_op, + cache_at_op: self.cache_at_op, + best_finalized_block: self.best_finalized_block, } } @@ -134,21 +181,42 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { mut self, parent: ComplexBlockId, block: ComplexBlockId, - authorities_at: Option>>, + data_at: HashMap>, is_final: bool, ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_insert( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - authorities_at, - is_final, - )?; + // prepare list of caches that are not update + // (we might still need to do some cache maintenance in this case) + let missed_caches = self.cache.cache_at.keys() + .filter(|cache| !data_at.contains_key(cache.clone())) + .cloned() + .collect::>(); + + let mut insert_op = |name: CacheKeyId, value: Option>| -> Result<(), client::error::Error> { + let cache = self.cache.get_cache(name); + let op = cache.on_block_insert( + &mut self::list_storage::DbStorageTransaction::new( + cache.storage(), + &mut self.tx, + ), + parent.clone(), + block.clone(), + value.or(cache.value_at_block(&parent)?), + is_final, + )?; + if let Some(op) = op { + self.cache_at_op.insert(name, op); + } + Ok(()) + }; + + data_at.into_iter().try_for_each(|(name, data)| insert_op(name, Some(data)))?; + missed_caches.into_iter().try_for_each(|name| insert_op(name, None))?; + + if is_final { + self.best_finalized_block = Some(block); + } Ok(self) } @@ -159,16 +227,24 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { parent: ComplexBlockId, block: ComplexBlockId ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_finalize( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - )?; + for (name, cache_at) in self.cache.cache_at.iter() { + let op = cache_at.on_block_finalize( + &mut self::list_storage::DbStorageTransaction::new( + cache_at.storage(), + &mut self.tx + ), + parent.clone(), + block.clone(), + )?; + + if let Some(op) = op { + self.cache_at_op.insert(name.to_owned(), op); + } + } + + self.best_finalized_block = Some(block); Ok(self) } @@ -178,12 +254,12 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { pub struct DbCacheSync(pub RwLock>); impl BlockchainCache for DbCacheSync { - fn authorities_at(&self, at: BlockId) -> Option>> { + fn get_at(&self, key: &CacheKeyId, at: &BlockId) -> Option> { let cache = self.0.read(); - let storage = cache.authorities_at.storage(); + let storage = cache.cache_at.get(key)?.storage(); let db = storage.db(); let columns = storage.columns(); - let at = match at { + let at = match *at { BlockId::Hash(hash) => { let header = utils::read_header::( &**db, @@ -202,6 +278,7 @@ impl BlockchainCache for DbCacheSync { }, }; - cache.authorities_at.value_at_block(&at).ok()? + cache.cache_at.get(key)?.value_at_block(&at).ok()? } } + diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 36ac3cc3450552cc8e6f4280898ca413a8fb3ec3..7657bfd39691a0e2bec1e89e8ed7d84339ae1446 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -33,6 +33,7 @@ mod utils; use std::sync::Arc; use std::path::PathBuf; use std::io; +use std::collections::HashMap; use client::backend::NewBlockState; use client::blockchain::HeaderBackend; @@ -40,12 +41,12 @@ use client::ExecutionStrategies; use parity_codec::{Decode, Encode}; use hash_db::Hasher; use kvdb::{KeyValueDB, DBTransaction}; -use trie::MemoryDB; +use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::RwLock; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash}; use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem}; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; @@ -54,6 +55,7 @@ use crate::utils::{Meta, db_err, meta_keys, open_database, read_db, block_id_to_ use client::leaves::{LeafSet, FinalizationDisplaced}; use client::children; use state_db::StateDb; +use consensus_common::well_known_cache_keys; use crate::storage_cache::{CachingState, SharedCache, new_shared_cache}; use log::{trace, debug, warn}; pub use state_db::PruningMode; @@ -243,7 +245,7 @@ impl client::blockchain::Backend for BlockchainDb { Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&client::blockchain::Cache> { + fn cache(&self) -> Option>> { None } @@ -256,10 +258,16 @@ impl client::blockchain::Backend for BlockchainDb { } } +impl client::blockchain::ProvideCache for BlockchainDb { + fn cache(&self) -> Option>> { + None + } +} + /// Database transaction pub struct BlockImportOperation { old_state: CachingState, - db_updates: MemoryDB, + db_updates: PrefixedMemoryDB, storage_updates: Vec<(Vec, Option>)>, changes_trie_updates: MemoryDB, pending_block: Option>, @@ -306,11 +314,11 @@ where Block: BlockT, Ok(()) } - fn update_authorities(&mut self, _authorities: Vec>) { - // currently authorities are not cached on full nodes + fn update_cache(&mut self, _cache: HashMap>) { + // Currently cache isn't implemented on full nodes. } - fn update_db_storage(&mut self, update: MemoryDB) -> Result<(), client::error::Error> { + fn update_db_storage(&mut self, update: PrefixedMemoryDB) -> Result<(), client::error::Error> { self.db_updates = update; Ok(()) } @@ -321,7 +329,7 @@ where Block: BlockT, return Err(client::error::ErrorKind::GenesisInvalid.into()); } - let mut transaction: MemoryDB = Default::default(); + let mut transaction: PrefixedMemoryDB = Default::default(); for (child_key, child_map) in children { if !well_known_keys::is_child_storage_key(&child_key) { @@ -374,22 +382,23 @@ where Block: BlockT, struct StorageDb { pub db: Arc, - pub state_db: StateDb, + pub state_db: StateDb>, } impl state_machine::Storage for StorageDb { - fn get(&self, key: &H256) -> Result, String> { - self.state_db.get(key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) + fn get(&self, key: &H256, prefix: &[u8]) -> Result, String> { + let key = prefixed_key::(key, prefix); + self.state_db.get(&key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) .map_err(|e| format!("Database backend error: {:?}", e)) } } -impl state_db::HashDb for StorageDb { +impl state_db::NodeDb for StorageDb { type Error = io::Error; - type Hash = H256; + type Key = [u8]; - fn get(&self, key: &H256) -> Result>, Self::Error> { - self.db.get(columns::STATE, key.as_bytes()).map(|r| r.map(|v| v.to_vec())) + fn get(&self, key: &[u8]) -> Result>, Self::Error> { + self.db.get(columns::STATE, key).map(|r| r.map(|v| v.to_vec())) } } @@ -405,7 +414,7 @@ impl DbGenesisStorage { } impl state_machine::Storage for DbGenesisStorage { - fn get(&self, _key: &H256) -> Result, String> { + fn get(&self, _key: &H256, _prefix: &[u8]) -> Result, String> { Ok(None) } } @@ -515,7 +524,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC } impl state_machine::ChangesTrieStorage for DbChangesTrieStorage { - fn get(&self, key: &H256) -> Result, String> { + fn get(&self, key: &H256, _prefix: &[u8]) -> Result, String> { self.db.get(columns::CHANGES_TRIE, &key[..]) .map_err(|err| format!("{}", err)) } @@ -559,7 +568,7 @@ impl> Backend { let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); - let state_db: StateDb = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; + let state_db: StateDb<_, _> = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db: db.clone(), state_db, @@ -832,7 +841,7 @@ impl> Backend { transaction.put(columns::META, meta_keys::GENESIS_HASH, hash.as_ref()); } - let mut changeset: state_db::ChangeSet = state_db::ChangeSet::default(); + let mut changeset: state_db::ChangeSet> = state_db::ChangeSet::default(); for (key, (val, rc)) in operation.db_updates.drain() { if rc > 0 { changeset.inserted.push((key, val.to_vec())); @@ -981,7 +990,7 @@ impl> Backend { } } -fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet) { +fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet>) { for (key, val) in commit.data.inserted.into_iter() { transaction.put(columns::STATE, &key[..], &val); } @@ -1031,7 +1040,7 @@ impl client::backend::Backend for Backend whe Ok(BlockImportOperation { pending_block: None, old_state, - db_updates: MemoryDB::default(), + db_updates: PrefixedMemoryDB::default(), storage_updates: Default::default(), changes_trie_updates: MemoryDB::default(), aux_ops: Vec::new(), @@ -1169,6 +1178,10 @@ impl client::backend::Backend for Backend whe } } + fn have_state_at(&self, hash: &Block::Hash, number: NumberFor) -> bool { + !self.storage.state_db.is_pruned(hash, number.as_()) + } + fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> { if let Some(hash) = state.parent_hash.clone() { let is_best = || self.blockchain.meta.read().best_hash == hash; @@ -1410,7 +1423,7 @@ mod tests { op.reset_storage(storage.iter().cloned().collect(), Default::default()).unwrap(); - key = op.db_updates.insert(b"hello"); + key = op.db_updates.insert(&[], b"hello"); op.set_block_data( header, Some(vec![]), @@ -1444,8 +1457,8 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.insert(b"hello"); - op.db_updates.remove(&key); + op.db_updates.insert(&[], b"hello"); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1479,7 +1492,7 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.remove(&key); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1545,7 +1558,7 @@ mod tests { assert_eq!(backend.changes_tries_storage.root(&anchor, block), Ok(Some(changes_root))); for (key, (val, _)) in changes_trie_update.drain() { - assert_eq!(backend.changes_trie_storage().unwrap().get(&key), Ok(Some(val))); + assert_eq!(backend.changes_trie_storage().unwrap().get(&key, &[]), Ok(Some(val))); } }; @@ -1671,23 +1684,23 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 12); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root4).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root4, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_some()); // now simulate finalization of block#16, causing prune of tries at #5..#8 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 16); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_none()); // now "change" pruning mode to archive && simulate finalization of block#20 // => no changes tries are pruned, because we never prune in archive mode @@ -1695,10 +1708,10 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config), &mut tx, Default::default(), 20); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root9).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root10).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root11).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root12).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root9, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root10, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root11, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root12, &[]).unwrap().is_some()); } #[test] @@ -1737,15 +1750,15 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block5, 5); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_some()); // now simulate finalization of block#6, causing prune of tries at #2 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block6, 6); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_some()); } #[test] diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 8a3456df69a305c55870617c4147950a517c0da5..62b6486f54d7ea28ac5561a33aa5b374943e26ec 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! RocksDB-based light client blockchain storage. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -32,7 +32,8 @@ use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, - Zero, One, As, NumberFor, Digest, DigestItem, AuthorityIdFor}; + Zero, One, As, NumberFor, Digest, DigestItem}; +use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId}; use crate::utils::{self, meta_keys, Meta, db_err, open_database, read_db, block_id_to_lookup_key, read_meta}; @@ -59,7 +60,7 @@ pub struct LightStorage { db: Arc, meta: RwLock, Block::Hash>>, leaves: RwLock>>, - cache: DbCacheSync, + cache: Arc>, } impl LightStorage @@ -96,7 +97,7 @@ impl LightStorage Ok(LightStorage { db, meta: RwLock::new(meta), - cache: DbCacheSync(RwLock::new(cache)), + cache: Arc::new(DbCacheSync(RwLock::new(cache))), leaves: RwLock::new(leaves), }) } @@ -370,7 +371,7 @@ impl LightBlockchainStorage for LightStorage fn import_header( &self, header: Block::Header, - authorities: Option>>, + cache_at: HashMap>, leaf_state: NewBlockState, aux_ops: Vec<(Vec, Option>)>, ) -> ClientResult<()> { @@ -432,7 +433,7 @@ impl LightBlockchainStorage for LightStorage .on_block_insert( ComplexBlockId::new(*header.parent_hash(), if number.is_zero() { Zero::zero() } else { number - One::one() }), ComplexBlockId::new(hash, number), - authorities, + cache_at, finalized, )? .into_ops(); @@ -521,8 +522,8 @@ impl LightBlockchainStorage for LightStorage Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&BlockchainCache> { - Some(&self.cache) + fn cache(&self) -> Option>> { + Some(self.cache.clone()) } } @@ -538,9 +539,11 @@ pub(crate) mod tests { use client::cht; use runtime_primitives::generic::DigestItem; use runtime_primitives::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; + use runtime_primitives::traits::AuthorityIdFor; use super::*; type Block = RawBlock>; + type AuthorityId = AuthorityIdFor; pub fn default_header(parent: &Hash, number: u64) -> Header { Header { @@ -566,41 +569,41 @@ pub(crate) mod tests { pub fn insert_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Best, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Best, Vec::new()).unwrap(); hash } fn insert_final_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Final, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Final, Vec::new()).unwrap(); hash } fn insert_non_best_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Normal, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Normal, Vec::new()).unwrap(); hash } #[test] fn returns_known_header() { let db = LightStorage::new_test(); - let known_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let known_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let header_by_hash = db.header(BlockId::Hash(known_hash)).unwrap().unwrap(); let header_by_number = db.header(BlockId::Number(0)).unwrap().unwrap(); assert_eq!(header_by_hash, header_by_number); @@ -616,12 +619,12 @@ pub(crate) mod tests { #[test] fn returns_info() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let info = db.info().unwrap(); assert_eq!(info.best_hash, genesis_hash); assert_eq!(info.best_number, 0); assert_eq!(info.genesis_hash, genesis_hash); - let best_hash = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let best_hash = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); let info = db.info().unwrap(); assert_eq!(info.best_hash, best_hash); assert_eq!(info.best_number, 1); @@ -631,7 +634,7 @@ pub(crate) mod tests { #[test] fn returns_block_status() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.status(BlockId::Hash(genesis_hash)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Number(0)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Hash(Hash::from_low_u64_be(1))).unwrap(), BlockStatus::Unknown); @@ -641,7 +644,7 @@ pub(crate) mod tests { #[test] fn returns_block_hash() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.hash(0).unwrap(), Some(genesis_hash)); assert_eq!(db.hash(1).unwrap(), None); } @@ -650,11 +653,11 @@ pub(crate) mod tests { fn import_header_works() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.db.iter(columns::HEADER).count(), 1); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 2); - let _ = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let _ = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); assert_eq!(db.db.iter(columns::HEADER).count(), 2); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 4); } @@ -665,25 +668,25 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert genesis block header (never pruned) - let mut prev_hash = insert_final_block(&db, None, || header_producer(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_producer(&Default::default(), 0)); // insert SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert next SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert block #{2 * cht::SIZE + 1} && check that new CHT is created + headers of this CHT are pruned // nothing is yet finalized, so nothing is pruned. - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); assert_eq!(db.db.iter(columns::HEADER).count(), (2 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); @@ -732,9 +735,9 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert 1 + SIZE + SIZE + 1 blocks so that CHT#0 is created - let mut prev_hash = insert_final_block(&db, None, || header_with_changes_trie(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_with_changes_trie(&Default::default(), 0)); for i in 1..1 + cht::SIZE + cht::SIZE + 1 { - prev_hash = insert_block(&db, None, || header_with_changes_trie(&prev_hash, i as u64)); + prev_hash = insert_block(&db, HashMap::new(), || header_with_changes_trie(&prev_hash, i as u64)); db.finalize_header(BlockId::Hash(prev_hash)).unwrap(); } @@ -754,16 +757,16 @@ pub(crate) mod tests { #[test] fn tree_route_works() { let db = LightStorage::new_test(); - let block0 = insert_block(&db, None, || default_header(&Default::default(), 0)); + let block0 = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); // fork from genesis: 3 prong. - let a1 = insert_block(&db, None, || default_header(&block0, 1)); - let a2 = insert_block(&db, None, || default_header(&a1, 2)); - let a3 = insert_block(&db, None, || default_header(&a2, 3)); + let a1 = insert_block(&db, HashMap::new(), || default_header(&block0, 1)); + let a2 = insert_block(&db, HashMap::new(), || default_header(&a1, 2)); + let a3 = insert_block(&db, HashMap::new(), || default_header(&a2, 3)); // fork from genesis: 2 prong. - let b1 = insert_block(&db, None, || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); - let b2 = insert_block(&db, None, || default_header(&b1, 2)); + let b1 = insert_block(&db, HashMap::new(), || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); + let b2 = insert_block(&db, HashMap::new(), || default_header(&b1, 2)); { let tree_route = ::client::blockchain::tree_route( @@ -815,44 +818,64 @@ pub(crate) mod tests { } #[test] - fn authorites_are_cached() { + fn authorities_are_cached() { let db = LightStorage::new_test(); fn run_checks(db: &LightStorage, max: u64, checks: &[(u64, Option>>)]) { for (at, expected) in checks.iter().take_while(|(at, _)| *at <= max) { - let actual = db.cache().authorities_at(BlockId::Number(*at)); + let actual = get_authorities(db.cache(), BlockId::Number(*at)); assert_eq!(*expected, actual); } } + fn same_authorities() -> HashMap> { + HashMap::new() + } + + fn make_authorities(authorities: Vec) -> HashMap> { + let mut map = HashMap::new(); + map.insert(well_known_cache_keys::AUTHORITIES, authorities.encode()); + map + } + + fn get_authorities(cache: &BlockchainCache, at: BlockId) -> Option
(net_config_dir: &Option
, name: &str) -> Option +where + P: AsRef +{ + net_config_dir.as_ref().map(|d| d.as_ref().join(name)) +} + +/// Create an error caused by an invalid node key argument. +fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { + input_err(format!("Invalid node key: {}", e)) +} + +/// Parse a Secp256k1 secret key from a hex string into a `network::Secret`. +fn parse_secp256k1_secret(hex: &String) -> error::Result { + H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::secp256k1::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + +/// Parse a Ed25519 secret key from a hex string into a `network::Secret`. +fn parse_ed25519_secret(hex: &String) -> error::Result { + H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes| + network::identity::ed25519::SecretKey::from_bytes(bytes) + .map(network::Secret::Input) + .map_err(invalid_node_key)) +} + /// Fill the given `PoolConfiguration` by looking at the cli parameters. fn fill_transaction_pool_configuration( options: &mut FactoryFullConfiguration, @@ -295,11 +354,13 @@ fn fill_network_configuration( config.public_addresses = Vec::new(); config.client_version = client_id; - config.use_secret = parse_node_key(cli.node_key)?; + config.node_key = node_key_config(cli.node_key_params, &config.net_config_path)?; config.in_peers = cli.in_peers; config.out_peers = cli.out_peers; + config.enable_mdns = !cli.no_mdns; + Ok(()) } @@ -317,14 +378,14 @@ where config.impl_commit = version.commit; config.impl_version = version.version; - config.name = match cli.name { + config.name = match cli.name.or(cli.keyring.account.map(|a| a.to_string())) { None => generate_node_name(), Some(name) => name, }; match is_node_name_valid(&config.name) { Ok(_) => (), Err(msg) => bail!( - create_input_err( + input_err( format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", config.name, msg @@ -347,7 +408,7 @@ where Some(ref s) if s == "archive" => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => PruningMode::keep_blocks( - s.parse().map_err(|_| create_input_err("Invalid pruning mode specified"))? + s.parse().map_err(|_| input_err("Invalid pruning mode specified"))? ), }; @@ -360,14 +421,25 @@ where service::Roles::FULL }; + let exec = cli.execution_strategies; config.execution_strategies = ExecutionStrategies { - syncing: cli.syncing_execution.into(), - importing: cli.importing_execution.into(), - block_construction: cli.block_construction_execution.into(), - other: cli.other_execution.into(), + syncing: exec.syncing_execution.into(), + importing: exec.importing_execution.into(), + block_construction: exec.block_construction_execution.into(), + offchain_worker: exec.offchain_worker_execution.into(), + other: exec.other_execution.into(), + }; + + config.offchain_worker = match (cli.offchain_worker, role) { + (params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true, + (params::OffchainWorkerEnabled::Always, _) => true, + (params::OffchainWorkerEnabled::Never, _) => false, + (params::OffchainWorkerEnabled::WhenValidating, _) => false, }; config.roles = role; + config.disable_grandpa = cli.no_grandpa; + let client_id = config.client_id(); fill_network_configuration( cli.network_config, @@ -387,7 +459,11 @@ where } if cli.shared_params.dev { - config.keys.push("Alice".into()); + config.keys.push("//Alice".into()); + } + + if let Some(account) = cli.keyring.account { + config.keys.push(format!("//{}", account)); } let rpc_interface: &str = if cli.rpc_external { "0.0.0.0" } else { "127.0.0.1" }; @@ -407,6 +483,8 @@ where config.telemetry_endpoints = Some(TelemetryEndpoints::new(cli.telemetry_endpoints)); } + config.force_authoring = cli.force_authoring; + Ok(config) } @@ -439,23 +517,19 @@ where // 9926-9949 Unassigned fn with_default_boot_node( - mut spec: ChainSpec>, - cli: &BuildSpecCmd, + spec: &mut ChainSpec>, + cli: BuildSpecCmd, version: &VersionInfo, -) -> error::Result>> +) -> error::Result<()> where F: ServiceFactory { if spec.boot_nodes().is_empty() { - let network_path = - Some(network_path(&base_path(&cli.shared_params, version), spec.id()).to_string_lossy().into()); - let network_key = parse_node_key(cli.node_key.clone())?; - - let network_keys = - network::obtain_private_key(&network_key, &network_path) - .map_err(|err| format!("Error obtaining network key: {}", err))?; - - let peer_id = network_keys.to_peer_id(); + let base_path = base_path(&cli.shared_params, version); + let storage_path = network_path(&base_path, spec.id()); + let node_key = node_key_config(cli.node_key_params, &Some(storage_path))?; + let keys = node_key.into_keypair()?; + let peer_id = keys.public().into_peer_id(); let addr = build_multiaddr![ Ip4([127, 0, 0, 1]), Tcp(30333u16), @@ -463,7 +537,7 @@ where ]; spec.add_boot_node(addr) } - Ok(spec) + Ok(()) } fn build_spec( @@ -476,9 +550,10 @@ where S: FnOnce(&str) -> Result>>, String>, { info!("Building chain spec"); - let spec = load_spec(&cli.shared_params, spec_factory)?; - let spec = with_default_boot_node::(spec, &cli, version)?; - let json = service::chain_ops::build_spec::>(spec, cli.raw)?; + let raw_output = cli.raw; + let mut spec = load_spec(&cli.shared_params, spec_factory)?; + with_default_boot_node::(&mut spec, cli, version)?; + let json = service::chain_ops::build_spec::>(spec, raw_output)?; print!("{}", json); @@ -574,23 +649,28 @@ where S: FnOnce(&str) -> Result>>, String>, { let config = create_config_with_db_path::(spec_factory, &cli.shared_params, version)?; - let db_path = config.database_path; - print!("Are you sure to remove {:?}? (y/n)", &db_path); - stdout().flush().expect("failed to flush stdout"); - - let mut input = String::new(); - stdin().read_line(&mut input)?; - let input = input.trim(); - - match input.chars().nth(0) { - Some('y') | Some('Y') => { - fs::remove_dir_all(&db_path)?; - println!("{:?} removed.", &db_path); - }, - _ => println!("Aborted"), + + if cli.yes == false { + print!("Are you sure to remove {:?}? (y/n)", &db_path); + stdout().flush().expect("failed to flush stdout"); + + let mut input = String::new(); + stdin().read_line(&mut input)?; + let input = input.trim(); + + match input.chars().nth(0) { + Some('y') | Some('Y') => {}, + _ => { + println!("Aborted"); + return Ok(()); + }, + } } + fs::remove_dir_all(&db_path)?; + println!("{:?} removed.", &db_path); + Ok(()) } @@ -698,6 +778,8 @@ fn kill_color(s: &str) -> String { #[cfg(test)] mod tests { use super::*; + use tempdir::TempDir; + use network::identity::{secp256k1, ed25519}; #[test] fn tests_node_name_good() { @@ -713,4 +795,111 @@ mod tests { assert!(is_node_name_valid("www.visit.me").is_err()); assert!(is_node_name_valid("email@domain").is_err()); } + + #[test] + fn test_node_key_config_input() { + fn secret_input(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let sk = match node_key_type { + NodeKeyType::Secp256k1 => secp256k1::SecretKey::generate().as_ref().to_vec(), + NodeKeyType::Ed25519 => ed25519::SecretKey::generate().as_ref().to_vec() + }; + let params = NodeKeyParams { + node_key_type, + node_key: Some(format!("{:x}", H256::from_slice(sk.as_ref()))), + node_key_file: None + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Secp256k1 && + &sk[..] == ski.as_ref() => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::Input(ref ski)) + if node_key_type == NodeKeyType::Ed25519 && + &sk[..] == ski.as_ref() => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_input(None).is_ok()); + assert!(secret_input(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_file() { + fn secret_file(net_config_dir: Option) -> error::Result<()> { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + let tmp = TempDir::new("alice")?; + let file = tmp.path().join(format!("{}_mysecret", t)).to_path_buf(); + let params = NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: Some(file.clone()) + }; + node_key_config(params, &net_config_dir).and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Secp256k1 && f == &file => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(secret_file(None).is_ok()); + assert!(secret_file(Some("x".to_string())).is_ok()); + } + + #[test] + fn test_node_key_config_default() { + fn with_def_params(f: F) -> error::Result<()> + where + F: Fn(NodeKeyParams) -> error::Result<()> + { + NodeKeyType::variants().into_iter().try_for_each(|t| { + let node_key_type = NodeKeyType::from_str(t).unwrap(); + f(NodeKeyParams { + node_key_type, + node_key: None, + node_key_file: None + }) + }) + } + + fn no_config_dir() -> error::Result<()> { + with_def_params(|params| { + let typ = params.node_key_type; + node_key_config::(params, &None) + .and_then(|c| match c { + NodeKeyConfig::Secp256k1(network::Secret::New) + if typ == NodeKeyType::Secp256k1 => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::New) + if typ == NodeKeyType::Ed25519 => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + fn some_config_dir(net_config_dir: String) -> error::Result<()> { + with_def_params(|params| { + let dir = PathBuf::from(net_config_dir.clone()); + let typ = params.node_key_type; + node_key_config(params, &Some(net_config_dir.clone())) + .and_then(move |c| match c { + NodeKeyConfig::Secp256k1(network::Secret::File(ref f)) + if typ == NodeKeyType::Secp256k1 && + f == &dir.join(NODE_KEY_SECP256K1_FILE) => Ok(()), + NodeKeyConfig::Ed25519(network::Secret::File(ref f)) + if typ == NodeKeyType::Ed25519 && + f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), + _ => Err(input_err("Unexpected node key config")) + }) + }) + } + + assert!(no_config_dir().is_ok()); + assert!(some_config_dir("x".to_string()).is_ok()); + } } diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 26a9a00ebf0a00d271b0036a2ff2958054962680..321cf17efb39cff59dd950dcd4d6b95df4cb7388 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Parity Technologies (UK) Ltd. +// Copyright 2018-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ use crate::traits::{AugmentClap, GetLogFilter}; use std::path::PathBuf; -use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand}}; +use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand, Arg}}; use client; /// Auxialary macro to implement `GetLogFilter` for all types that have the `shared_params` field. @@ -39,6 +39,7 @@ arg_enum! { Wasm, Both, NativeElseWasm, + NativeWhenPossible, } } @@ -49,10 +50,21 @@ impl Into for ExecutionStrategy { ExecutionStrategy::Wasm => client::ExecutionStrategy::AlwaysWasm, ExecutionStrategy::Both => client::ExecutionStrategy::Both, ExecutionStrategy::NativeElseWasm => client::ExecutionStrategy::NativeElseWasm, + ExecutionStrategy::NativeWhenPossible => client::ExecutionStrategy::NativeWhenPossible, } } } +arg_enum! { + /// How to execute blocks + #[derive(Debug, Clone)] + pub enum OffchainWorkerEnabled { + Always, + Never, + WhenValidating, + } +} + /// Shared parameters used by all `CoreParams`. #[derive(Debug, StructOpt, Clone)] pub struct SharedParams { @@ -68,7 +80,7 @@ pub struct SharedParams { #[structopt(long = "base-path", short = "d", value_name = "PATH", parse(from_os_str))] pub base_path: Option, - ///Sets a custom logging filter + /// Sets a custom logging filter #[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")] pub log: Option, } @@ -98,10 +110,6 @@ pub struct NetworkConfigurationParams { #[structopt(long = "port", value_name = "PORT")] pub port: Option, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, - /// Specify the number of outgoing connections we're trying to maintain #[structopt(long = "out-peers", value_name = "OUT_PEERS", default_value = "25")] pub out_peers: u32, @@ -109,6 +117,98 @@ pub struct NetworkConfigurationParams { /// Specify the maximum number of incoming connections we're accepting #[structopt(long = "in-peers", value_name = "IN_PEERS", default_value = "25")] pub in_peers: u32, + + /// By default, the network will use mDNS to discover other nodes on the local network. This + /// disables it. + #[structopt(long = "no-mdns")] + pub no_mdns: bool, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams +} + +arg_enum! { + #[derive(Debug, Copy, Clone, PartialEq, Eq)] + pub enum NodeKeyType { + Secp256k1, + Ed25519 + } +} + +/// Parameters used to create the `NodeKeyConfig`, which determines the keypair +/// used for libp2p networking. +#[derive(Debug, StructOpt, Clone)] +pub struct NodeKeyParams { + /// The secret key to use for libp2p networking. + /// + /// The value is a string that is parsed according to the choice of + /// `--node-key-type` as follows: + /// + /// `secp256k1`: + /// The value is parsed as a hex-encoded Secp256k1 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// `ed25519`: + /// The value is parsed as a hex-encoded Ed25519 32 bytes secret key, + /// i.e. 64 hex characters. + /// + /// The value of this option takes precedence over `--node-key-file`. + /// + /// WARNING: Secrets provided as command-line arguments are easily exposed. + /// Use of this option should be limited to development and testing. To use + /// an externally managed secret key, use `--node-key-file` instead. + #[structopt(long = "node-key", value_name = "KEY")] + pub node_key: Option, + + /// The type of secret key to use for libp2p networking. + /// + /// The secret key of the node is obtained as follows: + /// + /// * If the `--node-key` option is given, the value is parsed as a secret key + /// according to the type. See the documentation for `--node-key`. + /// + /// * If the `--node-key-file` option is given, the secret key is read from the + /// specified file. See the documentation for `--node-key-file`. + /// + /// * Otherwise, the secret key is read from a file with a predetermined, + /// type-specific name from the chain-specific network config directory + /// inside the base directory specified by `--base-dir`. If this file does + /// not exist, it is created with a newly generated secret key of the + /// chosen type. + /// + /// The node's secret key determines the corresponding public key and hence the + /// node's peer ID in the context of libp2p. + /// + /// NOTE: The current default key type is `secp256k1` for a transition period only + /// but will eventually change to `ed25519` in a future release. To continue using + /// `secp256k1` keys, use `--node-key-type=secp256k1`. + #[structopt( + long = "node-key-type", + value_name = "TYPE", + raw( + possible_values = "&NodeKeyType::variants()", + case_insensitive = "true", + default_value = r#""Secp256k1""# + ) + )] + pub node_key_type: NodeKeyType, + + /// The file from which to read the node's secret key to use for libp2p networking. + /// + /// The contents of the file are parsed according to the choice of `--node-key-type` + /// as follows: + /// + /// `secp256k1`: + /// The file must contain an unencoded 32 bytes Secp256k1 secret key. + /// + /// `ed25519`: + /// The file must contain an unencoded 32 bytes Ed25519 secret key. + /// + /// If the file does not exist, it is created with a newly generated secret key of + /// the chosen type. + #[structopt(long = "node-key-file", value_name = "FILE")] + pub node_key_file: Option } /// Parameters used to create the pool configuration. @@ -122,6 +222,70 @@ pub struct TransactionPoolParams { pub pool_kbytes: usize, } +/// Execution strategies parameters. +#[derive(Debug, StructOpt, Clone)] +pub struct ExecutionStrategies { + /// The means of execution used when calling into the runtime while syncing blocks. + #[structopt( + long = "syncing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub syncing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while importing blocks. + #[structopt( + long = "importing-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeElseWasm""# + ) + )] + pub importing_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "block-construction-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub block_construction_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while constructing blocks. + #[structopt( + long = "offchain-worker-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""NativeWhenPossible""# + ) + )] + pub offchain_worker_execution: ExecutionStrategy, + + /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. + #[structopt( + long = "other-execution", + value_name = "STRATEGY", + raw( + possible_values = "&ExecutionStrategy::variants()", + case_insensitive = "true", + default_value = r#""Wasm""# + ) + )] + pub other_execution: ExecutionStrategy, +} + /// The `run` command used to run a node. #[derive(Debug, StructOpt, Clone)] pub struct RunCmd { @@ -137,6 +301,10 @@ pub struct RunCmd { #[structopt(long = "validator")] pub validator: bool, + /// Disable GRANDPA when running in validator mode + #[structopt(long = "no-grandpa")] + pub no_grandpa: bool, + /// Run in light client mode #[structopt(long = "light")] pub light: bool, @@ -169,7 +337,7 @@ pub struct RunCmd { #[structopt(long = "name", value_name = "NAME")] pub name: Option, - /// Should not connect to the Substrate telemetry server (telemetry is on by default on global chains) + /// Disable connecting to the Substrate telemetry server (telemetry is on by default on global chains). #[structopt(long = "no-telemetry")] pub no_telemetry: bool, @@ -179,55 +347,23 @@ pub struct RunCmd { #[structopt(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = "parse_telemetry_endpoints"))] pub telemetry_endpoints: Vec<(String, u8)>, - /// The means of execution used when calling into the runtime while syncing blocks. + /// Should execute offchain workers on every block. By default it's only enabled for nodes that are authoring new + /// blocks. #[structopt( - long = "syncing-execution", - value_name = "STRATEGY", + long = "offchain-worker", + value_name = "ENABLED", raw( - possible_values = "&ExecutionStrategy::variants()", + possible_values = "&OffchainWorkerEnabled::variants()", case_insensitive = "true", - default_value = r#""NativeElseWasm""# + default_value = r#""WhenValidating""# ) )] - pub syncing_execution: ExecutionStrategy, + pub offchain_worker: OffchainWorkerEnabled, - /// The means of execution used when calling into the runtime while importing blocks. - #[structopt( - long = "importing-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""NativeElseWasm""# - ) - )] - pub importing_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while constructing blocks. - #[structopt( - long = "block-construction-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub block_construction_execution: ExecutionStrategy, - - /// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks. - #[structopt( - long = "other-execution", - value_name = "STRATEGY", - raw( - possible_values = "&ExecutionStrategy::variants()", - case_insensitive = "true", - default_value = r#""Wasm""# - ) - )] - pub other_execution: ExecutionStrategy, + #[allow(missing_docs)] + #[structopt(flatten)] + pub execution_strategies: ExecutionStrategies, - #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, @@ -239,6 +375,84 @@ pub struct RunCmd { #[allow(missing_docs)] #[structopt(flatten)] pub pool_config: TransactionPoolParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub keyring: Keyring, + + /// Enable authoring even when offline. + #[structopt(long = "force-authoring")] + pub force_authoring: bool, +} + +/// Stores all required Cli values for a keyring test account. +struct KeyringTestAccountCliValues { + help: String, + conflicts_with: Vec, + name: String, + variant: keyring::AuthorityKeyring, +} + +lazy_static::lazy_static! { + /// The Cli values for all test accounts. + static ref TEST_ACCOUNTS_CLI_VALUES: Vec = { + keyring::AuthorityKeyring::iter().map(|a| { + let help = format!("Shortcut for `--key //{} --name {}`.", a, a); + let conflicts_with = keyring::AuthorityKeyring::iter() + .filter(|b| a != *b) + .map(|b| b.to_string().to_lowercase()) + .chain(["name", "key"].iter().map(|s| s.to_string())) + .collect::>(); + let name = a.to_string().to_lowercase(); + + KeyringTestAccountCliValues { + help, + conflicts_with, + name, + variant: a, + } + }).collect() + }; +} + +/// Wrapper for exposing the keyring test accounts into the Cli. +#[derive(Debug, Clone)] +pub struct Keyring { + pub account: Option, +} + +impl StructOpt for Keyring { + fn clap<'a, 'b>() -> App<'a, 'b> { + unimplemented!("Should not be called for `TestAccounts`.") + } + + fn from_clap(m: &::structopt::clap::ArgMatches) -> Self { + Keyring { + account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant), + } + } +} + +impl AugmentClap for Keyring { + fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| { + let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::>(); + + app.arg( + Arg::with_name(&a.name) + .long(&a.name) + .help(&a.help) + .conflicts_with_all(&conflicts_with_strs) + .takes_value(false) + ) + }) + } +} + +impl Keyring { + fn is_subcommand() -> bool { + false + } } /// Default to verbosity level 0, if none is provided. @@ -270,9 +484,9 @@ pub struct BuildSpecCmd { #[structopt(flatten)] pub shared_params: SharedParams, - /// Specify node secret key (64-character hex string) - #[structopt(long = "node-key", value_name = "KEY")] - pub node_key: Option, + #[allow(missing_docs)] + #[structopt(flatten)] + pub node_key_params: NodeKeyParams, } impl_get_log_filter!(BuildSpecCmd); @@ -338,6 +552,10 @@ impl_get_log_filter!(RevertCmd); /// The `purge-chain` command used to remove the whole chain. #[derive(Debug, StructOpt, Clone)] pub struct PurgeChainCmd { + /// Skip interactive prompt by answering yes automatically. + #[structopt(short = "y")] + pub yes: bool, + #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, diff --git a/core/client/Cargo.toml b/core/client/Cargo.toml index 495b11b61d5b8aa0ecda2a9507b608db280b254d..cfc7eb3e3447e4f4c2a39d46fb5dcbadac9bdeef 100644 --- a/core/client/Cargo.toml +++ b/core/client/Cargo.toml @@ -18,9 +18,9 @@ state-machine = { package = "substrate-state-machine", path = "../state-machine" keyring = { package = "substrate-keyring", path = "../keyring", optional = true } trie = { package = "substrate-trie", path = "../trie", optional = true } substrate-telemetry = { path = "../telemetry", optional = true } -hash-db = { version = "0.11", optional = true } +hash-db = { version = "0.12", optional = true } kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } runtime-primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } runtime-version = { package = "sr-version", path = "../sr-version", default-features = false } diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 8828eefa4fbf391d21bb4d8fbc3ef2396461c486..2944ab533b551c924d55c7fbf2adc81b36b5857b 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -12,15 +12,16 @@ kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } lru-cache = "0.1.1" -hash-db = { version = "0.11" } +hash-db = { version = "0.12" } primitives = { package = "substrate-primitives", path = "../../primitives" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } client = { package = "substrate-client", path = "../../client" } state-machine = { package = "substrate-state-machine", path = "../../state-machine" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } executor = { package = "substrate-executor", path = "../../executor" } state_db = { package = "substrate-state-db", path = "../../state-db" } trie = { package = "substrate-trie", path = "../../trie" } +consensus_common = { package = "substrate-consensus-common", path = "../../consensus/common" } [dev-dependencies] kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } diff --git a/core/client/db/src/cache/list_cache.rs b/core/client/db/src/cache/list_cache.rs index f8e52e14c630f07b421eaff4b69ca1bd0071c4fc..1e641534f969c0d63eefe387e98c9ded8bb3c81a 100644 --- a/core/client/db/src/cache/list_cache.rs +++ b/core/client/db/src/cache/list_cache.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_entry.rs b/core/client/db/src/cache/list_entry.rs index d2d88ab12f38ab341a6b69b51d35fbe989ac23e5..237ae9a268026744b87f6d85b7c6301cb82ee204 100644 --- a/core/client/db/src/cache/list_entry.rs +++ b/core/client/db/src/cache/list_entry.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/list_storage.rs b/core/client/db/src/cache/list_storage.rs index b9bf99f67b884fba4ae85f358cb9c0b731cb834b..659a30507e136576a844624fa167eb1cfb08ddb9 100644 --- a/core/client/db/src/cache/list_storage.rs +++ b/core/client/db/src/cache/list_storage.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index 12f8c5e519782a9b2db3e7842176665e41b120f5..b5dd45f11dd52e69ea715243924ac5e799e038b1 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! DB-backed cache of blockchain data. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -25,7 +25,8 @@ use client::blockchain::Cache as BlockchainCache; use client::error::Result as ClientResult; use parity_codec::{Encode, Decode}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As}; +use consensus_common::well_known_cache_keys::Id as CacheKeyId; use crate::utils::{self, COLUMN_META}; use self::list_cache::ListCache; @@ -64,7 +65,12 @@ impl CacheItemT for T where T: Clone + Decode + Encode + PartialEq {} /// Database-backed blockchain data cache. pub struct DbCache { - authorities_at: ListCache>, self::list_storage::DbStorage>, + cache_at: HashMap, self::list_storage::DbStorage>>, + db: Arc, + key_lookup_column: Option, + header_column: Option, + authorities_column: Option, + best_finalized_block: ComplexBlockId, } impl DbCache { @@ -76,19 +82,13 @@ impl DbCache { authorities_column: Option, best_finalized_block: ComplexBlockId, ) -> Self { - DbCache { - authorities_at: ListCache::new( - self::list_storage::DbStorage::new(b"auth".to_vec(), db, - self::list_storage::DbColumns { - meta: COLUMN_META, - key_lookup: key_lookup_column, - header: header_column, - cache: authorities_column, - }, - ), - As::sa(PRUNE_DEPTH), - best_finalized_block, - ), + Self { + cache_at: HashMap::new(), + db, + key_lookup_column, + header_column, + authorities_column, + best_finalized_block, } } @@ -97,35 +97,82 @@ impl DbCache { DbCacheTransaction { cache: self, tx, - authorities_at_op: None, + cache_at_op: HashMap::new(), + best_finalized_block: None, } } /// Run post-commit cache operations. pub fn commit(&mut self, ops: DbCacheTransactionOps) { - if let Some(authorities_at_op) = ops.authorities_at_op { - self.authorities_at.on_transaction_commit(authorities_at_op); + for (name, op) in ops.cache_at_op.into_iter() { + self.get_cache(name).on_transaction_commit(op); + } + if let Some(best_finalized_block) = ops.best_finalized_block { + self.best_finalized_block = best_finalized_block; } } + + /// Creates `ListCache` with the given name or returns a reference to the existing. + fn get_cache(&mut self, name: CacheKeyId) -> &mut ListCache, self::list_storage::DbStorage> { + get_cache_helper( + &mut self.cache_at, + name, + &self.db, + self.key_lookup_column, + self.header_column, + self.authorities_column, + &self.best_finalized_block + ) + } +} + +// This helper is needed because otherwise the borrow checker will require to +// clone all parameters outside of the closure. +fn get_cache_helper<'a, Block: BlockT>( + cache_at: &'a mut HashMap, self::list_storage::DbStorage>>, + name: CacheKeyId, + db: &Arc, + key_lookup: Option, + header: Option, + cache: Option, + best_finalized_block: &ComplexBlockId, +) -> &'a mut ListCache, self::list_storage::DbStorage> { + cache_at.entry(name).or_insert_with(|| { + ListCache::new( + self::list_storage::DbStorage::new(name.to_vec(), db.clone(), + self::list_storage::DbColumns { + meta: COLUMN_META, + key_lookup, + header, + cache, + }, + ), + As::sa(PRUNE_DEPTH), + best_finalized_block.clone(), + ) + }) } /// Cache operations that are to be committed after database transaction is committed. pub struct DbCacheTransactionOps { - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } /// Database-backed blockchain data cache transaction valid for single block import. pub struct DbCacheTransaction<'a, Block: BlockT> { cache: &'a mut DbCache, tx: &'a mut DBTransaction, - authorities_at_op: Option>>>, + cache_at_op: HashMap>>, + best_finalized_block: Option>, } impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { /// Convert transaction into post-commit operations set. pub fn into_ops(self) -> DbCacheTransactionOps { DbCacheTransactionOps { - authorities_at_op: self.authorities_at_op, + cache_at_op: self.cache_at_op, + best_finalized_block: self.best_finalized_block, } } @@ -134,21 +181,42 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { mut self, parent: ComplexBlockId, block: ComplexBlockId, - authorities_at: Option>>, + data_at: HashMap>, is_final: bool, ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_insert( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - authorities_at, - is_final, - )?; + // prepare list of caches that are not update + // (we might still need to do some cache maintenance in this case) + let missed_caches = self.cache.cache_at.keys() + .filter(|cache| !data_at.contains_key(cache.clone())) + .cloned() + .collect::>(); + + let mut insert_op = |name: CacheKeyId, value: Option>| -> Result<(), client::error::Error> { + let cache = self.cache.get_cache(name); + let op = cache.on_block_insert( + &mut self::list_storage::DbStorageTransaction::new( + cache.storage(), + &mut self.tx, + ), + parent.clone(), + block.clone(), + value.or(cache.value_at_block(&parent)?), + is_final, + )?; + if let Some(op) = op { + self.cache_at_op.insert(name, op); + } + Ok(()) + }; + + data_at.into_iter().try_for_each(|(name, data)| insert_op(name, Some(data)))?; + missed_caches.into_iter().try_for_each(|name| insert_op(name, None))?; + + if is_final { + self.best_finalized_block = Some(block); + } Ok(self) } @@ -159,16 +227,24 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { parent: ComplexBlockId, block: ComplexBlockId ) -> ClientResult { - assert!(self.authorities_at_op.is_none()); + assert!(self.cache_at_op.is_empty()); - self.authorities_at_op = self.cache.authorities_at.on_block_finalize( - &mut self::list_storage::DbStorageTransaction::new( - self.cache.authorities_at.storage(), - &mut self.tx - ), - parent, - block, - )?; + for (name, cache_at) in self.cache.cache_at.iter() { + let op = cache_at.on_block_finalize( + &mut self::list_storage::DbStorageTransaction::new( + cache_at.storage(), + &mut self.tx + ), + parent.clone(), + block.clone(), + )?; + + if let Some(op) = op { + self.cache_at_op.insert(name.to_owned(), op); + } + } + + self.best_finalized_block = Some(block); Ok(self) } @@ -178,12 +254,12 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { pub struct DbCacheSync(pub RwLock>); impl BlockchainCache for DbCacheSync { - fn authorities_at(&self, at: BlockId) -> Option>> { + fn get_at(&self, key: &CacheKeyId, at: &BlockId) -> Option> { let cache = self.0.read(); - let storage = cache.authorities_at.storage(); + let storage = cache.cache_at.get(key)?.storage(); let db = storage.db(); let columns = storage.columns(); - let at = match at { + let at = match *at { BlockId::Hash(hash) => { let header = utils::read_header::( &**db, @@ -202,6 +278,7 @@ impl BlockchainCache for DbCacheSync { }, }; - cache.authorities_at.value_at_block(&at).ok()? + cache.cache_at.get(key)?.value_at_block(&at).ok()? } } + diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 36ac3cc3450552cc8e6f4280898ca413a8fb3ec3..7657bfd39691a0e2bec1e89e8ed7d84339ae1446 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -33,6 +33,7 @@ mod utils; use std::sync::Arc; use std::path::PathBuf; use std::io; +use std::collections::HashMap; use client::backend::NewBlockState; use client::blockchain::HeaderBackend; @@ -40,12 +41,12 @@ use client::ExecutionStrategies; use parity_codec::{Decode, Encode}; use hash_db::Hasher; use kvdb::{KeyValueDB, DBTransaction}; -use trie::MemoryDB; +use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::RwLock; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash}; use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem, AuthorityIdFor}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem}; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; @@ -54,6 +55,7 @@ use crate::utils::{Meta, db_err, meta_keys, open_database, read_db, block_id_to_ use client::leaves::{LeafSet, FinalizationDisplaced}; use client::children; use state_db::StateDb; +use consensus_common::well_known_cache_keys; use crate::storage_cache::{CachingState, SharedCache, new_shared_cache}; use log::{trace, debug, warn}; pub use state_db::PruningMode; @@ -243,7 +245,7 @@ impl client::blockchain::Backend for BlockchainDb { Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&client::blockchain::Cache> { + fn cache(&self) -> Option>> { None } @@ -256,10 +258,16 @@ impl client::blockchain::Backend for BlockchainDb { } } +impl client::blockchain::ProvideCache for BlockchainDb { + fn cache(&self) -> Option>> { + None + } +} + /// Database transaction pub struct BlockImportOperation { old_state: CachingState, - db_updates: MemoryDB, + db_updates: PrefixedMemoryDB, storage_updates: Vec<(Vec, Option>)>, changes_trie_updates: MemoryDB, pending_block: Option>, @@ -306,11 +314,11 @@ where Block: BlockT, Ok(()) } - fn update_authorities(&mut self, _authorities: Vec>) { - // currently authorities are not cached on full nodes + fn update_cache(&mut self, _cache: HashMap>) { + // Currently cache isn't implemented on full nodes. } - fn update_db_storage(&mut self, update: MemoryDB) -> Result<(), client::error::Error> { + fn update_db_storage(&mut self, update: PrefixedMemoryDB) -> Result<(), client::error::Error> { self.db_updates = update; Ok(()) } @@ -321,7 +329,7 @@ where Block: BlockT, return Err(client::error::ErrorKind::GenesisInvalid.into()); } - let mut transaction: MemoryDB = Default::default(); + let mut transaction: PrefixedMemoryDB = Default::default(); for (child_key, child_map) in children { if !well_known_keys::is_child_storage_key(&child_key) { @@ -374,22 +382,23 @@ where Block: BlockT, struct StorageDb { pub db: Arc, - pub state_db: StateDb, + pub state_db: StateDb>, } impl state_machine::Storage for StorageDb { - fn get(&self, key: &H256) -> Result, String> { - self.state_db.get(key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) + fn get(&self, key: &H256, prefix: &[u8]) -> Result, String> { + let key = prefixed_key::(key, prefix); + self.state_db.get(&key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) .map_err(|e| format!("Database backend error: {:?}", e)) } } -impl state_db::HashDb for StorageDb { +impl state_db::NodeDb for StorageDb { type Error = io::Error; - type Hash = H256; + type Key = [u8]; - fn get(&self, key: &H256) -> Result>, Self::Error> { - self.db.get(columns::STATE, key.as_bytes()).map(|r| r.map(|v| v.to_vec())) + fn get(&self, key: &[u8]) -> Result>, Self::Error> { + self.db.get(columns::STATE, key).map(|r| r.map(|v| v.to_vec())) } } @@ -405,7 +414,7 @@ impl DbGenesisStorage { } impl state_machine::Storage for DbGenesisStorage { - fn get(&self, _key: &H256) -> Result, String> { + fn get(&self, _key: &H256, _prefix: &[u8]) -> Result, String> { Ok(None) } } @@ -515,7 +524,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC } impl state_machine::ChangesTrieStorage for DbChangesTrieStorage { - fn get(&self, key: &H256) -> Result, String> { + fn get(&self, key: &H256, _prefix: &[u8]) -> Result, String> { self.db.get(columns::CHANGES_TRIE, &key[..]) .map_err(|err| format!("{}", err)) } @@ -559,7 +568,7 @@ impl> Backend { let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); - let state_db: StateDb = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; + let state_db: StateDb<_, _> = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db: db.clone(), state_db, @@ -832,7 +841,7 @@ impl> Backend { transaction.put(columns::META, meta_keys::GENESIS_HASH, hash.as_ref()); } - let mut changeset: state_db::ChangeSet = state_db::ChangeSet::default(); + let mut changeset: state_db::ChangeSet> = state_db::ChangeSet::default(); for (key, (val, rc)) in operation.db_updates.drain() { if rc > 0 { changeset.inserted.push((key, val.to_vec())); @@ -981,7 +990,7 @@ impl> Backend { } } -fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet) { +fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet>) { for (key, val) in commit.data.inserted.into_iter() { transaction.put(columns::STATE, &key[..], &val); } @@ -1031,7 +1040,7 @@ impl client::backend::Backend for Backend whe Ok(BlockImportOperation { pending_block: None, old_state, - db_updates: MemoryDB::default(), + db_updates: PrefixedMemoryDB::default(), storage_updates: Default::default(), changes_trie_updates: MemoryDB::default(), aux_ops: Vec::new(), @@ -1169,6 +1178,10 @@ impl client::backend::Backend for Backend whe } } + fn have_state_at(&self, hash: &Block::Hash, number: NumberFor) -> bool { + !self.storage.state_db.is_pruned(hash, number.as_()) + } + fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> { if let Some(hash) = state.parent_hash.clone() { let is_best = || self.blockchain.meta.read().best_hash == hash; @@ -1410,7 +1423,7 @@ mod tests { op.reset_storage(storage.iter().cloned().collect(), Default::default()).unwrap(); - key = op.db_updates.insert(b"hello"); + key = op.db_updates.insert(&[], b"hello"); op.set_block_data( header, Some(vec![]), @@ -1444,8 +1457,8 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.insert(b"hello"); - op.db_updates.remove(&key); + op.db_updates.insert(&[], b"hello"); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1479,7 +1492,7 @@ mod tests { ).0.into(); let hash = header.hash(); - op.db_updates.remove(&key); + op.db_updates.remove(&key, &[]); op.set_block_data( header, Some(vec![]), @@ -1545,7 +1558,7 @@ mod tests { assert_eq!(backend.changes_tries_storage.root(&anchor, block), Ok(Some(changes_root))); for (key, (val, _)) in changes_trie_update.drain() { - assert_eq!(backend.changes_trie_storage().unwrap().get(&key), Ok(Some(val))); + assert_eq!(backend.changes_trie_storage().unwrap().get(&key, &[]), Ok(Some(val))); } }; @@ -1671,23 +1684,23 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 12); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root4).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root4, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_some()); // now simulate finalization of block#16, causing prune of tries at #5..#8 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, Default::default(), 16); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root5).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root6).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root7).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root8).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root5, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root6, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root7, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root8, &[]).unwrap().is_none()); // now "change" pruning mode to archive && simulate finalization of block#20 // => no changes tries are pruned, because we never prune in archive mode @@ -1695,10 +1708,10 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config), &mut tx, Default::default(), 20); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root9).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root10).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root11).unwrap().is_some()); - assert!(backend.changes_tries_storage.get(&root12).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root9, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root10, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root11, &[]).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root12, &[]).unwrap().is_some()); } #[test] @@ -1737,15 +1750,15 @@ mod tests { let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block5, 5); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root1).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root1, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_some()); // now simulate finalization of block#6, causing prune of tries at #2 let mut tx = DBTransaction::new(); backend.changes_tries_storage.prune(Some(config.clone()), &mut tx, block6, 6); backend.storage.db.write(tx).unwrap(); - assert!(backend.changes_tries_storage.get(&root2).unwrap().is_none()); - assert!(backend.changes_tries_storage.get(&root3).unwrap().is_some()); + assert!(backend.changes_tries_storage.get(&root2, &[]).unwrap().is_none()); + assert!(backend.changes_tries_storage.get(&root3, &[]).unwrap().is_some()); } #[test] diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 8a3456df69a305c55870617c4147950a517c0da5..62b6486f54d7ea28ac5561a33aa5b374943e26ec 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2018 Parity Technologies (UK) Ltd. +// Copyright 2017-2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ //! RocksDB-based light client blockchain storage. -use std::sync::Arc; +use std::{sync::Arc, collections::HashMap}; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -32,7 +32,8 @@ use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, - Zero, One, As, NumberFor, Digest, DigestItem, AuthorityIdFor}; + Zero, One, As, NumberFor, Digest, DigestItem}; +use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId}; use crate::utils::{self, meta_keys, Meta, db_err, open_database, read_db, block_id_to_lookup_key, read_meta}; @@ -59,7 +60,7 @@ pub struct LightStorage { db: Arc, meta: RwLock, Block::Hash>>, leaves: RwLock>>, - cache: DbCacheSync, + cache: Arc>, } impl LightStorage @@ -96,7 +97,7 @@ impl LightStorage Ok(LightStorage { db, meta: RwLock::new(meta), - cache: DbCacheSync(RwLock::new(cache)), + cache: Arc::new(DbCacheSync(RwLock::new(cache))), leaves: RwLock::new(leaves), }) } @@ -370,7 +371,7 @@ impl LightBlockchainStorage for LightStorage fn import_header( &self, header: Block::Header, - authorities: Option>>, + cache_at: HashMap>, leaf_state: NewBlockState, aux_ops: Vec<(Vec, Option>)>, ) -> ClientResult<()> { @@ -432,7 +433,7 @@ impl LightBlockchainStorage for LightStorage .on_block_insert( ComplexBlockId::new(*header.parent_hash(), if number.is_zero() { Zero::zero() } else { number - One::one() }), ComplexBlockId::new(hash, number), - authorities, + cache_at, finalized, )? .into_ops(); @@ -521,8 +522,8 @@ impl LightBlockchainStorage for LightStorage Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option<&BlockchainCache> { - Some(&self.cache) + fn cache(&self) -> Option>> { + Some(self.cache.clone()) } } @@ -538,9 +539,11 @@ pub(crate) mod tests { use client::cht; use runtime_primitives::generic::DigestItem; use runtime_primitives::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; + use runtime_primitives::traits::AuthorityIdFor; use super::*; type Block = RawBlock>; + type AuthorityId = AuthorityIdFor; pub fn default_header(parent: &Hash, number: u64) -> Header { Header { @@ -566,41 +569,41 @@ pub(crate) mod tests { pub fn insert_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Best, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Best, Vec::new()).unwrap(); hash } fn insert_final_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Final, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Final, Vec::new()).unwrap(); hash } fn insert_non_best_block Header>( db: &LightStorage, - authorities: Option>>, + cache: HashMap>, header: F, ) -> Hash { let header = header(); let hash = header.hash(); - db.import_header(header, authorities, NewBlockState::Normal, Vec::new()).unwrap(); + db.import_header(header, cache, NewBlockState::Normal, Vec::new()).unwrap(); hash } #[test] fn returns_known_header() { let db = LightStorage::new_test(); - let known_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let known_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let header_by_hash = db.header(BlockId::Hash(known_hash)).unwrap().unwrap(); let header_by_number = db.header(BlockId::Number(0)).unwrap().unwrap(); assert_eq!(header_by_hash, header_by_number); @@ -616,12 +619,12 @@ pub(crate) mod tests { #[test] fn returns_info() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); let info = db.info().unwrap(); assert_eq!(info.best_hash, genesis_hash); assert_eq!(info.best_number, 0); assert_eq!(info.genesis_hash, genesis_hash); - let best_hash = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let best_hash = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); let info = db.info().unwrap(); assert_eq!(info.best_hash, best_hash); assert_eq!(info.best_number, 1); @@ -631,7 +634,7 @@ pub(crate) mod tests { #[test] fn returns_block_status() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.status(BlockId::Hash(genesis_hash)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Number(0)).unwrap(), BlockStatus::InChain); assert_eq!(db.status(BlockId::Hash(Hash::from_low_u64_be(1))).unwrap(), BlockStatus::Unknown); @@ -641,7 +644,7 @@ pub(crate) mod tests { #[test] fn returns_block_hash() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.hash(0).unwrap(), Some(genesis_hash)); assert_eq!(db.hash(1).unwrap(), None); } @@ -650,11 +653,11 @@ pub(crate) mod tests { fn import_header_works() { let db = LightStorage::new_test(); - let genesis_hash = insert_block(&db, None, || default_header(&Default::default(), 0)); + let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); assert_eq!(db.db.iter(columns::HEADER).count(), 1); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 2); - let _ = insert_block(&db, None, || default_header(&genesis_hash, 1)); + let _ = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); assert_eq!(db.db.iter(columns::HEADER).count(), 2); assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), 4); } @@ -665,25 +668,25 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert genesis block header (never pruned) - let mut prev_hash = insert_final_block(&db, None, || header_producer(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_producer(&Default::default(), 0)); // insert SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert next SIZE blocks && ensure that nothing is pruned for number in 0..cht::SIZE { - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + number)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + number)); } assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert block #{2 * cht::SIZE + 1} && check that new CHT is created + headers of this CHT are pruned // nothing is yet finalized, so nothing is pruned. - prev_hash = insert_block(&db, None, || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); + prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); assert_eq!(db.db.iter(columns::HEADER).count(), (2 + cht::SIZE + cht::SIZE) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 0); @@ -732,9 +735,9 @@ pub(crate) mod tests { let db = LightStorage::new_test(); // insert 1 + SIZE + SIZE + 1 blocks so that CHT#0 is created - let mut prev_hash = insert_final_block(&db, None, || header_with_changes_trie(&Default::default(), 0)); + let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_with_changes_trie(&Default::default(), 0)); for i in 1..1 + cht::SIZE + cht::SIZE + 1 { - prev_hash = insert_block(&db, None, || header_with_changes_trie(&prev_hash, i as u64)); + prev_hash = insert_block(&db, HashMap::new(), || header_with_changes_trie(&prev_hash, i as u64)); db.finalize_header(BlockId::Hash(prev_hash)).unwrap(); } @@ -754,16 +757,16 @@ pub(crate) mod tests { #[test] fn tree_route_works() { let db = LightStorage::new_test(); - let block0 = insert_block(&db, None, || default_header(&Default::default(), 0)); + let block0 = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); // fork from genesis: 3 prong. - let a1 = insert_block(&db, None, || default_header(&block0, 1)); - let a2 = insert_block(&db, None, || default_header(&a1, 2)); - let a3 = insert_block(&db, None, || default_header(&a2, 3)); + let a1 = insert_block(&db, HashMap::new(), || default_header(&block0, 1)); + let a2 = insert_block(&db, HashMap::new(), || default_header(&a1, 2)); + let a3 = insert_block(&db, HashMap::new(), || default_header(&a2, 3)); // fork from genesis: 2 prong. - let b1 = insert_block(&db, None, || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); - let b2 = insert_block(&db, None, || default_header(&b1, 2)); + let b1 = insert_block(&db, HashMap::new(), || header_with_extrinsics_root(&block0, 1, Hash::from([1; 32]))); + let b2 = insert_block(&db, HashMap::new(), || default_header(&b1, 2)); { let tree_route = ::client::blockchain::tree_route( @@ -815,44 +818,64 @@ pub(crate) mod tests { } #[test] - fn authorites_are_cached() { + fn authorities_are_cached() { let db = LightStorage::new_test(); fn run_checks(db: &LightStorage, max: u64, checks: &[(u64, Option>>)]) { for (at, expected) in checks.iter().take_while(|(at, _)| *at <= max) { - let actual = db.cache().authorities_at(BlockId::Number(*at)); + let actual = get_authorities(db.cache(), BlockId::Number(*at)); assert_eq!(*expected, actual); } } + fn same_authorities() -> HashMap> { + HashMap::new() + } + + fn make_authorities(authorities: Vec) -> HashMap> { + let mut map = HashMap::new(); + map.insert(well_known_cache_keys::AUTHORITIES, authorities.encode()); + map + } + + fn get_authorities(cache: &BlockchainCache, at: BlockId) -> Option