diff --git a/.github/workflows/iroha2-dev-pr-wasm.yml b/.github/workflows/iroha2-dev-pr-wasm.yml index ab682d7f657..d8e3ce82c8a 100644 --- a/.github/workflows/iroha2-dev-pr-wasm.yml +++ b/.github/workflows/iroha2-dev-pr-wasm.yml @@ -47,7 +47,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build wasm libs - run: mold --run cargo run --bin iroha_wasm_builder -- build ./wasm/libs/default_executor --optimize --out-file ${{ env.DEFAULTS_DIR }}/executor.wasm + run: mold --run cargo run --bin kagami -- wasm build ./wasm/libs/default_executor --optimize --out-file ${{ env.DEFAULTS_DIR }}/executor.wasm - name: Upload executor to reuse in other jobs uses: actions/upload-artifact@v4 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a79912111f3..a71d7a92a0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -282,7 +282,7 @@ It can be done by running: ```bash # compile executor without optimizations -cargo run --bin iroha_wasm_builder -- build ./path/to/executor --out-file executor.wasm +cargo run --bin kagami -- wasm build ./path/to/executor --out-file executor.wasm ``` With profiling feature enabled Iroha exposes endpoint to scrap pprof profiles: diff --git a/Cargo.lock b/Cargo.lock index 65c495e40e1..09faa0690b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -844,12 +844,12 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -2978,23 +2978,6 @@ dependencies = [ "vergen", ] -[[package]] -name = "iroha_codec" -version = "2.0.0-rc.1.0" -dependencies = [ - "clap", - "colored", - "eyre", - "iroha_data_model", - "iroha_genesis", - "iroha_schema", - "iroha_schema_gen", - "parity-scale-codec", - "serde", - "serde_json", - "supports-color 2.1.0", -] - [[package]] name = "iroha_config" version = "2.0.0-rc.1.0" @@ -3330,16 +3313,24 @@ dependencies = [ "clap", "color-eyre", "derive_more", + "inquire", + "iroha_core", "iroha_crypto", "iroha_data_model", "iroha_executor_data_model", "iroha_genesis", "iroha_primitives", + "iroha_schema", "iroha_schema_gen", + "iroha_swarm", "iroha_test_samples", + "iroha_version", + "iroha_wasm_builder", + "owo-colors 4.1.0", "parity-scale-codec", "serde", "serde_json", + "spinoff", ] [[package]] @@ -3534,7 +3525,6 @@ dependencies = [ "color-eyre", "displaydoc", "expect-test", - "inquire", "iroha_config", "iroha_crypto", "iroha_data_model", @@ -3734,7 +3724,6 @@ dependencies = [ "path-absolutize", "serde_json", "sha256", - "spinoff", "wasm-opt", ] @@ -3919,16 +3908,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "kura_inspector" -version = "2.0.0-rc.1.0" -dependencies = [ - "clap", - "iroha_core", - "iroha_data_model", - "iroha_version", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -6404,9 +6383,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" diff --git a/crates/iroha_codec/Cargo.toml b/crates/iroha_codec/Cargo.toml deleted file mode 100644 index fd1bac9b464..00000000000 --- a/crates/iroha_codec/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "iroha_codec" - -edition.workspace = true -version.workspace = true -authors.workspace = true - -license.workspace = true - -[lints] -workspace = true - -[dependencies] -iroha_schema = { workspace = true } -iroha_schema_gen = { workspace = true } -iroha_genesis = { workspace = true } - -clap = { workspace = true, features = ["derive", "cargo", "env", "string"] } -eyre = { workspace = true } -parity-scale-codec = { workspace = true } -colored = "2.1.0" -serde_json = { workspace = true, features = ["std"]} -serde = { workspace = true } -supports-color = { workspace = true } - -[dev-dependencies] -iroha_data_model = { workspace = true } - -[build-dependencies] -iroha_data_model = { workspace = true } - -parity-scale-codec = { workspace = true } -serde_json = { workspace = true, features = ["std"]} -serde = { workspace = true } -eyre = { workspace = true } diff --git a/crates/iroha_kagami/Cargo.toml b/crates/iroha_kagami/Cargo.toml index 6c97b364da2..1c75edb75ca 100644 --- a/crates/iroha_kagami/Cargo.toml +++ b/crates/iroha_kagami/Cargo.toml @@ -20,14 +20,32 @@ iroha_schema_gen.workspace = true iroha_primitives.workspace = true iroha_genesis.workspace = true iroha_test_samples.workspace = true +iroha_schema.workspace = true +iroha_core.workspace = true +iroha_version.workspace = true +iroha_wasm_builder.workspace = true + +iroha_swarm = { path = "../iroha_swarm" } clap = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] } +spinoff = { workspace = true, features = ["binary"] } +owo-colors = { workspace = true, features = ["supports-colors"] } color-eyre.workspace = true serde_json.workspace = true derive_more.workspace = true parity-scale-codec.workspace = true +inquire = "0.6.2" + +[build-dependencies] +iroha_data_model = { workspace = true } + +parity-scale-codec = { workspace = true } +serde_json = { workspace = true, features = ["std"]} +serde = { workspace = true } +color-eyre = { workspace = true } + [[bin]] name = "kagami" path = "src/main.rs" diff --git a/crates/iroha_kagami/README.md b/crates/iroha_kagami/README.md index a6738056823..3d0abba9b23 100644 --- a/crates/iroha_kagami/README.md +++ b/crates/iroha_kagami/README.md @@ -14,7 +14,18 @@ This will place `kagami` inside the `target/debug/` directory (from the root of ## Usage -As it is an internal tool with no stable API, we decided to move all the documentation into the CLI help messages and keep it up to date in a single place. +### Subcommands + +| Command | Description | +|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| +| `crypto` | Generate cryptographic key pairs using the given algorithm and either private key or seed | +| `schema` | Generate the schema used for code generation in Iroha SDKs | +| [`genesis`](docs/genesis.md) | Commands related to genesis | +| [`codec`](docs/codec.md) | Commands related to codec | +| [`kura`](docs/kura.md) | Commands related to block inspection | +| [`swarm`](docs/swarm.md) | Commands related to Docker Compose configuration generation | +| [`wasm`](docs/wasm.md) | Commands related to building smartcontracts | +| `help` | Print the help message for the tool or a subcommand Run: diff --git a/crates/iroha_codec/build.rs b/crates/iroha_kagami/build.rs similarity index 94% rename from crates/iroha_codec/build.rs rename to crates/iroha_kagami/build.rs index 5ad93926c7d..23dfac2df96 100644 --- a/crates/iroha_codec/build.rs +++ b/crates/iroha_kagami/build.rs @@ -2,7 +2,7 @@ use std::{fs, path::PathBuf}; -use eyre::Result; +use color_eyre::eyre::Result; use iroha_data_model::{account::NewAccount, domain::NewDomain, prelude::*}; use parity_scale_codec::Encode; use serde::de::DeserializeOwned; @@ -20,7 +20,7 @@ where T: Encode + DeserializeOwned, { let mut path_to = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path_to.push("samples/"); + path_to.push("samples/codec"); path_to.push(filename); let path_to_json = path_to.with_extension("json"); diff --git a/crates/iroha_codec/README.md b/crates/iroha_kagami/docs/codec.md similarity index 77% rename from crates/iroha_codec/README.md rename to crates/iroha_kagami/docs/codec.md index 80cb2dbd6bb..3735078e2e5 100644 --- a/crates/iroha_codec/README.md +++ b/crates/iroha_kagami/docs/codec.md @@ -1,22 +1,6 @@ -# Parity Scale Decoder Tool +# Parity Scale Decoder -This tool helps you decode **Iroha 2** data types from binaries using [Parity Scale Codec](https://github.com/paritytech/parity-scale-codec). - -## Build - -To build the tool, run: - -```bash -cargo build --bin iroha_codec -``` - -## Usage - -Run Parity Scale Decoder Tool: - -```bash -iroha_codec -``` +These commands help you decode **Iroha 2** data types from binaries using [Parity Scale Codec](https://github.com/paritytech/parity-scale-codec). ### Subcommands @@ -33,7 +17,7 @@ iroha_codec To list all supported data types, run from the project main directory: ```bash -./target/debug/iroha_codec list-types +kagami codec list-types ```
Expand to see expected output @@ -66,7 +50,7 @@ These commands require `--type` argument. If data type is not known, [`scale-to- * Decode the specified data type from a binary: ```bash - ./target/debug/iroha_codec scale-to-json --input --type + kagami codec scale-to-json --input --type ``` ### `scale-to-json` and `json-to-scale` usage examples @@ -74,13 +58,13 @@ These commands require `--type` argument. If data type is not known, [`scale-to- * Decode the `NewAccount` data type from the `samples/account.bin` binary: ```bash - ./target/debug/iroha_codec scale-to-json --input iroha_codec/samples/account.bin --type NewAccount + kagami codec scale-to-json --input crates/iroha_kagami/src/codec/samples/account.bin --type NewAccount ``` * Encode the `NewAccount` data type from the `samples/account.json`: ```bash - ./target/debug/iroha_codec json-to-scale --input iroha_codec/samples/account.json --output result.bin --type NewAccount + kagami codec json-to-scale --input crates/iroha_kagami/src/codec/samples/account.json --output result.bin --type NewAccount ``` ## `scale-to-rust` @@ -95,13 +79,13 @@ Decode the data type from a given binary. * Decode the specified data type from a binary: ```bash - ./target/debug/iroha_codec scale-to-rust --type + kagami codec scale-to-rust --type ``` * If you are not sure which data type is encoded in the binary, run the tool without the `--type` option: ```bash - ./target/debug/iroha_codec scale-to-rust + kagami codec scale-to-rust ``` ### `scale-to-rust` usage examples @@ -109,11 +93,11 @@ Decode the data type from a given binary. * Decode the `NewAccount` data type from the `samples/account.bin` binary: ```bash - ./target/debug/iroha_codec scale-to-rust iroha_codec/samples/account.bin --type NewAccount + kagami codec scale-to-rust crates/iroha_kagami/src/codec/samples/account.bin --type NewAccount ``` * Decode the `NewDomain` data type from the `samples/domain.bin` binary: ```bash - ./target/debug/iroha_codec scale-to-rust iroha_codec/samples/domain.bin --type NewDomain + kagami codec scale-to-rust crates/iroha_kagami/src/codec/samples/domain.bin --type NewDomain ``` diff --git a/crates/iroha_kagami/docs/genesis.md b/crates/iroha_kagami/docs/genesis.md new file mode 100644 index 00000000000..4a26dff65e2 --- /dev/null +++ b/crates/iroha_kagami/docs/genesis.md @@ -0,0 +1,11 @@ +# Genesis + +These commands help to organize genesis configurations + +### Subcommands + +| Command | Description | +|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| +| `sign` | Sign the genesis block | +| `generate` | Generate a genesis configuration and standard-output in JSON format | +| `help` | Print the help message for the tool or a subcommand | diff --git a/crates/kura_inspector/README.md b/crates/iroha_kagami/docs/kura.md similarity index 73% rename from crates/kura_inspector/README.md rename to crates/iroha_kagami/docs/kura.md index 5918cf31c6a..755c51dfff1 100644 --- a/crates/kura_inspector/README.md +++ b/crates/iroha_kagami/docs/kura.md @@ -1,35 +1,13 @@ # Kura Inspector -Kura Inspector is a CLI tool to inspect blocks in disk storage. - -With Kura Inspector you can inspect the disk storage regardless of the operating status of Iroha and print out block contents in a human-readabe format. - -## Examples - -- Print the contents of the latest block: - - ```bash - kura_inspector print - ``` - -- Print all blocks with a height between 100 and 104: - - ```bash - kura_inspector -f 100 print -n 5 - ``` - -- Print errors for all blocks with a height between 100 and 104: - - ```bash - kura_inspector -f 100 print -n 5 >/dev/null - ``` +With Kura Inspector you can inspect blocks in disk storage regardless of the operating status of Iroha and print out block contents in a human-readabe format. ## Usage Run Kura Inspector: ```bash -kura_inspector [OPTIONS] +kagami kura [OPTIONS] ``` ### Options @@ -49,8 +27,8 @@ kura_inspector [OPTIONS] An error in Kura Inspector occurs if one the following happens: -- `kura_inspector` fails to configure `kura::BlockStore` -- `kura_inspector` [fails](#print-errors) to run the `print` subcommand +- `kura` fails to configure `kura::BlockStore` +- `kura` [fails](#print-errors) to run the `print` subcommand ## `print` @@ -64,6 +42,26 @@ The `print` command reads data from the `block_store` and prints the results to ### `print` errors An error in `print` occurs if one the following happens: -- `kura_inspector` fails to read `block_store` -- `kura_inspector` fails to print the `output` -- `kura_inspector` tries to print the latest block and there is none \ No newline at end of file +- `kura` fails to read `block_store` +- `kura` fails to print the `output` +- `kura` tries to print the latest block and there is none + +## Examples + +- Print the contents of the latest block: + + ```bash + kagami kura print + ``` + +- Print all blocks with a height between 100 and 104: + + ```bash + kagami kura -f 100 print -n 5 + ``` + +- Print errors for all blocks with a height between 100 and 104: + + ```bash + kagami kura -f 100 print -n 5 >/dev/null + ``` \ No newline at end of file diff --git a/crates/iroha_swarm/README.md b/crates/iroha_kagami/docs/swarm.md similarity index 94% rename from crates/iroha_swarm/README.md rename to crates/iroha_kagami/docs/swarm.md index 637b8efe49d..c5b1132ff93 100644 --- a/crates/iroha_swarm/README.md +++ b/crates/iroha_kagami/docs/swarm.md @@ -1,11 +1,11 @@ # Iroha Swarm -Command-line tool for generating Docker Compose configuration for Iroha. +Tools for generating Docker Compose configuration for Iroha. ## Usage ```bash -iroha_swarm [OPTIONS] --peers --config-dir --image --out-file +kagami swarm [OPTIONS] --peers --config-dir --image --out-file ``` ### Options @@ -50,7 +50,7 @@ iroha_swarm [OPTIONS] --peers --config-dir --image --out-fi Generate a configuration with 4 peers, using `Iroha` as the cryptographic seed, using `./peer_config` as a directory with configuration, and using `.` as a directory with the Iroha `Dockerfile` to build a `myiroha:local` image, saving the Compose config to `./my-configs/docker-compose.build.yml` in the current directory: ```bash -iroha_swarm \ +kagami swarm \ --peers 4 \ --seed Iroha \ --config-dir ./peer_config \ @@ -62,7 +62,7 @@ iroha_swarm \ Generate the same configuration, but use an existing image pulled from Docker Hub instead. The output is printed to stdout (notice how the target path still has to be provided, as it is used to resolve the config and build directories): ```bash -iroha_swarm \ +kagami swarm \ --peers 4 \ --seed Iroha \ --healthcheck \ diff --git a/crates/iroha_kagami/docs/wasm.md b/crates/iroha_kagami/docs/wasm.md new file mode 100644 index 00000000000..a69253e9fab --- /dev/null +++ b/crates/iroha_kagami/docs/wasm.md @@ -0,0 +1,23 @@ +# `iroha_wasm_builder` + +Tools for building wasm smartcontracts. + +## Usage + +**Check the smartcontract:** + +```bash +kagami wasm check path/to/project +``` + +**Build the smartcontract:** + +```bash +kagami wasm build path/to/project --out-file ./smartcontract.wasm +``` + +**Build with options:** + +```bash +kagami wasm build path/to/project --optimize --format --out-file ./smartcontract.wasm +``` diff --git a/crates/iroha_codec/samples/account.bin b/crates/iroha_kagami/samples/codec/account.bin similarity index 100% rename from crates/iroha_codec/samples/account.bin rename to crates/iroha_kagami/samples/codec/account.bin diff --git a/crates/iroha_codec/samples/account.json b/crates/iroha_kagami/samples/codec/account.json similarity index 100% rename from crates/iroha_codec/samples/account.json rename to crates/iroha_kagami/samples/codec/account.json diff --git a/crates/iroha_codec/samples/domain.bin b/crates/iroha_kagami/samples/codec/domain.bin similarity index 100% rename from crates/iroha_codec/samples/domain.bin rename to crates/iroha_kagami/samples/codec/domain.bin diff --git a/crates/iroha_codec/samples/domain.json b/crates/iroha_kagami/samples/codec/domain.json similarity index 100% rename from crates/iroha_codec/samples/domain.json rename to crates/iroha_kagami/samples/codec/domain.json diff --git a/crates/iroha_codec/samples/trigger.bin b/crates/iroha_kagami/samples/codec/trigger.bin similarity index 100% rename from crates/iroha_codec/samples/trigger.bin rename to crates/iroha_kagami/samples/codec/trigger.bin diff --git a/crates/iroha_codec/samples/trigger.json b/crates/iroha_kagami/samples/codec/trigger.json similarity index 100% rename from crates/iroha_codec/samples/trigger.json rename to crates/iroha_kagami/samples/codec/trigger.json diff --git a/crates/iroha_codec/src/main.rs b/crates/iroha_kagami/src/codec.rs similarity index 77% rename from crates/iroha_codec/src/main.rs rename to crates/iroha_kagami/src/codec.rs index 2aa7b236eb4..3749bb55b77 100644 --- a/crates/iroha_codec/src/main.rs +++ b/crates/iroha_kagami/src/codec.rs @@ -1,4 +1,3 @@ -//! Parity Scale decoder tool for Iroha data types. For usage run with `--help` use core::num::{NonZeroU32, NonZeroU64}; use std::{ collections::{BTreeMap, BTreeSet}, @@ -11,13 +10,17 @@ use std::{ path::PathBuf, }; -use clap::Parser; -use colored::*; -use eyre::{eyre, Result}; +use clap::{Args as ClapArgs, Subcommand}; +use color_eyre::{ + eyre::{eyre, Result}, + owo_colors::OwoColorize, +}; use iroha_schema_gen::complete_data_model::*; use parity_scale_codec::{DecodeAll, Encode}; use serde::{de::DeserializeOwned, Serialize}; +use crate::{Outcome, RunArgs}; + /// Generate map with types and converter trait object fn generate_map() -> ConverterMap { let mut map = ConverterMap::new(); @@ -75,31 +78,14 @@ where } } -/// Parity Scale decoder tool for Iroha data types -#[derive(Debug, Parser)] -#[clap(version, about, author)] -struct Args { +/// Parity Scale decoder for Iroha data types +#[derive(Debug, ClapArgs, Clone)] +pub struct Args { #[clap(subcommand)] command: Command, - - /// Whether to enable ANSI colored output or not - /// - /// By default, Iroha determines whether the terminal supports colors or not. - /// - /// In order to disable this flag explicitly, pass `--terminal-colors=false`. - #[arg( - long, - env, - default_missing_value("true"), - default_value(default_terminal_colors_str()), - action(clap::ArgAction::Set), - require_equals(true), - num_args(0..=1), - )] - pub terminal_colors: bool, } -#[derive(Debug, Parser)] +#[derive(Debug, Clone, Subcommand)] enum Command { /// Show all available types ListTypes, @@ -111,7 +97,7 @@ enum Command { JsonToScale(ScaleJsonArgs), } -#[derive(Debug, clap::Args)] +#[derive(Debug, ClapArgs, Clone)] struct ScaleToRustArgs { /// Path to the binary with encoded Iroha structure binary: PathBuf, @@ -121,7 +107,7 @@ struct ScaleToRustArgs { type_name: Option, } -#[derive(Debug, clap::Args)] +#[derive(Debug, ClapArgs, Clone)] struct ScaleJsonArgs { /// Path to the input file #[clap(short, long)] @@ -134,36 +120,40 @@ struct ScaleJsonArgs { type_name: String, } -fn is_coloring_supported() -> bool { - supports_color::on(supports_color::Stream::Stdout).is_some() -} - -fn default_terminal_colors_str() -> clap::builder::OsStr { - is_coloring_supported().to_string().into() -} - -fn main() -> Result<()> { - let args = Args::parse(); - - let map = generate_map(); +impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + let map = generate_map(); - match args.command { - Command::ScaleToRust(decode_args) => { - let mut writer = BufWriter::new(io::stdout().lock()); - let decoder = ScaleToRustDecoder::new(decode_args, &map); - decoder.decode(&mut writer) - } - Command::ScaleToJson(args) => { - let decoder = ScaleJsonDecoder::new(args, &map)?; - decoder.scale_to_json() - } - Command::JsonToScale(args) => { - let decoder = ScaleJsonDecoder::new(args, &map)?; - decoder.json_to_scale() - } - Command::ListTypes => { - let mut writer = BufWriter::new(io::stdout().lock()); - list_types(&map, &mut writer) + match self.command { + Command::ScaleToRust(decode_args) => { + let decoder = ScaleToRustDecoder::new(decode_args, &map); + decoder.decode(writer) + } + Command::ScaleToJson(args) => { + let mut file_writer = match args.output.clone() { + None => None, + Some(path) => Some(BufWriter::new(File::create(path)?)), + }; + + let writer: &mut dyn Write = file_writer + .as_mut() + .map_or(writer, |file_writer| file_writer); + let decoder = ScaleJsonDecoder::new(args, &map, writer)?; + decoder.scale_to_json() + } + Command::JsonToScale(args) => { + let mut file_writer = match args.output.clone() { + None => None, + Some(path) => Some(BufWriter::new(File::create(path)?)), + }; + + let writer: &mut dyn Write = file_writer + .as_mut() + .map_or(writer, |file_writer| file_writer); + let decoder = ScaleJsonDecoder::new(args, &map, writer)?; + decoder.json_to_scale() + } + Command::ListTypes => list_types(&map, writer), } } } @@ -231,22 +221,22 @@ impl<'map> ScaleToRustDecoder<'map> { } } -struct ScaleJsonDecoder<'map> { +struct ScaleJsonDecoder<'map, 'w> { reader: Box, - writer: Box, + writer: &'w mut dyn Write, converter: &'map dyn Converter, } -impl<'map> ScaleJsonDecoder<'map> { - fn new(args: ScaleJsonArgs, map: &'map ConverterMap) -> Result { +impl<'map, 'w> ScaleJsonDecoder<'map, 'w> { + fn new( + args: ScaleJsonArgs, + map: &'map ConverterMap, + writer: &'w mut dyn Write, + ) -> Result { let reader: Box = match args.input { None => Box::new(io::stdin().lock()), Some(path) => Box::new(BufReader::new(File::open(path)?)), }; - let writer: Box = match args.output { - None => Box::new(BufWriter::new(io::stdout().lock())), - Some(path) => Box::new(BufWriter::new(File::create(path)?)), - }; let Some(converter) = map.get(&args.type_name) else { return Err(eyre!("Unknown type: `{}`", args.type_name)); }; @@ -260,7 +250,7 @@ impl<'map> ScaleJsonDecoder<'map> { fn scale_to_json(self) -> Result<()> { let Self { mut reader, - mut writer, + writer, converter, } = self; let mut input = Vec::new(); @@ -273,7 +263,7 @@ impl<'map> ScaleJsonDecoder<'map> { fn json_to_scale(self) -> Result<()> { let Self { mut reader, - mut writer, + writer, converter, } = self; let mut input = String::new(); @@ -363,7 +353,7 @@ mod tests { fn decode_sample(sample_path: &str, type_id: String, expected: &T) { let mut binary = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - binary.push("samples/"); + binary.push("samples/codec"); binary.push(sample_path); let args = ScaleToRustArgs { binary, @@ -397,7 +387,7 @@ mod tests { fn test_decode_encode(sample_path: &str, type_id: &str) { let binary = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("samples/") + .join("samples/codec") .join(sample_path); let scale_expected = fs::read(binary).expect("Couldn't read file"); @@ -411,23 +401,4 @@ mod tests { .expect("Couldn't convert to SCALE"); assert_eq!(scale_actual, scale_expected); } - - #[test] - fn terminal_colors_works_as_expected() -> eyre::Result<()> { - fn try_with(arg: &str) -> eyre::Result { - // Since arg contains enum Command and we must provide something for it, we use "list-types" - Ok(Args::try_parse_from(["test", arg, "list-types"])?.terminal_colors) - } - - assert_eq!( - Args::try_parse_from(["test", "list-types"])?.terminal_colors, - is_coloring_supported() - ); - assert!(try_with("--terminal-colors")?); - assert!(!try_with("--terminal-colors=false")?); - assert!(try_with("--terminal-colors=true")?); - assert!(try_with("--terminal-colors=random").is_err()); - - Ok(()) - } } diff --git a/crates/kura_inspector/src/main.rs b/crates/iroha_kagami/src/kura.rs similarity index 50% rename from crates/kura_inspector/src/main.rs rename to crates/iroha_kagami/src/kura.rs index 10eaec2efd6..db7259249db 100644 --- a/crates/kura_inspector/src/main.rs +++ b/crates/iroha_kagami/src/kura.rs @@ -1,15 +1,19 @@ -//! Kura inspector binary. For usage run with `--help`. -use std::path::{Path, PathBuf}; +use std::{ + io::{BufWriter, Write}, + path::{Path, PathBuf}, +}; -use clap::{Parser, Subcommand}; +use clap::{Args as ClapArgs, Subcommand}; +use color_eyre::eyre::{eyre, WrapErr as _}; use iroha_core::kura::{BlockIndex, BlockStore}; use iroha_data_model::block::SignedBlock; use iroha_version::scale::DecodeVersioned; +use crate::{Outcome, RunArgs}; + /// Kura inspector -#[derive(Parser)] -#[clap(author, version, about)] -struct Args { +#[derive(Debug, ClapArgs, Clone)] +pub struct Args { /// Height of the block from which start the inspection. /// Defaults to the latest block height #[clap(short, long, name = "BLOCK_HEIGHT")] @@ -20,7 +24,7 @@ struct Args { command: Command, } -#[derive(Subcommand)] +#[derive(Subcommand, Debug, Clone)] enum Command { /// Print contents of a certain length of the blocks Print { @@ -31,25 +35,36 @@ enum Command { }, } -fn main() { - let args = Args::parse(); - - let from_height = args.from.map(|height| { - assert!(height != 0, "The genesis block has the height 1. Therefore, the \"from height\" you specify must not be 0."); - // Kura starts counting blocks from 0 like an array while the outside world counts the first block as number 1. - height - 1 - }); - - match args.command { - Command::Print { length } => print_blockchain( - &args.path_to_block_store, - from_height.unwrap_or(u64::MAX), - length, - ), +impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + let args = self; + let from_height = args.from.map(|height| { + if height == 0 { + Err(eyre!("The genesis block has the height 1. Therefore, the \"from height\" you specify must not be 0 ({} is provided). ", height)) + } else { + // Kura starts counting blocks from 0 like an array while the outside world counts the first block as number 1. + Ok(height - 1) + } + }).transpose()?; + + match args.command { + Command::Print { length } => print_blockchain( + writer, + &args.path_to_block_store, + from_height.unwrap_or(u64::MAX), + length, + ) + .wrap_err("failed to print blockchain"), + } } } -fn print_blockchain(block_store_path: &Path, from_height: u64, block_count: u64) { +fn print_blockchain( + writer: &mut dyn Write, + block_store_path: &Path, + from_height: u64, + block_count: u64, +) -> Outcome { let mut block_store_path: std::borrow::Cow<'_, Path> = block_store_path.into(); if let Some(os_str_file_name) = block_store_path.file_name() { @@ -63,18 +78,12 @@ fn print_blockchain(block_store_path: &Path, from_height: u64, block_count: u64) let index_count = block_store .read_index_count() - .expect("Failed to read index count from block store {block_store_path:?}."); + .wrap_err("failed to read index count from block store {block_store_path:?}.")?; if index_count == 0 { - println!("The block store is empty."); - return; + return Err(eyre!("Index count is zero. This could be because there are no blocks in the store: {block_store_path:?}")); } - assert!( - index_count != 0, - "Index count is zero. This could be because there are no blocks in the store: {block_store_path:?}" - ); - let from_height = if from_height >= index_count { index_count - 1 } else { @@ -94,39 +103,43 @@ fn print_blockchain(block_store_path: &Path, from_height: u64, block_count: u64) }; block_count .try_into() - .expect("block_count didn't fit in 32-bits") + .wrap_err("block_count didn't fit in 32-bits")? ]; block_store .read_block_indices(from_height, &mut block_indices) - .expect("Failed to read block indices"); + .wrap_err("failed to read block indices")?; let block_indices = block_indices; // Now for the actual printing - println!("Index file says there are {index_count} blocks."); - println!( + writeln!(writer, "Index file says there are {index_count} blocks.",)?; + writeln!( + writer, "Printing blocks {}-{}...", from_height + 1, from_height + block_count - ); + )?; for i in 0..block_count { - let idx = block_indices[usize::try_from(i).expect("i didn't fit in 32-bits")]; + let idx = block_indices[usize::try_from(i).wrap_err("index didn't fit in 32-bits")?]; let meta_index = from_height + i; - println!( + writeln!( + writer, "Block#{} starts at byte offset {} and is {} bytes long.", meta_index + 1, idx.start, idx.length - ); + )?; let mut block_buf = - vec![0_u8; usize::try_from(idx.length).expect("index_len didn't fit in 32-bits")]; + vec![0_u8; usize::try_from(idx.length).wrap_err("index_len didn't fit in 32-bits")?]; block_store .read_block_data(idx.start, &mut block_buf) - .unwrap_or_else(|_| panic!("Failed to read block № {} data.", meta_index + 1)); + .wrap_err(format!("failed to read block № {} data.", meta_index + 1))?; let block = SignedBlock::decode_all_versioned(&block_buf) - .unwrap_or_else(|_| panic!("Failed to decode block № {}", meta_index + 1)); - println!("Block#{} :", meta_index + 1); - println!("{block:#?}"); + .wrap_err(format!("Failed to decode block № {}", meta_index + 1))?; + writeln!(writer, "Block#{} :", meta_index + 1)?; + writeln!(writer, "{block:#?}")?; } + + Ok(()) } diff --git a/crates/iroha_kagami/src/main.rs b/crates/iroha_kagami/src/main.rs index c043339197d..c578a6f15b0 100644 --- a/crates/iroha_kagami/src/main.rs +++ b/crates/iroha_kagami/src/main.rs @@ -7,9 +7,13 @@ use clap::{Args as ClapArgs, Parser}; use color_eyre::eyre::WrapErr as _; use iroha_data_model::prelude::*; +mod codec; mod crypto; mod genesis; +mod kura; mod schema; +mod swarm; +mod wasm; /// Outcome shorthand used throughout this crate pub(crate) type Outcome = color_eyre::Result<()>; @@ -42,6 +46,15 @@ enum Args { /// Commands related to genesis #[clap(subcommand)] Genesis(genesis::Args), + /// Commands related to codec + Codec(codec::Args), + /// Commands related to block inspection + Kura(kura::Args), + /// Commands related to Docker Compose configuration generation + Swarm(swarm::Args), + /// Commands related to building wasm smartcontracts + #[clap(subcommand)] + Wasm(wasm::Args), } impl RunArgs for Args { @@ -52,6 +65,83 @@ impl RunArgs for Args { Crypto(args) => args.run(writer), Schema(args) => args.run(writer), Genesis(args) => args.run(writer), + Codec(args) => args.run(writer), + Kura(args) => args.run(writer), + Swarm(args) => args.run(writer), + Wasm(args) => args.run(writer), } } } + +#[cfg(test)] +mod tests { + use clap::Error; + + use super::Args; + + fn parse(args: &str) -> Result { + ::try_parse_from(args.split(' ')) + } + + #[test] + fn ok_with_flags() { + assert!(parse( + "kagami swarm \ + -p 20 \ + -c ./config \ + -i hyperledger/iroha \ + -o sample.yml\ + -HF", + ) + .is_ok()) + } + + #[test] + fn cannot_mix_print_and_force() { + assert!(parse( + "kagami swarm \ + -p 20 \ + -c ./config \ + -i hyperledger/iroha \ + -o sample.yml \ + -PF", + ) + .is_err()) + } + + #[test] + fn ok_when_pull_image() { + assert!(parse( + "kagami swarm \ + -p 20 \ + -c ./config \ + -i hyperledger/iroha \ + -o sample.yml", + ) + .is_ok()) + } + + #[test] + fn ok_when_build_image() { + assert!(parse( + "kagami swarm \ + -p 20 \ + -i hyperledger/iroha \ + -b . \ + -c ./config \ + -o sample.yml", + ) + .is_ok()) + } + + #[test] + fn fails_when_image_is_omitted() { + assert!(parse( + "kagami swarm \ + -p 1 \ + -c ./ \ + -o test.yml", + ) + .is_err()) + } +} diff --git a/crates/iroha_swarm/src/main.rs b/crates/iroha_kagami/src/swarm.rs similarity index 58% rename from crates/iroha_swarm/src/main.rs rename to crates/iroha_kagami/src/swarm.rs index 193964521d1..974c48a66df 100644 --- a/crates/iroha_swarm/src/main.rs +++ b/crates/iroha_kagami/src/swarm.rs @@ -1,8 +1,12 @@ -//! Iroha Swarm CLI. +use std::io::{BufWriter, Write}; + +use clap::Args as ClapArgs; + +use crate::{Outcome, RunArgs}; /// Docker Compose configuration generator for Iroha. #[allow(clippy::struct_excessive_bools)] -#[derive(clap::Parser, Debug)] +#[derive(ClapArgs, Debug, Clone)] pub struct Args { // TODO: optional peer configuration file / other ways to configure peers /// Number of peer services in the configuration. @@ -98,133 +102,61 @@ impl Args { } } -fn main() -> color_eyre::Result<()> { - color_eyre::install()?; - - let args: Args = ::parse(); - - if !args.print && !args.user_allows_overwrite()? { - return Ok(()); - } - - let swarm = iroha_swarm::Swarm::new( - args.peers, - args.seed.as_deref().map(str::as_bytes), - args.healthcheck, - &args.config_dir, - &args.image, - args.build.as_deref(), - args.no_cache, - &args.out_file, - )?; - let schema = swarm.build(); - - let (mut stdout, mut file); - - let writer: &mut dyn std::io::Write = if args.print { - stdout = std::io::stdout(); - &mut stdout - } else { - use color_eyre::eyre::Context; - file = std::fs::File::create(&args.out_file).wrap_err("Could not open the target file.")?; - &mut file - }; - - schema.write( - &mut std::io::BufWriter::new(writer), - (!args.no_banner).then_some( - [ - "Generated by `iroha_swarm`.", - "You should not edit this manually.", - ] - .into_iter() - .chain( - args.seed - .as_deref() - .map(|seed| format!("Seed: {seed}")) - .as_deref(), - ) - .collect::>() - .as_slice(), - ), - )?; - - if !args.print { - args.log_file_mode_complete(swarm.absolute_target_path()); - } - - Ok(()) -} +impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + // let args: Args = ::parse(); + let args = self; -#[cfg(test)] -mod tests { - use clap::Error; - - use super::Args; - - fn parse(args: &str) -> Result { - ::try_parse_from(args.split(' ')) - } - - #[test] - fn ok_with_flags() { - assert!(parse( - "swarm \ - -p 20 \ - -c ./config \ - -i hyperledger/iroha \ - -o sample.yml\ - -HF", - ) - .is_ok()) - } - - #[test] - fn cannot_mix_print_and_force() { - assert!(parse( - "swarm \ - -p 20 \ - -c ./config \ - -i hyperledger/iroha \ - -o sample.yml \ - -PF", - ) - .is_err()) - } - - #[test] - fn ok_when_pull_image() { - assert!(parse( - "swarm \ - -p 20 \ - -c ./config \ - -i hyperledger/iroha \ - -o sample.yml", - ) - .is_ok()) - } + if !args.print && !args.user_allows_overwrite()? { + return Ok(()); + } - #[test] - fn ok_when_build_image() { - assert!(parse( - "swarm \ - -p 20 \ - -i hyperledger/iroha \ - -b . \ - -c ./config \ - -o sample.yml", - ) - .is_ok()) - } + let swarm = iroha_swarm::Swarm::new( + args.peers, + args.seed.as_deref().map(str::as_bytes), + args.healthcheck, + &args.config_dir, + &args.image, + args.build.as_deref(), + args.no_cache, + &args.out_file, + )?; + let schema = swarm.build(); + + let mut file; + + let writer: &mut dyn Write = if args.print { + writer + } else { + use color_eyre::eyre::Context; + file = std::fs::File::create(&args.out_file) + .wrap_err("Could not open the target file.")?; + &mut file + }; + + schema.write( + &mut std::io::BufWriter::new(writer), + (!args.no_banner).then_some( + [ + "Generated by `kagami swarm`.", + "You should not edit this manually.", + ] + .into_iter() + .chain( + args.seed + .as_deref() + .map(|seed| format!("Seed: {seed}")) + .as_deref(), + ) + .collect::>() + .as_slice(), + ), + )?; + + if !args.print { + args.log_file_mode_complete(swarm.absolute_target_path()); + } - #[test] - fn fails_when_image_is_omitted() { - assert!(parse( - "swarm \ - -p 1 \ - -c ./ \ - -o test.yml", - ) - .is_err()) + Ok(()) } } diff --git a/crates/iroha_kagami/src/wasm.rs b/crates/iroha_kagami/src/wasm.rs new file mode 100644 index 00000000000..b7ff54715eb --- /dev/null +++ b/crates/iroha_kagami/src/wasm.rs @@ -0,0 +1,111 @@ +use std::{ + io::{BufWriter, Write}, + path::PathBuf, +}; + +use clap::{Args as ClapArgs, Subcommand}; +use color_eyre::eyre::{eyre, Context}; +use iroha_wasm_builder::Builder; +use owo_colors::OwoColorize; + +use crate::{Outcome, RunArgs}; + +#[derive(Debug, Clone, Subcommand)] +pub enum Args { + /// Apply `cargo check` to the smartcontract + Check { + #[command(flatten)] + common: CommonArgs, + }, + /// Build the smartcontract + Build { + #[command(flatten)] + common: CommonArgs, + /// Optimize WASM output. + #[arg(long)] + optimize: bool, + /// Where to store the output WASM. If the file exists, it will be overwritten. + #[arg(long)] + out_file: PathBuf, + }, +} + +#[derive(ClapArgs, Debug, Clone)] +pub struct CommonArgs { + /// Path to the smartcontract + path: PathBuf, +} + +impl RunArgs for Args { + fn run(self, writer: &mut BufWriter) -> Outcome { + match self { + Args::Check { + common: CommonArgs { path }, + } => { + let builder = Builder::new(&path).show_output(); + builder.check()?; + } + Args::Build { + common: CommonArgs { path }, + optimize, + out_file, + } => { + let builder = Builder::new(&path).show_output(); + + let output = { + // not showing the spinner here, cargo does a progress bar for us + + match builder.build() { + Ok(output) => output, + err => err?, + } + }; + + let output = if optimize { + let sp = if std::env::var("CI").is_err() { + Some(spinoff::Spinner::new_with_stream( + spinoff::spinners::Binary, + "Optimizing the output", + None, + spinoff::Streams::Stderr, + )) + } else { + None + }; + + match output.optimize() { + Ok(optimized) => { + if let Some(mut sp) = sp { + sp.success("Output is optimized"); + } + optimized + } + err => { + if let Some(mut sp) = sp { + sp.fail("Optimization failed"); + } + err? + } + } + } else { + output + }; + + std::fs::copy(output.wasm_file_path(), &out_file).wrap_err_with(|| { + eyre!( + "Failed to write the resulting file into {}", + out_file.display() + ) + })?; + + writeln!( + writer, + "✓ File is written into {}", + out_file.display().green().bold() + )?; + } + } + + Ok(()) + } +} diff --git a/crates/iroha_swarm/Cargo.toml b/crates/iroha_swarm/Cargo.toml index 8831c10bd73..d173f61daec 100644 --- a/crates/iroha_swarm/Cargo.toml +++ b/crates/iroha_swarm/Cargo.toml @@ -22,7 +22,6 @@ serde_with = { workspace = true, features = ["json", "macros", "hex"] } displaydoc.workspace = true serde_yaml = "0.9.34" pathdiff = "0.2.1" -inquire = "0.6.2" [dev-dependencies] serde_json.workspace = true diff --git a/crates/iroha_wasm_builder/Cargo.toml b/crates/iroha_wasm_builder/Cargo.toml index 990a2ff8a95..88c569d0404 100644 --- a/crates/iroha_wasm_builder/Cargo.toml +++ b/crates/iroha_wasm_builder/Cargo.toml @@ -20,5 +20,4 @@ wasm-opt = "0.116.1" clap = { workspace = true, features = ["derive"] } color-eyre.workspace = true -spinoff = { workspace = true, features = ["binary"] } owo-colors = { workspace = true, features = ["supports-colors"] } diff --git a/crates/iroha_wasm_builder/README.md b/crates/iroha_wasm_builder/README.md deleted file mode 100644 index cef8a10db00..00000000000 --- a/crates/iroha_wasm_builder/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# `iroha_wasm_builder` - -A CLI for building wasm smartcontracts. - -## Usage - -**Check the smartcontract:** - -```bash -iroha_wasm_builder check path/to/project -``` - -**Build the smartcontract:** - -```bash -iroha_wasm_builder build path/to/project --out-file ./smartcontract.wasm -``` - -**Build with options:** - -```bash -iroha_wasm_builder build path/to/project --optimize --format --out-file ./smartcontract.wasm -``` diff --git a/crates/iroha_wasm_builder/src/main.rs b/crates/iroha_wasm_builder/src/main.rs deleted file mode 100644 index 73b35822d49..00000000000 --- a/crates/iroha_wasm_builder/src/main.rs +++ /dev/null @@ -1,106 +0,0 @@ -#![allow(missing_docs)] - -use std::path::PathBuf; - -use clap::{Args, Parser}; -use color_eyre::eyre::{eyre, Context}; -use iroha_wasm_builder::Builder; -use owo_colors::OwoColorize; - -#[derive(Parser, Debug)] -#[command(name = "iroha_wasm_builder", version, author)] -enum Cli { - /// Apply `cargo check` to the smartcontract - Check { - #[command(flatten)] - common: CommonArgs, - }, - /// Build the smartcontract - Build { - #[command(flatten)] - common: CommonArgs, - /// Optimize WASM output. - #[arg(long)] - optimize: bool, - /// Where to store the output WASM. If the file exists, it will be overwritten. - #[arg(long)] - out_file: PathBuf, - }, -} - -#[derive(Args, Debug)] -struct CommonArgs { - /// Path to the smartcontract - path: PathBuf, -} - -fn main() -> color_eyre::Result<()> { - match Cli::parse() { - Cli::Check { - common: CommonArgs { path }, - } => { - let builder = Builder::new(&path).show_output(); - builder.check()?; - } - Cli::Build { - common: CommonArgs { path }, - optimize, - out_file, - } => { - let builder = Builder::new(&path).show_output(); - - let output = { - // not showing the spinner here, cargo does a progress bar for us - - match builder.build() { - Ok(output) => output, - err => err?, - } - }; - - let output = if optimize { - let sp = if std::env::var("CI").is_err() { - Some(spinoff::Spinner::new_with_stream( - spinoff::spinners::Binary, - "Optimizing the output", - None, - spinoff::Streams::Stderr, - )) - } else { - None - }; - - match output.optimize() { - Ok(optimized) => { - if let Some(mut sp) = sp { - sp.success("Output is optimized"); - } - optimized - } - err => { - if let Some(mut sp) = sp { - sp.fail("Optimization failed"); - } - err? - } - } - } else { - output - }; - - std::fs::copy(output.wasm_file_path(), &out_file).wrap_err_with(|| { - eyre!( - "Failed to write the resulting file into {}", - out_file.display() - ) - })?; - - println!( - "✓ File is written into {}", - out_file.display().green().bold() - ); - } - } - - Ok(()) -} diff --git a/crates/kura_inspector/Cargo.toml b/crates/kura_inspector/Cargo.toml deleted file mode 100644 index 31854303380..00000000000 --- a/crates/kura_inspector/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "kura_inspector" - -edition.workspace = true -version.workspace = true -authors.workspace = true - -license.workspace = true - -[lints] -workspace = true - -[dependencies] -iroha_core = { workspace = true } -iroha_version = { workspace = true } -iroha_data_model = { workspace = true } - -clap = { workspace = true, features = ["derive", "cargo"] } diff --git a/defaults/docker-compose.local.yml b/defaults/docker-compose.local.yml index 0fe84117f91..66a4cc4e537 100644 --- a/defaults/docker-compose.local.yml +++ b/defaults/docker-compose.local.yml @@ -1,4 +1,4 @@ -# Generated by `iroha_swarm`. +# Generated by `kagami swarm`. # You should not edit this manually. # Seed: Iroha diff --git a/defaults/docker-compose.single.yml b/defaults/docker-compose.single.yml index b654bfb7668..bfcb31295c1 100644 --- a/defaults/docker-compose.single.yml +++ b/defaults/docker-compose.single.yml @@ -1,4 +1,4 @@ -# Generated by `iroha_swarm`. +# Generated by `kagami swarm`. # You should not edit this manually. # Seed: Iroha diff --git a/defaults/docker-compose.yml b/defaults/docker-compose.yml index cc94927f745..20d683f5dae 100644 --- a/defaults/docker-compose.yml +++ b/defaults/docker-compose.yml @@ -1,4 +1,4 @@ -# Generated by `iroha_swarm`. +# Generated by `kagami swarm`. # You should not edit this manually. # Seed: Iroha diff --git a/docs/README.md b/docs/README.md index 457f3a3cf17..bb1158bdf66 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,5 +13,3 @@ You can also check out [Iroha 2 Whitepaper](./source/iroha_2_whitepaper.md) for In this repository you can find documentation for Iroha 2 tools: - [Kagami](../crates/iroha_kagami/README.md) -- [Kura Inspector](../crates/kura_inspector/README.md) -- [Parity Scale Decoder Tool](../crates/iroha_codec/README.md) diff --git a/flake.nix b/flake.nix index 74d15a02cd7..c783921cbc1 100755 --- a/flake.nix +++ b/flake.nix @@ -48,8 +48,6 @@ "irohad" "iroha" "kagami" - "kura_inspector" - "iroha_codec" ]; # HACK: A hook to filter out darwin-specific flags when cross-compiling. diff --git a/hooks/pre-commit.sample b/hooks/pre-commit.sample index 93aa9f5e8f6..f20c1999301 100755 --- a/hooks/pre-commit.sample +++ b/hooks/pre-commit.sample @@ -13,8 +13,8 @@ cargo run --bin kagami -- genesis generate --executor executor.wasm --wasm-dir l # update schema cargo run --bin kagami -- schema > ./docs/source/references/schema.json # update docker compose files -cargo run --bin iroha_swarm -- -p 1 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.single.yml -F -cargo run --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.local.yml -F -cargo run --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev -o ./defaults/docker-compose.yml -F +cargo run --bin kagami -- swarm -p 1 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.single.yml -F +cargo run --bin kagami -- swarm -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.local.yml -F +cargo run --bin kagami -- swarm -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev -o ./defaults/docker-compose.yml -F # stage updates git add ./defaults/genesis.json ./docs/source/references/schema.json ./defaults/docker-compose.single.yml ./defaults/docker-compose.local.yml ./defaults/docker-compose.yml diff --git a/scripts/build_wasm.sh b/scripts/build_wasm.sh index da0ee864647..aada9058d15 100755 --- a/scripts/build_wasm.sh +++ b/scripts/build_wasm.sh @@ -23,7 +23,7 @@ build() { mkdir -p "$TARGET_DIR/$1" for name in ${NAMES[@]}; do out_file="$TARGET_DIR/$1/$name.wasm" - cargo run --bin iroha_wasm_builder -- build "$CARGO_DIR/$1/$name" --optimize --out-file "$out_file" + cargo run --bin kagami -- wasm build "$CARGO_DIR/$1/$name" --optimize --out-file "$out_file" done echo "info: WASM $1 build complete" echo "artifacts written to $TARGET_DIR/$1/" diff --git a/scripts/tests/consistency.sh b/scripts/tests/consistency.sh index cbbdabd04a2..e09360e6e5e 100755 --- a/scripts/tests/consistency.sh +++ b/scripts/tests/consistency.sh @@ -25,15 +25,15 @@ case $1 in } command_base_for_single() { - echo "cargo run --release --bin iroha_swarm -- -p 1 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b ." + echo "cargo run --release --bin kagami -- swarm -p 1 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b ." } command_base_for_multiple_local() { - echo "cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b ." + echo "cargo run --release --bin kagami -- swarm -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b ." } command_base_for_default() { - echo "cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev" + echo "cargo run --release --bin kagami -- swarm -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev" } diff --git a/wasm/libs/default_executor/README.md b/wasm/libs/default_executor/README.md index d646e872ed7..2451f23adea 100644 --- a/wasm/libs/default_executor/README.md +++ b/wasm/libs/default_executor/README.md @@ -1,8 +1,8 @@ # `iroha_default_executor` -Use the [Wasm Builder CLI](../../../crates/iroha_wasm_builder) in order to build it: +Use the [Kagami Wasm Builder](../../../crates/iroha_kagami/README.md) in order to build it: ```bash -cargo run --bin iroha_wasm_builder -- \ +cargo run --bin kagami -- wasm \ build ./wasm/libs/default_executor --optimize --out-file ./defaults/executor.wasm ```