Skip to content

Commit

Permalink
refactor: rename configs to defaults, remove swarm
Browse files Browse the repository at this point in the history
Signed-off-by: Nurzhan Sakén <[email protected]>
  • Loading branch information
nxsaken committed Jul 18, 2024
1 parent 50e8104 commit eb5189a
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ config-changes:
- base-branch: 'main'
- changed-files:
# TODO have templates actually reflect configurations #4288
- any-glob-to-any-file: 'configs/*.template.toml'
- any-glob-to-any-file: 'defaults/*.template.toml'
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
CARGO_TERM_COLOR: always
DOCKER_COMPOSE_PATH: configs/swarm
DOCKER_COMPOSE_PATH: defaults

jobs:
registry:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
CARGO_TERM_COLOR: always
DOCKER_COMPOSE_PATH: configs/swarm
DOCKER_COMPOSE_PATH: defaults

jobs:
registry:
Expand Down
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`](defaults/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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ docker compose up
With the `docker-compose` instance running, use [Iroha Client CLI](./client_cli/README.md):

```bash
cargo run --bin iroha -- --config ./configs/swarm/client.toml
cargo run --bin iroha -- --config ./defaults/client.toml
```

## Integration
Expand Down
8 changes: 4 additions & 4 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You may deploy Iroha as a [native binary](#native-binary) or by using [Docker](#

### Native binary

<!-- FIXME: I don't like that this section suggests using docker configs for deployment -->
<!-- FIXME: I don't like that this section suggests using docker defaults for deployment -->

1. Prepare a deployment environment.

Expand All @@ -89,8 +89,8 @@ You may deploy Iroha as a [native binary](#native-binary) or by using [Docker](#
```bash
# FIXME
# cp ./target/release/irohad
# cp ./configs/peer/config.json deploy
# cp ./configs/peer/genesis.json deploy
# cp ./defaults/peer/config.json deploy
# cp ./defaults/peer/genesis.json deploy
```

2. Make the necessary edits to `config.json` and `genesis.json`, such as:
Expand All @@ -110,7 +110,7 @@ You may deploy Iroha as a [native binary](#native-binary) or by using [Docker](#

### Docker

We provide a sample configuration for Docker in [`docker-compose.yml`](../configs/swarm/docker-compose.yml). We highly recommend that you adjust the `config.json` to include a set of new key pairs.
We provide a sample configuration for Docker in [`docker-compose.yml`](../defaults/docker-compose.yml). We highly recommend that you adjust the `config.json` to include a set of new key pairs.

[Generate the keys](#generating-keys) and put them into `services.*.environment` in `docker-compose.yml`. Don't forget to update the public keys of `TRUSTED_PEERS`.

Expand Down
2 changes: 1 addition & 1 deletion client/examples/tutorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use iroha_primitives::numeric::Numeric;

fn main() {
// #region rust_config_load
let config = Config::load("../configs/swarm/client.toml").unwrap();
let config = Config::load("../defaults/client.toml").unwrap();
// #endregion rust_config_load

// Your code goes here…
Expand Down
2 changes: 1 addition & 1 deletion client/tests/ui_fail/cant_filter_singular_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iroha::{
};

fn main() {
let config = Config::load("../configs/swarm/client.toml").unwrap();
let config = Config::load("../defaults/client.toml").unwrap();

let client = Client::new(config);

Expand Down
2 changes: 1 addition & 1 deletion client_cli/pytests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ To do so, perform the following steps:
# Create a new directory:
mkdir test
# Copy the files:
cp configs/swarm/client.toml test
cp defaults/client.toml test
cp target/debug/iroha test
```

Expand Down
4 changes: 2 additions & 2 deletions core/benches/blocks/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ pub fn build_state(rt: &tokio::runtime::Handle, account_id: &AccountId) -> State
state_block.world.parameters.executor.memory = NonZeroU64::MAX;

