From 79ac153f1dcfc0a77ec511c6e25285728312ad4c Mon Sep 17 00:00:00 2001 From: Ivan Boldyrev Date: Wed, 15 Mar 2023 16:59:30 +0700 Subject: [PATCH] feat(tools): merge some tools into the `air` CLI tool (#509) * feat(tools): merge some tools into the `air` CLI tool `air-beautify` and `air-trace` are merged into a single `air` tool. Its crate name is `fluence-air-cli` as otherwise it confilicts with `air` interpreter crate. The tool has subcommands `beautify`, `run` and `stats`. * Add one-letter aliases to `air` CLI subcommands + `air beautify` => `air b` + `air run` => `air r` + `air stats` => `air s` --------- Co-authored-by: Mike Voronov --- .github/release-please/config.json | 5 +- .github/release-please/manifest.json | 3 +- .github/workflows/ci.yml | 4 +- Cargo.lock | 180 +++++++++--------- Cargo.toml | 3 +- air-interpreter/Cargo.toml | 2 +- air/Cargo.toml | 6 +- .../auth_module/Cargo.toml | 2 +- .../log_storage/Cargo.toml | 2 +- air/tracing_benches.sh | 6 +- crates/air-lib/air-parser/Cargo.toml | 9 +- .../execution-info-collector/Cargo.toml | 5 +- crates/air-lib/interpreter-data/Cargo.toml | 5 +- crates/air-lib/lambda/ast/Cargo.toml | 3 +- crates/air-lib/lambda/parser/Cargo.toml | 3 +- crates/air-lib/log-targets/Cargo.toml | 3 +- crates/air-lib/test-utils/Cargo.toml | 5 +- crates/air-lib/trace-handler/Cargo.toml | 2 +- crates/beautifier/Cargo.toml | 6 +- crates/testing-framework/Cargo.toml | 2 +- tools/cli/air-beautify/Cargo.toml | 14 -- tools/cli/{air-trace => air}/CHANGELOG.md | 0 tools/cli/{air-trace => air}/Cargo.toml | 18 +- tools/cli/{air-trace => air}/README.md | 52 +++-- .../src/main.rs => air/src/beautify/mod.rs} | 18 +- tools/cli/{air-trace => air}/src/main.rs | 20 +- tools/cli/air/src/trace/mod.rs | 19 ++ .../{air-trace/src => air/src/trace}/run.rs | 0 .../src => air/src/trace}/run/data/anomaly.rs | 2 +- .../src => air/src/trace}/run/data/mod.rs | 0 .../src => air/src/trace}/run/data/plain.rs | 4 +- .../src => air/src/trace}/run/native.rs | 0 .../src => air/src/trace}/run/runner.rs | 0 .../src => air/src/trace}/run/wasm.rs | 0 .../{air-trace/src => air/src/trace}/stats.rs | 0 .../src => air/src/trace}/stats/log_data.rs | 0 .../src => air/src/trace}/stats/report.rs | 6 +- .../{air-trace/src => air/src/trace}/utils.rs | 0 tools/cli/performance_metering/README.md | 2 +- .../performance_metering/bench.py | 2 +- .../performance_metering/run.py | 2 +- 41 files changed, 215 insertions(+), 200 deletions(-) delete mode 100644 tools/cli/air-beautify/Cargo.toml rename tools/cli/{air-trace => air}/CHANGELOG.md (100%) rename tools/cli/{air-trace => air}/Cargo.toml (66%) rename tools/cli/{air-trace => air}/README.md (69%) rename tools/cli/{air-beautify/src/main.rs => air/src/beautify/mod.rs} (87%) rename tools/cli/{air-trace => air}/src/main.rs (70%) create mode 100644 tools/cli/air/src/trace/mod.rs rename tools/cli/{air-trace/src => air/src/trace}/run.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/run/data/anomaly.rs (98%) rename tools/cli/{air-trace/src => air/src/trace}/run/data/mod.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/run/data/plain.rs (96%) rename tools/cli/{air-trace/src => air/src/trace}/run/native.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/run/runner.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/run/wasm.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/stats.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/stats/log_data.rs (100%) rename tools/cli/{air-trace/src => air/src/trace}/stats/report.rs (92%) rename tools/cli/{air-trace/src => air/src/trace}/utils.rs (100%) diff --git a/.github/release-please/config.json b/.github/release-please/config.json index 460345bd..c18e77ad 100644 --- a/.github/release-please/config.json +++ b/.github/release-please/config.json @@ -48,10 +48,7 @@ }, "crates/data-store": {}, "crates/testing-framework": {}, - "tools/cli/air-beautify": { - "component": "air-beautify" - }, - "tools/cli/air-trace": {}, + "tools/cli/aquavm-air-cli": {}, "tools/wasm/air-beautify-wasm": { "component": "air-beautify-wasm" } diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json index 39ce1fcc..a8e18629 100644 --- a/.github/release-please/manifest.json +++ b/.github/release-please/manifest.json @@ -14,7 +14,6 @@ "crates/beautifier": "0.1.1", "crates/data-store": "0.6.0", "crates/testing-framework": "0.1.5", - "tools/cli/air-beautify": "0.1.1", - "tools/cli/air-trace": "0.2.6", + "tools/cli/aquavm-air-cli": "0.2.6", "tools/wasm/air-beautify-wasm": "0.1.0" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6904faef..27960ba6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,8 +105,8 @@ jobs: - name: Run cargo check run: cargo check - - name: Check native air-trace - run: cargo check --package air-trace --no-default-features + - name: Check native aquavm-air-cli + run: cargo check --package aquavm-air-cli --no-default-features - name: Run cargo clippy run: cargo clippy -v diff --git a/Cargo.lock b/Cargo.lock index 491c1fe8..4f7349d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,63 +11,15 @@ dependencies = [ "memchr", ] -[[package]] -name = "air" -version = "0.37.0" -dependencies = [ - "air-execution-info-collector", - "air-interpreter-cid", - "air-interpreter-data", - "air-interpreter-interface", - "air-lambda-ast", - "air-lambda-parser", - "air-log-targets", - "air-parser", - "air-test-utils", - "air-testing-framework", - "air-trace-handler", - "air-utils", - "boolinator", - "concat-idents", - "criterion 0.3.6", - "csv", - "env_logger", - "fluence-app-service", - "fstrings", - "log", - "maplit", - "marine-rs-sdk", - "non-empty-vec", - "once_cell", - "polyplets", - "pretty_assertions 0.6.1", - "semver 1.0.17", - "serde", - "serde_json", - "strum", - "strum_macros", - "thiserror", - "tracing", -] - [[package]] name = "air-beautifier" version = "0.1.2" dependencies = [ - "air-parser", + "aquavm-air-parser", "itertools", "thiserror", ] -[[package]] -name = "air-beautify" -version = "0.1.2" -dependencies = [ - "air-beautifier", - "anyhow", - "clap 4.1.8", -] - [[package]] name = "air-beautify-wasm" version = "0.1.1" @@ -80,16 +32,16 @@ dependencies = [ name = "air-execution-info-collector" version = "0.7.3" dependencies = [ - "air-parser", + "aquavm-air-parser", ] [[package]] name = "air-interpreter" version = "0.37.0" dependencies = [ - "air", "air-interpreter-interface", "air-log-targets", + "aquavm-air", "log", "marine-rs-sdk", "serde", @@ -115,8 +67,8 @@ version = "0.6.3" dependencies = [ "air-interpreter-cid", "air-interpreter-interface", - "air-parser", "air-utils", + "aquavm-air-parser", "once_cell", "polyplets", "semver 1.0.17", @@ -166,36 +118,14 @@ dependencies = [ name = "air-log-targets" version = "0.1.0" -[[package]] -name = "air-parser" -version = "0.7.3" -dependencies = [ - "air-lambda-ast", - "air-lambda-parser", - "codespan", - "codespan-reporting", - "criterion 0.4.0", - "fstrings", - "itertools", - "lalrpop", - "lalrpop-util", - "multimap", - "non-empty-vec", - "regex", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "air-test-utils" version = "0.4.5" dependencies = [ - "air", "air-interpreter-cid", "air-interpreter-data", "air-interpreter-interface", + "aquavm-air", "avm-interface", "avm-server", "fstrings", @@ -212,8 +142,8 @@ dependencies = [ name = "air-testing-framework" version = "0.1.5" dependencies = [ - "air-parser", "air-test-utils", + "aquavm-air-parser", "itertools", "maplit", "nom 7.1.3", @@ -223,23 +153,6 @@ dependencies = [ "strum", ] -[[package]] -name = "air-trace" -version = "0.2.6" -dependencies = [ - "air", - "air-interpreter-interface", - "air-test-utils", - "anyhow", - "avm-data-store", - "avm-interface", - "clap 4.1.8", - "itertools", - "serde", - "serde_json", - "tracing-subscriber", -] - [[package]] name = "air-trace-handler" version = "0.1.2" @@ -248,7 +161,7 @@ dependencies = [ "air-interpreter-data", "air-interpreter-interface", "air-log-targets", - "air-parser", + "aquavm-air-parser", "bimap", "log", "polyplets", @@ -291,6 +204,85 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +[[package]] +name = "aquavm-air" +version = "0.37.0" +dependencies = [ + "air-execution-info-collector", + "air-interpreter-cid", + "air-interpreter-data", + "air-interpreter-interface", + "air-lambda-ast", + "air-lambda-parser", + "air-log-targets", + "air-test-utils", + "air-testing-framework", + "air-trace-handler", + "air-utils", + "aquavm-air-parser", + "boolinator", + "concat-idents", + "criterion 0.3.6", + "csv", + "env_logger", + "fluence-app-service", + "fstrings", + "log", + "maplit", + "marine-rs-sdk", + "non-empty-vec", + "once_cell", + "polyplets", + "pretty_assertions 0.6.1", + "semver 1.0.17", + "serde", + "serde_json", + "strum", + "strum_macros", + "thiserror", + "tracing", +] + +[[package]] +name = "aquavm-air-cli" +version = "0.2.6" +dependencies = [ + "air-beautifier", + "air-interpreter-interface", + "air-test-utils", + "anyhow", + "aquavm-air", + "avm-data-store", + "avm-interface", + "clap 4.1.8", + "itertools", + "serde", + "serde_json", + "tracing-subscriber", +] + +[[package]] +name = "aquavm-air-parser" +version = "0.7.3" +dependencies = [ + "air-lambda-ast", + "air-lambda-parser", + "codespan", + "codespan-reporting", + "criterion 0.4.0", + "fstrings", + "itertools", + "lalrpop", + "lalrpop-util", + "multimap", + "non-empty-vec", + "regex", + "serde", + "serde_json", + "thiserror", + "tracing", +] + [[package]] name = "arrayref" version = "0.3.6" diff --git a/Cargo.toml b/Cargo.toml index 1a6255fc..3b52506e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,7 @@ members = [ "crates/beautifier", "crates/data-store", "crates/testing-framework", - "tools/cli/air-beautify", - "tools/cli/air-trace", + "tools/cli/air", "tools/wasm/air-beautify-wasm", ] diff --git a/air-interpreter/Cargo.toml b/air-interpreter/Cargo.toml index c607c783..0762d6e4 100644 --- a/air-interpreter/Cargo.toml +++ b/air-interpreter/Cargo.toml @@ -18,7 +18,7 @@ name = "air_interpreter_server" path = "src/marine.rs" [dependencies] -air = { version = "0.37.0", path = "../air" } +aquavm-air = { version = "0.37.0", path = "../air" } air-interpreter-interface = { version = "0.12.1", path = "../crates/air-lib/interpreter-interface" } air-log-targets = { version = "0.1.0", path = "../crates/air-lib/log-targets" } diff --git a/air/Cargo.toml b/air/Cargo.toml index 212df61d..13e7dc7d 100644 --- a/air/Cargo.toml +++ b/air/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "air" +name = "aquavm-air" version = "0.37.0" description = "Interpreter of AIR scripts intended to coordinate request flow in the Fluence network" authors = ["Fluence Labs"] edition = "2018" repository = "https://github.com/fluencelabs/aquavm" -publish = false +documentation = "https://docs.rs/aquavm-air" keywords = ["fluence", "air", "webassembly", "programming-language"] categories = ["wasm"] @@ -15,7 +15,7 @@ path = "src/lib.rs" doctest = false [dependencies] -air-parser = { version = "0.7.2", path = "../crates/air-lib/air-parser" } +aquavm-air-parser = { version = "0.7.2", path = "../crates/air-lib/air-parser" } air-execution-info-collector = { version = "0.7.2", path = "../crates/air-lib/execution-info-collector" } air-interpreter-cid = { version = "0.2.0", path = "../crates/air-lib/interpreter-cid" } air-interpreter-data = { version = "0.6.2", path = "../crates/air-lib/interpreter-data" } diff --git a/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml index 7cfad50c..727861a4 100644 --- a/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/auth_module/Cargo.toml @@ -9,7 +9,7 @@ name = "auth_module" path = "src/main.rs" [dependencies] -air = { path = "../../../../../../../air" } +aquavm-air = { path = "../../../../../../../air" } marine-rs-sdk = "0.7.0" [workspace] diff --git a/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml index 31f044c8..8c13f555 100644 --- a/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml +++ b/air/tests/test_module/features/tetraplets/security_tetraplets/log_storage/Cargo.toml @@ -9,7 +9,7 @@ name = "log_storage" path = "src/main.rs" [dependencies] -air = { path = "../../../../../../../air" } +aquavm-air = { path = "../../../../../../../air" } marine-rs-sdk = "0.7.0" [workspace] diff --git a/air/tracing_benches.sh b/air/tracing_benches.sh index c5b70053..675ff05c 100755 --- a/air/tracing_benches.sh +++ b/air/tracing_benches.sh @@ -5,7 +5,7 @@ set -o pipefail -e # Its dependencies: # + jq utility # + compiled AquaVM WASM binary -# + installed air-trace +# + installed air function trace_len { jq '.trace | length' @@ -37,7 +37,7 @@ function error { function main { if [ "$#" \< 2 ]; then if [ x"$1" == x"--help" ]; then - error "usage: $0 (--all|big|long) (--all|merge|nomerge) [ air-trace run args ... ]" + error "usage: $0 (--all|big|long) (--all|merge|nomerge) [ air run args ... ]" else error "Provide at least two arguments: (--all|big|long) and (--all|merge|nomerge)" fi @@ -113,7 +113,7 @@ function main { echo >&1 echo "*** Running test ${tst}-${subt}..." >&1 eval "${script_cmd}" | \ - air-trace run "$@" --repeat 1 --plain \ + air run "$@" --repeat 1 --plain \ --prev-data "$prev_data_path" \ --data "$current_data_path" done diff --git a/crates/air-lib/air-parser/Cargo.toml b/crates/air-lib/air-parser/Cargo.toml index 78528aa4..bab381ff 100644 --- a/crates/air-lib/air-parser/Cargo.toml +++ b/crates/air-lib/air-parser/Cargo.toml @@ -1,14 +1,19 @@ [package] -name = "air-parser" +name = "aquavm-air-parser" description = "Parser of the AIR scripts in a form of string to AST" version = "0.7.3" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +documentation = "https://docs.rs/air-parser" +repository = "https://github.com/fluencelabs/aquavm" keywords = ["fluence", "air", "parser", "lalrpop"] categories = ["wasm"] +[lib] +name = "air_parser" +path = "src/lib.rs" + [build-dependencies] lalrpop = "0.19.8" diff --git a/crates/air-lib/execution-info-collector/Cargo.toml b/crates/air-lib/execution-info-collector/Cargo.toml index 3dbe2144..125912fd 100644 --- a/crates/air-lib/execution-info-collector/Cargo.toml +++ b/crates/air-lib/execution-info-collector/Cargo.toml @@ -5,7 +5,8 @@ description = "Implementation of AIR execution info collector" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-execution-info-collector" keywords = ["fluence", "air", "webassembly", "programming-language"] categories = ["wasm"] @@ -14,4 +15,4 @@ name = "air_execution_info_collector" path = "src/lib.rs" [dependencies] -air-parser = { path = "../air-parser" } +aquavm-air-parser = { path = "../air-parser" } diff --git a/crates/air-lib/interpreter-data/Cargo.toml b/crates/air-lib/interpreter-data/Cargo.toml index 488f93ca..64baee46 100644 --- a/crates/air-lib/interpreter-data/Cargo.toml +++ b/crates/air-lib/interpreter-data/Cargo.toml @@ -5,7 +5,8 @@ version = "0.6.3" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-interpreter-data" keywords = ["fluence", "air", "webassembly", "programming-language"] categories = ["wasm"] @@ -15,7 +16,7 @@ path = "src/lib.rs" [dependencies] air-utils = { version = "0.1.0", path = "../utils" } -air-parser = { version = "0.7.3", path = "../air-parser" } +aquavm-air-parser = { version = "0.7.3", path = "../air-parser" } air-interpreter-interface = { version = "0.12.1", path = "../interpreter-interface" } air-interpreter-cid = { version = "0.2.0", path = "../interpreter-cid" } polyplets = { version = "0.3.2", path = "../polyplets" } diff --git a/crates/air-lib/lambda/ast/Cargo.toml b/crates/air-lib/lambda/ast/Cargo.toml index 3c8630fc..8c9d22b6 100644 --- a/crates/air-lib/lambda/ast/Cargo.toml +++ b/crates/air-lib/lambda/ast/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-lambda-ast" keywords = ["fluence", "air", "lambda", "ast"] categories = ["wasm"] diff --git a/crates/air-lib/lambda/parser/Cargo.toml b/crates/air-lib/lambda/parser/Cargo.toml index 2cd1f90f..94b7696b 100644 --- a/crates/air-lib/lambda/parser/Cargo.toml +++ b/crates/air-lib/lambda/parser/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-lambda-parser" keywords = ["fluence", "air", "parser", "lalrpop"] categories = ["wasm"] diff --git a/crates/air-lib/log-targets/Cargo.toml b/crates/air-lib/log-targets/Cargo.toml index f1d7aed3..4e8b8161 100644 --- a/crates/air-lib/log-targets/Cargo.toml +++ b/crates/air-lib/log-targets/Cargo.toml @@ -5,7 +5,8 @@ description = "Definition of global consts used for logging" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-log-targets" keywords = ["fluence", "air", "webassembly", "programming-language"] categories = ["wasm"] diff --git a/crates/air-lib/test-utils/Cargo.toml b/crates/air-lib/test-utils/Cargo.toml index a2dca01a..cb1f4e72 100644 --- a/crates/air-lib/test-utils/Cargo.toml +++ b/crates/air-lib/test-utils/Cargo.toml @@ -5,7 +5,8 @@ description = "Test utils for the AIR interpreter" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-test-utils" keywords = ["fluence", "air", "webassembly", "security", "authorization"] categories = ["wasm"] @@ -14,7 +15,7 @@ name = "air_test_utils" path = "src/lib.rs" [dependencies] -air = { path = "../../../air" } +aquavm-air = { path = "../../../air" } air-interpreter-cid = { version = "0.2.0", path = "../interpreter-cid" } air-interpreter-data = { version = "0.6.3", path = "../interpreter-data" } air-interpreter-interface = { version = "0.12.1", path = "../interpreter-interface" } diff --git a/crates/air-lib/trace-handler/Cargo.toml b/crates/air-lib/trace-handler/Cargo.toml index 8232feb6..200ec635 100644 --- a/crates/air-lib/trace-handler/Cargo.toml +++ b/crates/air-lib/trace-handler/Cargo.toml @@ -18,7 +18,7 @@ air-interpreter-cid = { version = "0.2.0", path = "../interpreter-cid" } air-interpreter-data = { version = "0.6.3", path = "../interpreter-data" } air-interpreter-interface = { version = "0.12.1", path = "../interpreter-interface" } air-log-targets = { version = "0.1.0", path = "../log-targets" } -air-parser = { version = "0.7.3", path = "../air-parser" } +aquavm-air-parser = { version = "0.7.3", path = "../air-parser" } polyplets = { version = "0.3.2", path = "../polyplets" } bimap = "0.6.2" diff --git a/crates/beautifier/Cargo.toml b/crates/beautifier/Cargo.toml index 76a7ff31..c777f834 100644 --- a/crates/beautifier/Cargo.toml +++ b/crates/beautifier/Cargo.toml @@ -5,8 +5,8 @@ description = "AIR human-readable format transformer library" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" -repository = "https://github.com/fluencelabs/aquavm/tree/master/crates/beautifier" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/air-beautifier" keywords = ["fluence", "air", "beautifier"] [lib] @@ -14,6 +14,6 @@ name = "air_beautifier" path = "src/lib.rs" [dependencies] -air-parser = { version = "0.7.3", path = "../air-lib/air-parser" } +aquavm-air-parser = { version = "0.7.3", path = "../air-lib/air-parser" } itertools = "0.10.5" thiserror = "1.0.39" diff --git a/crates/testing-framework/Cargo.toml b/crates/testing-framework/Cargo.toml index 35968646..b3603276 100644 --- a/crates/testing-framework/Cargo.toml +++ b/crates/testing-framework/Cargo.toml @@ -15,7 +15,7 @@ path = "src/lib.rs" [dependencies] air-test-utils = { version = "0.4.5", path = "../air-lib/test-utils" } -air-parser = { version = "0.7.3", path = "../air-lib/air-parser" } +aquavm-air-parser = { version = "0.7.3", path = "../air-lib/air-parser" } itertools = "0.10.5" strum = { version="0.24.1", features=["derive"] } diff --git a/tools/cli/air-beautify/Cargo.toml b/tools/cli/air-beautify/Cargo.toml deleted file mode 100644 index 77394a30..00000000 --- a/tools/cli/air-beautify/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "air-beautify" -version = "0.1.2" -edition = "2021" -description = "AIR human-readable format transformer binary" -authors = ["Fluence Labs"] -license = "Apache-2.0" -publish = false -keywords = ["fluence", "air", "beautifier"] - -[dependencies] -air-beautifier = { version = "0.1.2", path = "../../../crates/beautifier" } -clap = { version = "4.1.8", features = ["derive"] } -anyhow = "1.0.69" diff --git a/tools/cli/air-trace/CHANGELOG.md b/tools/cli/air/CHANGELOG.md similarity index 100% rename from tools/cli/air-trace/CHANGELOG.md rename to tools/cli/air/CHANGELOG.md diff --git a/tools/cli/air-trace/Cargo.toml b/tools/cli/air/Cargo.toml similarity index 66% rename from tools/cli/air-trace/Cargo.toml rename to tools/cli/air/Cargo.toml index beea559a..c6350e0d 100644 --- a/tools/cli/air-trace/Cargo.toml +++ b/tools/cli/air/Cargo.toml @@ -1,19 +1,21 @@ [package] -name = "air-trace" +name = "aquavm-air-cli" version = "0.2.6" edition = "2021" -description = "AIR performance tracing tool" +description = "AIR execution and printing tool" authors = ["Fluence Labs"] license = "Apache-2.0" -publish = false +repository = "https://github.com/fluencelabs/aquavm" +documentation = "https://docs.rs/aquavm-air-cli" keywords = ["fluence", "air", "tracing"] [dependencies] -air = { version = "0.37.0", path = "../../../air" } -air-test-utils = { version = "0.4.5",path = "../../../crates/air-lib/test-utils", optional = true } -air-interpreter-interface = { version = "0.12.1", path = "../../../crates/air-lib/interpreter-interface", default-features = false } +aquavm-air = { version = "0.37.0", path = "../../../air" } +air-beautifier = { version = "0.1.2", path = "../../../crates/beautifier" } avm-data-store = { version = "0.6.0", path = "../../../crates/data-store" } avm-interface = { version = "0.28.2", path = "../../../avm/interface" } +air-interpreter-interface = { version = "0.12.1", path = "../../../crates/air-lib/interpreter-interface", default-features = false } +air-test-utils = { version = "0.4.4",path = "../../../crates/air-lib/test-utils", optional = true } anyhow = "1.0.69" clap = { version = "4.1.8", features = ["derive", "env"] } @@ -25,3 +27,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = [features] default = ["wasm"] wasm = ["air-test-utils"] + +[[bin]] +name = "air" +path = "src/main.rs" diff --git a/tools/cli/air-trace/README.md b/tools/cli/air/README.md similarity index 69% rename from tools/cli/air-trace/README.md rename to tools/cli/air/README.md index 4517b0c9..acfc7b2e 100644 --- a/tools/cli/air-trace/README.md +++ b/tools/cli/air/README.md @@ -1,8 +1,18 @@ -# The `air-trace` utility +# The `air` CLI utility -The main propose of this utility is to run AquaVM with data and analyze its performance. It has two subcommands: `run` and `stats`. +The `air` CLI utility is a helper tool for Aqua and AIR developers. It has three subcommands: `beautify`, `run` and `stats`. -## `air-trace run` +## `air beautify` + +Alias: `air b`. + +This subcommand reads an AIR script from standard input and prints it in human-readable Python-like representation. This representation cannot be executed and is intended to be read by mere mortals. + +It outputs to standard output or a file. + +## `air run` + +Alias: `air r`. Executes an AIR script with data in WASM AquaVM. It has two modes of parameter input: plain and anomaly. @@ -12,27 +22,29 @@ All common parameters are optional. Their position is before the mode selector + `--call-results PATH` parameter allows you to provide call results for current execution. + `--max-heap-size N` defines maximum heap size for WASM runtime. + `--interpreter PATH` option defines the AquaVM WASM binary to be executed. By default, it is "target/wasm32-wasi/release/air_interpreter_server.wasm", but you can define a global value with the `AIR_INTERPRETER_WASM_PATH` environment variable. The default presumes that the tool is run from the root of this repository. Feel free to use option or environment variable to run from any location. -+ with the `--json` option, tracing info is output (to stderr) in machine-readable JSON format. The output can be later processed with `air-trace stats` subcommand. ++ with the `--json` option, tracing info is output (to stderr) in machine-readable JSON format. The output can be later processed with `air stats` subcommand. + `--tracing-params` defines tracing logging levels for AquaVM. By default, it is equal to `info` and does trace the most high-level AquaVM constructions (data parsing, AIR script parsing, execution). With `debug` level it traces some individual commands, and with `trace` level it traces even more fine grained functionality, but it induce more overhead. + `--runner-tracing-params` defines tracing logging level for the runner. By default, it is equal to `warn`. The important option is `--native`. It runs the AquaVM as the native code that can be profiled with any native profiler. As input data deserialization and serialization time can be comparable to particle execution time, and short execution times provides less reliable results, one can use `--repeat N` option to repeat particle execution several times. Execution result is not printed in this case, so you may run `--repeat 1` to suppress it. -Run `air-trace run --help` to see all common parameters. +Run `air run --help` to see all common parameters. ### Plain mode In the `--plain` mode, the parameters like AIR script path, data path, previous data path and other particle fields can be provided in separate arguments, of which only `--data` is the required one (and AIR script is read from stdin by default). -Run `air-trace run --plain --help` to see all plain mode options. +Run `air run --plain --help` to see all plain mode options. ### Anomaly mode -In the anomaly mode, the only argument is a path to self-contained anomaly data file obtained from Anomaly Particle Detection System. +In the anomaly mode, the only argument is a path to self-contained anomaly data file obtained from `rust-peer`'s Anomaly Particle Detection System. -Run `air-trace run --anomaly --help` to see all anomaly mode options. +Run `air run --anomaly --help` to see all anomaly mode options. -## `air-trace stats` +## `air stats` -This subcommand allows to process JSON trace collected with `air-trace run --json`. It has two primary options: +Alias: `air s`. + +This subcommand allows to process JSON trace collected with `air run --json`. It has two primary options: + `--pretty` outputs JSON trace in human readable format. + `--stats` outputs execution summary. @@ -41,7 +53,7 @@ By default, both options are effective. The `--sort-stats-by-duration` flag sorts spans by time, not by name, in the report. -Please, note that currently tracing outputs to stdout, and execution result is also printed to stdout. You may suppress printing the result with `air-trace run --repeat 1` option. +Please, note that currently tracing outputs to stdout, and execution result is also printed to stdout. You may suppress printing the result with `air run --repeat 1` option. ## Known limitations @@ -49,7 +61,7 @@ Please, note that currently tracing outputs to stdout, and execution result is a ## Installation -### AIR interpreter server +### AIR interpreter You need the `marine` tool installed. Run following command in the repo's root directory: @@ -57,23 +69,23 @@ You need the `marine` tool installed. Run following command in the repo's root marine build --features marine --package air-interpreter --release ``` -It will output the binary to default `--interpreter` path at `target/wasm32-wasi/release/air_interpreter_server.wasm`; if you wish to run the `air-trace` from arbitrary place, store the `air_interpreter_server.wasm` binary in a cool dry place and set `AIR_INTERPRETER_WASM_PATH` variable. +It will output the binary to default `--interpreter` path at `target/wasm32-wasi/release/air_interpreter_server.wasm`; if you wish to run the `air` from arbitrary place, store the `air_interpreter_server.wasm` binary in a cool dry place and set `AIR_INTERPRETER_WASM_PATH` variable. -## `air-trace` binary +## `air` binary You need to have Rust toolchain and its `cargo` utility installed. Run this command from the repo's root directory: ``` sh -cargo install --path tools/cli/air-trace +cargo install --path tools/cli/air ``` -## `air-trace` native build +## `air` CLI native build -You can have fully native or WASM `air-trace` build with the following commands: +You can have fully native or pure WASM `air` CLI build with the following commands: ``` sh -cargo build --no-default-features --release -p air-trace -cargo build --no-default-features --release -p air-trace --target wasm32-wasi +cargo build --no-default-features --release -p aquavm-air-cli +cargo build --no-default-features --release -p aquavm-air-cli --target wasm32-wasi ``` -This build doesn't need the AIR interpreter server binary. +This build doesn't need the AIR interpreter WASM binary. diff --git a/tools/cli/air-beautify/src/main.rs b/tools/cli/air/src/beautify/mod.rs similarity index 87% rename from tools/cli/air-beautify/src/main.rs rename to tools/cli/air/src/beautify/mod.rs index 1adb7e2f..50b6ee8e 100644 --- a/tools/cli/air-beautify/src/main.rs +++ b/tools/cli/air/src/beautify/mod.rs @@ -14,18 +14,6 @@ * limitations under the License. */ -#![forbid(unsafe_code)] -#![warn(rust_2018_idioms)] -#![deny( - dead_code, - nonstandard_style, - unused_imports, - unused_mut, - unused_variables, - unused_unsafe, - unreachable_patterns -)] - use air_beautifier::Beautifier; use anyhow::{Context, Result}; use clap::Parser; @@ -33,7 +21,8 @@ use clap::Parser; use std::{io, path::PathBuf}; #[derive(Parser)] -struct Args { +#[clap(about = "Pretty-print an AIR script to Python-like representation")] +pub(crate) struct Args { #[clap(short, long, default_value_t = air_beautifier::DEFAULT_INDENT_STEP)] indent_step: usize, #[clap(short, long)] @@ -72,8 +61,7 @@ fn build_output(args: &Args) -> Result> { Ok(output) } -fn main() -> Result<()> { - let args = Args::parse(); +pub(crate) fn beautify(args: Args) -> Result<()> { let air_script = read_script(&args).context("failed to read the input")?; let output = build_output(&args).context("failed to open the output")?; diff --git a/tools/cli/air-trace/src/main.rs b/tools/cli/air/src/main.rs similarity index 70% rename from tools/cli/air-trace/src/main.rs rename to tools/cli/air/src/main.rs index 2235cfb0..ad3ebe96 100644 --- a/tools/cli/air-trace/src/main.rs +++ b/tools/cli/air/src/main.rs @@ -1,5 +1,5 @@ /* - * Copyright 2022 Fluence Labs Limited + * Copyright 2023 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,8 @@ unreachable_patterns )] -mod run; -mod stats; -mod utils; +mod beautify; +mod trace; use clap::Parser; @@ -41,14 +40,19 @@ struct Cli { #[derive(clap::Subcommand)] #[allow(clippy::large_enum_variant)] enum Subcommand { - Run(crate::run::Args), - Stats(crate::stats::Args), + #[clap(alias = "b")] + Beautify(self::beautify::Args), + #[clap(alias = "r")] + Run(self::trace::run::Args), + #[clap(alias = "s")] + Stats(self::trace::stats::Args), } fn main() -> anyhow::Result<()> { let args = Cli::parse(); match args.subcommand { - Subcommand::Run(args) => crate::run::run(args), - Subcommand::Stats(args) => crate::stats::stats(args), + Subcommand::Run(args) => self::trace::run::run(args), + Subcommand::Stats(args) => self::trace::stats::stats(args), + Subcommand::Beautify(args) => self::beautify::beautify(args), } } diff --git a/tools/cli/air/src/trace/mod.rs b/tools/cli/air/src/trace/mod.rs new file mode 100644 index 00000000..145b9ab3 --- /dev/null +++ b/tools/cli/air/src/trace/mod.rs @@ -0,0 +1,19 @@ +/* + * Copyright 2023 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +pub(crate) mod run; +pub(crate) mod stats; +mod utils; diff --git a/tools/cli/air-trace/src/run.rs b/tools/cli/air/src/trace/run.rs similarity index 100% rename from tools/cli/air-trace/src/run.rs rename to tools/cli/air/src/trace/run.rs diff --git a/tools/cli/air-trace/src/run/data/anomaly.rs b/tools/cli/air/src/trace/run/data/anomaly.rs similarity index 98% rename from tools/cli/air-trace/src/run/data/anomaly.rs rename to tools/cli/air/src/trace/run/data/anomaly.rs index 54e538ec..b29ff49f 100644 --- a/tools/cli/air-trace/src/run/data/anomaly.rs +++ b/tools/cli/air/src/trace/run/data/anomaly.rs @@ -14,8 +14,8 @@ * limitations under the License. */ +use super::super::load_data; use super::ExecutionData; -use crate::run::load_data; use avm_data_store::AnomalyData; use avm_interface::ParticleParameters; diff --git a/tools/cli/air-trace/src/run/data/mod.rs b/tools/cli/air/src/trace/run/data/mod.rs similarity index 100% rename from tools/cli/air-trace/src/run/data/mod.rs rename to tools/cli/air/src/trace/run/data/mod.rs diff --git a/tools/cli/air-trace/src/run/data/plain.rs b/tools/cli/air/src/trace/run/data/plain.rs similarity index 96% rename from tools/cli/air-trace/src/run/data/plain.rs rename to tools/cli/air/src/trace/run/data/plain.rs index b4a2d641..fc4b8405 100644 --- a/tools/cli/air-trace/src/run/data/plain.rs +++ b/tools/cli/air/src/trace/run/data/plain.rs @@ -14,8 +14,8 @@ * limitations under the License. */ +use super::super::super::utils::unix_timestamp_now; use super::ExecutionData; -use crate::utils::unix_timestamp_now; use avm_interface::ParticleParameters; use anyhow::Context; @@ -44,7 +44,7 @@ pub(crate) struct PlainDataArgs { } pub(crate) fn load(args: &PlainDataArgs) -> anyhow::Result> { - use crate::run::load_data; + use super::super::load_data; let air_script = read_air_script(args.air_script_path.as_deref()).context("failed to read AIR script")?; diff --git a/tools/cli/air-trace/src/run/native.rs b/tools/cli/air/src/trace/run/native.rs similarity index 100% rename from tools/cli/air-trace/src/run/native.rs rename to tools/cli/air/src/trace/run/native.rs diff --git a/tools/cli/air-trace/src/run/runner.rs b/tools/cli/air/src/trace/run/runner.rs similarity index 100% rename from tools/cli/air-trace/src/run/runner.rs rename to tools/cli/air/src/trace/run/runner.rs diff --git a/tools/cli/air-trace/src/run/wasm.rs b/tools/cli/air/src/trace/run/wasm.rs similarity index 100% rename from tools/cli/air-trace/src/run/wasm.rs rename to tools/cli/air/src/trace/run/wasm.rs diff --git a/tools/cli/air-trace/src/stats.rs b/tools/cli/air/src/trace/stats.rs similarity index 100% rename from tools/cli/air-trace/src/stats.rs rename to tools/cli/air/src/trace/stats.rs diff --git a/tools/cli/air-trace/src/stats/log_data.rs b/tools/cli/air/src/trace/stats/log_data.rs similarity index 100% rename from tools/cli/air-trace/src/stats/log_data.rs rename to tools/cli/air/src/trace/stats/log_data.rs diff --git a/tools/cli/air-trace/src/stats/report.rs b/tools/cli/air/src/trace/stats/report.rs similarity index 92% rename from tools/cli/air-trace/src/stats/report.rs rename to tools/cli/air/src/trace/stats/report.rs index 6e99f730..db578629 100644 --- a/tools/cli/air-trace/src/stats/report.rs +++ b/tools/cli/air/src/trace/stats/report.rs @@ -14,8 +14,10 @@ * limitations under the License. */ -use super::log_data::{LogKey, LogRecord, Message}; -use crate::utils::parse_tracing_duration; +use super::super::utils::parse_tracing_duration; +use super::log_data::LogKey; +use super::log_data::LogRecord; +use super::log_data::Message; use std::{collections::HashMap, time::Duration}; diff --git a/tools/cli/air-trace/src/utils.rs b/tools/cli/air/src/trace/utils.rs similarity index 100% rename from tools/cli/air-trace/src/utils.rs rename to tools/cli/air/src/trace/utils.rs diff --git a/tools/cli/performance_metering/README.md b/tools/cli/performance_metering/README.md index d4c5d0e1..a76588ab 100644 --- a/tools/cli/performance_metering/README.md +++ b/tools/cli/performance_metering/README.md @@ -2,7 +2,7 @@ Execute an AquaVM special benchmarking suite and recort results with some meta information to `benches/PERFORMANCE.json` database. -This script is intended to be run from the project root. It uses the `air-trace` through `cargo`, without installation. +This script is intended to be run from the project root. It uses the `air` through `cargo`, without installation. # Installation diff --git a/tools/cli/performance_metering/performance_metering/bench.py b/tools/cli/performance_metering/performance_metering/bench.py index fc088362..51c3ab25 100644 --- a/tools/cli/performance_metering/performance_metering/bench.py +++ b/tools/cli/performance_metering/performance_metering/bench.py @@ -76,7 +76,7 @@ class Bench: "cargo", "run", "--quiet", "--release", - "--package", "air-trace", + "--package", "aquavm-air-cli", "--", "run", "--json", diff --git a/tools/cli/performance_metering/performance_metering/run.py b/tools/cli/performance_metering/performance_metering/run.py index 2a7a8453..f28ab8b2 100644 --- a/tools/cli/performance_metering/performance_metering/run.py +++ b/tools/cli/performance_metering/performance_metering/run.py @@ -42,7 +42,7 @@ def _prepare(args): ]) logger.info("Build air-trace...") subprocess.check_call([ - "cargo", "build", "--release", "--package", "air-trace", + "cargo", "build", "--release", "--package", "aquavm-air-cli", ])