diff --git a/.github/workflows/iroha2-dev-pr-static.yml b/.github/workflows/iroha2-dev-pr-static.yml index 2def0484fe6..76f2d9a90d2 100644 --- a/.github/workflows/iroha2-dev-pr-static.yml +++ b/.github/workflows/iroha2-dev-pr-static.yml @@ -32,9 +32,3 @@ jobs: - name: Verify iroha_data_model still supports no_std run: cargo nono check --package iroha_data_model --no-default-features if: always() - - - name: Documentation check - run: | - cargo doc --no-deps --quiet - ./scripts/check_docs.sh - if: always() diff --git a/.github/workflows/iroha2-dev-pr-wasm.yaml b/.github/workflows/iroha2-dev-pr-wasm.yaml index fe4f65ea579..7681cce3d04 100644 --- a/.github/workflows/iroha2-dev-pr-wasm.yaml +++ b/.github/workflows/iroha2-dev-pr-wasm.yaml @@ -12,6 +12,8 @@ on: - "wasm/**.json" - "wasm/**.toml" - "wasm/**.yml" + - "data_model/**.rs" + - "data_model/**.toml" env: RUSTC_BOOTSTRAP: 1 diff --git a/.github/workflows/iroha2-dev-pr.yml b/.github/workflows/iroha2-dev-pr.yml index b29a20c3a20..57409efe7c2 100644 --- a/.github/workflows/iroha2-dev-pr.yml +++ b/.github/workflows/iroha2-dev-pr.yml @@ -26,12 +26,12 @@ jobs: - uses: actions/checkout@v2 - uses: Swatinem/rust-cache@v1 - name: Run tests - run: mold -run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2 + run: mold --run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2 - name: Run iroha tests with network mock - run: mold -run cargo test --quiet --features mock -- --ignored --skip unstable_network --test-threads 2 + run: mold --run cargo test --quiet --features mock -- --ignored --skip unstable_network --test-threads 2 working-directory: core/test_network - name: Run iroha_actor deadlock detection tests - run: mold -run cargo test --quiet --features deadlock_detection -- --skip unstable_network --test-threads 2 + run: mold --run cargo test --quiet --features deadlock_detection -- --skip unstable_network --test-threads 2 working-directory: actor if: always() - name: Verify wasm smartcontracts are able to build @@ -39,10 +39,20 @@ jobs: working-directory: wasm env: RUSTC_BOOTSTRAP: 1 + - name: Documentation check + run: | + cargo doc --no-deps --quiet + ./scripts/check.sh docs + if: always() + - name: Check genesis + run: | + ./scripts/check.sh genesis + if: always() # Coverage is both in PR and in push pipelines so that: # 1. PR can get coverage report from bot. - # 2. Coverage bot can have results from `iroha2-dev` to report coverage changes. + # 2. Coverage bot can have results from + # `iroha2-dev` to report coverage changes. coverage: runs-on: ubuntu-latest container: @@ -51,13 +61,19 @@ jobs: - uses: actions/checkout@v2 - uses: Swatinem/rust-cache@v1 - name: Run tests - run: mold -run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2 || true + run: | + mold --run cargo +nightly-2022-04-20 test \ + --quiet --workspace --no-fail-fast -- \ + --skip unstable_network --skip ui --test-threads 3 env: - RUSTFLAGS: "-Zinstrument-coverage" + RUSTFLAGS: "-C instrument-coverage" LLVM_PROFILE_FILE: "iroha-%p-%m.profraw" - name: Generate a grcov coverage report - run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + run: | + grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + if: always() - name: Upload coverage to codecov.io uses: codecov/codecov-action@v1 + if: always() with: file: lcov.info diff --git a/.github/workflows/iroha2-dev.yml b/.github/workflows/iroha2-dev.yml index 7eced522db0..17ee0508766 100644 --- a/.github/workflows/iroha2-dev.yml +++ b/.github/workflows/iroha2-dev.yml @@ -52,14 +52,14 @@ jobs: with: context: . push: true - tags: hyperledger/iroha2:crypto-cli-dev + tags: hyperledger/iroha2:kagami-dev build-args: | TARGET_DIR=release PROFILE=--release - BIN=iroha_crypto_cli + BIN=kagami - name: Build and push load-rs:dev docker image - run: | + run: | sleep 10s echo "wait to other workflow" - uses: convictional/trigger-workflow-and-wait@v1.6.0 @@ -112,11 +112,11 @@ jobs: uses: actions/upload-artifact@v2 with: name: cargo-crypto-cli-build-release - path: target/release/iroha_crypto_cli + path: target/release/kagami - name: Run schema generation run: | mkdir -p target/schema - cargo run -p iroha_schema_bin > target/schema/schema.json + cargo run --bin kagami -- schema > target/schema/schema.json - name: Upload schema uses: actions/upload-artifact@v2 with: @@ -145,7 +145,8 @@ jobs: apt-get update apt-get install -y --no-install-recommends lz4 jq - name: Print debug telemetry info - run: ./scripts/analyze_telemetry.sh target/telemetry/debug.json.lz4 >target/telemetry/debug.md + run: | + ./scripts/analyze_telemetry.sh target/telemetry/debug.json.lz4 >target/telemetry/debug.md - name: Print release telemetry info run: ./scripts/analyze_telemetry.sh target/telemetry/release.json.lz4 >target/telemetry/release.md - name: Print debug telemetry info @@ -175,7 +176,8 @@ jobs: # Coverage is both in PR and in push pipelines so that: # 1. PR can get coverage report from bot. - # 2. Coverage bot can have results from `iroha2-dev` to report coverage changes. + # 2. Coverage bot can have results from + # `iroha2-dev` to report coverage changes. coverage: runs-on: ubuntu-latest container: @@ -184,14 +186,19 @@ jobs: - uses: actions/checkout@v2 - uses: Swatinem/rust-cache@v1 - name: Run tests - run: mold -run cargo test --workspace --no-fail-fast -- --skip unstable_network || true + run: | + mold --run cargo +nightly-2022-04-20 test \ + --quiet --workspace --no-fail-fast -- \ + --skip unstable_network --skip ui --test-threads 3 env: - RUSTFLAGS: "-Zinstrument-coverage" - RUSTC_BOOTSTRAP: 1 + RUSTFLAGS: "-C instrument-coverage" LLVM_PROFILE_FILE: "iroha-%p-%m.profraw" - name: Generate a grcov coverage report - run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + run: | + grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + if: always() - name: Upload coverage to codecov.io uses: codecov/codecov-action@v1 + if: always() with: file: lcov.info diff --git a/.github/workflows/iroha2-push-nightly.yml b/.github/workflows/iroha2-push-nightly.yml index fcc7c7cb822..5780bd6b07c 100644 --- a/.github/workflows/iroha2-push-nightly.yml +++ b/.github/workflows/iroha2-push-nightly.yml @@ -38,8 +38,8 @@ jobs: with: context: . push: true - tags: hyperledger/iroha2:crypto-cli-dev-nightly-${{ github.sha }} + tags: hyperledger/iroha2:kagami-dev-nightly-${{ github.sha }} build-args: | TARGET_DIR=release PROFILE=--release - BIN=iroha_crypto_cli + BIN=kagami diff --git a/.github/workflows/iroha2.yml b/.github/workflows/iroha2.yml index 7b8ef3f70e5..1e29e80f613 100644 --- a/.github/workflows/iroha2.yml +++ b/.github/workflows/iroha2.yml @@ -9,6 +9,10 @@ env: RUSTC_BOOTSTRAP: 1 jobs: + # Coverage is both in PR and in push pipelines so that: + # 1. PR can get coverage report from bot. + # 2. Coverage bot can have results from + # `iroha2-dev` to report coverage changes. coverage: runs-on: ubuntu-latest container: @@ -17,17 +21,24 @@ jobs: - uses: actions/checkout@v2 - uses: Swatinem/rust-cache@v1 - name: Run tests - run: mold -run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2 || true + run: | + mold --run cargo +nightly-2022-04-20 test \ + --quiet --workspace --no-fail-fast -- \ + --skip unstable_network --skip ui --test-threads 3 env: - RUSTFLAGS: "-Zinstrument-coverage" + RUSTFLAGS: "-C instrument-coverage" LLVM_PROFILE_FILE: "iroha-%p-%m.profraw" - name: Generate a grcov coverage report - run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + run: | + grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info + if: always() - name: Upload coverage to codecov.io uses: codecov/codecov-action@v1 + if: always() with: file: lcov.info + deploy: runs-on: ubuntu-latest container: @@ -59,7 +70,7 @@ jobs: with: context: . push: true - tags: hyperledger/iroha2:stable-client-cli + tags: hyperledger/iroha2:client-cli-stable build-args: | TARGET_DIR=release PROFILE=--release @@ -69,11 +80,11 @@ jobs: with: context: . push: true - tags: hyperledger/iroha2:stable-crypto-cli + tags: hyperledger/iroha2:kagami-stable build-args: | TARGET_DIR=release PROFILE=--release - BIN=iroha_crypto_cli + BIN=kagami - name: Build and push load-rs:release docker image run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ced8c0e32d..e413438cb1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ The following is a short set of guidelines for contributing to Iroha. * Fix your issue of choice. * Write [tests](https://doc.rust-lang.org/cargo/commands/cargo-test.html). Ensure they all pass (`cargo test`). * Fix [`clippy`](https://lib.rs/crates/cargo-lints) warnings: `cargo lints clippy --workspace --benches --tests --examples --all-features` -* Format code `cargo +nightly fmt --all` and generate docs `cargo run --bin iroha_docs >"docs/source/references/config.md" && git add "docs/source/references/config.md"` +* Format code `cargo +nightly fmt --all` and generate docs `cargo run --bin kagami -- docs >"docs/source/references/config.md" && git add "docs/source/references/config.md"` * `git pull -r hyperledger iroha2-dev`, `git commit -s`, `git push `, and [create a pull request](https://github.com/hyperledger/iroha/compare) to the `iroha2-dev` branch on GitHub. ### Reporting Bugs @@ -149,7 +149,7 @@ Set the `LOG_FILE_PATH` environment variable to an appropriate location to store - Limit the first line of your commit message to 50 characters or less. - The first line of your commit message should contain the summary of the work you've done. If you need more than one line, leave a blank line between each paragraph and describe your changes in the middle. The last line must be the sign-off. - Use the [Git Rebase Workflow](https://git-rebase.io/). Avoid using `git pull` use `git pull --rebase` instead. -- If you modify the Schema (check by generating the schema with `iroha_schema_bin` and diff), you should make all changes to the schema in a separate commit with the message `[schema]`. +- If you modify the Schema (check by generating the schema with `kagami schema` and diff), you should make all changes to the schema in a separate commit with the message `[schema]`. - Generally, try to stick to one commit per meaningful change. - If you fixed several issues in one PR, give them separate commits. - As mentioned previously changes to the `schema` and the API should be done in appropriate commits separate from the rest of your work. diff --git a/Cargo.lock b/Cargo.lock index 19d71c2bebd..429cc11b50c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,13 +465,9 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term", - "atty", "bitflags", - "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", - "vec_map", ] [[package]] @@ -486,7 +482,7 @@ dependencies = [ "clap_lex", "indexmap", "lazy_static", - "strsim 0.10.0", + "strsim", "termcolor", "textwrap 0.15.0", ] @@ -497,7 +493,7 @@ version = "3.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro-error", "proc-macro2", "quote", @@ -1491,15 +1487,6 @@ dependencies = [ "http", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -1693,7 +1680,7 @@ dependencies = [ "iroha_macro", "iroha_p2p", "iroha_permissions_validators", - "iroha_schema_bin", + "iroha_schema_gen", "iroha_telemetry", "iroha_version", "parity-scale-codec", @@ -1770,6 +1757,7 @@ dependencies = [ name = "iroha_client_cli" version = "2.0.0-pre-rc.3" dependencies = [ + "clap 3.1.10", "color-eyre", "dialoguer", "futures", @@ -1777,7 +1765,6 @@ dependencies = [ "iroha_crypto", "iroha_data_model", "serde_json", - "structopt", ] [[package]] @@ -1859,17 +1846,6 @@ dependencies = [ "ursa", ] -[[package]] -name = "iroha_crypto_cli" -version = "2.0.0-pre-rc.3" -dependencies = [ - "clap 2.34.0", - "color-eyre", - "hex", - "iroha_crypto", - "serde_json", -] - [[package]] name = "iroha_data_model" version = "2.0.0-pre-rc.3" @@ -1922,17 +1898,6 @@ dependencies = [ "trybuild", ] -[[package]] -name = "iroha_docs" -version = "2.0.0-pre-rc.3" -dependencies = [ - "color-eyre", - "iroha", - "iroha_config", - "iroha_core", - "serde_json", -] - [[package]] name = "iroha_futures" version = "2.0.0-pre-rc.3" @@ -2022,25 +1987,25 @@ dependencies = [ ] [[package]] -name = "iroha_schema_bin" +name = "iroha_schema_derive" version = "2.0.0-pre-rc.3" dependencies = [ - "iroha_core", - "iroha_crypto", - "iroha_data_model", "iroha_schema", - "serde_json", + "proc-macro2", + "quote", + "syn", + "trybuild", ] [[package]] -name = "iroha_schema_derive" +name = "iroha_schema_gen" version = "2.0.0-pre-rc.3" dependencies = [ + "iroha_core", + "iroha_crypto", + "iroha_data_model", "iroha_schema", - "proc-macro2", - "quote", - "syn", - "trybuild", + "serde_json", ] [[package]] @@ -2173,6 +2138,22 @@ dependencies = [ "sha2", ] +[[package]] +name = "kagami" +version = "2.0.0-pre-rc.3" +dependencies = [ + "clap 3.1.10", + "color-eyre", + "hex", + "iroha", + "iroha_config", + "iroha_core", + "iroha_crypto", + "iroha_data_model", + "iroha_schema_gen", + "serde_json", +] + [[package]] name = "keccak" version = "0.1.0" @@ -2568,7 +2549,7 @@ dependencies = [ "iroha_crypto", "iroha_data_model", "iroha_schema", - "iroha_schema_bin", + "iroha_schema_gen", "iroha_version", "parity-scale-codec", ] @@ -3413,42 +3394,12 @@ dependencies = [ "num-traits", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "subtle" version = "2.4.1" @@ -3956,12 +3907,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - [[package]] name = "unicode-width" version = "0.1.9" @@ -4069,12 +4014,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "vergen" version = "5.1.17" diff --git a/Cargo.toml b/Cargo.toml index d224ef5339c..6705c72ea9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,12 +9,11 @@ members = [ "config", "config/derive", "core", - "core/docs", "core/test_network", "crypto", - "tools/crypto_cli", "tools/kura_inspector", "tools/parity_scale_decoder", + "tools/kagami", "data_model", "data_model/primitives", "futures", @@ -25,7 +24,7 @@ members = [ "p2p", "permissions_validators", "schema", - "schema/bin", + "schema/gen", "schema/derive", "substrate", "telemetry", diff --git a/README.md b/README.md index 1b41d72f32f..51fde0fb649 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Iroha project mainly consists of the following crates: * [`iroha_config`](config), which handles configuration, generating documentation for options and run-time changes * [`iroha_core`](core) — the primary library used by all other crates which includes the peer's endpoint management * [`iroha_crypto`](crypto) — cryptographic aspects of Iroha -* [`iroha_crypto_cli`](crypto_cli), which is used to generate cryptographic keys +* [`kagami`](tools/kagami), which is used to generate cryptographic keys, default genesis, configuration reference, and schema * [`iroha_data_model`](data_model), which defines common data models in Iroha * [`iroha_futures`](futures) — technical crate used for `async` programming * [`iroha_logger`](logger), which uses `tracing` to provide logging facilities diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 919601480e3..53aaba50f8b 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -18,7 +18,7 @@ bridge = ["iroha_core/bridge"] dex = ["iroha_core/dex"] telemetry = ["iroha_telemetry", "iroha_core/telemetry"] dev-telemetry = ["iroha_core/dev-telemetry", "iroha_telemetry"] -schema-endpoint = ["iroha_schema_bin"] +schema-endpoint = ["iroha_schema_gen"] test-network = [] [badges] @@ -39,7 +39,7 @@ iroha_version = { version = "=2.0.0-pre-rc.3", path = "../version", features = [ iroha_config = { version = "=2.0.0-pre-rc.3", path = "../config" } iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../crypto" } iroha_p2p = { version = "=2.0.0-pre-rc.3", path = "../p2p" } -iroha_schema_bin = { version = "=2.0.0-pre-rc.3", path = "../schema/bin", optional = true } +iroha_schema_gen = { version = "=2.0.0-pre-rc.3", path = "../schema/gen", optional = true } eyre = "0.6.5" futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } diff --git a/cli/README.md b/cli/README.md index 4850f0a5f2d..fc2152a97b5 100644 --- a/cli/README.md +++ b/cli/README.md @@ -49,12 +49,12 @@ This flag can be combined with the `--features` flag in order to precisely speci ### Generating Keys -We highly recommend that any non-testing deployment generate a new key pair, with the recommended algorithm `Ed25519`. For convenience, you can use the provided [`iroha_crypto_cli`](../crypto_cli/README.md). For example, +We highly recommend that any non-testing deployment generate a new key pair, with the recommended algorithm `Ed25519`. For convenience, you can use the provided [`kagami`](../tools/kagami/README.md). For example, ```bash -cargo run --bin iroha_crypto_cli +cargo run --bin kagami -- crypto ``` should produce @@ -65,13 +65,13 @@ Private key: 0311152fad9308482f51ca2832fdfab18e1c74f36c6adb198e3ef0213fe42fd8bdf Digest function: ed25519 ``` -**NOTE**: to see the command-line options for `iroha_crypto_cli` you must first terminate the arguments passed to `cargo`, so the command for running the `iroha_crypto_cli` binary with JSON formatting is +**NOTE**: to see the command-line options for `kagami` you must first terminate the arguments passed to `cargo`, so the command for running the `kagami` binary with JSON formatting is ```bash -cargo run --bin iroha_crypto_cli -- --json +cargo run --bin kagami -- crypto --json ``` -**NOTE**: The `iroha_crypto_cli` binary can be run without `cargo` using the `/target/release/iroha_crypto_cli` binary. +**NOTE**: The `kagami` binary can be run without `cargo` using the `/target/release/kagami` binary. ### Configuration file diff --git a/cli/src/torii/mod.rs b/cli/src/torii/mod.rs index 28c967324e8..1eb46527774 100644 --- a/cli/src/torii/mod.rs +++ b/cli/src/torii/mod.rs @@ -1,5 +1,6 @@ -//! This module contains incoming requests handling logic of Iroha. -//! `Torii` is used to receive, accept and route incoming instructions, queries and messages. +//! Translates to gateway. Request handling logic of Iroha. `Torii` +//! is used to receive, accept and route incoming instructions, +//! queries and messages. use std::{convert::Infallible, fmt::Debug, net::ToSocketAddrs, sync::Arc}; diff --git a/cli/src/torii/routing.rs b/cli/src/torii/routing.rs index cef25eae20e..9795263de17 100644 --- a/cli/src/torii/routing.rs +++ b/cli/src/torii/routing.rs @@ -153,7 +153,7 @@ async fn handle_health() -> Json { #[iroha_futures::telemetry_future] #[cfg(feature = "schema-endpoint")] async fn handle_schema() -> Json { - reply::json(&iroha_schema_bin::build_schemas()) + reply::json(&iroha_schema_gen::build_schemas()) } #[iroha_futures::telemetry_future] diff --git a/client/build.rs b/client/build.rs index 94d2e1aed79..1960300971c 100644 --- a/client/build.rs +++ b/client/build.rs @@ -14,7 +14,8 @@ fn main() { Path::new(&manifest_dir).join("tests/integration/create_nft_for_every_user_smartcontract"); let out_dir = env::var_os("OUT_DIR").expect("Expected `OUT_DIR` environment variable"); - println!("cargo:rerun-if-changed=.."); + // TODO: check if this was causing the recursive loop. + // println!("cargo:rerun-if-changed=.."); let fmt = Command::new("cargo") // Removing environment variable to avoid @@ -26,24 +27,32 @@ fn main() { .expect("Failed to run `cargo fmt` on smartcontract"); assert!(fmt.success(), "Can't format smartcontract"); - let build = Command::new("cargo") + let instrumenting_coverage = if let Ok(flags) = env::var("RUSTFLAGS") { + flags.contains("instrument-coverage") + } else { + false + }; + + if instrumenting_coverage { + let build = Command::new("cargo") // Removing environment variable to avoid // `error: infinite recursion detected` when running `cargo lints` - .env_remove("RUST_RECURSION_COUNT") - .env("CARGO_TARGET_DIR", out_dir) - .current_dir(smartcontract_path) - .args(&[ - "+nightly-2022-04-20", - "build", - "--release", - "-Z", - "build-std", - "-Z", - "build-std-features=panic_immediate_abort", - "--target", - "wasm32-unknown-unknown", - ]) - .status() - .expect("Failed to run `cargo build` on smartcontract"); - assert!(build.success(), "Can't build smartcontract") + .env_remove("RUST_RECURSION_COUNT") + .env("CARGO_TARGET_DIR", out_dir) + .current_dir(smartcontract_path) + .args(&[ + "+nightly-2022-04-20", + "build", + "--release", + "-Z", + "build-std", + "-Z", + "build-std-features=panic_immediate_abort", + "--target", + "wasm32-unknown-unknown", + ]) + .status() + .expect("Failed to run `cargo build` on smartcontract"); + assert!(build.success(), "Can't build smartcontract") + } } diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index b30a8b89f5a..92b9ee7feb7 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -1,12 +1,15 @@ #![allow(clippy::restriction)] -use std::{str::FromStr as _, time::Duration}; +use std::{collections::BTreeMap, str::FromStr as _, time::Duration}; use eyre::{eyre, Result}; use iroha_client::client::{self, Client}; use iroha_core::{prelude::AllowAll, smartcontracts::permissions::ValidatorBuilder}; use iroha_data_model::{permissions::Permissions, prelude::*}; -use iroha_permissions_validators::public_blockchain::transfer; +use iroha_permissions_validators::public_blockchain::{ + key_value::{CAN_REMOVE_KEY_VALUE_IN_USER_METADATA, CAN_SET_KEY_VALUE_IN_USER_METADATA}, + transfer, +}; use test_network::{Peer as TestPeer, *}; use tokio::runtime::Runtime; @@ -122,3 +125,33 @@ fn register_role_with_empty_token_params() -> Result<()> { // TODO: When we have more sane default permissions, see if we can // test more about whether or not roles actually work. + +/// Test meant to mirror the test of the same name in the Iroha Kotlin +/// SDK. This doesn't actually test the functionality of the role +/// granted, merely that the role can be constructed and +/// registered. Once @appetrosyan (me) is onboarded into the Kotlin +/// SDK, I'll update both tests to actually verify functionality. +#[test] +fn register_metadata_role() -> Result<()> { + let (_rt, _peer, mut test_client) = ::start_test_with_runtime(); + wait_for_genesis_committed(&vec![test_client.clone()], 0); + + let bob_id = ::Id::from_str("bob@wonderland")?; + let register_bob = RegisterBox::new(Account::new(bob_id.clone(), [])); + test_client.submit_blocking(register_bob)?; + + let role_id = iroha_data_model::role::Id::new("USER_METADATA_ACCESS".parse::()?); + let mut permissions = Permissions::new(); + let mut params = BTreeMap::new(); + params.insert(Name::from_str("account_id")?, bob_id.into()); + permissions.insert( + PermissionToken::new(CAN_SET_KEY_VALUE_IN_USER_METADATA.clone()) + .with_params(params.clone()), + ); + permissions.insert( + PermissionToken::new(CAN_REMOVE_KEY_VALUE_IN_USER_METADATA.clone()).with_params(params), + ); + let register_role = RegisterBox::new(Role::new(role_id, permissions)); + test_client.submit(register_role)?; + Ok(()) +} diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index 85590873ab9..13777b4a0cf 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -170,6 +170,7 @@ fn pre_commit_trigger_should_be_executed() -> Result<()> { } #[test] +#[ignore = "flaky and unreliable. Re-enable once performance improvements are made"] fn mint_nft_for_every_user_every_1_sec() -> Result<()> { const TRIGGER_PERIOD_MS: u64 = 1000; const EXPECTED_COUNT: u64 = 4; diff --git a/client/tests/integration/unregister_peer.rs b/client/tests/integration/unregister_peer.rs index 6650540355d..18ba7a3c0f8 100644 --- a/client/tests/integration/unregister_peer.rs +++ b/client/tests/integration/unregister_peer.rs @@ -8,8 +8,9 @@ use test_network::*; use super::Configuration; +// Note the test is marked as `unstable`, not the network. #[test] -fn network_stable_after_add_and_after_remove_peer() -> Result<()> { +fn unstable_network_stable_after_add_and_after_remove_peer() -> Result<()> { // Given a network let (rt, network, mut genesis_client, pipeline_time, account_id, asset_definition_id) = init()?; wait_for_genesis_committed(&network.clients(), 0); diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index c7bbc2c5387..25d57faaf7d 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -22,7 +22,7 @@ iroha_data_model = { version = "=2.0.0-pre-rc.3", path = "../data_model" } iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../crypto" } color-eyre = "0.5.11" -structopt = "0.3" +clap = { version = "3.1.10", features = ["derive"] } futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } dialoguer = { version = "0.9", default-features = false } serde_json = "1.0" diff --git a/client_cli/src/main.rs b/client_cli/src/main.rs index d059a15e242..cb5a3727730 100644 --- a/client_cli/src/main.rs +++ b/client_cli/src/main.rs @@ -9,6 +9,7 @@ use std::{fmt, fs::File, str::FromStr, time::Duration}; +use clap::StructOpt; use color_eyre::{ eyre::{Error, WrapErr}, Result, @@ -17,7 +18,6 @@ use dialoguer::Confirm; use iroha_client::{client::Client, config::Configuration as ClientConfiguration}; use iroha_crypto::prelude::*; use iroha_data_model::prelude::*; -use structopt::StructOpt; /// Metadata wrapper, which can be captured from cli arguments (from user supplied file). #[derive(Debug, Clone)] @@ -60,11 +60,7 @@ impl FromStr for Configuration { /// Iroha CLI Client provides an ability to interact with Iroha Peers Web API without direct network usage. #[derive(StructOpt, Debug)] -#[structopt( - name = "iroha_client_cli", - version = "0.1.0", - author = "Soramitsu Iroha2 team (https://github.com/orgs/soramitsu/teams/iroha2)" -)] +#[structopt(name = "iroha_client_cli", version, author)] pub struct Args { /// Sets a config file path #[structopt(short, long, default_value = "config.json")] @@ -77,14 +73,19 @@ pub struct Args { #[derive(StructOpt, Debug)] pub enum Subcommand { /// The subcommand related to domains + #[clap(subcommand)] Domain(domain::Args), /// The subcommand related to accounts + #[clap(subcommand)] Account(account::Args), /// The subcommand related to assets + #[clap(subcommand)] Asset(asset::Args), /// The subcommand related to p2p networking + #[clap(subcommand)] Peer(peer::Args), /// The subcommand related to event streaming + #[clap(subcommand)] Events(events::Args), } @@ -121,8 +122,7 @@ fn main() -> Result<()> { let Args { config: Configuration(config), subcommand, - } = Args::from_args(); - println!("Iroha Client CLI: build v0.0.1 [release]"); + } = clap::Parser::parse(); println!( "User: {}@{}", config.account_id.name, config.account_id.domain_id @@ -229,11 +229,12 @@ mod domain { use super::*; /// Arguments for domain subcommand - #[derive(Debug, StructOpt)] + #[derive(Debug, clap::Subcommand)] pub enum Args { /// Register domain Register(Register), /// List domains + #[clap(subcommand)] List(List), } @@ -301,8 +302,10 @@ mod account { /// Register account Register(Register), /// Set something in account + #[clap(subcommand)] Set(Set), /// List accounts + #[clap(subcommand)] List(List), } @@ -429,6 +432,7 @@ mod asset { /// Get info of asset Get(Get), /// List assets + #[clap(subcommand)] List(List), } diff --git a/core/docs/src/main.rs b/core/docs/src/main.rs deleted file mode 100644 index 1a4a9bba7a2..00000000000 --- a/core/docs/src/main.rs +++ /dev/null @@ -1,99 +0,0 @@ -//! Cli for generating documentation for iroha configuraion - -#![allow(clippy::restriction)] - -use std::{ - fmt::Debug, - io::{stdout, BufWriter, Result, Write}, -}; - -use color_eyre::eyre::WrapErr; -use iroha::config::Configuration; -use iroha_config::Configurable; -use serde_json::{Map, Value}; - -fn main() -> color_eyre::Result<()> { - color_eyre::install().unwrap(); - Configuration::get_markdown(&mut BufWriter::new(stdout())) - .wrap_err("Failed to generate documentation") -} - -impl + Send + Sync + Default> PrintDocs for C {} - -trait PrintDocs: Configurable + Send + Sync + Default -where - Self::Error: Debug, -{ - fn get_markdown(writer: &mut W) -> Result<()> { - let docs = match Self::get_docs() { - Value::Object(obj) => obj, - _ => unreachable!("As top level structure is always object"), - }; - let mut vec = Vec::new(); - let defaults = serde_json::to_string_pretty(&Self::default())?; - - writeln!(writer, "# Iroha Configuration reference\n")?; - writeln!(writer, "In this document we provide a reference and detailed descriptions of Iroha's configuration options.\n")?; - writeln!(writer, "## Default configuration\n")?; - writeln!( - writer, - "The following is the default configuration used by Iroha.\n" - )?; - writeln!(writer, "```json\n{}\n```\n", defaults)?; - Self::get_markdown_with_depth(writer, &docs, &mut vec, 2)?; - Ok(()) - } - - fn get_markdown_with_depth( - writer: &mut W, - docs: &Map, - field: &mut Vec, - depth: usize, - ) -> Result<()> { - let current_field = { - let mut docs = docs; - for f in &*field { - docs = match &docs[f] { - Value::Object(obj) => obj, - _ => unreachable!(), - }; - } - docs - }; - - for (f, value) in current_field { - field.push(f.clone()); - let get_field = field.iter().map(AsRef::as_ref).collect::>(); - let (doc, inner) = match value { - Value::Object(_) => { - let doc = Self::get_doc_recursive(&get_field) - .expect("Should be there, as already in docs"); - (doc.unwrap_or_default().to_owned(), true) - } - Value::String(s) => (s.clone(), false), - _ => unreachable!("Only strings and objects in docs"), - }; - let doc = doc.strip_prefix(' ').unwrap_or(&doc); - let defaults = Self::default() - .get_recursive(get_field) - .expect("Failed to get defaults."); - let defaults = serde_json::to_string_pretty(&defaults)?; - let field_str = field - .join(".") - .chars() - .filter(|&chr| chr != ' ') - .collect::(); - - write!(writer, "{} `{}`\n\n", "#".repeat(depth), field_str)?; - write!(writer, "{}\n\n", doc)?; - write!(writer, "```json\n{}\n```\n\n", defaults)?; - - if inner { - Self::get_markdown_with_depth(writer, docs, field, depth + 1)?; - } - - field.pop(); - } - Ok(()) - } -} diff --git a/core/src/genesis.rs b/core/src/genesis.rs index 65fa15ec807..592a6a22e07 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -1,4 +1,5 @@ -//! This module contains execution Genesis Block logic, and `GenesisBlock` definition. +//! Genesis-related logic and constructs. Contains the `GenesisBlock`, +//! `RawGenesisBlock` and the `RawGenesisBlockBuilder` structures. #![allow(clippy::module_name_repetitions)] #![allow(clippy::new_without_default)] @@ -10,7 +11,7 @@ use iroha_crypto::{KeyPair, PublicKey}; use iroha_data_model::{asset::AssetDefinition, prelude::*}; use iroha_schema::prelude::*; use serde::{Deserialize, Serialize}; -use small::SmallVec; +use small::{smallvec, SmallVec}; use tokio::{time, time::Duration}; pub use self::config::GenesisConfiguration; @@ -49,8 +50,9 @@ pub trait GenesisNetworkTrait: transaction_limits: &TransactionLimits, ) -> Result>; - /// Waits for a minimum number of [`Peer`]s needed for consensus to be online. - /// Returns initialized network [`Topology`] with the set A consisting of online peers. + /// Waits for a minimum number of [`Peer`]s needed for consensus + /// to be online. Returns initialized network [`Topology`] with + /// the set A consisting of online peers. async fn wait_for_peers( &self, this_peer_id: PeerId, @@ -58,9 +60,10 @@ pub trait GenesisNetworkTrait: network: Addr, ) -> Result; - // FIXME: Having `ctx` reference and `sumaregi` reference here is not ideal. - // The way it is currently designed, this function is called from sumeragi and then calls sumeragi, while being in an unrelated module. - // This needs to be restructured. + // FIXME: Having `ctx` reference and `sumaregi` reference here is + // not ideal. The way it is currently designed, this function is + // called from sumeragi and then calls sumeragi, while being in an + // unrelated module. This needs to be restructured. /// Submits genesis transactions. /// @@ -253,7 +256,7 @@ impl RawGenesisBlock { /// Create a [`RawGenesisBlock`] with specified [`Domain`] and [`Account`]. pub fn new(account_name: Name, domain_id: DomainId, public_key: PublicKey) -> Self { RawGenesisBlock { - transactions: SmallVec(smallvec::smallvec![GenesisTransaction::new( + transactions: SmallVec(smallvec![GenesisTransaction::new( account_name, domain_id, public_key, @@ -291,7 +294,7 @@ impl GenesisTransaction { /// Create a [`GenesisTransaction`] with the specified [`Domain`] and [`Account`]. pub fn new(account_name: Name, domain_id: DomainId, public_key: PublicKey) -> Self { Self { - isi: SmallVec(smallvec::smallvec![ + isi: SmallVec(smallvec![ RegisterBox::new(Domain::new(domain_id.clone())).into(), RegisterBox::new(Account::new( AccountId::new(account_name, domain_id), @@ -410,9 +413,10 @@ impl RawGenesisBlockBuilder { /// be used to create assets and accounts. pub fn domain(mut self, domain_name: Name) -> RawGenesisDomainBuilder { let domain_id = DomainId::new(domain_name); + let new_domain = Domain::new(domain_id.clone()); self.transaction .isi - .push(RegisterBox::new(domain_id.clone()).into()); + .push(Instruction::from(RegisterBox::new(new_domain))); RawGenesisDomainBuilder { transaction: self.transaction, domain_id, @@ -421,7 +425,7 @@ impl RawGenesisBlockBuilder { /// Finish building and produce a `RawGenesisBlock`. pub fn build(self) -> RawGenesisBlock { RawGenesisBlock { - transactions: SmallVec(smallvec::smallvec![self.transaction]), + transactions: SmallVec(smallvec![self.transaction]), } } } @@ -516,7 +520,7 @@ mod tests { let domain_id: DomainId = "wonderland".parse().unwrap(); assert_eq!( finished_genesis_block.transactions[0].isi[0], - RegisterBox::new(domain_id.clone()).into() + Instruction::from(RegisterBox::new(Domain::new(domain_id.clone()))) ); assert_eq!( finished_genesis_block.transactions[0].isi[1], @@ -532,7 +536,7 @@ mod tests { let domain_id: DomainId = "tulgey_wood".parse().unwrap(); assert_eq!( finished_genesis_block.transactions[0].isi[3], - RegisterBox::new(domain_id.clone()).into() + Instruction::from(RegisterBox::new(Domain::new(domain_id.clone()))) ); assert_eq!( finished_genesis_block.transactions[0].isi[4], @@ -543,7 +547,7 @@ mod tests { let domain_id: DomainId = "meadow".parse().unwrap(); assert_eq!( finished_genesis_block.transactions[0].isi[5], - RegisterBox::new(domain_id.clone()).into() + Instruction::from(RegisterBox::new(Domain::new(domain_id.clone()))) ); assert_eq!( finished_genesis_block.transactions[0].isi[6], diff --git a/core/src/kura.rs b/core/src/kura.rs index fd527afeb0d..56c3564d51f 100644 --- a/core/src/kura.rs +++ b/core/src/kura.rs @@ -1,5 +1,7 @@ -//! This module contains persistence related Iroha logic. -//! [`Kura`] is the main entity which should be used to store new [`Block`](`crate::block::VersionedCommittedBlock`)s on the blockchain. +//! Translates to warehouse. File-system and persistence-related +//! logic. [`Kura`] is the main entity which should be used to store +//! new [`Block`](`crate::block::VersionedCommittedBlock`)s on the +//! blockchain. use std::{ collections::BTreeSet, diff --git a/core/src/smartcontracts/wasm.rs b/core/src/smartcontracts/wasm.rs index e78e04a335c..dd2759835a3 100644 --- a/core/src/smartcontracts/wasm.rs +++ b/core/src/smartcontracts/wasm.rs @@ -346,12 +346,14 @@ impl<'wrld, W: WorldTrait> Runtime<'wrld, W> { Ok(()) } - /// Host defined function which prints given string. When calling this function, module - /// serializes ISI to linear memory and provides offset and length as parameters + /// Host defined function which prints given string. When calling + /// this function, module serializes ISI to linear memory and + /// provides offset and length as parameters /// /// # Warning /// - /// This function doesn't take ownership of the provided allocation + /// This function doesn't take ownership of the provided + /// allocation /// /// # Errors /// diff --git a/core/src/sumeragi/mod.rs b/core/src/sumeragi/mod.rs index d1dc65a6cfb..7f703c5b423 100644 --- a/core/src/sumeragi/mod.rs +++ b/core/src/sumeragi/mod.rs @@ -1,4 +1,4 @@ -//! This module contains consensus related logic of the Iroha. +//! Translates to Emperor. Consensus-related logic of Iroha. //! //! `Consensus` trait is now implemented only by `Sumeragi` for now. diff --git a/crypto/src/lib.rs b/crypto/src/lib.rs index 17611c11103..1436ab20dd5 100644 --- a/crypto/src/lib.rs +++ b/crypto/src/lib.rs @@ -39,14 +39,18 @@ use ursa::{ }, }; +// Hiding constants is a bad idea. For one, you're forcing the user to +// create temporaries, but also you're not actually hiding any +// information that can be used in malicious ways. If you want to hide +// these, I'd prefer inlining them instead. /// ed25519 -const ED_25519: &str = "ed25519"; +pub const ED_25519: &str = "ed25519"; /// secp256k1 -const SECP_256_K1: &str = "secp256k1"; +pub const SECP_256_K1: &str = "secp256k1"; /// bls normal -const BLS_NORMAL: &str = "bls_normal"; +pub const BLS_NORMAL: &str = "bls_normal"; /// bls small -const BLS_SMALL: &str = "bls_small"; +pub const BLS_SMALL: &str = "bls_small"; /// Error indicating algorithm could not be found #[derive(Debug, Clone, Copy, Display, IntoSchema)] diff --git a/data_model/src/domain.rs b/data_model/src/domain.rs index dbe620e118e..a39a101911a 100644 --- a/data_model/src/domain.rs +++ b/data_model/src/domain.rs @@ -1,4 +1,9 @@ -//! This module contains [`Domain`](`crate::domain::Domain`) structure and related implementations and trait implementations. +//! This module contains [`Domain`](`crate::domain::Domain`) structure +//! and related implementations and trait implementations. +//! +//! Note that the Genesis domain and account have a temporary +//! privileged position, and permission validation is turned off for +//! the Genesis block. #[cfg(not(feature = "std"))] use alloc::{format, string::String, vec::Vec}; @@ -18,7 +23,9 @@ use crate::{ Identifiable, Name, ParseError, }; -/// Genesis domain name. Genesis domain should contain only genesis account. +/// The domain name of the genesis domain. +/// +/// The genesis domain should only contain the genesis account. pub const GENESIS_DOMAIN_NAME: &str = "genesis"; /// Genesis domain. It will contain only one `genesis` account. @@ -62,8 +69,11 @@ impl From for Domain { /// Builder which can be submitted in a transaction to create a new [`Domain`] #[derive(Debug, Clone, PartialEq, Eq, Decode, Encode, Deserialize, Serialize, IntoSchema)] pub struct NewDomain { + /// The identification associated to the domain builder. id: ::Id, + /// The (IPFS) link to the logo of this domain. logo: Option, + /// metadata associated to the domain builder. metadata: Metadata, } @@ -82,6 +92,7 @@ impl Ord for NewDomain { } impl NewDomain { + /// Create a [`NewDomain`], reserved for internal use. #[must_use] fn new(id: ::Id) -> Self { Self { @@ -251,8 +262,8 @@ impl Domain { self.asset_definitions.get_mut(asset_definition_id) } - /// Add asset definition into the [`Domain`] returning previous asset definition stored under - /// the same id + /// Add asset definition into the [`Domain`] returning previous + /// asset definition stored under the same id #[inline] pub fn add_asset_definition( &mut self, @@ -284,9 +295,8 @@ impl FromIterator for crate::Value { } } -/// Represents path in IPFS. Performs some checks to ensure path validity. -/// -/// Should be constructed with `from_str()` method. +/// Represents path in IPFS. Performs checks to ensure path validity. +/// Construct using [`FromStr::from_str`] method. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Serialize, IntoSchema)] pub struct IpfsPath(String); diff --git a/docs/source/references/glossary.md b/docs/source/references/glossary.md index b6cb791281f..4779ae2cf0c 100644 --- a/docs/source/references/glossary.md +++ b/docs/source/references/glossary.md @@ -62,6 +62,9 @@ Module with the incoming request handling logic for the peer. It is used to rece ### Kura (Warehouse) Persistence-related logic. It handles storing the blocks, log rotation, block storage folder rotation etc. +### Kagami(Teacher and Exemplar and/or looking glass) +Generator for commonly used data. Can generate cryptographic key pairs, genesis blocks, documentation etc. + ### Merkle tree (hash tree) A data structure used to validate and verify the state at each block height. Iroha's current implementation is a binary tree. See [Wikipedia](https://en.wikipedia.org/wiki/Merkle_tree) for more details. diff --git a/docs/source/references/keypairs.md b/docs/source/references/keypairs.md index 2c18f4053ba..73797bb1152 100644 --- a/docs/source/references/keypairs.md +++ b/docs/source/references/keypairs.md @@ -5,10 +5,10 @@ Iroha uses Public key cryptography. # TL;DR The easiest way to generate keys for use in Iroha is to use -`iroha_crypto_cli`. +`kagami`. ```bash -cargo run --bin iroha_crypto_cli -- --json +cargo run --bin kagami -- crypto --json ``` Which produces (for example) @@ -47,7 +47,7 @@ The `payload** is the private key itself. The digest_function you can ignore for ### What needs signing. -Let's look at an [example configuration](../../../configs/peer/config.json). A peer has a `PUBLIC_KEY` and a corresponding `PRIVATE_KEY`, which must come from a single pair generated by `iroha_crypto_cli`. Every peer that wants to connect to it from the outside must know its `PRIVATE_KEY` specified in the `TRUSTED_PEERS` section. +Let's look at an [example configuration](../../../configs/peer/config.json). A peer has a `PUBLIC_KEY` and a corresponding `PRIVATE_KEY`, which must come from a single pair generated by `kagami`. Every peer that wants to connect to it from the outside must know its `PRIVATE_KEY` specified in the `TRUSTED_PEERS` section. Now look at [`genesis.json`](../../../configs/peer/genesis.json). We register an account "alice@wonderland", which has a signatory, this is not the genesis account, it's just **an** account with a key, so matching this signature to the genesis account's key is not necessary. You *could*, though and that wouldn't compromise the blockchain's security as the genesis account only has `root` user privileges for the duration of the genesis round. diff --git a/hooks/pre-commit.sample b/hooks/pre-commit.sample index 1a8526044bb..c7265617221 100755 --- a/hooks/pre-commit.sample +++ b/hooks/pre-commit.sample @@ -1,4 +1,5 @@ #!/bin/sh set -e -cargo run --bin iroha_docs >docs/source/references/config.md -git add docs/source/references/config.md +cargo run --bin kagami -- --docs >docs/source/references/config.md +cargo run --bin kagami -- --genesis >configs/peer/genesis.json +git add docs/source/references/config.md configs/peer/genesis.json diff --git a/lints.toml b/lints.toml index bd0980b2980..6fef49dcfb3 100644 --- a/lints.toml +++ b/lints.toml @@ -20,6 +20,7 @@ deny = [ 'unused_import_braces', 'variant_size_differences', ] + allow = [ 'clippy::string_add', 'clippy::as_conversions', @@ -60,4 +61,5 @@ allow = [ ## https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn 'clippy::missing_const_for_fn' ] + warn = [] diff --git a/schema/bin/src/main.rs b/schema/bin/src/main.rs deleted file mode 100644 index 007f7a33ab4..00000000000 --- a/schema/bin/src/main.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Binary to print all types to json string - -// Schemas should always be serializable to JSON -#[allow(clippy::expect_used, clippy::print_stdout)] -fn main() { - let schemas = iroha_schema_bin::build_schemas(); - - println!( - "{}", - serde_json::to_string_pretty(&schemas).expect("Unable to serialize schemas") - ); -} diff --git a/schema/bin/Cargo.toml b/schema/gen/Cargo.toml similarity index 94% rename from schema/bin/Cargo.toml rename to schema/gen/Cargo.toml index d1f327aad1e..6e40c70f135 100644 --- a/schema/bin/Cargo.toml +++ b/schema/gen/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroha_schema_bin" +name = "iroha_schema_gen" version = "2.0.0-pre-rc.3" authors = ["Iroha 2 team "] edition = "2021" diff --git a/schema/bin/src/lib.rs b/schema/gen/src/lib.rs similarity index 100% rename from schema/bin/src/lib.rs rename to schema/gen/src/lib.rs diff --git a/scripts/check.sh b/scripts/check.sh new file mode 100755 index 00000000000..6f9a3b210f5 --- /dev/null +++ b/scripts/check.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +TMPFILE=$(mktemp) + +case $1 in + "docs") + cargo run --bin kagami -- docs >"$TMPFILE" + diff "$TMPFILE" docs/source/references/config.md || { + echo 'Please re-generate docs using `cargo run --bin kagami -- docs`' + exit 1 + };; + "genesis") + cargo run --bin kagami -- genesis >"$TMPFILE" + diff "$TMPFILE" configs/peer/genesis.json || { + echo 'Please re-generate the genesis with `cargo run --bin kagami -- genesis`' + exit 1 + };; +esac diff --git a/scripts/check_docs.sh b/scripts/check_docs.sh deleted file mode 100755 index 87ba12f7594..00000000000 --- a/scripts/check_docs.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -ex -TMPFILE=$(mktemp) -cargo run --bin iroha_docs >$TMPFILE -diff $TMPFILE docs/source/references/config.md || { - echo "Please regenerate docs with git hook in ./hooks directory" - exit 1 -} diff --git a/tools/crypto_cli/Cargo.toml b/tools/crypto_cli/Cargo.toml deleted file mode 100644 index 729e63d2dfd..00000000000 --- a/tools/crypto_cli/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "iroha_crypto_cli" -version = "2.0.0-pre-rc.3" -authors = ["Iroha 2 team "] -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../../crypto" } - -clap = "2.33.0" -color-eyre = "0.5.11" -hex = "0.4.0" -serde_json = "1.0" diff --git a/tools/crypto_cli/README.md b/tools/crypto_cli/README.md deleted file mode 100644 index f85e49fa7be..00000000000 --- a/tools/crypto_cli/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Iroha Crypto CLI - -## Description - -Tool for generating public/private key pairs for use in Iroha networks. - -All keys are represented in the [multihash format](https://github.com/multiformats/multihash). - -## Usage - -Assuming that the command is run either from the root of the cloned repository or the directory containing this document, use - - -```bash -cargo run --bin iroha_crypto_cli -``` - -**NOTE:** arguments before the `--` terminator are interpreted as arguments given to `cargo run`, rather than `iroha_crypto_cli` to pass the argument `--help` use the following syntax. - -```bash -cargo run --bin iroha_crypto_cli -- --help -``` - -### Contributing - -Check out [this document](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md) - -## [Need help?](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md#contact) - -## License - -Iroha codebase is 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. - -Iroha documentation files are made available under the Creative Commons -Attribution 4.0 International License (CC-BY-4.0), available at -http://creativecommons.org/licenses/by/4.0/ diff --git a/tools/crypto_cli/src/main.rs b/tools/crypto_cli/src/main.rs deleted file mode 100644 index 0c6a4db57d4..00000000000 --- a/tools/crypto_cli/src/main.rs +++ /dev/null @@ -1,110 +0,0 @@ -//! `iroha_crypto_cli` is a command line tool used to generate keys for Iroha peers and clients. - -use clap::{App, Arg, ArgGroup}; -use color_eyre::{ - eyre::{self, eyre, WrapErr}, - Report, Result, -}; -use iroha_crypto::{Algorithm, KeyGenConfiguration, KeyPair, PrivateKey}; - -fn main() -> Result<(), Report> { - color_eyre::install()?; - let default_algorithm = Algorithm::default().to_string(); - let matches = App::new("iroha_crypto_cli") - .version("0.1") - .author("Soramitsu") - .about("iroha_crypto_cli is a command line tool used to generate keys for Iroha peers and clients.") - .arg( - Arg::with_name("seed") - .long("seed") - .value_name("seed") - .help("Sets a seed for random number generator. Should be used separately from `private_key`.") - .required(false) - .takes_value(true) - ) - .arg( - Arg::with_name("private_key") - .long("private_key") - .value_name("private_key") - .help("Sets a private key. Should be used separately from `seed`.") - .required(false) - .takes_value(true) - ) - .arg( - Arg::with_name("algorithm") - .long("algorithm") - .value_name("algorithm") - .help("Function used to generate the key pair.") - .takes_value(true) - .possible_value(&Algorithm::Ed25519.to_string()) - .possible_value(&Algorithm::Secp256k1.to_string()) - .possible_value(&Algorithm::BlsNormal.to_string()) - .possible_value(&Algorithm::BlsSmall.to_string()) - .default_value(&default_algorithm) - ) - .arg( - Arg::with_name("json") - .long("json") - .help("If specified the output will be formatted as json.") - .takes_value(false) - .multiple(false) - ) - .group( - ArgGroup::with_name("key_gen_options") - .args(&["seed", "private_key"]) - .required(false) - .multiple(false) - ) - .get_matches(); - let seed_option = matches.value_of("seed"); - let private_key_option = matches.value_of("private_key"); - let algorithm = matches - .value_of("algorithm") - .ok_or_else(|| eyre!("Failed to get algorithm name."))? - .parse::() - .wrap_err("Failed to parse algorithm.")?; - let key_gen_configuration = KeyGenConfiguration::default().with_algorithm(algorithm); - let keypair: KeyPair = seed_option.map_or_else( - || -> eyre::Result<_> { - private_key_option.map_or_else( - || { - KeyPair::generate_with_configuration(key_gen_configuration.clone()) - .wrap_err("failed to generate key pair") - }, - |private_key| { - KeyPair::generate_with_configuration( - key_gen_configuration.clone().use_private_key( - PrivateKey::from_hex(algorithm, &private_key) - .wrap_err("Failed to decode private key.")?, - ), - ) - .wrap_err("Failed to generate key pair") - }, - ) - }, - |seed| -> eyre::Result<_> { - KeyPair::generate_with_configuration( - key_gen_configuration - .clone() - .use_seed(seed.as_bytes().into()), - ) - .wrap_err("Failed to generate key pair") - }, - )?; - - #[allow(clippy::print_stdout)] - if matches.is_present("json") { - let json = - serde_json::to_string_pretty(&keypair).wrap_err("Failed to serialize to json.")?; - println!("{}", json); - } else { - println!("Public key (multihash): {}", keypair.public_key()); - println!("Private key: {}", keypair.private_key()); - println!( - "Digest function: {}", - keypair.public_key().digest_function() - ); - } - - Ok(()) -} diff --git a/core/docs/Cargo.toml b/tools/kagami/Cargo.toml similarity index 50% rename from core/docs/Cargo.toml rename to tools/kagami/Cargo.toml index 0827c76668a..a717b489d51 100644 --- a/core/docs/Cargo.toml +++ b/tools/kagami/Cargo.toml @@ -1,12 +1,17 @@ [package] -name = "iroha_docs" +name = "kagami" +# Translates to teacher, the exemplar, the looking glass. A tool used to generate cryptographic keys, docs, the schema and genesis block. version = "2.0.0-pre-rc.3" authors = ["Iroha 2 team "] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -# Explanation: You want the option to remove configuration docs if you distribute e.g. a `deb`, but want the person who just cloned the repo to be able to see at a glance what kinds of features are accessible to them, what they do and how to use them. #1975 should be fixed soon. +# Explanation: You want the option to remove configuration docs if you +# distribute e.g. a `deb`, but want the person who just cloned the +# repo to be able to see at a glance what kinds of features are +# accessible to them, what they do and how to use them. #1975 should +# be fixed soon. [features] default = ["dex", "telemetry", "dev-telemetry"] dex = ["iroha_core/dex"] @@ -16,8 +21,13 @@ dev-telemetry = ["iroha_core/dev-telemetry"] [dependencies] iroha_core = { version = "=2.0.0-pre-rc.3", path = "../../core" } +iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../../crypto" } iroha_config = { version = "=2.0.0-pre-rc.3", path = "../../config" } +iroha_data_model = { version = "=2.0.0-pre-rc.3", path = "../../data_model" } +iroha_schema_gen = { version = "=2.0.0-pre-rc.3", path = "../../schema/gen" } iroha = { path = "../../cli" } color-eyre = "0.5.11" +hex = "0.4.0" +clap = { version = "3.1.10", features = ["derive"] } serde_json = "1" diff --git a/tools/kagami/README.md b/tools/kagami/README.md new file mode 100644 index 00000000000..f582296638d --- /dev/null +++ b/tools/kagami/README.md @@ -0,0 +1,94 @@ +# Kagami (Teacher and Exemplar and/or Looking glass) + +Generate and validate the automatically generated data files shipped with Iroha. + +### Building + +Use + +```bash +cargo build --bin kagami +``` + +anywhere in this repository. This will place `kagami` inside the `target/debug/` directory (from the root of the repository). + +### Usage + +```bash +kagami 2.0.0-pre-rc.3 +Soramitsu Iroha2 team (https://github.com/orgs/soramitsu/teams/iroha2) +Tool generating the cryptorgraphic key pairs, + +USAGE: +kagami + +OPTIONS: +-h, --help Print help information +-V, --version Print version information + +SUBCOMMANDS: +crypto Generate cryptorgraphic key pairs +docs Generate a Markdown reference of configuration parameters +genesis Generate a default genesis block that is used in tests +help Print this message or the help of the given subcommand(s) +schema Generate schema used for code generation in Iroha SDKs +``` + +#### Key generation + +With a few examples. + +```bash +$ ./kagami crypto +``` + +```bash +Kagami. To see help run with `--help`. +No flags specified, generating key-pair. +Public key (multihash): ed0120232adec551bfa1856279ebccc3c3a09783c516478f4cbb2f42f342614bec7601 +Private key: a1e2c094496dd53ea103f1423b90ccb7d65ff25ab46f5fa1643c14e6010f7f75232adec551bfa1856279ebccc3c3a09783c516478f4cbb2f42f342614bec7601 +Digest function: ed25519 +``` + +To generate a key pair from a given seed, run + +```bash +$ ./kagami crypto --seed +``` + +To generate a key with the `secp256k1` algorithm, which corresponds to the private key `8e170e7abe3cc71afeb2459b2d055641159dca4825e0536234e120ced756fabda2bfcb42761216a95a5bf2574219c602a9e7d410420af8b020c9e9e40ffb3690`, run + +```bash +$ ./kagami crypto --algorithm secp256k1 --private-key "b32129af69b829a88ab9bac60b2a33cc57f8843e93aae0478e93f2285059c236" +``` + +```bash +Public key (multihash): e70121031c59a9cabaf58f3b8a6157362b9f6feac3dd47ee947fbf2f335805e1a7f96bde +Private key: b32129af69b829a88ab9bac60b2a33cc57f8843e93aae0478e93f2285059c236 +Digest function: secp256k1 +``` + + +#### Genesis + +```bash +kagami genesis +``` + +Should produce a genesis block in JSON format. You might want to use shell redirections e.g. `kagami -g >genesis.json`. + +#### Schema + +```bash +kagami schema +``` + +Should generate the schema in JSON format. You might want to use shell redirections e.g. `kagami -g >genesis.json`. + +#### Peer configuration reference + +```bash +kagami docs +``` + +Should generate the documentation in Markdown format. Should be identical to the [reference configuration](../../docs/source/references/config.md). diff --git a/tools/kagami/src/main.rs b/tools/kagami/src/main.rs new file mode 100644 index 00000000000..7313f6f1278 --- /dev/null +++ b/tools/kagami/src/main.rs @@ -0,0 +1,297 @@ +//! CLI for generating iroha sample configuration, genesis and +//! cryptographic key pairs. To be used with all compliant Iroha +//! installations. + +use std::io::{stdout, BufWriter, Write}; + +use clap::{ArgGroup, StructOpt}; +use color_eyre::eyre::WrapErr as _; +use iroha::config::Configuration; + +pub type Outcome = color_eyre::Result<()>; + +// The reason for hard-coding this default is to ensure that the +// algorithm is matched to the public key. If you need to change +// either, you should definitely change both. +static DEFAULT_PUBLIC_KEY: &str = + "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"; +// static DEFAULT_ALGORITHM: &str = iroha_crypto::ED_25519; + +fn main() -> Outcome { + color_eyre::install()?; + let args: Args = clap::Parser::parse(); + let mut writer = BufWriter::new(stdout()); + args.run(&mut writer) +} + +/// Trait to encapsulate common attributes of the commands and sub-commands. +pub trait RunArgs { + /// Run the given command. + /// + /// # Errors + /// if inner command fails. + fn run(self, writer: &mut BufWriter) -> Outcome; +} + +/// Tool generating the cryptorgraphic key pairs, schema, genesis block and configuration reference. +#[derive(StructOpt, Debug)] +#[structopt(name = "kagami", version, author)] +pub enum Args { + /// Generate cryptorgraphic key pairs + Crypto(crypto::Args), + /// Generate schema used for code generation in Iroha SDKs + Schema(schema::Args), + /// Generate a default genesis block that is used in tests + Genesis(genesis::Args), + /// Generate a Markdown reference of configuration parameters + Docs(docs::Args), +} + +impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + use Args::*; + + match self { + Crypto(args) => args.run(writer), + Schema(args) => args.run(writer), + Genesis(args) => args.run(writer), + Docs(args) => args.run(writer), + } + } +} + +mod crypto { + use color_eyre::eyre::WrapErr as _; + use iroha_crypto::{Algorithm, KeyGenConfiguration, KeyPair, PrivateKey}; + + use super::*; + + /// Use `Kagami` to generate cryptographic key-pairs. + #[derive(StructOpt, Debug, Clone)] + #[structopt(group = ArgGroup::new("generate_from").required(false))] + pub struct Args { + /// Algorithm used for generating the key-pair + #[clap(default_value_t, long, short)] + algorithm: Algorithm, + /// The `private_key` used to generate the key-pair + #[clap(long, short, group = "generate_from")] + private_key: Option, + /// The `seed` used to generate the key-pair + #[clap(long, short, group = "generate_from")] + seed: Option, + /// Output the key-pair in JSON format + #[clap(long, short)] + json: bool, + } + + impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + if self.json { + let output = serde_json::to_string_pretty(&self.key_pair()?) + .wrap_err("Failed to serialise to JSON.")?; + writeln!(writer, "{}", output)?; + } else { + let key_pair = self.key_pair()?; + writeln!(writer, "Public key (multihash): {}", &key_pair.public_key())?; + writeln!(writer, "Private key: {}", &key_pair.private_key())?; + writeln!( + writer, + "Digest function: {}", + &key_pair.public_key().digest_function() + )?; + } + Ok(()) + } + } + + impl Args { + fn key_pair(self) -> color_eyre::Result { + let key_gen_configuration = + KeyGenConfiguration::default().with_algorithm(self.algorithm); + let keypair: KeyPair = self.seed.map_or_else( + || -> color_eyre::Result<_> { + self.private_key.map_or_else( + || { + KeyPair::generate_with_configuration(key_gen_configuration.clone()) + .wrap_err("failed to generate key pair") + }, + |private_key| { + let private_key = PrivateKey::from_hex(self.algorithm, &private_key) + .wrap_err("Failed to decode private key")?; + KeyPair::generate_with_configuration( + key_gen_configuration.clone().use_private_key(private_key), + ) + .wrap_err("Failed to generate key pair") + }, + ) + }, + |seed| -> color_eyre::Result<_> { + KeyPair::generate_with_configuration( + key_gen_configuration + .clone() + .use_seed(seed.as_bytes().into()), + ) + .wrap_err("Failed to generate key pair") + }, + )?; + Ok(keypair) + } + } +} + +mod schema { + use super::*; + + #[derive(StructOpt, Debug, Clone, Copy)] + pub struct Args; + + impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + let schemas = iroha_schema_gen::build_schemas(); + writeln!(writer, "{}", serde_json::to_string_pretty(&schemas)?) + .wrap_err("Failed to write schema.") + } + } +} + +mod genesis { + use iroha_core::{ + genesis::{RawGenesisBlock, RawGenesisBlockBuilder}, + tx::{AssetDefinition, MintBox}, + }; + + use super::*; + + #[derive(StructOpt, Debug, Clone, Copy)] + pub struct Args; + + impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + writeln!( + writer, + "{}", + serde_json::to_string_pretty(&generate_default()?)? + ) + .wrap_err("Failed to write.") + } + } + + pub fn generate_default() -> color_eyre::Result { + let asset_definition = AssetDefinition::quantity("rose#wonderland".parse()?).build(); + let mut result = RawGenesisBlockBuilder::new() + .domain("wonderland".parse()?) + .with_account("alice".parse()?, crate::DEFAULT_PUBLIC_KEY.parse()?) + .with_asset(asset_definition.clone()) + .finish_domain() + .build(); + let mint = MintBox::new( + iroha_data_model::prelude::Value::U32(13_u32), + iroha_data_model::IdBox::AssetId(iroha_data_model::prelude::AssetId::new( + asset_definition.id().clone(), // Probably redundant clone + "alice@wonderland".parse()?, + )), + ); + result.transactions[0].isi.push(mint.into()); + Ok(result) + } +} + +mod docs { + #![allow(clippy::panic_in_result_fn, clippy::expect_used)] + use std::{fmt::Debug, io::Write}; + + use color_eyre::eyre::WrapErr as _; + use iroha_config::Configurable; + use serde_json::Value; + + use super::*; + + impl + Send + Sync + Default> PrintDocs for C {} + + #[derive(StructOpt, Debug, Clone, Copy)] + pub struct Args; + + impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> crate::Outcome { + Configuration::get_markdown(writer).wrap_err("Failed to generate documentation") + } + } + + pub trait PrintDocs: Configurable + Send + Sync + Default + where + Self::Error: Debug, + { + fn get_markdown(writer: &mut W) -> color_eyre::Result<()> { + let docs = match Self::get_docs() { + Value::Object(obj) => obj, + _ => unreachable!("As top level structure is always object"), + }; + let mut vec = Vec::new(); + let defaults = serde_json::to_string_pretty(&Self::default())?; + + writeln!(writer, "# Iroha Configuration reference\n")?; + writeln!(writer, "In this document we provide a reference and detailed descriptions of Iroha's configuration options.\n")?; + writeln!(writer, "## Default configuration\n")?; + writeln!( + writer, + "The following is the default configuration used by Iroha.\n" + )?; + writeln!(writer, "```json\n{}\n```\n", defaults)?; + Self::get_markdown_with_depth(writer, &docs, &mut vec, 2)?; + Ok(()) + } + + fn get_markdown_with_depth( + writer: &mut W, + docs: &serde_json::Map, + field: &mut Vec, + depth: usize, + ) -> color_eyre::Result<()> { + let current_field = { + let mut docs = docs; + for f in &*field { + docs = match &docs[f] { + Value::Object(obj) => obj, + _ => unreachable!(), + }; + } + docs + }; + + for (f, value) in current_field { + field.push(f.clone()); + let get_field = field.iter().map(AsRef::as_ref).collect::>(); + let (doc, inner) = match value { + Value::Object(_) => { + let doc = Self::get_doc_recursive(&get_field) + .expect("Should be there, as already in docs"); + (doc.unwrap_or_default().to_owned(), true) + } + Value::String(s) => (s.clone(), false), + _ => unreachable!("Only strings and objects in docs"), + }; + let doc = doc.strip_prefix(' ').unwrap_or(&doc); + let defaults = Self::default() + .get_recursive(get_field) + .expect("Failed to get defaults."); + let defaults = serde_json::to_string_pretty(&defaults)?; + let field_str = field + .join(".") + .chars() + .filter(|&chr| chr != ' ') + .collect::(); + + write!(writer, "{} `{}`\n\n", "#".repeat(depth), field_str)?; + write!(writer, "{}\n\n", doc)?; + write!(writer, "```json\n{}\n```\n\n", defaults)?; + + if inner { + Self::get_markdown_with_depth(writer, docs, field, depth + 1)?; + } + + field.pop(); + } + Ok(()) + } + } +} diff --git a/tools/kura_inspector/Cargo.toml b/tools/kura_inspector/Cargo.toml index 5b42ce5d2ae..eb96fc6c0a6 100644 --- a/tools/kura_inspector/Cargo.toml +++ b/tools/kura_inspector/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" iroha_core = { path = "../../core" } iroha_config = { path = "../../config" } -clap = { version = "3.1.8", features = ["derive", "cargo"] } +clap = { version = "3.1.10", features = ["derive", "cargo"] } futures-util = "0.3" tokio = { version = "1.6.0", features = ["rt"]} diff --git a/tools/parity_scale_decoder/Cargo.toml b/tools/parity_scale_decoder/Cargo.toml index 4ae5b8002c3..3271bf12cb9 100644 --- a/tools/parity_scale_decoder/Cargo.toml +++ b/tools/parity_scale_decoder/Cargo.toml @@ -15,10 +15,10 @@ iroha_schema = { version = "=2.0.0-pre-rc.3", path = "../../schema"} iroha_core = { version = "=2.0.0-pre-rc.3", path = "../../core"} iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../../crypto", default-features = false } iroha_version = { version = "=2.0.0-pre-rc.3", path = "../../version", default-features = false } -clap = { version = "3.1.8", features = ["derive", "cargo"] } +clap = { version = "3.1.10", features = ["derive", "cargo"] } eyre = "0.6.8" parity-scale-codec = { version = "2.3.1", default-features = false } colored = "2.0.0" [dev-dependencies] -iroha_schema_bin = { version = "=2.0.0-pre-rc.3", path = "../../schema/bin"} +iroha_schema_gen = { version = "=2.0.0-pre-rc.3", path = "../../schema/gen"} diff --git a/tools/parity_scale_decoder/src/generate_map.rs b/tools/parity_scale_decoder/src/generate_map.rs index 3a4576bf8de..843e7b8b5f9 100644 --- a/tools/parity_scale_decoder/src/generate_map.rs +++ b/tools/parity_scale_decoder/src/generate_map.rs @@ -361,7 +361,7 @@ pub fn generate_map() -> DumpDecodedMap { mod tests { use std::collections::HashSet; - use iroha_schema_bin::build_schemas; + use iroha_schema_gen::build_schemas; use super::*;