Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…r-iroha#4136: refactor CLIs (hyperledger-iroha#4153)

* [refactor]: refactor cli(s)

- `iroha`: use `clap` `v4`
- `iroha`: update CLI (`--config`, `--terminal-colors`)
- `iroha`: handle user-provided config file strictly
- `iroha`: parse ENV config after file config
- `iroha_config`: add `genesis.file`, remove `account_*` prefix
- `iroha_config`: move some genesis config validation logic
  from `iroha`
- `iroha_client_cli`: upgrade `clap` to `v4`
- `iroha_genesis`: remove side effects (bail, logs)
- `iroha_genesis`: clarify validation logic (hyperledger-iroha#3075)
- `iroha_genesis`: remove `pub` to guard invariant of `GenesisNetwork`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: chore

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: fix & test config

- `iroha_config`: use `PathBuf` when appropriate
- `iroha_config`: fix `Path` behaviour
- `iroha_config`: finally, make `disable_panic_terminal_colors`
  truly optional (hyperledger-iroha#3506)
- `iroha`: resolve all relative paths in config file
- `iroha`: improve config error messages
- `iroha`: add config integration tests

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: test & refactor

- `iroha_client_cli`: adopt `--config` from `iroha`
- `iroha_client_cli`: refactor `--metadata` arg
- `iroha`: extend tests
- update test code overall

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: clippy, tests

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: use `serde_as_str` for paths

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [chore]: re-generate peer config

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: update `test_env.py`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: remove deprecated option from test config

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: update README

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [chore]: remove obsolete comment

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: update `iroha_swarm`

Now it relies on that `genesis.file` is set in the config file

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [feat]: `kagami config peer` + `--genesis-file-in-config`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: chores

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Ekaterina Mekhnetsova <mekkatya@gmail.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>

* [feat]: use `PATH` as value name

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: align `StatusFailure` message

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: adopt suggestion in `iroha_client_cli`

hyperledger-iroha#4153 (comment)
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [build]: exclude `genesis.file` from default config

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [feat]: refine genesis config parse error

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: fix & refactor `test_env.py`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: fix CANNOT_BE_EMPTY message

It is updated with a new version of clap

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: return `disable_panic_terminal_colors: null` to test config

It is needed so that only `iroha_test_config.json` without
defaults layer is valid (will fix on config refactoring)

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: handle configuration properly in `iroha_swarm`

- set `GENESIS_FILE` in env, since `config.json` doesn't have it
- strictly specify `config.json` and `genesis.json` files

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>

* Update client_cli/src/main.rs

Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>

* [refactor]: eliminate extra `iroha_config` dependency

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: remove dead code

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: use `serde_json::json!`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: remove `disable_panic_terminal_colors` parameter

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: update genesis & its testing

- remove `cfg(test)` behaviour from `GenesisNetwork::new()`
- refactor `impl TestGenesis for Genesis`
  - remove extra `bool` + `Option` invariant
  - allow creating genesis with additional ISIs
- remove `test-utils` feature & `GenesisNetwork::transactions_mut()`
- update related tests
- update error message on signing failure

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: remove extension check from `Path::default()`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: update genesis topology messages

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: use `Popen`'s `env` instead of global `os.environ`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: typo

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: use `Partial`/`Full` terminology

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: inherit env from OS

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: link issue hyperledger-iroha#4161

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [fix]: format

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [refactor]: apply lints

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [feat]: panic on default path extension

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [test]: update err message

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

* [docs]: update docs of `read_config`

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>

---------

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Co-authored-by: Ekaterina Mekhnetsova <mekkatya@gmail.com>
Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com>
  • Loading branch information
3 people authored and Asem-Abdelhady committed Feb 9, 2024
1 parent bb3dfa6 commit a90b725
Show file tree
Hide file tree
Showing 35 changed files with 1,046 additions and 901 deletions.
95 changes: 27 additions & 68 deletions Cargo.lock

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

17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,18 @@ A brief overview on how to configure and maintain an Iroha instance:

### Configuration

**Note:** this section is under development. You can track it in the [issue](https://github.com/hyperledger/iroha-2-docs/issues/392).
There is a set of configuration parameters that could be passed either through a configuration file or environment variables.

```shell
# look for `config.json` or `config.json5` (won't fail if files are not found)
iroha

# Override default config path through CLI or ENV
iroha --config /path/to/config.json
IROHA_CONFIG=/path/to/config.json iroha
```

**Note:** detailed configuration reference is [work in progress](https://github.com/hyperledger/iroha-2-docs/issues/392).

### Endpoints

Expand Down Expand Up @@ -198,9 +209,9 @@ prometheus --config.file=configs/prometheus.yml

### Storage

The blocks are written to the `blocks` sub-folder, which is created automatically by Iroha in the working directory of the peer. Additionally, if specified, the logging file must also be stored in a user-specified directory.
Iroha stores blocks and snapshots in the `storage` directory, which is created automatically by Iroha in the working directory of the peer. If `kura.block_store_path` is specified in the config file, it overrides the default one and is resolved relative to the config file location.

No additional storage is necessary.
**Note:** detailed configuration reference is [work in progress](https://github.com/hyperledger/iroha-2-docs/issues/392).

### Scalability

Expand Down
6 changes: 6 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ iroha_torii = { workspace = true }
iroha_genesis = { workspace = true }
iroha_wasm_builder = { workspace = true }

clap = { workspace = true, features = ["derive", "env", "string"] }
color-eyre = { workspace = true }
eyre = { workspace = true }
tracing = { workspace = true }
Expand All @@ -67,6 +68,11 @@ thread-local-panic-hook = { version = "0.1.0", optional = true }

[dev-dependencies]
serial_test = "2.0.0"
tempfile = { workspace = true }
serde_json = { workspace = true }
futures = { workspace = true }
path-absolutize = { workspace = true }
assertables = "7"

[build-dependencies]
iroha_wasm_builder = { workspace = true }
Expand Down
Loading

0 comments on commit a90b725

Please sign in to comment.