From dc5722d5bf0a5b4d25e680504337f31a66460903 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:28:11 +0100 Subject: [PATCH 01/15] Move mithril build-script/doc/doc-derive/persistence to an internal folder --- .../mithril-build-script}/.gitignore | 0 .../mithril-build-script}/Cargo.toml | 0 {mithril-build-script => internal/mithril-build-script}/README.md | 0 .../mithril-build-script}/src/fake_aggregator.rs | 0 .../mithril-build-script}/src/lib.rs | 0 {mithril-doc-derive => internal/mithril-doc-derive}/Cargo.toml | 0 {mithril-doc-derive => internal/mithril-doc-derive}/src/doc.rs | 0 {mithril-doc-derive => internal/mithril-doc-derive}/src/lib.rs | 0 {mithril-doc => internal/mithril-doc}/Cargo.toml | 0 {mithril-doc => internal/mithril-doc}/src/extract_clap_info.rs | 0 {mithril-doc => internal/mithril-doc}/src/lib.rs | 0 {mithril-doc => internal/mithril-doc}/src/markdown_formatter.rs | 0 {mithril-doc => internal/mithril-doc}/src/test_doc_macro.rs | 0 {mithril-persistence => internal/mithril-persistence}/.gitignore | 0 {mithril-persistence => internal/mithril-persistence}/Cargo.toml | 0 {mithril-persistence => internal/mithril-persistence}/Makefile | 0 {mithril-persistence => internal/mithril-persistence}/README.md | 0 .../mithril-persistence}/src/database/db_version.rs | 0 .../mithril-persistence}/src/database/mod.rs | 0 .../mithril-persistence}/src/database/signed_entity_hydrator.rs | 0 .../mithril-persistence}/src/database/version_checker.rs | 0 {mithril-persistence => internal/mithril-persistence}/src/lib.rs | 0 .../mithril-persistence}/src/sqlite/condition.rs | 0 .../mithril-persistence}/src/sqlite/cursor.rs | 0 .../mithril-persistence}/src/sqlite/entity.rs | 0 .../mithril-persistence}/src/sqlite/mod.rs | 0 .../mithril-persistence}/src/sqlite/projection.rs | 0 .../mithril-persistence}/src/sqlite/provider.rs | 0 .../mithril-persistence}/src/sqlite/source_alias.rs | 0 .../mithril-persistence}/src/store/adapter/dumb_adapter.rs | 0 .../mithril-persistence}/src/store/adapter/fail_adapter.rs | 0 .../mithril-persistence}/src/store/adapter/memory_adapter.rs | 0 .../mithril-persistence}/src/store/adapter/mod.rs | 0 .../mithril-persistence}/src/store/adapter/sqlite_adapter.rs | 0 .../mithril-persistence}/src/store/adapter/store_adapter.rs | 0 .../mithril-persistence}/src/store/mod.rs | 0 .../mithril-persistence}/src/store/stake_store.rs | 0 .../mithril-persistence}/src/store/store_pruner.rs | 0 38 files changed, 0 insertions(+), 0 deletions(-) rename {mithril-build-script => internal/mithril-build-script}/.gitignore (100%) rename {mithril-build-script => internal/mithril-build-script}/Cargo.toml (100%) rename {mithril-build-script => internal/mithril-build-script}/README.md (100%) rename {mithril-build-script => internal/mithril-build-script}/src/fake_aggregator.rs (100%) rename {mithril-build-script => internal/mithril-build-script}/src/lib.rs (100%) rename {mithril-doc-derive => internal/mithril-doc-derive}/Cargo.toml (100%) rename {mithril-doc-derive => internal/mithril-doc-derive}/src/doc.rs (100%) rename {mithril-doc-derive => internal/mithril-doc-derive}/src/lib.rs (100%) rename {mithril-doc => internal/mithril-doc}/Cargo.toml (100%) rename {mithril-doc => internal/mithril-doc}/src/extract_clap_info.rs (100%) rename {mithril-doc => internal/mithril-doc}/src/lib.rs (100%) rename {mithril-doc => internal/mithril-doc}/src/markdown_formatter.rs (100%) rename {mithril-doc => internal/mithril-doc}/src/test_doc_macro.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/.gitignore (100%) rename {mithril-persistence => internal/mithril-persistence}/Cargo.toml (100%) rename {mithril-persistence => internal/mithril-persistence}/Makefile (100%) rename {mithril-persistence => internal/mithril-persistence}/README.md (100%) rename {mithril-persistence => internal/mithril-persistence}/src/database/db_version.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/database/mod.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/database/signed_entity_hydrator.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/database/version_checker.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/lib.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/condition.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/cursor.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/entity.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/mod.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/projection.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/provider.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/sqlite/source_alias.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/dumb_adapter.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/fail_adapter.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/memory_adapter.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/mod.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/sqlite_adapter.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/adapter/store_adapter.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/mod.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/stake_store.rs (100%) rename {mithril-persistence => internal/mithril-persistence}/src/store/store_pruner.rs (100%) diff --git a/mithril-build-script/.gitignore b/internal/mithril-build-script/.gitignore similarity index 100% rename from mithril-build-script/.gitignore rename to internal/mithril-build-script/.gitignore diff --git a/mithril-build-script/Cargo.toml b/internal/mithril-build-script/Cargo.toml similarity index 100% rename from mithril-build-script/Cargo.toml rename to internal/mithril-build-script/Cargo.toml diff --git a/mithril-build-script/README.md b/internal/mithril-build-script/README.md similarity index 100% rename from mithril-build-script/README.md rename to internal/mithril-build-script/README.md diff --git a/mithril-build-script/src/fake_aggregator.rs b/internal/mithril-build-script/src/fake_aggregator.rs similarity index 100% rename from mithril-build-script/src/fake_aggregator.rs rename to internal/mithril-build-script/src/fake_aggregator.rs diff --git a/mithril-build-script/src/lib.rs b/internal/mithril-build-script/src/lib.rs similarity index 100% rename from mithril-build-script/src/lib.rs rename to internal/mithril-build-script/src/lib.rs diff --git a/mithril-doc-derive/Cargo.toml b/internal/mithril-doc-derive/Cargo.toml similarity index 100% rename from mithril-doc-derive/Cargo.toml rename to internal/mithril-doc-derive/Cargo.toml diff --git a/mithril-doc-derive/src/doc.rs b/internal/mithril-doc-derive/src/doc.rs similarity index 100% rename from mithril-doc-derive/src/doc.rs rename to internal/mithril-doc-derive/src/doc.rs diff --git a/mithril-doc-derive/src/lib.rs b/internal/mithril-doc-derive/src/lib.rs similarity index 100% rename from mithril-doc-derive/src/lib.rs rename to internal/mithril-doc-derive/src/lib.rs diff --git a/mithril-doc/Cargo.toml b/internal/mithril-doc/Cargo.toml similarity index 100% rename from mithril-doc/Cargo.toml rename to internal/mithril-doc/Cargo.toml diff --git a/mithril-doc/src/extract_clap_info.rs b/internal/mithril-doc/src/extract_clap_info.rs similarity index 100% rename from mithril-doc/src/extract_clap_info.rs rename to internal/mithril-doc/src/extract_clap_info.rs diff --git a/mithril-doc/src/lib.rs b/internal/mithril-doc/src/lib.rs similarity index 100% rename from mithril-doc/src/lib.rs rename to internal/mithril-doc/src/lib.rs diff --git a/mithril-doc/src/markdown_formatter.rs b/internal/mithril-doc/src/markdown_formatter.rs similarity index 100% rename from mithril-doc/src/markdown_formatter.rs rename to internal/mithril-doc/src/markdown_formatter.rs diff --git a/mithril-doc/src/test_doc_macro.rs b/internal/mithril-doc/src/test_doc_macro.rs similarity index 100% rename from mithril-doc/src/test_doc_macro.rs rename to internal/mithril-doc/src/test_doc_macro.rs diff --git a/mithril-persistence/.gitignore b/internal/mithril-persistence/.gitignore similarity index 100% rename from mithril-persistence/.gitignore rename to internal/mithril-persistence/.gitignore diff --git a/mithril-persistence/Cargo.toml b/internal/mithril-persistence/Cargo.toml similarity index 100% rename from mithril-persistence/Cargo.toml rename to internal/mithril-persistence/Cargo.toml diff --git a/mithril-persistence/Makefile b/internal/mithril-persistence/Makefile similarity index 100% rename from mithril-persistence/Makefile rename to internal/mithril-persistence/Makefile diff --git a/mithril-persistence/README.md b/internal/mithril-persistence/README.md similarity index 100% rename from mithril-persistence/README.md rename to internal/mithril-persistence/README.md diff --git a/mithril-persistence/src/database/db_version.rs b/internal/mithril-persistence/src/database/db_version.rs similarity index 100% rename from mithril-persistence/src/database/db_version.rs rename to internal/mithril-persistence/src/database/db_version.rs diff --git a/mithril-persistence/src/database/mod.rs b/internal/mithril-persistence/src/database/mod.rs similarity index 100% rename from mithril-persistence/src/database/mod.rs rename to internal/mithril-persistence/src/database/mod.rs diff --git a/mithril-persistence/src/database/signed_entity_hydrator.rs b/internal/mithril-persistence/src/database/signed_entity_hydrator.rs similarity index 100% rename from mithril-persistence/src/database/signed_entity_hydrator.rs rename to internal/mithril-persistence/src/database/signed_entity_hydrator.rs diff --git a/mithril-persistence/src/database/version_checker.rs b/internal/mithril-persistence/src/database/version_checker.rs similarity index 100% rename from mithril-persistence/src/database/version_checker.rs rename to internal/mithril-persistence/src/database/version_checker.rs diff --git a/mithril-persistence/src/lib.rs b/internal/mithril-persistence/src/lib.rs similarity index 100% rename from mithril-persistence/src/lib.rs rename to internal/mithril-persistence/src/lib.rs diff --git a/mithril-persistence/src/sqlite/condition.rs b/internal/mithril-persistence/src/sqlite/condition.rs similarity index 100% rename from mithril-persistence/src/sqlite/condition.rs rename to internal/mithril-persistence/src/sqlite/condition.rs diff --git a/mithril-persistence/src/sqlite/cursor.rs b/internal/mithril-persistence/src/sqlite/cursor.rs similarity index 100% rename from mithril-persistence/src/sqlite/cursor.rs rename to internal/mithril-persistence/src/sqlite/cursor.rs diff --git a/mithril-persistence/src/sqlite/entity.rs b/internal/mithril-persistence/src/sqlite/entity.rs similarity index 100% rename from mithril-persistence/src/sqlite/entity.rs rename to internal/mithril-persistence/src/sqlite/entity.rs diff --git a/mithril-persistence/src/sqlite/mod.rs b/internal/mithril-persistence/src/sqlite/mod.rs similarity index 100% rename from mithril-persistence/src/sqlite/mod.rs rename to internal/mithril-persistence/src/sqlite/mod.rs diff --git a/mithril-persistence/src/sqlite/projection.rs b/internal/mithril-persistence/src/sqlite/projection.rs similarity index 100% rename from mithril-persistence/src/sqlite/projection.rs rename to internal/mithril-persistence/src/sqlite/projection.rs diff --git a/mithril-persistence/src/sqlite/provider.rs b/internal/mithril-persistence/src/sqlite/provider.rs similarity index 100% rename from mithril-persistence/src/sqlite/provider.rs rename to internal/mithril-persistence/src/sqlite/provider.rs diff --git a/mithril-persistence/src/sqlite/source_alias.rs b/internal/mithril-persistence/src/sqlite/source_alias.rs similarity index 100% rename from mithril-persistence/src/sqlite/source_alias.rs rename to internal/mithril-persistence/src/sqlite/source_alias.rs diff --git a/mithril-persistence/src/store/adapter/dumb_adapter.rs b/internal/mithril-persistence/src/store/adapter/dumb_adapter.rs similarity index 100% rename from mithril-persistence/src/store/adapter/dumb_adapter.rs rename to internal/mithril-persistence/src/store/adapter/dumb_adapter.rs diff --git a/mithril-persistence/src/store/adapter/fail_adapter.rs b/internal/mithril-persistence/src/store/adapter/fail_adapter.rs similarity index 100% rename from mithril-persistence/src/store/adapter/fail_adapter.rs rename to internal/mithril-persistence/src/store/adapter/fail_adapter.rs diff --git a/mithril-persistence/src/store/adapter/memory_adapter.rs b/internal/mithril-persistence/src/store/adapter/memory_adapter.rs similarity index 100% rename from mithril-persistence/src/store/adapter/memory_adapter.rs rename to internal/mithril-persistence/src/store/adapter/memory_adapter.rs diff --git a/mithril-persistence/src/store/adapter/mod.rs b/internal/mithril-persistence/src/store/adapter/mod.rs similarity index 100% rename from mithril-persistence/src/store/adapter/mod.rs rename to internal/mithril-persistence/src/store/adapter/mod.rs diff --git a/mithril-persistence/src/store/adapter/sqlite_adapter.rs b/internal/mithril-persistence/src/store/adapter/sqlite_adapter.rs similarity index 100% rename from mithril-persistence/src/store/adapter/sqlite_adapter.rs rename to internal/mithril-persistence/src/store/adapter/sqlite_adapter.rs diff --git a/mithril-persistence/src/store/adapter/store_adapter.rs b/internal/mithril-persistence/src/store/adapter/store_adapter.rs similarity index 100% rename from mithril-persistence/src/store/adapter/store_adapter.rs rename to internal/mithril-persistence/src/store/adapter/store_adapter.rs diff --git a/mithril-persistence/src/store/mod.rs b/internal/mithril-persistence/src/store/mod.rs similarity index 100% rename from mithril-persistence/src/store/mod.rs rename to internal/mithril-persistence/src/store/mod.rs diff --git a/mithril-persistence/src/store/stake_store.rs b/internal/mithril-persistence/src/store/stake_store.rs similarity index 100% rename from mithril-persistence/src/store/stake_store.rs rename to internal/mithril-persistence/src/store/stake_store.rs diff --git a/mithril-persistence/src/store/store_pruner.rs b/internal/mithril-persistence/src/store/store_pruner.rs similarity index 100% rename from mithril-persistence/src/store/store_pruner.rs rename to internal/mithril-persistence/src/store/store_pruner.rs From ae81baf36fb3f85ce25b629de1ef4fdffe19882e Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:48:28 +0100 Subject: [PATCH 02/15] Update `Cargo.toml`s for the crates moved to the `internal` folder --- Cargo.toml | 8 ++++---- demo/protocol-demo/Cargo.toml | 2 +- internal/mithril-persistence/Cargo.toml | 4 ++-- mithril-aggregator/Cargo.toml | 4 ++-- mithril-client-cli/Cargo.toml | 2 +- mithril-client-wasm/Cargo.toml | 2 +- mithril-relay/Cargo.toml | 2 +- mithril-signer/Cargo.toml | 4 ++-- mithril-test-lab/mithril-aggregator-fake/Cargo.toml | 2 +- mithril-test-lab/mithril-end-to-end/Cargo.toml | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5bb1fc21b39..dcbfc717d57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,15 +7,15 @@ members = [ "examples/client-cardano-transaction", "examples/client-mithril-stake-distribution", "examples/client-snapshot", + "internal/mithril-build-script", + "internal/mithril-doc", + "internal/mithril-doc-derive", + "internal/mithril-persistence", "mithril-aggregator", - "mithril-build-script", "mithril-client", "mithril-client-cli", "mithril-client-wasm", "mithril-common", - "mithril-doc", - "mithril-doc-derive", - "mithril-persistence", "mithril-relay", "mithril-signer", "mithril-stm", diff --git a/demo/protocol-demo/Cargo.toml b/demo/protocol-demo/Cargo.toml index c057994fe7b..f0aa347f682 100644 --- a/demo/protocol-demo/Cargo.toml +++ b/demo/protocol-demo/Cargo.toml @@ -15,7 +15,7 @@ clap = { version = "4.4.18", features = ["derive"] } hex = "0.4.3" log = "0.4.20" mithril-common = { path = "../../mithril-common", features = ["fs"] } -mithril-doc = { path = "../../mithril-doc" } +mithril-doc = { path = "../../internal/mithril-doc" } rand_chacha = "0.3.1" rand_core = "0.6.4" serde = { version = "1.0.196", features = ["derive"] } diff --git a/internal/mithril-persistence/Cargo.toml b/internal/mithril-persistence/Cargo.toml index 8871f168a26..3f61ed972e7 100644 --- a/internal/mithril-persistence/Cargo.toml +++ b/internal/mithril-persistence/Cargo.toml @@ -16,7 +16,7 @@ anyhow = "1.0.79" async-trait = "0.1.77" chrono = { version = "0.4.33", features = ["serde"] } hex = "0.4.3" -mithril-common = { path = "../mithril-common" } +mithril-common = { path = "../../mithril-common" } semver = "1.0.21" serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" @@ -27,7 +27,7 @@ thiserror = "1.0.56" tokio = { version = "1.35.1", features = ["sync"] } [dev-dependencies] -mithril-common = { path = "../mithril-common", features = ["test_tools"] } +mithril-common = { path = "../../mithril-common", features = ["test_tools"] } mockall = "0.12.1" slog-async = "2.8.0" slog-scope = "4.4.0" diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index eb5f107f5a1..09e2c37706c 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -19,8 +19,8 @@ config = "0.13.4" flate2 = "1.0.28" hex = "0.4.3" mithril-common = { path = "../mithril-common", features = ["full"] } -mithril-doc = { path = "../mithril-doc" } -mithril-persistence = { path = "../mithril-persistence" } +mithril-doc = { path = "../internal/mithril-doc" } +mithril-persistence = { path = "../internal/mithril-persistence" } openssl = { version = "0.10.63", features = ["vendored"], optional = true } openssl-probe = { version = "0.1.5", optional = true } reqwest = { version = "0.11.23", features = ["json"] } diff --git a/mithril-client-cli/Cargo.toml b/mithril-client-cli/Cargo.toml index c2c8005b0f9..3f9357d4c5c 100644 --- a/mithril-client-cli/Cargo.toml +++ b/mithril-client-cli/Cargo.toml @@ -33,7 +33,7 @@ futures = "0.3.28" human_bytes = { version = "0.4.3", features = ["fast"] } indicatif = { version = "0.17.7", features = ["tokio"] } mithril-client = { path = "../mithril-client", features = ["fs", "unstable"] } -mithril-doc = { path = "../mithril-doc" } +mithril-doc = { path = "../internal/mithril-doc" } openssl = { version = "0.10.63", features = ["vendored"], optional = true } openssl-probe = { version = "0.1.5", optional = true } serde = { version = "1.0.196", features = ["derive"] } diff --git a/mithril-client-wasm/Cargo.toml b/mithril-client-wasm/Cargo.toml index d0d230cc220..c43cafde7fb 100644 --- a/mithril-client-wasm/Cargo.toml +++ b/mithril-client-wasm/Cargo.toml @@ -26,7 +26,7 @@ web-sys = { version = "0.3.67", features = ["BroadcastChannel"] } wasm-bindgen-test = "0.3.40" [build-dependencies] -mithril-build-script = { path = "../mithril-build-script" } +mithril-build-script = { path = "../internal/mithril-build-script" } [features] # Include nothing by default diff --git a/mithril-relay/Cargo.toml b/mithril-relay/Cargo.toml index deeeae74181..a294206f413 100644 --- a/mithril-relay/Cargo.toml +++ b/mithril-relay/Cargo.toml @@ -28,7 +28,7 @@ libp2p = { version = "0.53.2", features = [ "yamux", ] } mithril-common = { path = "../mithril-common", features = ["full"] } -mithril-doc = { path = "../mithril-doc" } +mithril-doc = { path = "../internal/mithril-doc" } reqwest = { version = "0.11.23", features = ["json"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" diff --git a/mithril-signer/Cargo.toml b/mithril-signer/Cargo.toml index a80e894bd06..0686ce3c3ad 100644 --- a/mithril-signer/Cargo.toml +++ b/mithril-signer/Cargo.toml @@ -16,8 +16,8 @@ clap = { version = "4.4.18", features = ["derive", "env"] } config = "0.13.4" hex = "0.4.3" mithril-common = { path = "../mithril-common", features = ["full"] } -mithril-doc = { path = "../mithril-doc" } -mithril-persistence = { path = "../mithril-persistence" } +mithril-doc = { path = "../internal/mithril-doc" } +mithril-persistence = { path = "../internal/mithril-persistence" } openssl = { version = "0.10.63", features = ["vendored"], optional = true } openssl-probe = { version = "0.1.5", optional = true } rand_chacha = "0.3.1" diff --git a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml index 5e6d2e716de..a6e339e9a8f 100644 --- a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml +++ b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml @@ -33,4 +33,4 @@ reqwest = "0.11.23" warp = "0.3.6" [build-dependencies] -mithril-build-script = { path = "../../mithril-build-script" } +mithril-build-script = { path = "../../internal/mithril-build-script" } diff --git a/mithril-test-lab/mithril-end-to-end/Cargo.toml b/mithril-test-lab/mithril-end-to-end/Cargo.toml index 281776135ba..dcb1bf7a487 100644 --- a/mithril-test-lab/mithril-end-to-end/Cargo.toml +++ b/mithril-test-lab/mithril-end-to-end/Cargo.toml @@ -23,7 +23,7 @@ glob = "0.3.1" hex = "0.4.3" indicatif = { version = "0.17.7", features = ["tokio"] } mithril-common = { path = "../../mithril-common", features = ["full"] } -mithril-doc = { path = "../../mithril-doc" } +mithril-doc = { path = "../../internal/mithril-doc" } reqwest = { version = "0.11.23", features = ["json"] } serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" From 2f3f446399056cf84209bc36b848fe1901a6c92d Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:03:09 +0100 Subject: [PATCH 03/15] Update main Makefile & add Makefile for all internal crates --- Makefile | 4 +++- internal/mithril-build-script/Makefile | 19 +++++++++++++++++++ internal/mithril-doc-derive/Makefile | 19 +++++++++++++++++++ internal/mithril-doc/Makefile | 19 +++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 internal/mithril-build-script/Makefile create mode 100644 internal/mithril-doc-derive/Makefile create mode 100644 internal/mithril-doc/Makefile diff --git a/Makefile b/Makefile index 0ffd8ee21ca..c0124d89882 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -COMPONENTS = mithril-common mithril-persistence mithril-stm mithril-aggregator mithril-client mithril-client-cli mithril-signer demo/protocol-demo mithril-test-lab/mithril-end-to-end +COMPONENTS = mithril-common mithril-stm mithril-aggregator mithril-client mithril-client-cli mithril-signer \ + internal/mithril-persistence internal/mithril-doc-derive internal/mithril-doc internal/mithril-build-script \ + demo/protocol-demo mithril-test-lab/mithril-end-to-end GOALS := $(or $(MAKECMDGOALS),all) .PHONY: $(GOALS) $(COMPONENTS) diff --git a/internal/mithril-build-script/Makefile b/internal/mithril-build-script/Makefile new file mode 100644 index 00000000000..adc3e3d5c11 --- /dev/null +++ b/internal/mithril-build-script/Makefile @@ -0,0 +1,19 @@ +.PHONY: all build test check doc + +CARGO = cargo + +all: test build + +build: + ${CARGO} build --release + +test: + ${CARGO} test + +check: + ${CARGO} check --release --all-features --all-targets + ${CARGO} clippy --release --all-features --all-targets + ${CARGO} fmt --check + +doc: + ${CARGO} doc --no-deps --open --features full diff --git a/internal/mithril-doc-derive/Makefile b/internal/mithril-doc-derive/Makefile new file mode 100644 index 00000000000..adc3e3d5c11 --- /dev/null +++ b/internal/mithril-doc-derive/Makefile @@ -0,0 +1,19 @@ +.PHONY: all build test check doc + +CARGO = cargo + +all: test build + +build: + ${CARGO} build --release + +test: + ${CARGO} test + +check: + ${CARGO} check --release --all-features --all-targets + ${CARGO} clippy --release --all-features --all-targets + ${CARGO} fmt --check + +doc: + ${CARGO} doc --no-deps --open --features full diff --git a/internal/mithril-doc/Makefile b/internal/mithril-doc/Makefile new file mode 100644 index 00000000000..adc3e3d5c11 --- /dev/null +++ b/internal/mithril-doc/Makefile @@ -0,0 +1,19 @@ +.PHONY: all build test check doc + +CARGO = cargo + +all: test build + +build: + ${CARGO} build --release + +test: + ${CARGO} test + +check: + ${CARGO} check --release --all-features --all-targets + ${CARGO} clippy --release --all-features --all-targets + ${CARGO} fmt --check + +doc: + ${CARGO} doc --no-deps --open --features full From 76ae6186f46dc9421dc3484f7d4e10728d3d08aa Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:28:47 +0100 Subject: [PATCH 04/15] Update main README & add README for all internal crates --- README.md | 12 ++++++++++-- internal/mithril-doc-derive/README.md | 3 +++ internal/mithril-doc/README.md | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 internal/mithril-doc-derive/README.md create mode 100644 internal/mithril-doc/README.md diff --git a/README.md b/README.md index 537685634f6..a3537995ecf 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,6 @@ This repository consists of the following parts: * [**Mithril common**](./mithril-common): this is the **common** library that is used by the **Mithril network** nodes. -* [**Mithril persistence**](./mithril-persistence): the **persistence** library that is used by the **Mithril network** nodes. - * [**Mithril STM**](./mithril-stm): the **core** library that implements **Mithril** protocol cryptographic engine. * [**Mithril explorer**](./mithril-explorer): the **explorer** website that connects to a **Mithril aggregator** and displays its **Certificate chain** and artifacts. @@ -74,6 +72,16 @@ This repository consists of the following parts: * [**Mithril signer**](./mithril-signer): the node of the **Mithril network** responsible for producing individual signatures that are collected and aggregated by the **Mithril aggregator**. +* [**Internal**](./internal): the shared tools and API used by **Mithril** crates. + + * [**Mithril build script**](./internal/mithril-build-script): a toolbox for Mithril crates using a build scripts phase. + + * [**Mithril doc**](./internal/mithril-doc): an API that generates markdown documentation for a crate command lines arguments. + + * [**Mithril doc derive**](./internal/mithril-doc-derive): a macro implementation used by **Mithril doc**. + + * [**Mithril persistence**](./internal/mithril-persistence): the **persistence** library that is used by the **Mithril network** nodes. + * [**Mithril test lab**](./mithril-test-lab): the suite of tools that allow us to test and stress the **Mithril** protocol implementations. * [**Mithril devnet**](./mithril-test-lab/mithril-devnet): the private **Mithril/Cardano network** used to scaffold a **Mithril network** on top of a **Cardano network**. diff --git a/internal/mithril-doc-derive/README.md b/internal/mithril-doc-derive/README.md new file mode 100644 index 00000000000..c0b170b9c52 --- /dev/null +++ b/internal/mithril-doc-derive/README.md @@ -0,0 +1,3 @@ +# Mithril-doc-derive + +Macro implementation for [Mithril-doc](../mithril-doc) derives. diff --git a/internal/mithril-doc/README.md b/internal/mithril-doc/README.md new file mode 100644 index 00000000000..3b00e9d110e --- /dev/null +++ b/internal/mithril-doc/README.md @@ -0,0 +1,3 @@ +# Mithril-doc + +An API that generates markdown documentation of a crate command lines arguments. From 265a443fc00eb414990ad935a48454c089e42cc0 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:11:56 +0100 Subject: [PATCH 05/15] Remove `include` table from mithril-doc-derive as it is not published --- internal/mithril-doc-derive/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/mithril-doc-derive/Cargo.toml b/internal/mithril-doc-derive/Cargo.toml index c9949fefd1a..c15c23e5a4f 100644 --- a/internal/mithril-doc-derive/Cargo.toml +++ b/internal/mithril-doc-derive/Cargo.toml @@ -7,7 +7,6 @@ edition = { workspace = true } homepage = { workspace = true } license = { workspace = true } repository = { workspace = true } -include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore", "openapi.yaml"] [lib] proc-macro = true From 2fa12cfbe546d54e4ecf3d20138c45ce6e60320f Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:00:29 +0100 Subject: [PATCH 06/15] Upgrade nix flake dependencies By running 'nix flake update' command. --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 1ce9bcd0d95..25fdcd1d980 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1707461758, - "narHash": "sha256-VaqINICYEtVKF0X+chdNtXcNp6poZr385v6AG7j0ybM=", + "lastModified": 1708794349, + "narHash": "sha256-jX+B1VGHT0ruHHL5RwS8L21R6miBn4B6s9iVyUJsJJY=", "owner": "ipetkov", "repo": "crane", - "rev": "505976eaeac289fe41d074bee37006ac094636bb", + "rev": "2c94ff9a6fbeb9f3ea0107f28688edbe9c81deaa", "type": "github" }, "original": { @@ -40,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707451808, - "narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=", + "lastModified": 1708976803, + "narHash": "sha256-yvRygcySjjSvj5JTaCdo7lPqJ/2mBV2XQ94Oaq/14qw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "442d407992384ed9c0e6d352de75b69079904e4e", + "rev": "548a86b335d7ecd8b57ec617781f5e652ab0c38e", "type": "github" }, "original": { @@ -87,11 +87,11 @@ ] }, "locked": { - "lastModified": 1707300477, - "narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=", + "lastModified": 1708897213, + "narHash": "sha256-QECZB+Hgz/2F/8lWvHNk05N6NU/rD9bWzuNn6Cv8oUk=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "ac599dab59a66304eb511af07b3883114f061b9d", + "rev": "e497a9ddecff769c2a7cbab51e1ed7a8501e7a3a", "type": "github" }, "original": { From 91d7a829df308cacaac80bf6eaf7b4f462bc3af2 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:01:00 +0100 Subject: [PATCH 07/15] Fix nix build Two problems: * In `mithril_build_script::get_package_path` the `cargo pkgid` command returns a different format that the one we though when designing this method (the 'path+' suffix is missing in nix). * The json files in `/mithril-aggregator-fake/default_data/` were removed from the files used in the nix builds. --- flake.nix | 6 ++-- internal/mithril-build-script/src/lib.rs | 45 +++++++++++++++++++----- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index fdb05cdc06b..8d886dc5783 100644 --- a/flake.nix +++ b/flake.nix @@ -37,9 +37,11 @@ isCargoFile = base == "Cargo.lock"; isCargoConfig = parentDir == ".cargo" && base == "config"; isOpenApiYaml = base == "openapi.yaml"; + isFakeAggregatorDefaultData = lib.hasInfix "/mithril-aggregator-fake/default_data/" path; isTestDataAsset = lib.hasInfix "/test_data/" path; in - type == "directory" || matchesSuffix || isCargoFile || isCargoConfig || isOpenApiYaml || isTestDataAsset; + type == "directory" || matchesSuffix || isCargoFile || isCargoConfig || isOpenApiYaml + || isFakeAggregatorDefaultData || isTestDataAsset; }; buildInputs = @@ -108,7 +110,7 @@ mithril-client-cli = buildPackage ./mithril-client-cli/Cargo.toml mithril.cargoArtifacts {}; mithril-aggregator = buildPackage ./mithril-aggregator/Cargo.toml mithril.cargoArtifacts {}; mithril-signer = buildPackage ./mithril-signer/Cargo.toml mithril.cargoArtifacts {}; - mithril-persistence = buildPackage ./mithril-persistence/Cargo.toml mithril.cargoArtifacts {}; + mithril-persistence = buildPackage ./internal/mithril-persistence/Cargo.toml mithril.cargoArtifacts {}; mithrildemo = buildPackage ./demo/protocol-demo/Cargo.toml mithril.cargoArtifacts {}; mithril-end-to-end = buildPackage ./mithril-test-lab/mithril-end-to-end/Cargo.toml null {}; }; diff --git a/internal/mithril-build-script/src/lib.rs b/internal/mithril-build-script/src/lib.rs index 16efe1d64e2..8fff7c99934 100644 --- a/internal/mithril-build-script/src/lib.rs +++ b/internal/mithril-build-script/src/lib.rs @@ -10,15 +10,12 @@ pub fn get_package_path(package_name: &str) -> PathBuf { match cargo_pkgid_output.status.success() { true => { - let package_name = std::str::from_utf8(&cargo_pkgid_output.stdout) + let output_string = std::str::from_utf8(&cargo_pkgid_output.stdout) .unwrap() - .trim() - .strip_prefix("path+file://") - .unwrap() - .split('#') - .collect::>()[0]; + .trim(); + let package_path = extract_package_path(output_string); - PathBuf::from(package_name) + PathBuf::from(package_path) } false => { panic!( @@ -31,13 +28,31 @@ pub fn get_package_path(package_name: &str) -> PathBuf { } } +const PKGID_OUTPUT_PREFIX: &str = "file://"; + +fn extract_package_path<'a>(pkgid_output: &'a str) -> &'a str { + let output_without_prefix = pkgid_output + .split(PKGID_OUTPUT_PREFIX) + .collect::>(); + + output_without_prefix + .last() + .unwrap_or_else(|| { + panic!("Could not remove '{PKGID_OUTPUT_PREFIX}' prefix from `cargo pkgid` output: {pkgid_output}") + }) + .split('#') + .collect::>() + .first() + .unwrap_or_else(|| panic!("Could not remove '#x.y.z' suffix from `cargo pkgid` output: {pkgid_output}")) +} + #[cfg(test)] mod tests { use super::*; #[test] fn get_package_path_should_return_path_of_existing_package() { - let expected = PathBuf::from("./../mithril-aggregator/") + let expected = PathBuf::from("./../../mithril-aggregator/") .canonicalize() .unwrap(); @@ -57,4 +72,18 @@ mod tests { fn get_package_path_panic_if_invalid_package_name() { get_package_path("Invalid Package Name ~~~"); } + + #[test] + fn extract_package_path_from_multiple_pkid_formats() { + let expected = "/dev/package_path/crate"; + + assert_eq!( + extract_package_path(&format!("{PKGID_OUTPUT_PREFIX}{expected}#version")), + expected + ); + assert_eq!( + extract_package_path(&format!("path+{PKGID_OUTPUT_PREFIX}{expected}#version")), + expected + ); + } } From a0b901e7442c014c7247f34e585b19a5c6965779 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:43:25 +0100 Subject: [PATCH 08/15] Migrate `mithril-common` build script logic to `mithril-build-script` Also refactor the generated code to remove all potentially failing parsing. --- Cargo.lock | 5 + internal/mithril-build-script/Cargo.toml | 2 + .../src/fake_aggregator.rs | 12 +- internal/mithril-build-script/src/lib.rs | 18 +- internal/mithril-build-script/src/open_api.rs | 184 ++++++++++++++++++ .../src/http_server/routes/router.rs | 5 +- mithril-common/Cargo.toml | 5 +- mithril-common/build.rs | 62 +----- mithril-common/src/api_version.rs | 27 ++- 9 files changed, 227 insertions(+), 93 deletions(-) create mode 100644 internal/mithril-build-script/src/open_api.rs diff --git a/Cargo.lock b/Cargo.lock index 22c68b8318a..59a63500745 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3397,6 +3397,10 @@ dependencies = [ [[package]] name = "mithril-build-script" version = "0.1.0" +dependencies = [ + "semver", + "serde_yaml", +] [[package]] name = "mithril-client" @@ -3496,6 +3500,7 @@ dependencies = [ "jsonschema", "kes-summed-ed25519", "minicbor", + "mithril-build-script", "mithril-stm", "mockall", "nom", diff --git a/internal/mithril-build-script/Cargo.toml b/internal/mithril-build-script/Cargo.toml index cc299ad62f8..26234cacd5b 100644 --- a/internal/mithril-build-script/Cargo.toml +++ b/internal/mithril-build-script/Cargo.toml @@ -9,3 +9,5 @@ license = { workspace = true } repository = { workspace = true } [dependencies] +semver = "1.0.21" +serde_yaml = "0.9.31" diff --git a/internal/mithril-build-script/src/fake_aggregator.rs b/internal/mithril-build-script/src/fake_aggregator.rs index 256a0db1f7f..5620c19b7b4 100644 --- a/internal/mithril-build-script/src/fake_aggregator.rs +++ b/internal/mithril-build-script/src/fake_aggregator.rs @@ -180,17 +180,7 @@ impl FakeAggregatorData { } pub fn list_json_files_in_folder(folder: &Path) -> impl Iterator + '_ { - fs::read_dir(folder) - .unwrap_or_else(|_| panic!("Could not read `{}` dir", folder.display())) - .filter_map(move |e| { - let entry = e.unwrap_or_else(|_| { - panic!("Failed to read a file in the `{}` dir", folder.display()) - }); - match entry.file_type() { - Ok(file_type) if file_type.is_file() => Some(entry), - _ => None, - } - }) + crate::list_files_in_folder(folder) .filter(|e| e.file_name().to_string_lossy().ends_with(".json")) } diff --git a/internal/mithril-build-script/src/lib.rs b/internal/mithril-build-script/src/lib.rs index 8fff7c99934..2c90ba75784 100644 --- a/internal/mithril-build-script/src/lib.rs +++ b/internal/mithril-build-script/src/lib.rs @@ -1,6 +1,8 @@ -use std::path::PathBuf; +use std::fs; +use std::path::{Path, PathBuf}; pub mod fake_aggregator; +pub mod open_api; pub fn get_package_path(package_name: &str) -> PathBuf { let cargo_pkgid_output = std::process::Command::new(env!("CARGO")) @@ -46,6 +48,20 @@ fn extract_package_path<'a>(pkgid_output: &'a str) -> &'a str { .unwrap_or_else(|| panic!("Could not remove '#x.y.z' suffix from `cargo pkgid` output: {pkgid_output}")) } +pub(crate) fn list_files_in_folder(folder: &Path) -> impl Iterator + '_ { + fs::read_dir(folder) + .unwrap_or_else(|_| panic!("Could not read `{}` dir", folder.display())) + .filter_map(move |e| { + let entry = e.unwrap_or_else(|_| { + panic!("Failed to read a file in the `{}` dir", folder.display()) + }); + match entry.file_type() { + Ok(file_type) if file_type.is_file() => Some(entry), + _ => None, + } + }) +} + #[cfg(test)] mod tests { use super::*; diff --git a/internal/mithril-build-script/src/open_api.rs b/internal/mithril-build-script/src/open_api.rs new file mode 100644 index 00000000000..f12e1439bb3 --- /dev/null +++ b/internal/mithril-build-script/src/open_api.rs @@ -0,0 +1,184 @@ +use semver::Version; +use std::collections::BTreeMap; +use std::fs; +use std::path::{Path, PathBuf}; + +type OpenAPIFileName = String; +type OpenAPIVersionRaw = String; + +const TYPE_ALIAS: &str = r"/// Open API file name +pub type OpenAPIFileName = String; +"; + +fn list_all_open_api_spec_files(paths: &[&Path]) -> Vec { + let mut open_api_spec_files = Vec::new(); + + for path in paths { + for entry in crate::list_files_in_folder(path).filter(|e| { + let os_filename = e.file_name(); + let filename = os_filename.to_string_lossy(); + filename.starts_with("openapi") && filename.ends_with(".yaml") + }) { + open_api_spec_files.push(entry.path()) + } + } + + open_api_spec_files +} + +fn read_version_from_open_api_spec_file(spec_file_path: PathBuf) -> OpenAPIVersionRaw { + let yaml_spec = fs::read_to_string(spec_file_path).unwrap(); + let open_api: serde_yaml::Value = serde_yaml::from_str(&yaml_spec).unwrap(); + open_api["info"]["version"].as_str().unwrap().to_owned() +} + +/// Generate the `get_open_api_versions_mapping` function based on the Open API files +/// in the given folders. +pub fn generate_open_api_versions_mapping(paths: &[&Path]) -> String { + let open_api_spec_files = list_all_open_api_spec_files(paths); + // Use a BTreeMap to guarantee the deterministic code generation below + let open_api_versions: BTreeMap = open_api_spec_files + .into_iter() + .map(|path| (path.clone(), read_version_from_open_api_spec_file(path))) + .map(|(path, version_raw)| { + ( + path.file_name().unwrap().to_string_lossy().to_string(), + Version::parse(&version_raw).unwrap(), + ) + }) + .collect(); + + let mut open_api_versions_hashmap = String::new(); + for (filename, version) in open_api_versions { + open_api_versions_hashmap.push_str(&format!( + r#"("{filename}".to_string(), semver::Version::new({}, {}, {})), "#, + version.major, version.minor, version.patch + )); + } + + format!( + r#"{TYPE_ALIAS} +/// Build Open API versions mapping +pub fn get_open_api_versions_mapping() -> HashMap {{ + HashMap::from([ + {} + ]) +}} + "#, + open_api_versions_hashmap + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::path::Path; + + // Note: adding `mithril-common` as a dev-dependency would lead to a circular dependency, so + // we can't use its `TempDir` api. + fn get_temp_dir(dir_name: &str) -> PathBuf { + let dir = std::env::temp_dir() + .join("mithril_test") + .join("build_script") + .join(dir_name); + + if dir.exists() { + fs::remove_dir_all(&dir).unwrap(); + } + fs::create_dir_all(&dir).unwrap(); + + dir + } + + fn write_minimal_open_api_file(version: &str, path: &Path) { + fs::write( + path, + format!( + r#"openapi: "3.0.0" +info: + version: {version} + title: Minimal Open Api File +"# + ), + ) + .unwrap() + } + + fn assert_open_api_content_contains(expected_content: &str, generated_code: &str) { + assert!( + generated_code.contains(expected_content), + "generated code did not include expected openapi files entries:\ + \n---- Code that was expected to be included:\n{expected_content}\ + \n---- Actual generated code:{}", + // Remove type aliases for readability + generated_code.trim_start_matches(TYPE_ALIAS) + ); + } + + #[test] + fn generated_code_include_type_aliases() { + let generated_code = generate_open_api_versions_mapping(&[Path::new("./")]); + + assert!(generated_code.contains(TYPE_ALIAS)); + } + + #[test] + fn generated_function_returns_an_hashmap_of_open_api_file_name_and_semver_version() { + let generated_code = generate_open_api_versions_mapping(&[Path::new("./")]); + + assert!(generated_code.contains("-> HashMap")); + } + + #[test] + fn generate_code_from_a_simple_open_api_file() { + let dir = get_temp_dir("generate_code_from_a_simple_open_api_file"); + write_minimal_open_api_file("1.0.0", &dir.join("openapi.yaml")); + + let expected = r#"("openapi.yaml".to_string(), semver::Version::new(1, 0, 0))"#; + let generated_code = generate_open_api_versions_mapping(&[&dir]); + + assert_open_api_content_contains(expected, &generated_code); + } + + #[test] + fn only_read_yaml_files() { + let dir = get_temp_dir("only_read_yaml_files"); + write_minimal_open_api_file("1.0.0", &dir.join("openapi.yaml")); + fs::write(dir.join("openapi.json"), "{}").unwrap(); + + let included_files = list_all_open_api_spec_files(&[&dir]); + + assert_eq!(vec![dir.join("openapi.yaml")], included_files); + } + + #[test] + fn generate_code_from_two_open_api_files_in_different_folders() { + let sub_folder = + get_temp_dir("generate_code_from_two_open_api_files_in_different_folders/subfolder"); + let parent_folder = sub_folder.parent().unwrap(); + write_minimal_open_api_file("1.0.0", &parent_folder.join("openapi.yaml")); + write_minimal_open_api_file("2.0.0", &sub_folder.join("openapi-thales.yaml")); + + let expected = r#"("openapi-thales.yaml".to_string(), semver::Version::new(2, 0, 0)), ("openapi.yaml".to_string(), semver::Version::new(1, 0, 0))"#; + let generated_code = generate_open_api_versions_mapping(&[&parent_folder, &sub_folder]); + + assert_open_api_content_contains(expected, &generated_code); + } + + #[test] + fn when_colliding_filenames_version_is_read_from_latest_given_folder() { + let sub_folder = get_temp_dir( + "when_colliding_filenames_version_read_is_from_latest_given_folder/subfolder", + ); + let parent_folder = sub_folder.parent().unwrap(); + write_minimal_open_api_file("1.0.0", &parent_folder.join("openapi.yaml")); + write_minimal_open_api_file("2.0.0", &sub_folder.join("openapi.yaml")); + + let expected = r#"HashMap::from([ + ("openapi.yaml".to_string(), semver::Version::new(2, 0, 0)), + ])"#; + let generated_code = generate_open_api_versions_mapping(&[&parent_folder, &sub_folder]); + + assert_open_api_content_contains(expected, &generated_code); + } +} diff --git a/mithril-aggregator/src/http_server/routes/router.rs b/mithril-aggregator/src/http_server/routes/router.rs index d84c3f6a697..93cffd70902 100644 --- a/mithril-aggregator/src/http_server/routes/router.rs +++ b/mithril-aggregator/src/http_server/routes/router.rs @@ -115,6 +115,7 @@ pub async fn handle_custom(reject: Rejection) -> Result { #[cfg(test)] mod tests { + use semver::Version; use std::collections::HashMap; use mithril_common::{ @@ -156,7 +157,7 @@ mod tests { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "1.0.0".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(1, 0, 0)); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); let filters = header_must_be(api_version_provider); @@ -173,7 +174,7 @@ mod tests { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "0.1.0".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(0, 1, 0)); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); let filters = header_must_be(api_version_provider); diff --git a/mithril-common/Cargo.toml b/mithril-common/Cargo.toml index 1454ad48bee..c3a6ea67482 100644 --- a/mithril-common/Cargo.toml +++ b/mithril-common/Cargo.toml @@ -92,10 +92,7 @@ slog-term = "2.9.0" tokio = { version = "1.35.1", features = ["macros", "time"] } [build-dependencies] -glob = "0.3.1" -semver = "1.0.21" -serde_json = "1.0.113" -serde_yaml = "0.9.31" +mithril-build-script = { path = "../internal/mithril-build-script" } [features] default = [] diff --git a/mithril-common/build.rs b/mithril-common/build.rs index 73a37e7f9bc..daa25086e98 100644 --- a/mithril-common/build.rs +++ b/mithril-common/build.rs @@ -1,69 +1,13 @@ // build.rs -use glob::glob; -use semver::Version; -use std::collections::HashMap; +use mithril_build_script::open_api::generate_open_api_versions_mapping; use std::env; use std::fs; use std::path::Path; -use std::path::PathBuf; - -type OpenAPIFileName = String; -type OpenAPIVersionRaw = String; - -fn read_version_from_open_api_spec_file(spec_file_path: PathBuf) -> OpenAPIVersionRaw { - let yaml_spec = std::fs::read_to_string(spec_file_path).unwrap(); - let open_api: serde_yaml::Value = serde_yaml::from_str(&yaml_spec).unwrap(); - open_api["info"]["version"].as_str().unwrap().to_owned() -} - -fn list_all_open_api_spec_files() -> Vec { - let mut open_api_spec_files = Vec::new(); - for entry in glob("./openapi*.yaml").unwrap() { - open_api_spec_files.push(entry.unwrap()) - } - for entry in glob("../openapi*.yaml").unwrap() { - open_api_spec_files.push(entry.unwrap()) - } - - open_api_spec_files -} fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join("open_api.rs"); - let open_api_spec_files = list_all_open_api_spec_files(); - let open_api_versions = open_api_spec_files - .into_iter() - .map(|path| (path.clone(), read_version_from_open_api_spec_file(path))) - .map(|(path, version_raw)| { - ( - path.file_name().unwrap().to_str().unwrap().to_string(), - Version::parse(&version_raw).unwrap().to_string(), - ) - }) - .collect::>(); - let open_api_versions_json = format!( - "r#\"{}\"#", - serde_json::to_string(&open_api_versions).unwrap() - ); - fs::write( - dest_path, - format!( - r#" -/// Open API file name -pub type OpenAPIFileName = String; - -/// Open API raw version -pub type OpenAPIVersionRaw = String; + let open_api_code = generate_open_api_versions_mapping(&[Path::new("./"), &Path::new("../")]); -/// Build Open API versions mapping -pub fn get_open_api_versions_mapping() -> HashMap {{ - serde_json::from_str({}).unwrap() -}} - "#, - open_api_versions_json - ), - ) - .unwrap(); + fs::write(Path::new(&out_dir).join("open_api.rs"), open_api_code).unwrap(); } diff --git a/mithril-common/src/api_version.rs b/mithril-common/src/api_version.rs index a253ed13431..b18a745ca1c 100644 --- a/mithril-common/src/api_version.rs +++ b/mithril-common/src/api_version.rs @@ -1,7 +1,6 @@ //! API Version provider service include!(concat!(env!("OUT_DIR"), "/open_api.rs")); use anyhow::anyhow; -use anyhow::Context; use semver::{Version, VersionReq}; use std::collections::HashMap; use std::sync::Arc; @@ -13,7 +12,7 @@ use crate::StdResult; #[derive(Clone)] pub struct APIVersionProvider { era_checker: Arc, - open_api_versions: HashMap, + open_api_versions: HashMap, } impl APIVersionProvider { @@ -30,7 +29,7 @@ impl APIVersionProvider { let current_era = self.era_checker.current_era(); let open_api_spec_file_name_default = "openapi.yaml"; let open_api_spec_file_name_era = &format!("openapi-{current_era}.yaml"); - let open_api_version_raw = self + let open_api_version = self .open_api_versions .get(open_api_spec_file_name_era) .unwrap_or( @@ -39,9 +38,7 @@ impl APIVersionProvider { .ok_or_else(|| anyhow!("Missing default API version"))?, ); - Version::parse(open_api_version_raw) - .map_err(|e| anyhow!(e)) - .with_context(|| format!("Cannot parse Semver from: '{open_api_version_raw:?}'")) + Ok(open_api_version.clone()) } /// Compute the current api version requirement @@ -58,10 +55,7 @@ impl APIVersionProvider { /// Compute all the sorted list of all versions pub fn compute_all_versions_sorted() -> StdResult> { - let mut versions = Vec::new(); - for version_raw in get_open_api_versions_mapping().into_values() { - versions.push(Version::parse(&version_raw)?) - } + let mut versions: Vec = get_open_api_versions_mapping().into_values().collect(); versions.sort(); Ok(versions) } @@ -69,7 +63,7 @@ impl APIVersionProvider { /// Update open api versions. Test only pub fn update_open_api_versions( &mut self, - open_api_versions: HashMap, + open_api_versions: HashMap, ) { self.open_api_versions = open_api_versions; } @@ -77,6 +71,7 @@ impl APIVersionProvider { #[cfg(test)] mod test { + use semver::Version; use std::{collections::HashMap, sync::Arc}; use crate::{ @@ -90,7 +85,7 @@ mod test { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "1.2.3".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(1, 2, 3)); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); @@ -108,10 +103,10 @@ mod test { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "1.2.3".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(1, 2, 3)); open_api_versions.insert( format!("openapi-{}.yaml", SupportedEra::dummy()), - "2.1.0".to_string(), + Version::new(2, 1, 0), ); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); @@ -130,7 +125,7 @@ mod test { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "0.2.3".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(0, 2, 3)); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); @@ -148,7 +143,7 @@ mod test { let era_checker = EraChecker::new(SupportedEra::dummy(), Epoch(1)); let mut version_provider = APIVersionProvider::new(Arc::new(era_checker)); let mut open_api_versions = HashMap::new(); - open_api_versions.insert("openapi.yaml".to_string(), "3.2.1".to_string()); + open_api_versions.insert("openapi.yaml".to_string(), Version::new(3, 2, 1)); version_provider.update_open_api_versions(open_api_versions); let api_version_provider = Arc::new(version_provider); From 8b45de0d37767fa43bea53a41acc3a51f1dc6b44 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:48:05 +0100 Subject: [PATCH 09/15] Rework release note crates table generation to only include "released" crates --- .github/workflows/actions/prepare-distribution/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actions/prepare-distribution/action.yml b/.github/workflows/actions/prepare-distribution/action.yml index dca92955157..31b025f1a79 100644 --- a/.github/workflows/actions/prepare-distribution/action.yml +++ b/.github/workflows/actions/prepare-distribution/action.yml @@ -58,9 +58,9 @@ runs: EOF cargo metadata --quiet --no-deps | \ - jq -r '.packages | sort_by(.name) | .[] | select([.name] | inside(["mithrildemo", "client-mithril-stake-distribution", "client-snapshot", "mithril-end-to-end", "mithril-relay"]) | not) | "| \(.name) | `\(.version)` |"' \ + jq -r '.packages | sort_by(.name) | .[] | select([.name] | inside(["mithril-stm", "mithril-aggregator", "mithril-client", "mithril-client-cli", "mithril-client-wasm", "mithril-signer", "mithril-common"])) | "| \(.name) | `\(.version)` |"' \ >> ./release-notes-addon.txt - + - name: Add compatibility table shell: bash run: | @@ -74,7 +74,7 @@ runs: echo '${{ inputs.compatibility-table }}' \ | jq -r 'keys_unsorted[] as $network | "| \($network) | \(.[$network]) |"' \ >> ./release-notes-addon.txt - + - name: Add minimum supported libc version shell: bash run: | From e80a00e26d25ccca1f6332f910f995bcd601aada Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:10:38 +0100 Subject: [PATCH 10/15] Prepare `mithril-build-script` for publication --- .../actions/publish-crate-package/action.yml | 79 ++++++++++--------- .github/workflows/ci.yml | 2 +- .github/workflows/manual-publish-crates.yml | 6 +- .github/workflows/pre-release.yml | 2 +- .github/workflows/release.yml | 4 +- internal/mithril-build-script/Cargo.toml | 1 + internal/mithril-build-script/README.md | 2 +- mithril-common/Cargo.toml | 2 +- 8 files changed, 52 insertions(+), 46 deletions(-) diff --git a/.github/workflows/actions/publish-crate-package/action.yml b/.github/workflows/actions/publish-crate-package/action.yml index 404d1a2494b..d1853c4ba75 100644 --- a/.github/workflows/actions/publish-crate-package/action.yml +++ b/.github/workflows/actions/publish-crate-package/action.yml @@ -8,7 +8,7 @@ inputs: package: description: crate package name. required: true - api_token: + api_token: description: crates.io API token. required: false publish_args: @@ -18,45 +18,46 @@ inputs: runs: using: "composite" steps: - - name: Check crate latest version - id: check_version - shell: bash - run: | - echo "Check crate latest published version for '${{ inputs.package}}' package" - LATEST_REMOTE_VERSION=$(curl -sL https://crates.io/api/v1/crates/${{ inputs.package}} | jq -r '.crate.newest_version') - LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="${{ inputs.package}}") | .version') - echo "Latest crate.io version: $LATEST_REMOTE_VERSION" - echo "Local version: $LOCAL_VERSION" + - name: Check crate latest version + id: check_version + shell: bash + run: | + echo "Check crate latest published version for '${{ inputs.package}}' package" + LATEST_REMOTE_VERSION=$(curl -sL https://crates.io/api/v1/crates/${{ inputs.package}} | jq -r '.crate.newest_version') + LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="${{ inputs.package}}") | .version') + echo "Latest crate.io version: $LATEST_REMOTE_VERSION" + echo "Local version: $LOCAL_VERSION" + + if [ "$LOCAL_VERSION" != "$LATEST_REMOTE_VERSION" ]; then + echo "Local version is newer than remote version: we will publish to crates.io" + echo "should_deploy=true" >> $GITHUB_OUTPUT + else + echo "Local version and remote version are the same: no need to publish to crates.io" + echo "should_deploy=false" >> $GITHUB_OUTPUT + fi - if [ "$LOCAL_VERSION" != "$LATEST_REMOTE_VERSION" ]; then - echo "Local version is newer than remote version: we will publish to crates.io" - echo "should_deploy=true" >> $GITHUB_OUTPUT - else - echo "Local version and remote version are the same: no need to publish to crates.io" - echo "should_deploy=false" >> $GITHUB_OUTPUT - fi + - name: Copy OpenAPI specs files + if: inputs.package == 'mithril-common' + shell: bash + run: | + echo "Copy OpenAPI specs files" + cp openapi*.yaml ./${{ inputs.package}} - - name: Copy OpenAPI specs files - shell: bash - run: | - echo "Copy OpenAPI specs files" - cp openapi*.yaml ./${{ inputs.package}} + - name: Cargo publish dry run + shell: bash + run: | + echo "Cargo publish '${{ inputs.package }}' package (dry run)" + cargo publish -p ${{ inputs.package }} --dry-run --no-verify --allow-dirty ${{ inputs.publish_args }} - - name: Cargo publish dry run - shell: bash - run: | - echo "Cargo publish '${{ inputs.package }}' package (dry run)" - cargo publish -p ${{ inputs.package }} --dry-run --no-verify --allow-dirty ${{ inputs.publish_args }} + - name: Cargo package list + shell: bash + run: | + echo "Cargo package list '${{ inputs.package }}' package" + cargo package -p ${{ inputs.package }} --list --allow-dirty - - name: Cargo package list - shell: bash - run: | - echo "Cargo package list '${{ inputs.package }}' package" - cargo package -p ${{ inputs.package }} --list --allow-dirty - - - name: Cargo publish - if: inputs.dry_run == 'false' && steps.check_version.outputs.should_deploy == 'true' - shell: bash - run: | - echo "Cargo publish '${{ inputs.package }}' package" - cargo publish -p ${{ inputs.package }} --token ${{ inputs.api_token }} --no-verify --allow-dirty ${{ inputs.publish_args }} + - name: Cargo publish + if: inputs.dry_run == 'false' && steps.check_version.outputs.should_deploy == 'true' + shell: bash + run: | + echo "Cargo publish '${{ inputs.package }}' package" + cargo publish -p ${{ inputs.package }} --token ${{ inputs.api_token }} --no-verify --allow-dirty ${{ inputs.publish_args }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6723315962b..2327fa882c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -431,7 +431,7 @@ jobs: fail-fast: false max-parallel: 1 matrix: - package: [ mithril-stm, mithril-common, mithril-client ] + package: [ mithril-stm, mithril-build-script, mithril-common, mithril-client ] runs-on: ubuntu-22.04 needs: diff --git a/.github/workflows/manual-publish-crates.yml b/.github/workflows/manual-publish-crates.yml index fd4123b58b7..7e597ca9f99 100644 --- a/.github/workflows/manual-publish-crates.yml +++ b/.github/workflows/manual-publish-crates.yml @@ -30,10 +30,12 @@ jobs: fail-fast: true max-parallel: 1 matrix: - package: [ mithril-stm, mithril-common, mithril-client ] + package: [ mithril-stm, mithril-build-script, mithril-common, mithril-client ] include: - package: mithril-stm api_token_secret_name: CRATES_IO_API_TOKEN + - package: mithril-build-script + api_token_secret_name: CRATES_IO_API_TOKEN_MITHRIL_BUILD_SCRIPT - package: mithril-common api_token_secret_name: CRATES_IO_API_TOKEN_MITHRIL_COMMON - package: mithril-client @@ -59,4 +61,4 @@ jobs: with: dry_run: ${{ inputs.dry_run }} package: ${{ matrix.package }} - api_token: ${{ secrets[matrix.api_token_secret_name] }} \ No newline at end of file + api_token: ${{ secrets[matrix.api_token_secret_name] }} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 4c18fb003c4..9e6e4ab8825 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -235,7 +235,7 @@ jobs: fail-fast: false max-parallel: 1 matrix: - package: [ mithril-stm, mithril-common, mithril-client ] + package: [ mithril-stm, mithril-build-script, mithril-common, mithril-client ] runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e598a6991d4..5c86b5481e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -172,10 +172,12 @@ jobs: fail-fast: true max-parallel: 1 matrix: - package: [ mithril-stm, mithril-common, mithril-client ] + package: [ mithril-stm, mithril-build-script, mithril-common, mithril-client ] include: - package: mithril-stm api_token_secret_name: CRATES_IO_API_TOKEN + - package: mithril-build-script + api_token_secret_name: CRATES_IO_API_TOKEN_MITHRIL_BUILD_SCRIPT - package: mithril-common api_token_secret_name: CRATES_IO_API_TOKEN_MITHRIL_COMMON - package: mithril-client diff --git a/internal/mithril-build-script/Cargo.toml b/internal/mithril-build-script/Cargo.toml index 26234cacd5b..5dd19f5f9a1 100644 --- a/internal/mithril-build-script/Cargo.toml +++ b/internal/mithril-build-script/Cargo.toml @@ -7,6 +7,7 @@ edition = { workspace = true } homepage = { workspace = true } license = { workspace = true } repository = { workspace = true } +include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore"] [dependencies] semver = "1.0.21" diff --git a/internal/mithril-build-script/README.md b/internal/mithril-build-script/README.md index f2cf934390d..8f7d4aed572 100644 --- a/internal/mithril-build-script/README.md +++ b/internal/mithril-build-script/README.md @@ -1,4 +1,4 @@ -# Mithril-build-script +# Mithril-build-script [crates.io](https://img.shields.io/crates/v/mithril-build-script.svg) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE-APACHE) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq) A toolbox for Mithril crates that need a [build scripts phase](https://doc.rust-lang.org/cargo/reference/build-scripts.html). diff --git a/mithril-common/Cargo.toml b/mithril-common/Cargo.toml index c3a6ea67482..e019b943fe8 100644 --- a/mithril-common/Cargo.toml +++ b/mithril-common/Cargo.toml @@ -92,7 +92,7 @@ slog-term = "2.9.0" tokio = { version = "1.35.1", features = ["macros", "time"] } [build-dependencies] -mithril-build-script = { path = "../internal/mithril-build-script" } +mithril-build-script = { path = "../internal/mithril-build-script", version = "=0.1.0" } [features] default = [] From efa1c16e03da36aaf643e4860d1f54ea4485a613 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:43:03 +0100 Subject: [PATCH 11/15] Fix edit links in docusaurus website It was not updated to the move of the docusaurus source from the `/docs` folder to the `/docs/website` subfolder. --- docs/website/docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/website/docusaurus.config.js b/docs/website/docusaurus.config.js index ab32fea13cc..e520470d9fb 100644 --- a/docs/website/docusaurus.config.js +++ b/docs/website/docusaurus.config.js @@ -36,7 +36,7 @@ const config = { editUrl: ({ docPath }) => { // We want users to submit doc updates to the upstream/next version! // Otherwise we risk losing the update on the next release. - return `https://github.com/input-output-hk/mithril/edit/main/docs/root/${docPath}`; + return `https://github.com/input-output-hk/mithril/edit/main/docs/website/root/${docPath}`; }, lastVersion: 'maintained', versions: { From 2a08bf5ee521a5dbdb74b5351fe6ca2ff48275a6 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:56:52 +0100 Subject: [PATCH 12/15] Make CI generate rust-doc for all internal crates --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2327fa882c3..506f91e871e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -700,6 +700,7 @@ jobs: # Force `--lib` to avoid a collision between the client lib and the client cli binary who share # the same name (we only want to document those anyway) cargo doc --no-deps --lib -p mithril-stm -p mithril-common -p mithril-persistence \ + -p mithril-build-script -p mithril-doc -p mithril-doc-derive \ -p mithril-aggregator -p mithril-signer -p mithril-client -p mithril-client-cli \ --all-features --message-format=json \ | clippy-sarif | tee rust-cargo-doc-results.sarif | sarif-fmt From 0376a6762146db66239e20c1c092ffc08ea47851 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:27:54 +0100 Subject: [PATCH 13/15] Update API reference page of the doc website to add the new crates --- .../root/manual/developer-docs/references.md | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/docs/website/root/manual/developer-docs/references.md b/docs/website/root/manual/developer-docs/references.md index e6234a0b455..f119498a93d 100644 --- a/docs/website/root/manual/developer-docs/references.md +++ b/docs/website/root/manual/developer-docs/references.md @@ -24,17 +24,20 @@ To learn more about the **Mithril protocol**, please refer to the [about Mithril ## A list of dependencies -| Dependency | Description | Source repository | Rust documentation | REST API -|------------|-------------|:-----------------:|:------------------:|:------------:| -| **Mithril common** | The **common** library used by **Mithril network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-common) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_common/index.html) | - -| **Mithril persistence** | The **persistence** library used by **Mithril network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-persistence) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_persistence/index.html) | - -| **Mithril STM** | The **core** library that implements the cryptographic engine for the **Mithril** protocol. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-stm) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_stm/index.html) | - -| **Mithril aggregator** | The node within the **Mithril network** responsible for collecting individual signatures from the **Mithril signers** and aggregating them into a multi-signature. This capability enables the **Mithril aggregator** to provide certified snapshots of the **Cardano** blockchain. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-aggregator) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_aggregator/index.html) | [:arrow_upper_right:](/doc/aggregator-api) -| **Mithril client CLI** | The node within the **Mithril network** responsible for restoring the **Cardano** blockchain on an empty node from a certified snapshot. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-cli) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client_cli/index.html) | - -| **Mithril client** | The library that can be used by developers to interact with Mithril certified data in their applications. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client/index.html) | - -| **Mithril signer** | The node responsible for producing individual signatures that are collected and aggregated by the **Mithril aggregator**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-signer) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_signer/index.html) | - -| **Mithril devnet** | The private **Mithril/Cardano network** used to create a **Mithril network** on top of a private **Cardano network**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-test-lab/mithril-devnet) | - | - -| **Mithril end to end** | The tool used to run test scenarios against a **Mithril devnet**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-explorer) | - | - -| **Mithril explorer** | The explorer website that connects to a **Mithril aggregator** and displays its **certificate chain**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-test-lab/mithril-end-to-end) | - | - -| **Protocol simulation** | A simple CLI that helps understand how the **Mithril protocol** works and the role of its protocol parameters. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/demo/protocol-demo) | - | - - +| Dependency | Description | Source repository | Rust documentation | Published | REST API | +|------------|-------------|:-----------------:|:------------------:|:------------:|:------------:| +| **Mithril STM** | The **core** library that implements the cryptographic engine for the **Mithril** protocol. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-stm) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_stm/index.html) | [crates :arrow_upper_right:](https://crates.io/crates/mithril-stm) | - | +| **Mithril aggregator** | The node within the **Mithril network** responsible for collecting individual signatures from the **Mithril signers** and aggregating them into a multi-signature. This capability enables the **Mithril aggregator** to provide certified snapshots of the **Cardano** blockchain. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-aggregator) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_aggregator/index.html) | - | [:arrow_upper_right:](/doc/aggregator-api) | +| **Mithril client** | The library that can be used by developers to interact with Mithril certified data in their applications. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client/index.html) | [crates :arrow_upper_right:](https://crates.io/crates/mithril-client) | - | +| **Mithril client CLI** | The node within the **Mithril network** responsible for restoring the **Cardano** blockchain on an empty node from a certified snapshot. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-cli) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client_cli/index.html) | - | - | +| **Mithril client wasm** | The WASM compatible library used for retrieving the certified artifacts produced by the **Mithril network**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-wasm) | - | [npm :arrow_upper_right:](https://www.npmjs.com/package/@mithril-dev/mithril-client-wasm) | - | +| **Mithril signer** | The node responsible for producing individual signatures that are collected and aggregated by the **Mithril aggregator**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-signer) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_signer/index.html) | - | - | +| **Mithril common** | The **common** library used by **Mithril network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-common) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_common/index.html) | [crates :arrow_upper_right:](https://crates.io/crates/mithril-common) | - | +| **Mithril build script** | A toolbox for Mithril crates using a build scripts phase. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/internal/mithril-build-script) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_build_script/index.html) | [crates :arrow_upper_right:](https://crates.io/crates/mithril-build-script) | - | +| **Mithril doc** | An API that generates markdown documentation for a crate command lines arguments. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/internal/mithril-doc) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_doc/index.html) | - | - | +| **Mithril doc derive** | A macro implementation used by **Mithril doc**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/internal/mithril-doc-derive) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_doc_derive/index.html) | - | - | +| **Mithril persistence** | The **persistence** library used by **Mithril network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/internal/mithril-persistence) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_persistence/index.html) | - | - | +| **Mithril devnet** | The private **Mithril/Cardano network** used to create a **Mithril network** on top of a private **Cardano network**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-test-lab/mithril-devnet) | - | - | - | +| **Mithril end to end** | The tool used to run test scenarios against a **Mithril devnet**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-explorer) | - | - | - | +| **Mithril explorer** | The explorer website that connects to a **Mithril aggregator** and displays its **certificate chain**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-test-lab/mithril-end-to-end) | - | - | - | +| **Protocol simulation** | A simple CLI that helps understand how the **Mithril protocol** works and the role of its protocol parameters. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/demo/protocol-demo) | - | - | - | From 9266b4582b04a146e7dd01a5e0c55770624cb503 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:38:35 +0100 Subject: [PATCH 14/15] Upgrade crates versions --- Cargo.lock | 20 +++++++++---------- demo/protocol-demo/Cargo.toml | 2 +- internal/mithril-build-script/Cargo.toml | 2 +- mithril-aggregator/Cargo.toml | 2 +- mithril-client-cli/Cargo.toml | 2 +- mithril-client-wasm/Cargo.toml | 2 +- mithril-common/Cargo.toml | 4 ++-- mithril-relay/Cargo.toml | 2 +- mithril-signer/Cargo.toml | 2 +- .../mithril-aggregator-fake/Cargo.toml | 2 +- .../mithril-end-to-end/Cargo.toml | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59a63500745..925b88e83e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3331,7 +3331,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.4.41" +version = "0.4.42" dependencies = [ "anyhow", "async-trait", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "mithril-aggregator-fake" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "axum", @@ -3396,7 +3396,7 @@ dependencies = [ [[package]] name = "mithril-build-script" -version = "0.1.0" +version = "0.1.1" dependencies = [ "semver", "serde_yaml", @@ -3437,7 +3437,7 @@ dependencies = [ [[package]] name = "mithril-client-cli" -version = "0.7.1" +version = "0.7.2" dependencies = [ "anyhow", "async-trait", @@ -3467,7 +3467,7 @@ dependencies = [ [[package]] name = "mithril-client-wasm" -version = "0.2.0" +version = "0.2.1" dependencies = [ "async-trait", "futures", @@ -3483,7 +3483,7 @@ dependencies = [ [[package]] name = "mithril-common" -version = "0.3.9" +version = "0.3.10" dependencies = [ "anyhow", "async-trait", @@ -3555,7 +3555,7 @@ dependencies = [ [[package]] name = "mithril-end-to-end" -version = "0.4.1" +version = "0.4.2" dependencies = [ "anyhow", "async-recursion", @@ -3604,7 +3604,7 @@ dependencies = [ [[package]] name = "mithril-relay" -version = "0.1.12" +version = "0.1.13" dependencies = [ "anyhow", "clap", @@ -3628,7 +3628,7 @@ dependencies = [ [[package]] name = "mithril-signer" -version = "0.2.110" +version = "0.2.111" dependencies = [ "anyhow", "async-trait", @@ -3682,7 +3682,7 @@ dependencies = [ [[package]] name = "mithrildemo" -version = "0.1.30" +version = "0.1.31" dependencies = [ "base64 0.21.7", "blake2 0.10.6", diff --git a/demo/protocol-demo/Cargo.toml b/demo/protocol-demo/Cargo.toml index f0aa347f682..4db58fc37c4 100644 --- a/demo/protocol-demo/Cargo.toml +++ b/demo/protocol-demo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithrildemo" -version = "0.1.30" +version = "0.1.31" authors = { workspace = true } edition = { workspace = true } documentation = { workspace = true } diff --git a/internal/mithril-build-script/Cargo.toml b/internal/mithril-build-script/Cargo.toml index 5dd19f5f9a1..f614abe1767 100644 --- a/internal/mithril-build-script/Cargo.toml +++ b/internal/mithril-build-script/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-build-script" -version = "0.1.0" +version = "0.1.1" description = "A toolbox for Mithril crates build scripts" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index 09e2c37706c..2f684350a98 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.4.41" +version = "0.4.42" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client-cli/Cargo.toml b/mithril-client-cli/Cargo.toml index 3f9357d4c5c..373624f84e6 100644 --- a/mithril-client-cli/Cargo.toml +++ b/mithril-client-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client-cli" -version = "0.7.1" +version = "0.7.2" description = "A Mithril Client" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client-wasm/Cargo.toml b/mithril-client-wasm/Cargo.toml index c43cafde7fb..db47d1db866 100644 --- a/mithril-client-wasm/Cargo.toml +++ b/mithril-client-wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client-wasm" -version = "0.2.0" +version = "0.2.1" description = "Mithril client WASM" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-common/Cargo.toml b/mithril-common/Cargo.toml index e019b943fe8..38f5a4b1ccb 100644 --- a/mithril-common/Cargo.toml +++ b/mithril-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-common" -version = "0.3.9" +version = "0.3.10" description = "Common types, interfaces, and utilities for Mithril nodes." authors = { workspace = true } edition = { workspace = true } @@ -92,7 +92,7 @@ slog-term = "2.9.0" tokio = { version = "1.35.1", features = ["macros", "time"] } [build-dependencies] -mithril-build-script = { path = "../internal/mithril-build-script", version = "=0.1.0" } +mithril-build-script = { path = "../internal/mithril-build-script", version = "=0.1.1" } [features] default = [] diff --git a/mithril-relay/Cargo.toml b/mithril-relay/Cargo.toml index a294206f413..e20fdf32e6f 100644 --- a/mithril-relay/Cargo.toml +++ b/mithril-relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-relay" -version = "0.1.12" +version = "0.1.13" description = "A Mithril relay" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-signer/Cargo.toml b/mithril-signer/Cargo.toml index 0686ce3c3ad..7d1add34927 100644 --- a/mithril-signer/Cargo.toml +++ b/mithril-signer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-signer" -version = "0.2.110" +version = "0.2.111" description = "A Mithril Signer" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml index a6e339e9a8f..22c253036e3 100644 --- a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml +++ b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator-fake" -version = "0.2.0" +version = "0.2.1" description = "Mithril Fake Aggregator for client testing" authors = { workspace = true } documentation = { workspace = true } diff --git a/mithril-test-lab/mithril-end-to-end/Cargo.toml b/mithril-test-lab/mithril-end-to-end/Cargo.toml index dcb1bf7a487..9b63be5a283 100644 --- a/mithril-test-lab/mithril-end-to-end/Cargo.toml +++ b/mithril-test-lab/mithril-end-to-end/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-end-to-end" -version = "0.4.1" +version = "0.4.2" authors = { workspace = true } edition = { workspace = true } documentation = { workspace = true } From 26f7b87eb8a8649510597f507052cd35510cb474 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:52:59 +0100 Subject: [PATCH 15/15] Simplify CI tests result by using download artifact v4 new capability Also rename the step to avoid confusion with crates/npm publication steps. --- .github/workflows/ci.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 506f91e871e..eefe4a3ded0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,9 +207,8 @@ jobs: uses: actions/upload-artifact@v4 if: success() || failure() with: - name: test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }} - path: | - ./test-results-*.xml + name: test-results-${{ runner.os }}-${{ runner.arch }} + path: ./test-results-*.xml check: runs-on: ubuntu-22.04 @@ -335,29 +334,18 @@ jobs: !./artifacts/devnet/cardano-node if-no-files-found: error - publish-tests-results: + send-tests-results: if: success() || failure() runs-on: ubuntu-22.04 needs: - test steps: - - name: Download Tests Results (${{ runner.os }}-${{ runner.arch }}) - if: success() || failure() - uses: actions/download-artifact@v4 - with: - name: test-results-${{ runner.os }}-${{ runner.arch }} - - - name: Download Tests Results (macOS-X64) - if: success() || failure() - uses: actions/download-artifact@v4 - with: - name: test-results-macOS-X64 - - - name: Download Tests Results (Windows-X64) + - name: Download Tests Results if: success() || failure() uses: actions/download-artifact@v4 with: - name: test-results-Windows-X64 + pattern: test-results-* + merge-multiple: true - name: Publish Unit Test Results if: success() || failure()