Skip to content

Commit

Permalink
refactor(iroha): rename iroha_client_cli to iroha
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed May 28, 2024
1 parent 63618df commit 2150821
Show file tree
Hide file tree
Showing 61 changed files with 232 additions and 234 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion Dockerfile.glibc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "iroha_client"
name = "iroha"

edition.workspace = true
version.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
25 changes: 12 additions & 13 deletions client/benches/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
});
Expand All @@ -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] = [
Expand All @@ -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");

Expand All @@ -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<Vec<_>, _> = iroha_client
.request(request.clone())
.and_then(Iterator::collect);
let iter: Result<Vec<_>, _> =
iroha.request(request.clone()).and_then(Iterator::collect);

match iter {
Ok(assets) => {
Expand Down Expand Up @@ -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));
Expand All @@ -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}");
Expand Down
2 changes: 1 addition & 1 deletion client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
4 changes: 2 additions & 2 deletions client/examples/million_accounts_genesis.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/examples/register_1000_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 2150821

Please sign in to comment.