From 102cfa8a22dc3dfa9af455a647f0a63711706ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Tue, 28 May 2024 17:45:12 +0300 Subject: [PATCH 1/4] refactor(irohad): rename iroha to irohad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- .github/workflows/iroha2-release-pr.yml | 148 -------------------- .github/workflows/iroha2-release.yml | 25 ---- CONTRIBUTING.md | 30 ++-- Cargo.lock | 75 +++++----- Cargo.toml | 9 +- Dockerfile | 6 +- Dockerfile.glibc | 4 +- README.md | 6 +- cli/Cargo.toml | 3 +- cli/README.md | 10 +- cli/build.rs | 2 +- cli/src/lib.rs | 6 +- cli/src/main.rs | 8 +- client/Cargo.toml | 6 +- client/benches/torii.rs | 2 +- client/benches/tps/utils.rs | 2 +- client/examples/million_accounts_genesis.rs | 2 +- client/examples/register_1000_triggers.rs | 4 +- client/src/client.rs | 3 +- client/src/http.rs | 2 + client/src/lib.rs | 7 +- client/tests/integration/events/pipeline.rs | 2 +- client_cli/build.rs | 2 +- client_cli/pytests/README.md | 2 +- client_cli/src/main.rs | 9 +- core/src/tx.rs | 2 +- core/test_network/Cargo.toml | 7 +- core/test_network/src/lib.rs | 26 ++-- crypto/src/encryption/mod.rs | 2 +- crypto/src/kex/mod.rs | 2 +- data_model/src/lib.rs | 2 +- docs/source/guides/hot-reload.md | 6 +- docs/source/iroha_2_whitepaper.md | 2 +- ffi/derive/src/attr_parse/getset.rs | 2 +- flake.nix | 6 +- futures/src/lib.rs | 2 +- macro/src/lib.rs | 2 +- macro/utils/src/lib.rs | 2 +- p2p/src/network.rs | 2 +- primitives/numeric/src/lib.rs | 6 +- primitives/src/numeric.rs | 2 +- schema/derive/src/lib.rs | 2 +- scripts/API/java.sh | 20 --- scripts/analyze_telemetry.sh | 2 +- scripts/test_env.py | 10 +- scripts/tests/panic_on_invalid_genesis.sh | 24 ---- scripts/update_configs.sh | 25 ---- smart_contract/README.md | 4 +- telemetry/src/lib.rs | 2 +- tools/kagami/src/main.rs | 2 +- tools/swarm/src/cli.rs | 2 +- tools/swarm/src/compose.rs | 8 +- torii/src/routing.rs | 4 +- 53 files changed, 157 insertions(+), 396 deletions(-) delete mode 100644 .github/workflows/iroha2-release-pr.yml delete mode 100755 scripts/API/java.sh delete mode 100755 scripts/tests/panic_on_invalid_genesis.sh delete mode 100755 scripts/update_configs.sh diff --git a/.github/workflows/iroha2-release-pr.yml b/.github/workflows/iroha2-release-pr.yml deleted file mode 100644 index 041770dc0a2..00000000000 --- a/.github/workflows/iroha2-release-pr.yml +++ /dev/null @@ -1,148 +0,0 @@ -name: I2::Release::Tests - -on: - pull_request: - branches: [stable, lts] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - CLIENT_CLI_DIR: "/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/test" - ALLURE_RESULTS: "${{ github.workspace }}/allure-results" - ALLURE_JOB_RUN_ID: ${{ github.event.inputs.ALLURE_JOB_RUN_ID }} - -jobs: - client-cli-tests: - runs-on: [self-hosted, Linux, iroha2] - container: - image: hyperledger/iroha2-ci:nightly-2024-04-18 - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - name: Install and configure allurectl - uses: allure-framework/setup-allurectl@v1 - with: - allure-endpoint: https://soramitsu.testops.cloud - allure-token: ${{ secrets.ALLURE_TOKEN }} - allure-project-id: 1 - - name: Build binaries - run: | - cargo build --bin iroha_client_cli - cargo build --bin kagami - cargo build --bin iroha - - name: Setup test Iroha 2 environment on bare metal - run: | - pip3 install -r scripts/requirements.txt --no-input --break-system-packages - ./scripts/test_env.py setup - - name: Mark binaries as executable - run: | - chmod +x ${{ env.CLIENT_CLI_DIR }} - - name: Install dependencies using Poetry - working-directory: client_cli/pytests - run: | - poetry install - - name: Run client cli tests and upload results to Allure Test Ops - working-directory: client_cli/pytests - run: | - allurectl watch -- poetry run pytest --alluredir=${ALLURE_RESULTS} - printenv | grep GITHUB_TESTS_ - env: - GITHUB_TESTS_REF_NAME: ${{ github.ref_name }} - - name: Cleanup test environment - run: | - ./scripts/test_env.py cleanup - - name: Panic on invalid genesis test - run: bash -c './scripts/tests/panic_on_invalid_genesis.sh' - - bench: - runs-on: ubuntu-latest - container: - image: hyperledger/iroha2-ci:nightly-2024-04-18 - steps: - - name: Maximize build space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - name: Run benchmarks - run: mold --run cargo bench --workspace --quiet - - # ------------------------------ SDK tests go here ------------------------ - - java-api: - runs-on: ubuntu-latest - container: - image: hyperledger/iroha2-ci:nightly-2024-04-18 - steps: - - name: Maximize build space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v4.2.1 - with: - java-version: '11' - distribution: 'temurin' - - name: Cache Gradle packages - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Build iroha - working-directory: cli - run: mold --run cargo build - - name: Build iroha_client_cli - working-directory: client_cli - run: mold --run cargo build - - name: Build kagami - working-directory: tools/kagami - run: mold --run cargo build - - name: Mark binaries as executable - run: | - chmod +x target/debug/iroha - chmod +x target/debug/iroha_client_cli - chmod +x target/debug/kagami - - name: Setup test environment - run: ./scripts/test_env.sh setup - - name: Test iroha2-java API - run: ./scripts/API/java.sh setup && ./scripts/API/java.sh run - - name: Cleanup test iroha2-java API - run: ./scripts/API/java.sh cleanup - - name: Cleanup test environment - run: ./scripts/test_env.sh cleanup - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't - # cached by GitHub Actions. Restoring these files from a - # GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties - - long: - runs-on: ubuntu-latest - container: - image: hyperledger/iroha2-ci:nightly-2024-04-18 - steps: - - name: Maximize build space - uses: jlumbroso/free-disk-space@v1.3.1 - with: - tool-cache: true - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: false - swap-storage: true - - uses: actions/checkout@v4 - - name: Run long tests - run: mold --run cargo test --workspace --no-fail-fast -- --ignored --test-threads=1 long diff --git a/.github/workflows/iroha2-release.yml b/.github/workflows/iroha2-release.yml index d38a0ceda26..a8200155d53 100644 --- a/.github/workflows/iroha2-release.yml +++ b/.github/workflows/iroha2-release.yml @@ -69,28 +69,3 @@ jobs: hyperledger/iroha:${{ env.TAG }} docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }} labels: commit=${{ github.sha }} - - configs: - runs-on: ubuntu-latest - container: - image: hyperledger/iroha2-ci:nightly-2024-04-18 - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - with: - ref: iroha2-dev - token: ${{ secrets.G_ACCESS_TOKEN }} - - name: Update configs - run: | - ./scripts/update_configs.sh lts - ./scripts/update_configs.sh stable - - name: Commit config changes - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: '[documentation]: Update lts/stable configs following a release' - branch: iroha2-dev - commit_options: '--signoff' - commit_user_name: sorabot - commit_user_email: <> - commit_author: sorabot diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ec646a1285..beeca40fe7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -157,7 +157,7 @@ To pass the *`check-PR-title`* check, the pull request title must adhere to the
Expand to read the detailed title guidelines 1. Follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with-multi-paragraph-body-and-multiple-footers) format. - + 2. If the pull request has a single commit, the PR title should be the same as the commit message.
@@ -217,11 +217,11 @@ Set the `LOG_FILE_PATH` environment variable to an appropriate location to store ### Debugging using tokio console -
Expand to learn how to compile iroha with tokio console support. +
Expand to learn how to compile Iroha with tokio console support. Sometimes it might be helpful for debugging to analyze tokio tasks using [tokio-console](https://github.com/tokio-rs/console). -In this case you should compile iroha with support of tokio console like that: +In this case you should compile Iroha with support of tokio console like that: ```bash RUSTFLAGS="--cfg tokio_unstable" cargo build --features tokio-console @@ -230,14 +230,14 @@ RUSTFLAGS="--cfg tokio_unstable" cargo build --features tokio-console Port for tokio console can by configured through `LOG_TOKIO_CONSOLE_ADDR` configuration parameter (or environment variable). Using tokio console require log level to be `TRACE`, can be enabled through configuration parameter or environment variable `LOG_LEVEL`. -Example of running iroha with tokio console support using `scripts/test_env.sh`: +Example of running Iroha with tokio console support using `scripts/test_env.sh`: ```bash -# 1. Compile iroha +# 1. Compile Iroha RUSTFLAGS="--cfg tokio_unstable" cargo build --features tokio-console -# 2. Run iroha with TRACE log level +# 2. Run Iroha with TRACE log level LOG_LEVEL=TRACE ./scripts/test_env.sh setup -# 3. Access iroha. Peers will be available on ports 5555, 5556, ... +# 3. Access Iroha. Peers will be available on ports 5555, 5556, ... tokio-console http://127.0.0.1:5555 ``` @@ -245,19 +245,19 @@ tokio-console http://127.0.0.1:5555 ### Profiling -
Expand to learn ho to profile iroha. +
Expand to learn ho to profile Iroha. -To optimize performance it's useful to profile iroha. +To optimize performance it's useful to profile Iroha. -To do that you should compile iroha with `profiling` profile and with `profiling` feature: +To do that you should compile Iroha with `profiling` profile and with `profiling` feature: ```bash RUSTFLAGS="-C force-frame-pointers=on" cargo +nightly -Z build-std build --target your-desired-target --profile profiling --features profiling ``` -Then start iroha and attach profiler of your choice to the iroha pid. +Then start Iroha and attach profiler of your choice to the Iroha pid. -Alternatively it's possible to build iroha inside docker with profiler support and profile iroha this way. +Alternatively it's possible to build Iroha inside docker with profiler support and profile Iroha this way. ```bash docker build -f Dockerfile.glibc --build-arg="PROFILE=profiling" --build-arg='RUSTFLAGS=-C force-frame-pointers=on' --build-arg='FEATURES=profiling' --build-arg='CARGOFLAGS=-Z build-std' -t iroha:profiling . @@ -272,7 +272,7 @@ sudo perf record -g -p sudo perf report ``` -To be able to observe profile of the executor during iroha profiling, executor should be compiled without stripping symbols. +To be able to observe profile of the executor during Iroha profiling, executor should be compiled without stripping symbols. It can be done by running: ```bash @@ -280,10 +280,10 @@ It can be done by running: cargo run --bin iroha_wasm_builder_cli -- build ./path/to/executor --outfile executor.wasm ``` -With profiling feature enabled iroha exposes endpoint to scrap pprof profiles: +With profiling feature enabled Iroha exposes endpoint to scrap pprof profiles: ```bash -# profile iroha for 30 seconds and get protobuf profile +# profile Iroha for 30 seconds and get protobuf profile curl host:port/debug/pprof/profile?seconds=30 -o profile.pb # analyze profile in browser (required installed go) go tool pprof -web profile.pb diff --git a/Cargo.lock b/Cargo.lock index a4e2fb4ceb7..3e3179fc3ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2763,42 +2763,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "iroha" -version = "2.0.0-pre-rc.21" -dependencies = [ - "assertables", - "clap", - "error-stack", - "eyre", - "futures", - "iroha_config", - "iroha_core", - "iroha_crypto", - "iroha_data_model", - "iroha_futures", - "iroha_genesis", - "iroha_logger", - "iroha_p2p", - "iroha_primitives", - "iroha_telemetry", - "iroha_torii", - "iroha_wasm_builder", - "json5", - "once_cell", - "owo-colors", - "path-absolutize", - "serial_test", - "supports-color 2.1.0", - "tempfile", - "thiserror", - "thread-local-panic-hook", - "tokio", - "toml 0.8.13", - "tracing", - "vergen", -] - [[package]] name = "iroha_client" version = "2.0.0-pre-rc.21" @@ -2814,7 +2778,6 @@ dependencies = [ "futures-util", "hex", "http 1.1.0", - "iroha", "iroha_config", "iroha_config_base", "iroha_crypto", @@ -2826,6 +2789,7 @@ dependencies = [ "iroha_torii_const", "iroha_version", "iroha_wasm_builder", + "irohad", "nonzero_ext", "once_cell", "parity-scale-codec", @@ -3567,6 +3531,41 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "irohad" +version = "2.0.0-pre-rc.21" +dependencies = [ + "assertables", + "clap", + "error-stack", + "eyre", + "futures", + "iroha_config", + "iroha_core", + "iroha_crypto", + "iroha_data_model", + "iroha_futures", + "iroha_genesis", + "iroha_logger", + "iroha_primitives", + "iroha_telemetry", + "iroha_torii", + "iroha_wasm_builder", + "json5", + "once_cell", + "owo-colors", + "path-absolutize", + "serial_test", + "supports-color 2.1.0", + "tempfile", + "thiserror", + "thread-local-panic-hook", + "tokio", + "toml 0.8.13", + "tracing", + "vergen", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -5632,7 +5631,6 @@ version = "2.0.0-pre-rc.21" dependencies = [ "eyre", "futures", - "iroha", "iroha_client", "iroha_config", "iroha_core", @@ -5641,6 +5639,7 @@ dependencies = [ "iroha_genesis", "iroha_logger", "iroha_primitives", + "irohad", "parity-scale-codec", "rand", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index ce319b93e3e..dd1a096b653 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,20 +14,23 @@ keywords = ["blockchain", "crypto", "iroha", "ledger"] categories = ["cryptography::cryptocurrencies"] [workspace.dependencies] -iroha = { path = "cli" } +iroha_core = { version = "=2.0.0-pre-rc.21 ", path = "core" } + +irohad = { version = "=2.0.0-pre-rc.21", path = "cli" } iroha_torii = { version = "=2.0.0-pre-rc.21", path = "torii" } iroha_torii_derive = { version = "=2.0.0-pre-rc.21", path = "torii/derive" } iroha_torii_const = { version = "=2.0.0-pre-rc.21", path = "torii/const" } + +iroha_client = { version = "=2.0.0-pre-rc.21", path = "client" } + iroha_macro_utils = { version = "=2.0.0-pre-rc.21", path = "macro/utils" } iroha_telemetry = { version = "=2.0.0-pre-rc.21", path = "telemetry" } iroha_telemetry_derive = { version = "=2.0.0-pre-rc.21", path = "telemetry/derive" } iroha_p2p = { version = "=2.0.0-pre-rc.21", path = "p2p" } -iroha_core = { version = "=2.0.0-pre-rc.21 ", path = "core" } iroha_primitives = { version = "=2.0.0-pre-rc.21", path = "primitives", default-features = false } iroha_primitives_derive = { version = "=2.0.0-pre-rc.21", path = "primitives/derive" } iroha_data_model = { version = "=2.0.0-pre-rc.21", path = "data_model", default-features = false } iroha_data_model_derive = { version = "=2.0.0-pre-rc.21", path = "data_model/derive" } -iroha_client = { version = "=2.0.0-pre-rc.21", path = "client" } iroha_config = { version = "=2.0.0-pre-rc.21", path = "config" } iroha_config_base = { version = "=2.0.0-pre-rc.21", path = "config/base" } iroha_config_base_derive = { version = "=2.0.0-pre-rc.21", path = "config/base/derive" } diff --git a/Dockerfile b/Dockerfile index e9b86a545d1..e9d570f8179 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/x86_64-linux-musl-native/bin/ # builder stage WORKDIR /iroha COPY . . -# FIXME: consider building only `iroha`, `iroha_client_cli`, and `kagami`? +# FIXME: consider building only `irohad`, `iroha_client_cli`, and `kagami`? RUN cargo build --target x86_64-unknown-linux-musl --profile deploy @@ -66,8 +66,8 @@ RUN set -ex && \ chown $USER:$USER $STORAGE && \ chown $USER:$USER $WASM_DIRECTORY -COPY --from=builder $TARGET_DIR/iroha $BIN_PATH +COPY --from=builder $TARGET_DIR/irohad $BIN_PATH COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER -CMD ["iroha"] +CMD ["irohad"] diff --git a/Dockerfile.glibc b/Dockerfile.glibc index 818d850ef2b..394280db5ee 100644 --- a/Dockerfile.glibc +++ b/Dockerfile.glibc @@ -55,8 +55,8 @@ RUN set -ex && \ chown $USER:$USER $STORAGE && \ chown $USER:$USER $WASM_DIRECTORY -COPY --from=builder $TARGET_DIR/iroha $BIN_PATH +COPY --from=builder $TARGET_DIR/irohad $BIN_PATH COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER -CMD ["iroha"] +CMD ["irohad"] diff --git a/README.md b/README.md index 5c90dd9fc9d..5f23254cbf1 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,14 @@ Run API functional tests: ```bash cargo build -chmod +x target/debug/iroha +chmod +x target/debug/irohad chmod +x target/debug/iroha_client_cli bash ./scripts/test_env.sh setup bash ./scripts/tests/register_mint_quantity.sh bash ./scripts/test_env.sh cleanup ``` -To generate WASM files for smart contracts, use the provided script `generate_wasm.sh`. If you are in the root directory of iroha run the following command: +To generate WASM files for smart contracts, use the provided script `generate_wasm.sh`. If you are in the root directory of Iroha run the following command: ```bash bash ./scripts/generate_wasm.sh [path/to/smartcontracts] @@ -164,7 +164,7 @@ A brief overview on how to configure and maintain an Iroha instance: There is a set of configuration parameters that could be passed either through a configuration file or environment variables. ```shell -iroha --config /path/to/config.toml +irohad --config /path/to/config.toml ``` **Note:** detailed configuration reference is [work in progress](https://github.com/hyperledger/iroha-2-docs/issues/392). diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 8ed2910ba7d..528dd814def 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroha" +name = "irohad" edition.workspace = true version.workspace = true @@ -48,7 +48,6 @@ iroha_primitives = { workspace = true } iroha_telemetry = { workspace = true, optional = true } iroha_config = { workspace = true } iroha_crypto = { workspace = true } -iroha_p2p = { workspace = true } iroha_torii = { workspace = true } iroha_genesis = { workspace = true } iroha_wasm_builder = { workspace = true } diff --git a/cli/README.md b/cli/README.md index 60a69f453c9..ee2f1d4582e 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,8 +1,6 @@ # Iroha CLI -The binary `iroha` crate contains the Iroha peer binary. The binary is used to instantiate a peer and bootstrap an Iroha-based network. The capabilities of the network are determined by the feature flags used to compile the binary. - -The `iroha` crate contains the Iroha peer binary, which is used to instantiate a peer and bootstrap an Iroha-based network. The capabilities of the network are determined by the feature flags used to compile said binary. +The `irohad` crate contains the Iroha server binary. The binary is used to instantiate a peer and bootstrap an Iroha-based network. The capabilities of the network are determined by the feature flags used to compile the binary. ## Build @@ -86,11 +84,11 @@ You may deploy Iroha as a [native binary](#native-binary) or by using [Docker](# 1. Prepare a deployment environment. - If you plan on running the `iroha` peer binary from the directory `deploy`, copy `config.json` and `genesis.json`: + If you plan on running the `irohad` binary from the directory `deploy`, copy `config.json` and `genesis.json`: ```bash # FIXME - # cp ./target/release/iroha + # cp ./target/release/irohad # cp ./configs/peer/config.json deploy # cp ./configs/peer/genesis.json deploy ``` @@ -109,7 +107,7 @@ You may deploy Iroha as a [native binary](#native-binary) or by using [Docker](# ```bash cd deploy - ./iroha --submit-genesis + ./irohad --submit-genesis ``` ### Docker diff --git a/cli/build.rs b/cli/build.rs index 699f4559ba8..884f4710f81 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -1,4 +1,4 @@ -//! Build script to extract git hash of iroha build +//! Build script to extract git hash of Iroha build use eyre::{eyre, Result, WrapErr}; diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 6c5ac55f9b1..c3e2cc646fd 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -434,7 +434,7 @@ impl Iroha { Ok(new_self) } - /// Starts iroha in separate tokio task. + /// Starts Iroha in separate tokio task. /// /// # Errors /// - Forwards initialisation error. @@ -785,10 +785,10 @@ fn default_terminal_colors_str() -> clap::builder::OsStr { is_colouring_supported().to_string().into() } -/// Iroha peer Command-Line Interface. +/// Iroha server CLI #[derive(Parser, Debug)] #[command( - name = "iroha", + name = "irohad", version = concat!("version=", env!("CARGO_PKG_VERSION"), " git_commit_sha=", env!("VERGEN_GIT_SHA"), " cargo_features=", env!("VERGEN_CARGO_FEATURES")), author )] diff --git a/cli/src/main.rs b/cli/src/main.rs index 0575126bb93..410ddd903f6 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,9 +1,9 @@ -//! Iroha peer command-line interface. +//! Iroha server command-line interface. use std::env; use clap::Parser; use error_stack::{IntoReportCompat, ResultExt}; -use iroha::Args; +use irohad::{Args, Iroha}; #[derive(thiserror::Error, Debug)] enum MainError { @@ -30,7 +30,7 @@ async fn main() -> error_stack::Result<(), MainError> { } let (config, logger_config, genesis) = - iroha::read_config_and_genesis(&args).change_context(MainError::Config).attach_printable_lazy(|| { + irohad::read_config_and_genesis(&args).change_context(MainError::Config).attach_printable_lazy(|| { args.config.as_ref().map_or_else( || "`--config` arg was not set, therefore configuration relies fully on environment variables".to_owned(), |path| format!("config path is specified by `--config` arg: {}", path.display()), @@ -51,7 +51,7 @@ async fn main() -> error_stack::Result<(), MainError> { iroha_logger::debug!("Submitting genesis."); } - let _iroha = iroha::Iroha::start_network(config, genesis, logger) + let _iroha = Iroha::start_network(config, genesis, logger) .await .change_context(MainError::IrohaStart)? .start_torii() diff --git a/client/Cargo.toml b/client/Cargo.toml index 0ea16af09ba..13e823959b3 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -82,12 +82,12 @@ toml = { workspace = true } nonzero_ext = { workspace = true } [dev-dependencies] -iroha_wasm_builder = { workspace = true } - # TODO: These three activate `transparent_api` but client should never activate this feature. # Additionally there is a dependency on iroha_core in dev-dependencies in telemetry/derive # Hopefully, once the integration tests migration is finished these can be removed -iroha = { workspace = true } +irohad = { workspace = true } + +iroha_wasm_builder = { workspace = true } iroha_genesis = { workspace = true } test_network = { workspace = true } diff --git a/client/benches/torii.rs b/client/benches/torii.rs index ca0b809c69f..ca8df450b81 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -3,7 +3,7 @@ use std::thread; use criterion::{criterion_group, criterion_main, Criterion, Throughput}; -use iroha::samples::{construct_executor, get_config}; +use irohad::samples::{construct_executor, get_config}; use iroha_client::{ client::{asset, Client}, data_model::prelude::*, diff --git a/client/benches/tps/utils.rs b/client/benches/tps/utils.rs index 913aca11688..a7f0fd662c6 100644 --- a/client/benches/tps/utils.rs +++ b/client/benches/tps/utils.rs @@ -111,7 +111,7 @@ impl Config { let blocks_out_of_measure = 2 + MeasurerUnit::PREPARATION_BLOCKS_NUMBER * self.peers; let state_view = network .genesis - .iroha + .irohad .as_ref() .expect("Must be some") .state() diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index 013e2fd0d3b..d30cb6a6e15 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -1,7 +1,7 @@ //! This file contains examples from the Rust tutorial. use std::{thread, time::Duration}; -use iroha::samples::{construct_executor, get_config}; +use irohad::samples::{construct_executor, get_config}; use iroha_client::{crypto::KeyPair, data_model::prelude::*}; use iroha_data_model::isi::InstructionBox; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; diff --git a/client/examples/register_1000_triggers.rs b/client/examples/register_1000_triggers.rs index cc9542fd9b9..fff4a33159c 100644 --- a/client/examples/register_1000_triggers.rs +++ b/client/examples/register_1000_triggers.rs @@ -1,8 +1,8 @@ //! Example of registering multiple triggers -//! Used to show iroha's trigger deduplication capabilities +//! Used to show Iroha's trigger deduplication capabilities use std::str::FromStr; -use iroha::samples::{construct_executor, get_config}; +use irohad::samples::{construct_executor, get_config}; use iroha_client::{client::Client, data_model::prelude::*}; use iroha_data_model::trigger::TriggerId; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; diff --git a/client/src/client.rs b/client/src/client.rs index 5c53801742f..ddcc4c47185 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1,5 +1,6 @@ //! Contains the end-point querying logic. This is where you need to //! add any custom end-point related logic. + use std::{ collections::HashMap, fmt::Debug, @@ -343,7 +344,7 @@ impl_query_output! { pub struct Client { /// Unique id of the blockchain. Used for simple replay attack protection. pub chain_id: ChainId, - /// Url for accessing iroha node + /// Url for accessing Iroha node pub torii_url: Url, /// Accounts keypair pub key_pair: KeyPair, diff --git a/client/src/http.rs b/client/src/http.rs index d974db4c4f1..25a147fbed5 100644 --- a/client/src/http.rs +++ b/client/src/http.rs @@ -1,3 +1,5 @@ +//! Module with general communication primitives like an HTTP request builder. + use core::borrow::Borrow; use eyre::{eyre, Result}; diff --git a/client/src/lib.rs b/client/src/lib.rs index a551c23adc3..0de4272bd81 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,15 +1,14 @@ -//! Crate contains iroha client which talks to iroha network via http +//! Crate contains client which talks to Iroha network via http -/// Module with iroha client itself pub mod client; pub mod config; -/// Module with general communication primitives like an HTTP request builder. pub mod http; mod http_default; mod query_builder; -/// Module containing sample configurations for tests and benchmarks. pub mod samples { + //! Module containing sample configurations for tests and benchmarks. + use eyre::Result; use iroha_telemetry::metrics::Status; use url::Url; diff --git a/client/tests/integration/events/pipeline.rs b/client/tests/integration/events/pipeline.rs index 778cb29615f..90b19fde177 100644 --- a/client/tests/integration/events/pipeline.rs +++ b/client/tests/integration/events/pipeline.rs @@ -125,7 +125,7 @@ fn applied_block_must_be_available_in_kura() { .try_into() .expect("Received unexpected event"); - peer.iroha + peer.irohad .as_ref() .expect("Must be some") .kura() diff --git a/client_cli/build.rs b/client_cli/build.rs index 5a7cf35f6f4..92e754aab91 100644 --- a/client_cli/build.rs +++ b/client_cli/build.rs @@ -1,4 +1,4 @@ -//! Build script to extract git hash of iroha build +//! Build script to extract git hash of Iroha build use color_eyre::{ eyre::{eyre, WrapErr}, diff --git a/client_cli/pytests/README.md b/client_cli/pytests/README.md index 6aefb69e900..20034f78449 100644 --- a/client_cli/pytests/README.md +++ b/client_cli/pytests/README.md @@ -58,7 +58,7 @@ The test model has the following structure: # Note: make sure you have installed packages from `./scripts/requirements.txt` ``` - By default, this builds `iroha`, `iroha_client_cli`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ + By default, this builds `irohad`, `iroha_client_cli`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ This behavior can be reconfigured. You can run `./scripts/test_env.py --help` to see the list of available commands and options. 2. Install and configure [Poetry](https://python-poetry.org/).\ diff --git a/client_cli/src/main.rs b/client_cli/src/main.rs index d8d96386c88..d8a8eab7fe6 100644 --- a/client_cli/src/main.rs +++ b/client_cli/src/main.rs @@ -1,4 +1,5 @@ -//! iroha client command line +//! Iroha client CLI + use std::{ fs::{self, read as read_file}, io::{stdin, stdout}, @@ -176,7 +177,7 @@ impl RunArgs for Subcommand { #[derive(Error, Debug)] enum MainError { - #[error("Failed to load Iroha Client CLI configuration")] + #[error("Failed to load Iroha client configuration")] Config, #[error("Failed to serialize config")] SerializeConfig, @@ -278,7 +279,7 @@ mod events { use super::*; - /// Get event stream from iroha peer + /// Get event stream from Iroha peer #[derive(clap::Subcommand, Debug, Clone, Copy)] pub enum Args { /// Gets block pipeline events @@ -322,7 +323,7 @@ mod blocks { use super::*; - /// Get block stream from iroha peer + /// Get block stream from Iroha peer #[derive(clap::Args, Debug, Clone, Copy)] pub struct Args { /// Block height from which to start streaming blocks diff --git a/core/src/tx.rs b/core/src/tx.rs index ac1e5986ccb..9314a4b9dc8 100644 --- a/core/src/tx.rs +++ b/core/src/tx.rs @@ -25,7 +25,7 @@ use crate::{ state::{StateBlock, StateTransaction, WorldReadOnly}, }; -/// `AcceptedTransaction` — a transaction accepted by iroha peer. +/// `AcceptedTransaction` — a transaction accepted by Iroha peer. #[derive(Debug, Clone, PartialEq, Eq)] // TODO: Inner field should be private to maintain invariants pub struct AcceptedTransaction(pub(crate) SignedTransaction); diff --git a/core/test_network/Cargo.toml b/core/test_network/Cargo.toml index 5505617e14e..6241fbf5a44 100644 --- a/core/test_network/Cargo.toml +++ b/core/test_network/Cargo.toml @@ -8,10 +8,11 @@ authors.workspace = true license.workspace = true [dependencies] -iroha = { workspace = true, features = ["test-network"] } -iroha_crypto = { workspace = true } -iroha_client = { workspace = true } iroha_core = { workspace = true } +irohad = { workspace = true, features = ["test-network"] } +iroha_client = { workspace = true } + +iroha_crypto = { workspace = true } iroha_config = { workspace = true } iroha_data_model = { workspace = true } iroha_primitives = { workspace = true } diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 51108f115e6..7dfc90cba11 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -6,7 +6,7 @@ use std::{collections::BTreeMap, ops::Deref, path::Path, sync::Arc, thread}; use eyre::Result; use futures::{prelude::*, stream::FuturesUnordered}; -use iroha::{Iroha, ToriiStarted}; +use irohad::{Iroha, ToriiStarted}; use iroha_client::{ client::{Client, QueryOutput}, config::Config as ClientConfig, @@ -148,8 +148,8 @@ impl Network { #[cfg(debug_assertions)] pub fn get_freeze_status_handles(&self) -> Vec> { self.peers() - .filter_map(|peer| peer.iroha.as_ref()) - .map(|iroha| iroha.freeze_status().clone()) + .filter_map(|peer| peer.irohad.as_ref()) + .map(|irohad| irohad.freeze_status().clone()) .collect() } @@ -386,8 +386,8 @@ pub struct Peer { pub key_pair: KeyPair, /// Shutdown handle shutdown: Option>, - /// Iroha itself - pub iroha: Option>, + /// Iroha server + pub irohad: Option>, /// Temporary directory // Note: last field to be dropped after Iroha (struct fields drops in FIFO RFC 1857) pub temp_dir: Option>, @@ -466,17 +466,17 @@ impl Peer { let handle = task::spawn( async move { - let iroha = Iroha::start_network(config, genesis, logger) + let irohad = Iroha::start_network(config, genesis, logger) .await - .expect("Failed to start iroha"); - let (job_handle, iroha) = iroha.start_torii_as_task(); - sender.send(iroha).unwrap(); + .expect("Failed to start Iroha"); + let (job_handle, irohad) = irohad.start_torii_as_task(); + sender.send(irohad).unwrap(); job_handle.await.unwrap().unwrap(); } .instrument(info_span), ); - self.iroha = Some(receiver.recv().unwrap()); + self.irohad = Some(receiver.recv().unwrap()); time::sleep(Duration::from_millis(300)).await; self.shutdown = Some(handle); // Prevent temporary directory deleting @@ -494,7 +494,7 @@ impl Peer { if let Some(shutdown) = self.shutdown.take() { shutdown.abort(); iroha_logger::info!("Shutting down peer..."); - self.iroha.take(); + self.irohad.take(); Some(()) } else { None @@ -520,7 +520,7 @@ impl Peer { p2p_address, api_address, shutdown, - iroha: None, + irohad: None, temp_dir: None, }) } @@ -786,7 +786,7 @@ impl TestConfig for Config { fn test() -> Self { use iroha_config::base::toml::TomlSource; - let mut raw = iroha::samples::get_config_toml( + let mut raw = irohad::samples::get_config_toml( <_>::default(), get_chain_id(), get_key_pair(Signatory::Peer), diff --git a/crypto/src/encryption/mod.rs b/crypto/src/encryption/mod.rs index bc200b7f5b3..b9e9cd70fbb 100644 --- a/crypto/src/encryption/mod.rs +++ b/crypto/src/encryption/mod.rs @@ -13,7 +13,7 @@ //! algorithms by using any algorithm that implements the [`Encryptor`] trait. //! //! [`ChaCha20Poly1305`] is the only algorithm currently supported, -//! as it is the only one used by the iroha p2p transport protocol. +//! as it is the only one used by the Iroha p2p transport protocol. mod chacha20poly1305; diff --git a/crypto/src/kex/mod.rs b/crypto/src/kex/mod.rs index db8e45bfb74..32512ab9768 100644 --- a/crypto/src/kex/mod.rs +++ b/crypto/src/kex/mod.rs @@ -1,7 +1,7 @@ //! A suite of Diffie-Hellman key exchange methods. //! //! [`X25519Sha256`] is the only key exchange scheme currently supported, -//! as it is the only one used by the iroha p2p transport protocol. +//! as it is the only one used by the Iroha p2p transport protocol. mod x25519; diff --git a/data_model/src/lib.rs b/data_model/src/lib.rs index 4f411f1dca9..2e42a5d6aab 100644 --- a/data_model/src/lib.rs +++ b/data_model/src/lib.rs @@ -222,7 +222,7 @@ pub mod parameter { use super::*; use crate::isi::InstructionBox; - /// Set of parameter names currently used by iroha + /// Set of parameter names currently used by Iroha #[allow(missing_docs)] pub mod default { pub const MAX_TRANSACTIONS_IN_BLOCK: &str = "MaxTransactionsInBlock"; diff --git a/docs/source/guides/hot-reload.md b/docs/source/guides/hot-reload.md index 584ef643944..e0919950aaa 100644 --- a/docs/source/guides/hot-reload.md +++ b/docs/source/guides/hot-reload.md @@ -27,7 +27,7 @@ Here is the overall procedure for hot reloading Iroha in a Docker container: 3. Copy Iroha to the current directory: ```bash - docker cp root/soramitsu/iroha/target/x86_64-unknown-linux-musl/release/iroha . + docker cp root/soramitsu/iroha/target/x86_64-unknown-linux-musl/release/irohad . ``` 4. (Optional) Make any modifications you need: @@ -54,7 +54,7 @@ rm blocks/* The new genesis block will be automatically recommited upon container restart. -## Use custom configuration files +## Use custom configuration files To use custom configuration files, such as `config.json` or `genesis.json`, copy (or bind mount) them to the `config/` subvolume before restarting the Docker container. @@ -68,4 +68,4 @@ To use custom environment variables (e.g. `IROHA_PUBLIC_KEY`), simply modify the IROHA_PUBLIC_KEY= docker restart ``` -The changes will take effect upon container restart. \ No newline at end of file +The changes will take effect upon container restart. diff --git a/docs/source/iroha_2_whitepaper.md b/docs/source/iroha_2_whitepaper.md index 10f762f111f..3542e56407d 100644 --- a/docs/source/iroha_2_whitepaper.md +++ b/docs/source/iroha_2_whitepaper.md @@ -18,7 +18,7 @@ To this end, Iroha provides encapsulated components for use by other projects, p Having a solid distributed ledger system is not useful if there are no applications that can easily utilize it. To ease use, we created and opened sourced software development kits for iOS, Android, and JavaScript. -Using these libraries, cryptographic public/private key pairs that are compatible with iroha can be created and common API functions can be conveniently called. +Using these libraries, cryptographic public/private key pairs that are compatible with Iroha can be created and common API functions can be conveniently called. ## 2. System architecture diff --git a/ffi/derive/src/attr_parse/getset.rs b/ffi/derive/src/attr_parse/getset.rs index 083adf5957d..39dffdb6879 100644 --- a/ffi/derive/src/attr_parse/getset.rs +++ b/ffi/derive/src/attr_parse/getset.rs @@ -205,7 +205,7 @@ impl GetSetRawFieldAttr { for attr in attrs { // getset crate is quite liberal in what it accepts // it allows both the `#[getset(get)]` and `#[get]` syntax to be used - // iroha doesn't use the latter form, so it is not supported by `iroha_ffi_derive` + // Iroha doesn't use the latter form, so it is not supported by `iroha_ffi_derive` if attr.path().is_ident("getset") { let Some(list) = accumulator.handle(attr.meta.require_list().map_err(Into::into)) else { diff --git a/flake.nix b/flake.nix index f3757dd001d..185837f8a00 100755 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ ]; allBinaries = [ - "iroha" + "irohad" "iroha_client_cli" "kagami" "kura_inspector" @@ -171,7 +171,7 @@ inherit target; # TODO: Cross-compilation doesn't work with multiple # binaries for some reason - binaries = ["iroha"]; + binaries = ["irohad"]; }; }) supportedTargets); @@ -180,7 +180,7 @@ { default = { type = "app"; - program = "${self.packages.${system}.default}/bin/iroha"; + program = "${self.packages.${system}.default}/bin/irohad"; }; } // builtins.listToAttrs (map (bin: { diff --git a/futures/src/lib.rs b/futures/src/lib.rs index 3865cc4e6fe..516182e08d9 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -1,4 +1,4 @@ -//! Crate with various iroha futures +//! Crate with various Iroha futures use std::{ future::Future, pin::Pin, diff --git a/macro/src/lib.rs b/macro/src/lib.rs index e7d398f16b5..edfab03f680 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -1,4 +1,4 @@ -//! Crate containing iroha macros +//! Crate containing Iroha macros #![cfg_attr(not(feature = "std"), no_std)] pub use iroha_derive::*; diff --git a/macro/utils/src/lib.rs b/macro/utils/src/lib.rs index 7a44ef5592f..f709c8fc912 100644 --- a/macro/utils/src/lib.rs +++ b/macro/utils/src/lib.rs @@ -1,4 +1,4 @@ -//! Module for various functions and structs to build macros in iroha. +//! Module for various functions and structs to build macros in Iroha. mod emitter; diff --git a/p2p/src/network.rs b/p2p/src/network.rs index fa98a39bbb7..a362baa5223 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -557,7 +557,7 @@ struct RefPeer { conn_id: ConnectionId, p2p_addr: SocketAddr, /// Disambiguator serves purpose of resolving situation when both peers are tying to connect to each other at the same time. - /// Usually in iroha network only one peer is trying to connect to another peer, but if peer is misbehaving it could be useful. + /// Usually in Iroha network only one peer is trying to connect to another peer, but if peer is misbehaving it could be useful. /// /// Consider timeline: /// diff --git a/primitives/numeric/src/lib.rs b/primitives/numeric/src/lib.rs index ab4fb96bee0..5a596de71b8 100644 --- a/primitives/numeric/src/lib.rs +++ b/primitives/numeric/src/lib.rs @@ -1,4 +1,4 @@ -//! Arbitrary precision numeric type for iroha assets +//! Arbitrary precision numeric type for Iroha assets #![cfg_attr(not(feature = "std"), no_std)] @@ -20,10 +20,10 @@ use serde_with::{DeserializeFromStr, SerializeDisplay}; /// The finite set of values of type [`Numeric`] are of the form $m / 10^e$, /// where m is an integer such that $-2^96 < m < 2^96$, and e is an integer between 0 and 28 inclusive. /// -/// This type provide only bare minimum of operations required to execute iroha isi. +/// This type provide only bare minimum of operations required to execute ISI. /// If more rich functionality is required (e.g. in smartcontract) /// it's suggested to convert this type into proper decimal type (like `rust_decimal`, `bigdecimal`, `u128`, ...), -/// perform necessary operations, and then convert back into `Numeric` when sending isi to iroha. +/// perform necessary operations, and then convert back into `Numeric` when sending ISI to Iroha. #[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct Numeric { diff --git a/primitives/src/numeric.rs b/primitives/src/numeric.rs index efddc24bcf5..4f249901d9a 100644 --- a/primitives/src/numeric.rs +++ b/primitives/src/numeric.rs @@ -1,4 +1,4 @@ -//! Arbitrary precision numeric type for iroha assets +//! Arbitrary precision numeric type for Iroha assets pub use iroha_numeric::*; pub use iroha_primitives_derive::numeric; diff --git a/schema/derive/src/lib.rs b/schema/derive/src/lib.rs index e9e72a47cec..ee32e9bcf8c 100644 --- a/schema/derive/src/lib.rs +++ b/schema/derive/src/lib.rs @@ -481,7 +481,7 @@ fn variant_field(fields: &IntoSchemaFields) -> Result> { bail!("Use at most 1 field in unnamed enum variants. Check out styleguide"); } Style::Struct => { - bail!("Please don't use named fields on enums. It is against iroha styleguide") + bail!("Please don't use named fields on enums. It is against Iroha styleguide") } }; Ok(convert_field_to_codegen(field).map(|this_field| this_field.ty)) diff --git a/scripts/API/java.sh b/scripts/API/java.sh deleted file mode 100755 index 251b9333fbb..00000000000 --- a/scripts/API/java.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -JAVA_DIR=${JAVA_DIR:-"iroha-java"} -JAVA_REPO=${JAVA_REPO:-"https://github.com/hyperledger/iroha-java.git"} -JAVA_BRANCH=${JAVA_BRANCH:-"iroha2-dev"} - -case $1 in - setup) - git clone "$JAVA_REPO" - cd "$JAVA_DIR" || exit 1 - git checkout "$JAVA_BRANCH" # TODO: change this to main after release. - ;; - run) - cd "$JAVA_DIR" || exit 1 - ./gradlew build - ;; - cleanup) - rm -rf "$JAVA_DIR" - ;; -esac diff --git a/scripts/analyze_telemetry.sh b/scripts/analyze_telemetry.sh index 47efe70339e..1d8a40c02ce 100755 --- a/scripts/analyze_telemetry.sh +++ b/scripts/analyze_telemetry.sh @@ -3,7 +3,7 @@ set -e; # Gets json entries from archived file # Errors: -# Forcing 0 exit code is okay, as for now iroha sometimes doesn't write whole json object to file +# Forcing 0 exit code is okay, as for now Iroha sometimes doesn't write whole json object to file get_entries() { lz4cat $1 2>/dev/null | jq -e '.duration = .duration.nanos / 1000000' || true; } # Returns raw top $1 of items diff --git a/scripts/test_env.py b/scripts/test_env.py index f14894617ca..688c1ac2025 100755 --- a/scripts/test_env.py +++ b/scripts/test_env.py @@ -53,7 +53,7 @@ def __init__(self, args: argparse.Namespace): with open(peers_dir / SHARED_CONFIG_FILE_NAME, "wb") as f: tomli_w.dump(shared_config, f) - copy_or_prompt_build_bin("iroha", args.root_dir, peers_dir) + copy_or_prompt_build_bin("irohad", args.root_dir, peers_dir) def wait_for_genesis(self, n_tries: int): @@ -129,7 +129,7 @@ def __init__(self, args: argparse.Namespace, nth: int): "snapshot": { "store_dir": "storage/snapshot" }, - # it is not available in debug iroha build + # it is not available in debug Iroha build # "logger": { # "tokio_console_addr": f"{self.host_ip}:{self.tokio_console_port}", # } @@ -216,7 +216,7 @@ def main(args: argparse.Namespace): cleanup(args.out_dir) def setup(args: argparse.Namespace): - logging.info(f"Starting iroha network with {args.n_peers} peers...") + logging.info(f"Starting Iroha network with {args.n_peers} peers...") os.makedirs(args.out_dir, exist_ok=True) copy_or_prompt_build_bin("iroha_client_cli", args.root_dir, args.out_dir) with open(os.path.join(args.out_dir, "metadata.json"), "w") as f: @@ -228,7 +228,7 @@ def setup(args: argparse.Namespace): def cleanup(out_dir: pathlib.Path): logging.info("Killing peer processes...") - subprocess.run(["pkill", "-9", "iroha"]) + subprocess.run(["pkill", "-9", "irohad"]) logging.info(f"Cleaning up test directory `{out_dir}`...") shutil.rmtree(out_dir) @@ -261,7 +261,7 @@ def cleanup(out_dir: pathlib.Path): parser.add_argument("--root-dir", "-r", default=".", type=pathlib.Path, help="Directory containing Iroha project root. \ Defaults to `.`, i.e. the directory script is being run from. \ - This is used to locate the `iroha` binary and config files") + This is used to locate the `irohad` binary and config files") parser.add_argument("--peer-name-as-seed", action="store_true", help="Use peer name as seed for key generation. \ This option could be useful to preserve the same peer keys between script invocations") diff --git a/scripts/tests/panic_on_invalid_genesis.sh b/scripts/tests/panic_on_invalid_genesis.sh deleted file mode 100755 index 6ce79c0476e..00000000000 --- a/scripts/tests/panic_on_invalid_genesis.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -ex -# Setup env -# FIXME: these are obsolete -export TORII_P2P_ADDR='127.0.0.1:1341' -export TORII_API_URL='127.0.0.1:8084' -export IROHA_PUBLIC_KEY='ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B' -export IROHA_PRIVATE_KEY='{"digest_function": "ed25519", "payload": "282ED9F3CF92811C3818DBC4AE594ED59DC1A2F78E4241E31924E101D6B1FB831C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B"}' -export IROHA_GENESIS_ACCOUNT_PUBLIC_KEY='ed01203F4E3E98571B55514EDC5CCF7E53CA7509D89B2868E62921180A6F57C2F4E255' -export IROHA_GENESIS_ACCOUNT_PRIVATE_KEY="{ \"digest_function\": \"ed25519\", \"payload\": \"038AE16B219DA35AA036335ED0A43C28A2CC737150112C78A7B8034B9D99C9023F4E3E98571B55514EDC5CCF7E53CA7509D89B2868E62921180A6F57C2F4E255\" }" -export IROHA2_CONFIG_PATH="configs/peer/config.json" -export SUMERAGI_TRUSTED_PEERS='[{"address":"127.0.0.1:1341", "public_key": "ed01201C61FAF8FE94E253B93114240394F79A607B7FA55F9E5A41EBEC74B88055768B"}]' -# Create tmp file for genesis -export IROHA2_GENESIS_PATH="$(mktemp).json" -# Create tmp folder for block storage -export KURA_BLOCK_STORE_PATH="$(mktemp -d)" -# Remove on exit -trap 'rm -rf -- "$IROHA2_GENESIS_PATH" "$KURA_BLOCK_STORE_PATH"' EXIT - -# Create invalid genesis -# NewAssetDefinition replaced with AssetDefinition -sed 's/NewAssetDefinition/AssetDefinition/' ./configs/swarm/genesis.json > $IROHA2_GENESIS_PATH - -timeout 1m target/debug/iroha --submit-genesis 2>&1 | tee /dev/stderr | grep -q 'Transaction validation failed in genesis block' diff --git a/scripts/update_configs.sh b/scripts/update_configs.sh deleted file mode 100755 index 4e005a111e8..00000000000 --- a/scripts/update_configs.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# This script is intended for release updates, when LTS and Stable branch configurations may change. -# -# # Example -# -# You run it like: -# `./update_configs.sh lts` -# or: -# `./update_configs.sh stable` - -MSG="Use './update_configs.sh lts' or './update_configs.sh stable'" - -if [ -z "$1" ]; then - echo $MSG && exit 1 -fi -if [ "$1" != "stable" ] && [ "$1" != "lts" ]; then - echo $MSG && exit 1 -fi - -curl https://raw.githubusercontent.com/hyperledger/iroha/stable/configs/peer/config.json -o ./configs/client/$1/config.json -curl https://raw.githubusercontent.com/hyperledger/iroha/iroha2-lts/configs/peer/config.json -o ./configs/client/$1/config.json - -curl https://raw.githubusercontent.com/hyperledger/iroha/stable/configs/peer/config.json -o ./configs/peer/$1/config.json -curl https://raw.githubusercontent.com/hyperledger/iroha/stable/configs/peer/genesis.json -o ./configs/peer/$1/genesis.json -curl https://raw.githubusercontent.com/hyperledger/iroha/stable/configs/peer/executor.wasm -o ./configs/peer/$1/executor.wasm diff --git a/smart_contract/README.md b/smart_contract/README.md index 430c73f33ec..5231e044444 100644 --- a/smart_contract/README.md +++ b/smart_contract/README.md @@ -8,10 +8,10 @@ Check the [WASM section of our tutorial](https://hyperledger.github.io/iroha-2-d ## Running tests -To be able to run tests compiled for `wasm32-unknown-unknown` target install `iroha_wasm_test_runner` from the root of the iroha repository: +To be able to run tests compiled for `wasm32-unknown-unknown` target install `iroha_wasm_test_runner` from the root of the Iroha repository: ```bash -cargo install --path tools/wasm_test_runner +cargo install --path tools/wasm_test_runner ``` Then run tests: diff --git a/telemetry/src/lib.rs b/telemetry/src/lib.rs index 0fb3ec02ebd..0cd65ed95d3 100644 --- a/telemetry/src/lib.rs +++ b/telemetry/src/lib.rs @@ -1,4 +1,4 @@ -//! Crate with iroha telemetry processing +//! Crate with Iroha telemetry processing #[cfg(feature = "dev-telemetry")] pub mod dev; diff --git a/tools/kagami/src/main.rs b/tools/kagami/src/main.rs index 270e140994e..e809b465d19 100644 --- a/tools/kagami/src/main.rs +++ b/tools/kagami/src/main.rs @@ -1,4 +1,4 @@ -//! CLI for generating iroha sample configuration, genesis and +//! 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}; diff --git a/tools/swarm/src/cli.rs b/tools/swarm/src/cli.rs index 178824f3cdc..42bdbb30675 100644 --- a/tools/swarm/src/cli.rs +++ b/tools/swarm/src/cli.rs @@ -120,7 +120,7 @@ mod tests { #[test] fn doesnt_allow_multiple_sources() { - let _ = match_args("-p 1 --build . --image hp/iroha --config-dir ./ --outfile test.yml") + let _ = match_args("-p 1 --build . --image hp/irohad --config-dir ./ --outfile test.yml") .unwrap_err(); } diff --git a/tools/swarm/src/compose.rs b/tools/swarm/src/compose.rs index e1e88bd8306..99bfd684886 100644 --- a/tools/swarm/src/compose.rs +++ b/tools/swarm/src/compose.rs @@ -20,7 +20,7 @@ use crate::{cli::SourceParsed, util::AbsolutePath}; const DIR_CONFIG_IN_DOCKER: &str = "/config"; const PATH_TO_GENESIS: &str = "/config/genesis.json"; const GENESIS_KEYPAIR_SEED: &[u8; 7] = b"genesis"; -const COMMAND_SUBMIT_GENESIS: &str = "iroha --submit-genesis"; +const COMMAND_SUBMIT_GENESIS: &str = "irohad --submit-genesis"; const DOCKER_COMPOSE_VERSION: &str = "3.8"; const PLATFORM_ARCHITECTURE: &str = "linux/amd64"; @@ -466,7 +466,7 @@ mod peer_generator { const BASE_PORT_P2P: u16 = 1337; const BASE_PORT_API: u16 = 8080; - const BASE_SERVICE_NAME: &'_ str = "iroha"; + const BASE_SERVICE_NAME: &'_ str = "irohad"; #[derive(Clone)] pub struct Peer { @@ -684,7 +684,7 @@ mod tests { volumes: - ./configs/peer/legacy_stable:/config init: true - command: iroha --submit-genesis + command: irohad --submit-genesis "#]]; expected.assert_eq(&actual); } @@ -765,7 +765,7 @@ mod tests { volumes: - ./config:/config init: true - command: iroha --submit-genesis + command: irohad --submit-genesis healthcheck: test: test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0 interval: 2s diff --git a/torii/src/routing.rs b/torii/src/routing.rs index 66e7b3ebe90..5ed4e40240e 100644 --- a/torii/src/routing.rs +++ b/torii/src/routing.rs @@ -332,10 +332,10 @@ pub mod profiling { #[allow(clippy::unsafe_derive_deserialize)] #[derive(Serialize, Deserialize, Clone, Copy)] pub struct ProfileParams { - /// How often to sample iroha + /// How often to sample Iroha #[serde(default = "ProfileParams::default_frequency")] frequency: NonZeroU16, - /// How long to sample iroha + /// How long to sample Iroha #[serde(default = "ProfileParams::default_seconds")] seconds: NonZeroU64, } From 148e97cfce6f69be545b10965d76ee46b27ba295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Tue, 28 May 2024 18:12:27 +0300 Subject: [PATCH 2/4] refactor(iroha): rename iroha_client_cli to iroha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- CONTRIBUTING.md | 2 +- Cargo.lock | 6 +- Cargo.toml | 2 +- Dockerfile | 4 +- Dockerfile.glibc | 2 +- README.md | 13 ++-- client/Cargo.toml | 2 +- client/README.md | 4 +- client/benches/torii.rs | 25 +++--- client/benches/tps/utils.rs | 2 +- client/examples/million_accounts_genesis.rs | 4 +- client/examples/register_1000_triggers.rs | 4 +- client/examples/tutorial.rs | 44 +++++------ client/src/http.rs | 4 +- client/tests/integration/add_domain.rs | 4 +- client/tests/integration/asset.rs | 14 ++-- client/tests/integration/asset_propagation.rs | 4 +- .../integration/domain_owner_permissions.rs | 2 +- client/tests/integration/events/data.rs | 4 +- .../tests/integration/events/notification.rs | 2 +- client/tests/integration/events/pipeline.rs | 4 +- .../extra_functional/connected_peers.rs | 2 +- .../multiple_blocks_created.rs | 2 +- .../extra_functional/offline_peers.rs | 2 +- .../extra_functional/restart_peer.rs | 2 +- .../extra_functional/unregister_peer.rs | 8 +- .../extra_functional/unstable_network.rs | 12 ++- client/tests/integration/non_mintable.rs | 2 +- client/tests/integration/pagination.rs | 2 +- client/tests/integration/permissions.rs | 77 +++++++++---------- client/tests/integration/queries/account.rs | 2 +- client/tests/integration/queries/asset.rs | 2 +- client/tests/integration/queries/mod.rs | 2 +- .../tests/integration/queries/query_errors.rs | 2 +- client/tests/integration/queries/role.rs | 2 +- .../integration/queries/smart_contract.rs | 2 +- client/tests/integration/roles.rs | 2 +- client/tests/integration/set_parameter.rs | 2 +- client/tests/integration/sorting.rs | 2 +- client/tests/integration/status_response.rs | 2 +- client/tests/integration/transfer_asset.rs | 20 ++--- .../integration/triggers/by_call_trigger.rs | 2 +- .../integration/triggers/data_trigger.rs | 2 +- .../integration/triggers/event_trigger.rs | 2 +- .../integration/triggers/time_trigger.rs | 2 +- .../integration/triggers/trigger_rollback.rs | 2 +- client/tests/integration/tx_history.rs | 2 +- client/tests/integration/tx_rollback.rs | 2 +- client/tests/integration/upgrade.rs | 2 +- .../ui_fail/cant_filter_singular_query.rs | 2 +- .../ui_fail/cant_filter_singular_query.stderr | 2 +- client_cli/Cargo.toml | 6 +- client_cli/README.md | 48 ++++++------ client_cli/pytests/README.md | 16 ++-- client_cli/src/main.rs | 60 +++++++-------- core/src/smartcontracts/isi/triggers/set.rs | 2 +- core/test_network/Cargo.toml | 2 +- core/test_network/src/lib.rs | 6 +- flake.nix | 2 +- scripts/test_env.py | 4 +- 60 files changed, 232 insertions(+), 235 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index beeca40fe7a..22024e8e2f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -199,7 +199,7 @@ Follow these commit guidelines: - To run the source-code based tests, execute [`cargo test`](https://doc.rust-lang.org/cargo/commands/cargo-test.html) in the Iroha root. Note that this is a long process. - To run benchmarks, execute [`cargo bench`](https://doc.rust-lang.org/cargo/commands/cargo-bench.html) from the Iroha root. To help debug benchmark outputs, set the `debug_assertions` environment variable like so: `RUSTFLAGS="--cfg debug_assertions" cargo bench`. - If you are working on a particular component, be mindful that when you run `cargo test` in a [workspace](https://doc.rust-lang.org/cargo/reference/workspaces.html), it will only run the tests for that workspace, which usually doesn't include any [integration tests](https://www.testingxperts.com/blog/what-is-integration-testing). -- If you want to test your changes on a minimal network, the provided [`docker-compose.yml`](configs/swarm/docker-compose.yml) creates a network of 4 Iroha peers in docker containers that can be used to test consensus and asset propagation-related logic. We recommend interacting with that network using either [`iroha-python`](https://github.com/hyperledger/iroha-python), or the included `iroha_client_cli`. +- If you want to test your changes on a minimal network, the provided [`docker-compose.yml`](configs/swarm/docker-compose.yml) creates a network of 4 Iroha peers in docker containers that can be used to test consensus and asset propagation-related logic. We recommend interacting with that network using either [`iroha-python`](https://github.com/hyperledger/iroha-python), or the included Iroha client CLI. - Do not remove failing tests. Even tests that are ignored will be run in our pipeline eventually. - If possible, please benchmark your code both before and after making your changes, as a significant performance regression can break existing users' installations. diff --git a/Cargo.lock b/Cargo.lock index 3e3179fc3ef..d51bc57ea19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2764,7 +2764,7 @@ dependencies = [ ] [[package]] -name = "iroha_client" +name = "iroha" version = "2.0.0-pre-rc.21" dependencies = [ "attohttpc", @@ -2820,7 +2820,7 @@ dependencies = [ "erased-serde", "error-stack", "eyre", - "iroha_client", + "iroha", "iroha_config_base", "iroha_primitives", "json5", @@ -5631,7 +5631,7 @@ version = "2.0.0-pre-rc.21" dependencies = [ "eyre", "futures", - "iroha_client", + "iroha", "iroha_config", "iroha_core", "iroha_crypto", diff --git a/Cargo.toml b/Cargo.toml index dd1a096b653..7b416cec711 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ iroha_torii = { version = "=2.0.0-pre-rc.21", path = "torii" } iroha_torii_derive = { version = "=2.0.0-pre-rc.21", path = "torii/derive" } iroha_torii_const = { version = "=2.0.0-pre-rc.21", path = "torii/const" } -iroha_client = { version = "=2.0.0-pre-rc.21", path = "client" } +iroha = { version = "=2.0.0-pre-rc.21", path = "client" } iroha_macro_utils = { version = "=2.0.0-pre-rc.21", path = "macro/utils" } iroha_telemetry = { version = "=2.0.0-pre-rc.21", path = "telemetry" } diff --git a/Dockerfile b/Dockerfile index e9d570f8179..2497b6e7615 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/x86_64-linux-musl-native/bin/ # builder stage WORKDIR /iroha COPY . . -# FIXME: consider building only `irohad`, `iroha_client_cli`, and `kagami`? +# FIXME: consider building only `irohad`, `iroha`, and `kagami`? RUN cargo build --target x86_64-unknown-linux-musl --profile deploy @@ -67,7 +67,7 @@ RUN set -ex && \ chown $USER:$USER $WASM_DIRECTORY COPY --from=builder $TARGET_DIR/irohad $BIN_PATH -COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH +COPY --from=builder $TARGET_DIR/iroha $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER CMD ["irohad"] diff --git a/Dockerfile.glibc b/Dockerfile.glibc index 394280db5ee..0aacc8d256e 100644 --- a/Dockerfile.glibc +++ b/Dockerfile.glibc @@ -56,7 +56,7 @@ RUN set -ex && \ chown $USER:$USER $WASM_DIRECTORY COPY --from=builder $TARGET_DIR/irohad $BIN_PATH -COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH +COPY --from=builder $TARGET_DIR/iroha $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER CMD ["irohad"] diff --git a/README.md b/README.md index 5f23254cbf1..11d8cfb1c72 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Run API functional tests: ```bash cargo build chmod +x target/debug/irohad -chmod +x target/debug/iroha_client_cli +chmod +x target/debug/iroha bash ./scripts/test_env.sh setup bash ./scripts/tests/register_mint_quantity.sh @@ -124,19 +124,18 @@ docker compose up With the `docker-compose` instance running, use [Iroha Client CLI](./client_cli/README.md): ```bash -cargo run --bin iroha_client_cli -- --config ./configs/swarm/client.toml +cargo run --bin iroha -- --config ./configs/swarm/client.toml ``` ## Integration Iroha project mainly consists of the following crates: -* [`iroha`](cli) is the command-line application for deploying an Iroha peer. Contains the routing table and definitions of API endpoints. -* [`iroha_actor`](actor) provides a message passing model for Iroha components. -* [`iroha_client`](client) provides a library for building clients that communicate with peers. -* [`iroha_client_cli`](client_cli) is the reference implementation of a client. -* [`iroha_config`](config) handles configuration and documentation generation for options and run-time changes. +* [`iroha`](client) provides a library for building clients that communicate with peers. +* [`irohad`](server cli) is the command-line application for deploying an Iroha peer. Contains the routing table and definitions of API endpoints. +* [`iroha_client_cli`](client cli) is the reference implementation of a client. * [`iroha_core`](core) is the primary library used by all other crates, including the peer endpoint management. +* [`iroha_config`](config) handles configuration and documentation generation for options and run-time changes. * [`iroha_crypto`](crypto) defines cryptographic aspects of Iroha. * [`kagami`](tools/kagami) is used to generate cryptographic keys, default genesis, configuration reference, and schema. * [`iroha_data_model`](data_model) defines common data models in Iroha. diff --git a/client/Cargo.toml b/client/Cargo.toml index 13e823959b3..c3a99eba1ae 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroha_client" +name = "iroha" edition.workspace = true version.workspace = true diff --git a/client/README.md b/client/README.md index 791dbe2a8f0..9faa164a258 100644 --- a/client/README.md +++ b/client/README.md @@ -16,9 +16,9 @@ Follow the [Iroha 2 tutorial](https://hyperledger.github.io/iroha-2-docs/guide/r Add the following to the manifest file of your Rust project: ```toml -iroha_client = { git = "https://github.com/hyperledger/iroha", branch = "main" } +iroha = { git = "https://github.com/hyperledger/iroha", branch = "main" } ``` ## Examples -We highly recommend looking at the sample [`iroha_client_cli`](../client_cli) implementation binary as well as our [tutorial](https://hyperledger.github.io/iroha-2-docs/guide/rust.html) for more examples and explanations. +We highly recommend looking at the sample [`iroha`](../client_cli) implementation binary as well as our [tutorial](https://hyperledger.github.io/iroha-2-docs/guide/rust.html) for more examples and explanations. diff --git a/client/benches/torii.rs b/client/benches/torii.rs index ca8df450b81..3619df46cae 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -3,14 +3,14 @@ use std::thread; use criterion::{criterion_group, criterion_main, Criterion, Throughput}; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{ +use iroha::{ client::{asset, Client}, data_model::prelude::*, }; use iroha_genesis::{GenesisNetwork, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; use iroha_version::Encode; +use irohad::samples::{construct_executor, get_config}; use test_network::{get_chain_id, get_key_pair, Peer as TestPeer, PeerBuilder, TestRuntime}; use test_samples::gen_account_in; use tokio::runtime::Runtime; @@ -52,7 +52,7 @@ fn query_requests(criterion: &mut Criterion) { rt.block_on(builder.start_with_peer(&mut peer)); rt.block_on(async { iroha_logger::test_logger() - .reload_level(iroha_client::data_model::Level::ERROR) + .reload_level(iroha::data_model::Level::ERROR) .await .unwrap() }); @@ -68,13 +68,13 @@ fn query_requests(criterion: &mut Criterion) { 200u32, AssetId::new(asset_definition_id, account_id.clone()), ); - let client_config = iroha_client::samples::get_client_config( + let client_config = iroha::samples::get_client_config( get_chain_id(), get_key_pair(test_network::Signatory::Alice), format!("http://{}", peer.api_address).parse().unwrap(), ); - let iroha_client = Client::new(client_config); + let iroha = Client::new(client_config); thread::sleep(std::time::Duration::from_millis(5000)); let instructions: [InstructionBox; 4] = [ @@ -83,7 +83,7 @@ fn query_requests(criterion: &mut Criterion) { create_asset.into(), mint_asset.into(), ]; - let _ = iroha_client + let _ = iroha .submit_all(instructions) .expect("Failed to prepare state"); @@ -94,9 +94,8 @@ fn query_requests(criterion: &mut Criterion) { let _dropable = group.throughput(Throughput::Bytes(request.encode().len() as u64)); let _dropable2 = group.bench_function("query", |b| { b.iter(|| { - let iter: Result, _> = iroha_client - .request(request.clone()) - .and_then(Iterator::collect); + let iter: Result, _> = + iroha.request(request.clone()).and_then(Iterator::collect); match iter { Ok(assets) => { @@ -157,14 +156,14 @@ fn instruction_submits(criterion: &mut Criterion) { let (account_id, _account_keypair) = gen_account_in("domain"); let create_account = Register::account(Account::new(account_id.clone())).into(); let asset_definition_id: AssetDefinitionId = "xor#domain".parse().expect("Valid"); - let client_config = iroha_client::samples::get_client_config( + let client_config = iroha::samples::get_client_config( get_chain_id(), get_key_pair(test_network::Signatory::Alice), format!("http://{}", peer.api_address).parse().unwrap(), ); - let iroha_client = Client::new(client_config); + let iroha = Client::new(client_config); thread::sleep(std::time::Duration::from_millis(5000)); - let _ = iroha_client + let _ = iroha .submit_all([create_domain, create_account]) .expect("Failed to create role."); thread::sleep(std::time::Duration::from_millis(500)); @@ -176,7 +175,7 @@ fn instruction_submits(criterion: &mut Criterion) { 200u32, AssetId::new(asset_definition_id.clone(), account_id.clone()), ); - match iroha_client.submit(mint_asset) { + match iroha.submit(mint_asset) { Ok(_) => success_count += 1, Err(e) => { eprintln!("Failed to execute instruction: {e}"); diff --git a/client/benches/tps/utils.rs b/client/benches/tps/utils.rs index a7f0fd662c6..07f6a350fa3 100644 --- a/client/benches/tps/utils.rs +++ b/client/benches/tps/utils.rs @@ -1,7 +1,7 @@ use std::{fmt, fs::File, io::BufReader, path::Path, sync::mpsc, thread, time}; use eyre::{Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::Client, crypto::KeyPair, data_model::{ diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index d30cb6a6e15..9a802816672 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -1,11 +1,11 @@ //! This file contains examples from the Rust tutorial. use std::{thread, time::Duration}; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{crypto::KeyPair, data_model::prelude::*}; +use iroha::{crypto::KeyPair, data_model::prelude::*}; use iroha_data_model::isi::InstructionBox; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; +use irohad::samples::{construct_executor, get_config}; use test_network::{ get_chain_id, get_key_pair, wait_for_genesis_committed, Peer as TestPeer, PeerBuilder, TestRuntime, diff --git a/client/examples/register_1000_triggers.rs b/client/examples/register_1000_triggers.rs index fff4a33159c..b4461fa2001 100644 --- a/client/examples/register_1000_triggers.rs +++ b/client/examples/register_1000_triggers.rs @@ -2,11 +2,11 @@ //! Used to show Iroha's trigger deduplication capabilities use std::str::FromStr; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{client::Client, data_model::prelude::*}; +use iroha::{client::Client, data_model::prelude::*}; use iroha_data_model::trigger::TriggerId; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; +use irohad::samples::{construct_executor, get_config}; use test_network::{ get_chain_id, get_key_pair, wait_for_genesis_committed_with_max_retries, Peer as TestPeer, PeerBuilder, TestClient, TestRuntime, diff --git a/client/examples/tutorial.rs b/client/examples/tutorial.rs index a5194db6f3d..1589b8d78ad 100644 --- a/client/examples/tutorial.rs +++ b/client/examples/tutorial.rs @@ -2,7 +2,7 @@ //! use eyre::{Error, WrapErr}; -use iroha_client::config::Config; +use iroha::config::Config; use iroha_primitives::numeric::Numeric; // #region rust_config_crates // #endregion rust_config_crates @@ -31,7 +31,7 @@ fn main() { fn domain_registration_test(config: Config) -> Result<(), Error> { // #region domain_register_example_crates - use iroha_client::{ + use iroha::{ client::Client, data_model::{ metadata::UnlimitedMetadata, @@ -52,19 +52,19 @@ fn domain_registration_test(config: Config) -> Result<(), Error> { // #region rust_client_create // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #endregion rust_client_create // #region domain_register_example_prepare_tx // Prepare a transaction let metadata = UnlimitedMetadata::default(); let instructions: Vec = vec![create_looking_glass.into()]; - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); // #endregion domain_register_example_prepare_tx // #region domain_register_example_submit_tx // Submit a prepared domain registration transaction - iroha_client + iroha .submit_transaction(&tx) .wrap_err("Failed to submit transaction")?; // #endregion domain_register_example_submit_tx @@ -75,7 +75,7 @@ fn domain_registration_test(config: Config) -> Result<(), Error> { fn account_definition_test() -> Result<(), Error> { // #region account_definition_comparison - use iroha_client::{crypto::KeyPair, data_model::prelude::AccountId}; + use iroha::{crypto::KeyPair, data_model::prelude::AccountId}; // Generate a new public key for a new account let (public_key, _) = KeyPair::random().into_parts(); @@ -97,7 +97,7 @@ fn account_definition_test() -> Result<(), Error> { fn account_registration_test(config: Config) -> Result<(), Error> { // #region register_account_crates - use iroha_client::{ + use iroha::{ client::Client, crypto::KeyPair, data_model::{ @@ -108,7 +108,7 @@ fn account_registration_test(config: Config) -> Result<(), Error> { // #endregion register_account_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region register_account_create // Generate a new public key for a new account @@ -129,12 +129,12 @@ fn account_registration_test(config: Config) -> Result<(), Error> { // Account's RegisterBox let metadata = UnlimitedMetadata::new(); let instructions: Vec = vec![create_account.into()]; - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); // #endregion register_account_prepare_tx // #region register_account_submit_tx // Submit a prepared account registration transaction - iroha_client.submit_transaction(&tx)?; + iroha.submit_transaction(&tx)?; // #endregion register_account_submit_tx // Finish the test successfully @@ -145,7 +145,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { // #region register_asset_crates use std::str::FromStr as _; - use iroha_client::{ + use iroha::{ client::Client, crypto::KeyPair, data_model::prelude::{ @@ -155,7 +155,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { // #endregion register_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region register_asset_create_asset // Create an asset @@ -169,7 +169,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { Register::asset_definition(AssetDefinition::numeric(asset_def_id.clone()).mintable_once()); // Submit a registration time - iroha_client.submit(register_time)?; + iroha.submit(register_time)?; // #endregion register_asset_init_submit // Generate a new public key for a new account @@ -184,7 +184,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { let mint = Mint::asset_numeric(numeric!(12.34), AssetId::new(asset_def_id, account_id)); // Submit a minting transaction - iroha_client.submit_all([mint])?; + iroha.submit_all([mint])?; // #endregion register_asset_mint_submit // Finish the test successfully @@ -195,14 +195,14 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #region mint_asset_crates use std::str::FromStr; - use iroha_client::{ + use iroha::{ client::Client, data_model::prelude::{AccountId, AssetDefinitionId, AssetId, Mint}, }; // #endregion mint_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // Define the instances of an Asset and Account // #region mint_asset_define_asset_account @@ -218,7 +218,7 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #endregion mint_asset_mint // #region mint_asset_submit_tx - iroha_client + iroha .submit(mint_roses) .wrap_err("Failed to submit transaction")?; // #endregion mint_asset_submit_tx @@ -236,7 +236,7 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #endregion mint_asset_mint_alt // #region mint_asset_submit_tx_alt - iroha_client + iroha .submit(mint_roses_alt) .wrap_err("Failed to submit transaction")?; // #endregion mint_asset_submit_tx_alt @@ -249,14 +249,14 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #region burn_asset_crates use std::str::FromStr; - use iroha_client::{ + use iroha::{ client::Client, data_model::prelude::{AccountId, AssetDefinitionId, AssetId, Burn}, }; // #endregion burn_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region burn_asset_define_asset_account // Define the instances of an Asset and Account @@ -272,7 +272,7 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #endregion burn_asset_burn // #region burn_asset_submit_tx - iroha_client + iroha .submit(burn_roses) .wrap_err("Failed to submit transaction")?; // #endregion burn_asset_submit_tx @@ -290,7 +290,7 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #endregion burn_asset_burn_alt // #region burn_asset_submit_tx_alt - iroha_client + iroha .submit(burn_roses_alt) .wrap_err("Failed to submit transaction")?; // #endregion burn_asset_submit_tx_alt diff --git a/client/src/http.rs b/client/src/http.rs index 25a147fbed5..253b3fd808a 100644 --- a/client/src/http.rs +++ b/client/src/http.rs @@ -96,7 +96,7 @@ pub mod ws { /// /// ```rust /// use eyre::{eyre, Result}; - /// use iroha_client::http::{ + /// use iroha::http::{ /// ws::conn_flow::{Events as FlowEvents, Init as FlowInit, InitData}, /// Method, RequestBuilder, /// }; @@ -143,7 +143,7 @@ pub mod ws { /// /// ```rust /// use eyre::Result; - /// use iroha_client::{ + /// use iroha::{ /// client::events_api::flow as events_api_flow, /// data_model::prelude::EventBox, /// http::{ diff --git a/client/tests/integration/add_domain.rs b/client/tests/integration/add_domain.rs index 443978885d8..514e18b85d6 100644 --- a/client/tests/integration/add_domain.rs +++ b/client/tests/integration/add_domain.rs @@ -1,12 +1,12 @@ use std::thread; use eyre::Result; -use iroha_client::{client, data_model::prelude::*}; +use iroha::{client, data_model::prelude::*}; use iroha_config::parameters::actual::Root as Config; use test_network::*; #[test] -// This test suite is also covered at the UI level in the iroha_client_cli tests +// This test suite is also covered at the UI level in the iroha_cli tests // in test_register_domains.py fn client_add_domain_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()> { diff --git a/client/tests/integration/asset.rs b/client/tests/integration/asset.rs index e27a69b91de..6c55cb4f2da 100644 --- a/client/tests/integration/asset.rs +++ b/client/tests/integration/asset.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, crypto::KeyPair, data_model::prelude::*, @@ -17,7 +17,7 @@ use test_network::*; use test_samples::{gen_account_in, ALICE_ID, BOB_ID}; #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_register_asset_definitions.py fn client_register_asset_should_add_asset_once_but_not_twice() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_620).start_with_runtime(); @@ -95,7 +95,7 @@ fn unregister_asset_should_remove_asset_from_account() -> Result<()> { } #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_mint_assets.py fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_000).start_with_runtime(); @@ -106,7 +106,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = numeric!(200); let mint = Mint::asset_numeric( @@ -137,7 +137,7 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount( let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = Numeric::new(2_u128.pow(65), 0); let mint = Mint::asset_numeric( @@ -168,7 +168,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let asset_definition = AssetDefinition::numeric(asset_definition_id.clone()); let create_asset = Register::asset_definition(asset_definition); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = numeric!(123.456); @@ -210,7 +210,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { } #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_register_asset_definitions.py fn client_add_asset_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_520).start_with_runtime(); diff --git a/client/tests/integration/asset_propagation.rs b/client/tests/integration/asset_propagation.rs index 84396976c85..1e8326dd237 100644 --- a/client/tests/integration/asset_propagation.rs +++ b/client/tests/integration/asset_propagation.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -13,7 +13,7 @@ use test_network::*; use test_samples::gen_account_in; #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_mint_asset.py fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_another_peer( ) -> Result<()> { diff --git a/client/tests/integration/domain_owner_permissions.rs b/client/tests/integration/domain_owner_permissions.rs index e9751363444..d6fd536b68a 100644 --- a/client/tests/integration/domain_owner_permissions.rs +++ b/client/tests/integration/domain_owner_permissions.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::data_model::prelude::*; +use iroha::data_model::prelude::*; use iroha_data_model::transaction::error::TransactionRejectionReason; use serde_json::json; use test_network::*; diff --git a/client/tests/integration/events/data.rs b/client/tests/integration/events/data.rs index 1ce0094bcdd..aa4aaa16932 100644 --- a/client/tests/integration/events/data.rs +++ b/client/tests/integration/events/data.rs @@ -1,7 +1,7 @@ use std::{fmt::Write as _, str::FromStr, sync::mpsc, thread}; use eyre::Result; -use iroha_client::data_model::{prelude::*, transaction::WasmSmartContract}; +use iroha::data_model::{prelude::*, transaction::WasmSmartContract}; use parity_scale_codec::Encode as _; use serde_json::json; use test_network::*; @@ -207,7 +207,7 @@ fn produce_multiple_events() -> Result<()> { "CanSetKeyValueInAccount".parse()?, json!({ "account_id": alice_id }), ); - let role = iroha_client::data_model::role::Role::new(role_id.clone()) + let role = iroha::data_model::role::Role::new(role_id.clone()) .add_permission(token_1.clone()) .add_permission(token_2.clone()); let instructions = [Register::role(role.clone())]; diff --git a/client/tests/integration/events/notification.rs b/client/tests/integration/events/notification.rs index 093fd213bc3..8c36edc64c3 100644 --- a/client/tests/integration/events/notification.rs +++ b/client/tests/integration/events/notification.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_client::data_model::prelude::*; +use iroha::data_model::prelude::*; use test_network::*; use test_samples::ALICE_ID; diff --git a/client/tests/integration/events/pipeline.rs b/client/tests/integration/events/pipeline.rs index 90b19fde177..28afa87ac40 100644 --- a/client/tests/integration/events/pipeline.rs +++ b/client/tests/integration/events/pipeline.rs @@ -1,7 +1,7 @@ use std::thread::{self, JoinHandle}; use eyre::Result; -use iroha_client::{ +use iroha::{ crypto::HashOf, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -85,7 +85,7 @@ fn test_with_instruction_and_status_and_port( #[derive(Clone)] struct Checker { - listener: iroha_client::client::Client, + listener: iroha::client::Client, hash: HashOf, } diff --git a/client/tests/integration/extra_functional/connected_peers.rs b/client/tests/integration/extra_functional/connected_peers.rs index 000a352ce3d..fb98d69e141 100644 --- a/client/tests/integration/extra_functional/connected_peers.rs +++ b/client/tests/integration/extra_functional/connected_peers.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::{Context, Result}; -use iroha_client::{ +use iroha::{ client::Client, data_model::{ isi::{Register, Unregister}, diff --git a/client/tests/integration/extra_functional/multiple_blocks_created.rs b/client/tests/integration/extra_functional/multiple_blocks_created.rs index 0c96b849824..afa8737c974 100644 --- a/client/tests/integration/extra_functional/multiple_blocks_created.rs +++ b/client/tests/integration/extra_functional/multiple_blocks_created.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, diff --git a/client/tests/integration/extra_functional/offline_peers.rs b/client/tests/integration/extra_functional/offline_peers.rs index b6455eed100..f0d847ee048 100644 --- a/client/tests/integration/extra_functional/offline_peers.rs +++ b/client/tests/integration/extra_functional/offline_peers.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::{ diff --git a/client/tests/integration/extra_functional/restart_peer.rs b/client/tests/integration/extra_functional/restart_peer.rs index 5b1995ad2d2..2b919073c68 100644 --- a/client/tests/integration/extra_functional/restart_peer.rs +++ b/client/tests/integration/extra_functional/restart_peer.rs @@ -1,7 +1,7 @@ use std::{str::FromStr, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/extra_functional/unregister_peer.rs b/client/tests/integration/extra_functional/unregister_peer.rs index 5742025cc01..3ea3a3292f8 100644 --- a/client/tests/integration/extra_functional/unregister_peer.rs +++ b/client/tests/integration/extra_functional/unregister_peer.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -67,12 +67,12 @@ fn unstable_network_stable_after_add_and_after_remove_peer() -> Result<()> { } fn check_assets( - iroha_client: &client::Client, + iroha: &client::Client, account_id: &AccountId, asset_definition_id: &AssetDefinitionId, quantity: Numeric, ) { - iroha_client + iroha .poll_request_with_period( client::asset::by_account_id(account_id.clone()), Config::block_sync_gossip_time(), @@ -109,7 +109,7 @@ fn mint( fn init() -> Result<( tokio::runtime::Runtime, test_network::Network, - iroha_client::client::Client, + iroha::client::Client, std::time::Duration, AccountId, AssetDefinitionId, diff --git a/client/tests/integration/extra_functional/unstable_network.rs b/client/tests/integration/extra_functional/unstable_network.rs index 52b2b9ad851..e96bfb428fc 100644 --- a/client/tests/integration/extra_functional/unstable_network.rs +++ b/client/tests/integration/extra_functional/unstable_network.rs @@ -1,7 +1,7 @@ use core::sync::atomic::Ordering; use std::thread; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{prelude::*, Level}, }; @@ -52,7 +52,7 @@ fn unstable_network( } let rt = Runtime::test(); // Given - let (network, iroha_client) = rt.block_on(async { + let (network, iroha) = rt.block_on(async { let mut configuration = Config::test(); configuration.chain_wide.max_transactions_in_block = MAX_TRANSACTIONS_IN_BLOCK.try_into().unwrap(); @@ -80,7 +80,7 @@ fn unstable_network( let asset_definition_id: AssetDefinitionId = "camomile#wonderland".parse().expect("Valid"); let register_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - iroha_client + iroha .submit_blocking(register_asset) .expect("Failed to register asset"); // Initially there are 0 camomile @@ -105,13 +105,11 @@ fn unstable_network( quantity, AssetId::new(asset_definition_id.clone(), account_id.clone()), ); - iroha_client - .submit(mint_asset) - .expect("Failed to create asset."); + iroha.submit(mint_asset).expect("Failed to create asset."); account_has_quantity = account_has_quantity.checked_add(quantity).unwrap(); thread::sleep(pipeline_time); - iroha_client + iroha .poll_request_with_period( client::asset::by_account_id(account_id.clone()), Config::pipeline_time(), diff --git a/client/tests/integration/non_mintable.rs b/client/tests/integration/non_mintable.rs index 301ecb93b81..b6561028e41 100644 --- a/client/tests/integration/non_mintable.rs +++ b/client/tests/integration/non_mintable.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{metadata::UnlimitedMetadata, prelude::*}, }; diff --git a/client/tests/integration/pagination.rs b/client/tests/integration/pagination.rs index 176e3726e2e..5b508734523 100644 --- a/client/tests/integration/pagination.rs +++ b/client/tests/integration/pagination.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{asset, Client, QueryResult}, data_model::{asset::AssetDefinition, prelude::*, query::Pagination}, }; diff --git a/client/tests/integration/permissions.rs b/client/tests/integration/permissions.rs index 1f47541466b..2a891581f2d 100644 --- a/client/tests/integration/permissions.rs +++ b/client/tests/integration/permissions.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread, time::Duration}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::prelude::*, @@ -56,8 +56,8 @@ fn genesis_transactions_are_validated() { } } -fn get_assets(iroha_client: &Client, id: &AccountId) -> Vec { - iroha_client +fn get_assets(iroha: &Client, id: &AccountId) -> Vec { + iroha .request(client::asset::by_account_id(id.clone())) .expect("Failed to execute request.") .collect::>>() @@ -69,8 +69,8 @@ fn get_assets(iroha_client: &Client, id: &AccountId) -> Vec { fn permissions_disallow_asset_transfer() { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_730).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(10_730).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -81,8 +81,8 @@ fn permissions_disallow_asset_transfer() { Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); let mouse_keypair = KeyPair::random(); - let alice_start_assets = get_assets(&iroha_client, &alice_id); - iroha_client + let alice_start_assets = get_assets(&iroha, &alice_id); + iroha .submit_blocking(create_asset) .expect("Failed to prepare state."); @@ -91,7 +91,7 @@ fn permissions_disallow_asset_transfer() { quantity, AssetId::new(asset_definition_id.clone(), bob_id.clone()), ); - iroha_client + iroha .submit_blocking(mint_asset) .expect("Failed to create asset."); @@ -104,7 +104,7 @@ fn permissions_disallow_asset_transfer() { let transfer_tx = TransactionBuilder::new(chain_id, mouse_id) .with_instructions([transfer_asset]) .sign(&mouse_keypair); - let err = iroha_client + let err = iroha .submit_transaction_blocking(&transfer_tx) .expect_err("Transaction was not rejected."); let rejection_reason = err @@ -115,7 +115,7 @@ fn permissions_disallow_asset_transfer() { rejection_reason, &TransactionRejectionReason::Validation(ValidationFail::NotPermitted(_)) )); - let alice_assets = get_assets(&iroha_client, &alice_id); + let alice_assets = get_assets(&iroha, &alice_id); assert_eq!(alice_assets, alice_start_assets); } @@ -124,7 +124,7 @@ fn permissions_disallow_asset_transfer() { fn permissions_disallow_asset_burn() { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_735).start_with_runtime(); + let (_rt, _peer, iroha) = ::new().with_port(10_735).start_with_runtime(); let alice_id = ALICE_ID.clone(); let bob_id = BOB_ID.clone(); @@ -134,16 +134,16 @@ fn permissions_disallow_asset_burn() { Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); let mouse_keypair = KeyPair::random(); - let alice_start_assets = get_assets(&iroha_client, &alice_id); + let alice_start_assets = get_assets(&iroha, &alice_id); - iroha_client + iroha .submit_blocking(create_asset) .expect("Failed to prepare state."); let quantity = numeric!(200); let mint_asset = Mint::asset_numeric(quantity, AssetId::new(asset_definition_id.clone(), bob_id)); - iroha_client + iroha .submit_blocking(mint_asset) .expect("Failed to create asset."); let burn_asset = Burn::asset_numeric( @@ -154,7 +154,7 @@ fn permissions_disallow_asset_burn() { .with_instructions([burn_asset]) .sign(&mouse_keypair); - let err = iroha_client + let err = iroha .submit_transaction_blocking(&burn_tx) .expect_err("Transaction was not rejected."); let rejection_reason = err @@ -166,7 +166,7 @@ fn permissions_disallow_asset_burn() { &TransactionRejectionReason::Validation(ValidationFail::NotPermitted(_)) )); - let alice_assets = get_assets(&iroha_client, &alice_id); + let alice_assets = get_assets(&iroha, &alice_id); assert_eq!(alice_assets, alice_start_assets); } @@ -293,8 +293,8 @@ fn permissions_differ_not_only_by_names() { fn stored_vs_granted_token_payload() -> Result<()> { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_730).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(10_730).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -309,7 +309,7 @@ fn stored_vs_granted_token_payload() -> Result<()> { Register::account(new_mouse_account).into(), create_asset.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to register mouse"); @@ -321,8 +321,7 @@ fn stored_vs_granted_token_payload() -> Result<()> { JsonString::from_string_unchecked(format!( // Introducing some whitespaces // This way, if the executor compares just JSON strings, this test would fail - r##"{{ "asset_id" : "xor#wonderland#{}" }}"##, - mouse_id + r##"{{ "asset_id" : "xor#wonderland#{mouse_id}" }}"## )), ), alice_id, @@ -331,13 +330,13 @@ fn stored_vs_granted_token_payload() -> Result<()> { let transaction = TransactionBuilder::new(chain_id, mouse_id) .with_instructions([allow_alice_to_set_key_value_in_mouse_asset]) .sign(&mouse_keypair); - iroha_client + iroha .submit_transaction_blocking(&transaction) .expect("Failed to grant permission to alice."); // Check that alice can indeed mint mouse asset let set_key_value = SetKeyValue::asset(mouse_asset, Name::from_str("color")?, "red".to_owned()); - iroha_client + iroha .submit_blocking(set_key_value) .expect("Failed to mint asset for mouse."); @@ -347,8 +346,8 @@ fn stored_vs_granted_token_payload() -> Result<()> { #[test] #[allow(deprecated)] fn permissions_are_unified() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_230).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_230).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -370,19 +369,19 @@ fn permissions_are_unified() { alice_id, ); - iroha_client + iroha .submit_blocking(allow_alice_to_transfer_rose_1) .expect("failed to grant permission token"); - let _ = iroha_client + let _ = iroha .submit_blocking(allow_alice_to_transfer_rose_2) .expect_err("should reject due to duplication"); } #[test] fn associated_permissions_removed_on_unregister() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_240).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_240).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let bob_id = BOB_ID.clone(); let kingdom_id: DomainId = "kingdom".parse().expect("Valid"); @@ -397,7 +396,7 @@ fn associated_permissions_removed_on_unregister() { let allow_bob_to_set_kv_in_domain = Grant::permission(bob_to_set_kv_in_domain_token.clone(), bob_id.clone()); - iroha_client + iroha .submit_all_blocking([ InstructionBox::from(register_domain), allow_bob_to_set_kv_in_domain.into(), @@ -405,7 +404,7 @@ fn associated_permissions_removed_on_unregister() { .expect("failed to register domain and grant permission"); // check that bob indeed have granted permission - assert!(iroha_client + assert!(iroha .request(client::permission::by_account_id(bob_id.clone())) .and_then(std::iter::Iterator::collect::>>) .expect("failed to get permissions for bob") @@ -413,12 +412,12 @@ fn associated_permissions_removed_on_unregister() { .any(|token| { token == bob_to_set_kv_in_domain_token })); // unregister kingdom - iroha_client + iroha .submit_blocking(Unregister::domain(kingdom_id)) .expect("failed to unregister domain"); // check that permission is removed from bob - assert!(iroha_client + assert!(iroha .request(client::permission::by_account_id(bob_id)) .and_then(std::iter::Iterator::collect::>>) .expect("failed to get permissions for bob") @@ -428,8 +427,8 @@ fn associated_permissions_removed_on_unregister() { #[test] fn associated_permissions_removed_from_role_on_unregister() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_255).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_255).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let role_id: RoleId = "role".parse().expect("Valid"); let kingdom_id: DomainId = "kingdom".parse().expect("Valid"); @@ -444,12 +443,12 @@ fn associated_permissions_removed_from_role_on_unregister() { let role = Role::new(role_id.clone()).add_permission(set_kv_in_domain_token.clone()); let register_role = Register::role(role); - iroha_client + iroha .submit_all_blocking([InstructionBox::from(register_domain), register_role.into()]) .expect("failed to register domain and grant permission"); // check that role indeed have permission - assert!(iroha_client + assert!(iroha .request(client::role::by_id(role_id.clone())) .map(|role| role.permissions().cloned().collect::>()) .expect("failed to get permissions for role") @@ -457,12 +456,12 @@ fn associated_permissions_removed_from_role_on_unregister() { .any(|token| { token == set_kv_in_domain_token })); // unregister kingdom - iroha_client + iroha .submit_blocking(Unregister::domain(kingdom_id)) .expect("failed to unregister domain"); // check that permission is removed from role - assert!(iroha_client + assert!(iroha .request(client::role::by_id(role_id.clone())) .map(|role| role.permissions().cloned().collect::>()) .expect("failed to get permissions for role") diff --git a/client/tests/integration/queries/account.rs b/client/tests/integration/queries/account.rs index eb047c732cc..d89d74b8ac0 100644 --- a/client/tests/integration/queries/account.rs +++ b/client/tests/integration/queries/account.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, str::FromStr as _}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/queries/asset.rs b/client/tests/integration/queries/asset.rs index 68ce747732f..d306f5b9540 100644 --- a/client/tests/integration/queries/asset.rs +++ b/client/tests/integration/queries/asset.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{Client, ClientQueryError}, data_model::{ asset::AssetValue, diff --git a/client/tests/integration/queries/mod.rs b/client/tests/integration/queries/mod.rs index d53bb97853e..f9d15a11e62 100644 --- a/client/tests/integration/queries/mod.rs +++ b/client/tests/integration/queries/mod.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, ClientQueryError}, data_model::{ prelude::*, diff --git a/client/tests/integration/queries/query_errors.rs b/client/tests/integration/queries/query_errors.rs index 5d8194fc043..e3a756f1522 100644 --- a/client/tests/integration/queries/query_errors.rs +++ b/client/tests/integration/queries/query_errors.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, ClientQueryError}, data_model::{ prelude::*, diff --git a/client/tests/integration/queries/role.rs b/client/tests/integration/queries/role.rs index c537f5b557d..a2cd250a060 100644 --- a/client/tests/integration/queries/role.rs +++ b/client/tests/integration/queries/role.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{prelude::*, query::error::QueryExecutionFail}, }; diff --git a/client/tests/integration/queries/smart_contract.rs b/client/tests/integration/queries/smart_contract.rs index 1e5cb8a3b56..33858c64c07 100644 --- a/client/tests/integration/queries/smart_contract.rs +++ b/client/tests/integration/queries/smart_contract.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::ClientQueryError, data_model::{ prelude::*, diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index 986f298fc23..9a3ba0e2e67 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/set_parameter.rs b/client/tests/integration/set_parameter.rs index e35209b0101..cf2fa11accb 100644 --- a/client/tests/integration/set_parameter.rs +++ b/client/tests/integration/set_parameter.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/sorting.rs b/client/tests/integration/sorting.rs index 5e8fa205021..dd95bba5579 100644 --- a/client/tests/integration/sorting.rs +++ b/client/tests/integration/sorting.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, str::FromStr as _}; use eyre::{Result, WrapErr as _}; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, crypto::KeyPair, data_model::{ diff --git a/client/tests/integration/status_response.rs b/client/tests/integration/status_response.rs index 8209d46b5dd..1eb863d1f0e 100644 --- a/client/tests/integration/status_response.rs +++ b/client/tests/integration/status_response.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{data_model::prelude::*, samples::get_status_json}; +use iroha::{data_model::prelude::*, samples::get_status_json}; use iroha_telemetry::metrics::Status; use test_network::*; use test_samples::gen_account_in; diff --git a/client/tests/integration/transfer_asset.rs b/client/tests/integration/transfer_asset.rs index f58d479e49c..e974e9f8e2b 100644 --- a/client/tests/integration/transfer_asset.rs +++ b/client/tests/integration/transfer_asset.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{isi::Instruction, prelude::*, Registered}, }; @@ -14,7 +14,7 @@ use test_network::*; use test_samples::{gen_account_in, ALICE_ID}; #[test] -// This test suite is also covered at the UI level in the iroha_client_cli tests +// This test suite is also covered at the UI level in the iroha_cli tests // in test_tranfer_assets.py fn simulate_transfer_numeric() { simulate_transfer( @@ -29,8 +29,8 @@ fn simulate_transfer_numeric() { #[test] fn simulate_transfer_store_asset() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_145).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_145).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let (alice_id, mouse_id) = generate_two_ids(); let create_mouse = create_mouse(mouse_id.clone()); let asset_definition_id: AssetDefinitionId = "camomile#wonderland".parse().unwrap(); @@ -49,7 +49,7 @@ fn simulate_transfer_store_asset() { set_key_value.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to prepare state."); @@ -59,7 +59,7 @@ fn simulate_transfer_store_asset() { ); let transfer_box: InstructionBox = transfer_asset.into(); - iroha_client + iroha .submit_till( transfer_box, client::asset::by_account_id(mouse_id.clone()), @@ -86,10 +86,10 @@ fn simulate_transfer( Mint: Instruction, Transfer: Instruction, { - let (_rt, _peer, iroha_client) = ::new() + let (_rt, _peer, iroha) = ::new() .with_port(port_number) .start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + wait_for_genesis_committed(&[iroha.clone()], 0); let (alice_id, mouse_id) = generate_two_ids(); let create_mouse = create_mouse(mouse_id.clone()); @@ -107,7 +107,7 @@ fn simulate_transfer( create_asset.into(), mint_asset.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to prepare state."); @@ -117,7 +117,7 @@ fn simulate_transfer( amount_to_transfer.clone(), mouse_id.clone(), ); - iroha_client + iroha .submit_till( transfer_asset, client::asset::by_account_id(mouse_id.clone()), diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index cd50142186c..337802c4dd7 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::{self, Client}, data_model::{ prelude::*, diff --git a/client/tests/integration/triggers/data_trigger.rs b/client/tests/integration/triggers/data_trigger.rs index 3f070c2e4a2..b4c9789ea63 100644 --- a/client/tests/integration/triggers/data_trigger.rs +++ b/client/tests/integration/triggers/data_trigger.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{client, data_model::prelude::*}; +use iroha::{client, data_model::prelude::*}; use iroha_data_model::asset::AssetValue; use test_network::*; use test_samples::{gen_account_in, ALICE_ID}; diff --git a/client/tests/integration/triggers/event_trigger.rs b/client/tests/integration/triggers/event_trigger.rs index 756a2ee6ac3..0221d770139 100644 --- a/client/tests/integration/triggers/event_trigger.rs +++ b/client/tests/integration/triggers/event_trigger.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client}, data_model::prelude::*, }; diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index 37f9f002407..7dde83840bc 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, time::Duration}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{ asset::AssetId, diff --git a/client/tests/integration/triggers/trigger_rollback.rs b/client/tests/integration/triggers/trigger_rollback.rs index 1eb6188d916..36c9d40cd70 100644 --- a/client/tests/integration/triggers/trigger_rollback.rs +++ b/client/tests/integration/triggers/trigger_rollback.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::QueryResult, data_model::{prelude::*, query::asset::FindAllAssetsDefinitions, trigger::TriggerId}, }; diff --git a/client/tests/integration/tx_history.rs b/client/tests/integration/tx_history.rs index 19a57bd638e..77ee2fcfa2e 100644 --- a/client/tests/integration/tx_history.rs +++ b/client/tests/integration/tx_history.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{transaction, QueryResult}, data_model::{prelude::*, query::Pagination}, }; diff --git a/client/tests/integration/tx_rollback.rs b/client/tests/integration/tx_rollback.rs index a5cc76ad759..c9a713d79c0 100644 --- a/client/tests/integration/tx_rollback.rs +++ b/client/tests/integration/tx_rollback.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/upgrade.rs b/client/tests/integration/upgrade.rs index 622842d8226..1208ced8a7a 100644 --- a/client/tests/integration/upgrade.rs +++ b/client/tests/integration/upgrade.rs @@ -2,7 +2,7 @@ use std::{path::Path, str::FromStr as _}; use eyre::Result; use futures_util::TryStreamExt as _; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::prelude::*, diff --git a/client/tests/ui_fail/cant_filter_singular_query.rs b/client/tests/ui_fail/cant_filter_singular_query.rs index 45078dbb2cc..4bb6a337574 100644 --- a/client/tests/ui_fail/cant_filter_singular_query.rs +++ b/client/tests/ui_fail/cant_filter_singular_query.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, Client}, config::Config, data_model::query::predicate::{string, value, PredicateBox}, diff --git a/client/tests/ui_fail/cant_filter_singular_query.stderr b/client/tests/ui_fail/cant_filter_singular_query.stderr index 6213c6dfb1e..b3388ad62ca 100644 --- a/client/tests/ui_fail/cant_filter_singular_query.stderr +++ b/client/tests/ui_fail/cant_filter_singular_query.stderr @@ -21,4 +21,4 @@ error[E0599]: the method `with_filter` exists for struct `QueryRequestBuilder<'_ | |_____- doesn't satisfy `_: IterableQuery` | = note: the following trait bounds were not satisfied: - `iroha_client::iroha_data_model::prelude::FindDomainById: IterableQuery` + `iroha::iroha_data_model::prelude::FindDomainById: IterableQuery` diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index 8b0d7d46383..ea49de44b9a 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -22,8 +22,12 @@ is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledg is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } maintenance = { status = "actively-developed" } +[[bin]] +name = "iroha" +path = "src/main.rs" + [dependencies] -iroha_client = { workspace = true } +iroha = { workspace = true } iroha_primitives = { workspace = true } iroha_config_base = { workspace = true } diff --git a/client_cli/README.md b/client_cli/README.md index 9cb7fdf4d29..cc1e45cd9d6 100644 --- a/client_cli/README.md +++ b/client_cli/README.md @@ -1,7 +1,7 @@ # Iroha CLI Client With the Iroha CLI Client, you can interact with Iroha Peers Web API. -It is a "thin" wrapper around functionality exposed in the `iroha_client` crate. Specifically, it should be used as a reference for using `iroha_client`'s features, and not as a production-ready client. As such, the CLI client is not guaranteed to support all features supported by the client library. +It is a "thin" wrapper around functionality exposed in the `iroha` crate. Specifically, it should be used as a reference for using `iroha`'s features, and not as a production-ready client. As such, the CLI client is not guaranteed to support all features supported by the client library. ## Features @@ -18,7 +18,7 @@ Build Iroha and its binaries: cargo build ``` -The above command will produce the `iroha_client_cli` ELF executable file for Linux/BSD, the `iroha_client_cli` executable for MacOS, and the `iroha_client_cli.exe` executable for Windows, depending on your platform and configuration. +The above command will produce the `iroha` ELF executable file for Linux/BSD, the `iroha` executable for MacOS, and the `iroha.exe` executable for Windows, depending on your platform and configuration. Check [build and installation instructions](https://hyperledger.github.io/iroha-2-docs/guide/build-and-install.html) for more details. @@ -27,7 +27,7 @@ Check [build and installation instructions](https://hyperledger.github.io/iroha- Run Iroha Client CLI: ``` -iroha_client_cli [OPTIONS] +iroha [OPTIONS] ``` ### Options @@ -48,7 +48,7 @@ iroha_client_cli [OPTIONS] | `json` | Submit multi-instructions as JSON | | `peer` | Execute commands related to peer administration and networking | | `wasm` | Execute commands related to WASM | -| `help` | Print the help message for `iroha_client_cli` and/or the current subcommand other than `help` subcommand | +| `help` | Print the help message for `iroha` and/or the current subcommand other than `help` subcommand | Refer to [Iroha Special Instructions](https://hyperledger.github.io/iroha-2-docs/guide/blockchain/instructions.html) for more information about Iroha instructions such as register, mint, grant, and so on. @@ -56,14 +56,14 @@ Check the [Bash guide in Iroha Tutorial](https://hyperledger.github.io/iroha-2-d ## Examples -:grey_exclamation: All examples below are Unix-oriented. If you're working on Windows, we would highly encourage you to consider using WSL, as most documentation assumes a POSIX-like shell running on your system. Please be advised that the differences in the syntax may go beyond executing `iroha_client_cli.exe` instead of `iroha_client_cli`. +:grey_exclamation: All examples below are Unix-oriented. If you're working on Windows, we would highly encourage you to consider using WSL, as most documentation assumes a POSIX-like shell running on your system. Please be advised that the differences in the syntax may go beyond executing `iroha.exe` instead of `iroha`. ```bash -./iroha_client_cli domain register --id="Soramitsu" -./iroha_client_cli account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" -./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Numeric -./iroha_client_cli asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 -./iroha_client_cli asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" +./iroha domain register --id="Soramitsu" +./iroha account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" +./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric +./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" ``` In this section we will show you how to use Iroha CLI Client to do the following: @@ -89,7 +89,7 @@ Let's start with domain creation. To create a domain, you need to specify the en For the `domain` entity, you only need to provide the `id` argument as a string that doesn't contain the `@` and `#` symbols. ```bash -./iroha_client_cli domain register --id="Soramitsu" +./iroha domain register --id="Soramitsu" ``` Now you have a domain without any accounts. @@ -99,7 +99,7 @@ Now you have a domain without any accounts. Let's create a new account. Like in the previous example, specify the entity type (`account`) and the command (`register`). Then define the value of the `id` argument in "signatory@domain" format, where signatory is the account's public key in multihash representation. ```bash -./iroha_client_cli account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" +./iroha account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" ``` ### Mint Asset to Account @@ -111,8 +111,8 @@ To do so, you must first register an Asset Definition and only then add some Ass Every asset has its own value spec. In this example, it is defined as `Numeric`, a 96-bit unsigned decimal. We also support `Store` for key-value structured data. ```bash -./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Numeric -./iroha_client_cli asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric +./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 ``` You created `XOR#Soramitsu`, an asset of type `Numeric`, and then gave `1010` units of this asset to the account `ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu`. @@ -133,7 +133,7 @@ Let's use Get Account Assets Query as an example. To know how many units of a particular asset an account has, use `asset get` with the specified account and asset: ```bash -./iroha_client_cli asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" +./iroha asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" ``` This query returns the quantity of `XOR#Soramitsu` asset for the `ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu` account. @@ -143,21 +143,21 @@ It's possible to filter based on either account, asset or domain id by using the Generally it looks like this: ```bash -./iroha_client_cli ENTITY list filter PREDICATE +./iroha ENTITY list filter PREDICATE ``` -Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha_client::data_model::predicate::value::ValuePredicate` type). +Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha::data_model::predicate::value::ValuePredicate` type). Examples: ```bash # Filter domains by id -./iroha_client_cli domain list filter '{"Identifiable": {"Is": "wonderland"}}' +./iroha domain list filter '{"Identifiable": {"Is": "wonderland"}}' # Filter accounts by domain -./iroha_client_cli account list filter '{"Identifiable": {"EndsWith": "@wonderland"}}' +./iroha account list filter '{"Identifiable": {"EndsWith": "@wonderland"}}' # It is possible to combine filters using "Or" or "And" # Filter asset by domain -./iroha_client_cli asset list filter '{"Or": [{"Identifiable": {"Contains": "#wonderland#"}}, {"And": [{"Identifiable": {"Contains": "##"}}, {"Identifiable": {"EndsWith": "@wonderland"}}]}]}' +./iroha asset list filter '{"Or": [{"Identifiable": {"Contains": "#wonderland#"}}, {"And": [{"Identifiable": {"Contains": "##"}}, {"Identifiable": {"EndsWith": "@wonderland"}}]}]}' ``` ### Execute WASM transaction @@ -165,23 +165,23 @@ Examples: Use `--file` to specify a path to the WASM file: ```bash -./iroha_client_cli wasm --file=/path/to/file.wasm +./iroha wasm --file=/path/to/file.wasm ``` Or skip `--file` to read WASM from standard input: ```bash -cat /path/to/file.wasm | ./iroha_client_cli wasm +cat /path/to/file.wasm | ./iroha wasm ``` These subcommands submit the provided wasm binary as an `Executable` to be executed outside a trigger context. ### Execute Multi-instruction Transactions -The reference implementation of the Rust client, `iroha_client_cli`, is often used for diagnosing problems in other implementations. +The reference implementation of the Rust client, `iroha`, is often used for diagnosing problems in other implementations. To test transactions in the JSON format (used in the genesis block and by other SDKs), pipe the transaction into the client and add the `json` subcommand to the arguments: ```bash -cat /path/to/file.json | ./iroha_client_cli json +cat /path/to/file.json | ./iroha json ``` diff --git a/client_cli/pytests/README.md b/client_cli/pytests/README.md index 20034f78449..df8a1c90322 100644 --- a/client_cli/pytests/README.md +++ b/client_cli/pytests/README.md @@ -58,7 +58,7 @@ The test model has the following structure: # Note: make sure you have installed packages from `./scripts/requirements.txt` ``` - By default, this builds `irohad`, `iroha_client_cli`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ + By default, this builds `irohad`, `iroha`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ This behavior can be reconfigured. You can run `./scripts/test_env.py --help` to see the list of available commands and options. 2. Install and configure [Poetry](https://python-poetry.org/).\ @@ -88,7 +88,7 @@ The test model has the following structure: ### Custom Test Environment with Docker Compose -By default, we provide the [`test_env.py`](../../scripts/test_env.py) script to set up a test environment. This environment is composed of a running network of Iroha peers and an `iroha_client_cli` configuration to interact with it. +By default, we provide the [`test_env.py`](../../scripts/test_env.py) script to set up a test environment. This environment is composed of a running network of Iroha peers and an Iroha client configuration to interact with it. However, if for any reason this approach is inconvenient, it is possible to set up a custom network of Iroha peers using the provided Docker Compose configurations. @@ -100,26 +100,26 @@ To do so, perform the following steps: docker-compose -f docker-compose.dev.yml up ``` -2. Build the `iroha_client_cli` binary: +2. Build the Iroha client CLI binary: ```bash - cargo build --bin iroha_client_cli + cargo build --bin iroha ``` -3. Create a new directory, then copy the `iroha_client_cli` binary and its `client.toml` configuration file into it: +3. Create a new directory, then copy the `iroha` binary and `client.toml` configuration file into it: ```shell # Create a new directory: mkdir test # Copy the files: cp configs/swarm/client.toml test - cp target/debug/iroha_client_cli test + cp target/debug/iroha test ``` 4. Proceed with _Step 2_ of the [Using Test Suites](#using-test-suites) instructions. > [!NOTE] -> Don't forget to specify the path to the directory created for the `iroha_client_cli` binary and its `client.toml` configuration file (see Step 3) in the `CLIENT_CLI_DIR` variable of the `.env` file. +> Don't forget to specify the path to the directory created for the `iroha` binary and its `client.toml` configuration file (see Step 3) in the `CLIENT_CLI_DIR` variable of the `.env` file. > For details, see [Tests Configuration](#tests-configuration) below. ### Poetry Configuration @@ -156,7 +156,7 @@ Tests are configured via environment variables. These variables can be optionall The variables: -- `CLIENT_CLI_DIR` — Specifies a path to a directory containing the `iroha_client_cli` binary and its `config.json` configuration file.\ +- `CLIENT_CLI_DIR` — Specifies a path to a directory containing the `iroha` binary and its `config.json` configuration file.\ Set to `/client_cli`, by default. - `TORII_API_PORT_MIN`/`TORII_API_PORT_MAX` — This pair specifies the range of local ports through which the Iroha 2 peers are deployed. A randomly selected port from the specified range is used for each test.\ Set to `8080` and `8083` respectively, by default. diff --git a/client_cli/src/main.rs b/client_cli/src/main.rs index d8a8eab7fe6..281258b5060 100644 --- a/client_cli/src/main.rs +++ b/client_cli/src/main.rs @@ -10,7 +10,7 @@ use std::{ use erased_serde::Serialize; use error_stack::{fmt::ColorMode, IntoReportCompat, ResultExt}; use eyre::{eyre, Error, Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::{Client, QueryResult}, config::Config, data_model::{metadata::MetadataValueBox, prelude::*}, @@ -80,7 +80,7 @@ impl FromStr for MetadataValueArg { /// Iroha CLI Client provides an ability to interact with Iroha Peers Web API without direct network usage. #[derive(clap::Parser, Debug)] -#[command(name = "iroha_client_cli", version = concat!("version=", env!("CARGO_PKG_VERSION"), " git_commit_sha=", env!("VERGEN_GIT_SHA")), author)] +#[command(name = "iroha", version = concat!("version=", env!("CARGO_PKG_VERSION"), " git_commit_sha=", env!("VERGEN_GIT_SHA")), author)] struct Args { /// Path to the configuration file #[arg(short, long, value_name("PATH"), value_hint(clap::ValueHint::FilePath))] @@ -239,24 +239,22 @@ fn submit( metadata: UnlimitedMetadata, context: &mut dyn RunContext, ) -> Result<()> { - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); let instructions = instructions.into(); - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); #[cfg(not(debug_assertions))] let err_msg = "Failed to submit transaction."; #[cfg(debug_assertions)] let err_msg = format!("Failed to submit transaction {tx:?}"); - let hash = iroha_client - .submit_transaction_blocking(&tx) - .wrap_err(err_msg)?; + let hash = iroha.submit_transaction_blocking(&tx).wrap_err(err_msg)?; context.print_data(&hash)?; Ok(()) } mod filter { - use iroha_client::data_model::query::predicate::PredicateBox; + use iroha::data_model::query::predicate::PredicateBox; use super::*; @@ -275,7 +273,7 @@ mod filter { mod events { - use iroha_client::data_model::events::pipeline::{BlockEventFilter, TransactionEventFilter}; + use iroha::data_model::events::pipeline::{BlockEventFilter, TransactionEventFilter}; use super::*; @@ -308,9 +306,9 @@ mod events { fn listen(filter: impl Into, context: &mut dyn RunContext) -> Result<()> { let filter = filter.into(); - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); eprintln!("Listening to events with filter: {filter:?}"); - iroha_client + iroha .listen_for_events([filter]) .wrap_err("Failed to listen for events.")? .try_for_each(|event| context.print_data(&event?))?; @@ -338,9 +336,9 @@ mod blocks { } fn listen(height: NonZeroU64, context: &mut dyn RunContext) -> Result<()> { - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); eprintln!("Listening to blocks from height: {height}"); - iroha_client + iroha .listen_for_blocks(height) .wrap_err("Failed to listen for blocks.")? .try_for_each(|event| context.print_data(&event?))?; @@ -349,7 +347,7 @@ mod blocks { } mod domain { - use iroha_client::client; + use iroha::client; use super::*; @@ -387,7 +385,7 @@ mod domain { impl RunArgs for Register { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { id, metadata } = self; - let create_domain = iroha_client::data_model::isi::Register::domain(Domain::new(id)); + let create_domain = iroha::data_model::isi::Register::domain(Domain::new(id)); submit([create_domain], metadata.load()?, context).wrap_err("Failed to create domain") } } @@ -444,14 +442,14 @@ mod domain { to, metadata, } = self; - let transfer_domain = iroha_client::data_model::isi::Transfer::domain(from, id, to); + let transfer_domain = iroha::data_model::isi::Transfer::domain(from, id, to); submit([transfer_domain], metadata.load()?, context) .wrap_err("Failed to transfer domain") } } mod metadata { - use iroha_client::data_model::domain::DomainId; + use iroha::data_model::domain::DomainId; use super::*; @@ -521,7 +519,7 @@ mod domain { mod account { use std::fmt::Debug; - use iroha_client::client::{self}; + use iroha::client::{self}; use super::{Permission as DataModelPermission, *}; @@ -563,7 +561,7 @@ mod account { impl RunArgs for Register { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { id, metadata } = self; - let create_account = iroha_client::data_model::isi::Register::account(Account::new(id)); + let create_account = iroha::data_model::isi::Register::account(Account::new(id)); submit([create_account], metadata.load()?, context) .wrap_err("Failed to register account") } @@ -634,7 +632,7 @@ mod account { permission, metadata, } = self; - let grant = iroha_client::data_model::isi::Grant::permission(permission.0, id); + let grant = iroha::data_model::isi::Grant::permission(permission.0, id); submit([grant], metadata.load()?, context) .wrap_err("Failed to grant the permission to the account") } @@ -662,7 +660,7 @@ mod account { } mod asset { - use iroha_client::{ + use iroha::{ client::{self, asset}, data_model::{asset::AssetDefinition, name::Name}, }; @@ -731,7 +729,7 @@ mod asset { asset_definition = asset_definition.mintable_once(); } let create_asset_definition = - iroha_client::data_model::isi::Register::asset_definition(asset_definition); + iroha::data_model::isi::Register::asset_definition(asset_definition); submit([create_asset_definition], metadata.load()?, context) .wrap_err("Failed to register asset") } @@ -757,7 +755,7 @@ mod asset { quantity, metadata, } = self; - let mint_asset = iroha_client::data_model::isi::Mint::asset_numeric(quantity, asset_id); + let mint_asset = iroha::data_model::isi::Mint::asset_numeric(quantity, asset_id); submit([mint_asset], metadata.load()?, context) .wrap_err("Failed to mint asset of type `Numeric`") } @@ -783,7 +781,7 @@ mod asset { quantity, metadata, } = self; - let burn_asset = iroha_client::data_model::isi::Burn::asset_numeric(quantity, asset_id); + let burn_asset = iroha::data_model::isi::Burn::asset_numeric(quantity, asset_id); submit([burn_asset], metadata.load()?, context) .wrap_err("Failed to burn asset of type `Numeric`") } @@ -814,7 +812,7 @@ mod asset { metadata, } = self; let transfer_asset = - iroha_client::data_model::isi::Transfer::asset_numeric(asset_id, quantity, to); + iroha::data_model::isi::Transfer::asset_numeric(asset_id, quantity, to); submit([transfer_asset], metadata.load()?, context).wrap_err("Failed to transfer asset") } } @@ -830,8 +828,8 @@ mod asset { impl RunArgs for Get { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { asset_id } = self; - let iroha_client = context.client_from_config(); - let asset = iroha_client + let iroha = context.client_from_config(); + let asset = iroha .request(asset::by_id(asset_id)) .wrap_err("Failed to get asset.")?; context.print_data(&asset)?; @@ -887,7 +885,7 @@ mod asset { value: MetadataValueArg { value }, } = self; - let set = iroha_client::data_model::isi::SetKeyValue::asset(asset_id, key, value); + let set = iroha::data_model::isi::SetKeyValue::asset(asset_id, key, value); submit([set], UnlimitedMetadata::default(), context)?; Ok(()) } @@ -905,7 +903,7 @@ mod asset { impl RunArgs for RemoveKeyValue { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { asset_id, key } = self; - let remove = iroha_client::data_model::isi::RemoveKeyValue::asset(asset_id, key); + let remove = iroha::data_model::isi::RemoveKeyValue::asset(asset_id, key); submit([remove], UnlimitedMetadata::default(), context)?; Ok(()) } @@ -977,7 +975,7 @@ mod peer { metadata, } = self; let register_peer = - iroha_client::data_model::isi::Register::peer(Peer::new(PeerId::new(address, key))); + iroha::data_model::isi::Register::peer(Peer::new(PeerId::new(address, key))); submit([register_peer], metadata.load()?, context).wrap_err("Failed to register peer") } } @@ -1003,7 +1001,7 @@ mod peer { metadata, } = self; let unregister_peer = - iroha_client::data_model::isi::Unregister::peer(PeerId::new(address, key)); + iroha::data_model::isi::Unregister::peer(PeerId::new(address, key)); submit([unregister_peer], metadata.load()?, context) .wrap_err("Failed to unregister peer") } diff --git a/core/src/smartcontracts/isi/triggers/set.rs b/core/src/smartcontracts/isi/triggers/set.rs index fcd5ea90efa..955d4229b96 100644 --- a/core/src/smartcontracts/isi/triggers/set.rs +++ b/core/src/smartcontracts/isi/triggers/set.rs @@ -150,7 +150,7 @@ pub struct SetView<'set> { /// Entry in wasm smart-contracts map #[derive(Debug, Clone, Serialize)] -struct WasmSmartContractEntry { +pub struct WasmSmartContractEntry { /// Original wasm binary blob original_contract: WasmSmartContract, /// Compiled with [`wasmtime`] smart-contract diff --git a/core/test_network/Cargo.toml b/core/test_network/Cargo.toml index 6241fbf5a44..410919ef7aa 100644 --- a/core/test_network/Cargo.toml +++ b/core/test_network/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true [dependencies] iroha_core = { workspace = true } irohad = { workspace = true, features = ["test-network"] } -iroha_client = { workspace = true } +iroha = { workspace = true } iroha_crypto = { workspace = true } iroha_config = { workspace = true } diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 7dfc90cba11..66ae5bbfb82 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -6,8 +6,7 @@ use std::{collections::BTreeMap, ops::Deref, path::Path, sync::Arc, thread}; use eyre::Result; use futures::{prelude::*, stream::FuturesUnordered}; -use irohad::{Iroha, ToriiStarted}; -use iroha_client::{ +use iroha::{ client::{Client, QueryOutput}, config::Config as ClientConfig, data_model::{isi::Instruction, peer::Peer as DataModelPeer, prelude::*, query::Query, Level}, @@ -22,6 +21,7 @@ use iroha_primitives::{ addr::{socket_addr, SocketAddr}, unique_vec::UniqueVec, }; +use irohad::{Iroha, ToriiStarted}; use rand::{seq::IteratorRandom, thread_rng}; use serde_json::json; use tempfile::TempDir; @@ -813,7 +813,7 @@ impl TestConfig for Config { impl TestClientConfig for ClientConfig { fn test(api_address: &SocketAddr) -> Self { - iroha_client::samples::get_client_config( + iroha::samples::get_client_config( get_chain_id(), get_key_pair(Signatory::Alice), format!("http://{api_address}") diff --git a/flake.nix b/flake.nix index 185837f8a00..7136e93ffcc 100755 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ allBinaries = [ "irohad" - "iroha_client_cli" + "iroha" "kagami" "kura_inspector" "parity_scale_cli" diff --git a/scripts/test_env.py b/scripts/test_env.py index 688c1ac2025..900ee79d46e 100755 --- a/scripts/test_env.py +++ b/scripts/test_env.py @@ -168,7 +168,7 @@ def run(self, submit_genesis: bool = False): stderr_file = open(self.peer_dir / ".stderr", "w") # These processes are created detached from the parent process already subprocess.Popen([self.name, "--config", self.config_path] + (["--submit-genesis"] if submit_genesis else []), - executable=self.out_dir / "peers/iroha", stdout=stdout_file, stderr=stderr_file) + executable=self.out_dir / "peers/irohad", stdout=stdout_file, stderr=stderr_file) def pos_int(arg): if int(arg) > 0: @@ -218,7 +218,7 @@ def main(args: argparse.Namespace): def setup(args: argparse.Namespace): logging.info(f"Starting Iroha network with {args.n_peers} peers...") os.makedirs(args.out_dir, exist_ok=True) - copy_or_prompt_build_bin("iroha_client_cli", args.root_dir, args.out_dir) + copy_or_prompt_build_bin("iroha", args.root_dir, args.out_dir) with open(os.path.join(args.out_dir, "metadata.json"), "w") as f: f.write('{"comment":{"String": "Hello Meta!"}}') shutil.copy2(pathlib.Path(args.root_dir) / SWARM_CONFIGS_DIRECTORY / "client.toml", args.out_dir) From 35d057ff92a89f431d6b2ab0aaf3116c5b129890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Tue, 28 May 2024 18:42:24 +0300 Subject: [PATCH 3/4] fix(docker): update docker compose files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- .github/workflows/iroha2-dev-code-quality.yml | 4 +-- .github/workflows/iroha2-dev-pr.yml | 8 ++--- .github/workflows/iroha2-dev.yml | 8 ++--- config/base/src/util.rs | 12 +++---- configs/swarm/docker-compose.local.yml | 34 +++++++++---------- configs/swarm/docker-compose.single.yml | 8 ++--- configs/swarm/docker-compose.yml | 34 +++++++++---------- core/benches/validation.rs | 2 +- core/src/block.rs | 2 +- core/src/queue.rs | 2 +- core/src/smartcontracts/isi/triggers/set.rs | 4 +-- core/src/sumeragi/main_loop.rs | 2 +- data_model/src/query/predicate.rs | 20 +++++------ smart_contract/src/lib.rs | 6 ++-- 14 files changed, 73 insertions(+), 73 deletions(-) diff --git a/.github/workflows/iroha2-dev-code-quality.yml b/.github/workflows/iroha2-dev-code-quality.yml index b5731cd3257..8c83fad2bf9 100644 --- a/.github/workflows/iroha2-dev-code-quality.yml +++ b/.github/workflows/iroha2-dev-code-quality.yml @@ -44,8 +44,8 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Run tests, with coverage run: | - mold --run cargo test --all-features --no-fail-fast --workspace --exclude iroha_client - mold --run cargo test --all-features --no-fail-fast -p iroha_client -- --skip integration + mold --run cargo test --all-features --no-fail-fast --workspace --exclude iroha + mold --run cargo test --all-features --no-fail-fast -p iroha -- --skip integration env: RUSTFLAGS: "-C instrument-coverage" LLVM_PROFILE_FILE: "iroha-%p-%m.profraw" diff --git a/.github/workflows/iroha2-dev-pr.yml b/.github/workflows/iroha2-dev-pr.yml index ad69a5e1601..38862c91740 100644 --- a/.github/workflows/iroha2-dev-pr.yml +++ b/.github/workflows/iroha2-dev-pr.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Run tests, with no-default-features - run: mold --run cargo test --no-default-features --no-fail-fast -p iroha_client integration -- --skip extra_functional + run: mold --run cargo test --no-default-features --no-fail-fast -p iroha integration -- --skip extra_functional # include: client/tests/integration/extra_functional extra_functional: @@ -60,7 +60,7 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Run tests - run: mold --run cargo test --no-default-features --no-fail-fast -p iroha_client extra_functional + run: mold --run cargo test --no-default-features --no-fail-fast -p iroha extra_functional # Run the job to check that the docker containers are properly buildable pr-generator-build: @@ -105,7 +105,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build binaries run: | - cargo build -p iroha_client_cli -p kagami -p iroha + cargo build -p iroha_client_cli -p kagami -p irohad - name: Setup test Iroha 2 environment on the bare metal run: | pip3 install -r scripts/requirements.txt --no-input --break-system-packages @@ -129,7 +129,7 @@ jobs: working-directory: client_cli/pytests env: # prepared by `test_env.py` - CLIENT_CLI_BINARY: ../../test/iroha_client_cli + CLIENT_CLI_BINARY: ../../test/iroha CLIENT_CLI_CONFIG: ../../test/client.toml run: | poetry run pytest diff --git a/.github/workflows/iroha2-dev.yml b/.github/workflows/iroha2-dev.yml index 7a20a73af5a..fb2cf76e9b7 100644 --- a/.github/workflows/iroha2-dev.yml +++ b/.github/workflows/iroha2-dev.yml @@ -78,11 +78,11 @@ jobs: with: name: cargo-build-release path: target/release/iroha - - name: Archive iroha_client_cli + - name: Archive Iroha client CLI uses: actions/upload-artifact@v3 with: name: cargo-client-cli-build-release - path: target/release/iroha_client_cli + path: target/release/iroha - name: Archive kagami uses: actions/upload-artifact@v3 with: @@ -112,11 +112,11 @@ jobs: TELEMETRY_FILE: ../target/telemetry/debug.json.lz4 run: | mkdir -p target/telemetry - mold --run cargo test -p iroha_client --all-features -- unstable_network || true + mold --run cargo test -p iroha --all-features -- unstable_network || true - name: Run release tests and save telemetry env: TELEMETRY_FILE: ../target/telemetry/release.json.lz4 - run: mold --run cargo test -p iroha_client --all-features --release -- unstable_network || true + run: mold --run cargo test -p iroha --all-features --release -- unstable_network || true - name: Install script dependencies run: | apt-get update diff --git a/config/base/src/util.rs b/config/base/src/util.rs index 99fa86131fa..33d82985c55 100644 --- a/config/base/src/util.rs +++ b/config/base/src/util.rs @@ -186,6 +186,12 @@ mod tests { extends: Option, } + impl ExtendsPaths { + fn as_str_vec(&self) -> Vec<&str> { + self.iter().map(|p| p.to_str().unwrap()).collect() + } + } + #[test] fn parse_empty_extends() { let value: TestExtends = toml::from_str("").expect("should be fine with empty input"); @@ -224,12 +230,6 @@ mod tests { #[test] fn iterating_over_extends() { - impl ExtendsPaths { - fn as_str_vec(&self) -> Vec<&str> { - self.iter().map(|p| p.to_str().unwrap()).collect() - } - } - let single = ExtendsPaths::Single("single".into()); assert_eq!(single.as_str_vec(), vec!["single"]); diff --git a/configs/swarm/docker-compose.local.yml b/configs/swarm/docker-compose.local.yml index 30714875c45..21bf2da9970 100644 --- a/configs/swarm/docker-compose.local.yml +++ b/configs/swarm/docker-compose.local.yml @@ -3,43 +3,43 @@ version: '3.8' services: - iroha0: + irohad0: build: ../.. platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB - PRIVATE_KEY: 8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB + PUBLIC_KEY: ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 + PRIVATE_KEY: 802640418A3712F4841FFE7A90B14E90BF76A6EF2A2546AC8DBBB1F442FFB8250426B082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 P2P_ADDRESS: 0.0.0.0:1337 API_ADDRESS: 0.0.0.0:8080 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 GENESIS_PRIVATE_KEY: 80264082B3BDE54AEBECA4146257DA0DE8D59D8E46D5FE34887DCD8072866792FCB3AD4164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 GENESIS_FILE: /config/genesis.json - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1337:1337 - 8080:8080 volumes: - ./:/config init: true - command: iroha --submit-genesis + command: irohad --submit-genesis healthcheck: test: test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0 interval: 2s timeout: 1s retries: 30 start_period: 4s - iroha1: + irohad1: build: ../.. platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F - PRIVATE_KEY: 802640C02FFAD5E455E7EC620D74DE5769681E4D8385906BCE5A437EB67452A9EFBBC2815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F + PUBLIC_KEY: ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D + PRIVATE_KEY: 8026403895C6FA512EF0C2D73DE2F2F2953C3F385ED636D9579BCC5022531228B8DBAF83C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D P2P_ADDRESS: 0.0.0.0:1338 API_ADDRESS: 0.0.0.0:8081 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1338:1338 - 8081:8081 @@ -52,17 +52,17 @@ services: timeout: 1s retries: 30 start_period: 4s - iroha2: + irohad2: build: ../.. platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736 - PRIVATE_KEY: 80264029C5ED1409CB10FD791BC4FF8A6CB5E22A5FAE7E36F448EF3EA2988B1319A88BF417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736 + PUBLIC_KEY: ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E + PRIVATE_KEY: 802640DB566C53DFF72340CA72E690F882D67B75E47C6B1A5D7A1723B3B2082279BB9AA37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E P2P_ADDRESS: 0.0.0.0:1339 API_ADDRESS: 0.0.0.0:8082 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1339:1339 - 8082:8082 @@ -75,17 +75,17 @@ services: timeout: 1s retries: 30 start_period: 4s - iroha3: + irohad3: build: ../.. platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61 - PRIVATE_KEY: 8026405EED4855FAD183C451AAC39DFC50831607E4CF408C98E2B977F3CE4A2DF42CE2A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61 + PUBLIC_KEY: ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E + PRIVATE_KEY: 802640E28031CC65994ADE240E32FCFD0405DF30A47BDD6ABAF76C8C3C5A4F3DE96F75B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E P2P_ADDRESS: 0.0.0.0:1340 API_ADDRESS: 0.0.0.0:8083 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"}]' ports: - 1340:1340 - 8083:8083 diff --git a/configs/swarm/docker-compose.single.yml b/configs/swarm/docker-compose.single.yml index 8d307182477..59a454237af 100644 --- a/configs/swarm/docker-compose.single.yml +++ b/configs/swarm/docker-compose.single.yml @@ -3,13 +3,13 @@ version: '3.8' services: - iroha0: + irohad0: build: ../.. platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB - PRIVATE_KEY: 8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB + PUBLIC_KEY: ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 + PRIVATE_KEY: 802640418A3712F4841FFE7A90B14E90BF76A6EF2A2546AC8DBBB1F442FFB8250426B082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 P2P_ADDRESS: 0.0.0.0:1337 API_ADDRESS: 0.0.0.0:8080 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 @@ -21,7 +21,7 @@ services: volumes: - ./:/config init: true - command: iroha --submit-genesis + command: irohad --submit-genesis healthcheck: test: test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0 interval: 2s diff --git a/configs/swarm/docker-compose.yml b/configs/swarm/docker-compose.yml index 5a9da79e2e9..9388026179e 100644 --- a/configs/swarm/docker-compose.yml +++ b/configs/swarm/docker-compose.yml @@ -3,43 +3,43 @@ version: '3.8' services: - iroha0: + irohad0: image: hyperledger/iroha:dev platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB - PRIVATE_KEY: 8026408F4C15E5D664DA3F13778801D23D4E89B76E94C1B94B389544168B6CB894F84F8BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB + PUBLIC_KEY: ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 + PRIVATE_KEY: 802640418A3712F4841FFE7A90B14E90BF76A6EF2A2546AC8DBBB1F442FFB8250426B082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731 P2P_ADDRESS: 0.0.0.0:1337 API_ADDRESS: 0.0.0.0:8080 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 GENESIS_PRIVATE_KEY: 80264082B3BDE54AEBECA4146257DA0DE8D59D8E46D5FE34887DCD8072866792FCB3AD4164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 GENESIS_FILE: /config/genesis.json - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1337:1337 - 8080:8080 volumes: - ./:/config init: true - command: iroha --submit-genesis + command: irohad --submit-genesis healthcheck: test: test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0 interval: 2s timeout: 1s retries: 30 start_period: 4s - iroha1: + irohad1: image: hyperledger/iroha:dev platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F - PRIVATE_KEY: 802640C02FFAD5E455E7EC620D74DE5769681E4D8385906BCE5A437EB67452A9EFBBC2815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F + PUBLIC_KEY: ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D + PRIVATE_KEY: 8026403895C6FA512EF0C2D73DE2F2F2953C3F385ED636D9579BCC5022531228B8DBAF83C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D P2P_ADDRESS: 0.0.0.0:1338 API_ADDRESS: 0.0.0.0:8081 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1338:1338 - 8081:8081 @@ -52,17 +52,17 @@ services: timeout: 1s retries: 30 start_period: 4s - iroha2: + irohad2: image: hyperledger/iroha:dev platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736 - PRIVATE_KEY: 80264029C5ED1409CB10FD791BC4FF8A6CB5E22A5FAE7E36F448EF3EA2988B1319A88BF417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736 + PUBLIC_KEY: ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E + PRIVATE_KEY: 802640DB566C53DFF72340CA72E690F882D67B75E47C6B1A5D7A1723B3B2082279BB9AA37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E P2P_ADDRESS: 0.0.0.0:1339 API_ADDRESS: 0.0.0.0:8082 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha3:1340","public_key":"ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad3:1340","public_key":"ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E"}]' ports: - 1339:1339 - 8082:8082 @@ -75,17 +75,17 @@ services: timeout: 1s retries: 30 start_period: 4s - iroha3: + irohad3: image: hyperledger/iroha:dev platform: linux/amd64 environment: CHAIN_ID: 00000000-0000-0000-0000-000000000000 - PUBLIC_KEY: ed0120A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61 - PRIVATE_KEY: 8026405EED4855FAD183C451AAC39DFC50831607E4CF408C98E2B977F3CE4A2DF42CE2A66522370D60B9C09E79ADE2E9BB1EF2E78733A944B999B3A6AEE687CE476D61 + PUBLIC_KEY: ed0120B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E + PRIVATE_KEY: 802640E28031CC65994ADE240E32FCFD0405DF30A47BDD6ABAF76C8C3C5A4F3DE96F75B23E14F659B91736AAB980B6ADDCE4B1DB8A138AB0267E049C082A744471714E P2P_ADDRESS: 0.0.0.0:1340 API_ADDRESS: 0.0.0.0:8083 GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha1:1338","public_key":"ed0120815BBDC9775D28C3633269B25F22D048E2AA2E36017CBE5AD85F15220BEB6F6F"},{"address":"iroha0:1337","public_key":"ed01208BA62848CF767D72E7F7F4B9D2D7BA07FEE33760F79ABE5597A51520E292A0CB"},{"address":"iroha2:1339","public_key":"ed0120F417E0371E6ADB32FD66749477402B1AB67F84A8E9B082E997980CC91F327736"}]' + SUMERAGI_TRUSTED_PEERS: '[{"address":"irohad0:1337","public_key":"ed012082528CCC8727333530C8F6F19F70C23882DEB1BF2BA3BE4A6654C7E8A91A7731"},{"address":"irohad1:1338","public_key":"ed012083C85E315776FD2DDC187ECB23E608F800B313A1D614B108078EC048D5013D2D"},{"address":"irohad2:1339","public_key":"ed0120A37B7B758C952FE9429E9E35D1D71E2D8BB9364EDD077B5027ABAAC798D3230E"}]' ports: - 1340:1340 - 8083:8083 diff --git a/core/benches/validation.rs b/core/benches/validation.rs index da0917a18ef..54d7baab0dc 100644 --- a/core/benches/validation.rs +++ b/core/benches/validation.rs @@ -18,7 +18,7 @@ use once_cell::sync::Lazy; use test_samples::gen_account_in; static STARTER_DOMAIN: Lazy = Lazy::new(|| "start".parse().unwrap()); -static STARTER_KEYPAIR: Lazy = Lazy::new(|| KeyPair::random()); +static STARTER_KEYPAIR: Lazy = Lazy::new(KeyPair::random); static STARTER_ID: Lazy = Lazy::new(|| AccountId::new(STARTER_DOMAIN.clone(), STARTER_KEYPAIR.public_key().clone())); diff --git a/core/src/block.rs b/core/src/block.rs index dd2e717fc25..e4c1d30802d 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -569,7 +569,7 @@ mod valid { fn payload(block: &ValidBlock) -> &BlockPayload { let SignedBlock::V1(signed) = &block.0; - &signed.payload() + signed.payload() } #[test] diff --git a/core/src/queue.rs b/core/src/queue.rs index 645a5363a04..b60a880f13f 100644 --- a/core/src/queue.rs +++ b/core/src/queue.rs @@ -436,7 +436,7 @@ pub mod tests { let tx = TransactionBuilder::new_with_time_source(chain_id.clone(), account_id, time_source) .with_instructions(instructions) - .sign(&key_pair); + .sign(key_pair); let limits = TransactionLimits { max_instruction_number: 4096, max_wasm_size_bytes: 0, diff --git a/core/src/smartcontracts/isi/triggers/set.rs b/core/src/smartcontracts/isi/triggers/set.rs index 955d4229b96..f5baa02534b 100644 --- a/core/src/smartcontracts/isi/triggers/set.rs +++ b/core/src/smartcontracts/isi/triggers/set.rs @@ -412,13 +412,13 @@ pub trait SetReadOnly { /// Apply `f` to triggers that belong to the given [`DomainId`] /// /// Return an empty list if [`Set`] doesn't contain any triggers belonging to [`DomainId`]. - fn inspect_by_domain_id<'a, F: 'a, R>( + fn inspect_by_domain_id<'a, F, R>( &'a self, domain_id: &DomainId, f: F, ) -> impl Iterator + '_ where - F: Fn(&TriggerId, &dyn LoadedActionTrait) -> R, + F: Fn(&TriggerId, &dyn LoadedActionTrait) -> R + 'a, { let domain_id = domain_id.clone(); diff --git a/core/src/sumeragi/main_loop.rs b/core/src/sumeragi/main_loop.rs index 9c0c051b047..74a433c00dc 100644 --- a/core/src/sumeragi/main_loop.rs +++ b/core/src/sumeragi/main_loop.rs @@ -1217,7 +1217,7 @@ mod tests { let mut payload = signed.payload().clone(); f(&mut payload); - SignedBlock::V1(SignedBlockV1::new(payload, &key_pair)) + SignedBlock::V1(SignedBlockV1::new(payload, key_pair)) } fn create_data_for_test( diff --git a/data_model/src/query/predicate.rs b/data_model/src/query/predicate.rs index 57dfab02558..87b4e80917e 100644 --- a/data_model/src/query/predicate.rs +++ b/data_model/src/query/predicate.rs @@ -693,19 +693,19 @@ pub mod string { fn account_id() { let alice: PublicKey = KeyPair::random().into_parts().0; let id = IdBox::AccountId(format!("{alice}@wonderland").parse().expect("Valid")); - assert!(StringPredicate::starts_with(&*format!("{alice}@")).applies(&id)); + assert!(StringPredicate::starts_with(&format!("{alice}@")).applies(&id)); assert!(StringPredicate::ends_with("@wonderland").applies(&id)); - assert!(StringPredicate::is(&*format!("{alice}@wonderland")).applies(&id)); + assert!(StringPredicate::is(&format!("{alice}@wonderland")).applies(&id)); // Should we also include a check into string // predicates? If the internal predicate starts with // whitespace, it can't possibly match any Id, but // there's no way to enforce this at both type level // and run-time. - assert!(!StringPredicate::starts_with(&*format!(" {alice}@")).applies(&id)); + assert!(!StringPredicate::starts_with(&format!(" {alice}@")).applies(&id)); assert!(!StringPredicate::ends_with("@wonderland ").applies(&id)); - assert!(!StringPredicate::is(&*format!("{alice}@@wonderland ")).applies(&id)); + assert!(!StringPredicate::is(&format!("{alice}@@wonderland ")).applies(&id)); assert!(!StringPredicate::contains("#").applies(&id)); - assert!(!StringPredicate::is(&*format!("{alice}#wonderland")).applies(&id)); + assert!(!StringPredicate::is(&format!("{alice}#wonderland")).applies(&id)); } #[test] @@ -714,9 +714,9 @@ pub mod string { let id = IdBox::AssetId(format!("rose##{alice}@wonderland").parse().expect("Valid")); assert!(StringPredicate::starts_with("rose##").applies(&id)); - assert!(StringPredicate::ends_with(&*format!("#{alice}@wonderland")).applies(&id)); - assert!(StringPredicate::is(&*format!("rose##{alice}@wonderland")).applies(&id)); - assert!(StringPredicate::contains(&*format!("#{alice}@")).applies(&id)); + assert!(StringPredicate::ends_with(&format!("#{alice}@wonderland")).applies(&id)); + assert!(StringPredicate::is(&format!("rose##{alice}@wonderland")).applies(&id)); + assert!(StringPredicate::contains(&format!("#{alice}@")).applies(&id)); } #[test] @@ -1241,7 +1241,7 @@ pub mod value { let alice_id: AccountId = format!("{alice}@wonderland").parse().expect("Valid"); { let pred = QueryOutputPredicate::Identifiable(string::StringPredicate::is( - &*alice_id.to_string(), + &alice_id.to_string(), )); println!("{pred:?}"); assert!(pred.applies(&QueryOutputBox::Id(IdBox::AccountId(alice_id.clone())))); @@ -1265,7 +1265,7 @@ pub mod value { } { let pred = QueryOutputPredicate::Display(string::StringPredicate::is( - &*alice_id.to_string(), + &alice_id.to_string(), )); println!("{pred:?}"); diff --git a/smart_contract/src/lib.rs b/smart_contract/src/lib.rs index 2378b0f1bd7..327ac4744d3 100644 --- a/smart_contract/src/lib.rs +++ b/smart_contract/src/lib.rs @@ -645,11 +645,11 @@ mod tests { filter: smart_contract_filter.clone(), sorting: Sorting::by_metadata_key(Name::from_str("metadata_key").unwrap()), pagination: Pagination { - limit: Some(NonZeroU32::new(12341234).unwrap()), - start: Some(NonZeroU64::new(43214321).unwrap()), + limit: Some(NonZeroU32::new(12_341_234).unwrap()), + start: Some(NonZeroU64::new(43_214_321).unwrap()), }, fetch_size: FetchSize { - fetch_size: Some(NonZeroU32::new(56785678).unwrap()), + fetch_size: Some(NonZeroU32::new(56_785_678).unwrap()), }, }; let smart_contract_query_rq = super::QueryRequest::Query(smart_contract_query.clone()); From 1051e0332a08059b4dedecd49cd86dd2bd2fef6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Tue, 28 May 2024 19:17:16 +0300 Subject: [PATCH 4/4] refactor!: rename wasm_builder_cli to wasm_builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- CONTRIBUTING.md | 2 +- default_executor/README.md | 4 ++-- hooks/pre-commit.sample | 2 +- scripts/generate_wasm.sh | 2 +- tools/wasm_builder_cli/Cargo.toml | 4 ++++ tools/wasm_builder_cli/README.md | 10 +++++----- tools/wasm_builder_cli/src/main.rs | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22024e8e2f0..fe3aae27cbd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -277,7 +277,7 @@ It can be done by running: ```bash # compile executor without optimizations -cargo run --bin iroha_wasm_builder_cli -- build ./path/to/executor --outfile executor.wasm +cargo run --bin iroha_wasm_builder -- build ./path/to/executor --outfile executor.wasm ``` With profiling feature enabled Iroha exposes endpoint to scrap pprof profiles: diff --git a/default_executor/README.md b/default_executor/README.md index 0fe04b6fe24..f14d1a887ad 100644 --- a/default_executor/README.md +++ b/default_executor/README.md @@ -3,6 +3,6 @@ Use the [Wasm Builder CLI](../tools/wasm_builder_cli) in order to build it: ```bash -cargo run --bin iroha_wasm_builder_cli -- \ +cargo run --bin iroha_wasm_builder -- \ build ./default_executor --optimize --outfile ./configs/swarm/executor.wasm -``` \ No newline at end of file +``` diff --git a/hooks/pre-commit.sample b/hooks/pre-commit.sample index a175705e418..a289118545b 100755 --- a/hooks/pre-commit.sample +++ b/hooks/pre-commit.sample @@ -10,7 +10,7 @@ cd ./client/tests/integration/smartcontracts cargo fmt --all -- --check cd - # update the default executor -cargo run --release --bin iroha_wasm_builder_cli -- build ./default_executor --optimize --outfile ./configs/swarm/executor.wasm +cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --outfile ./configs/swarm/executor.wasm # update the default genesis, assuming the transaction authority is `test_samples::SAMPLE_GENESIS_ACCOUNT_ID` cargo run --release --bin kagami -- genesis --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./configs/swarm/genesis.json # update schema diff --git a/scripts/generate_wasm.sh b/scripts/generate_wasm.sh index e693108933f..b6b3aca0d69 100755 --- a/scripts/generate_wasm.sh +++ b/scripts/generate_wasm.sh @@ -20,7 +20,7 @@ for folder in "$SOURCE_DIR"/*; do folder_name=$(basename "$folder") target_wasm_file_path="${TARGET_DIR}/${folder_name}.wasm" # Build the smart contracts - cargo run --bin iroha_wasm_builder_cli -- build "$folder" --optimize --outfile "$target_wasm_file_path" + cargo run --bin iroha_wasm_builder -- build "$folder" --optimize --outfile "$target_wasm_file_path" fi done diff --git a/tools/wasm_builder_cli/Cargo.toml b/tools/wasm_builder_cli/Cargo.toml index b884ac5c196..91deae67674 100644 --- a/tools/wasm_builder_cli/Cargo.toml +++ b/tools/wasm_builder_cli/Cargo.toml @@ -9,6 +9,10 @@ license.workspace = true [lints] workspace = true +[[bin]] +name = "iroha_wasm_builder" +path = "src/main.rs" + [dependencies] iroha_wasm_builder.workspace = true diff --git a/tools/wasm_builder_cli/README.md b/tools/wasm_builder_cli/README.md index 9585039b2fc..9d22356f075 100644 --- a/tools/wasm_builder_cli/README.md +++ b/tools/wasm_builder_cli/README.md @@ -1,23 +1,23 @@ -# `iroha_wasm_builder_cli` +# `iroha_wasm_builder` -A CLI around [`iroha_wasm_builder`](../wasm_builder) crate. +A CLI for building wasm smartcontracts. ## Usage **Check the smartcontract:** ```bash -iroha_wasm_builder_cli check path/to/project +iroha_wasm_builder check path/to/project ``` **Build the smartcontract:** ```bash -iroha_wasm_builder_cli build path/to/project --outfile ./smartcontract.wasm +iroha_wasm_builder build path/to/project --outfile ./smartcontract.wasm ``` **Build with options:** ```bash -iroha_wasm_builder_cli build path/to/project --optimize --format --outfile ./smartcontract.wasm +iroha_wasm_builder build path/to/project --optimize --format --outfile ./smartcontract.wasm ``` diff --git a/tools/wasm_builder_cli/src/main.rs b/tools/wasm_builder_cli/src/main.rs index 645b079a451..8af017bf2cd 100644 --- a/tools/wasm_builder_cli/src/main.rs +++ b/tools/wasm_builder_cli/src/main.rs @@ -8,7 +8,7 @@ use iroha_wasm_builder::Builder; use owo_colors::OwoColorize; #[derive(Parser, Debug)] -#[command(name = "iroha_wasm_builder_cli", version, author)] +#[command(name = "iroha_wasm_builder", version, author)] enum Cli { /// Apply `cargo check` to the smartcontract Check {