let mut state_transaction = state_block.transaction();
let path_to_executor = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../configs/swarm/executor.wasm");
let path_to_executor =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../defaults/executor.wasm");
let wasm = std::fs::read(&path_to_executor)
.unwrap_or_else(|_| panic!("Failed to read file: {}", path_to_executor.display()));
let executor = Executor::new(WasmSmartContract::from_compiled(wasm));
Expand Down
4 changes: 2 additions & 2 deletions core/benches/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ fn build_test_and_transient_state() -> State {
{
let mut state_block = state.block();
let mut state_transaction = state_block.transaction();
let path_to_executor = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../configs/swarm/executor.wasm");
let path_to_executor =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../defaults/executor.wasm");
let wasm = std::fs::read(&path_to_executor)
.unwrap_or_else(|_| panic!("Failed to read file: {}", path_to_executor.display()));
let executor = Executor::new(WasmSmartContract::from_compiled(wasm));
Expand Down
2 changes: 1 addition & 1 deletion core/test_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl TestGenesis for GenesisBlock {
// TODO: Fix this somehow. Probably we need to make `kagami` a library (#3253).
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut genesis =
RawGenesisTransaction::from_path(manifest_dir.join("../../configs/swarm/genesis.json"))
RawGenesisTransaction::from_path(manifest_dir.join("../../defaults/genesis.json"))
.expect("Failed to deserialize genesis block from file");

let rose_definition_id = "rose#wonderland".parse::<AssetDefinitionId>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion default_executor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Use the [Wasm Builder CLI](../tools/wasm_builder_cli) in order to build it:

```bash
cargo run --bin iroha_wasm_builder -- \
build ./default_executor --optimize --out-file ./configs/swarm/executor.wasm
build ./default_executor --optimize --out-file ./defaults/executor.wasm
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
services:
irohad0:
image: hyperledger/iroha:local
build: ../..
build: ..
pull_policy: never
environment:
CHAIN: 00000000-0000-0000-0000-000000000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
services:
irohad0:
image: hyperledger/iroha:local
build: ../..
build: ..
pull_policy: never
environment:
CHAIN: 00000000-0000-0000-0000-000000000000
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions hooks/pre-commit.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ cd ./client/tests/integration/smartcontracts
cargo fmt --all -- --check
cd -
# update the default executor
cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --out-file ./configs/swarm/executor.wasm
cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --out-file ./defaults/executor.wasm
# update the default genesis, assuming the transaction authority is `test_samples::SAMPLE_GENESIS_ACCOUNT_ID`
cargo run --release --bin kagami -- genesis generate --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./configs/swarm/genesis.json
cargo run --release --bin kagami -- genesis generate --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./defaults/genesis.json
# update schema
cargo run --release --bin kagami -- schema > ./docs/source/references/schema.json
# update docker compose files
cargo run --release --bin iroha_swarm -- -p 1 -s Iroha -H -c ./configs/swarm -i hyperledger/iroha:local -b . -o ./configs/swarm/docker-compose.single.yml -F
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./configs/swarm -i hyperledger/iroha:local -b . -o ./configs/swarm/docker-compose.local.yml -F
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./configs/swarm -i hyperledger/iroha:dev -o ./configs/swarm/docker-compose.yml -F
cargo run --release --bin iroha_swarm -- -p 1 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.single.yml -F
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:local -b . -o ./defaults/docker-compose.local.yml -F
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev -o ./defaults/docker-compose.yml -F
# lints
cargo lints clippy --workspace --benches --tests --examples --all-features
# stage updates
git add ./configs/swarm/executor.wasm ./configs/swarm/genesis.json ./docs/source/references/schema.json ./configs/swarm/docker-compose.single.yml ./configs/swarm/docker-compose.local.yml ./configs/swarm/docker-compose.yml
git add ./defaults/executor.wasm ./defaults/genesis.json ./docs/source/references/schema.json ./defaults/docker-compose.single.yml ./defaults/docker-compose.local.yml ./defaults/docker-compose.yml
2 changes: 1 addition & 1 deletion scripts/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import urllib.request
import tomli_w

SWARM_CONFIGS_DIRECTORY = pathlib.Path("configs/swarm")
SWARM_CONFIGS_DIRECTORY = pathlib.Path("defaults")
SHARED_CONFIG_FILE_NAME = "config.base.toml"

class Network:
Expand Down
16 changes: 8 additions & 8 deletions scripts/tests/consistency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

case $1 in
"genesis")
cargo run --release --bin kagami -- genesis generate --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 | diff - configs/swarm/genesis.json || {
echo 'Please re-generate the default genesis with `cargo run --release --bin kagami -- genesis --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./configs/swarm/genesis.json`'
cargo run --release --bin kagami -- genesis generate --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 | diff - defaults/genesis.json || {
echo 'Please re-generate the default genesis with `cargo run --release --bin kagami -- genesis --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./defaults/genesis.json`'
echo 'The assumption here is that the authority of the default genesis transaction is `test_samples::SAMPLE_GENESIS_ACCOUNT_ID`'
exit 1
};;
Expand All @@ -25,19 +25,19 @@ case $1 in
}

command_base_for_single() {
echo "cargo run --release --bin iroha_swarm -- -p 1 -s Iroha -H -c ./configs/swarm -i hyperledger/iroha:local -b ."
echo "cargo run --release --bin iroha_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 ./configs/swarm -i hyperledger/iroha:local -b ."
echo "cargo run --release --bin iroha_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 ./configs/swarm -i hyperledger/iroha:dev"
echo "cargo run --release --bin iroha_swarm -- -p 4 -s Iroha -H -c ./defaults -i hyperledger/iroha:dev"
}


do_check "$(command_base_for_single)" "configs/swarm/docker-compose.single.yml"
do_check "$(command_base_for_multiple_local)" "configs/swarm/docker-compose.local.yml"
do_check "$(command_base_for_default)" "configs/swarm/docker-compose.yml"
do_check "$(command_base_for_single)" "defaults/docker-compose.single.yml"
do_check "$(command_base_for_multiple_local)" "defaults/docker-compose.local.yml"
do_check "$(command_base_for_default)" "defaults/docker-compose.yml"
esac
10 changes: 5 additions & 5 deletions tools/swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ mod tests {
use crate::Swarm;

const IMAGE: &str = "hyperledger/iroha:dev";
const PEER_CONFIG_PATH: &str = "./configs/swarm";
const TARGET_PATH: &str = "./configs/swarm/docker-compose.yml";
const PEER_CONFIG_PATH: &str = "./defaults";
const TARGET_PATH: &str = "./defaults/docker-compose.yml";

fn build_as_string(
count: std::num::NonZeroU16,
Expand Down Expand Up @@ -180,7 +180,7 @@ mod tests {
services:
irohad0:
image: hyperledger/iroha:dev
build: ../..
build: ..
pull_policy: never
environment:
CHAIN: 00000000-0000-0000-0000-000000000000
Expand Down Expand Up @@ -232,7 +232,7 @@ mod tests {
services:
irohad0:
image: hyperledger/iroha:dev
build: ../..
build: ..
pull_policy: build
environment:
CHAIN: 00000000-0000-0000-0000-000000000000
Expand Down Expand Up @@ -283,7 +283,7 @@ mod tests {
services:
irohad0:
image: hyperledger/iroha:dev
build: ../..
build: ..
pull_policy: build
environment:
CHAIN: 00000000-0000-0000-0000-000000000000
Expand Down
2 changes: 1 addition & 1 deletion torii/pytests/common/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
BASE_DIR = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
)
CONFIG_DIR = os.path.join(BASE_DIR, "configs/swarm/client.toml")
CONFIG_DIR = os.path.join(BASE_DIR, "defaults/client.toml")

with open(CONFIG_DIR, "r") as file:
config = toml.load(file)
Expand Down

0 comments on commit eb5189a

Please sign in to comment.