diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..219c13acb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..3e16d3ca7 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,67 @@ +name: continuous-intergration/windows + +on: + pull_request: + push: + branches: + - master + tags: + - v* + paths-ignore: + - 'README.md' + +jobs: + check: + name: build-contract-template + strategy: + matrix: + platform: + - windows-latest + toolchain: + - nightly + runs-on: ${{ matrix.platform }} + env: + RUST_BACKTRACE: full + steps: + + - uses: engineerd/configurator@v0.0.6 + with: + name: "wasm-opt.exe" + url: "https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-windows.tar.gz" + pathInArchive: "binaryen-version_101/bin/wasm-opt.exe" + + - name: Checkout sources & submodules + uses: actions/checkout@master + with: + fetch-depth: 1 + submodules: recursive + + - name: Install toolchain + id: toolchain + uses: actions-rs/toolchain@master + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + components: rust-src + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@v1.2.0 + + - name: Build contract template on ${{ matrix.platform }}-${{ matrix.toolchain }} + run: | + wasm-opt --version + cargo -vV + cargo run -- contract --version + cargo run -- contract new foobar + echo "[workspace]" >> foobar/Cargo.toml + cargo run -- contract build --manifest-path=foobar/Cargo.toml + cargo run -- contract check --manifest-path=foobar/Cargo.toml + cargo run -- contract test --manifest-path=foobar/Cargo.toml + + - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} + # The tests take a long time in the GitHub Actions runner (~30 mins), + # hence we run them only on `master`. + if: github.ref == 'refs/heads/master' + run: | + cargo test --verbose --workspace --all-features diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8d9c37f9..aa2b90ab3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,13 +12,18 @@ stages: variables: GIT_STRATEGY: fetch - GIT_DEPTH: 3 - CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}" + GIT_DEPTH: "100" + CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" - CI_SERVER_NAME: "GitLab CI" - REGISTRY: "paritytech" - RUSTUP_TOOLCHAIN: nightly - RUST_LIB_BACKTRACE: 0 + RUST_LIB_BACKTRACE: "0" + # this var is changed to "-:staging" when the CI image gets rebuilt + # read more https://github.com/paritytech/cargo-contract/pull/115 + CI_IMAGE: "paritytech/contracts-ci-linux:production" + +workflow: + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH .collect-artifacts: &collect-artifacts artifacts: @@ -29,28 +34,28 @@ variables: - artifacts/ .docker-env: &docker-env - image: ${REGISTRY}/contracts-ci-linux:latest + image: "${CI_IMAGE}" before_script: - cargo -vV - rustc -vV - rustup show - bash --version - - mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config - - mkdir -p ${CARGO_TARGET_DIR} + - ./scripts/pre_cache.sh # global RUSTFLAGS overrides the linker args so this way is better to pass the flags - - printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config + - printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' > ${CARGO_HOME}/config - sccache -s - git show - only: - - master - - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - - schedules - - web - - /^[0-9]+$/ # PRs + rules: + - if: $CI_PIPELINE_SOURCE == "web" + - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_COMMIT_REF_NAME == "master" + - if: $CI_COMMIT_REF_NAME == "tags" + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 dependencies: [] interruptible: true retry: - max: 2 + max: 2 when: - runner_system_failure - unknown_failure @@ -68,13 +73,39 @@ fmt: script: - cargo fmt --verbose --all -- --check +clippy: + stage: check + <<: *docker-env + script: + - cargo clippy --verbose --all-targets --all-features -- -D warnings; + #### stage: test (all features) test: stage: test <<: *docker-env script: - - cargo test --verbose --all-features + - cargo test --verbose --workspace --all-features + +test-new-project-template: + stage: test + <<: *docker-env + script: + - cargo run -- contract new new_project + + # needed because otherwise: + # `error: current package believes it's in a workspace when it's not` + - echo "[workspace]" >> new_project/Cargo.toml + + - cargo run --all-features -- contract build --manifest-path new_project/Cargo.toml + - cargo run --all-features -- contract check --manifest-path new_project/Cargo.toml + - cargo run --all-features -- contract test --manifest-path new_project/Cargo.toml + - cd new_project + + - cargo check --verbose + - cargo test --verbose --all + - cargo fmt --verbose --all -- --check + - cargo clippy --verbose --manifest-path Cargo.toml -- -D warnings; #### stage: build (default features) @@ -82,9 +113,11 @@ build: stage: build <<: *docker-env <<: *collect-artifacts - only: - - schedules - - master + rules: + - if: $CI_PIPELINE_SOURCE == "web" + - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_COMMIT_REF_NAME == "master" + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 script: - cargo build --verbose --release after_script: diff --git a/.images/cargo-contract.svg b/.images/cargo-contract.svg new file mode 100644 index 000000000..61f1acde6 --- /dev/null +++ b/.images/cargo-contract.svg @@ -0,0 +1,103 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/.images/ink-squid.svg b/.images/ink-squid.svg new file mode 100644 index 000000000..3058c4230 --- /dev/null +++ b/.images/ink-squid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.rustfmt.toml b/.rustfmt.toml index 814bfd61e..183ce92e0 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1 +1,3 @@ license_template_path = "FILE_HEADER" # changed +report_todo = "Always" +report_fixme = "Always" diff --git a/CHANGELOG.md b/CHANGELOG.md index 13fc238a6..3e1861a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,160 @@ -# Version 0.6.1 (2020-05-12) +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Changed +- Update `cargo contract new` template dependencies to ink! `rc4` - [#332](https://github.com/paritytech/cargo-contract/pull/332) +- Update `cargo contract new` template dependencies to ink! `rc5` - [#335](https://github.com/paritytech/cargo-contract/pull/335) + +## [0.14.0] - 2021-08-12 + +### Added +- Add option for JSON formatted output - [#324](https://github.com/paritytech/cargo-contract/pull/324) + +### Changed +- Use new dependency resolver for template contract - [#325](https://github.com/paritytech/cargo-contract/pull/325) +- Do not strip out panic messages in debug builds - [#326](https://github.com/paritytech/cargo-contract/pull/326) + +## [0.13.1] - 2021-08-03 + +### Fixed +- Fixed a Windows issue with contract files in sub-folders - [#313](https://github.com/paritytech/cargo-contract/pull/313) + +## [0.13.0] - 2021-07-22 + +### Added +- Convenient off-chain testing through `cargo contract test` - [#283](https://github.com/paritytech/cargo-contract/pull/283) +- Build contracts in debug mode by default, add `--release` flag - [#298](https://github.com/paritytech/cargo-contract/pull/298) +- Add `--keep-symbols` flag for better Wasm analysis capabilities - [#302](https://github.com/paritytech/cargo-contract/pull/302) + +### Changed +- Change default optimizations pass to focus on code size - [#305](https://github.com/paritytech/cargo-contract/pull/305) + +## [0.12.1] - 2021-05-25 + +### Added +- Suggest `binaryen` installation from GitHub release on outdated version - [#274](https://github.com/paritytech/cargo-contract/pull/274) + +### Fixed +- Always use library targets name for contract artifacts - [#277](https://github.com/paritytech/cargo-contract/pull/277) + +## [0.12.0] - 2021-04-21 + +### Fixed +- Fixed `ERROR: The workspace root package should be a workspace member` when building a contract + under Windows - [#261](https://github.com/paritytech/cargo-contract/pull/261) + +### Removed +- Remove support for `--binaryen-as-dependency` - [#251](https://github.com/paritytech/cargo-contract/pull/251) +- Remove support for the deprecated `cargo contract generate-metadata` command - [#265](https://github.com/paritytech/cargo-contract/pull/265) +- Remove pinned `funty` dependency from "new project" template - [#260](https://github.com/paritytech/cargo-contract/pull/260) + +## [0.11.1] - 2021-04-06 + +### Fixed +- Fix `wasm-opt --version` parsing - [#248](https://github.com/paritytech/cargo-contract/pull/248) + +## [0.11.0] - 2021-03-31 + +### Added +- Improve error output for `wasm-opt` interaction - [#244](https://github.com/paritytech/cargo-contract/pull/244) +- Check optimized Wasm output file exists - [#243](https://github.com/paritytech/cargo-contract/pull/243) +- Detect `wasm-opt` version compatibility and improve error messages - [#242](https://github.com/paritytech/cargo-contract/pull/242) +- Detect version mismatches of `parity-scale-codec` in contract and ink! dependency - [#237](https://github.com/paritytech/cargo-contract/pull/237) +- Support specifying `optimization-passes` in the release profile - [#231](https://github.com/paritytech/cargo-contract/pull/231) +- Support specifying `optimization-passes` on the CLI - [#216](https://github.com/paritytech/cargo-contract/pull/216) +- Use `ink::test` attribute in "new project" template - [#190](https://github.com/paritytech/cargo-contract/pull/190) + +### Fixed +- Only allow new contract names beginning with an alphabetic character - [#219](https://github.com/paritytech/cargo-contract/pull/219) +- Upgrade `cargo-metadata` and fix usages - [#210](https://github.com/paritytech/cargo-contract/pull/210) + +## [0.10.0] - 2021-03-02 + +### Fixed +- no periods in new contract names - [#192](https://github.com/paritytech/cargo-contract/pull/192) + +### Changed +- Update `cargo contract new` template dependencies for `ink!` `rc3` - [#204](https://github.com/paritytech/cargo-contract/pull/204) + +## [0.9.1] - 2021-02-24 + +### Fixed +- Fix linker error when building complex contracts - [#199](https://github.com/paritytech/cargo-contract/pull/199) + +## [0.9.0] - 2021-02-22 + +### Added +- Implement Wasm validation for known issues/markers - [#171](https://github.com/paritytech/cargo-contract/pull/171) + +### Changed +- Use either `binaryen-rs` dep or `wasm-opt` binary - [#168](https://github.com/paritytech/cargo-contract/pull/168) +- Update to scale-info 0.5 and codec 2.0 - [#164](https://github.com/paritytech/cargo-contract/pull/164) +- Put build artifacts under `target/ink/` - [#122](https://github.com/paritytech/cargo-contract/pull/122) + +### Fixed +- Fix `wasm-opt` regression - [#187](https://github.com/paritytech/cargo-contract/pull/187) +- Generate metadata explicitly for the contract which is build - [#174](https://github.com/paritytech/cargo-contract/pull/174) +- Fix bug with empty Wasm file when using system binaryen for optimization - [#179](https://github.com/paritytech/cargo-contract/pull/179) +- Suppress output on `--quiet` - [#165](https://github.com/paritytech/cargo-contract/pull/165) +- Do not generate build artifacts under `target` for `check` - [#124](https://github.com/paritytech/cargo-contract/pull/124) +- update wasm-path usage name - [#135](https://github.com/paritytech/cargo-contract/pull/135) + +## [0.8.0] - 2020-11-27 + +- Exit with 1 on Err [#109](https://github.com/paritytech/cargo-contract/pull/109) +- Use package name instead of lib name for metadata dependency [#107](https://github.com/paritytech/cargo-contract/pull/107) +- Do not prettify JSON for bundle [#105](https://github.com/paritytech/cargo-contract/pull/105) +- Make `source.hash` non-optional, remove metadata-only [#104](https://github.com/paritytech/cargo-contract/pull/104) +- Implement new commands `build` and `check` + introduce bundles (.contract files) [#97](https://github.com/paritytech/cargo-contract/pull/97) +- Replace xbuild with cargo build-std [#99](https://github.com/paritytech/cargo-contract/pull/99) +- Use binaryen-rs as dep instead of requiring manual wasm-opt installation [#95](https://github.com/paritytech/cargo-contract/pull/95) +- Specify optional --manifest-path for build and generate-metadata [#93](https://github.com/paritytech/cargo-contract/pull/93) + +## [0.7.1] - 2020-10-26 + +- Update new command template to ink! 3.0-rc2 [#85](https://github.com/paritytech/cargo-contract/pull/85) + +## [0.7.0] - 2020-10-13 + +- Fix deprecation warnings [#82](https://github.com/paritytech/cargo-contract/pull/82) +- Use ink 3.0.0-rc1 [#82](https://github.com/paritytech/cargo-contract/pull/82) +- [template] now uses ink_env and ink_storage [#81](https://github.com/paritytech/cargo-contract/pull/81) +- Update new command template to ink! 3.0 syntax [#80](https://github.com/paritytech/cargo-contract/pull/80) +- Extract contract metadata to its own crate [#69](https://github.com/paritytech/cargo-contract/pull/69) +- Fix ManifestPath compiler errors [#73](https://github.com/paritytech/cargo-contract/pull/73) +- Upgrade cargo-xbuild and other dependencies [#71](https://github.com/paritytech/cargo-contract/pull/71) +- Update subxt and async-std dependencies [#66](https://github.com/paritytech/cargo-contract/pull/66) +- Generate extended contract metadata [#62](https://github.com/paritytech/cargo-contract/pull/62) +- Autogenerate abi/metadata package [#58](https://github.com/paritytech/cargo-contract/pull/58) +- Extract workspace to module directory [#59](https://github.com/paritytech/cargo-contract/pull/59) +- Add preferred default release profile settings [#55](https://github.com/paritytech/cargo-contract/pull/55) +- Add option to build with unmodified original manifest [#51](https://github.com/paritytech/cargo-contract/pull/51) +- Update cargo-xbuild [#54](https://github.com/paritytech/cargo-contract/pull/54) + +## [0.6.1] - 2020-05-12 - Fix LTO regressions in nightly toolchain [#52](https://github.com/paritytech/cargo-contract/pull/52) -# Version 0.6.0 (2020-03-25) +## [0.6.0] - 2020-03-25 - First release to crates.io - Use `subxt` release from [crates.io](https://crates.io/crates/substrate-subxt) -# Version 0.5.0 (2020-03-18) +## [0.5.0] - 2020-03-18 - Upgrades dependencies [#45](https://github.com/paritytech/cargo-contract/pull/45) - Update template to ink! 2.0 dependencies [#47](https://github.com/paritytech/cargo-contract/pull/47) -# Version 0.4.1 (2020-02-26) +## [0.4.1] - 2020-02-26 - Fix: fail the whole build process if the contract build fails. -# Version 0.4.0 (2020-02-26) +## [0.4.0] - 2020-02-26 - Minimize contract wasm binary size: - Run `wasm-opt` on the contract Wasm binary. diff --git a/Cargo.lock b/Cargo.lock index 01e681617..95b824cb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "Inflector" version = "0.11.4" @@ -12,33 +14,36 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.12.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456d75cbb82da1ad150c8a9d97285ffcd21c9931dcb11e995903e7d75141b38b" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" -version = "0.2.18" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" -dependencies = [ - "const-random", -] +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" [[package]] name = "ahash" -version = "0.3.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c251dce3391a07b43218ca070203ecb8f9f520d35ab71312296a59dbceab154" +checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "aho-corasick" -version = "0.7.10" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -60,7 +65,16 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", ] [[package]] @@ -74,9 +88,18 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.28" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" + +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] [[package]] name = "approx" @@ -104,64 +127,137 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.5.1" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7" + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "async-channel" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] [[package]] -name = "asn1_der" -version = "0.6.3" +name = "async-executor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" dependencies = [ - "asn1_der_derive", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "slab", ] [[package]] -name = "asn1_der_derive" -version = "0.1.2" +name = "async-global-executor" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" +checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" dependencies = [ - "quote", - "syn", + "async-channel", + "async-executor", + "async-io", + "async-mutex", + "blocking", + "futures-lite", + "num_cpus", + "once_cell", ] [[package]] -name = "assert_matches" -version = "1.3.0" +name = "async-io" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" +checksum = "4bbfd5cf2794b1e908ea8457e6c45f8f8f1f6ec5f74617bf4662623f47503c3b" +dependencies = [ + "concurrent-queue", + "fastrand", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "slab", + "socket2 0.4.0", + "waker-fn", + "winapi 0.3.9", +] + +[[package]] +name = "async-lock" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-mutex" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" +dependencies = [ + "event-listener", +] [[package]] name = "async-std" -version = "1.6.2" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d68a33ebc8b57800847d00787307f84a562224a14db069b0acefe4c2abbf5d" +checksum = "f8056f1455169ab86dd47b47391e4ab0cbd25410a70e9fe675544f49bafaf952" dependencies = [ - "async-task", + "async-channel", + "async-global-executor", + "async-io", + "async-lock", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", +<<<<<<< HEAD "futures-timer 3.0.2", +======= + "futures-lite", + "gloo-timers", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "kv-log-macro", "log", "memchr", "num_cpus", "once_cell", - "pin-project-lite", + "pin-project-lite 0.2.6", "pin-utils", "slab", - "smol", "wasm-bindgen-futures", ] [[package]] name = "async-task" -version = "3.0.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-tls" @@ -169,17 +265,24 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce6977f57fa68da77ffe5542950d47e9c23d65f5bc7cb0a9f8700996913eec7" dependencies = [ - "futures 0.3.5", + "futures", "rustls", "webpki", "webpki-roots", ] [[package]] +<<<<<<< HEAD name = "atomic" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64f46ca51dca4837f1520754d1c8c36636356b81553d928dc9c177025369a06e" +======= +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [[package]] name = "atty" @@ -189,7 +292,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -200,19 +303,25 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.47" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5393cb2f40a6fae0014c9af00018e95846f3b241b331a6b7733c326d3e58108" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cc", + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libc", + "miniz_oxide", "object", "rustc-demangle", ] @@ -257,20 +366,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" dependencies = [ "either", - "radium", + "radium 0.3.0", +] + +[[package]] +name = "bitvec" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +dependencies = [ + "funty", + "radium 0.6.2", + "tap", + "wyz", ] [[package]] name = "blake2" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ce5b6108f8e154604bd4eb76a2f726066c3464d5a552a4229262a18c9bb471" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" dependencies = [ - "byte-tools", - "byteorder", "crypto-mac 0.8.0", "digest 0.9.0", +<<<<<<< HEAD "opaque-debug 0.2.3", +======= + "opaque-debug 0.3.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -283,28 +406,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "blake2b_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "constant_time_eq", -] - -[[package]] -name = "blake2s_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "constant_time_eq", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -314,7 +415,16 @@ dependencies = [ "block-padding 0.1.5", "byte-tools", "byteorder", - "generic-array 0.12.3", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", ] [[package]] @@ -344,15 +454,16 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blocking" -version = "0.4.6" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d17efb70ce4421e351d61aafd90c16a20fb5bfe339fcdc32a86816280e62ce0" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" dependencies = [ - "futures-channel", - "futures-util", + "async-channel", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", "once_cell", - "parking", - "waker-fn", ] [[package]] @@ -369,18 +480,18 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "memchr", ] [[package]] name = "bumpalo" -version = "3.2.1" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byte-slice-cast" @@ -388,6 +499,12 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" +[[package]] +name = "byte-slice-cast" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c1bf4a04a88c54f589125563643d773f3254b5c38571395e2b591c693bbc81" + [[package]] name = "byte-tools" version = "0.3.1" @@ -396,15 +513,21 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "bytes" -version = "0.5.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cache-padded" @@ -413,37 +536,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] +<<<<<<< HEAD name = "cargo-t3rn-contract" version = "0.4.1" +======= +name = "camino" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4648c6d00a709aa069a236adcaae4f605a6241c72bf5bee79331a4b625921a9" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-contract" +version = "0.14.0" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "anyhow", "assert_matches", "async-std", "blake2", - "cargo-xbuild", "cargo_metadata", "colored", + "contract-metadata", "env_logger", - "futures 0.3.5", + "funty", + "futures", "heck", "hex", + "impl-serde", "log", +<<<<<<< HEAD "meval", "parity-scale-codec", "parity-wasm", "pretty_assertions", "pwasm-utils", +======= + "parity-scale-codec 2.1.1", + "parity-wasm 0.42.2", + "platforms", + "pretty_assertions", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "regex", "rustc_version", - "semver 0.10.0", + "semver", "serde", "serde_json", "sp-core", "structopt", + "substrate-build-script-utils", "substrate-subxt", "tempfile", "toml", - "url 2.1.1", + "url", "wabt", "walkdir", "wat", @@ -452,41 +599,47 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "cargo-xbuild" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681545a8d9888d72325ffc1603065ec4732986c8ce88cfffae0464ce22daad3a" +======= +name = "cargo-platform" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "cargo_metadata", - "error-chain", - "fs2", - "libc", - "rustc_version", "serde", +<<<<<<< HEAD "serde_derive", "serde_json", "tempfile", "toml", "walkdir", +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "cargo_metadata" -version = "0.9.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" +checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a" dependencies = [ - "semver 0.9.0", + "camino", + "cargo-platform", + "semver", "serde", - "serde_derive", "serde_json", ] [[package]] name = "cc" -version = "1.0.52" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" [[package]] name = "cfg-if" @@ -509,15 +662,19 @@ dependencies = [ "libc", "num-integer", "num-traits", +<<<<<<< HEAD "time", "winapi 0.3.8", +======= + "winapi 0.3.9", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "clap" -version = "2.33.1" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term 0.11.0", "atty", @@ -548,58 +705,64 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" +checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" dependencies = [ "cc", ] [[package]] name = "colored" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" dependencies = [ "atty", "lazy_static", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "concurrent-queue" -version = "1.1.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1582139bb74d97ef232c30bc236646017db06f13ee7cc01fa24c9e55640f86d4" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" dependencies = [ "cache-padded", ] [[package]] -name = "const-random" -version = "0.1.8" +name = "constant_time_eq" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "contract-metadata" +version = "0.3.0" dependencies = [ - "const-random-macro", - "proc-macro-hack", + "pretty_assertions", + "semver", + "serde", + "serde_json", + "url", ] [[package]] -name = "const-random-macro" -version = "0.1.8" +name = "convert_case" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" -dependencies = [ - "getrandom", - "proc-macro-hack", -] +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "cpufeatures" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +dependencies = [ + "libc", +] [[package]] name = "cpuid-bool" @@ -609,21 +772,30 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crc32fast" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ +<<<<<<< HEAD "autocfg 1.0.0", "cfg-if 0.1.10", +======= + "autocfg 1.0.1", + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "lazy_static", ] @@ -639,7 +811,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", "subtle 1.0.0", ] @@ -649,15 +821,15 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.2", - "subtle 2.2.2", + "generic-array 0.14.4", + "subtle 2.4.0", ] [[package]] name = "ctor" -version = "0.1.15" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39858aa5bac06462d4dd4b9164848eb81ffc4aa5c479746393598fd193afa227" +checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d" dependencies = [ "quote", "syn", @@ -665,39 +837,47 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "2.0.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" +checksum = "434e1720189a637d44fe464f4df1e6eb900b4835255b14354497c78af37d9bb8" dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle 2.2.2", + "subtle 2.4.0", "zeroize", ] [[package]] -name = "data-encoding" -version = "2.2.1" +name = "curve25519-dalek" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle 2.4.0", + "zeroize", +] [[package]] name = "derive_more" -version = "0.99.5" +version = "0.99.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" +checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320" dependencies = [ + "convert_case", "proc-macro2", "quote", "syn", ] [[package]] -name = "difference" -version = "2.0.0" +name = "diff" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] name = "digest" @@ -705,7 +885,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -714,10 +894,32 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.2", + "generic-array 0.14.4", +] + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] +<<<<<<< HEAD name = "dyn-clonable" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -743,27 +945,37 @@ name = "dyn-clone" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55796afa1b20c2945ca8eabfc421839f2b766619209f1ede813cf2484f31804" +======= +name = "dyn-clone" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [[package]] name = "ed25519" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf038a7b6fd7ef78ad3348b63f3a17550877b0e28f8d68bcc94894d1412158bc" +checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" dependencies = [ "signature", ] [[package]] name = "ed25519-dalek" -version = "1.0.0-pre.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a8a37f4e8b35af971e6db5e3897e7a6344caa3f92f6544f88125a1f5f0035a" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 3.1.0", "ed25519", "rand 0.7.3", "serde", +<<<<<<< HEAD "sha2 0.8.1", +======= + "sha2 0.9.5", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "zeroize", ] @@ -775,9 +987,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "env_logger" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" dependencies = [ "atty", "humantime", @@ -788,18 +1000,15 @@ dependencies = [ [[package]] name = "environmental" -version = "1.1.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" +checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" [[package]] -name = "error-chain" -version = "0.12.2" +name = "event-listener" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" -dependencies = [ - "version_check", -] +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "failure" @@ -831,9 +1040,12 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fastrand" -version = "1.3.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36a9cb09840f81cd211e435d00a4e487edd263dc3c8ff815c32dd76ad668ebed" +checksum = "77b705829d1e87f762c2df6da140b26af5839e1033aa84aa5f56bb688e4e1bdb" +dependencies = [ + "instant", +] [[package]] name = "finality-grandpa" @@ -863,16 +1075,39 @@ dependencies = [ ] [[package]] -name = "fixedbitset" -version = "0.2.0" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "fnv" -version = "1.0.6" +name = "form_urlencoded" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "frame-benchmarking" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b94f3dd88fd10ea9eb8bf6731ee22787deeb620c158766061ec1fc54170cda" +dependencies = [ + "frame-support", + "frame-system", + "linregress", + "parity-scale-codec 1.3.7", + "paste", + "sp-api", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", +] [[package]] name = "frame-benchmarking" @@ -895,11 +1130,17 @@ dependencies = [ [[package]] name = "frame-metadata" +<<<<<<< HEAD version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b5640bfcb7111643807c63cd38ecdcc923d3253e525f23ab6b366002bf8ecd5" +======= +version = "12.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61200390d9eb6bac07a60adafa6961ef250f9022970fabb2412183fc96ba5f6b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "parity-scale-codec", + "parity-scale-codec 1.3.7", "serde", "sp-core", "sp-std", @@ -907,9 +1148,15 @@ dependencies = [ [[package]] name = "frame-support" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "807c32da14bd0e5fb751095335a07938cda6f1488f57d7b0539118e3434980a8" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a569b3964b996dae5a9aab81a04a65f81a386645db1f16583647fc67190b0748" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "bitmask", "frame-metadata", @@ -917,10 +1164,10 @@ dependencies = [ "impl-trait-for-tuples", "log", "once_cell", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "paste", "serde", - "smallvec 1.4.1", + "smallvec", "sp-arithmetic", "sp-core", "sp-inherents", @@ -933,9 +1180,15 @@ dependencies = [ [[package]] name = "frame-support-procedural" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "508dc2eb44a802f1876e3dc97a76aed8f18b993f75f6cb1975cb83cf45a5d981" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c107da590c5cf22f9bb96193812256e59c60f73786a72429660142d9000c07b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "frame-support-procedural-tools", "proc-macro2", @@ -945,9 +1198,15 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f6d1dd14477123180c47024bcc24c1a624ea8631b4f00080d14089907397f4" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb23ac15b9dfe806c1da92d6c8710fa09371ec61e13f4eadfdeef55e3d6b155b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -958,9 +1217,15 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ad38379ecedd632f286c7b94a4b9a15bffb635194de4dbf2b4458bc46cee28f" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fb72ae75d457bfcb457e1098cf18134967e9069ecc4bba2c77416924b44843" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro2", "quote", @@ -969,13 +1234,19 @@ dependencies = [ [[package]] name = "frame-system" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d172404f0e44b867f5fd14465a27f298b8828b53d7a7a555d3759e1dec3c8f0d" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bd441142244193759326c7311d075716d1aaa98a9ad50491af923a4c6e42f3b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "frame-support", "impl-trait-for-tuples", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "serde", "sp-core", "sp-io", @@ -984,16 +1255,6 @@ dependencies = [ "sp-version", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi 0.3.8", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -1017,16 +1278,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] -name = "futures" -version = "0.1.29" +name = "funty" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" dependencies = [ "futures-channel", "futures-core", @@ -1039,9 +1300,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", "futures-sink", @@ -1049,15 +1310,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-executor" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" dependencies = [ "futures-core", "futures-task", @@ -1067,16 +1328,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-lite" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite 0.2.6", + "waker-fn", +] [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ + "autocfg 1.0.1", "proc-macro-hack", "proc-macro2", "quote", @@ -1085,18 +1362,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" -dependencies = [ - "once_cell", -] +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-timer" @@ -1109,18 +1383,14 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper 0.4.0", -] [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ - "futures 0.1.29", + "autocfg 1.0.1", "futures-channel", "futures-core", "futures-io", @@ -1128,7 +1398,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project", + "pin-project-lite 0.2.6", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1150,39 +1420,54 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] [[package]] name = "generic-array" -version = "0.14.2" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac746a5f3bbfdadd6106868134545e684693d54d9d44f6e9588a7d54af0bf980" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "typenum", - "version_check", + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.1.14" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.21.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "glob" @@ -1192,9 +1477,9 @@ checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" [[package]] name = "globset" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" dependencies = [ "aho-corasick", "bstr", @@ -1218,21 +1503,22 @@ dependencies = [ [[package]] name = "h2" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", "futures-util", "http", "indexmap", - "log", "slab", "tokio", "tokio-util", + "tracing", + "tracing-futures", ] [[package]] @@ -1252,57 +1538,56 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.6.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" dependencies = [ - "ahash 0.2.18", - "autocfg 0.1.7", + "ahash 0.3.8", + "autocfg 1.0.1", ] [[package]] name = "hashbrown" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" +checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" dependencies = [ - "ahash 0.3.4", - "autocfg 1.0.0", + "ahash 0.3.8", + "autocfg 1.0.1", ] [[package]] name = "hashbrown" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" dependencies = [ - "ahash 0.3.4", - "autocfg 1.0.0", + "ahash 0.4.7", ] [[package]] name = "heck" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.12" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" @@ -1321,17 +1606,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" dependencies = [ "digest 0.8.1", - "generic-array 0.12.3", + "generic-array 0.12.4", "hmac", ] [[package]] name = "http" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" dependencies = [ - "bytes", + "bytes 1.0.1", "fnv", "itoa", ] @@ -1342,32 +1627,35 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes", + "bytes 0.5.6", "http", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" + +[[package]] +name = "httpdate" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" [[package]] name = "humantime" -version = "1.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.13.5" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96816e1d921eca64d208a85aab4f7798455a8e34229ee5a88c935bdee1b78b14" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-channel", "futures-core", "futures-util", @@ -1375,32 +1663,21 @@ dependencies = [ "http", "http-body", "httparse", + "httpdate", "itoa", - "log", - "net2", - "pin-project", - "time", + "pin-project 1.0.7", + "socket2 0.3.19", "tokio", "tower-service", + "tracing", "want", ] [[package]] name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", @@ -1413,7 +1690,11 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" dependencies = [ +<<<<<<< HEAD "parity-scale-codec", +======= + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -1438,15 +1719,17 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.3.2" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", + "hashbrown 0.9.1", ] [[package]] name = "instant" +<<<<<<< HEAD version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" @@ -1463,37 +1746,53 @@ checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" [[package]] name = "iovec" version = "0.1.4" +======= +version = "0.1.9" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ - "libc", + "cfg-if 1.0.0", ] [[package]] -name = "itertools" -version = "0.8.2" +name = "integer-sqrt" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" dependencies = [ - "either", + "num-traits", +] + +[[package]] +<<<<<<< HEAD +======= +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", ] [[package]] +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "itoa" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.39" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" dependencies = [ "wasm-bindgen", ] [[package]] +<<<<<<< HEAD name = "jsonrpc-client-transports" version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1557,6 +1856,8 @@ dependencies = [ ] [[package]] +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "jsonrpsee" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1564,11 +1865,19 @@ checksum = "5cc8a1da5a54b417cfb7edb9f932024d833dc333de50c21c0e1b28d0e8b4f853" dependencies = [ "async-std", "async-tls", +<<<<<<< HEAD "bs58 0.3.1", "bytes", "fnv", "futures 0.3.5", "futures-timer 3.0.2", +======= + "bs58", + "bytes 0.5.6", + "fnv", + "futures", + "futures-timer", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "globset", "hashbrown 0.7.2", "hyper", @@ -1576,16 +1885,16 @@ dependencies = [ "lazy_static", "log", "parking_lot 0.10.2", - "pin-project", + "pin-project 0.4.28", "rand 0.7.3", "serde", "serde_json", - "smallvec 1.4.1", + "smallvec", "soketto", "thiserror", "tokio", "unicase", - "url 2.1.1", + "url", "webpki", ] @@ -1619,23 +1928,13 @@ dependencies = [ [[package]] name = "kv-log-macro" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2d3beed37e5483887d81eb39de6de03a8346531410e1306ca48a9a89bd3a51" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ "log", ] -[[package]] -name = "kvdb" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0315ef2f688e33844400b31f11c263f2b3dc21d8b9355c6891c5f185fae43f9a" -dependencies = [ - "parity-util-mem", - "smallvec 1.4.1", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1650,6 +1949,7 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" +<<<<<<< HEAD version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" @@ -1718,14 +2018,14 @@ dependencies = [ [[package]] name = "libp2p-core-derive" version = "0.20.2" +======= +version = "0.2.94" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f753d9324cd3ec14bf04b8a8cd0d269c87f294153d6bf2a84497a63a5ad22213" -dependencies = [ - "quote", - "syn", -] +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] +<<<<<<< HEAD name = "libp2p-swarm" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1740,6 +2040,12 @@ dependencies = [ "void", "wasm-timer", ] +======= +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [[package]] name = "libsecp256k1" @@ -1752,8 +2058,13 @@ dependencies = [ "digest 0.8.1", "hmac-drbg", "rand 0.7.3", +<<<<<<< HEAD "sha2 0.8.1", "subtle 2.2.2", +======= + "sha2 0.8.2", + "subtle 2.4.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "typenum", ] @@ -1779,19 +2090,26 @@ dependencies = [ [[package]] name = "lock_api" +<<<<<<< HEAD version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +======= +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", ] @@ -1806,15 +2124,19 @@ dependencies = [ "scoped-tls", "serde", "serde_json", +======= + "cfg-if 1.0.0", + "value-bag", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] -name = "lru" -version = "0.4.3" +name = "matchers" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "hashbrown 0.6.3", + "regex-automata", ] [[package]] @@ -1834,6 +2156,7 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "matrixmultiply" +<<<<<<< HEAD version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" @@ -1844,14 +2167,20 @@ dependencies = [ [[package]] name = "maybe-uninit" version = "2.0.0" +======= +version = "0.2.4" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" +dependencies = [ + "rawpointer", +] [[package]] name = "memchr" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memory-db" @@ -1860,7 +2189,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36f36ddb0b2cdc25d38babba472108798e3477f02be5165f038c5e393e50c57a" dependencies = [ "hash-db", - "hashbrown 0.8.1", + "hashbrown 0.8.2", "parity-util-mem", ] @@ -1872,9 +2201,9 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merlin" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" dependencies = [ "byteorder", "keccak", @@ -1883,6 +2212,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "meval" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1890,13 +2220,22 @@ checksum = "f79496a5651c8d57cd033c5add8ca7ee4e3d5f7587a4777484640d9cb60392d9" dependencies = [ "fnv", "nom", +======= +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg 1.0.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ "cfg-if 0.1.10", "fuchsia-zircon", @@ -1913,9 +2252,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1924,6 +2263,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "multihash" version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1956,6 +2296,22 @@ dependencies = [ "pin-project", "smallvec 1.4.1", "unsigned-varint 0.4.0", +======= +name = "nalgebra" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" +dependencies = [ + "alga", + "approx", + "generic-array 0.12.4", + "matrixmultiply", + "num-complex", + "num-rational", + "num-traits", + "rand 0.6.5", + "typenum", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -1977,13 +2333,13 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.34" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -2004,7 +2360,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "num-integer", "num-traits", ] @@ -2015,17 +2371,21 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ +<<<<<<< HEAD "autocfg 1.0.0", +======= + "autocfg 1.0.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "num-traits", ] [[package]] name = "num-integer" -version = "0.1.42" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "num-traits", ] @@ -2035,7 +2395,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "num-bigint", "num-integer", "num-traits", @@ -2043,11 +2403,15 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ +<<<<<<< HEAD "autocfg 1.0.0", +======= + "autocfg 1.0.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libm", ] @@ -2063,17 +2427,17 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" [[package]] name = "once_cell" -version = "1.3.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" dependencies = [ - "parking_lot 0.9.0", + "parking_lot 0.11.1", ] [[package]] @@ -2094,10 +2458,27 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", +] + +[[package]] +name = "pallet-authorship" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b04a80b2d09fcaacaea6190926012348df6ddb225690de098cb8c4cf3fd19b" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec 1.3.7", + "sp-authorship", + "sp-inherents", + "sp-runtime", + "sp-std", ] [[package]] +<<<<<<< HEAD name = "pallet-authorship" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2109,11 +2490,26 @@ dependencies = [ "parity-scale-codec", "sp-authorship", "sp-inherents", +======= +name = "pallet-indices" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f204e45af958dd3bd8fe0e884a00c30fa745b653cc8ed7fe33f9f8db536fd58e" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec 1.3.7", + "serde", + "sp-core", + "sp-io", + "sp-keyring", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-runtime", "sp-std", ] [[package]] +<<<<<<< HEAD name = "pallet-im-online" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2222,30 +2618,127 @@ dependencies = [ "data-encoding", "multihash", "percent-encoding 2.1.0", +======= +name = "pallet-session" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d239080d33f284a388b8510ffff3d08452314515e122c2f979d8989578e638aa" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-timestamp", + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-staking" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def1b8639275c25dd621ae68a18c25d14f14992031c360eff98dd6a1d0095213" +dependencies = [ + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec 1.3.7", "serde", + "sp-application-crypto", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", "static_assertions", +<<<<<<< HEAD "unsigned-varint 0.5.1", "url 2.1.1", +======= +] + +[[package]] +name = "pallet-timestamp" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e206c754d6cd6d8e6e79ba2ea1a55f72af68be106e7d725d367c11c52c96da32" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec 1.3.7", + "serde", + "sp-inherents", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "parity-scale-codec" +version = "1.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" +dependencies = [ + "arrayvec 0.5.2", + "bitvec 0.17.4", + "byte-slice-cast 0.3.5", + "parity-scale-codec-derive 1.2.3", + "serde", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "parity-scale-codec" +<<<<<<< HEAD version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c740e5fbcb6847058b40ac7e5574766c6388f585e184d769910fe0d3a2ca861" +======= +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0f518afaa5a47d0d6386229b0a6e01e86427291d643aa4cabb4992219f504f8" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", + "arrayvec 0.7.0", + "bitvec 0.20.4", + "byte-slice-cast 1.0.0", + "parity-scale-codec-derive 2.1.0", "serde", ] [[package]] name = "parity-scale-codec-derive" +<<<<<<< HEAD version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "198db82bb1c18fc00176004462dd809b2a6d851669550aa17af6dacd21ae0c14" +======= +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41512944b1faff334a5f1b9447611bf4ef40638ccb6328173dacefb338e878c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f44c5f94427bd0b5076e8f7e15ca3f60a4d8ac0077e4793884e6fdfd8915344e" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2260,12 +2753,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "297ff91fa36aec49ce183484b102f6b75b46776822bd81525bfc4cc9b0dd0f5c" dependencies = [ "cfg-if 0.1.10", +<<<<<<< HEAD "hashbrown 0.8.1", +======= + "hashbrown 0.8.2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "impl-trait-for-tuples", "parity-util-mem-derive", "parking_lot 0.10.2", "primitive-types", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -2285,31 +2782,47 @@ version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" +[[package]] +name = "parity-wasm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" + [[package]] name = "parking" -version = "1.0.6" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api 0.3.4", +<<<<<<< HEAD "parking_lot_core 0.6.2", "rustc_version", +======= + "parking_lot_core 0.7.2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "parking_lot" -version = "0.10.2" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ +<<<<<<< HEAD "lock_api 0.3.4", "parking_lot_core 0.7.2", +======= + "instant", + "lock_api 0.4.4", + "parking_lot_core 0.8.3", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -2325,25 +2838,29 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.6.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if 0.1.10", +<<<<<<< HEAD "cloudabi 0.0.3", +======= + "cloudabi", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", + "redox_syscall 0.1.57", + "smallvec", + "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.7.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", "cloudabi 0.0.3", "libc", @@ -2360,18 +2877,21 @@ checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" dependencies = [ "cfg-if 0.1.10", "cloudabi 0.1.0", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "instant", "libc", - "redox_syscall", - "smallvec 1.4.1", - "winapi 0.3.8", + "redox_syscall 0.2.8", + "smallvec", + "winapi 0.3.9", ] [[package]] name = "paste" -version = "0.1.12" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a229b1c58c692edcaa5b9b0948084f130f55d2dcc15b02fcc5340b2b4521476" +checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" dependencies = [ "paste-impl", "proc-macro-hack", @@ -2379,14 +2899,11 @@ dependencies = [ [[package]] name = "paste-impl" -version = "0.1.12" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0bf239e447e67ff6d16a8bb5e4d4bd2343acf5066061c0e8e06ac5ba8ca68c" +checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" dependencies = [ "proc-macro-hack", - "proc-macro2", - "quote", - "syn", ] [[package]] @@ -2399,12 +2916,6 @@ dependencies = [ "crypto-mac 0.7.0", ] -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - [[package]] name = "percent-encoding" version = "2.1.0" @@ -2412,29 +2923,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] -name = "petgraph" -version = "0.5.1" +name = "pin-project" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" dependencies = [ - "fixedbitset", - "indexmap", + "pin-project-internal 0.4.28", ] [[package]] name = "pin-project" -version = "0.4.22" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" +dependencies = [ + "pin-project-internal 1.0.7", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" dependencies = [ - "pin-project-internal", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "pin-project-internal" -version = "0.4.22" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" dependencies = [ "proc-macro2", "quote", @@ -2443,9 +2964,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.5" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] +name = "pin-project-lite" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7505eeebd78492e0f6108f7171c4948dbb120ee8119d9d77d0afa5469bef67f" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pin-utils" @@ -2454,34 +2981,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "podio" -version = "0.1.6" +name = "platforms" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989d43012e2ca1c4a02507c67282691a0a3207f9dc67cec596b43fe925b3d325" + +[[package]] +name = "polling" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" +checksum = "4fc12d774e799ee9ebae13f4076ca003b40d18a11ac0f3641e6f899618580b7b" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-sys", + "winapi 0.3.9", +] [[package]] name = "ppv-lite86" -version = "0.2.6" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pretty_assertions" -version = "0.6.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" +checksum = "ec0cfe1b2403f172ba0f234e500906ee0a3e493fb81092dac23ebefe129301cc" dependencies = [ +<<<<<<< HEAD "ansi_term 0.11.0", +======= + "ansi_term 0.12.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "ctor", - "difference", + "diff", "output_vt100", ] [[package]] name = "primitive-types" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55c21c64d0eaa4d7ed885d959ef2d62d9e488c27c0e02d9aa5ce6c877b7d5f8" +checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" dependencies = [ "fixed-hash", "impl-codec", @@ -2524,26 +3068,27 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.15" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ "unicode-xid", ] [[package]] +<<<<<<< HEAD name = "prometheus" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2555,22 +3100,27 @@ dependencies = [ "parking_lot 0.11.0", "regex", "thiserror", +======= +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] -name = "prost" -version = "0.6.1" +name = "radium" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" -dependencies = [ - "bytes", - "prost-derive", -] +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" [[package]] -name = "prost-build" -version = "0.6.1" +name = "radium" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +<<<<<<< HEAD checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" dependencies = [ "bytes", @@ -2584,57 +3134,83 @@ dependencies = [ "tempfile", "which", ] +======= +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [[package]] -name = "prost-derive" -version = "0.6.1" +name = "rand" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" dependencies = [ +<<<<<<< HEAD "anyhow", "itertools", "proc-macro2", "quote", "syn", +======= + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi 0.3.9", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] -name = "prost-types" -version = "0.6.1" +name = "rand" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "bytes", - "prost", + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg 0.1.2", + "rand_xorshift", + "winapi 0.3.9", ] [[package]] +<<<<<<< HEAD name = "pwasm-utils" version = "0.12.0" +======= +name = "rand" +version = "0.7.3" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "byteorder", - "log", - "parity-wasm", + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", + "rand_pcg 0.2.1", ] [[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "1.0.7" +name = "rand" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ - "proc-macro2", + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", ] [[package]] +<<<<<<< HEAD name = "radium" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2670,14 +3246,24 @@ dependencies = [ "rand_pcg 0.1.2", "rand_xorshift", "winapi 0.3.8", +======= +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] -name = "rand" -version = "0.7.3" +name = "rand_chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ +<<<<<<< HEAD "getrandom", "libc", "rand_chacha 0.2.2", @@ -2694,16 +3280,20 @@ checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ "autocfg 0.1.7", "rand_core 0.3.1", +======= + "ppv-lite86", + "rand_core 0.5.1", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", + "rand_core 0.6.2", ] [[package]] @@ -2727,7 +3317,25 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.3", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", ] [[package]] @@ -2749,6 +3357,18 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD +======= +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", +] + +[[package]] +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "rand_isaac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2765,7 +3385,11 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", +<<<<<<< HEAD "winapi 0.3.8", +======= + "winapi 0.3.9", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -2774,12 +3398,20 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ +<<<<<<< HEAD "cloudabi 0.0.3", +======= + "cloudabi", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "fuchsia-cprng", "libc", "rand_core 0.4.2", "rdrand", +<<<<<<< HEAD "winapi 0.3.8", +======= + "winapi 0.3.9", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ] [[package]] @@ -2827,24 +3459,33 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +dependencies = [ + "bitflags", +] [[package]] name = "ref-cast" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a214c7875e1b63fc1618db7c80efc0954f6156c9ff07699fd9039e255accdd1" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eb59cda66fcb9aec25841fb76bc01d2b34282dcdd705028da297db6f3eec8" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" dependencies = [ "proc-macro2", "quote", @@ -2853,19 +3494,19 @@ dependencies = [ [[package]] name = "regex" -version = "1.3.7" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] name = "regex-automata" version = "0.1.9" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" dependencies = [ @@ -2876,23 +3517,38 @@ dependencies = [ [[package]] name = "regex-syntax" version = "0.6.17" +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] + +[[package]] +<<<<<<< HEAD +======= +name = "regex-syntax" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "remove_dir_all" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "ring" -version = "0.16.13" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", @@ -2900,14 +3556,14 @@ dependencies = [ "spin", "untrusted", "web-sys", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" [[package]] name = "rustc-hash" @@ -2923,11 +3579,11 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 0.9.0", + "semver", ] [[package]] @@ -2943,22 +3599,11 @@ dependencies = [ "webpki", ] -[[package]] -name = "rw-stream-sink" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" -dependencies = [ - "futures 0.3.5", - "pin-project", - "static_assertions", -] - [[package]] name = "ryu" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "same-file" @@ -2970,6 +3615,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "sc-rpc-api" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2995,29 +3641,30 @@ dependencies = [ ] [[package]] +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "schnorrkel" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ "arrayref", - "arrayvec 0.5.1", - "curve25519-dalek", - "getrandom", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.2", + "getrandom 0.1.16", "merlin", "rand 0.7.3", "rand_core 0.5.1", +<<<<<<< HEAD "sha2 0.8.1", "subtle 2.2.2", +======= + "sha2 0.8.2", + "subtle 2.4.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "zeroize", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -3026,9 +3673,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sct" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ "ring", "untrusted", @@ -3045,56 +3692,39 @@ dependencies = [ [[package]] name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", - "serde", -] - -[[package]] -name = "semver" -version = "0.10.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394cec28fa623e00903caf7ba4fa6fb9a0e260280bb8cdbbba029611108a0190" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" dependencies = [ - "semver-parser", "serde", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "send_wrapper" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" - -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" +<<<<<<< HEAD version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +======= +version = "1.0.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" +<<<<<<< HEAD version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +======= +version = "1.0.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro2", "quote", @@ -3103,9 +3733,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.57" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -3113,6 +3743,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "sha-1" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3126,6 +3757,8 @@ dependencies = [ ] [[package]] +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "sha1" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3133,14 +3766,15 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", "opaque-debug 0.2.3", +<<<<<<< HEAD ] [[package]] @@ -3176,66 +3810,73 @@ checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" dependencies = [ "lazy_static", "loom", +======= ] [[package]] -name = "signature" -version = "1.2.2" +name = "sha2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 +] [[package]] -name = "slab" -version = "0.4.2" +name = "sharded-slab" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" +dependencies = [ + "lazy_static", +] [[package]] -name = "smallvec" -version = "0.6.13" +name = "signature" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" + +[[package]] +name = "slab" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] name = "smallvec" -version = "1.4.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] -name = "smol" -version = "0.1.18" +name = "socket2" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "async-task", - "blocking", - "concurrent-queue", - "fastrand", - "futures-io", - "futures-util", + "cfg-if 1.0.0", "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2", - "wepoll-sys-stjepang", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "socket2" -version = "0.3.12" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libc", - "redox_syscall", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -3245,26 +3886,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" dependencies = [ "base64 0.11.0", - "bytes", - "futures 0.3.5", + "bytes 0.5.6", + "futures", "http", "httparse", "log", "rand 0.7.3", "sha1", - "smallvec 1.4.1", + "smallvec", "static_assertions", "thiserror", ] [[package]] name = "sp-api" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953a3296335d9761311763dbe6855109ea4bea915e27cf5633d8b01057898302" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8496732f255ef290eee6d438ebd0ecdbfe31ec8246e31870a4faf44df76b6280" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "hash-db", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "sp-api-proc-macro", "sp-core", "sp-runtime", @@ -3275,9 +3922,15 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8247ca24a2a881af2ac675c8ec33584944965d6d45645bbec16fe327ce42dce6" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c863d32b9e36849f2fc76efad959924561b2fcb15b3abdebb3d3f48a94074a00" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -3288,15 +3941,22 @@ dependencies = [ [[package]] name = "sp-application-crypto" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "885eca124aa6ce0bba57c08bc48c4357096996d630a77f572580ef8e2e4df034" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda2660cca492b58328d6a057bf5ba6c8a58e9f6e079a2f603b623d030300841" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "parity-scale-codec", + "parity-scale-codec 1.3.7", "serde", "sp-core", "sp-io", "sp-std", +<<<<<<< HEAD ] [[package]] @@ -3374,12 +4034,26 @@ name = "sp-chain-spec" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "150ce7661d02d4d0509a4a8364ab3b71a5ef2faf3f97d22d4b76bc0786d9e28b" +======= +] + +[[package]] +name = "sp-arithmetic" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c4d204b1cf8e1d4826804ffbd2edd2c4df385ee3046fa4581f09bc18977ea89" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec 1.3.7", "serde", - "serde_json", + "sp-debug-derive", + "sp-std", ] [[package]] +<<<<<<< HEAD name = "sp-consensus" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3395,15 +4069,17 @@ dependencies = [ "serde", "sp-api", "sp-core", +======= +name = "sp-authorship" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c99612989f07a55a160b1d041cac74c9089f97b3d0e0244cdde4ed3e00560ff" +dependencies = [ + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-inherents", "sp-runtime", - "sp-state-machine", "sp-std", - "sp-trie", - "sp-utils", - "sp-version", - "substrate-prometheus-endpoint", - "wasm-timer", ] [[package]] @@ -3451,9 +4127,15 @@ dependencies = [ [[package]] name = "sp-core" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e92ac5c674ee2cd9219d084301b4cbb82b28a94a0f3087bf4bea0ef3067ebb5c" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1b8a5031e866ebee7535446915c83e8f676c68dcc8555f0c0f149ff4b48035" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "base58", "blake2-rfc", @@ -3461,7 +4143,7 @@ dependencies = [ "derive_more", "dyn-clonable", "ed25519-dalek", - "futures 0.3.5", + "futures", "hash-db", "hash256-std-hasher", "hex", @@ -3471,7 +4153,7 @@ dependencies = [ "log", "merlin", "num-traits", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "parity-util-mem", "parking_lot 0.10.2", "primitive-types", @@ -3480,7 +4162,11 @@ dependencies = [ "schnorrkel", "secrecy", "serde", +<<<<<<< HEAD "sha2 0.8.1", +======= + "sha2 0.8.2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-debug-derive", "sp-externalities", "sp-runtime-interface", @@ -3495,6 +4181,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "sp-database" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3509,6 +4196,12 @@ name = "sp-debug-derive" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a3750b084e0f4677f6e834a974f30b1ba97fc2fe00185c9d03611a2228446dc" +======= +name = "sp-debug-derive" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558a1a24f2feab950ce382923b62879f253207c6cbf7832eb1e47dba5f57fba8" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro2", "quote", @@ -3517,12 +4210,18 @@ dependencies = [ [[package]] name = "sp-externalities" +<<<<<<< HEAD version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d87fcd0e0fc5e025459cfe769803488d4894e36d0f8cef80b5239d2e7ef6580" +======= +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144c39acb7affd7a9ce478e289157b9a6c225e3f08a7d4d2f4fee85cc3899684" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "environmental", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "sp-std", "sp-storage", ] @@ -3546,12 +4245,18 @@ dependencies = [ [[package]] name = "sp-inherents" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "365e5aee23640631e63e8634f1d804e33c8fcb521f4052910f29abaa2df1c1cf" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebcf5925a850392cb044af9b8da20dc0610e613ff15607b3b96bed6461f9193" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "derive_more", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "parking_lot 0.10.2", "sp-core", "sp-std", @@ -3559,15 +4264,21 @@ dependencies = [ [[package]] name = "sp-io" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e1dee9244eb6cba1bef9b3a4ec288185e1380e455f1fd348b60252592c1cf0" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffbebdeacf0a313ac65e043c37e37d98b48ea75cd1e8ab9ba40a925fecb616b" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "futures 0.3.5", + "futures", "hash-db", "libsecp256k1", "log", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "parking_lot 0.10.2", "sp-core", "sp-externalities", @@ -3583,9 +4294,15 @@ dependencies = [ [[package]] name = "sp-keyring" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f76feeb27b218d58523931ea2d708b622c3bd96a3be1c3a5895bba0f7a54c13" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9741dcf007b33496e1add259fae40d59cfe64847bf992d2605edcecd8ae6d0c2" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "lazy_static", "sp-core", @@ -3595,11 +4312,19 @@ dependencies = [ [[package]] name = "sp-npos-elections" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54bb6d3d49dccf6ee26586a29ce8aabade8e102e51ed5009660ef7abb973eb7d" dependencies = [ "parity-scale-codec", +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404f9b99ff38395d48bf2f041096fc5dbc1b892a8c314314c7bf66a0dfb5622c" +dependencies = [ + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "serde", "sp-arithmetic", "sp-npos-elections-compact", @@ -3608,9 +4333,15 @@ dependencies = [ [[package]] name = "sp-npos-elections-compact" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d784c5576824b0ffa4cb359b7eebfd87511c49685b170b8214aabaa5f2454c87" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ac5b8443203fbc6472f08f376b3b09307dc3ae1b0c1a91776a3b934f1314ce" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3620,9 +4351,15 @@ dependencies = [ [[package]] name = "sp-panic-handler" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "492126eb766b3b6740e4e4929d6527d37708598b7296a664f3680c0f0c1fc573" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1055031d4994705cd9eca38602fea1ed88f6916c0979f85352c3d540baedb2e8" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "backtrace", "log", @@ -3630,9 +4367,15 @@ dependencies = [ [[package]] name = "sp-rpc" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5c6678f4b42421e6dcdf3896a0c81a403c29ef1cf8d74b046d59125d40da911" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009f2b8ae311ff2c5f319e545492f26a3954fc84f477f85e2c3dd49fde605cf9" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "serde", "sp-core", @@ -3640,15 +4383,21 @@ dependencies = [ [[package]] name = "sp-runtime" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62542f8ce9d5fcb43a4dd3c3a53326d33aacf9b0bc9d353d6fe9fd5ff3031747" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85d8d12cba8cb9c50d8c0eee517d74044c22faa9322260e88dccb5bd06bf0762" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "either", "hash256-std-hasher", "impl-trait-for-tuples", "log", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "parity-util-mem", "paste", "rand 0.7.3", @@ -3663,11 +4412,17 @@ dependencies = [ [[package]] name = "sp-runtime-interface" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7e363c480cc8c9019b84f85d10c0b56a184079d5d840d2d1d55087ad835dc6" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb6574401a7b5c89111b417efecbc9f0c3d38c2c539ce3a964b8393769c3e15" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "parity-scale-codec", + "parity-scale-codec 1.3.7", "primitive-types", "sp-externalities", "sp-runtime-interface-proc-macro", @@ -3680,9 +4435,15 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85cf56a38544293e54dbe0aa7b6aed1e046bfc704b6fc3de7255897dca98ccb1" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d724b1feca629bf958dc0db0453225e59d9b2098fe5a47f86cd964cbc116d89d" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "Inflector", "proc-macro-crate", @@ -3693,11 +4454,19 @@ dependencies = [ [[package]] name = "sp-session" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d138b1f548933003feaa967de49ed87066643073bcc41be45ef2daaa0991c133" dependencies = [ "parity-scale-codec", +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "242e7e9069cfd163b6ceb22c2d1aba7a09144ac8360f07270739ca7917520b69" +dependencies = [ + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-api", "sp-core", "sp-runtime", @@ -3707,28 +4476,42 @@ dependencies = [ [[package]] name = "sp-staking" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b06f9839d8b4312486626bde31d6cd7763dd9b7d93ea9e70c01ca30f0998032" dependencies = [ "parity-scale-codec", +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6abfd1a33f36879117b5f511ac066e265258028d1190088be89924794967f395" +dependencies = [ + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-runtime", "sp-std", ] [[package]] name = "sp-state-machine" +<<<<<<< HEAD version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f58335de98bca196683a8ef22195a8a43b457b8bc705dba3124138ffc2ee720" +======= +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "095a8c33f70151e561c53fdaca23ad19cc059088807a25be0d60d04fb2ededea" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "hash-db", "log", "num-traits", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "parking_lot 0.10.2", "rand 0.7.3", - "smallvec 1.4.1", + "smallvec", "sp-core", "sp-externalities", "sp-panic-handler", @@ -3740,6 +4523,7 @@ dependencies = [ [[package]] name = "sp-std" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa2d6e166cead2d3b1d3d8fe0e787d076b7d0296b1760a0d7d340846d0ba42c5" @@ -3752,6 +4536,20 @@ checksum = "0f4625e6f8f40995939560f48f89028f658b7929657c68d01c571c81ab5619ff" dependencies = [ "impl-serde", "parity-scale-codec", +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2585fb8f5f4fde53c2f9ccebac4517da4dc435373a8fcaf5db7f54b798da66c2" + +[[package]] +name = "sp-storage" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781cc04c8d61c7bb1c269ca68d5d001fcaafbca8a21af46f87bf2e79a749c295" +dependencies = [ + "impl-serde", + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "ref-cast", "serde", "sp-debug-derive", @@ -3760,6 +4558,7 @@ dependencies = [ [[package]] name = "sp-timestamp" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cb398f0a5d2798ad4e02450b3089534547b448d22ebe6f3b2c03f74170f58d1" @@ -3792,26 +4591,50 @@ name = "sp-transaction-pool" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83b34ee48341c17c6e2f1e55f6076918f46b0c4505a99ad69ab1edda8b45bbd8" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d86fb8fd203faa146ba06b0d88c60f9bcb4c1dcbe49f64e36d4038893018536" dependencies = [ - "derive_more", - "futures 0.3.5", - "log", - "parity-scale-codec", - "serde", + "impl-trait-for-tuples", + "parity-scale-codec 1.3.7", "sp-api", - "sp-blockchain", + "sp-inherents", "sp-runtime", + "sp-std", + "wasm-timer", +] + +[[package]] +name = "sp-tracing" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c574a06ac032f3c6fc29ae61ae1292546499342219c256098914f6110312f6f4" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 +dependencies = [ + "log", + "parity-scale-codec 1.3.7", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", ] [[package]] name = "sp-trie" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3aae57c8ae81ba978503137a8c625d2963eb425dd90dec0d96b4ed18d8bfd55" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "311f320e1a1d6d961664af519d343d7a0493d9fe2f81dc3de488841e4fbaaa46" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "hash-db", "memory-db", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "sp-core", "sp-std", "trie-db", @@ -3819,6 +4642,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "sp-utils" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3839,6 +4663,15 @@ checksum = "21935199c8765f0d02facc718f9c83149a70ea684fb03612e5161c682b38a301" dependencies = [ "impl-serde", "parity-scale-codec", +======= +name = "sp-version" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d5fb7fa5f747a7d1b1854a1b69b813a9df6425ab0f0a9876cbddea8c6b9ab34" +dependencies = [ + "impl-serde", + "parity-scale-codec 1.3.7", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "serde", "sp-runtime", "sp-std", @@ -3846,12 +4679,18 @@ dependencies = [ [[package]] name = "sp-wasm-interface" +<<<<<<< HEAD version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1c28225e8b7ec7e260f8b46443f8731abda206334cb75c740d2407693f38167" +======= +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "554daa08d61bb3bf2d81ac79b7ae089733339fc8fdc129dc21d074195f1219be" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "impl-trait-for-tuples", - "parity-scale-codec", + "parity-scale-codec 1.3.7", "sp-std", "wasmi", ] @@ -3885,9 +4724,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.14" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef" +checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" dependencies = [ "clap", "lazy_static", @@ -3896,9 +4735,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.7" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a" +checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" dependencies = [ "heck", "proc-macro-error", @@ -3937,33 +4776,44 @@ dependencies = [ "hmac", "pbkdf2", "schnorrkel", +<<<<<<< HEAD "sha2 0.8.1", +======= + "sha2 0.8.2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "zeroize", ] [[package]] +<<<<<<< HEAD name = "substrate-prometheus-endpoint" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3e361741d066bfc29554b9f1bc8e4ac927eb4bd33dd8bb0486969edd8b0b5a" +======= +name = "substrate-build-script-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd540ba72520174c2c73ce96bf507eeba3cc8a481f58be92525b69110e1fa645" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ - "async-std", - "derive_more", - "futures-util", - "hyper", - "log", - "prometheus", - "tokio", + "platforms", ] [[package]] name = "substrate-subxt" +<<<<<<< HEAD version = "0.12.0" source = "git+https://github.com/MaciejBaj/substrate-subxt?branch=development#632da8964b7930de786b2301d397a222b17574ec" +======= +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7745e786bcfe0223008d20a3a9d61c7b80b9651d19180e835a377a19c007845e" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "frame-metadata", "frame-support", - "futures 0.3.5", + "futures", "hex", "jsonrpsee", "log", @@ -3971,6 +4821,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-staking", +<<<<<<< HEAD "parity-scale-codec", "sc-rpc-api", "serde", @@ -3978,22 +4829,37 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-consensus-babe", +======= + "parity-scale-codec 1.3.7", + "serde", + "serde_json", + "sp-application-crypto", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-core", "sp-finality-grandpa", "sp-rpc", "sp-runtime", "sp-std", +<<<<<<< HEAD "sp-transaction-pool", +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "sp-version", "substrate-subxt-proc-macro", "thiserror", - "url 2.1.1", + "url", ] [[package]] name = "substrate-subxt-proc-macro" +<<<<<<< HEAD version = "0.12.0" source = "git+https://github.com/MaciejBaj/substrate-subxt?branch=development#632da8964b7930de786b2301d397a222b17574ec" +======= +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d47ddc15af08feb25287ba1eea618773192d9e9b28eef6ce615f51cf342fd147" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "heck", "proc-macro-crate", @@ -4012,15 +4878,21 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.2.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" +<<<<<<< HEAD version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" +======= +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "proc-macro2", "quote", @@ -4040,24 +4912,37 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD +======= +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.8", "remove_dir_all", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] @@ -4073,18 +4958,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" dependencies = [ "proc-macro2", "quote", @@ -4093,21 +4978,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.43" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "libc", - "winapi 0.3.8", + "once_cell", ] [[package]] @@ -4122,7 +4997,11 @@ dependencies = [ "pbkdf2", "rand 0.7.3", "rustc-hash", +<<<<<<< HEAD "sha2 0.8.1", +======= + "sha2 0.8.2", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "unicode-normalization", ] @@ -4135,20 +5014,35 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "tokio" -version = "0.2.20" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c1d570eb1a36f0345a5ce9c6c6e665b70b73d11236912c0b477616aeec47b1" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "iovec", "lazy_static", "memchr", "mio", - "pin-project-lite", + "pin-project-lite 0.1.12", "slab", ] @@ -4158,31 +5052,32 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.1.12", "tokio", ] [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" +<<<<<<< HEAD version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" @@ -4190,10 +5085,20 @@ dependencies = [ "cfg-if 0.1.10", "pin-project-lite", "tracing-attributes", +======= +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite 0.2.6", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "tracing-core", ] [[package]] +<<<<<<< HEAD name = "tracing-attributes" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4209,15 +5114,39 @@ name = "tracing-core" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +======= +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project 1.0.7", + "tracing", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 +] + [[package]] name = "tracing-log" +<<<<<<< HEAD version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +======= +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "lazy_static", "log", @@ -4236,9 +5165,15 @@ dependencies = [ [[package]] name = "tracing-subscriber" +<<<<<<< HEAD version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +======= +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa5553bf0883ba7c9cbe493b085c29926bd41b66afc31ff72cf17ff4fb60dcd5" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 dependencies = [ "ansi_term 0.12.1", "chrono", @@ -4248,7 +5183,11 @@ dependencies = [ "serde", "serde_json", "sharded-slab", +<<<<<<< HEAD "smallvec 1.4.1", +======= + "smallvec", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "thread_local", "tracing", "tracing-core", @@ -4258,15 +5197,15 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.22.1" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e55f7ace33d6237e14137e386f4e1672e2a5c6bbc97fef9f438581a143971f0" +checksum = "ec051edf7f0fc9499a2cb0947652cab2148b9d7f61cee7605e312e9f970dacaf" dependencies = [ "hash-db", - "hashbrown 0.8.1", + "hashbrown 0.9.1", "log", "rustc-hex", - "smallvec 1.4.1", + "smallvec", ] [[package]] @@ -4280,30 +5219,32 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "twox-hash" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" +checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" dependencies = [ + "cfg-if 0.1.10", "rand 0.7.3", + "static_assertions", ] [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "uint" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173cd16430c206dc1a430af8a89a0e9c076cf15cb42b4aedb10e8cc8fee73681" +checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" dependencies = [ "byteorder", "crunchy", @@ -4322,36 +5263,37 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" dependencies = [ "matches", ] [[package]] name = "unicode-normalization" -version = "0.1.12" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" dependencies = [ - "smallvec 1.4.1", + "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" +<<<<<<< HEAD version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" @@ -4367,6 +5309,11 @@ name = "unsigned-varint" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" +======= +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [[package]] name = "untrusted" @@ -4376,25 +5323,25 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "1.7.2" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ - "idna 0.1.5", + "form_urlencoded", + "idna", "matches", - "percent-encoding 1.0.1", + "percent-encoding", + "serde", ] [[package]] -name = "url" -version = "2.1.1" +name = "value-bag" +version = "1.0.0-alpha.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "dd320e1520f94261153e96f7534476ad869c14022aee1e59af7c778075d840ae" dependencies = [ - "idna 0.2.0", - "matches", - "percent-encoding 2.1.0", - "serde", + "ctor", + "version_check", ] [[package]] @@ -4405,15 +5352,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" - -[[package]] -name = "void" -version = "1.0.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wabt" @@ -4440,18 +5381,18 @@ dependencies = [ [[package]] name = "waker-fn" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9571542c2ce85ce642e6b58b3364da2fb53526360dfb7c211add4f5c23105ff7" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi 0.3.8", + "winapi 0.3.9", "winapi-util", ] @@ -4471,21 +5412,31 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasm-bindgen" -version = "0.2.62" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.62" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" dependencies = [ "bumpalo", "lazy_static", @@ -4498,11 +5449,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.12" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a369c5e1dfb7569e14d62af4da642a3cbc2f9a3652fe586e26ac22222aa4b04" +checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" dependencies = [ +<<<<<<< HEAD "cfg-if 0.1.10", +======= + "cfg-if 1.0.0", +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 "js-sys", "wasm-bindgen", "web-sys", @@ -4510,9 +5465,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.62" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4520,9 +5475,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.62" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" dependencies = [ "proc-macro2", "quote", @@ -4533,21 +5488,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.62" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" [[package]] name = "wasm-timer" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324c5e65a08699c9c4334ba136597ab22b85dccd4b65dd1e36ccf8f723a95b54" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.5", + "futures", "js-sys", - "parking_lot 0.9.0", + "parking_lot 0.11.1", "pin-utils", - "send_wrapper 0.2.0", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -4563,7 +5517,7 @@ dependencies = [ "memory_units", "num-rational", "num-traits", - "parity-wasm", + "parity-wasm 0.41.0", "wasmi-validation", ] @@ -4573,7 +5527,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" dependencies = [ - "parity-wasm", + "parity-wasm 0.41.0", ] [[package]] @@ -4596,9 +5550,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.39" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" dependencies = [ "js-sys", "wasm-bindgen", @@ -4606,9 +5560,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -4624,21 +5578,22 @@ dependencies = [ ] [[package]] -name = "wepoll-sys-stjepang" -version = "1.0.6" +name = "wepoll-sys" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694" +checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff" dependencies = [ "cc", ] [[package]] name = "which" -version = "3.1.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" dependencies = [ - "failure", + "either", + "lazy_static", "libc", ] @@ -4650,9 +5605,9 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -4676,7 +5631,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -4695,20 +5650,26 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" +checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" dependencies = [ "proc-macro2", "quote", @@ -4718,10 +5679,11 @@ dependencies = [ [[package]] name = "zip" -version = "0.5.5" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df134e83b8f0f8153a094c7b0fd79dfebe437f1d76e7715afa18ed95ebe2fd7" +checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815" dependencies = [ + "byteorder", "crc32fast", - "podio", + "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 8d67f0d97..eb531d62b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,16 @@ +[workspace] +members = [".", "metadata"] + [package] +<<<<<<< HEAD name = "cargo-t3rn-contract" version = "0.4.1" authors = ["Parity Technologies ", "Maciej Baj "] +======= +name = "cargo-contract" +version = "0.14.0" +authors = ["Parity Technologies "] +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 build = "build.rs" edition = "2018" @@ -13,9 +22,10 @@ homepage = "https://www.parity.io/" description = "Setup and deployment tool for developing Wasm based smart contracts via ink!" keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] categories = ["command-line-utilities", "development-tools::build-utils", "development-tools::cargo-plugins"] -include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE", "build.rs", "template"] +include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE", "build.rs", "templates"] [dependencies] +<<<<<<< HEAD env_logger = "0.7.1" anyhow = "1.0.26" structopt = "0.3.9" @@ -49,15 +59,57 @@ futures = { version = "0.3.2", optional = true } hex = { version = "0.4.0", optional = true } meval = "0.2" regex = "1" +======= +env_logger = "0.9.0" +anyhow = "1.0.44" +structopt = "0.3.23" +log = "0.4.14" +heck = "0.3.3" +zip = { version = "0.5.13", default-features = false } +parity-wasm = "0.42.2" +cargo_metadata = "0.14.0" +codec = { package = "parity-scale-codec", version = "2.1", features = ["derive"] } +which = "4.2.2" +colored = "2.0.0" +toml = "0.5.8" +rustc_version = "0.4.0" +blake2 = "0.9.2" +contract-metadata = { version = "0.3.0", path = "./metadata" } +semver = { version = "1.0.4", features = ["serde"] } +serde = { version = "1.0.130", default-features = false, features = ["derive"] } +serde_json = "1.0.68" +tempfile = "3.2.0" +url = { version = "2.2.2", features = ["serde"] } +impl-serde = "0.3.1" +regex = "1.4" + +# dependencies for optional extrinsics feature +async-std = { version = "1.10.0", optional = true } +sp-core = { version = "2.0.1", optional = true } +subxt = { version = "0.14.0", package = "substrate-subxt", optional = true } +futures = { version = "0.3.17", optional = true } +hex = { version = "0.4.3", optional = true } + +# Should be removed once bitvecto-rs/bitvec#105 is resolved +funty = "=1.1.0" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [build-dependencies] -anyhow = "1.0" -zip = { version = "0.5.4", default-features = false } -walkdir = "2.3.1" +anyhow = "1.0.44" +zip = { version = "0.5.13", default-features = false } +walkdir = "2.3.2" +substrate-build-script-utils = "3.0.0" +platforms = "1.1" [dev-dependencies] +<<<<<<< HEAD assert_matches = "1.3.0" pretty_assertions = "0.6.1" +======= +assert_matches = "1.5.0" +pretty_assertions = "1.0.0" +wabt = "0.10.0" +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 [features] default = [] diff --git a/README.md b/README.md index 418ac87d7..58d8a181f 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,57 @@ +<<<<<<< HEAD # Cargo plugin for t3rn composable contracts +======= +
+ cargo-contract +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 -[![GitHub license](https://img.shields.io/github/license/paritytech/cargo-contract)](LICENSE) -[![GitLab Status](https://gitlab.parity.io/parity/cargo-contract/badges/master/pipeline.svg)](https://gitlab.parity.io/parity/cargo-contract/pipelines) -[![Latest Version](https://img.shields.io/crates/v/cargo-contract.svg)](https://crates.io/crates/cargo-contract) +[![CI Status][a1]][a2] +[![Matrix Chat][b1]][b2] +[![Discord Chat][c1]][c2] +[![Latest Release][d1]][d2] +[a1]: https://gitlab.parity.io/parity/cargo-contract/badges/master/pipeline.svg +[a2]: https://gitlab.parity.io/parity/cargo-contract/pipelines +[b1]: https://img.shields.io/badge/matrix-chat-brightgreen.svg?style=flat +[b2]: https://riot.im/app/#/room/#ink:matrix.parity.io +[c1]: https://img.shields.io/discord/722223075629727774?style=flat-square&label=discord +[c2]: https://discord.gg/ztCASQE +[d1]: https://img.shields.io/crates/v/cargo-contract.svg +[d2]: https://crates.io/crates/cargo-contract + +

+ +> squink, the ink! mascot`cargo-contract` is a CLI tool which helps you develop smart contracts in Parity's ink!.
ink! is a Rust [eDSL](https://wiki.haskell.org/Embedded_domain_specific_language) which allows you to write smart contracts for blockchains built on the [Substrate](https://github.com/paritytech/substrate) framework. +

+ +
+ +[Guided Tutorial for Beginners](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract)  â€¢   +[ink! Documentation Portal](https://paritytech.github.io/ink-docs) + +
+
+ +More relevant links: +* Talk to us on [Element][b2] or [Discord][c2] +* [`ink!`](https://github.com/paritytech/ink) ‒ The main ink! repository with smart contract examples +* [Canvas UI](https://paritytech.github.io/canvas-ui/#/upload) ‒ Frontend for contract deployment and interaction +* [Substrate Contracts Node](https://github.com/paritytech/substrate-contracts-node) ‒ Simple Substrate blockchain which includes smart contract functionality + +<<<<<<< HEAD A CLI tool for helping setting up and managing WebAssembly smart contracts in !ink, Solidity (_not yet! WIP._) and WebAssembly text format. Supports t3rn composable contracts. **This is a fork of [`cargo-contracts`](https://github.com/paritytech/cargo-contracts). The fork extends the smart contract languages with Solidity and WASM text format. It also adds the features of composable contract builds, deployment and execution via t3rn gateways.** +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 ## Installation -- **Prerequisites** +* Step 1: `rustup component add rust-src`. - - **rust-src**: `rustup component add rust-src` - - **wasm-opt**: https://github.com/WebAssembly/binaryen#tools +* Step 2: Install `binaryen` in a version >= 99: +<<<<<<< HEAD - **Install from source** - `cargo build --features extrinsics` - **Install from remote repo** @@ -22,10 +59,37 @@ A CLI tool for helping setting up and managing WebAssembly smart contracts in !i **You can now use the compiler as a command line tool: `cargo t3rn-contract`** +======= + * [Debian/Ubuntu](https://tracker.debian.org/pkg/binaryen): `apt-get install binaryen` + * [Homebrew](https://formulae.brew.sh/formula/binaryen): `brew install binaryen` + * [Arch Linux](https://archlinux.org/packages/community/x86_64/binaryen/): `pacman -S binaryen` + * Windows: [binary releases are available](https://github.com/WebAssembly/binaryen/releases) +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 -## Usage + There's only an old version in your distributions package manager? Just use a + [binary release](https://github.com/WebAssembly/binaryen/releases). + +* Step 3: `cargo install --force cargo-contract` + +### Installation using Docker Image + +If you prefer to use Docker instead we have a Docker image +[available on the Docker Hub](https://hub.docker.com/r/paritytech/contracts-ci-linux): + +```bash +# Pull the latest stable image. +docker pull paritytech/contracts-ci-linux:production +# Create a new contract in your current directory. +docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux:production \ + cargo +nightly contract new --target-dir /sources my_contract + +# Build the contract. This will create the contract file under +# `my_contract/target/ink/my_contract.contract`. +docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux:production \ + cargo +nightly contract build --manifest-path=/sources/my_contract/Cargo.toml ``` +<<<<<<< HEAD cargo-t3rn-contract 0.3.0 Utilities to develop Wasm smart contracts. @@ -52,26 +116,62 @@ SUBCOMMANDS: instantiate Instantiate a deployed smart contract help Prints this message or the help of the given subcommand(s) ``` +======= +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 + +If you want to reproduce other steps of CI process you can use the following +[guide](https://github.com/paritytech/scripts#reproduce-ci-locally). -## `build` requires the `nightly` toolchain +## Usage -`cargo contract build` must be run using the `nightly` toolchain. If you have -[`rustup`](https://github.com/rust-lang/rustup) installed, the simplest way to do so is `cargo +nightly contract build`. -To avoid having to add `+nightly` you can also create a `rust-toolchain` file in your local directory containing -`nightly`. Read more about how to [specify the rustup toolchain](https://github.com/rust-lang/rustup#override-precedence). +You can always use `cargo contract help` to print information on available +commands and their usage. -## Features +For each command there is also a `--help` flag with info on additional parameters, +e.g. `cargo contract new --help`. -The `deploy` and `instantiate` subcommands are **disabled by default**, since they are not fully stable yet and increase the build time. +##### `cargo contract new my_contract` -If you want to try them, you need to enable the `extrinsics` feature: +Creates an initial smart contract with some scaffolding code into a new +folder `my_contract` . +<<<<<<< HEAD `cargo install --git https://github.com/MaciejBaj/cargo-contract cargo-t3rn-contract --features extrinsics --force` +======= +The contract contains the source code for the [`Flipper`](https://github.com/paritytech/ink/blob/master/examples/flipper/lib.rs) +contract, which is about the simplest "smart" contract you can build ‒ a `bool` which gets flipped +from `true` to `false` through the `flip()` function. +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 -Once they are stable and the compilation time is acceptable, we will consider removing the `extrinsics` feature. +##### `cargo +nightly contract build` -## License +Compiles the contract into optimized WebAssembly bytecode, generates metadata for it, +and bundles both together in a `.contract` file, which you can use for +deploying the contract on-chain. + +`cargo contract build` must be run using the `nightly` toolchain. If you have +[`rustup`](https://github.com/rust-lang/rustup) installed, the simplest way to +do so is `cargo +nightly contract build`. +<<<<<<< HEAD The entire code within this repository is licensed under the [GPLv3](LICENSE). Please [contact Parity](https://www.parity.io/contact/) if you have questions about the licensing of this product. +======= +To avoid having to always add `+nightly` you can also set `nightly` as the default +toolchain of a directory by executing `rustup override set nightly` in it. + +##### `cargo contract check` + +Checks that the code builds as WebAssembly. This command does not output any `.contract` +artifact to the `target/` directory. + +##### `cargo contract test` + +Runs test suites defined for a smart contract off-chain. + +## License +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 +The entire code within this repository is licensed under the [GPLv3](LICENSE). +Please [contact us](https://www.parity.io/contact/) if you have questions about +the licensing of our products. diff --git a/build.rs b/build.rs index 2687128ee..dc79aa3f4 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -15,18 +15,23 @@ // along with cargo-contract. If not, see . use std::{ + borrow::Cow, env, ffi::OsStr, fs::File, io::{prelude::*, Write}, iter::Iterator, - path::PathBuf, + path::{Path, PathBuf}, + process::Command, }; use anyhow::Result; use walkdir::WalkDir; use zip::{write::FileOptions, CompressionMethod, ZipWriter}; +use platforms::{TARGET_ARCH, TARGET_ENV, TARGET_OS}; +use substrate_build_script_utils::rerun_if_git_head_changed; + const DEFAULT_UNIX_PERMISSIONS: u32 = 0o755; fn main() { @@ -46,6 +51,9 @@ fn main() { dst_file.display() ); + generate_cargo_keys(); + rerun_if_git_head_changed(); + std::process::exit( match zip_dir(&template_dir, &dst_file, CompressionMethod::Stored) { Ok(_) => { @@ -64,7 +72,7 @@ fn main() { ); } -fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf, method: CompressionMethod) -> Result<()> { +fn zip_dir(src_dir: &Path, dst_file: &Path, method: CompressionMethod) -> Result<()> { if !src_dir.exists() { anyhow::bail!("src_dir '{}' does not exist", src_dir.display()); } @@ -92,18 +100,71 @@ fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf, method: CompressionMethod) -> name.set_file_name("Cargo.toml"); } + let file_path = name.as_os_str().to_string_lossy(); + if path.is_file() { - zip.start_file_from_path(name.as_path(), options)?; + zip.start_file(file_path, options)?; let mut f = File::open(path)?; f.read_to_end(&mut buffer)?; zip.write_all(&*buffer)?; buffer.clear(); - } else if name.as_os_str().len() != 0 { - zip.add_directory_from_path(name.as_path(), options)?; + } else if !name.as_os_str().is_empty() { + zip.add_directory(file_path, options)?; } } zip.finish()?; Ok(()) } + +/// Generate the `cargo:` key output +fn generate_cargo_keys() { + let output = Command::new("git") + .args(&["rev-parse", "--short", "HEAD"]) + .output(); + + let commit = match output { + Ok(o) if o.status.success() => { + let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned(); + Cow::from(sha) + } + Ok(o) => { + println!("cargo:warning=Git command failed with status: {}", o.status); + Cow::from("unknown") + } + Err(err) => { + println!("cargo:warning=Failed to execute git command: {}", err); + Cow::from("unknown") + } + }; + + println!( + "cargo:rustc-env=CARGO_CONTRACT_CLI_IMPL_VERSION={}", + get_version(&commit) + ) +} + +fn get_version(impl_commit: &str) -> String { + let commit_dash = if impl_commit.is_empty() { "" } else { "-" }; + + format!( + "{}{}{}-{}", + std::env::var("CARGO_PKG_VERSION").unwrap_or_default(), + commit_dash, + impl_commit, + get_platform(), + ) +} + +fn get_platform() -> String { + let env_dash = if TARGET_ENV.is_some() { "-" } else { "" }; + + format!( + "{}-{}{}{}", + TARGET_ARCH.as_str(), + TARGET_OS.as_str(), + env_dash, + TARGET_ENV.map(|x| x.as_str()).unwrap_or(""), + ) +} diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml new file mode 100644 index 000000000..4fa06dcd6 --- /dev/null +++ b/metadata/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "contract-metadata" +version = "0.3.0" +authors = ["Parity Technologies "] +edition = "2018" + +license = "Apache-2.0" +readme = "README.md" +repository = "https://github.com/paritytech/cargo-contract" +documentation = "https://docs.rs/contract-metadata" +homepage = "https://www.substrate.io/" +description = "Library defining metadata for smart contracts on substrate" +keywords = ["parity", "blockchain"] +include = ["Cargo.toml", "*.rs", "LICENSE"] + +[lib] +path = "lib.rs" + +[dependencies] +semver = { version = "1.0.4", features = ["serde"] } +serde = { version = "1.0.130", default-features = false, features = ["derive"] } +serde_json = "1.0.68" +url = { version = "2.2.2", features = ["serde"] } + +[dev-dependencies] +pretty_assertions = "1.0.0" diff --git a/metadata/LICENSE b/metadata/LICENSE new file mode 100644 index 000000000..6b0b1270f --- /dev/null +++ b/metadata/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/metadata/README.md b/metadata/README.md new file mode 100644 index 000000000..57a396c2a --- /dev/null +++ b/metadata/README.md @@ -0,0 +1,7 @@ +# Contract Metadata + +Defines types for the extended metadata of smart contracts targeting [substrate](https://github.com/paritytech/substrate). + +Currently part of [`cargo-contract`](https://github.com/paritytech/cargo-contract), the build tool for smart + contracts written in [ink!](https://github.com/paritytech/ink). + diff --git a/metadata/lib.rs b/metadata/lib.rs new file mode 100644 index 000000000..90eebbf13 --- /dev/null +++ b/metadata/lib.rs @@ -0,0 +1,651 @@ +// Copyright 2018-2021 Parity Technologies (UK) Ltd. +// This file is part of cargo-contract. +// +// cargo-contract is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// cargo-contract is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with cargo-contract. If not, see . + +//! Type definitions for creating and serializing metadata for smart contracts targeting +//! Substrate's contracts pallet. +//! +//! # Example +//! +//! ``` +//! # use contract_metadata::*; +//! # use semver::Version; +//! # use url::Url; +//! # use serde_json::{Map, Value}; +//! +//! let language = SourceLanguage::new(Language::Ink, Version::new(2, 1, 0)); +//! let compiler = SourceCompiler::new(Compiler::RustC, Version::parse("1.46.0-nightly").unwrap()); +//! let wasm = SourceWasm::new(vec![0u8]); +//! let source = Source::new(Some(wasm), CodeHash([0u8; 32]), language, compiler); +//! let contract = Contract::builder() +//! .name("incrementer".to_string()) +//! .version(Version::new(2, 1, 0)) +//! .authors(vec!["Parity Technologies ".to_string()]) +//! .description("increment a value".to_string()) +//! .documentation(Url::parse("http://docs.rs/").unwrap()) +//! .repository(Url::parse("http://github.com/paritytech/ink/").unwrap()) +//! .homepage(Url::parse("http://example.com/").unwrap()) +//! .license("Apache-2.0".to_string()) +//! .build() +//! .unwrap(); +//! // user defined raw json +//! let user_json: Map = Map::new(); +//! let user = User::new(user_json); +//! // contract abi raw json generated by contract compilation +//! let abi_json: Map = Map::new(); +//! +//! let metadata = ContractMetadata::new(source, contract, Some(user), abi_json); +//! +//! // serialize to json +//! let json = serde_json::to_value(&metadata).unwrap(); +//! ``` + +use core::fmt::{Display, Formatter, Result as DisplayResult, Write}; +use semver::Version; +use serde::{Serialize, Serializer}; +use serde_json::{Map, Value}; +use url::Url; + +const METADATA_VERSION: &str = "0.1.0"; + +/// Smart contract metadata. +#[derive(Clone, Debug, Serialize)] +pub struct ContractMetadata { + #[serde(rename = "metadataVersion")] + metadata_version: semver::Version, + source: Source, + contract: Contract, + #[serde(skip_serializing_if = "Option::is_none")] + user: Option, + /// Raw JSON of the contract abi metadata, generated during contract compilation. + #[serde(flatten)] + abi: Map, +} + +impl ContractMetadata { + /// Construct new contract metadata. + pub fn new( + source: Source, + contract: Contract, + user: Option, + abi: Map, + ) -> Self { + let metadata_version = semver::Version::parse(METADATA_VERSION) + .expect("METADATA_VERSION is a valid semver string"); + + Self { + metadata_version, + source, + contract, + user, + abi, + } + } + + pub fn remove_source_wasm_attribute(&mut self) { + self.source.wasm = None; + } +} + +/// Representation of the Wasm code hash. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CodeHash(pub [u8; 32]); + +impl Serialize for CodeHash { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serialize_as_byte_str(&self.0[..], serializer) + } +} + +#[derive(Clone, Debug, Serialize)] +pub struct Source { + hash: CodeHash, + language: SourceLanguage, + compiler: SourceCompiler, + #[serde(skip_serializing_if = "Option::is_none")] + wasm: Option, +} + +impl Source { + /// Constructs a new InkProjectSource. + pub fn new( + wasm: Option, + hash: CodeHash, + language: SourceLanguage, + compiler: SourceCompiler, + ) -> Self { + Source { + hash, + language, + compiler, + wasm, + } + } +} + +/// The bytes of the compiled Wasm smart contract. +#[derive(Clone, Debug)] +pub struct SourceWasm { + wasm: Vec, +} + +impl SourceWasm { + /// Constructs a new `SourceWasm`. + pub fn new(wasm: Vec) -> Self { + SourceWasm { wasm } + } +} + +impl Serialize for SourceWasm { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serialize_as_byte_str(&self.wasm[..], serializer) + } +} + +impl Display for SourceWasm { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + write!(f, "0x").expect("failed writing to string"); + for byte in &self.wasm { + write!(f, "{:02x}", byte).expect("failed writing to string"); + } + write!(f, "") + } +} + +/// The language and version in which a smart contract is written. +#[derive(Clone, Debug)] +pub struct SourceLanguage { + language: Language, + version: Version, +} + +impl SourceLanguage { + /// Constructs a new SourceLanguage. + pub fn new(language: Language, version: Version) -> Self { + SourceLanguage { language, version } + } +} + +impl Serialize for SourceLanguage { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +impl Display for SourceLanguage { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + write!(f, "{} {}", self.language, self.version) + } +} + +/// The language in which the smart contract is written. +#[derive(Clone, Debug)] +pub enum Language { + Ink, + Solidity, + AssemblyScript, +} + +impl Display for Language { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + match self { + Self::Ink => write!(f, "ink!"), + Self::Solidity => write!(f, "Solidity"), + Self::AssemblyScript => write!(f, "AssemblyScript"), + } + } +} + +/// A compiler used to compile a smart contract. +#[derive(Clone, Debug)] +pub struct SourceCompiler { + compiler: Compiler, + version: Version, +} + +impl Display for SourceCompiler { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + write!(f, "{} {}", self.compiler, self.version) + } +} + +impl Serialize for SourceCompiler { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +impl SourceCompiler { + pub fn new(compiler: Compiler, version: Version) -> Self { + SourceCompiler { compiler, version } + } +} + +/// Compilers used to compile a smart contract. +#[derive(Clone, Debug, Serialize)] +pub enum Compiler { + RustC, + Solang, +} + +impl Display for Compiler { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + match self { + Self::RustC => write!(f, "rustc"), + Self::Solang => write!(f, "solang"), + } + } +} + +/// Metadata about a smart contract. +#[derive(Clone, Debug, Serialize)] +pub struct Contract { + name: String, + version: Version, + authors: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + description: Option, + #[serde(skip_serializing_if = "Option::is_none")] + documentation: Option, + #[serde(skip_serializing_if = "Option::is_none")] + repository: Option, + #[serde(skip_serializing_if = "Option::is_none")] + homepage: Option, + #[serde(skip_serializing_if = "Option::is_none")] + license: Option, +} + +impl Contract { + pub fn builder() -> ContractBuilder { + ContractBuilder::default() + } +} + +/// Additional user defined metadata, can be any valid json. +#[derive(Clone, Debug, Serialize)] +pub struct User { + #[serde(flatten)] + json: Map, +} + +impl User { + /// Constructs new user metadata. + pub fn new(json: Map) -> Self { + User { json } + } +} + +/// Builder for contract metadata +#[derive(Default)] +pub struct ContractBuilder { + name: Option, + version: Option, + authors: Option>, + description: Option, + documentation: Option, + repository: Option, + homepage: Option, + license: Option, +} + +impl ContractBuilder { + /// Set the contract name (required) + pub fn name(&mut self, name: S) -> &mut Self + where + S: AsRef, + { + if self.name.is_some() { + panic!("name has already been set") + } + self.name = Some(name.as_ref().to_string()); + self + } + + /// Set the contract version (required) + pub fn version(&mut self, version: Version) -> &mut Self { + if self.version.is_some() { + panic!("version has already been set") + } + self.version = Some(version); + self + } + + /// Set the contract version (required) + pub fn authors(&mut self, authors: I) -> &mut Self + where + I: IntoIterator, + S: AsRef, + { + if self.authors.is_some() { + panic!("authors has already been set") + } + + let authors = authors + .into_iter() + .map(|s| s.as_ref().to_string()) + .collect::>(); + + if authors.is_empty() { + panic!("must have at least one author") + } + + self.authors = Some(authors); + self + } + + /// Set the contract description (optional) + pub fn description(&mut self, description: S) -> &mut Self + where + S: AsRef, + { + if self.description.is_some() { + panic!("description has already been set") + } + self.description = Some(description.as_ref().to_string()); + self + } + + /// Set the contract documentation url (optional) + pub fn documentation(&mut self, documentation: Url) -> &mut Self { + if self.documentation.is_some() { + panic!("documentation is already set") + } + self.documentation = Some(documentation); + self + } + + /// Set the contract repository url (optional) + pub fn repository(&mut self, repository: Url) -> &mut Self { + if self.repository.is_some() { + panic!("repository is already set") + } + self.repository = Some(repository); + self + } + + /// Set the contract homepage url (optional) + pub fn homepage(&mut self, homepage: Url) -> &mut Self { + if self.homepage.is_some() { + panic!("homepage is already set") + } + self.homepage = Some(homepage); + self + } + + /// Set the contract license (optional) + pub fn license(&mut self, license: S) -> &mut Self + where + S: AsRef, + { + if self.license.is_some() { + panic!("license has already been set") + } + self.license = Some(license.as_ref().to_string()); + self + } + + /// Finalize construction of the [`ContractMetadata`]. + /// + /// Returns an `Err` if any required fields missing. + pub fn build(&self) -> Result { + let mut required = Vec::new(); + + if let (Some(name), Some(version), Some(authors)) = + (&self.name, &self.version, &self.authors) + { + Ok(Contract { + name: name.to_string(), + version: version.clone(), + authors: authors.to_vec(), + description: self.description.clone(), + documentation: self.documentation.clone(), + repository: self.repository.clone(), + homepage: self.homepage.clone(), + license: self.license.clone(), + }) + } else { + if self.name.is_none() { + required.push("name"); + } + if self.version.is_none() { + required.push("version") + } + if self.authors.is_none() { + required.push("authors") + } + Err(format!( + "Missing required non-default fields: {}", + required.join(", ") + )) + } + } +} + +/// Serializes the given bytes as byte string. +fn serialize_as_byte_str(bytes: &[u8], serializer: S) -> Result +where + S: serde::Serializer, +{ + if bytes.is_empty() { + // Return empty string without prepended `0x`. + return serializer.serialize_str(""); + } + let mut hex = String::with_capacity(bytes.len() * 2 + 2); + write!(hex, "0x").expect("failed writing to string"); + for byte in bytes { + write!(hex, "{:02x}", byte).expect("failed writing to string"); + } + serializer.serialize_str(&hex) +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + use serde_json::json; + + #[test] + fn builder_fails_with_missing_required_fields() { + let missing_name = Contract::builder() + // .name("incrementer".to_string()) + .version(Version::new(2, 1, 0)) + .authors(vec!["Parity Technologies ".to_string()]) + .build(); + + assert_eq!( + missing_name.unwrap_err(), + "Missing required non-default fields: name" + ); + + let missing_version = Contract::builder() + .name("incrementer".to_string()) + // .version(Version::new(2, 1, 0)) + .authors(vec!["Parity Technologies ".to_string()]) + .build(); + + assert_eq!( + missing_version.unwrap_err(), + "Missing required non-default fields: version" + ); + + let missing_authors = Contract::builder() + .name("incrementer".to_string()) + .version(Version::new(2, 1, 0)) + // .authors(vec!["Parity Technologies ".to_string()]) + .build(); + + assert_eq!( + missing_authors.unwrap_err(), + "Missing required non-default fields: authors" + ); + + let missing_all = Contract::builder() + // .name("incrementer".to_string()) + // .version(Version::new(2, 1, 0)) + // .authors(vec!["Parity Technologies ".to_string()]) + .build(); + + assert_eq!( + missing_all.unwrap_err(), + "Missing required non-default fields: name, version, authors" + ); + } + + #[test] + fn json_with_optional_fields() { + let language = SourceLanguage::new(Language::Ink, Version::new(2, 1, 0)); + let compiler = + SourceCompiler::new(Compiler::RustC, Version::parse("1.46.0-nightly").unwrap()); + let wasm = SourceWasm::new(vec![0u8, 1u8, 2u8]); + let source = Source::new(Some(wasm), CodeHash([0u8; 32]), language, compiler); + let contract = Contract::builder() + .name("incrementer".to_string()) + .version(Version::new(2, 1, 0)) + .authors(vec!["Parity Technologies ".to_string()]) + .description("increment a value".to_string()) + .documentation(Url::parse("http://docs.rs/").unwrap()) + .repository(Url::parse("http://github.com/paritytech/ink/").unwrap()) + .homepage(Url::parse("http://example.com/").unwrap()) + .license("Apache-2.0".to_string()) + .build() + .unwrap(); + + let user_json = json! { + { + "more-user-provided-fields": [ + "and", + "their", + "values" + ], + "some-user-provided-field": "and-its-value" + } + }; + let user = User::new(user_json.as_object().unwrap().clone()); + let abi_json = json! { + { + "spec": {}, + "storage": {}, + "types": [] + } + } + .as_object() + .unwrap() + .clone(); + + let metadata = ContractMetadata::new(source, contract, Some(user), abi_json); + let json = serde_json::to_value(&metadata).unwrap(); + + let expected = json! { + { + "metadataVersion": "0.1.0", + "source": { + "hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "language": "ink! 2.1.0", + "compiler": "rustc 1.46.0-nightly", + "wasm": "0x000102" + }, + "contract": { + "name": "incrementer", + "version": "2.1.0", + "authors": [ + "Parity Technologies " + ], + "description": "increment a value", + "documentation": "http://docs.rs/", + "repository": "http://github.com/paritytech/ink/", + "homepage": "http://example.com/", + "license": "Apache-2.0", + }, + "user": { + "more-user-provided-fields": [ + "and", + "their", + "values" + ], + "some-user-provided-field": "and-its-value" + }, + // these fields are part of the flattened raw json for the contract ABI + "spec": {}, + "storage": {}, + "types": [] + } + }; + + assert_eq!(json, expected); + } + + #[test] + fn json_excludes_optional_fields() { + let language = SourceLanguage::new(Language::Ink, Version::new(2, 1, 0)); + let compiler = + SourceCompiler::new(Compiler::RustC, Version::parse("1.46.0-nightly").unwrap()); + let source = Source::new(None, CodeHash([0u8; 32]), language, compiler); + let contract = Contract::builder() + .name("incrementer".to_string()) + .version(Version::new(2, 1, 0)) + .authors(vec!["Parity Technologies ".to_string()]) + .build() + .unwrap(); + let abi_json = json! { + { + "spec": {}, + "storage": {}, + "types": [] + } + } + .as_object() + .unwrap() + .clone(); + + let metadata = ContractMetadata::new(source, contract, None, abi_json); + let json = serde_json::to_value(&metadata).unwrap(); + + let expected = json! { + { + "metadataVersion": "0.1.0", + "source": { + "hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "language": "ink! 2.1.0", + "compiler": "rustc 1.46.0-nightly" + }, + "contract": { + "name": "incrementer", + "version": "2.1.0", + "authors": [ + "Parity Technologies " + ], + }, + // these fields are part of the flattened raw json for the contract ABI + "spec": {}, + "storage": {}, + "types": [] + } + }; + + assert_eq!(json, expected); + } +} diff --git a/scripts/pre_cache.sh b/scripts/pre_cache.sh new file mode 100755 index 000000000..d295f4031 --- /dev/null +++ b/scripts/pre_cache.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -u + +# if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME +# create such directory and +# copy recursively all the files from the newest dir which has $CI_JOB_NAME, if it exists + +# caches are in /ci-cache/${CI_PROJECT_NAME}/${2}/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME} + +function prepopulate { + if [[ ! -d $1 ]]; then + mkdir -p "$1"; + FRESH_CACHE=$(find "/ci-cache/$CI_PROJECT_NAME/$2" -mindepth 2 -maxdepth 2 \ + -type d -name "$CI_JOB_NAME" -not -path "$1" -exec stat --printf="%Y\t%n\n" {} \; \ + |sort -n -r |head -1 |cut -f2); + if [[ -d "$FRESH_CACHE" ]]; then + echo "____Using" "$FRESH_CACHE" "to prepopulate the cache____"; + time cp -rf "$FRESH_CACHE" "$1"; + else + echo "_____No such $2 dir, proceeding from scratch_____"; + fi + else + echo "____No need to prepopulate $2 cache____"; + fi +} + +# CARGO_HOME cache was moved to the same "project/cache_type/branch_name/job_name" level as +# CARGO_TARGET_DIR because of frequent weird data-race issues. This just means that the same cache that +# would have been used for the entire pipeline will be duplicated for the each job. +prepopulate "$CARGO_HOME" cargo +prepopulate "$CARGO_TARGET_DIR" targets diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 58b4e00a9..676a95d98 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -14,30 +14,206 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . -use std::{ - fs::metadata, - io::{self, Write}, - path::PathBuf, - process::Command, -}; - use crate::{ crate_metadata::CrateMetadata, - util, - workspace::{ManifestPath, Profile, Workspace}, - UnstableFlags, Verbosity, + maybe_println, util, validate_wasm, + workspace::{Manifest, ManifestPath, Profile, Workspace}, + BuildArtifacts, BuildMode, BuildResult, OptimizationPasses, OptimizationResult, OutputType, + UnstableFlags, UnstableOptions, Verbosity, VerbosityFlags, }; use anyhow::{Context, Result}; use colored::Colorize; -use parity_wasm::elements::{External, MemoryType, Module, Section}; +use parity_wasm::elements::{External, Internal, MemoryType, Module, Section}; +use regex::Regex; +use semver::Version; +use std::{ + convert::TryFrom, + ffi::OsStr, + fs::metadata, + path::{Path, PathBuf}, + process::Command, + str, +}; +use structopt::StructOpt; /// This is the maximum number of pages available for a contract to allocate. const MAX_MEMORY_PAGES: u32 = 16; -/// Builds the project in the specified directory, defaults to the current directory. +/// Arguments to use when executing `build` or `check` commands. +#[derive(Default)] +pub(crate) struct ExecuteArgs { + /// The location of the Cargo manifest (`Cargo.toml`) file to use. + pub(crate) manifest_path: ManifestPath, + verbosity: Verbosity, + build_mode: BuildMode, + build_artifact: BuildArtifacts, + unstable_flags: UnstableFlags, + optimization_passes: OptimizationPasses, + keep_debug_symbols: bool, + output_type: OutputType, +} + +/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying. +/// +/// It does so by invoking `cargo build` and then post processing the final binary. +#[derive(Debug, StructOpt)] +#[structopt(name = "build")] +pub struct BuildCommand { + /// Path to the Cargo.toml of the contract to build + #[structopt(long, parse(from_os_str))] + manifest_path: Option, + /// By default the contract is compiled with debug functionality + /// included. This enables the contract to output debug messages, + /// but increases the contract size and the amount of gas used. + /// + /// A production contract should always be build in `release` mode! + /// Then no debug functionality is compiled into the contract. + #[structopt(long = "--release")] + build_release: bool, + /// Which build artifacts to generate. + /// + /// - `all`: Generate the Wasm, the metadata and a bundled `.contract` file. + /// + /// - `code-only`: Only the Wasm is created, generation of metadata and a bundled + /// `.contract` file is skipped. + #[structopt( + long = "generate", + default_value = "all", + value_name = "all | code-only", + verbatim_doc_comment + )] + build_artifact: BuildArtifacts, + #[structopt(flatten)] + verbosity: VerbosityFlags, + #[structopt(flatten)] + unstable_options: UnstableOptions, + /// Number of optimization passes, passed as an argument to wasm-opt. + /// + /// - `0`: execute no optimization passes + /// + /// - `1`: execute 1 optimization pass (quick & useful opts, useful for iteration builds) + /// + /// - `2`, execute 2 optimization passes (most opts, generally gets most perf) + /// + /// - `3`, execute 3 optimization passes (spends potentially a lot of time optimizing) + /// + /// - `4`, execute 4 optimization passes (also flatten the IR, which can take a lot more time and memory + /// but is useful on more nested / complex / less-optimized input) + /// + /// - `s`, execute default optimization passes, focusing on code size + /// + /// - `z`, execute default optimization passes, super-focusing on code size + /// + /// - The default value is `z` + /// + /// - It is possible to define the number of optimization passes in the + /// `[package.metadata.contract]` of your `Cargo.toml` as e.g. `optimization-passes = "3"`. + /// The CLI argument always takes precedence over the profile value. + #[structopt(long)] + optimization_passes: Option, + /// Do not remove symbols (Wasm name section) when optimizing. + /// + /// This is useful if one wants to analyze or debug the optimized binary. + #[structopt(long)] + keep_debug_symbols: bool, + + /// Export the build output in JSON format. + #[structopt(long, conflicts_with = "verbose")] + output_json: bool, +} + +impl BuildCommand { + pub fn exec(&self) -> Result { + let manifest_path = ManifestPath::try_from(self.manifest_path.as_ref())?; + let unstable_flags: UnstableFlags = + TryFrom::<&UnstableOptions>::try_from(&self.unstable_options)?; + let mut verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?; + + // The CLI flag `optimization-passes` overwrites optimization passes which are + // potentially defined in the `Cargo.toml` profile. + let optimization_passes = match self.optimization_passes { + Some(opt_passes) => opt_passes, + None => { + let mut manifest = Manifest::new(manifest_path.clone())?; + match manifest.get_profile_optimization_passes() { + // if no setting is found, neither on the cli nor in the profile, + // then we use the default + None => OptimizationPasses::default(), + Some(opt_passes) => opt_passes, + } + } + }; + + let build_mode = match self.build_release { + true => BuildMode::Release, + false => BuildMode::Debug, + }; + + let output_type = match self.output_json { + true => OutputType::Json, + false => OutputType::HumanReadable, + }; + + // We want to ensure that the only thing in `STDOUT` is our JSON formatted string. + if matches!(output_type, OutputType::Json) { + verbosity = Verbosity::Quiet; + } + + let args = ExecuteArgs { + manifest_path, + verbosity, + build_mode, + build_artifact: self.build_artifact, + unstable_flags, + optimization_passes, + keep_debug_symbols: self.keep_debug_symbols, + output_type, + }; + + execute(args) + } +} + +#[derive(Debug, StructOpt)] +#[structopt(name = "check")] +pub struct CheckCommand { + /// Path to the Cargo.toml of the contract to build + #[structopt(long, parse(from_os_str))] + manifest_path: Option, + #[structopt(flatten)] + verbosity: VerbosityFlags, + #[structopt(flatten)] + unstable_options: UnstableOptions, +} + +impl CheckCommand { + pub fn exec(&self) -> Result { + let manifest_path = ManifestPath::try_from(self.manifest_path.as_ref())?; + let unstable_flags: UnstableFlags = + TryFrom::<&UnstableOptions>::try_from(&self.unstable_options)?; + let verbosity: Verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?; + + let args = ExecuteArgs { + manifest_path, + verbosity, + build_mode: BuildMode::Debug, + build_artifact: BuildArtifacts::CheckOnly, + unstable_flags, + optimization_passes: OptimizationPasses::Zero, + keep_debug_symbols: false, + output_type: OutputType::default(), + }; + + execute(args) + } +} + +/// Executes the supplied cargo command on the project in the specified directory, defaults to the +/// current directory. /// -/// Uses [`cargo-xbuild`](https://github.com/rust-osdev/cargo-xbuild) for maximum optimization of -/// the resulting Wasm binary. +/// Uses the unstable cargo feature [`build-std`](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std) +/// to build the standard library with [`panic_immediate_abort`](https://github.com/johnthagen/min-sized-rust#remove-panic-string-formatting-with-panic_immediate_abort) +/// which reduces the size of the Wasm binary by not including panic strings and formatting code. /// /// # Cargo.toml optimizations /// @@ -48,63 +224,56 @@ const MAX_MEMORY_PAGES: u32 = 16; /// user-defined settings will be preserved. /// /// To disable this and use the original `Cargo.toml` as is then pass the `-Z original_manifest` flag. -fn build_cargo_project( +fn exec_cargo_for_wasm_target( crate_metadata: &CrateMetadata, - verbosity: Option, - unstable_options: UnstableFlags, + command: &str, + build_mode: BuildMode, + verbosity: Verbosity, + unstable_flags: &UnstableFlags, ) -> Result<()> { util::assert_channel()?; - // set RUSTFLAGS, read from environment var by cargo-xbuild + // set linker args via RUSTFLAGS. + // Currently will override user defined RUSTFLAGS from .cargo/config. See https://github.com/paritytech/cargo-contract/issues/98. std::env::set_var( "RUSTFLAGS", - "-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", + "-C link-arg=-zstack-size=65536 -C link-arg=--import-memory", ); - let verbosity = verbosity.map(|v| match v { - Verbosity::Verbose => xargo_lib::Verbosity::Verbose, - Verbosity::Quiet => xargo_lib::Verbosity::Quiet, - }); - - let xbuild = |manifest_path: &ManifestPath| { - let manifest_path = Some(manifest_path); - let target = Some("wasm32-unknown-unknown"); - let target_dir = &crate_metadata.cargo_meta.target_directory; - let other_args = [ + let cargo_build = |manifest_path: &ManifestPath| { + let target_dir = &crate_metadata.target_directory; + let target_dir = format!("--target-dir={}", target_dir.to_string_lossy()); + let mut args = vec![ + "--target=wasm32-unknown-unknown", + "-Zbuild-std", "--no-default-features", "--release", - &format!("--target-dir={}", target_dir.to_string_lossy()), + &target_dir, ]; - let args = xargo_lib::Args::new(target, manifest_path, verbosity, &other_args) - .map_err(|e| anyhow::anyhow!("{}", e)) - .context("Creating xargo args")?; - - let config = xargo_lib::Config { - sysroot_path: target_dir.join("sysroot"), - memcpy: false, - panic_immediate_abort: true, - }; - - let exit_status = xargo_lib::build(args, "build", Some(config)) - .map_err(|e| anyhow::anyhow!("{}", e)) - .context("Building with xbuild")?; - if !exit_status.success() { - anyhow::bail!("xbuild failed with status {}", exit_status) + if build_mode == BuildMode::Debug { + args.push("--features=ink_env/ink-debug"); + } else { + args.push("-Zbuild-std-features=panic_immediate_abort"); } +<<<<<<< HEAD println!("exit_status {:?}", exit_status); +======= + util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 Ok(()) }; - if unstable_options.original_manifest { - println!( + if unstable_flags.original_manifest { + maybe_println!( + verbosity, "{} {}", "warning:".yellow().bold(), "with 'original-manifest' enabled, the contract binary may not be of optimal size." .bold() ); - xbuild(&crate_metadata.manifest_path)?; + cargo_build(&crate_metadata.manifest_path)?; } else { Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)? .with_root_package_manifest(|manifest| { @@ -113,7 +282,7 @@ fn build_cargo_project( .with_profile_release_defaults(Profile::default_contract_release())?; Ok(()) })? - .using_temp(xbuild)?; + .using_temp(cargo_build)?; } // clear RUSTFLAGS @@ -160,149 +329,916 @@ fn ensure_maximum_memory_pages(module: &mut Module, maximum_allowed_pages: u32) /// Strips all custom sections. /// /// Presently all custom sections are not required so they can be stripped safely. +/// The name section is already stripped by `wasm-opt`. fn strip_custom_sections(module: &mut Module) { module.sections_mut().retain(|section| match section { - Section::Custom(_) => false, - Section::Name(_) => false, Section::Reloc(_) => false, + Section::Custom(custom) if custom.name() != "name" => false, _ => true, - }); + }) +} + +/// A contract should export nothing but the "call" and "deploy" functions. +/// +/// Any elements not referenced by these exports become orphaned and are removed by `wasm-opt`. +fn strip_exports(module: &mut Module) { + if let Some(section) = module.export_section_mut() { + section.entries_mut().retain(|entry| { + matches!(entry.internal(), Internal::Function(_)) + && (entry.field() == "call" || entry.field() == "deploy") + }) + } +} + +/// Load and parse a wasm file from disk. +fn load_module>(path: P) -> Result { + let path = path.as_ref(); + parity_wasm::deserialize_file(path).context(format!( + "Loading of wasm module at '{}' failed", + path.display(), + )) } /// Performs required post-processing steps on the wasm artifact. fn post_process_wasm(crate_metadata: &CrateMetadata) -> Result<()> { // Deserialize wasm module from a file. let mut module = - parity_wasm::deserialize_file(&crate_metadata.original_wasm).context(format!( - "Loading original wasm file '{}'", - crate_metadata.original_wasm.display() - ))?; - - // Perform optimization. - // - // In practice only tree-shaking is performed, i.e transitively removing all symbols that are - // NOT used by the specified entrypoints. - if pwasm_utils::optimize(&mut module, ["call", "deploy"].to_vec()).is_err() { - anyhow::bail!("Optimizer failed"); - } + load_module(&crate_metadata.original_wasm).context("Loading of original wasm failed")?; + + strip_exports(&mut module); ensure_maximum_memory_pages(&mut module, MAX_MEMORY_PAGES)?; strip_custom_sections(&mut module); + validate_wasm::validate_import_section(&module)?; + + debug_assert!( + !module.clone().to_bytes().unwrap().is_empty(), + "resulting wasm size of post processing must be > 0" + ); + parity_wasm::serialize_to_file(&crate_metadata.dest_wasm, module)?; Ok(()) } -/// Attempts to perform optional wasm optimization using `wasm-opt`. +/// Attempts to perform optional wasm optimization using `binaryen`. /// /// The intention is to reduce the size of bloated wasm binaries as a result of missing /// optimizations (or bugs?) between Rust and Wasm. +fn optimize_wasm( + crate_metadata: &CrateMetadata, + optimization_passes: OptimizationPasses, + keep_debug_symbols: bool, +) -> Result { + let mut dest_optimized = crate_metadata.dest_wasm.clone(); + dest_optimized.set_file_name(format!( + "{}-opt.wasm", + crate_metadata.contract_artifact_name + )); + let _ = do_optimization( + crate_metadata.dest_wasm.as_os_str(), + dest_optimized.as_os_str(), + optimization_passes, + keep_debug_symbols, + )?; + + if !dest_optimized.exists() { + return Err(anyhow::anyhow!( + "Optimization failed, optimized wasm output file `{}` not found.", + dest_optimized.display() + )); + } + + let original_size = metadata(&crate_metadata.dest_wasm)?.len() as f64 / 1000.0; + let optimized_size = metadata(&dest_optimized)?.len() as f64 / 1000.0; + + // overwrite existing destination wasm file with the optimised version + std::fs::rename(&dest_optimized, &crate_metadata.dest_wasm)?; + Ok(OptimizationResult { + dest_wasm: crate_metadata.dest_wasm.clone(), + original_size, + optimized_size, + }) +} + +/// Optimizes the Wasm supplied as `crate_metadata.dest_wasm` using +/// the `wasm-opt` binary. +/// +/// The supplied `optimization_level` denotes the number of optimization passes, +/// resulting in potentially a lot of time spent optimizing. /// -/// This step depends on the `wasm-opt` tool being installed. If it is not the build will still -/// succeed, and the user will be encouraged to install it for further optimizations. -fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> { - // check `wasm-opt` installed - if which::which("wasm-opt").is_err() { - println!( - "{}", - "wasm-opt is not installed. Install this tool on your system in order to \n\ - reduce the size of your contract's Wasm binary. \n\ - See https://github.com/WebAssembly/binaryen#tools" +/// If successful, the optimized wasm is written to `dest_optimized`. +fn do_optimization( + dest_wasm: &OsStr, + dest_optimized: &OsStr, + optimization_level: OptimizationPasses, + keep_debug_symbols: bool, +) -> Result<()> { + // check `wasm-opt` is installed + let which = which::which("wasm-opt"); + if which.is_err() { + anyhow::bail!( + "wasm-opt not found! Make sure the binary is in your PATH environment.\n\ + We use this tool to optimize the size of your contract's Wasm binary.\n\n\ + wasm-opt is part of the binaryen package. You can find detailed\n\ + installation instructions on https://github.com/WebAssembly/binaryen#tools.\n\n\ + + There are ready-to-install packages for many platforms:\n\ + * Debian/Ubuntu: apt-get install binaryen\n\ + * Homebrew: brew install binaryen\n\ + * Arch Linux: pacman -S binaryen\n\ + * Windows: binary releases at https://github.com/WebAssembly/binaryen/releases" + .to_string() .bright_yellow() ); - return Ok(()); } + let wasm_opt_path = which + .as_ref() + .expect("we just checked if which returned an err; qed") + .as_path(); + log::info!("Path to wasm-opt executable: {}", wasm_opt_path.display()); - let mut optimized = crate_metadata.dest_wasm.clone(); - optimized.set_file_name(format!("{}-opt.wasm", crate_metadata.package_name)); + let _ = check_wasm_opt_version_compatibility(wasm_opt_path)?; - let output = Command::new("wasm-opt") - .arg(crate_metadata.dest_wasm.as_os_str()) - .arg("-O3") // execute -O3 optimization passes (spends potentially a lot of time optimizing) + log::info!( + "Optimization level passed to wasm-opt: {}", + optimization_level + ); + let mut command = Command::new(wasm_opt_path); + command + .arg(dest_wasm) + .arg(format!("-O{}", optimization_level)) .arg("-o") - .arg(optimized.as_os_str()) - .output()?; + .arg(dest_optimized) + // the memory in our module is imported, `wasm-opt` needs to be told that + // the memory is initialized to zeroes, otherwise it won't run the + // memory-packing pre-pass. + .arg("--zero-filled-memory"); + if keep_debug_symbols { + command.arg("-g"); + } + log::info!("Invoking wasm-opt with {:?}", command); + let output = command.output().map_err(|err| { + anyhow::anyhow!( + "Executing {} failed with {:?}", + wasm_opt_path.display(), + err + ) + })?; if !output.status.success() { - // Dump the output streams produced by wasm-opt into the stdout/stderr. - io::stdout().write_all(&output.stdout)?; - io::stderr().write_all(&output.stderr)?; - anyhow::bail!("wasm-opt optimization failed"); + let err = str::from_utf8(&output.stderr) + .expect("Cannot convert stderr output of wasm-opt to string") + .trim(); + anyhow::bail!( + "The wasm-opt optimization failed.\n\n\ + The error which wasm-opt returned was: \n{}", + err + ); } + Ok(()) +} - let original_size = metadata(&crate_metadata.dest_wasm)?.len() as f64 / 1000.0; - let optimized_size = metadata(&optimized)?.len() as f64 / 1000.0; - println!( - " Original wasm size: {:.1}K, Optimized: {:.1}K", - original_size, optimized_size - ); +/// Checks if the wasm-opt binary under `wasm_opt_path` returns a version +/// compatible with `cargo-contract`. +/// +/// Currently this must be a version >= 99. +fn check_wasm_opt_version_compatibility(wasm_opt_path: &Path) -> Result<()> { + let cmd = Command::new(wasm_opt_path) + .arg("--version") + .output() + .map_err(|err| { + anyhow::anyhow!( + "Executing `{:?} --version` failed with {:?}", + wasm_opt_path.display(), + err + ) + })?; + if !cmd.status.success() { + let err = str::from_utf8(&cmd.stderr) + .expect("Cannot convert stderr output of wasm-opt to string") + .trim(); + anyhow::bail!( + "Getting version information from wasm-opt failed.\n\ + The error which wasm-opt returned was: \n{}", + err + ); + } - // overwrite existing destination wasm file with the optimised version - std::fs::rename(&optimized, &crate_metadata.dest_wasm)?; + // ```sh + // $ wasm-opt --version + // wasm-opt version 99 (version_99-79-gc12cc3f50) + // ``` + let github_note = "\n\n\ + If you tried installing from your system package manager the best\n\ + way forward is to download a recent binary release directly:\n\n\ + https://github.com/WebAssembly/binaryen/releases\n\n\ + Make sure that the `wasm-opt` file from that release is in your `PATH`."; + let version_stdout = str::from_utf8(&cmd.stdout) + .expect("Cannot convert stdout output of wasm-opt to string") + .trim(); + let re = Regex::new(r"wasm-opt version (\d+)").expect("invalid regex"); + let captures = re.captures(version_stdout).ok_or_else(|| { + anyhow::anyhow!( + "Unable to extract version information from '{}'.\n\ + Your wasm-opt version is most probably too old. Make sure you use a version >= 99.{}", + version_stdout, + github_note, + ) + })?; + let version_number: u32 = captures + .get(1) // first capture group is at index 1 + .ok_or_else(|| { + anyhow::anyhow!( + "Unable to extract version number from '{:?}'", + version_stdout + ) + })? + .as_str() + .parse() + .map_err(|err| { + anyhow::anyhow!( + "Parsing version number failed with '{:?}' for '{:?}'", + err, + version_stdout + ) + })?; + + log::info!( + "The wasm-opt version output is '{}', which was parsed to '{}'", + version_stdout, + version_number + ); + if version_number < 99 { + anyhow::bail!( + "Your wasm-opt version is {}, but we require a version >= 99.{}", + version_number, + github_note, + ); + } Ok(()) } -/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying. -/// -/// It does so by invoking `cargo build` and then post processing the final binary. +/// Asserts that the contract's dependencies are compatible to the ones used in ink!. /// -/// # Note +/// This function utilizes `cargo tree`, which takes semver into consideration. /// -/// Collects the contract crate's metadata using the supplied manifest (`Cargo.toml`) path. Use -/// [`execute_build_with_metadata`] if an instance is already available. -pub(crate) fn execute( +/// Hence this function only returns an `Err` if it is a proper mismatch according +/// to semantic versioning. This means that either: +/// - the major version mismatches, differences in the minor/patch version +/// are not considered incompatible. +/// - or if the version starts with zero (i.e. `0.y.z`) a mismatch in the minor +/// version is already considered incompatible. +fn assert_compatible_ink_dependencies( manifest_path: &ManifestPath, - verbosity: Option, - unstable_options: UnstableFlags, -) -> Result { - let crate_metadata = CrateMetadata::collect(manifest_path)?; - execute_with_metadata(&crate_metadata, verbosity, unstable_options) + verbosity: Verbosity, +) -> Result<()> { + for dependency in ["parity-scale-codec", "scale-info"].iter() { + let args = ["-i", dependency, "--duplicates"]; + let _ = util::invoke_cargo("tree", &args, manifest_path.directory(), verbosity).map_err( + |_| { + anyhow::anyhow!( + "Mismatching versions of `{}` were found!\n\ + Please ensure that your contract and your ink! dependencies use a compatible \ + version of this package.", + dependency + ) + }, + )?; + } + Ok(()) +} + +/// Checks whether the supplied `ink_version` already contains the debug feature. +/// +/// This feature was introduced in `3.0.0-rc4` with `ink_env/ink-debug`. +pub fn assert_debug_mode_supported(ink_version: &Version) -> anyhow::Result<()> { + log::info!("Contract version: {:?}", ink_version); + let minimum_version = Version::parse("3.0.0-rc4").expect("parsing version failed"); + if ink_version < &minimum_version { + anyhow::bail!( + "Building the contract in debug mode requires an ink! version newer than `3.0.0-rc3`!" + ); + } + Ok(()) } /// Executes build of the smart-contract which produces a wasm binary that is ready for deploying. /// /// It does so by invoking `cargo build` and then post processing the final binary. -/// -/// # Note -/// -/// Uses the supplied `CrateMetadata`. If an instance is not available use [`execute_build`] -pub(crate) fn execute_with_metadata( - crate_metadata: &CrateMetadata, - verbosity: Option, - unstable_options: UnstableFlags, -) -> Result { - println!( - " {} {}", - "[1/3]".bold(), - "Building cargo project".bright_green().bold() - ); - build_cargo_project(&crate_metadata, verbosity, unstable_options)?; - println!( - " {} {}", - "[2/3]".bold(), - "Post processing wasm file".bright_green().bold() - ); - post_process_wasm(&crate_metadata)?; - println!( - " {} {}", - "[3/3]".bold(), - "Optimizing wasm file".bright_green().bold() - ); - optimize_wasm(&crate_metadata)?; - Ok(crate_metadata.dest_wasm.clone()) +pub(crate) fn execute(args: ExecuteArgs) -> Result { + let ExecuteArgs { + manifest_path, + verbosity, + build_mode, + build_artifact, + unstable_flags, + optimization_passes, + keep_debug_symbols, + output_type, + } = args; + + let crate_metadata = CrateMetadata::collect(&manifest_path)?; + + assert_compatible_ink_dependencies(&manifest_path, verbosity)?; + if build_mode == BuildMode::Debug { + assert_debug_mode_supported(&crate_metadata.ink_version)?; + } + + let build = || -> Result { + maybe_println!( + verbosity, + " {} {}", + format!("[1/{}]", build_artifact.steps()).bold(), + "Building cargo project".bright_green().bold() + ); + exec_cargo_for_wasm_target( + &crate_metadata, + "build", + build_mode, + verbosity, + &unstable_flags, + )?; + + maybe_println!( + verbosity, + " {} {}", + format!("[2/{}]", build_artifact.steps()).bold(), + "Post processing wasm file".bright_green().bold() + ); + post_process_wasm(&crate_metadata)?; + + maybe_println!( + verbosity, + " {} {}", + format!("[3/{}]", build_artifact.steps()).bold(), + "Optimizing wasm file".bright_green().bold() + ); + let optimization_result = + optimize_wasm(&crate_metadata, optimization_passes, keep_debug_symbols)?; + + Ok(optimization_result) + }; + + let (opt_result, metadata_result) = match build_artifact { + BuildArtifacts::CheckOnly => { + exec_cargo_for_wasm_target( + &crate_metadata, + "check", + BuildMode::Release, + verbosity, + &unstable_flags, + )?; + (None, None) + } + BuildArtifacts::CodeOnly => { + let optimization_result = build()?; + (Some(optimization_result), None) + } + BuildArtifacts::All => { + let optimization_result = build()?; + + let metadata_result = super::metadata::execute( + &crate_metadata, + optimization_result.dest_wasm.as_path(), + verbosity, + build_artifact.steps(), + &unstable_flags, + )?; + (Some(optimization_result), Some(metadata_result)) + } + }; + let dest_wasm = opt_result.as_ref().map(|r| r.dest_wasm.clone()); + + Ok(BuildResult { + dest_wasm, + metadata_result, + target_directory: crate_metadata.target_directory, + optimization_result: opt_result, + build_mode, + build_artifact, + verbosity, + output_type, + }) } #[cfg(feature = "test-ci-only")] #[cfg(test)] -mod tests { - use crate::{cmd, util::tests::with_tmp_dir, workspace::ManifestPath, UnstableFlags}; +mod tests_ci_only { + use super::{ + assert_compatible_ink_dependencies, assert_debug_mode_supported, + check_wasm_opt_version_compatibility, + }; + use crate::{ + cmd::{build::load_module, BuildCommand}, + util::tests::{with_new_contract_project, with_tmp_dir}, + workspace::Manifest, + BuildArtifacts, BuildMode, ManifestPath, OptimizationPasses, OutputType, UnstableOptions, + Verbosity, VerbosityFlags, + }; + use semver::Version; + #[cfg(unix)] + use std::os::unix::fs::PermissionsExt; + use std::{ + ffi::OsStr, + io::Write, + path::{Path, PathBuf}, + }; + + /// Modifies the `Cargo.toml` under the supplied `cargo_toml_path` by + /// setting `optimization-passes` in `[package.metadata.contract]` to `passes`. + fn write_optimization_passes_into_manifest(cargo_toml_path: &Path, passes: OptimizationPasses) { + let manifest_path = + ManifestPath::new(cargo_toml_path).expect("manifest path creation failed"); + let mut manifest = Manifest::new(manifest_path.clone()).expect("manifest creation failed"); + manifest + .set_profile_optimization_passes(passes) + .expect("setting `optimization-passes` in profile failed"); + manifest + .write(&manifest_path) + .expect("writing manifest failed"); + } + + fn has_debug_symbols>(p: P) -> bool { + load_module(p) + .unwrap() + .custom_sections() + .any(|e| e.name() == "name") + } + + /// Creates an executable `wasm-opt-mocked` file which outputs + /// "wasm-opt version `version`". + /// + /// Returns the path to this file. + /// + /// Currently works only on `unix`. + #[cfg(unix)] + fn mock_wasm_opt_version(tmp_dir: &Path, version: &str) -> PathBuf { + let path = tmp_dir.join("wasm-opt-mocked"); + { + let mut file = std::fs::File::create(&path).unwrap(); + let version = format!("#!/bin/sh\necho \"wasm-opt version {}\"", version); + file.write_all(version.as_bytes()) + .expect("writing wasm-opt-mocked failed"); + } + std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o777)) + .expect("setting permissions failed"); + path + } + + #[test] + fn build_code_only() { + with_new_contract_project(|manifest_path| { + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_mode: BuildMode::Release, + build_artifact: BuildArtifacts::CodeOnly, + ..Default::default() + }; + + let res = super::execute(args).expect("build failed"); + + // our ci has set `CARGO_TARGET_DIR` to cache artifacts. + // this dir does not include `/target/` as a path, hence + // we can't match for e.g. `foo_project/target/ink`. + // + // we also can't match for `/ink` here, since this would match + // for `/ink` being the root path. + assert!(res.target_directory.ends_with("ink")); + + assert!( + res.metadata_result.is_none(), + "CodeOnly should not generate the metadata" + ); + + let optimized_size = res.optimization_result.unwrap().optimized_size; + assert!(optimized_size > 0.0); + + // our optimized contract template should always be below 3k. + assert!(optimized_size < 3.0); + + // we specified that debug symbols should be removed + // original code should have some but the optimized version should have them removed + assert!(!has_debug_symbols(&res.dest_wasm.unwrap())); + + Ok(()) + }) + } + + #[test] + fn check_must_not_output_contract_artifacts_in_project_dir() { + with_new_contract_project(|manifest_path| { + // given + let project_dir = manifest_path.directory().expect("directory must exist"); + let args = crate::cmd::build::ExecuteArgs { + manifest_path: manifest_path.clone(), + build_artifact: BuildArtifacts::CheckOnly, + ..Default::default() + }; + + // when + super::execute(args).expect("build failed"); + + // then + assert!( + !project_dir.join("target/ink/new_project.contract").exists(), + "found contract artifact in project directory!" + ); + assert!( + !project_dir.join("target/ink/new_project.wasm").exists(), + "found wasm artifact in project directory!" + ); + Ok(()) + }) + } + + #[test] + fn optimization_passes_from_cli_must_take_precedence_over_profile() { + with_new_contract_project(|manifest_path| { + // given + write_optimization_passes_into_manifest( + manifest_path.as_ref(), + OptimizationPasses::Three, + ); + let cmd = BuildCommand { + manifest_path: Some(manifest_path.into()), + build_artifact: BuildArtifacts::All, + build_release: false, + verbosity: VerbosityFlags::default(), + unstable_options: UnstableOptions::default(), + + // we choose zero optimization passes as the "cli" parameter + optimization_passes: Some(OptimizationPasses::Zero), + keep_debug_symbols: false, + output_json: false, + }; + + // when + let res = cmd.exec().expect("build failed"); + let optimization = res + .optimization_result + .expect("no optimization result available"); + + // then + // The size does not exactly match the original size even without optimization + // passed because there is still some post processing happening. + let size_diff = optimization.original_size - optimization.optimized_size; + assert!( + 0.0 < size_diff && size_diff < 10.0, + "The optimized size savings are larger than allowed or negative: {}", + size_diff, + ); + Ok(()) + }) + } + + #[test] + fn optimization_passes_from_profile_must_be_used() { + with_new_contract_project(|manifest_path| { + // given + write_optimization_passes_into_manifest( + manifest_path.as_ref(), + OptimizationPasses::Three, + ); + let cmd = BuildCommand { + manifest_path: Some(manifest_path.into()), + build_artifact: BuildArtifacts::All, + build_release: false, + verbosity: VerbosityFlags::default(), + unstable_options: UnstableOptions::default(), + + // we choose no optimization passes as the "cli" parameter + optimization_passes: None, + keep_debug_symbols: false, + output_json: false, + }; + + // when + let res = cmd.exec().expect("build failed"); + let optimization = res + .optimization_result + .expect("no optimization result available"); + + // then + // The size does not exactly match the original size even without optimization + // passed because there is still some post processing happening. + let size_diff = optimization.original_size - optimization.optimized_size; + assert!( + size_diff > (optimization.original_size / 2.0), + "The optimized size savings are too small: {}", + size_diff, + ); + + Ok(()) + }) + } + + #[test] + fn project_template_dependencies_must_be_ink_compatible() { + with_new_contract_project(|manifest_path| { + // given + // the manifest path + + // when + let res = assert_compatible_ink_dependencies(&manifest_path, Verbosity::Default); + + // then + assert!(res.is_ok()); + Ok(()) + }) + } + + #[test] + fn detect_mismatching_parity_scale_codec_dependencies() { + with_new_contract_project(|manifest_path| { + // given + // the manifest path + + // at the time of writing this test ink! already uses `parity-scale-codec` + // in a version > 2, hence 1 is an incompatible version. + let mut manifest = Manifest::new(manifest_path.clone())?; + manifest + .set_dependency_version("scale", "1.0.0") + .expect("setting `scale` version failed"); + manifest + .write(&manifest_path) + .expect("writing manifest failed"); + + // when + let res = assert_compatible_ink_dependencies(&manifest_path, Verbosity::Default); + + // then + assert!(res.is_err()); + Ok(()) + }) + } + #[cfg(unix)] #[test] - fn build_template() { + fn incompatible_wasm_opt_version_must_be_detected_if_built_from_repo() { with_tmp_dir(|path| { - cmd::new::execute("new_project", Some(path)).expect("new project creation failed"); - let manifest_path = - ManifestPath::new(&path.join("new_project").join("Cargo.toml")).unwrap(); - super::execute(&manifest_path, None, UnstableFlags::default()).expect("build failed"); + // given + let path = mock_wasm_opt_version(path, "98 (version_13-79-gc12cc3f50)"); + + // when + let res = check_wasm_opt_version_compatibility(&path); + + // then + assert!(res.is_err()); + assert!( + format!("{:?}", res).starts_with( + "Err(Your wasm-opt version is 98, but we require a version >= 99." + ), + "Expected a different output, found {:?}", + res + ); + + Ok(()) + }) + } + + #[cfg(unix)] + #[test] + fn compatible_wasm_opt_version_must_be_detected_if_built_from_repo() { + with_tmp_dir(|path| { + // given + let path = mock_wasm_opt_version(path, "99 (version_99-79-gc12cc3f50"); + + // when + let res = check_wasm_opt_version_compatibility(&path); + + // then + assert!(res.is_ok()); + + Ok(()) + }) + } + + #[cfg(unix)] + #[test] + fn incompatible_wasm_opt_version_must_be_detected_if_installed_as_package() { + with_tmp_dir(|path| { + // given + let path = mock_wasm_opt_version(path, "98"); + + // when + let res = check_wasm_opt_version_compatibility(&path); + + // then + assert!(res.is_err()); + assert!(format!("{:?}", res) + .starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99.")); + + Ok(()) + }) + } + + #[cfg(unix)] + #[test] + fn compatible_wasm_opt_version_must_be_detected_if_installed_as_package() { + with_tmp_dir(|path| { + // given + let path = mock_wasm_opt_version(path, "99"); + + // when + let res = check_wasm_opt_version_compatibility(&path); + + // then + assert!(res.is_ok()); + + Ok(()) + }) + } + + #[test] + fn contract_lib_name_different_from_package_name_must_build() { + with_new_contract_project(|manifest_path| { + // given + let mut manifest = + Manifest::new(manifest_path.clone()).expect("manifest creation failed"); + let _ = manifest + .set_lib_name("some_lib_name") + .expect("setting lib name failed"); + let _ = manifest + .set_package_name("some_package_name") + .expect("setting pacakge name failed"); + manifest + .write(&manifest_path) + .expect("writing manifest failed"); + + // when + let cmd = BuildCommand { + manifest_path: Some(manifest_path.into()), + build_artifact: BuildArtifacts::All, + build_release: false, + verbosity: VerbosityFlags::default(), + unstable_options: UnstableOptions::default(), + optimization_passes: None, + keep_debug_symbols: false, + output_json: false, + }; + let res = cmd.exec().expect("build failed"); + + // then + assert_eq!( + res.dest_wasm + .expect("`dest_wasm` does not exist") + .file_name(), + Some(OsStr::new("some_lib_name.wasm")) + ); + + Ok(()) + }) + } + + #[test] + pub fn debug_mode_must_be_compatible() { + let _ = + assert_debug_mode_supported(&Version::parse("3.0.0-rc4").expect("parsing must work")) + .expect("debug mode must be compatible"); + let _ = + assert_debug_mode_supported(&Version::parse("4.0.0-rc1").expect("parsing must work")) + .expect("debug mode must be compatible"); + let _ = assert_debug_mode_supported(&Version::parse("5.0.0").expect("parsing must work")) + .expect("debug mode must be compatible"); + } + + #[test] + pub fn debug_mode_must_be_incompatible() { + let res = + assert_debug_mode_supported(&Version::parse("3.0.0-rc3").expect("parsing must work")) + .expect_err("assertion must fail"); + assert_eq!( + res.to_string(), + "Building the contract in debug mode requires an ink! version newer than `3.0.0-rc3`!" + ); + } + + #[test] + fn building_template_in_debug_mode_must_work() { + with_new_contract_project(|manifest_path| { + // given + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_mode: BuildMode::Debug, + ..Default::default() + }; + + // when + let res = super::execute(args); + + // then + assert!(res.is_ok(), "building template in debug mode failed!"); + Ok(()) + }) + } + + #[test] + fn building_template_in_release_mode_must_work() { + with_new_contract_project(|manifest_path| { + // given + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_mode: BuildMode::Release, + ..Default::default() + }; + + // when + let res = super::execute(args); + + // then + assert!(res.is_ok(), "building template in release mode failed!"); + Ok(()) + }) + } + + #[test] + fn building_contract_with_source_file_in_subfolder_must_work() { + with_new_contract_project(|manifest_path| { + // given + let path = manifest_path.directory().expect("dir must exist"); + let old_lib_path = path.join(Path::new("lib.rs")); + let new_lib_path = path.join(Path::new("srcfoo")).join(Path::new("lib.rs")); + let new_dir_path = path.join(Path::new("srcfoo")); + std::fs::create_dir_all(new_dir_path).expect("creating dir must work"); + std::fs::rename(old_lib_path, new_lib_path).expect("moving file must work"); + + let mut manifest = + Manifest::new(manifest_path.clone()).expect("creating manifest must work"); + manifest + .set_lib_path("srcfoo/lib.rs") + .expect("setting lib path must work"); + manifest.write(&manifest_path).expect("writing must work"); + + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_artifact: BuildArtifacts::CheckOnly, + ..Default::default() + }; + + // when + let res = super::execute(args); + + // then + assert!(res.is_ok(), "building contract failed!"); + Ok(()) + }) + } + + #[test] + fn keep_debug_symbols_in_debug_mode() { + with_new_contract_project(|manifest_path| { + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_mode: BuildMode::Debug, + build_artifact: BuildArtifacts::CodeOnly, + keep_debug_symbols: true, + ..Default::default() + }; + + let res = super::execute(args).expect("build failed"); + + // we specified that debug symbols should be kept + assert!(has_debug_symbols(&res.dest_wasm.unwrap())); + + Ok(()) + }) + } + + #[test] + fn keep_debug_symbols_in_release_mode() { + with_new_contract_project(|manifest_path| { + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + build_mode: BuildMode::Release, + build_artifact: BuildArtifacts::CodeOnly, + keep_debug_symbols: true, + ..Default::default() + }; + + let res = super::execute(args).expect("build failed"); + + // we specified that debug symbols should be kept + assert!(has_debug_symbols(&res.dest_wasm.unwrap())); + + Ok(()) + }) + } + + #[test] + fn build_with_json_output_works() { + with_new_contract_project(|manifest_path| { + // given + let args = crate::cmd::build::ExecuteArgs { + manifest_path, + output_type: OutputType::Json, + ..Default::default() + }; + + // when + let res = super::execute(args).expect("build failed"); + + // then + assert!(res.serialize_json().is_ok()); Ok(()) }) } diff --git a/src/cmd/deploy.rs b/src/cmd/deploy.rs index 70ad04819..eac3d542e 100644 --- a/src/cmd/deploy.rs +++ b/src/cmd/deploy.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -66,7 +66,7 @@ pub(crate) fn execute_deploy( let events = cli.put_code_and_watch(&signer, &code).await?; let code_stored = events .code_stored()? - .ok_or(anyhow::anyhow!("Failed to find CodeStored event"))?; + .context("Failed to find CodeStored event")?; Ok(code_stored.code_hash) }) diff --git a/src/cmd/instantiate.rs b/src/cmd/instantiate.rs index b94643666..6983bee11 100644 --- a/src/cmd/instantiate.rs +++ b/src/cmd/instantiate.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -14,10 +14,15 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . +<<<<<<< HEAD use anyhow::Result; use subxt::{ balances::Balances, contracts::*, system::System, ClientBuilder, ContractsTemplateRuntime, }; +======= +use anyhow::{Context, Result}; +use subxt::{balances::Balances, contracts::*, system::System, ClientBuilder, DefaultNodeRuntime}; +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 use crate::{ExtrinsicOpts, HexData}; @@ -45,7 +50,7 @@ pub(crate) fn execute_instantiate( .await?; let instantiated = events .instantiated()? - .ok_or(anyhow::anyhow!("Failed to find Instantiated event"))?; + .context("Failed to find Instantiated event")?; Ok(instantiated.contract) }) diff --git a/src/cmd/metadata.rs b/src/cmd/metadata.rs new file mode 100644 index 000000000..92bb3c3b0 --- /dev/null +++ b/src/cmd/metadata.rs @@ -0,0 +1,424 @@ +// Copyright 2018-2021 Parity Technologies (UK) Ltd. +// This file is part of cargo-contract. +// +// cargo-contract is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// cargo-contract is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with cargo-contract. If not, see . + +use crate::{ + crate_metadata::CrateMetadata, + maybe_println, util, + workspace::{ManifestPath, Workspace}, + UnstableFlags, Verbosity, +}; + +use anyhow::Result; +use blake2::digest::{Update as _, VariableOutput as _}; +use colored::Colorize; +use contract_metadata::{ + CodeHash, Compiler, Contract, ContractMetadata, Language, Source, SourceCompiler, + SourceLanguage, SourceWasm, User, +}; +use semver::Version; +use std::{ + fs, + path::{Path, PathBuf}, +}; +use url::Url; + +const METADATA_FILE: &str = "metadata.json"; + +/// Metadata generation result. +#[derive(serde::Serialize)] +pub struct MetadataResult { + /// Path to the resulting metadata file. + pub dest_metadata: PathBuf, + /// Path to the bundled file. + pub dest_bundle: PathBuf, +} + +/// Result of generating the extended contract project metadata +struct ExtendedMetadataResult { + source: Source, + contract: Contract, + user: Option, +} + +/// Generates a file with metadata describing the ABI of the smart-contract. +/// +/// It does so by generating and invoking a temporary workspace member. +pub(crate) fn execute( + crate_metadata: &CrateMetadata, + final_contract_wasm: &Path, + verbosity: Verbosity, + total_steps: usize, + unstable_options: &UnstableFlags, +) -> Result { + util::assert_channel()?; + + let target_directory = crate_metadata.target_directory.clone(); + let out_path_metadata = target_directory.join(METADATA_FILE); + + let fname_bundle = format!("{}.contract", crate_metadata.contract_artifact_name); + let out_path_bundle = target_directory.join(fname_bundle); + + // build the extended contract project metadata + let ExtendedMetadataResult { + source, + contract, + user, + } = extended_metadata(crate_metadata, final_contract_wasm)?; + + let generate_metadata = |manifest_path: &ManifestPath| -> Result<()> { + let mut current_progress = 4; + maybe_println!( + verbosity, + " {} {}", + format!("[{}/{}]", current_progress, total_steps).bold(), + "Generating metadata".bright_green().bold() + ); + let target_dir_arg = format!("--target-dir={}", target_directory.to_string_lossy()); + let stdout = util::invoke_cargo( + "run", + &[ + "--package", + "metadata-gen", + &manifest_path.cargo_arg(), + &target_dir_arg, + "--release", + ], + crate_metadata.manifest_path.directory(), + verbosity, + )?; + + let ink_meta: serde_json::Map = serde_json::from_slice(&stdout)?; + let metadata = ContractMetadata::new(source, contract, user, ink_meta); + { + let mut metadata = metadata.clone(); + metadata.remove_source_wasm_attribute(); + let contents = serde_json::to_string_pretty(&metadata)?; + fs::write(&out_path_metadata, contents)?; + current_progress += 1; + } + + maybe_println!( + verbosity, + " {} {}", + format!("[{}/{}]", current_progress, total_steps).bold(), + "Generating bundle".bright_green().bold() + ); + let contents = serde_json::to_string(&metadata)?; + fs::write(&out_path_bundle, contents)?; + + Ok(()) + }; + + if unstable_options.original_manifest { + generate_metadata(&crate_metadata.manifest_path)?; + } else { + Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)? + .with_root_package_manifest(|manifest| { + manifest + .with_added_crate_type("rlib")? + .with_profile_release_lto(false)?; + Ok(()) + })? + .with_metadata_gen_package(crate_metadata.manifest_path.absolute_directory()?)? + .using_temp(generate_metadata)?; + } + + Ok(MetadataResult { + dest_metadata: out_path_metadata, + dest_bundle: out_path_bundle, + }) +} + +/// Generate the extended contract project metadata +fn extended_metadata( + crate_metadata: &CrateMetadata, + final_contract_wasm: &Path, +) -> Result { + let contract_package = &crate_metadata.root_package; + let ink_version = &crate_metadata.ink_version; + let rust_version = Version::parse(&rustc_version::version()?.to_string())?; + let contract_name = contract_package.name.clone(); + let contract_version = Version::parse(&contract_package.version.to_string())?; + let contract_authors = contract_package.authors.clone(); + // optional + let description = contract_package.description.clone(); + let documentation = crate_metadata.documentation.clone(); + let repository = contract_package + .repository + .as_ref() + .map(|repo| Url::parse(repo)) + .transpose()?; + let homepage = crate_metadata.homepage.clone(); + let license = contract_package.license.clone(); + let source = { + let lang = SourceLanguage::new(Language::Ink, ink_version.clone()); + let compiler = SourceCompiler::new(Compiler::RustC, rust_version); + let wasm = fs::read(final_contract_wasm)?; + let hash = blake2_hash(wasm.as_slice()); + Source::new(Some(SourceWasm::new(wasm)), hash, lang, compiler) + }; + + // Required contract fields + let mut builder = Contract::builder(); + builder + .name(contract_name) + .version(contract_version) + .authors(contract_authors); + + if let Some(description) = description { + builder.description(description); + } + + if let Some(documentation) = documentation { + builder.documentation(documentation); + } + + if let Some(repository) = repository { + builder.repository(repository); + } + + if let Some(homepage) = homepage { + builder.homepage(homepage); + } + + if let Some(license) = license { + builder.license(license); + } + + let contract = builder + .build() + .map_err(|err| anyhow::anyhow!("Invalid contract metadata builder state: {}", err))?; + + // user defined metadata + let user = crate_metadata.user.clone().map(User::new); + + Ok(ExtendedMetadataResult { + source, + contract, + user, + }) +} + +/// Returns the blake2 hash of the submitted slice. +fn blake2_hash(code: &[u8]) -> CodeHash { + let mut output = [0u8; 32]; + let mut blake2 = blake2::VarBlake2b::new_keyed(&[], 32); + blake2.update(code); + blake2.finalize_variable(|result| output.copy_from_slice(result)); + CodeHash(output) +} + +#[cfg(feature = "test-ci-only")] +#[cfg(test)] +mod tests { + use crate::cmd::metadata::blake2_hash; + use crate::{ + cmd, crate_metadata::CrateMetadata, util::tests::with_new_contract_project, ManifestPath, + }; + use anyhow::Context; + use contract_metadata::*; + use serde_json::{Map, Value}; + use std::{fmt::Write, fs}; + use toml::value; + + struct TestContractManifest { + toml: value::Table, + manifest_path: ManifestPath, + } + + impl TestContractManifest { + fn new(manifest_path: ManifestPath) -> anyhow::Result { + Ok(Self { + toml: toml::from_slice(&fs::read(&manifest_path)?)?, + manifest_path, + }) + } + + fn package_mut(&mut self) -> anyhow::Result<&mut value::Table> { + self.toml + .get_mut("package") + .context("package section not found")? + .as_table_mut() + .context("package section should be a table") + } + + /// Add a key/value to the `[package.metadata.contract.user]` section + fn add_user_metadata_value( + &mut self, + key: &'static str, + value: value::Value, + ) -> anyhow::Result<()> { + self.package_mut()? + .entry("metadata") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("metadata section should be a table")? + .entry("contract") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("metadata.contract section should be a table")? + .entry("user") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("metadata.contract.user section should be a table")? + .insert(key.into(), value); + Ok(()) + } + + fn add_package_value( + &mut self, + key: &'static str, + value: value::Value, + ) -> anyhow::Result<()> { + self.package_mut()?.insert(key.into(), value); + Ok(()) + } + + fn write(&self) -> anyhow::Result<()> { + let toml = toml::to_string(&self.toml)?; + fs::write(&self.manifest_path, toml).map_err(Into::into) + } + } + + #[test] + fn generate_metadata() { + env_logger::try_init().ok(); + with_new_contract_project(|manifest_path| { + // add optional metadata fields + let mut test_manifest = TestContractManifest::new(manifest_path)?; + test_manifest.add_package_value("description", "contract description".into())?; + test_manifest.add_package_value("documentation", "http://documentation.com".into())?; + test_manifest.add_package_value("repository", "http://repository.com".into())?; + test_manifest.add_package_value("homepage", "http://homepage.com".into())?; + test_manifest.add_package_value("license", "Apache-2.0".into())?; + test_manifest + .add_user_metadata_value("some-user-provided-field", "and-its-value".into())?; + test_manifest.add_user_metadata_value( + "more-user-provided-fields", + vec!["and", "their", "values"].into(), + )?; + test_manifest.write()?; + + let crate_metadata = CrateMetadata::collect(&test_manifest.manifest_path)?; + + // usually this file will be produced by a previous build step + let final_contract_wasm_path = &crate_metadata.dest_wasm; + fs::create_dir_all(final_contract_wasm_path.parent().unwrap()).unwrap(); + fs::write(final_contract_wasm_path, "TEST FINAL WASM BLOB").unwrap(); + + let mut args = crate::cmd::build::ExecuteArgs::default(); + args.manifest_path = test_manifest.manifest_path; + + let build_result = cmd::build::execute(args)?; + let dest_bundle = build_result + .metadata_result + .expect("Metadata should be generated") + .dest_bundle; + + let metadata_json: Map = + serde_json::from_slice(&fs::read(&dest_bundle)?)?; + + assert!( + dest_bundle.exists(), + "Missing metadata file '{}'", + dest_bundle.display() + ); + + let source = metadata_json.get("source").expect("source not found"); + let hash = source.get("hash").expect("source.hash not found"); + let language = source.get("language").expect("source.language not found"); + let compiler = source.get("compiler").expect("source.compiler not found"); + let wasm = source.get("wasm").expect("source.wasm not found"); + + let contract = metadata_json.get("contract").expect("contract not found"); + let name = contract.get("name").expect("contract.name not found"); + let version = contract.get("version").expect("contract.version not found"); + let authors = contract + .get("authors") + .expect("contract.authors not found") + .as_array() + .expect("contract.authors is an array") + .iter() + .map(|author| author.as_str().expect("author is a string")) + .collect::>(); + let description = contract + .get("description") + .expect("contract.description not found"); + let documentation = contract + .get("documentation") + .expect("contract.documentation not found"); + let repository = contract + .get("repository") + .expect("contract.repository not found"); + let homepage = contract + .get("homepage") + .expect("contract.homepage not found"); + let license = contract.get("license").expect("contract.license not found"); + + let user = metadata_json.get("user").expect("user section not found"); + + // calculate wasm hash + let fs_wasm = fs::read(&crate_metadata.dest_wasm)?; + let expected_hash = blake2_hash(&fs_wasm[..]); + let expected_wasm = build_byte_str(&fs_wasm); + + let expected_language = + SourceLanguage::new(Language::Ink, crate_metadata.ink_version).to_string(); + let expected_rustc_version = + semver::Version::parse(&rustc_version::version()?.to_string())?; + let expected_compiler = + SourceCompiler::new(Compiler::RustC, expected_rustc_version).to_string(); + let mut expected_user_metadata = serde_json::Map::new(); + expected_user_metadata + .insert("some-user-provided-field".into(), "and-its-value".into()); + expected_user_metadata.insert( + "more-user-provided-fields".into(), + serde_json::Value::Array(vec!["and".into(), "their".into(), "values".into()]), + ); + + assert_eq!(build_byte_str(&expected_hash.0[..]), hash.as_str().unwrap()); + assert_eq!(expected_wasm, wasm.as_str().unwrap()); + assert_eq!(expected_language, language.as_str().unwrap()); + assert_eq!(expected_compiler, compiler.as_str().unwrap()); + assert_eq!( + crate_metadata.contract_artifact_name, + name.as_str().unwrap() + ); + assert_eq!( + crate_metadata.root_package.version.to_string(), + version.as_str().unwrap() + ); + assert_eq!(crate_metadata.root_package.authors, authors); + assert_eq!("contract description", description.as_str().unwrap()); + assert_eq!("http://documentation.com/", documentation.as_str().unwrap()); + assert_eq!("http://repository.com/", repository.as_str().unwrap()); + assert_eq!("http://homepage.com/", homepage.as_str().unwrap()); + assert_eq!("Apache-2.0", license.as_str().unwrap()); + assert_eq!(&expected_user_metadata, user.as_object().unwrap()); + + Ok(()) + }) + } + + fn build_byte_str(bytes: &[u8]) -> String { + let mut str = String::new(); + write!(str, "0x").expect("failed writing to string"); + for byte in bytes { + write!(str, "{:02x}", byte).expect("failed writing to string"); + } + str + } +} diff --git a/src/cmd/metadata/contract.rs b/src/cmd/metadata/contract.rs deleted file mode 100644 index dc273db09..000000000 --- a/src/cmd/metadata/contract.rs +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. -// This file is part of cargo-contract. -// -// cargo-contract is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cargo-contract is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with cargo-contract. If not, see . - -use core::fmt::{Display, Formatter, Result as DisplayResult, Write}; -use semver::Version; -use serde::{Serialize, Serializer}; -use serde_json::{Map, Value}; -use url::Url; - -const METADATA_VERSION: &str = "0.1.0"; - -/// An entire ink! project for metadata file generation purposes. -#[derive(Debug, Serialize)] -pub struct ContractMetadata { - metadata_version: semver::Version, - source: Source, - contract: Contract, - #[serde(skip_serializing_if = "Option::is_none")] - user: Option, - /// Raw JSON of the metadata generated by the ink! contract itself - #[serde(flatten)] - ink: Map, -} - -impl ContractMetadata { - /// Construct new contract metadata - pub fn new( - source: Source, - contract: Contract, - user: Option, - ink: Map, - ) -> Self { - let metadata_version = semver::Version::parse(METADATA_VERSION) - .expect("METADATA_VERSION is a valid semver string"); - - Self { - metadata_version, - source, - contract, - user, - ink, - } - } -} - -#[derive(Debug, Serialize)] -pub struct Source { - #[serde(serialize_with = "serialize_as_byte_str")] - hash: [u8; 32], - language: SourceLanguage, - compiler: SourceCompiler, -} - -impl Source { - /// Constructs a new InkProjectSource. - pub fn new(hash: [u8; 32], language: SourceLanguage, compiler: SourceCompiler) -> Self { - Source { - hash, - language, - compiler, - } - } -} - -/// The language and version in which a smart contract is written. -#[derive(Debug)] -pub struct SourceLanguage { - language: Language, - version: Version, -} - -impl SourceLanguage { - /// Constructs a new SourceLanguage. - pub fn new(language: Language, version: Version) -> Self { - SourceLanguage { language, version } - } -} - -impl Serialize for SourceLanguage { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(&self.to_string()) - } -} - -impl Display for SourceLanguage { - fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { - write!(f, "{} {}", self.language, self.version) - } -} - -/// The language in which the smart contract is written. -#[derive(Debug)] -pub enum Language { - Ink, - Solidity, - AssemblyScript, -} - -impl Display for Language { - fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { - match self { - Self::Ink => write!(f, "ink!"), - Self::Solidity => write!(f, "Solidity"), - Self::AssemblyScript => write!(f, "AssemblyScript"), - } - } -} - -/// A compiler used to compile a smart contract. -#[derive(Debug)] -pub struct SourceCompiler { - compiler: Compiler, - version: Version, -} - -impl Display for SourceCompiler { - fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { - write!(f, "{} {}", self.compiler, self.version) - } -} - -impl Serialize for SourceCompiler { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(&self.to_string()) - } -} - -impl SourceCompiler { - pub fn new(compiler: Compiler, version: Version) -> Self { - SourceCompiler { compiler, version } - } -} - -/// Compilers used to compile a smart contract. -#[derive(Debug, Serialize)] -pub enum Compiler { - RustC, - Solang, -} - -impl Display for Compiler { - fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { - match self { - Self::RustC => write!(f, "rustc"), - Self::Solang => write!(f, "solang"), - } - } -} - -/// Metadata about a smart contract. -#[derive(Debug, Serialize)] -pub struct Contract { - name: String, - version: Version, - authors: Vec, - #[serde(skip_serializing_if = "Option::is_none")] - description: Option, - #[serde(skip_serializing_if = "Option::is_none")] - documentation: Option, - #[serde(skip_serializing_if = "Option::is_none")] - repository: Option, - #[serde(skip_serializing_if = "Option::is_none")] - homepage: Option, - #[serde(skip_serializing_if = "Option::is_none")] - license: Option, -} - -impl Contract { - /// Constructs a new Contract. - pub fn new( - name: String, - version: Version, - authors: Vec, - description: Option, - documentation: Option, - repository: Option, - homepage: Option, - license: Option, - ) -> Self { - Contract { - name, - version, - authors, - description, - documentation, - repository, - homepage, - license, - } - } -} - -/// Additional user defined metadata, can be any valid json. -#[derive(Debug, Serialize)] -pub struct User { - #[serde(flatten)] - json: Map, -} - -impl User { - /// Constructs a new InkProjectUser - pub fn new(json: Map) -> Self { - User { json } - } -} - -/// Serializes the given bytes as byte string. -fn serialize_as_byte_str(bytes: &[u8], serializer: S) -> Result -where - S: serde::Serializer, -{ - if bytes.is_empty() { - // Return empty string without prepended `0x`. - return serializer.serialize_str(""); - } - let mut hex = String::with_capacity(bytes.len() * 2 + 2); - write!(hex, "0x").expect("failed writing to string"); - for byte in bytes { - write!(hex, "{:02x}", byte).expect("failed writing to string"); - } - serializer.serialize_str(&hex) -} diff --git a/src/cmd/metadata/mod.rs b/src/cmd/metadata/mod.rs deleted file mode 100644 index 9a62dc046..000000000 --- a/src/cmd/metadata/mod.rs +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. -// This file is part of cargo-contract. -// -// cargo-contract is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cargo-contract is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with cargo-contract. If not, see . - -mod contract; - -use crate::{ - crate_metadata::CrateMetadata, - util, - workspace::{ManifestPath, Workspace}, - UnstableFlags, Verbosity, -}; -use anyhow::Result; -use contract::{ - Compiler, Contract, ContractMetadata, Language, Source, SourceCompiler, SourceLanguage, User, -}; -use semver::Version; -use std::{fs, path::PathBuf}; -use url::Url; - -const METADATA_FILE: &str = "metadata.json"; - -/// Executes the metadata generation process -struct GenerateMetadataCommand { - crate_metadata: CrateMetadata, - verbosity: Option, - unstable_options: UnstableFlags, -} - -impl GenerateMetadataCommand { - pub fn exec(&self) -> Result { - util::assert_channel()?; - println!(" Generating metadata"); - - let cargo_meta = &self.crate_metadata.cargo_meta; - let out_path = cargo_meta.target_directory.join(METADATA_FILE); - let target_dir = cargo_meta.target_directory.clone(); - - // build the extended contract project metadata - let (source_meta, contract_meta, user_meta) = self.extended_metadata()?; - - let generate_metadata = |manifest_path: &ManifestPath| -> Result<()> { - let target_dir_arg = format!("--target-dir={}", target_dir.to_string_lossy()); - let stdout = util::invoke_cargo( - "run", - &[ - "--package", - "metadata-gen", - &manifest_path.cargo_arg(), - &target_dir_arg, - "--release", - ], - self.crate_metadata.manifest_path.directory(), - self.verbosity, - )?; - - let ink_meta: serde_json::Map = - serde_json::from_slice(&stdout)?; - let metadata = ContractMetadata::new(source_meta, contract_meta, user_meta, ink_meta); - let contents = serde_json::to_string_pretty(&metadata)?; - fs::write(&out_path, contents)?; - Ok(()) - }; - - if self.unstable_options.original_manifest { - generate_metadata(&self.crate_metadata.manifest_path)?; - } else { - Workspace::new(&cargo_meta, &self.crate_metadata.root_package.id)? - .with_root_package_manifest(|manifest| { - manifest - .with_added_crate_type("rlib")? - .with_profile_release_lto(false)?; - Ok(()) - })? - .with_metadata_gen_package()? - .using_temp(generate_metadata)?; - } - - Ok(out_path) - } - - /// Generate the extended contract project metadata - fn extended_metadata(&self) -> Result<(Source, Contract, Option)> { - let contract_package = &self.crate_metadata.root_package; - let ink_version = &self.crate_metadata.ink_version; - let rust_version = Version::parse(&rustc_version::version()?.to_string())?; - let contract_name = contract_package.name.clone(); - let contract_version = Version::parse(&contract_package.version.to_string())?; - let contract_authors = contract_package.authors.clone(); - // optional - let description = contract_package.description.clone(); - let documentation = self.crate_metadata.documentation.clone(); - let repository = contract_package - .repository - .as_ref() - .map(|repo| Url::parse(&repo)) - .transpose()?; - let homepage = self.crate_metadata.homepage.clone(); - let license = contract_package.license.clone(); - let hash = self.wasm_hash()?; - - let source = { - let lang = SourceLanguage::new(Language::Ink, ink_version.clone()); - let compiler = SourceCompiler::new(Compiler::RustC, rust_version); - Source::new(hash, lang, compiler) - }; - - // Required contract fields - let contract = Contract::new( - contract_name, - contract_version, - contract_authors, - description, - documentation, - repository, - homepage, - license, - ); - - // user defined metadata - let user = self.crate_metadata.user.clone().map(User::new); - - Ok((source, contract, user)) - } - - /// Compile the contract and then hash the resulting wasm - fn wasm_hash(&self) -> Result<[u8; 32]> { - super::build::execute_with_metadata( - &self.crate_metadata, - self.verbosity, - self.unstable_options.clone(), - )?; - - let wasm = fs::read(&self.crate_metadata.dest_wasm)?; - - use ::blake2::digest::{Update as _, VariableOutput as _}; - let mut output = [0u8; 32]; - let mut blake2 = blake2::VarBlake2b::new_keyed(&[], 32); - blake2.update(wasm); - blake2.finalize_variable(|result| output.copy_from_slice(result)); - Ok(output) - } -} - -/// Generates a file with metadata describing the ABI of the smart-contract. -/// -/// It does so by generating and invoking a temporary workspace member. -pub(crate) fn execute( - manifest_path: ManifestPath, - verbosity: Option, - unstable_options: UnstableFlags, -) -> Result { - let crate_metadata = CrateMetadata::collect(&manifest_path)?; - GenerateMetadataCommand { - crate_metadata, - verbosity, - unstable_options, - } - .exec() -} - -#[cfg(feature = "test-ci-only")] -#[cfg(test)] -mod tests { - use crate::{ - cmd::{self, metadata::contract::*}, - crate_metadata::CrateMetadata, - util::tests::with_tmp_dir, - workspace::ManifestPath, - UnstableFlags, - }; - use blake2::digest::{Update as _, VariableOutput as _}; - use serde_json::{Map, Value}; - use std::{fmt::Write, fs}; - use toml::value; - - struct TestContractManifest { - toml: value::Table, - manifest_path: ManifestPath, - } - - impl TestContractManifest { - fn new(manifest_path: ManifestPath) -> anyhow::Result { - Ok(Self { - toml: toml::from_slice(&fs::read(&manifest_path)?)?, - manifest_path, - }) - } - - fn package_mut(&mut self) -> anyhow::Result<&mut value::Table> { - self.toml - .get_mut("package") - .ok_or(anyhow::anyhow!("package section not found"))? - .as_table_mut() - .ok_or(anyhow::anyhow!("package section should be a table")) - } - - /// Add a key/value to the `[package.metadata.contract.user]` section - fn add_user_metadata_value( - &mut self, - key: &'static str, - value: value::Value, - ) -> anyhow::Result<()> { - self.package_mut()? - .entry("metadata") - .or_insert(value::Value::Table(Default::default())) - .as_table_mut() - .ok_or(anyhow::anyhow!("metadata section should be a table"))? - .entry("contract") - .or_insert(value::Value::Table(Default::default())) - .as_table_mut() - .ok_or(anyhow::anyhow!( - "metadata.contract section should be a table" - ))? - .entry("user") - .or_insert(value::Value::Table(Default::default())) - .as_table_mut() - .ok_or(anyhow::anyhow!( - "metadata.contract.user section should be a table" - ))? - .insert(key.into(), value); - Ok(()) - } - - fn add_package_value( - &mut self, - key: &'static str, - value: value::Value, - ) -> anyhow::Result<()> { - self.package_mut()?.insert(key.into(), value); - Ok(()) - } - - fn write(&self) -> anyhow::Result<()> { - let toml = toml::to_string(&self.toml)?; - fs::write(&self.manifest_path, toml).map_err(Into::into) - } - } - - #[test] - fn generate_metadata() { - env_logger::try_init().ok(); - with_tmp_dir(|path| { - cmd::new::execute("new_project", Some(path)).expect("new project creation failed"); - let working_dir = path.join("new_project"); - let manifest_path = ManifestPath::new(working_dir.join("Cargo.toml"))?; - - // add optional metadata fields - let mut test_manifest = TestContractManifest::new(manifest_path)?; - test_manifest.add_package_value("description", "contract description".into())?; - test_manifest.add_package_value("documentation", "http://documentation.com".into())?; - test_manifest.add_package_value("repository", "http://repository.com".into())?; - test_manifest.add_package_value("homepage", "http://homepage.com".into())?; - test_manifest.add_package_value("license", "Apache-2.0".into())?; - test_manifest - .add_user_metadata_value("some-user-provided-field", "and-its-value".into())?; - test_manifest.add_user_metadata_value( - "more-user-provided-fields", - vec!["and", "their", "values"].into(), - )?; - test_manifest.write()?; - - let crate_metadata = CrateMetadata::collect(&test_manifest.manifest_path)?; - let metadata_file = - cmd::metadata::execute(test_manifest.manifest_path, None, UnstableFlags::default()) - .expect("generate metadata failed"); - let metadata_json: Map = - serde_json::from_slice(&fs::read(&metadata_file)?)?; - - assert!( - metadata_file.exists(), - format!("Missing metadata file '{}'", metadata_file.display()) - ); - - let source = metadata_json.get("source").expect("source not found"); - let hash = source.get("hash").expect("source.hash not found"); - let language = source.get("language").expect("source.language not found"); - let compiler = source.get("compiler").expect("source.compiler not found"); - - let contract = metadata_json.get("contract").expect("contract not found"); - let name = contract.get("name").expect("contract.name not found"); - let version = contract.get("version").expect("contract.version not found"); - let authors = contract - .get("authors") - .expect("contract.authors not found") - .as_array() - .expect("contract.authors is an array") - .iter() - .map(|author| author.as_str().expect("author is a string")) - .collect::>(); - let description = contract - .get("description") - .expect("contract.description not found"); - let documentation = contract - .get("documentation") - .expect("contract.documentation not found"); - let repository = contract - .get("repository") - .expect("contract.repository not found"); - let homepage = contract - .get("homepage") - .expect("contract.homepage not found"); - let license = contract.get("license").expect("contract.license not found"); - - let user = metadata_json.get("user").expect("user section not found"); - - // calculate wasm hash - let wasm = fs::read(&crate_metadata.dest_wasm)?; - let mut output = [0u8; 32]; - let mut blake2 = blake2::VarBlake2b::new_keyed(&[], 32); - blake2.update(wasm); - blake2.finalize_variable(|result| output.copy_from_slice(result)); - - let mut expected_hash = String::new(); - write!(expected_hash, "0x").expect("failed writing to string"); - for byte in &output { - write!(expected_hash, "{:02x}", byte).expect("failed writing to string"); - } - let expected_language = - SourceLanguage::new(Language::Ink, crate_metadata.ink_version).to_string(); - let expected_rustc_version = - semver::Version::parse(&rustc_version::version()?.to_string())?; - let expected_compiler = - SourceCompiler::new(Compiler::RustC, expected_rustc_version).to_string(); - let mut expected_user_metadata = serde_json::Map::new(); - expected_user_metadata - .insert("some-user-provided-field".into(), "and-its-value".into()); - expected_user_metadata.insert( - "more-user-provided-fields".into(), - serde_json::Value::Array( - vec!["and".into(), "their".into(), "values".into()].into(), - ), - ); - - assert_eq!(expected_hash, hash.as_str().unwrap()); - assert_eq!(expected_language, language.as_str().unwrap()); - assert_eq!(expected_compiler, compiler.as_str().unwrap()); - assert_eq!(crate_metadata.package_name, name.as_str().unwrap()); - assert_eq!( - crate_metadata.root_package.version.to_string(), - version.as_str().unwrap() - ); - assert_eq!(crate_metadata.root_package.authors, authors); - assert_eq!("contract description", description.as_str().unwrap()); - assert_eq!("http://documentation.com/", documentation.as_str().unwrap()); - assert_eq!("http://repository.com/", repository.as_str().unwrap()); - assert_eq!("http://homepage.com/", homepage.as_str().unwrap()); - assert_eq!("Apache-2.0", license.as_str().unwrap()); - assert_eq!(&expected_user_metadata, user.as_object().unwrap()); - - Ok(()) - }) - } -} diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 00881e55d..5d3456d0b 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -24,7 +24,12 @@ pub mod deploy; mod instantiate; pub mod metadata; pub mod new; +pub mod test; +pub(crate) use self::{ + build::{BuildCommand, CheckCommand}, + test::TestCommand, +}; #[cfg(feature = "extrinsics")] pub(crate) use self::{ call::call_regular_contract, call::execute_call, call::execute_contract_call, diff --git a/src/cmd/new.rs b/src/cmd/new.rs index 39d794530..23eccd409 100644 --- a/src/cmd/new.rs +++ b/src/cmd/new.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -23,12 +23,21 @@ use std::{ use anyhow::Result; use heck::CamelCase as _; -pub(crate) fn execute

(name: &str, dir: Option

) -> Result +pub(crate) fn execute

(name: &str, dir: Option

) -> Result> where P: AsRef, { - if name.contains('-') { - anyhow::bail!("Contract names cannot contain hyphens"); + if !name.chars().all(|c| c.is_alphanumeric() || c == '_') { + anyhow::bail!("Contract names can only contain alphanumeric characters and underscores"); + } + + if !name + .chars() + .next() + .map(|c| c.is_alphabetic()) + .unwrap_or(false) + { + anyhow::bail!("Contract names must begin with an alphabetic character"); } let out_dir = dir @@ -57,7 +66,7 @@ where let contents = contents.replace("{{name}}", name); let contents = contents.replace("{{camel_name}}", &name.to_camel_case()); - let outpath = out_dir.join(file.sanitized_name()); + let outpath = out_dir.join(file.name()); if (&*file.name()).ends_with('/') { fs::create_dir_all(&outpath)?; @@ -73,10 +82,7 @@ where .open(outpath.clone()) .map_err(|e| { if e.kind() == std::io::ErrorKind::AlreadyExists { - anyhow::anyhow!( - "New contract file {} already exists", - file.sanitized_name().display() - ) + anyhow::anyhow!("New contract file {} already exists", file.name()) } else { anyhow::anyhow!(e) } @@ -96,21 +102,48 @@ where } } - Ok(format!("Created contract {}", name)) + Ok(Some(format!("Created contract {}", name))) } #[cfg(test)] mod tests { use super::*; - use crate::{cmd, util::tests::with_tmp_dir}; + use crate::util::tests::{with_new_contract_project, with_tmp_dir}; #[test] fn rejects_hyphenated_name() { - with_tmp_dir(|path| { - let result = cmd::new::execute("rejects-hyphenated-name", Some(path)); + with_new_contract_project(|manifest_path| { + let result = execute("rejects-hyphenated-name", Some(manifest_path)); + assert!(result.is_err(), "Should fail"); assert_eq!( - format!("{:?}", result), - r#"Err(Contract names cannot contain hyphens)"# + result.err().unwrap().to_string(), + "Contract names can only contain alphanumeric characters and underscores" + ); + Ok(()) + }) + } + + #[test] + fn rejects_name_with_period() { + with_new_contract_project(|manifest_path| { + let result = execute("../xxx", Some(manifest_path)); + assert!(result.is_err(), "Should fail"); + assert_eq!( + result.err().unwrap().to_string(), + "Contract names can only contain alphanumeric characters and underscores" + ); + Ok(()) + }) + } + + #[test] + fn rejects_name_beginning_with_number() { + with_new_contract_project(|manifest_path| { + let result = execute("1xxx", Some(manifest_path)); + assert!(result.is_err(), "Should fail"); + assert_eq!( + result.err().unwrap().to_string(), + "Contract names must begin with an alphabetic character" ); Ok(()) }) @@ -121,7 +154,7 @@ mod tests { with_tmp_dir(|path| { let name = "test_contract_cargo_project_already_exists"; let _ = execute(name, Some(path)); - let result = cmd::new::execute(name, Some(path)); + let result = execute(name, Some(path)); assert!(result.is_err(), "Should fail"); assert_eq!( @@ -139,7 +172,7 @@ mod tests { let dir = path.join(name); fs::create_dir_all(&dir).unwrap(); fs::File::create(dir.join(".gitignore")).unwrap(); - let result = cmd::new::execute(name, Some(path)); + let result = execute(name, Some(path)); assert!(result.is_err(), "Should fail"); assert_eq!( diff --git a/src/cmd/test.rs b/src/cmd/test.rs new file mode 100644 index 000000000..98b9dae13 --- /dev/null +++ b/src/cmd/test.rs @@ -0,0 +1,94 @@ +// Copyright 2018-2021 Parity Technologies (UK) Ltd. +// This file is part of cargo-contract. +// +// cargo-contract is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// cargo-contract is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with cargo-contract. If not, see . + +use crate::{maybe_println, util, workspace::ManifestPath, Verbosity, VerbosityFlags}; +use anyhow::Result; +use colored::Colorize; +use std::{convert::TryFrom, path::PathBuf}; +use structopt::StructOpt; + +/// Executes smart-contract tests off-chain by delegating to `cargo test`. +#[derive(Debug, StructOpt)] +#[structopt(name = "test")] +pub struct TestCommand { + /// Path to the `Cargo.toml` of the contract to test. + #[structopt(long, parse(from_os_str))] + manifest_path: Option, + #[structopt(flatten)] + verbosity: VerbosityFlags, +} + +impl TestCommand { + pub fn exec(&self) -> Result { + let manifest_path = ManifestPath::try_from(self.manifest_path.as_ref())?; + let verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?; + + execute(&manifest_path, verbosity) + } +} + +/// Result of the test runs. +pub struct TestResult { + /// The `cargo +nightly test` child process standard output stream buffer. + pub stdout: Vec, + /// The verbosity flags. + pub verbosity: Verbosity, +} + +impl TestResult { + pub fn display(&self) -> Result { + Ok(String::from_utf8(self.stdout.clone())?) + } +} + +/// Executes `cargo +nightly test`. +pub(crate) fn execute(manifest_path: &ManifestPath, verbosity: Verbosity) -> Result { + util::assert_channel()?; + + maybe_println!( + verbosity, + " {} {}", + format!("[{}/{}]", 1, 1).bold(), + "Running tests".bright_green().bold() + ); + + let stdout = util::invoke_cargo("test", &[""], manifest_path.directory(), verbosity)?; + + Ok(TestResult { stdout, verbosity }) +} + +#[cfg(feature = "test-ci-only")] +#[cfg(test)] +mod tests_ci_only { + use crate::{util::tests::with_new_contract_project, Verbosity}; + use regex::Regex; + + #[test] + fn passing_tests_yield_stdout() { + with_new_contract_project(|manifest_path| { + let ok_output_pattern = + Regex::new(r"test result: ok. \d+ passed; 0 failed; \d+ ignored") + .expect("regex pattern compilation failed"); + + let res = + super::execute(&manifest_path, Verbosity::Default).expect("test execution failed"); + + assert!(ok_output_pattern.is_match(&String::from_utf8_lossy(&res.stdout))); + + Ok(()) + }) + } +} diff --git a/src/crate_metadata.rs b/src/crate_metadata.rs index 660dd836f..945cd8983 100644 --- a/src/crate_metadata.rs +++ b/src/crate_metadata.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . -use crate::workspace::ManifestPath; +use crate::ManifestPath; use anyhow::{Context, Result}; use cargo_metadata::{Metadata as CargoMetadata, MetadataCommand, Package}; use colored::Colorize; @@ -52,8 +52,12 @@ pub struct ComposableScheduleMetadata { pub struct CrateMetadata { pub manifest_path: ManifestPath, pub cargo_meta: cargo_metadata::Metadata, +<<<<<<< HEAD pub package_name: String, pub t3rn_composable_schedule: Option, +======= + pub contract_artifact_name: String, +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 pub root_package: Package, pub original_wasm: PathBuf, pub target_directory: PathBuf, @@ -62,28 +66,50 @@ pub struct CrateMetadata { pub documentation: Option, pub homepage: Option, pub user: Option>, + pub target_directory: PathBuf, } impl CrateMetadata { /// Parses the contract manifest and returns relevant metadata. pub fn collect(manifest_path: &ManifestPath) -> Result { let (metadata, root_package) = get_cargo_metadata(manifest_path)?; + let mut target_directory = metadata.target_directory.as_path().join("ink"); - // Normalize the package name. + // Normalize the package and lib name. let package_name = root_package.name.replace("-", "_"); + let lib_name = &root_package + .targets + .iter() + .find(|target| target.kind.iter().any(|t| t == "cdylib")) + .expect("lib name not found") + .name + .replace("-", "_"); + let absolute_manifest_path = manifest_path.absolute_directory()?; + let absolute_workspace_root = metadata.workspace_root.canonicalize()?; + if absolute_manifest_path != absolute_workspace_root { + // If the contract is a package in a workspace, we use the package name + // as the name of the sub-folder where we put the `.contract` bundle. + target_directory = target_directory.join(package_name); + } + +<<<<<<< HEAD // {target_dir}/wasm32-unknown-unknown/release/{package_name}.wasm let mut original_wasm = metadata.target_directory.clone(); +======= + // {target_dir}/wasm32-unknown-unknown/release/{lib_name}.wasm + let mut original_wasm = target_directory.clone(); +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 original_wasm.push("wasm32-unknown-unknown"); original_wasm.push("release"); - original_wasm.push(package_name.clone()); + original_wasm.push(lib_name.clone()); original_wasm.set_extension("wasm"); - // {target_dir}/{package_name}.wasm - let mut dest_wasm = metadata.target_directory.clone(); - dest_wasm.push(package_name.clone()); + // {target_dir}/{lib_name}.wasm + let mut dest_wasm = target_directory.clone(); + dest_wasm.push(lib_name.clone()); dest_wasm.set_extension("wasm"); let mut composable_schedule: Option = None; @@ -117,23 +143,31 @@ impl CrateMetadata { None } }) - .ok_or(anyhow::anyhow!("No 'ink_lang' dependency found"))?; + .ok_or_else(|| anyhow::anyhow!("No 'ink_lang' dependency found"))?; - let (documentation, homepage, user) = get_cargo_toml_metadata(manifest_path)?; + let ExtraMetadata { + documentation, + homepage, + user, + } = get_cargo_toml_metadata(manifest_path)?; let crate_metadata = CrateMetadata { manifest_path: manifest_path.clone(), cargo_meta: metadata.clone(), root_package, - package_name, - original_wasm, - dest_wasm, + contract_artifact_name: lib_name.to_string(), + original_wasm: original_wasm.into(), + dest_wasm: dest_wasm.into(), ink_version, documentation, homepage, user, +<<<<<<< HEAD t3rn_composable_schedule: composable_schedule, target_directory: metadata.target_directory.clone(), +======= + target_directory: target_directory.into(), +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 }; Ok(crate_metadata) } @@ -143,7 +177,7 @@ impl CrateMetadata { fn get_cargo_metadata(manifest_path: &ManifestPath) -> Result<(CargoMetadata, Package)> { let mut cmd = MetadataCommand::new(); let metadata = cmd - .manifest_path(manifest_path) + .manifest_path(manifest_path.as_ref()) .exec() .context("Error invoking `cargo metadata`")?; let root_package_id = metadata @@ -163,16 +197,21 @@ fn get_cargo_metadata(manifest_path: &ManifestPath) -> Result<(CargoMetadata, Pa Ok((metadata, root_package)) } +/// Extra metadata not available via `cargo metadata`. +struct ExtraMetadata { + documentation: Option, + homepage: Option, + user: Option>, +} + /// Read extra metadata not available via `cargo metadata` directly from `Cargo.toml` -fn get_cargo_toml_metadata( - manifest_path: &ManifestPath, -) -> Result<(Option, Option, Option>)> { +fn get_cargo_toml_metadata(manifest_path: &ManifestPath) -> Result { let toml = fs::read_to_string(manifest_path)?; let toml: value::Table = toml::from_str(&toml)?; let get_url = |field_name| -> Result> { toml.get("package") - .ok_or(anyhow::anyhow!("package section not found"))? + .ok_or_else(|| anyhow::anyhow!("package section not found"))? .get(field_name) .and_then(|v| v.as_str()) .map(Url::parse) @@ -196,5 +235,9 @@ fn get_cargo_toml_metadata( }) .transpose()?; - Ok((documentation, homepage, user)) + Ok(ExtraMetadata { + documentation, + homepage, + user, + }) } diff --git a/src/main.rs b/src/main.rs index 10c9be88c..1f09e1828 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -17,8 +17,13 @@ mod cmd; mod crate_metadata; mod util; +mod validate_wasm; mod workspace; +use self::workspace::ManifestPath; + +use crate::cmd::{metadata::MetadataResult, BuildCommand, CheckCommand, TestCommand}; + #[cfg(feature = "extrinsics")] use sp_core::{ crypto::{AccountId32, Pair}, @@ -26,8 +31,10 @@ use sp_core::{ }; use std::{ - convert::{TryFrom, TryInto}, + convert::TryFrom, + fmt::{Display, Formatter, Result as DisplayResult}, path::PathBuf, + str::FromStr, }; #[cfg(feature = "extrinsics")] use subxt::PairSigner; @@ -40,9 +47,11 @@ use crate::crate_metadata::CrateMetadata; #[derive(Debug, StructOpt)] #[structopt(bin_name = "cargo")] +#[structopt(version = env!("CARGO_CONTRACT_CLI_IMPL_VERSION"))] pub(crate) enum Opts { /// Utilities to develop Wasm smart contracts. #[structopt(name = "contract")] + #[structopt(version = env!("CARGO_CONTRACT_CLI_IMPL_VERSION"))] #[structopt(setting = clap::AppSettings::UnifiedHelpMessage)] #[structopt(setting = clap::AppSettings::DeriveDisplayOrder)] #[structopt(setting = clap::AppSettings::DontCollapseArgsInUsage)] @@ -97,34 +106,116 @@ impl ExtrinsicOpts { } } -#[derive(Debug, StructOpt)] -struct VerbosityFlags { +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum OptimizationPasses { + Zero, + One, + Two, + Three, + Four, + S, + Z, +} + +impl Display for OptimizationPasses { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + let out = match self { + OptimizationPasses::Zero => "0", + OptimizationPasses::One => "1", + OptimizationPasses::Two => "2", + OptimizationPasses::Three => "3", + OptimizationPasses::Four => "4", + OptimizationPasses::S => "s", + OptimizationPasses::Z => "z", + }; + write!(f, "{}", out) + } +} + +impl Default for OptimizationPasses { + fn default() -> OptimizationPasses { + OptimizationPasses::Z + } +} + +impl std::str::FromStr for OptimizationPasses { + type Err = Error; + + fn from_str(input: &str) -> std::result::Result { + // We need to replace " here, since the input string could come + // from either the CLI or the `Cargo.toml` profile section. + // If it is from the profile it could e.g. be "3" or 3. + let normalized_input = input.replace("\"", "").to_lowercase(); + match normalized_input.as_str() { + "0" => Ok(OptimizationPasses::Zero), + "1" => Ok(OptimizationPasses::One), + "2" => Ok(OptimizationPasses::Two), + "3" => Ok(OptimizationPasses::Three), + "4" => Ok(OptimizationPasses::Four), + "s" => Ok(OptimizationPasses::S), + "z" => Ok(OptimizationPasses::Z), + _ => anyhow::bail!("Unknown optimization passes for option {}", input), + } + } +} + +impl From for OptimizationPasses { + fn from(str: String) -> Self { + OptimizationPasses::from_str(&str).expect("conversion failed") + } +} + +#[derive(Default, Clone, Debug, StructOpt)] +pub struct VerbosityFlags { + /// No output printed to stdout #[structopt(long)] quiet: bool, + /// Use verbose output #[structopt(long)] verbose: bool, } -#[derive(Clone, Copy)] -enum Verbosity { +/// Denotes if output should be printed to stdout. +#[derive(Clone, Copy, serde::Serialize)] +pub enum Verbosity { + /// Use default output + Default, + /// No output printed to stdout Quiet, + /// Use verbose output Verbose, } -impl TryFrom<&VerbosityFlags> for Option { +impl Default for Verbosity { + fn default() -> Self { + Verbosity::Default + } +} + +impl Verbosity { + /// Returns `true` if output should be printed (i.e. verbose output is set). + pub(crate) fn is_verbose(&self) -> bool { + match self { + Verbosity::Quiet => false, + Verbosity::Default | Verbosity::Verbose => true, + } + } +} + +impl TryFrom<&VerbosityFlags> for Verbosity { type Error = Error; fn try_from(value: &VerbosityFlags) -> Result { match (value.quiet, value.verbose) { - (false, false) => Ok(None), - (true, false) => Ok(Some(Verbosity::Quiet)), - (false, true) => Ok(Some(Verbosity::Verbose)), + (false, false) => Ok(Verbosity::Default), + (true, false) => Ok(Verbosity::Quiet), + (false, true) => Ok(Verbosity::Verbose), (true, true) => anyhow::bail!("Cannot pass both --quiet and --verbose flags"), } } } -#[derive(Debug, StructOpt)] +#[derive(Default, Clone, Debug, StructOpt)] struct UnstableOptions { /// Use the original manifest (Cargo.toml), do not modify for build optimizations #[structopt(long = "unstable-options", short = "Z", number_of_values = 1)] @@ -155,6 +246,199 @@ impl TryFrom<&UnstableOptions> for UnstableFlags { } } +/// Describes which artifacts to generate +#[derive(Copy, Clone, Eq, PartialEq, Debug, StructOpt, serde::Serialize)] +#[structopt(name = "build-artifacts")] +pub enum BuildArtifacts { + /// Generate the Wasm, the metadata and a bundled `.contract` file + #[structopt(name = "all")] + All, + /// Only the Wasm is created, generation of metadata and a bundled `.contract` file is skipped + #[structopt(name = "code-only")] + CodeOnly, + CheckOnly, +} + +impl BuildArtifacts { + /// Returns the number of steps required to complete a build artifact. + /// Used as output on the cli. + pub fn steps(&self) -> usize { + match self { + BuildArtifacts::All => 5, + BuildArtifacts::CodeOnly => 3, + BuildArtifacts::CheckOnly => 2, + } + } +} + +impl std::str::FromStr for BuildArtifacts { + type Err = String; + fn from_str(artifact: &str) -> Result { + match artifact { + "all" => Ok(BuildArtifacts::All), + "code-only" => Ok(BuildArtifacts::CodeOnly), + _ => Err("Could not parse build artifact".to_string()), + } + } +} + +impl Default for BuildArtifacts { + fn default() -> Self { + BuildArtifacts::All + } +} + +/// The mode to build the contract in. +#[derive(Eq, PartialEq, Copy, Clone, Debug, serde::Serialize)] +pub enum BuildMode { + /// Functionality to output debug messages is build into the contract. + Debug, + /// The contract is build without any debugging functionality. + Release, +} + +impl Default for BuildMode { + fn default() -> BuildMode { + BuildMode::Debug + } +} + +impl Display for BuildMode { + fn fmt(&self, f: &mut Formatter<'_>) -> DisplayResult { + match self { + Self::Debug => write!(f, "debug"), + Self::Release => write!(f, "release"), + } + } +} + +/// The type of output to display at the end of a build. +pub enum OutputType { + /// Output build results in a human readable format. + HumanReadable, + /// Output the build results JSON formatted. + Json, +} + +impl Default for OutputType { + fn default() -> Self { + OutputType::HumanReadable + } +} + +/// Result of the metadata generation process. +#[derive(serde::Serialize)] +pub struct BuildResult { + /// Path to the resulting Wasm file. + pub dest_wasm: Option, + /// Result of the metadata generation. + pub metadata_result: Option, + /// Path to the directory where output files are written to. + pub target_directory: PathBuf, + /// If existent the result of the optimization. + pub optimization_result: Option, + /// The mode to build the contract in. + pub build_mode: BuildMode, + /// Which build artifacts were generated. + pub build_artifact: BuildArtifacts, + /// The verbosity flags. + pub verbosity: Verbosity, + /// The type of formatting to use for the build output. + #[serde(skip_serializing)] + pub output_type: OutputType, +} + +/// Result of the optimization process. +#[derive(serde::Serialize)] +pub struct OptimizationResult { + /// The path of the optimized wasm file. + pub dest_wasm: PathBuf, + /// The original Wasm size. + pub original_size: f64, + /// The Wasm size after optimizations have been applied. + pub optimized_size: f64, +} + +impl BuildResult { + pub fn display(&self) -> String { + let optimization = self.display_optimization(); + let size_diff = format!( + "\nOriginal wasm size: {}, Optimized: {}\n\n", + format!("{:.1}K", optimization.0).bold(), + format!("{:.1}K", optimization.1).bold(), + ); + debug_assert!( + optimization.1 > 0.0, + "optimized file size must be greater 0" + ); + + let build_mode = format!( + "The contract was built in {} mode.\n\n", + format!("{}", self.build_mode).to_uppercase().bold(), + ); + + if self.build_artifact == BuildArtifacts::CodeOnly { + let out = format!( + "{}{}Your contract's code is ready. You can find it here:\n{}", + size_diff, + build_mode, + self.dest_wasm + .as_ref() + .expect("wasm path must exist") + .display() + .to_string() + .bold() + ); + return out; + }; + + let mut out = format!( + "{}{}Your contract artifacts are ready. You can find them in:\n{}\n\n", + size_diff, + build_mode, + self.target_directory.display().to_string().bold(), + ); + if let Some(metadata_result) = self.metadata_result.as_ref() { + let bundle = format!( + " - {} (code + metadata)\n", + util::base_name(&metadata_result.dest_bundle).bold() + ); + out.push_str(&bundle); + } + if let Some(dest_wasm) = self.dest_wasm.as_ref() { + let wasm = format!( + " - {} (the contract's code)\n", + util::base_name(dest_wasm).bold() + ); + out.push_str(&wasm); + } + if let Some(metadata_result) = self.metadata_result.as_ref() { + let metadata = format!( + " - {} (the contract's metadata)", + util::base_name(&metadata_result.dest_metadata).bold() + ); + out.push_str(&metadata); + } + out + } + + /// Returns a tuple of `(original_size, optimized_size)`. + /// + /// Panics if no optimization result is available. + fn display_optimization(&self) -> (f64, f64) { + let optimization = self + .optimization_result + .as_ref() + .expect("optimization result must exist"); + (optimization.original_size, optimization.optimized_size) + } + + /// Display the build results in a pretty formatted JSON string. + pub fn serialize_json(&self) -> Result { + Ok(serde_json::to_string_pretty(self)?) + } +} + #[derive(Debug, StructOpt)] enum Command { /// Setup and create a new smart contract project @@ -166,8 +450,9 @@ enum Command { #[structopt(short, long, parse(from_os_str))] target_dir: Option, }, - /// Compiles the smart contract + /// Compiles the contract, generates metadata, bundles both together in a `.contract` file #[structopt(name = "build")] +<<<<<<< HEAD Build { #[structopt(flatten)] verbosity: VerbosityFlags, @@ -190,16 +475,22 @@ enum Command { #[structopt(flatten)] unstable_options: UnstableOptions, }, +======= + Build(BuildCommand), + /// Check that the code builds as Wasm; does not output any `.contract` artifact to the `target/` directory + #[structopt(name = "check")] + Check(CheckCommand), +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 /// Test the smart contract off-chain #[structopt(name = "test")] - Test {}, + Test(TestCommand), /// Upload the smart contract code to the chain #[cfg(feature = "extrinsics")] #[structopt(name = "deploy")] Deploy { #[structopt(flatten)] extrinsic_opts: ExtrinsicOpts, - /// Path to wasm contract code, defaults to ./target/-pruned.wasm + /// Path to wasm contract code, defaults to `./target/ink/.wasm` #[structopt(parse(from_os_str))] wasm_path: Option, }, @@ -323,33 +614,37 @@ fn main() { let Opts::Contract(args) = Opts::from_args(); match exec(args.cmd) { - Ok(msg) => println!("\t{}", msg), - Err(err) => eprintln!( - "{} {}", - "ERROR:".bright_red().bold(), - format!("{:?}", err).bright_red() - ), + Ok(maybe_msg) => { + if let Some(msg) = maybe_msg { + println!("\t{}", msg) + } + } + Err(err) => { + eprintln!( + "{} {}", + "ERROR:".bright_red().bold(), + format!("{:?}", err).bright_red() + ); + std::process::exit(1); + } } } -fn exec(cmd: Command) -> Result { +fn exec(cmd: Command) -> Result> { match &cmd { Command::New { name, target_dir } => cmd::new::execute(name, target_dir.as_ref()), - Command::Build { - verbosity, - unstable_options, - } => { - let manifest_path = Default::default(); - let dest_wasm = cmd::build::execute( - &manifest_path, - verbosity.try_into()?, - unstable_options.try_into()?, - )?; - Ok(format!( - "\nYour contract is ready. You can find it here:\n{}", - dest_wasm.display().to_string().bold() - )) + Command::Build(build) => { + let result = build.exec()?; + + if matches!(result.output_type, OutputType::Json) { + Ok(Some(result.serialize_json()?)) + } else if result.verbosity.is_verbose() { + Ok(Some(result.display())) + } else { + Ok(None) + } } +<<<<<<< HEAD Command::ComposableBuild { verbosity, unstable_options, @@ -378,15 +673,37 @@ fn exec(cmd: Command) -> Result { "Your metadata file is ready.\nYou can find it here:\n{}", metadata_file.display() )) +======= + Command::Check(check) => { + let res = check.exec()?; + assert!( + res.dest_wasm.is_none(), + "no dest_wasm must be on the generation result" + ); + if res.verbosity.is_verbose() { + Ok(Some( + "\nYour contract's code was built successfully.".to_string(), + )) + } else { + Ok(None) + } + } + Command::Test(test) => { + let res = test.exec()?; + if res.verbosity.is_verbose() { + Ok(Some(res.display()?)) + } else { + Ok(None) + } +>>>>>>> 8e86572b4b4ed2442de131c8e3506dee219fb0b7 } - Command::Test {} => Err(anyhow::anyhow!("Command unimplemented")), #[cfg(feature = "extrinsics")] Command::Deploy { extrinsic_opts, wasm_path, } => { let code_hash = cmd::execute_deploy(extrinsic_opts, wasm_path.as_ref())?; - Ok(format!("Code hash: {:?}", code_hash)) + Ok(Some(format!("Code hash: {:?}", code_hash))) } #[cfg(feature = "extrinsics")] Command::ComposableDeploy { suri } => { @@ -447,7 +764,7 @@ fn exec(cmd: Command) -> Result { *code_hash, data.clone(), )?; - Ok(format!("Contract account: {:?}", contract_account)) + Ok(Some(format!("Contract account: {:?}", contract_account))) } #[cfg(feature = "extrinsics")] Command::CallRuntimeGateway { @@ -541,3 +858,54 @@ fn exec(cmd: Command) -> Result { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn build_result_seralization_sanity_check() { + // given + let raw_result = r#"{ + "dest_wasm": "/path/to/contract.wasm", + "metadata_result": { + "dest_metadata": "/path/to/metadata.json", + "dest_bundle": "/path/to/contract.contract" + }, + "target_directory": "/path/to/target", + "optimization_result": { + "dest_wasm": "/path/to/contract.wasm", + "original_size": 64.0, + "optimized_size": 32.0 + }, + "build_mode": "Debug", + "build_artifact": "All", + "verbosity": "Quiet" +}"#; + + let build_result = crate::BuildResult { + dest_wasm: Some(PathBuf::from("/path/to/contract.wasm")), + metadata_result: Some(crate::cmd::metadata::MetadataResult { + dest_metadata: PathBuf::from("/path/to/metadata.json"), + dest_bundle: PathBuf::from("/path/to/contract.contract"), + }), + target_directory: PathBuf::from("/path/to/target"), + optimization_result: Some(crate::OptimizationResult { + dest_wasm: PathBuf::from("/path/to/contract.wasm"), + original_size: 64.0, + optimized_size: 32.0, + }), + build_mode: Default::default(), + build_artifact: Default::default(), + verbosity: Verbosity::Quiet, + output_type: OutputType::Json, + }; + + // when + let serialized_result = build_result.serialize_json(); + + // then + assert!(serialized_result.is_ok()); + assert_eq!(serialized_result.unwrap(), raw_result); + } +} diff --git a/src/util.rs b/src/util.rs index 84b2b8948..9d6e70211 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -42,14 +42,14 @@ pub(crate) fn invoke_cargo( command: &str, args: I, working_dir: Option

, - verbosity: Option, + verbosity: Verbosity, ) -> Result> where I: IntoIterator + std::fmt::Debug, S: AsRef, P: AsRef, { - let cargo = std::env::var("CARGO").unwrap_or("cargo".to_string()); + let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); let mut cmd = Command::new(cargo); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); @@ -59,12 +59,12 @@ where cmd.arg(command); cmd.args(args); match verbosity { - Some(Verbosity::Quiet) => cmd.arg("--quiet"), - Some(Verbosity::Verbose) => cmd.arg("--verbose"), - None => &mut cmd, + Verbosity::Quiet => cmd.arg("--quiet"), + Verbosity::Verbose => cmd.arg("--verbose"), + Verbosity::Default => &mut cmd, }; - log::info!("invoking cargo: {:?}", cmd); + log::info!("Invoking cargo: {:?}", cmd); let child = cmd // capture the stdout to return from this function as bytes @@ -84,10 +84,32 @@ where } } +/// Returns the base name of the path. +pub(crate) fn base_name(path: &Path) -> &str { + path.file_name() + .expect("file name must exist") + .to_str() + .expect("must be valid utf-8") +} + +/// Prints to stdout if `verbosity.is_verbose()` is `true`. +#[macro_export] +macro_rules! maybe_println { + ($verbosity:expr, $($msg:tt)*) => { + if $verbosity.is_verbose() { + println!($($msg)*); + } + }; +} + #[cfg(test)] pub mod tests { + use crate::ManifestPath; use std::path::Path; + use std::sync::atomic::{AtomicU32, Ordering}; + /// Creates a temporary directory and passes the `tmp_dir` path to `f`. + /// Panics if `f` returns an `Err`. pub fn with_tmp_dir(f: F) where F: FnOnce(&Path) -> anyhow::Result<()>, @@ -98,6 +120,44 @@ pub mod tests { .expect("temporary directory creation failed"); // catch test panics in order to clean up temp dir which will be very large - f(tmp_dir.path()).expect("Error executing test with tmp dir") + f(&tmp_dir.path().canonicalize().unwrap()).expect("Error executing test with tmp dir") + } + + /// Global counter to generate unique contract names in `with_new_contract_project`. + /// + /// We typically use `with_tmp_dir` to generate temporary folders to build contracts + /// in. But for caching purposes our CI uses `CARGO_TARGET_DIR` to overwrite the + /// target directory of any contract build -- it is set to a fixed cache directory + /// instead. + /// This poses a problem since we still want to ensure that each test builds to its + /// own, unique target directory -- without interfering with the target directory of + /// other tests. In the past this has been a problem when a test tried to create a + /// contract with the same contract name as another test -- both were then build + /// into the same target directory, sometimes causing test failures for strange reasons. + /// + /// The fix we decided on is to append a unique number to each contract name which + /// is created. This `COUNTER` provides a global counter which is accessed by each test + /// (in each thread) to get the current `COUNTER` number and increase it afterwards. + /// + /// We decided to go for this counter instead of hashing (with e.g. the temp dir) to + /// prevent an infinite number of contract artifacts being created in the cache directory. + static COUNTER: AtomicU32 = AtomicU32::new(0); + + /// Creates a new contract into a temporary directory. The contract's + /// `ManifestPath` is passed into `f`. + pub fn with_new_contract_project(f: F) + where + F: FnOnce(ManifestPath) -> anyhow::Result<()>, + { + with_tmp_dir(|tmp_dir| { + let unique_name = format!("new_project_{}", COUNTER.fetch_add(1, Ordering::SeqCst)); + + crate::cmd::new::execute(&unique_name, Some(tmp_dir)) + .expect("new project creation failed"); + let working_dir = tmp_dir.join(unique_name); + let manifest_path = ManifestPath::new(working_dir.join("Cargo.toml"))?; + + f(manifest_path) + }) } } diff --git a/src/validate_wasm.rs b/src/validate_wasm.rs new file mode 100644 index 000000000..daec2eabf --- /dev/null +++ b/src/validate_wasm.rs @@ -0,0 +1,323 @@ +// Copyright 2018-2021 Parity Technologies (UK) Ltd. +// This file is part of cargo-contract. +// +// cargo-contract is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// cargo-contract is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with cargo-contract. If not, see . + +use anyhow::Result; +use colored::Colorize; +use impl_serde::serialize as serde_hex; +use parity_wasm::elements::Module; + +/// Marker inserted by the ink! codegen for an error which can't +/// be checked at compile time. +const INK_ENFORCE_ERR: &str = "__ink_enforce_error_"; + +/// Errors which may occur when forwarding a call is not allowed. +/// +/// We insert markers for these errors in the generated contract code. +/// This is necessary since we can't check these errors at compile time +/// of the contract. +/// `cargo-contract` checks the contract code for these error markers +/// when building a contract and fails if it finds markers. +/// +/// # Important Note +/// +/// This is a copy of the equivalent type in ink!, which currently resides +/// [here](https://github.com/paritytech/ink/blob/master/crates/lang/codegen/src/generator/cross_calling.rs). +/// This type must be compatible with the ink! version in order to decode +/// the error encoded in the marker. +#[derive(codec::Encode, codec::Decode)] +pub enum EnforcedErrors { + /// The below error represents calling a `&mut self` message in a context that + /// only allows for `&self` messages. This may happen under certain circumstances + /// when ink! trait implementations are involved with long-hand calling notation. + #[codec(index = 1)] + CannotCallTraitMessage { + /// The trait that defines the called message. + trait_ident: String, + /// The name of the called message. + message_ident: String, + /// The selector of the called message. + message_selector: [u8; 4], + /// Is `true` if the `self` receiver of the ink! message is `&mut self`. + message_mut: bool, + }, + /// The below error represents calling a constructor in a context that does + /// not allow calling it. This may happen when the constructor defined in a + /// trait is cross-called in another contract. + /// This is not allowed since the contract to which a call is forwarded must + /// already exist at the point when the call to it is made. + #[codec(index = 2)] + CannotCallTraitConstructor { + /// The trait that defines the called constructor. + trait_ident: String, + /// The name of the called constructor. + constructor_ident: String, + /// The selector of the called constructor. + constructor_selector: [u8; 4], + }, +} + +/// Validates the import section in the Wasm. +/// +/// The checks currently fall into two categories: +/// - Known bugs for which we want to recommend a solution. +/// - Markers inserted by the ink! codegen for errors which can't be checked at compile time. +pub fn validate_import_section(module: &Module) -> Result<()> { + let imports = match module.import_section() { + Some(section) => section.entries().iter(), + None => { + // the module does not contain any imports, + // hence no further validation is necessary. + return Ok(()); + } + }; + let original_imports_len = imports.len(); + let mut errs = Vec::new(); + + let filtered_imports = imports.filter(|section| { + let field = section.field(); + if field.contains("panic") { + errs.push(String::from( + "An unexpected panic function import was found in the contract Wasm.\n\ + This typically goes back to a known bug in the Rust compiler:\n\ + https://github.com/rust-lang/rust/issues/78744\n\n\ + As a workaround try to insert `overflow-checks = false` into your `Cargo.toml`.\n\ + This will disable safe math operations, but unfortunately we are currently not \n\ + aware of a better workaround until the bug in the compiler is fixed.", + )); + } else if field.starts_with(INK_ENFORCE_ERR) { + errs.push(parse_linker_error(field)); + } + + match check_import(field) { + Ok(_) => true, + Err(err) => { + errs.push(err); + false + } + } + }); + + if original_imports_len != filtered_imports.count() { + anyhow::bail!(format!( + "Validation of the Wasm failed.\n\n\n{}", + errs.into_iter() + .map(|err| format!("{} {}", "ERROR:".to_string().bold(), err)) + .collect::>() + .join("\n\n\n") + )); + } + Ok(()) +} + +/// Returns `true` if the import is allowed. +fn check_import(field: &str) -> Result<(), String> { + let allowed_prefixes = ["seal", "memory"]; + if allowed_prefixes + .iter() + .any(|prefix| field.starts_with(prefix)) + { + Ok(()) + } else { + let msg = format!( + "An unexpected import function was found in the contract Wasm: {}.\n\ + The only allowed import functions are those starting with one of the following prefixes:\n\ + {}", field, allowed_prefixes.join(", ") + ); + Err(msg) + } +} + +/// Extracts the ink! linker error marker from the `field`, parses it, and +/// returns a human readable error message for it. +fn parse_linker_error(field: &str) -> String { + let encoded = field + .strip_prefix(INK_ENFORCE_ERR) + .expect("error marker must exist as prefix"); + let hex = serde_hex::from_hex(encoded).expect("decoding hex failed"); + let decoded = ::decode(&mut &hex[..]).expect( + "The `EnforcedError` object could not be decoded. The probable\ + cause is a mismatch between the ink! definition of the type and the\ + local `cargo-contract` definition.", + ); + + match decoded { + EnforcedErrors::CannotCallTraitMessage { + trait_ident, + message_ident, + message_selector, + message_mut, + } => { + let receiver = match message_mut { + true => "&mut self", + false => "&self", + }; + format!( + "An error was found while compiling the contract:\n\ + The ink! message `{}::{}` with the selector `{}` contains an invalid trait call.\n\n\ + Please check if the receiver of the function to call is consistent\n\ + with the scope in which it is called. The receiver is `{}`.", + trait_ident, + message_ident, + serde_hex::to_hex(&codec::Encode::encode(&message_selector), false), + receiver + ) + } + EnforcedErrors::CannotCallTraitConstructor { + trait_ident, + constructor_ident, + constructor_selector, + } => { + format!( + "An error was found while compiling the contract:\n\ + The ink! constructor `{}::{}` with the selector `{}` contains an invalid trait call.\n\ + Constructor never need to be forwarded, please check if this is the case.", + trait_ident, + constructor_ident, + serde_hex::to_hex(&codec::Encode::encode(&constructor_selector), false) + ) + } + } +} + +#[cfg(test)] +mod tests { + use super::validate_import_section; + use parity_wasm::elements::Module; + + fn create_module(contract: &str) -> Module { + let wasm = wabt::wat2wasm(contract).expect("invalid wabt"); + parity_wasm::deserialize_buffer(&wasm).expect("deserializing must work") + } + + #[test] + fn must_catch_panic_import() { + // given + let contract = r#" + (module + (type (;0;) (func (param i32 i32 i32))) + (import "env" "_ZN4core9panicking5panic17h00e3acdd8048cb7cE" (func (;5;) (type 0))) + (func (;5;) (type 0)) + )"#; + let module = create_module(contract); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_err()); + assert!(res + .unwrap_err() + .to_string() + .contains("An unexpected panic function import was found in the contract Wasm.")); + } + + #[test] + fn must_catch_ink_enforce_error_marker_message() { + // given + let contract = r#" + (module + (type (;0;) (func)) + (import "env" "__ink_enforce_error_0x0110466c697010666c6970aa97cade01" (func $__ink_enforce_error_0x0110466c697010666c6970aa97cade01 (type 0))) + )"#; + let wasm = wabt::wat2wasm(contract).expect("invalid wabt"); + let module = parity_wasm::deserialize_buffer(&wasm).expect("deserializing must work"); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_err()); + let err = res.unwrap_err().to_string(); + assert!(err.contains( + "The ink! message `Flip::flip` with the selector `0xaa97cade` contains an invalid trait call." + )); + assert!(err.contains("The receiver is `&mut self`.",)); + } + + #[test] + fn must_catch_ink_enforce_error_marker_constructor() { + // given + let contract = r#" + (module + (type (;0;) (func)) + (import "env" "__ink_enforce_error_0x0210466c69700c6e657740d75d74" (func $__ink_enforce_error_0x0210466c69700c6e657740d75d74 (type 0))) + )"#; + let module = create_module(contract); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_err()); + assert!(res.unwrap_err().to_string().contains( + "The ink! constructor `Flip::new` with the selector `0x40d75d74` contains an invalid trait call." + )); + } + + #[test] + fn must_catch_invalid_import() { + // given + let contract = r#" + (module + (type (;0;) (func (param i32 i32 i32))) + (import "env" "some_fn" (func (;5;) (type 0))) + (func (;5;) (type 0)) + )"#; + let module = create_module(contract); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_err()); + assert!(res + .unwrap_err() + .to_string() + .contains("An unexpected import function was found in the contract Wasm: some_fn.")); + } + + #[test] + fn must_validate_successfully() { + // given + let contract = r#" + (module + (type (;0;) (func (param i32 i32 i32))) + (import "env" "seal_foo" (func (;5;) (type 0))) + (import "env" "memory" (func (;5;) (type 0))) + (func (;5;) (type 0)) + )"#; + let module = create_module(contract); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_ok()); + } + + #[test] + fn must_validate_successfully_if_no_import_section_found() { + // given + let contract = r#"(module)"#; + let module = create_module(contract); + + // when + let res = validate_import_section(&module); + + // then + assert!(res.is_ok()); + } +} diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index b96a8b67c..24f47c036 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -17,9 +17,11 @@ use anyhow::{Context, Result}; use super::{metadata, Profile}; -use std::convert::{TryFrom, TryInto}; +use crate::OptimizationPasses; + use std::{ collections::HashSet, + convert::TryFrom, fs, path::{Path, PathBuf}, }; @@ -66,13 +68,25 @@ impl ManifestPath { None } } + + /// Returns the absolute directory path of the manifest. + pub fn absolute_directory(&self) -> Result { + let directory = match self.directory() { + Some(dir) => dir, + None => Path::new("./"), + }; + directory.canonicalize() + } } -impl TryFrom<&PathBuf> for ManifestPath { +impl

TryFrom> for ManifestPath +where + P: AsRef, +{ type Error = anyhow::Error; - fn try_from(value: &PathBuf) -> Result { - ManifestPath::new(value) + fn try_from(value: Option

) -> Result { + value.map_or(Ok(Default::default()), ManifestPath::new) } } @@ -88,6 +102,12 @@ impl AsRef for ManifestPath { } } +impl From for PathBuf { + fn from(path: ManifestPath) -> Self { + path.path + } +} + /// Create, amend and save a copy of the specified `Cargo.toml`. pub struct Manifest { path: ManifestPath, @@ -100,11 +120,7 @@ impl Manifest { /// Create new Manifest for the given manifest path. /// /// The path *must* be to a `Cargo.toml`. - pub fn new

(path: P) -> Result - where - P: TryInto, - { - let manifest_path = path.try_into()?; + pub fn new(manifest_path: ManifestPath) -> Result { let toml = fs::read_to_string(&manifest_path).context("Loading Cargo.toml")?; let toml: value::Table = toml::from_str(&toml)?; @@ -125,14 +141,14 @@ impl Manifest { let lib = self .toml .get_mut("lib") - .ok_or(anyhow::anyhow!("lib section not found"))?; + .ok_or_else(|| anyhow::anyhow!("lib section not found"))?; let crate_types = lib .get_mut("crate-type") - .ok_or(anyhow::anyhow!("crate-type section not found"))?; + .ok_or_else(|| anyhow::anyhow!("crate-type section not found"))?; crate_types .as_array_mut() - .ok_or(anyhow::anyhow!("crate-types should be an Array")) + .ok_or_else(|| anyhow::anyhow!("crate-types should be an Array")) } /// Add a value to the `[lib] crate-types = []` section. @@ -146,6 +162,105 @@ impl Manifest { Ok(self) } + /// Extract `optimization-passes` from `[package.metadata.contract]` + pub fn get_profile_optimization_passes(&mut self) -> Option { + self.toml + .get("package")? + .as_table()? + .get("metadata")? + .as_table()? + .get("contract")? + .as_table()? + .get("optimization-passes") + .map(|val| val.to_string()) + .map(Into::into) + } + + /// Set `optimization-passes` in `[package.metadata.contract]` + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_profile_optimization_passes( + &mut self, + passes: OptimizationPasses, + ) -> Result> { + Ok(self + .toml + .entry("package") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("package section should be a table")? + .entry("metadata") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("metadata section should be a table")? + .entry("contract") + .or_insert(value::Value::Table(Default::default())) + .as_table_mut() + .context("metadata.contract section should be a table")? + .insert( + "optimization-passes".to_string(), + value::Value::String(passes.to_string()), + )) + } + + /// Set the dependency version of `package` to `version`. + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_dependency_version( + &mut self, + dependency: &str, + version: &str, + ) -> Result> { + Ok(self + .toml + .get_mut("dependencies") + .ok_or_else(|| anyhow::anyhow!("[dependencies] section not found"))? + .get_mut(dependency) + .ok_or_else(|| anyhow::anyhow!("{} dependency not found", dependency))? + .as_table_mut() + .ok_or_else(|| anyhow::anyhow!("{} dependency should be a table", dependency))? + .insert("version".into(), value::Value::String(version.into()))) + } + + /// Set the `lib` name to `name`. + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_lib_name(&mut self, name: &str) -> Result> { + Ok(self + .toml + .get_mut("lib") + .ok_or_else(|| anyhow::anyhow!("[lib] section not found"))? + .as_table_mut() + .ok_or_else(|| anyhow::anyhow!("[lib] should be a table"))? + .insert("name".into(), value::Value::String(name.into()))) + } + + /// Set the `package` name to `name`. + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_package_name(&mut self, name: &str) -> Result> { + Ok(self + .toml + .get_mut("package") + .ok_or_else(|| anyhow::anyhow!("[package] section not found"))? + .as_table_mut() + .ok_or_else(|| anyhow::anyhow!("[package] should be a table"))? + .insert("name".into(), value::Value::String(name.into()))) + } + + /// Set the `lib` path to `path`. + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_lib_path(&mut self, path: &str) -> Result> { + Ok(self + .toml + .get_mut("lib") + .ok_or_else(|| anyhow::anyhow!("[lib] section not found"))? + .as_table_mut() + .ok_or_else(|| anyhow::anyhow!("[lib] should be a table"))? + .insert("path".into(), value::Value::String(path.into()))) + } + /// Set `[profile.release]` lto flag pub fn with_profile_release_lto(&mut self, enabled: bool) -> Result<&mut Self> { let lto = self @@ -176,12 +291,12 @@ impl Manifest { .or_insert(value::Value::Table(Default::default())); let release = profile .as_table_mut() - .ok_or(anyhow::anyhow!("profile should be a table"))? + .ok_or_else(|| anyhow::anyhow!("profile should be a table"))? .entry("release") .or_insert(value::Value::Table(Default::default())); release .as_table_mut() - .ok_or(anyhow::anyhow!("release should be a table")) + .ok_or_else(|| anyhow::anyhow!("release should be a table")) } /// Remove a value from the `[lib] crate-types = []` section @@ -203,16 +318,16 @@ impl Manifest { .or_insert(value::Value::Table(Default::default())); let members = workspace .as_table_mut() - .ok_or(anyhow::anyhow!("workspace should be a table"))? + .ok_or_else(|| anyhow::anyhow!("workspace should be a table"))? .entry("members") .or_insert(value::Value::Array(Default::default())) .as_array_mut() - .ok_or(anyhow::anyhow!("members should be an array"))?; + .ok_or_else(|| anyhow::anyhow!("members should be an array"))?; if members.contains(&LEGACY_METADATA_PACKAGE_PATH.into()) { // warn user if they have legacy metadata generation artifacts use colored::Colorize; - println!( + eprintln!( "{} {} {} {}", "warning:".yellow().bold(), "please remove".bold(), @@ -252,7 +367,11 @@ impl Manifest { let to_absolute = |value_id: String, existing_path: &mut value::Value| -> Result<()> { let path_str = existing_path .as_str() - .ok_or(anyhow::anyhow!("{} should be a string", value_id))?; + .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; + #[cfg(windows)] + // On Windows path separators are `\`, hence we need to replace the `/` in + // e.g. `src/lib.rs`. + let path_str = &path_str.replace("/", "\\"); let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); @@ -263,10 +382,9 @@ impl Manifest { }; let rewrite_path = |table_value: &mut value::Value, table_section: &str, default: &str| { - let table = table_value.as_table_mut().ok_or(anyhow::anyhow!( - "'[{}]' section should be a table", - table_section - ))?; + let table = table_value.as_table_mut().ok_or_else(|| { + anyhow::anyhow!("'[{}]' section should be a table", table_section) + })?; match table.get_mut("path") { Some(existing_path) => { @@ -300,7 +418,7 @@ impl Manifest { if let Some(bin) = self.toml.get_mut("bin") { let bins = bin .as_array_mut() - .ok_or(anyhow::anyhow!("'[[bin]]' section should be a table array"))?; + .ok_or_else(|| anyhow::anyhow!("'[[bin]]' section should be a table array"))?; // Rewrite `[[bin]] path =` value to an absolute path. for bin in bins { @@ -316,7 +434,7 @@ impl Manifest { .collect::>(); let table = dependencies .as_table_mut() - .ok_or(anyhow::anyhow!("dependencies should be a table"))?; + .ok_or_else(|| anyhow::anyhow!("dependencies should be a table"))?; for (name, value) in table { let package_name = { let package = value.get("package"); @@ -352,25 +470,25 @@ impl Manifest { fs::create_dir_all(&dir).context(format!("Creating directory '{}'", dir.display()))?; - let name = self + let contract_package_name = self .toml - .get("lib") - .ok_or(anyhow::anyhow!("lib section not found"))? + .get("package") + .ok_or_else(|| anyhow::anyhow!("package section not found"))? .get("name") - .ok_or(anyhow::anyhow!("[lib] name field not found"))? + .ok_or_else(|| anyhow::anyhow!("[package] name field not found"))? .as_str() - .ok_or(anyhow::anyhow!("[lib] name should be a string"))?; + .ok_or_else(|| anyhow::anyhow!("[package] name should be a string"))?; let ink_metadata = self .toml .get("dependencies") - .ok_or(anyhow::anyhow!("[dependencies] section not found"))? + .ok_or_else(|| anyhow::anyhow!("[dependencies] section not found"))? .get("ink_metadata") - .ok_or(anyhow::anyhow!("{} dependency not found", name))? + .ok_or_else(|| anyhow::anyhow!("ink_metadata dependency not found"))? .as_table() - .ok_or(anyhow::anyhow!("{} dependency should be a table", name))?; + .ok_or_else(|| anyhow::anyhow!("ink_metadata dependency should be a table"))?; - metadata::generate_package(dir, name, ink_metadata.clone())?; + metadata::generate_package(dir, contract_package_name, ink_metadata.clone())?; } let updated_toml = toml::to_string(&self.toml)?; @@ -383,8 +501,35 @@ impl Manifest { } } -fn crate_type_exists(crate_type: &str, crate_types: &value::Array) -> bool { +fn crate_type_exists(crate_type: &str, crate_types: &[value::Value]) -> bool { crate_types .iter() .any(|v| v.as_str().map_or(false, |s| s == crate_type)) } + +#[cfg(test)] +mod test { + use super::ManifestPath; + use crate::util::tests::with_tmp_dir; + use std::fs; + + #[test] + fn must_return_absolute_path_from_absolute_path() { + with_tmp_dir(|path| { + // given + let cargo_toml_path = path.join("Cargo.toml"); + let _ = fs::File::create(&cargo_toml_path).expect("file creation failed"); + let manifest_path = + ManifestPath::new(cargo_toml_path).expect("manifest path creation failed"); + + // when + let absolute_path = manifest_path + .absolute_directory() + .expect("absolute path extraction failed"); + + // then + assert_eq!(absolute_path.as_path(), path); + Ok(()) + }) + } +} diff --git a/src/workspace/metadata.rs b/src/workspace/metadata.rs index 0f82bf3ad..76d356eca 100644 --- a/src/workspace/metadata.rs +++ b/src/workspace/metadata.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs index 6489a126e..733e8700f 100644 --- a/src/workspace/mod.rs +++ b/src/workspace/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -52,11 +52,14 @@ impl Workspace { .packages .iter() .find(|p| p.id == *package_id) - .expect(&format!( - "Package '{}' is a member and should be in the packages list", - package_id - )); - let manifest = Manifest::new(&package.manifest_path)?; + .unwrap_or_else(|| { + panic!( + "Package '{}' is a member and should be in the packages list", + package_id + ) + }); + let manifest_path = ManifestPath::new(&package.manifest_path)?; + let manifest = Manifest::new(manifest_path)?; Ok((package_id.clone(), (package.clone(), manifest))) }; @@ -71,7 +74,7 @@ impl Workspace { } Ok(Workspace { - workspace_root: metadata.workspace_root.clone(), + workspace_root: metadata.workspace_root.clone().into(), root_package: root_package.clone(), members, }) @@ -96,32 +99,43 @@ impl Workspace { Ok(self) } - /// Amend the workspace manifest using the supplied function. - pub fn with_workspace_manifest(&mut self, f: F) -> Result<&mut Self> + /// Amend the manifest of the package at `package_path` using the supplied function. + pub fn with_contract_manifest(&mut self, package_path: &Path, f: F) -> Result<&mut Self> where F: FnOnce(&mut Manifest) -> Result<()>, { - let workspace_root = self.workspace_root.clone(); - let workspace_manifest = self + let manifest = self .members .iter_mut() .find_map(|(_, (_, manifest))| { - if manifest.path().directory() == Some(&workspace_root) { + // `package_path` is always absolute and canonicalized. Thus we need to + // canonicalize the manifest's directory path as well in order to compare + // both of them. + let manifest_path = manifest.path().directory()?; + let manifest_path = manifest_path + .canonicalize() + .unwrap_or_else(|_| panic!("Cannot canonicalize {}", manifest_path.display())); + if manifest_path == package_path { Some(manifest) } else { None } }) - .ok_or(anyhow::anyhow!( - "The workspace root package should be a workspace member" - ))?; - f(workspace_manifest)?; + .ok_or_else(|| { + anyhow::anyhow!( + "Cannot find package with package path {} in workspace members", + package_path.display(), + ) + })?; + f(manifest)?; Ok(self) } - /// Generates a package to invoke for generating contract metadata - pub(super) fn with_metadata_gen_package(&mut self) -> Result<&mut Self> { - self.with_workspace_manifest(|manifest| { + /// Generates a package to invoke for generating contract metadata. + /// + /// The contract metadata will be generated for the package found at `package_path`. + pub(super) fn with_metadata_gen_package(&mut self, package_path: PathBuf) -> Result<&mut Self> { + self.with_contract_manifest(&package_path, |manifest| { manifest.with_metadata_package()?; Ok(()) }) diff --git a/src/workspace/profile.rs b/src/workspace/profile.rs index cf44fa099..df40e5268 100644 --- a/src/workspace/profile.rs +++ b/src/workspace/profile.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2020 Parity Technologies (UK) Ltd. +// Copyright 2018-2021 Parity Technologies (UK) Ltd. // This file is part of cargo-contract. // // cargo-contract is free software: you can redistribute it and/or modify @@ -72,7 +72,7 @@ pub enum OptLevel { } impl OptLevel { - fn to_toml_value(&self) -> value::Value { + fn to_toml_value(self) -> value::Value { match self { OptLevel::NoOptimizations => 0.into(), OptLevel::O1 => 1.into(), @@ -99,7 +99,7 @@ pub enum Lto { } impl Lto { - fn to_toml_value(&self) -> value::Value { + fn to_toml_value(self) -> value::Value { match self { Lto::ThinLocal => false.into(), Lto::Fat => "fat".into(), @@ -118,7 +118,7 @@ pub enum PanicStrategy { } impl PanicStrategy { - fn to_toml_value(&self) -> value::Value { + fn to_toml_value(self) -> value::Value { match self { PanicStrategy::Unwind => "unwind".into(), PanicStrategy::Abort => "abort".into(), diff --git a/templates/new/_Cargo.toml b/templates/new/_Cargo.toml index df71d79d9..341303636 100644 --- a/templates/new/_Cargo.toml +++ b/templates/new/_Cargo.toml @@ -3,15 +3,17 @@ name = "{{name}}" version = "0.1.0" authors = ["[your_name] <[your_email]>"] edition = "2018" +resolver = "2" [dependencies] -ink_metadata = { git = "https://github.com/paritytech/ink", branch = "master", package = "ink_metadata", default-features = false, features = ["derive"], optional = true } -ink_primitives = { git = "https://github.com/paritytech/ink", branch = "master", default-features = false } -ink_core = { git = "https://github.com/paritytech/ink", branch = "master", package = "ink_core", default-features = false } -ink_lang = { git = "https://github.com/paritytech/ink", branch = "master", package = "ink_lang", default-features = false } +ink_primitives = { version = "3.0.0-rc5", default-features = false } +ink_metadata = { version = "3.0.0-rc5", default-features = false, features = ["derive"], optional = true } +ink_env = { version = "3.0.0-rc5", default-features = false } +ink_storage = { version = "3.0.0-rc5", default-features = false } +ink_lang = { version = "3.0.0-rc5", default-features = false } -scale = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive"] } -scale-info = { version = "0.3", default-features = false, features = ["derive"], optional = true } +scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] } +scale-info = { version = "0.6.0", default-features = false, features = ["derive"], optional = true } [lib] name = "{{name}}" @@ -25,7 +27,8 @@ crate-type = [ default = ["std"] std = [ "ink_metadata/std", - "ink_core/std", + "ink_env/std", + "ink_storage/std", "ink_primitives/std", "scale/std", "scale-info/std", diff --git a/templates/new/lib.rs b/templates/new/lib.rs index 6c850eab9..45c4c5edd 100644 --- a/templates/new/lib.rs +++ b/templates/new/lib.rs @@ -2,14 +2,14 @@ use ink_lang as ink; -#[ink::contract(version = "0.1.0")] +#[ink::contract] mod {{name}} { /// Defines the storage of your contract. /// Add new fields to the below struct in order /// to add new static storage fields to your contract. #[ink(storage)] - struct {{camel_name}} { + pub struct {{camel_name}} { /// Stores a single `bool` value on the storage. value: bool, } @@ -17,7 +17,7 @@ mod {{name}} { impl {{camel_name}} { /// Constructor that initializes the `bool` value to the given `init_value`. #[ink(constructor)] - fn new(init_value: bool) -> Self { + pub fn new(init_value: bool) -> Self { Self { value: init_value } } @@ -25,7 +25,7 @@ mod {{name}} { /// /// Constructors can delegate to other constructors. #[ink(constructor)] - fn default() -> Self { + pub fn default() -> Self { Self::new(Default::default()) } @@ -33,13 +33,13 @@ mod {{name}} { /// This one flips the value of the stored `bool` from `true` /// to `false` and vice versa. #[ink(message)] - fn flip(&mut self) { + pub fn flip(&mut self) { self.value = !self.value; } /// Simply returns the current value of our `bool`. #[ink(message)] - fn get(&self) -> bool { + pub fn get(&self) -> bool { self.value } } @@ -52,15 +52,18 @@ mod {{name}} { /// Imports all the definitions from the outer scope so we can use them here. use super::*; + /// Imports `ink_lang` so we can use `#[ink::test]`. + use ink_lang as ink; + /// We test if the default constructor does its job. - #[test] + #[ink::test] fn default_works() { let {{name}} = {{camel_name}}::default(); assert_eq!({{name}}.get(), false); } /// We test a simple use case of our contract. - #[test] + #[ink::test] fn it_works() { let mut {{name}} = {{camel_name}}::new(false); assert_eq!({{name}}.get(), false);