From a89815b64281ce676aaec9e4b5c9becf93b5f9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Fri, 3 Dec 2021 07:32:02 +0100 Subject: [PATCH] [refactor] #1661: `Cargo.toml` cleanup (#1670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * sort out cargo dependencies Signed-off-by: Marin Veršić * don't expose tracing as a dependency, use iroha_logger::prelude Signed-off-by: Marin Veršić --- Cargo.lock | 89 ++----- actor/Cargo.toml | 8 +- actor/derive/src/lib.rs | 2 +- cli/Cargo.toml | 3 +- client/Cargo.toml | 4 - client/src/client.rs | 2 +- client_cli/Cargo.toml | 3 - config/derive/Cargo.toml | 3 - core/Cargo.toml | 8 - core/src/block.rs | 8 +- core/src/block_sync.rs | 17 +- core/src/kura.rs | 9 +- core/src/smartcontracts/isi/account.rs | 2 +- core/src/smartcontracts/isi/asset.rs | 4 +- core/src/smartcontracts/isi/domain.rs | 2 +- core/src/smartcontracts/isi/mod.rs | 27 +- core/src/smartcontracts/isi/query.rs | 2 +- core/src/smartcontracts/isi/tx.rs | 5 +- core/src/sumeragi/mod.rs | 50 ++-- core/src/sumeragi/view_change.rs | 2 +- core/src/tx.rs | 4 +- core/src/wsv.rs | 5 +- core/test_network/Cargo.toml | 1 - crypto/Cargo.toml | 1 - data_model/Cargo.toml | 7 +- data_model/src/events.rs | 6 +- data_model/src/expression.rs | 2 +- data_model/src/isi.rs | 2 +- data_model/src/lib.rs | 11 +- data_model/src/query.rs | 20 +- data_model/src/transaction.rs | 10 +- futures/Cargo.toml | 9 +- futures/derive/Cargo.toml | 5 +- futures/derive/src/lib.rs | 2 +- logger/Cargo.toml | 2 - logger/src/lib.rs | 236 +++++++++--------- macro/Cargo.toml | 5 +- macro/README.md | 10 +- macro/derive/Cargo.toml | 7 +- macro/src/lib.rs | 7 +- p2p/Cargo.toml | 9 +- p2p/src/lib.rs | 2 +- p2p/src/network.rs | 2 +- p2p/tests/p2p.rs | 8 +- permissions_validators/Cargo.toml | 3 - schema/Cargo.toml | 11 +- schema/derive/Cargo.toml | 1 - telemetry/Cargo.toml | 9 +- version/Cargo.toml | 7 +- version/derive/Cargo.toml | 10 +- version/derive/src/lib.rs | 2 +- version/derive/tests/as_version.rs | 2 +- version/derive/tests/json.rs | 4 +- version/derive/tests/scale.rs | 4 +- .../tests/ui/ok_declare_several_vesrioned.rs | 4 +- .../derive/tests/ui/ok_declare_versioned.rs | 2 +- .../tests/ui/ok_declare_versioned_json.rs | 2 +- .../tests/ui/ok_declare_versioned_scale.rs | 2 +- version/src/lib.rs | 2 +- 59 files changed, 305 insertions(+), 383 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fad3a8603c..84b31c72ba0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,7 +425,7 @@ dependencies = [ "libc", "num-integer", "num-traits", - "time", + "time 0.1.43", "winapi", ] @@ -789,12 +789,6 @@ dependencies = [ "generic-array 0.14.4", ] -[[package]] -name = "dissimilar" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ad93652f40969dead8d4bf897a41e9462095152eb21c56e5830537e41179dd" - [[package]] name = "ecdsa" version = "0.12.4" @@ -1407,7 +1401,6 @@ dependencies = [ "iroha_permissions_validators", "structopt", "tokio", - "tracing", ] [[package]] @@ -1441,12 +1434,10 @@ dependencies = [ name = "iroha_client" version = "0.1.0" dependencies = [ - "async-trait", "attohttpc", "color-eyre", "criterion", "eyre", - "futures", "http", "iroha_config", "iroha_core", @@ -1461,9 +1452,7 @@ dependencies = [ "tempfile", "test_network", "tokio", - "tracing", "tungstenite", - "unique_port", ] [[package]] @@ -1478,7 +1467,6 @@ dependencies = [ "iroha_data_model", "serde_json", "structopt", - "tempfile", ] [[package]] @@ -1500,7 +1488,6 @@ dependencies = [ "proc-macro2", "quote", "syn", - "trybuild", ] [[package]] @@ -1510,19 +1497,16 @@ dependencies = [ "async-stream", "async-trait", "byte-unit", - "chrono", "criterion", "crossbeam-queue", "dashmap", "eyre", "futures", "hex", - "hex-literal", "iroha_actor", "iroha_config", "iroha_crypto", "iroha_data_model", - "iroha_derive", "iroha_futures", "iroha_logger", "iroha_macro", @@ -1538,12 +1522,9 @@ dependencies = [ "serde_json", "structopt", "tempfile", - "test_network", "thiserror", "tokio", "tokio-stream", - "tracing", - "unique_port", "warp", ] @@ -1578,7 +1559,6 @@ dependencies = [ name = "iroha_data_model" version = "0.1.0" dependencies = [ - "chrono", "dashmap", "eyre", "fixnum", @@ -1586,16 +1566,12 @@ dependencies = [ "iroha_client", "iroha_core", "iroha_crypto", - "iroha_derive", - "iroha_logger", "iroha_macro", "iroha_schema", "iroha_version", "parity-scale-codec", - "port_check", "serde", "serde_json", - "tempfile", "test_network", "thiserror", "tokio", @@ -1607,10 +1583,8 @@ dependencies = [ name = "iroha_derive" version = "0.1.0" dependencies = [ - "iroha_logger", "iroha_macro", "parity-scale-codec", - "proc-macro-error", "proc-macro2", "quote", "syn", @@ -1648,16 +1622,13 @@ dependencies = [ "proc-macro2", "quote", "syn", - "trybuild", ] [[package]] name = "iroha_logger" version = "0.1.0" dependencies = [ - "chrono", "color-eyre", - "crossbeam", "iroha_config", "once_cell", "serde", @@ -1675,7 +1646,7 @@ name = "iroha_macro" version = "0.1.0" dependencies = [ "eyre", - "parity-scale-codec", + "iroha_derive", ] [[package]] @@ -1685,21 +1656,17 @@ dependencies = [ "aead", "async-stream", "async-trait", - "eyre", "futures", "iroha_actor", "iroha_config", "iroha_crypto", "iroha_data_model", - "iroha_derive", "iroha_logger", "iroha_macro", "parity-scale-codec", "rand 0.7.3", - "serde", "thiserror", "tokio", - "tracing", "unique_port", ] @@ -1710,7 +1677,6 @@ dependencies = [ "iroha_core", "iroha_data_model", "iroha_macro", - "maplit", ] [[package]] @@ -1721,8 +1687,6 @@ dependencies = [ "iroha_schema_derive", "parity-scale-codec", "serde", - "serde_json", - "trybuild", ] [[package]] @@ -1740,7 +1704,6 @@ dependencies = [ name = "iroha_schema_derive" version = "0.0.0" dependencies = [ - "parity-scale-codec", "proc-macro2", "quote", "syn", @@ -1768,7 +1731,6 @@ dependencies = [ "tokio", "tokio-stream", "tokio-tungstenite", - "tracing", "url", "vergen", ] @@ -1778,9 +1740,7 @@ name = "iroha_version" version = "0.1.0" dependencies = [ "eyre", - "iroha_derive", "iroha_macro", - "iroha_schema", "iroha_version_derive", "parity-scale-codec", "serde", @@ -1793,7 +1753,6 @@ dependencies = [ name = "iroha_version_derive" version = "0.1.0" dependencies = [ - "iroha_derive", "iroha_macro", "iroha_version", "parity-scale-codec", @@ -1902,12 +1861,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "matches" version = "0.1.9" @@ -2287,12 +2240,6 @@ dependencies = [ "universal-hash", ] -[[package]] -name = "port_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6519412c9e0d4be579b9f0618364d19cb434b324fc6ddb1b27b1e682c7105ed" - [[package]] name = "ppv-lite86" version = "0.2.14" @@ -3035,7 +2982,6 @@ name = "test_network" version = "0.1.0" dependencies = [ "async-trait", - "color-eyre", "eyre", "futures", "hex-literal", @@ -3102,6 +3048,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" +dependencies = [ + "itoa", + "libc", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -3129,9 +3085,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.12.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" +checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" dependencies = [ "autocfg 1.0.1", "bytes", @@ -3146,9 +3102,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd" +checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e" dependencies = [ "proc-macro2", "quote", @@ -3246,15 +3202,15 @@ dependencies = [ [[package]] name = "tracing-bunyan-formatter" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0814e45b1ba02f79418d90107acc44ae55dceb0623d40f4ee7d981b5e1984869" +checksum = "1cb2ad6aa9b1c637d84c54db002275bbf72a7f3c6fed80f8b33f5af0c39027e9" dependencies = [ - "chrono", "gethostname", "log", "serde", "serde_json", + "time 0.3.5", "tracing", "tracing-core", "tracing-log", @@ -3336,7 +3292,6 @@ version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbaccfa9796293406a02ec790614628c88d0b3246249a620ac1ee7076274716b" dependencies = [ - "dissimilar", "glob", "lazy_static", "serde", @@ -3494,7 +3449,7 @@ dependencies = [ "sha2", "sha3 0.9.1", "subtle", - "time", + "time 0.1.43", "x25519-dalek", "zeroize", ] @@ -3525,9 +3480,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "vergen" -version = "5.1.16" +version = "5.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b62d4fc8fc9c81d139c8106b9f4e583e7c1eb36e320dc28d5c03aab86729495" +checksum = "1d48696c0fbbdafd9553e14c4584b4b9583931e9474a3ae506f1872b890d0b47" dependencies = [ "anyhow", "cfg-if", diff --git a/actor/Cargo.toml b/actor/Cargo.toml index 3b05e658acf..be85efffd66 100644 --- a/actor/Cargo.toml +++ b/actor/Cargo.toml @@ -11,18 +11,18 @@ default = [] deadlock_detection = ["petgraph"] [dependencies] +iroha_actor_derive = { path = "derive" } +iroha_logger = { path = "../logger" } + async-trait = "0.1" once_cell = "1.8.0" dashmap = "4" eyre = "0.6.5" futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } -iroha_actor_derive = { path = "derive" } -tokio = { version = "1.6.0", features = ["sync", "time", "rt", "io-util", "rt-multi-thread"]} -iroha_logger = { path = "../logger" } +tokio = { version = "1.6.0", features = ["sync", "time", "rt", "rt-multi-thread", "macros"]} thiserror = "1.0.28" petgraph = { version = "0.5", optional = true } [dev-dependencies] trybuild = "1" -tokio = { version = "1.6.0", features = ["macros"]} diff --git a/actor/derive/src/lib.rs b/actor/derive/src/lib.rs index 7c22157b624..d27a51d2b31 100644 --- a/actor/derive/src/lib.rs +++ b/actor/derive/src/lib.rs @@ -1,4 +1,4 @@ -//! Module with actor derive macroses +//! Module with actor derive macros use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9a7cc074fa5..3733bfeb91f 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -31,5 +31,4 @@ iroha_logger = { version = "=0.1.0", path = "../logger"} color-eyre = "0.5.11" structopt = "0.3" -tracing = "0.1" -tokio = { version = "1.6.0", features = ["sync", "time", "rt", "io-util", "rt-multi-thread", "macros", "fs"]} +tokio = { version = "1.6.0", features = ["rt", "rt-multi-thread"]} diff --git a/client/Cargo.toml b/client/Cargo.toml index 25399275d86..744e20515b7 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -29,7 +29,6 @@ http = "0.2.1" rand = "0.7.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tracing = "0.1" tungstenite = { version = "0.12.0", features = ["tls-vendored"] } [dev-dependencies] @@ -37,12 +36,9 @@ iroha_core = { path = "../core", features = ["dev-telemetry", "telemetry"] } iroha_permissions_validators = { version = "=0.1.0", path = "../permissions_validators" } test_network = { path = "../core/test_network" } -async-trait = "0.1.31" color-eyre = "0.5.11" criterion = "0.3" -futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } tempfile = "3" -unique_port = "0.1.0" tokio = { version = "1.6.0", features = ["rt", "rt-multi-thread"]} [[bench]] diff --git a/client/src/client.rs b/client/src/client.rs index fa8807ff48f..9b6dacd9f87 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -15,7 +15,7 @@ use http_client::WebSocketStream; use iroha_config::{GetConfiguration, PostConfiguration}; use iroha_crypto::{HashOf, KeyPair}; use iroha_data_model::prelude::*; -use iroha_logger::log; +use iroha_logger::prelude::*; use iroha_version::prelude::*; use rand::Rng; use serde::de::DeserializeOwned; diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index 5d5d39c0f0c..23b57a94877 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -26,6 +26,3 @@ structopt = "0.3" futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } dialoguer = "0.8" serde_json = "1.0" - -[dev-dependencies] -tempfile = "3" diff --git a/config/derive/Cargo.toml b/config/derive/Cargo.toml index 86fc5a7c47b..adf342efe2b 100644 --- a/config/derive/Cargo.toml +++ b/config/derive/Cargo.toml @@ -12,6 +12,3 @@ syn = { version = "1.0", features = ["parsing", "full"] } quote = "1.0" proc-macro2 = "1.0" proc-macro-error = "1.0" - -[dev-dependencies] -trybuild = "1.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index 29a97ed0540..cdf8aff0db0 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -27,7 +27,6 @@ maintenance = { status = "actively-developed" } [dependencies] iroha_data_model = { path = "../data_model", features = ["warp"] } -iroha_derive = { version = "=0.1.0", path = "../macro/derive" } iroha_macro = { version = "=0.1.0", path = "../macro" } iroha_p2p = { version = "=0.1.0", path = "../p2p" } iroha_logger = { version = "=0.1.0", path = "../logger"} @@ -41,7 +40,6 @@ iroha_schema = { path = "../schema" } async-trait = "0.1" async-stream = "0.3.2" -chrono = "0.4" dashmap = { version = "4.0" } eyre = "0.6.5" futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } @@ -51,22 +49,16 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.6.0", features = ["sync", "time", "rt", "io-util", "rt-multi-thread", "macros", "fs"]} tokio-stream = { version = "0.1.6", features = ["fs"]} -tracing = "0.1" crossbeam-queue = "0.3" warp = "0.3" structopt = { version = "0.3", optional = true } thiserror = "1.0.28" pin-project = "1" - [dev-dependencies] -test_network = { version = "=0.1.0", path = "./test_network" } - -hex-literal = "0.3.4" tempfile = "3" criterion = "0.3" hex = "0.4.0" -unique_port = "0.1.0" byte-unit = "4.0.12" once_cell = "1.8.0" diff --git a/core/src/block.rs b/core/src/block.rs index 3a015048a19..28f983ec1e8 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -11,7 +11,7 @@ use iroha_crypto::{HashOf, KeyPair, SignatureOf, SignaturesOf}; use iroha_data_model::{ current_time, events::prelude::*, merkle::MerkleTree, transaction::prelude::*, }; -use iroha_derive::Io; +use iroha_macro::Io; use iroha_schema::IntoSchema; use iroha_version::{declare_versioned_with_scale, version_with_scale}; use parity_scale_codec::{Decode, Encode}; @@ -155,7 +155,7 @@ impl<'a> DoubleEndedIterator for ChainIterator<'a> { } } -declare_versioned_with_scale!(VersionedPendingBlock 1..2, Debug, Clone, iroha_derive::FromVariant); +declare_versioned_with_scale!(VersionedPendingBlock 1..2, Debug, Clone, iroha_macro::FromVariant); /// Transaction data is permanently recorded in files called blocks. Blocks are organized into /// a linear sequence over time (also known as the block chain). @@ -332,7 +332,7 @@ impl ChainedBlock { } } -declare_versioned_with_scale!(VersionedValidBlock 1..2, Debug, Clone, iroha_derive::FromVariant, IntoSchema); +declare_versioned_with_scale!(VersionedValidBlock 1..2, Debug, Clone, iroha_macro::FromVariant, IntoSchema); impl VersionedValidBlock { /// Same as [`as_v1`](`VersionedValidBlock::as_v1()`) but also does conversion @@ -618,7 +618,7 @@ impl From<&ValidBlock> for Vec { } } -declare_versioned_with_scale!(VersionedCommittedBlock 1..2, Debug, Clone, iroha_derive::FromVariant, IntoSchema); +declare_versioned_with_scale!(VersionedCommittedBlock 1..2, Debug, Clone, iroha_macro::FromVariant, IntoSchema); impl VersionedCommittedBlock { /// Same as [`as_v1`](`VersionedCommittedBlock::as_v1()`) but also does conversion diff --git a/core/src/block_sync.rs b/core/src/block_sync.rs index 3c868c4c818..e0b790f4c21 100644 --- a/core/src/block_sync.rs +++ b/core/src/block_sync.rs @@ -5,6 +5,7 @@ use std::{fmt::Debug, sync::Arc, time::Duration}; use iroha_actor::{broker::*, prelude::*, Context}; use iroha_crypto::SignatureOf; use iroha_data_model::prelude::*; +use iroha_logger::prelude::*; use rand::{prelude::SliceRandom, SeedableRng}; use self::{ @@ -158,7 +159,7 @@ impl BlockSynchronizer { return; }; - iroha_logger::info!(blocks_left = blocks.len(), "Synchronizing blocks"); + info!(blocks_left = blocks.len(), "Synchronizing blocks"); let (block, blocks) = if let Some((block, blocks)) = blocks.split_first() { (block, blocks) @@ -197,7 +198,7 @@ impl BlockSynchronizer { .do_send(CommitBlock(block.clone().into())) .await; } else { - iroha_logger::warn!(block_hash = %block.hash(), "Failed to commit a block received via synchronization request - validation failed"); + warn!(block_hash = %block.hash(), "Failed to commit a block received via synchronization request - validation failed"); self.state = State::Idle; } } @@ -208,8 +209,8 @@ pub mod message { use iroha_actor::broker::Broker; use iroha_crypto::*; use iroha_data_model::prelude::*; - use iroha_derive::*; - use iroha_logger::log; + use iroha_logger::prelude::*; + use iroha_macro::*; use iroha_p2p::Post; use iroha_version::prelude::*; use parity_scale_codec::{Decode, Encode}; @@ -219,7 +220,7 @@ pub mod message { block::VersionedCommittedBlock, sumeragi::SumeragiTrait, wsv::WorldTrait, NetworkMessage, }; - declare_versioned_with_scale!(VersionedMessage 1..2, Debug, Clone, iroha_derive::FromVariant, iroha_actor::Message); + declare_versioned_with_scale!(VersionedMessage 1..2, Debug, Clone, iroha_macro::FromVariant, iroha_actor::Message); impl VersionedMessage { /// Same as [`as_v1`](`VersionedMessage::as_v1()`) but also does conversion @@ -296,9 +297,7 @@ pub mod message { match self { Message::GetBlocksAfter(GetBlocksAfter { hash, peer_id }) => { if block_sync.batch_size == 0 { - iroha_logger::warn!( - "Error: not sending any blocks as batch_size is equal to zero." - ); + warn!("Error: not sending any blocks as batch_size is equal to zero."); return; } if *hash == block_sync.wsv.latest_block_hash() { @@ -307,7 +306,7 @@ pub mod message { let blocks = block_sync.wsv.blocks_after(*hash, block_sync.batch_size); if blocks.is_empty() { - iroha_logger::warn!(%hash, "Block hash not found"); + warn!(%hash, "Block hash not found"); } else { Message::ShareBlocks(ShareBlocks::new(blocks, block_sync.peer_id.clone())) .send_to(block_sync.broker.clone(), peer_id.clone()) diff --git a/core/src/kura.rs b/core/src/kura.rs index 3fca17f7802..9f8555f487d 100644 --- a/core/src/kura.rs +++ b/core/src/kura.rs @@ -16,6 +16,7 @@ use futures::{Stream, StreamExt, TryStreamExt}; use iroha_actor::{broker::*, prelude::*}; use iroha_crypto::HashOf; use iroha_data_model::merkle::MerkleTree; +use iroha_logger::prelude::*; use iroha_version::scale::{DecodeVersioned, EncodeVersioned}; use pin_project::pin_project; use serde::{Deserialize, Serialize}; @@ -180,7 +181,7 @@ impl Actor for KuraWithIO { .await; } Err(error) => { - iroha_logger::error!(%error, "Initialization of kura failed"); + error!(%error, "Initialization of kura failed"); panic!("Kura initialization failed"); } } @@ -209,7 +210,7 @@ impl Handler for KuraWithIO { iroha_logger::telemetry!(msg = iroha_telemetry::msg::SYSTEM_CONNECTED, genesis_hash = %block.hash()); } if let Err(error) = self.store(block).await { - iroha_logger::error!(%error, "Failed to write block") + error!(%error, "Failed to write block") } } } @@ -237,7 +238,7 @@ impl KuraWithIO { /// Methods consumes new validated block and atomically stores and caches it. #[iroha_futures::telemetry_future] - #[iroha_logger::log("INFO", skip(self, block))] + #[log("INFO", skip(self, block))] pub async fn store( &mut self, block: VersionedCommittedBlock, @@ -246,7 +247,7 @@ impl KuraWithIO { Ok(block_hash) => { self.merkle_tree = self.merkle_tree.add(block_hash); if let Err(error) = self.wsv.apply(block).await { - iroha_logger::warn!(%error, %block_hash, "Failed to apply block on WSV"); + warn!(%error, %block_hash, "Failed to apply block on WSV"); } self.broker.issue_send(UpdateNetworkTopology).await; self.broker.issue_send(ContinueSync).await; diff --git a/core/src/smartcontracts/isi/account.rs b/core/src/smartcontracts/isi/account.rs index 0c35573318f..566a77b3665 100644 --- a/core/src/smartcontracts/isi/account.rs +++ b/core/src/smartcontracts/isi/account.rs @@ -156,7 +156,7 @@ pub mod isi { pub mod query { use eyre::{eyre, Result, WrapErr}; - use iroha_logger::log; + use iroha_logger::prelude::*; use super::{super::Evaluate, *}; use crate::smartcontracts::isi::prelude::WorldTrait; diff --git a/core/src/smartcontracts/isi/asset.rs b/core/src/smartcontracts/isi/asset.rs index 05516193d8f..a43c46251eb 100644 --- a/core/src/smartcontracts/isi/asset.rs +++ b/core/src/smartcontracts/isi/asset.rs @@ -12,7 +12,7 @@ use crate::prelude::*; /// - transfer, etc. pub mod isi { use eyre::eyre; - use iroha_logger::log; + use iroha_logger::prelude::*; use super::*; @@ -274,7 +274,7 @@ pub mod isi { /// Query module provides [`Query`] Asset related implementations. pub mod query { use eyre::{eyre, Result, WrapErr}; - use iroha_logger::log; + use iroha_logger::prelude::*; use super::*; diff --git a/core/src/smartcontracts/isi/domain.rs b/core/src/smartcontracts/isi/domain.rs index 67f14536817..0a8e197caf3 100644 --- a/core/src/smartcontracts/isi/domain.rs +++ b/core/src/smartcontracts/isi/domain.rs @@ -204,7 +204,7 @@ pub mod isi { /// Query module provides [`Query`] Domain related implementations. pub mod query { use eyre::{Result, WrapErr}; - use iroha_logger::log; + use iroha_logger::prelude::*; use super::*; diff --git a/core/src/smartcontracts/isi/mod.rs b/core/src/smartcontracts/isi/mod.rs index d10cb9a52c1..a8785807232 100644 --- a/core/src/smartcontracts/isi/mod.rs +++ b/core/src/smartcontracts/isi/mod.rs @@ -17,7 +17,8 @@ use std::{ use eyre::{eyre, Result}; use iroha_crypto::HashOf; use iroha_data_model::{expression::prelude::*, isi::*, prelude::*}; -use iroha_derive::FromVariant; +use iroha_logger::prelude::*; +use iroha_macro::FromVariant; use thiserror::Error; use super::{Evaluate, Execute}; @@ -164,7 +165,7 @@ impl Execute for Instruction { impl Execute for RegisterBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -190,7 +191,7 @@ impl Execute for RegisterBox { impl Execute for UnregisterBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -216,7 +217,7 @@ impl Execute for UnregisterBox { impl Execute for MintBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -251,7 +252,7 @@ impl Execute for MintBox { impl Execute for BurnBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -279,7 +280,7 @@ impl Execute for BurnBox { impl Execute for TransferBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -309,7 +310,7 @@ impl Execute for TransferBox { impl Execute for SetKeyValueBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -342,7 +343,7 @@ impl Execute for SetKeyValueBox { impl Execute for RemoveKeyValueBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -369,7 +370,7 @@ impl Execute for RemoveKeyValueBox { impl Execute for If { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -388,7 +389,7 @@ impl Execute for If { impl Execute for Pair { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -403,7 +404,7 @@ impl Execute for Pair { impl Execute for SequenceBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, @@ -419,7 +420,7 @@ impl Execute for SequenceBox { impl Execute for FailBox { type Error = Error; - #[iroha_logger::log(skip(_authority, _wsv))] + #[log(skip(_authority, _wsv))] fn execute( self, _authority: ::Id, @@ -432,7 +433,7 @@ impl Execute for FailBox { impl Execute for GrantBox { type Error = Error; - #[iroha_logger::log] + #[log] fn execute( self, authority: ::Id, diff --git a/core/src/smartcontracts/isi/query.rs b/core/src/smartcontracts/isi/query.rs index ff6e2cabe64..91d5ece9186 100644 --- a/core/src/smartcontracts/isi/query.rs +++ b/core/src/smartcontracts/isi/query.rs @@ -5,7 +5,7 @@ use std::{convert::TryFrom, error::Error as StdError, fmt}; use eyre::{eyre, Result}; use iroha_crypto::SignatureOf; use iroha_data_model::{prelude::*, query}; -use iroha_derive::Io; +use iroha_macro::Io; use iroha_version::{scale::DecodeVersioned, Version}; use parity_scale_codec::{Decode, Encode}; use thiserror::Error; diff --git a/core/src/smartcontracts/isi/tx.rs b/core/src/smartcontracts/isi/tx.rs index 03bac798755..83b7ecde9ab 100644 --- a/core/src/smartcontracts/isi/tx.rs +++ b/core/src/smartcontracts/isi/tx.rs @@ -2,11 +2,12 @@ use eyre::{Result, WrapErr}; use iroha_data_model::prelude::*; +use iroha_logger::prelude::*; use super::*; impl ValidQuery for FindTransactionsByAccountId { - #[iroha_logger::log] + #[log] fn execute(&self, wsv: &WorldStateView) -> Result { let id = self .account_id @@ -17,7 +18,7 @@ impl ValidQuery for FindTransactionsByAccountId { } impl ValidQuery for FindTransactionByHash { - #[iroha_logger::log] + #[log] fn execute(&self, wsv: &WorldStateView) -> Result { let hash = self .hash diff --git a/core/src/sumeragi/mod.rs b/core/src/sumeragi/mod.rs index 020a0e794a2..d40a8c987cb 100644 --- a/core/src/sumeragi/mod.rs +++ b/core/src/sumeragi/mod.rs @@ -15,7 +15,7 @@ use futures::{prelude::*, stream::FuturesUnordered}; use iroha_actor::{broker::*, prelude::*, Context}; use iroha_crypto::{HashOf, KeyPair}; use iroha_data_model::prelude::*; -use iroha_logger::Instrument; +use iroha_logger::{prelude::*, Instrument}; use iroha_p2p::{ConnectPeer, DisconnectPeer}; use network_topology::{Role, Topology}; use rand::prelude::SliceRandom; @@ -273,9 +273,9 @@ impl Handler Handler for Sumeragi { type Result = (); async fn handle(&mut self, msg: Message) { - iroha_logger::trace!(peer_role=?self.topology.role(&self.peer_id), ?msg); + trace!(peer_role=?self.topology.role(&self.peer_id), ?msg); if let Err(error) = msg.handle(&mut self).await { - iroha_logger::error!(%error, "Handle message failed"); + error!(%error, "Handle message failed"); } } } @@ -289,7 +289,7 @@ impl Handler for Su } let txs = self.queue.get_transactions_for_block(&*self.wsv); if let Err(error) = self.round(txs).await { - iroha_logger::error!(%error, "Round failed"); + error!(%error, "Round failed"); } } } @@ -347,7 +347,7 @@ impl ContextHandler { type Result = (); async fn handle(&mut self, ctx: &mut Context, Init { last_block, height }: Init) { - iroha_logger::info!("Starting Sumeragi"); + info!("Starting Sumeragi"); self.connect_peers().await; if height != 0 && *last_block != Hash([0; 32]) { @@ -355,7 +355,7 @@ impl ContextHandler } else if let Some(genesis_network) = self.genesis_network.take() { let addr = self.network.clone(); if let Err(error) = genesis_network.submit_transactions(&mut self, addr).await { - iroha_logger::error!(%error, "Failed to submit genesis transactions") + error!(%error, "Failed to submit genesis transactions") } } self.update_network_topology().await; @@ -494,7 +494,7 @@ impl Sumeragi { /// * peer is not leader /// * there are already some blocks in blockchain #[iroha_futures::telemetry_future] - #[iroha_logger::log(skip(self, transactions, genesis_topology))] + #[log(skip(self, transactions, genesis_topology))] pub async fn start_genesis_round( &mut self, transactions: Vec, @@ -566,7 +566,7 @@ impl Sumeragi { // Without this `if` depending on the round time, the peers might DOS themselves. continue; } - iroha_logger::info!( + info!( peer_addr = %self.peer_id.address, peer_role = ?self.topology.role(&self.peer_id), leader_addr = %self.topology.leader().address, @@ -606,7 +606,7 @@ impl Sumeragi { async move { time::sleep(tx_receipt_time).await; if txs_awaiting_receipts.contains_key(&tx_hash) { - iroha_logger::warn!( + warn!( %tx_hash, "Transaction receipt timeout detected!", ); @@ -650,7 +650,7 @@ impl Sumeragi { return; } - iroha_logger::debug!( + debug!( peer_role = ?self.topology.role(&self.peer_id), tx_count = txs.len(), "Gossiping transactions" @@ -675,13 +675,13 @@ impl Sumeragi { &self.is_query_allowed, ); let network_topology = self.network_topology_current_or_genesis(block.header()); - iroha_logger::info!( + info!( peer_role = ?network_topology.role(&self.peer_id), block_hash = %block.hash(), "Created a block", ); for event in Vec::::from(&block) { - iroha_logger::info!(?event); + info!(?event); drop(self.events_sender.send(event)); } if !network_topology.is_consensus_required() { @@ -704,7 +704,7 @@ impl Sumeragi { /// Starts countdown for a period in which the `voting_block` should be committed. #[iroha_futures::telemetry_future] - #[iroha_logger::log(skip(self, voting_block))] + #[log(skip(self, voting_block))] pub async fn start_commit_countdown( &self, voting_block: VotingBlock, @@ -738,7 +738,7 @@ impl Sumeragi { return; } - iroha_logger::warn!( + warn!( block_hash = %voting_block.block.hash(), "Block commit timeout detected!", ); @@ -761,7 +761,7 @@ impl Sumeragi { } /// Commits `ValidBlock` and changes the state of the `Sumeragi` and its `NetworkTopology`. - #[iroha_logger::log(skip(self, block))] + #[log(skip(self, block))] #[iroha_futures::telemetry_future] pub async fn commit_block(&mut self, block: VersionedValidBlock) { self.invalidated_blocks_hashes.clear(); @@ -773,7 +773,7 @@ impl Sumeragi { let block_hash = block.hash(); for event in Vec::::from(&block) { - iroha_logger::info!(?event); + info!(?event); drop(self.events_sender.send(event)); } @@ -781,7 +781,7 @@ impl Sumeragi { let previous_role = self.topology.role(&self.peer_id); self.topology.apply_block(block_hash); - iroha_logger::info!( + info!( prev_peer_role = ?previous_role, new_peer_role = ?self.topology.role(&self.peer_id), new_block_height = %self.block_height, @@ -806,7 +806,7 @@ impl Sumeragi { } self.topology.apply_view_change(proof.clone()); *self.voting_block.write().await = None; - iroha_logger::info!( + info!( peer_addr = %self.peer_id.address, prev_peer_role = ?previous_role, new_peer_role = ?self.topology.role(&self.peer_id), @@ -826,7 +826,7 @@ impl Sumeragi { pub fn network_topology_current_or_genesis(&self, header: &BlockHeader) -> Topology { if header.is_genesis() && self.block_height == 0 { if let Some(genesis_topology) = &header.genesis_topology { - iroha_logger::info!("Using network topology from genesis block"); + info!("Using network topology from genesis block"); return genesis_topology.clone(); } } @@ -836,7 +836,7 @@ impl Sumeragi { /// Connects or disconnects peers according to the current network topology. pub async fn connect_peers(&self) { - iroha_logger::trace!("Connecting peers..."); + trace!("Connecting peers..."); let peers_expected = { let mut res = self.topology.sorted_peers().to_owned(); res.retain(|id| id.address != self.peer_id.address); @@ -856,7 +856,7 @@ impl Sumeragi { .iter() .filter(|id| !peers_online.contains(&id.public_key)) { - iroha_logger::info!(%peer_to_be_connected.address, "Connecting peer"); + info!(%peer_to_be_connected.address, "Connecting peer"); self.broker .issue_send(ConnectPeer { address: peer_to_be_connected.address.clone(), @@ -866,7 +866,7 @@ impl Sumeragi { for peer_to_be_disconnected in peers_online.difference(&peers_expected.into_iter().map(|id| id.public_key).collect()) { - iroha_logger::info!(%peer_to_be_disconnected, "Disconnecting peer"); + info!(%peer_to_be_disconnected, "Disconnecting peer"); self.broker .issue_send(DisconnectPeer(peer_to_be_disconnected.clone())) .await @@ -921,8 +921,8 @@ pub mod message { use iroha_actor::broker::Broker; use iroha_crypto::{HashOf, KeyPair, SignatureOf}; use iroha_data_model::prelude::*; - use iroha_derive::*; - use iroha_logger::Instrument; + use iroha_logger::{prelude::*, Instrument}; + use iroha_macro::*; use iroha_p2p::Post; use iroha_schema::IntoSchema; use iroha_version::prelude::*; @@ -939,7 +939,7 @@ pub mod message { VersionedAcceptedTransaction, VersionedValidBlock, }; - declare_versioned_with_scale!(VersionedMessage 1..2, Debug, Clone, iroha_derive::FromVariant, iroha_actor::Message); + declare_versioned_with_scale!(VersionedMessage 1..2, Debug, Clone, iroha_macro::FromVariant, iroha_actor::Message); impl VersionedMessage { /// Same as [`as_v1`](`VersionedMessage::as_v1()`) but also does conversion diff --git a/core/src/sumeragi/view_change.rs b/core/src/sumeragi/view_change.rs index f81e867befe..d192b94f985 100644 --- a/core/src/sumeragi/view_change.rs +++ b/core/src/sumeragi/view_change.rs @@ -6,7 +6,7 @@ use std::{collections::HashSet, fmt::Display}; use eyre::{Context, Result}; use iroha_crypto::{HashOf, KeyPair, PublicKey, SignatureOf, SignaturesOf}; use iroha_data_model::{prelude::PeerId, transaction::VersionedTransaction}; -use iroha_derive::*; +use iroha_macro::*; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; diff --git a/core/src/tx.rs b/core/src/tx.rs index 78699148ac3..fbef3d5ad16 100644 --- a/core/src/tx.rs +++ b/core/src/tx.rs @@ -7,7 +7,7 @@ use std::{cmp::min, time::Duration}; use eyre::{Result, WrapErr}; use iroha_crypto::SignaturesOf; pub use iroha_data_model::prelude::*; -use iroha_derive::Io; +use iroha_macro::Io; use iroha_version::{declare_versioned_with_scale, version_with_scale}; use parity_scale_codec::{Decode, Encode}; @@ -20,7 +20,7 @@ use crate::{ wsv::WorldTrait, }; -declare_versioned_with_scale!(VersionedAcceptedTransaction 1..2, Debug, Clone, iroha_derive::FromVariant); +declare_versioned_with_scale!(VersionedAcceptedTransaction 1..2, Debug, Clone, iroha_macro::FromVariant); impl VersionedAcceptedTransaction { /// Same as [`as_v1`](`VersionedAcceptedTransaction::as_v1()`) but also does conversion diff --git a/core/src/wsv.rs b/core/src/wsv.rs index 912065554f7..15f37c51a67 100644 --- a/core/src/wsv.rs +++ b/core/src/wsv.rs @@ -15,6 +15,7 @@ use dashmap::{ use eyre::Result; use iroha_crypto::HashOf; use iroha_data_model::{domain::DomainsMap, peer::PeersIds, prelude::*}; +use iroha_logger::prelude::*; use tokio::task; use crate::{ @@ -123,7 +124,7 @@ impl WorldStateView { for block in blocks { #[allow(clippy::panic)] if let Err(error) = self.apply(block).await { - iroha_logger::error!(%error, "Initialization of WSV failed"); + error!(%error, "Initialization of WSV failed"); panic!("WSV initialization failed"); } } @@ -152,7 +153,7 @@ impl WorldStateView { /// # Errors /// Can fail if execution of instruction fails(should be fine after validation) #[iroha_futures::telemetry_future] - #[iroha_logger::log(skip(self, block))] + #[log(skip(self, block))] pub async fn apply(&self, block: VersionedCommittedBlock) -> Result<()> { for tx in &block.as_inner_v1().transactions { let account_id = &tx.payload().account_id; diff --git a/core/test_network/Cargo.toml b/core/test_network/Cargo.toml index 70f1ed83efa..b94e9f41a6e 100644 --- a/core/test_network/Cargo.toml +++ b/core/test_network/Cargo.toml @@ -29,5 +29,4 @@ futures = { version = "0.3.17", default-features = false, features = ["std", "as iroha_crypto = { path = "../../crypto" } async-trait = "0.1" -color-eyre = "0.5.11" once_cell = "1.8.0" diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index 8e1507bd58f..9aab17c8408 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -20,4 +20,3 @@ ursa = "=0.3.7" [dev-dependencies] hex-literal = "0.3.4" -serde_json = "1.0" diff --git a/data_model/Cargo.toml b/data_model/Cargo.toml index 6222c949327..ee1fecf5686 100644 --- a/data_model/Cargo.toml +++ b/data_model/Cargo.toml @@ -23,14 +23,12 @@ test = [] [dependencies] iroha_crypto = { path = "../crypto" } -iroha_derive = { version = "=0.1.0", path = "../macro/derive" } iroha_macro = { version = "=0.1.0", path = "../macro" } iroha_schema = { path = "../schema"} -iroha_version = { version = "=0.1.0", path = "../version", features = ["warp"] } +iroha_version = { version = "=0.1.0", path = "../version", features = ["warp", "derive"] } eyre = "0.6.5" fixnum = { version = "0.6", features = ["i64"]} -chrono = "0.4" dashmap = { version = "4.0" } parity-scale-codec = { version = "2", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } @@ -42,11 +40,8 @@ warp = { version = "0.3", default-features = false, optional = true } [dev-dependencies] iroha_core = { path = "../core" } iroha_client = { version = "=0.1.0", path = "../client" } -iroha_logger = { version = "=0.1.0", path = "../logger" } hex-literal = { version = "0.3.4" } test_network = { path = "../core/test_network" } -port_check = "0.1.5" -tempfile = "3" tokio = { version = "1.6.0", features = ["rt", "rt-multi-thread"]} trybuild = "1" diff --git a/data_model/src/events.rs b/data_model/src/events.rs index 09eee6bb45c..d278357166d 100644 --- a/data_model/src/events.rs +++ b/data_model/src/events.rs @@ -1,7 +1,7 @@ //! Events for streaming API. #![allow(clippy::unused_self)] -use iroha_derive::FromVariant; +use iroha_macro::FromVariant; use iroha_schema::prelude::*; use iroha_version::prelude::*; use parity_scale_codec::{Decode, Encode}; @@ -91,7 +91,7 @@ impl EventFilter { /// Events of data entities. pub mod data { - use iroha_derive::FromVariant; + use iroha_macro::FromVariant; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -189,7 +189,7 @@ pub mod pipeline { }; use iroha_crypto::{Hash, SignatureVerificationFail}; - use iroha_derive::FromVariant; + use iroha_macro::FromVariant; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/data_model/src/expression.rs b/data_model/src/expression.rs index 82c42fb3fbe..7bd6c061e65 100644 --- a/data_model/src/expression.rs +++ b/data_model/src/expression.rs @@ -16,7 +16,7 @@ use std::{ }; use eyre::{eyre, Result}; -use iroha_derive::FromVariant; +use iroha_macro::FromVariant; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/data_model/src/isi.rs b/data_model/src/isi.rs index 4ed22643357..e5f4f806c33 100644 --- a/data_model/src/isi.rs +++ b/data_model/src/isi.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; -use iroha_derive::FromVariant; +use iroha_macro::FromVariant; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/data_model/src/lib.rs b/data_model/src/lib.rs index fc866a72d07..5ad5fb934a1 100644 --- a/data_model/src/lib.rs +++ b/data_model/src/lib.rs @@ -13,8 +13,7 @@ use std::{ use eyre::{eyre, Result, WrapErr}; use iroha_crypto::{Hash, PublicKey}; -use iroha_derive::FromVariant; -use iroha_macro::error::ErrorTryFromEnum; +use iroha_macro::{error::ErrorTryFromEnum, FromVariant}; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -598,7 +597,7 @@ pub mod account { use eyre::{eyre, Error, Result}; //TODO: get rid of it? use iroha_crypto::SignatureOf; - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -996,7 +995,7 @@ pub mod asset { }; use eyre::{eyre, Error, Result, WrapErr}; - use iroha_derive::{FromVariant, Io}; + use iroha_macro::{FromVariant, Io}; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -1561,7 +1560,7 @@ pub mod domain { use dashmap::DashMap; use eyre::{eyre, Result}; use iroha_crypto::PublicKey; - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -1713,7 +1712,7 @@ pub mod peer { use std::{hash::Hash, iter::FromIterator}; use dashmap::DashSet; - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::IntoSchema; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/data_model/src/query.rs b/data_model/src/query.rs index 21836de0695..75eb175ca9d 100644 --- a/data_model/src/query.rs +++ b/data_model/src/query.rs @@ -6,7 +6,7 @@ use std::convert::TryFrom; use eyre::Result; use iroha_crypto::{prelude::*, SignatureOf}; -use iroha_derive::{FromVariant, Io}; +use iroha_macro::{FromVariant, Io}; use iroha_schema::prelude::*; use iroha_version::prelude::*; use parity_scale_codec::{Decode, Encode}; @@ -128,7 +128,7 @@ pub struct QueryRequest { pub payload: Payload, } -declare_versioned_with_scale!(VersionedSignedQueryRequest 1..2, Debug, Clone, iroha_derive::FromVariant, IntoSchema); +declare_versioned_with_scale!(VersionedSignedQueryRequest 1..2, Debug, Clone, iroha_macro::FromVariant, IntoSchema); /// I/O ready structure to send queries. #[version_with_scale( @@ -144,7 +144,7 @@ pub struct SignedQueryRequest { pub signature: SignatureOf, } -declare_versioned_with_scale!(VersionedQueryResult 1..2, Debug, Clone, iroha_derive::FromVariant, Io, IntoSchema); +declare_versioned_with_scale!(VersionedQueryResult 1..2, Debug, Clone, iroha_macro::FromVariant, Io, IntoSchema); /// Sized container for all possible Query results. #[version_with_scale( @@ -200,7 +200,7 @@ impl QueryRequest { pub mod role { //! Queries related to `Role`. - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -263,7 +263,7 @@ pub mod role { pub mod permissions { //! Queries related to `PermissionToken`. - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -303,7 +303,7 @@ pub mod permissions { pub mod account { //! Queries related to `Account`. - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -492,7 +492,7 @@ pub mod asset { #![allow(clippy::missing_inline_in_public_items)] - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -881,7 +881,7 @@ pub mod domain { #![allow(clippy::missing_inline_in_public_items)] - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -995,7 +995,7 @@ pub mod domain { pub mod peer { //! Queries related to `Domain`. - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; @@ -1074,7 +1074,7 @@ pub mod transaction { #![allow(clippy::missing_inline_in_public_items)] use iroha_crypto::Hash; - use iroha_derive::Io; + use iroha_macro::Io; use iroha_schema::prelude::*; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/data_model/src/transaction.rs b/data_model/src/transaction.rs index fe0d37cee32..ffa11404602 100644 --- a/data_model/src/transaction.rs +++ b/data_model/src/transaction.rs @@ -4,7 +4,7 @@ use std::{cmp::Ordering, collections::BTreeSet, iter::FromIterator, vec::IntoIte use eyre::{eyre, Result}; use iroha_crypto::{HashOf, KeyPair, SignatureOf, SignaturesOf}; -use iroha_derive::Io; +use iroha_macro::Io; use iroha_schema::IntoSchema; use iroha_version::{declare_versioned, declare_versioned_with_scale, version, version_with_scale}; use parity_scale_codec::{Decode, Encode}; @@ -95,7 +95,7 @@ declare_versioned!( VersionedTransaction 1..2, Debug, Clone, - iroha_derive::FromVariant, + iroha_macro::FromVariant, IntoSchema, Eq ); @@ -284,7 +284,7 @@ impl Txn for Transaction { } } -declare_versioned_with_scale!(VersionedPendingTransactions 1..2, iroha_derive::FromVariant, Clone, Debug); +declare_versioned_with_scale!(VersionedPendingTransactions 1..2, iroha_macro::FromVariant, Clone, Debug); impl VersionedPendingTransactions { /// Same as [`as_v1`](`VersionedPendingTransactions::as_v1()`) but also does conversion @@ -392,7 +392,7 @@ impl PartialOrd for TransactionValue { } } -declare_versioned_with_scale!(VersionedValidTransaction 1..2, Debug, Clone, iroha_derive::FromVariant, IntoSchema); +declare_versioned_with_scale!(VersionedValidTransaction 1..2, Debug, Clone, iroha_macro::FromVariant, IntoSchema); impl VersionedValidTransaction { /// Same as [`as_v1`](`VersionedValidTransaction::as_v1()`) but also does conversion @@ -450,7 +450,7 @@ impl Txn for ValidTransaction { } } -declare_versioned!(VersionedRejectedTransaction 1..2, iroha_derive::FromVariant, Clone, Debug, IntoSchema, Eq); +declare_versioned!(VersionedRejectedTransaction 1..2, iroha_macro::FromVariant, Clone, Debug, IntoSchema, Eq); impl VersionedRejectedTransaction { /// The same as [`as_v1`](`VersionedRejectedTransaction::as_v1()`) but also runs into on it diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 6b5a820c9ed..03347e1ff3a 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -11,10 +11,13 @@ default = [] telemetry = ["iroha_futures_derive/telemetry"] [dependencies] +iroha_futures_derive = { path = "derive" } +iroha_logger = { path = "../logger" } + rand = "0.8" serde_json = "1" serde = { version = "1", features = ["derive"] } tokio = { version = "1.6.0", features = ["rt", "rt-multi-thread", "macros"]} -tokio-stream = { version = "0.1.6", features = ["fs"]} -iroha_logger = { path = "../logger" } -iroha_futures_derive = { path = "derive" } + +[dev-dependencies] +tokio-stream = { version = "0.1.6" } diff --git a/futures/derive/Cargo.toml b/futures/derive/Cargo.toml index aae4a94a213..6712f0ff772 100644 --- a/futures/derive/Cargo.toml +++ b/futures/derive/Cargo.toml @@ -12,10 +12,7 @@ telemetry = [] proc-macro = true [dependencies] -syn = { version = "1.0", features = ["parsing", "full"] } +syn = { version = "1.0", features = ["full"] } quote = "1.0" proc-macro2 = "1.0" proc-macro-error = "1.0" - -[dev-dependencies] -trybuild = "1.0" diff --git a/futures/derive/src/lib.rs b/futures/derive/src/lib.rs index ec7eff103fb..9fa67b5b614 100644 --- a/futures/derive/src/lib.rs +++ b/futures/derive/src/lib.rs @@ -1,4 +1,4 @@ -//! Crate with derive macroses for futures +//! Crate with derive macros for futures #![allow(clippy::expect_used, clippy::str_to_string)] diff --git a/logger/Cargo.toml b/logger/Cargo.toml index 0de474022ba..39317f65b4f 100644 --- a/logger/Cargo.toml +++ b/logger/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] iroha_config = { path = "../config" } -chrono = "0.4" color-eyre = "0.5.11" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -18,7 +17,6 @@ tracing-subscriber = { version = "0.3.0", default-features = false, features = [ tracing-bunyan-formatter = { version = "0.3.0", default-features = false } tokio = { version = "1.6.0", features = ["sync"] } once_cell = "1.8.0" -crossbeam = "0.8.1" [dev-dependencies] tokio = { version = "1.6.0", features = ["macros", "time", "rt"] } diff --git a/logger/src/lib.rs b/logger/src/lib.rs index 5c48f641a3b..a9eec47ccca 100644 --- a/logger/src/lib.rs +++ b/logger/src/lib.rs @@ -124,63 +124,63 @@ macro_rules! telemetry_target { /// Macro for sending telemetry info #[macro_export] macro_rules! telemetry { - () => { - $crate::info!(target: iroha_logger::telemetry_target!(),) - }; - ($($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - $($k).+ = $($field)* - ) - ); - (?$($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - ?$($k).+ = $($field)* - ) - ); - (%$($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - %$($k).+ = $($field)* - ) - ); - ($($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - $($k).+, $($field)* - ) - ); - (?$($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - ?$($k).+, $($field)* - ) - ); - (%$($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - %$($k).+, $($field)* - ) - ); - (?$($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - ?$($k).+ - ) - ); - (%$($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - %$($k).+ - ) - ); - ($($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_target!(), - $($k).+ - ) - ); + () => { + $crate::info!(target: iroha_logger::telemetry_target!(),) + }; + ($($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + $($k).+ = $($field)* + ) + ); + (?$($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + ?$($k).+ = $($field)* + ) + ); + (%$($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + %$($k).+ = $($field)* + ) + ); + ($($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + $($k).+, $($field)* + ) + ); + (?$($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + ?$($k).+, $($field)* + ) + ); + (%$($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + %$($k).+, $($field)* + ) + ); + (?$($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + ?$($k).+ + ) + ); + (%$($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + %$($k).+ + ) + ); + ($($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_target!(), + $($k).+ + ) + ); } /// Macro for getting telemetry future target @@ -194,64 +194,64 @@ macro_rules! telemetry_future_target { /// Macro for sending telemetry future info #[macro_export] macro_rules! telemetry_future { - // All arguments match arms are from info macro - () => { - $crate::info!(target: iroha_logger::telemetry_future_target!(),) - }; - ($($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - $($k).+ = $($field)* - ) - ); - (?$($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - ?$($k).+ = $($field)* - ) - ); - (%$($k:ident).+ = $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - %$($k).+ = $($field)* - ) - ); - ($($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - $($k).+, $($field)* - ) - ); - (?$($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - ?$($k).+, $($field)* - ) - ); - (%$($k:ident).+, $($field:tt)*) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - %$($k).+, $($field)* - ) - ); - (?$($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - ?$($k).+ - ) - ); - (%$($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - %$($k).+ - ) - ); - ($($k:ident).+) => ( - $crate::info!( - target: iroha_logger::telemetry_future_target!(), - $($k).+ - ) - ); + // All arguments match arms are from info macro + () => { + $crate::info!(target: iroha_logger::telemetry_future_target!(),) + }; + ($($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + $($k).+ = $($field)* + ) + ); + (?$($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + ?$($k).+ = $($field)* + ) + ); + (%$($k:ident).+ = $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + %$($k).+ = $($field)* + ) + ); + ($($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + $($k).+, $($field)* + ) + ); + (?$($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + ?$($k).+, $($field)* + ) + ); + (%$($k:ident).+, $($field:tt)*) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + %$($k).+, $($field)* + ) + ); + (?$($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + ?$($k).+ + ) + ); + (%$($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + %$($k).+ + ) + ); + ($($k:ident).+) => ( + $crate::info!( + target: iroha_logger::telemetry_future_target!(), + $($k).+ + ) + ); } /// Installs the panic hook with [`color_eyre::install`] if it isn't installed yet @@ -269,3 +269,9 @@ pub fn install_panic_hook() -> Result<(), Report> { Ok(()) } } + +pub mod prelude { + //! Module with most used items. Needs to be imported when using `log` macro to avoid `tracing` crate dependency + + pub use tracing::{self, debug, error, info, instrument as log, trace, warn}; +} diff --git a/macro/Cargo.toml b/macro/Cargo.toml index 18c7d6422ca..9d2aeeeb567 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -3,7 +3,7 @@ name = "iroha_macro" version = "0.1.0" authors = ["Iroha 2 team "] edition = "2021" -description = "This crate contains macroses and attributes for Iroha projects. iroha_derive contains derive macroses." +description = "This crate contains macros and attributes for Iroha projects. iroha_derive contains derive macros." readme = "README.md" homepage = "https://github.com/hyperledger/iroha/tree/iroha2-dev" repository = "https://github.com/hyperledger/iroha/tree/iroha2-dev" @@ -17,5 +17,6 @@ is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/ir maintenance = { status = "actively-developed" } [dependencies] +iroha_derive = { path="derive" } + eyre = "0.6.5" -parity-scale-codec = "2" diff --git a/macro/README.md b/macro/README.md index 4ae334e29fa..21dd5f8de7e 100644 --- a/macro/README.md +++ b/macro/README.md @@ -2,8 +2,8 @@ ## Description -This crate contains macroses and attributes for Iroha projects. -`iroha_derive` contains derive macroses. +This crate contains macros and attributes for Iroha projects. +`iroha_derive` contains derive macros. ### Features @@ -44,14 +44,14 @@ pub struct Test [ ### Want to help us develop Iroha? -That's great! +That's great! Check out [this document](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md) ## Need help? -* Join [Telegram chat](https://t.me/hyperledgeriroha) or [Hyperledger RocketChat](https://chat.hyperledger.org/channel/iroha) where the maintainers, contributors and fellow users are ready to help you. +* Join [Telegram chat](https://t.me/hyperledgeriroha) or [Hyperledger RocketChat](https://chat.hyperledger.org/channel/iroha) where the maintainers, contributors and fellow users are ready to help you. You can also discuss your concerns and proposals and simply chat about Iroha there or in Gitter [![Join the chat at https://gitter.im/hyperledger-iroha/Lobby](https://badges.gitter.im/hyperledger-iroha/Lobby.svg)](https://gitter.im/hyperledger-iroha/Lobby) -* Submit issues and improvement suggestions via [Hyperledger Jira](https://jira.hyperledger.org/secure/CreateIssue!default.jspa) +* Submit issues and improvement suggestions via [Hyperledger Jira](https://jira.hyperledger.org/secure/CreateIssue!default.jspa) * Subscribe to our [mailing list](https://lists.hyperledger.org/g/iroha) to receive the latest and most important news and spread your word within Iroha community ## License diff --git a/macro/derive/Cargo.toml b/macro/derive/Cargo.toml index 22583478fd7..24d1661444d 100644 --- a/macro/derive/Cargo.toml +++ b/macro/derive/Cargo.toml @@ -8,13 +8,12 @@ edition = "2021" proc-macro = true [dependencies] -iroha_macro = { path="../" } -parity-scale-codec = { version = "2", features = ["derive"] } syn = {version = "1.0", features = ["parsing", "full"] } quote = "1.0" proc-macro2 = "1.0" -proc-macro-error = "1.0" [dev-dependencies] -iroha_logger = { version = "=0.1.0", path = "../../logger"} +iroha_macro = { path="../" } + +parity-scale-codec = { version = "2", features = ["derive"] } trybuild = "1.0" diff --git a/macro/src/lib.rs b/macro/src/lib.rs index dbf480dbd88..65f0b53364d 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -1,7 +1,9 @@ -//! Crate containing iroha macroses +//! Crate containing iroha macros #![allow(clippy::module_name_repetitions)] +pub use iroha_derive::*; + /// Crate with errors pub mod error { use std::{any::type_name, error, fmt, marker::PhantomData}; @@ -46,6 +48,3 @@ pub mod error { } } } - -/// Trait alias for encode + decode -pub trait Io: parity_scale_codec::Encode + parity_scale_codec::Decode {} diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index f9e99591ec6..c3396c05f66 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -16,23 +16,18 @@ iroha_logger = { path = "../logger" } iroha_crypto = { path = "../crypto" } iroha_actor = { path = "../actor" } iroha_macro = { version = "=0.1.0", path = "../macro" } -iroha_derive = { version = "=0.1.0", path = "../macro/derive" } iroha_data_model = { path = "../data_model" } -eyre = "0.6.5" rand = "0.7.3" -tokio = { version = "1.6.0", features = ["net", "sync", "time", "io-util"]} +tokio = { version = "1.6.0", features = ["rt-multi-thread", "macros"]} async-stream = "0.3" -futures = { version = "0.3.17", default-features = false, features = ["std", "async-await"] } +futures = { version = "0.3.17", default-features = false } async-trait = "0.1" -serde = { version = "1", features = ["derive"] } parity-scale-codec = { version = "2", features = ["derive"] } aead = "0.3.2" thiserror = "1.0.28" -tracing = "0.1" [dev-dependencies] iroha_config = { path = "../config" } unique_port = "0.1.1" -tokio = { version = "1.6.0", features = ["rt-multi-thread", "macros"] } diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs index 2eef6c9945f..0c8c017223b 100644 --- a/p2p/src/lib.rs +++ b/p2p/src/lib.rs @@ -20,7 +20,7 @@ pub mod peer; pub type Network = NetworkBase; /// Errors used in the [`iroha_p2p`] crate. -#[derive(Clone, Debug, iroha_derive::FromVariant, Error, iroha_actor::Message)] +#[derive(Clone, Debug, Error, iroha_macro::FromVariant, iroha_actor::Message)] pub enum Error { /// Failed to read or write #[error("Failed IO operation.")] diff --git a/p2p/src/network.rs b/p2p/src/network.rs index 3488dfff8f2..e97eef80364 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -15,7 +15,7 @@ use iroha_crypto::{ ursa::{encryption::symm::Encryptor, kex::KeyExchangeScheme}, PublicKey, }; -use iroha_logger::{debug, error, info, log, warn}; +use iroha_logger::prelude::*; use parity_scale_codec::{Decode, Encode}; use tokio::{ net::{TcpListener, TcpStream}, diff --git a/p2p/tests/p2p.rs b/p2p/tests/p2p.rs index 414cf8ca31a..226a5a3ed8b 100644 --- a/p2p/tests/p2p.rs +++ b/p2p/tests/p2p.rs @@ -13,7 +13,7 @@ use futures::{prelude::*, stream::FuturesUnordered}; use iroha_actor::{broker::*, prelude::*}; use iroha_config::logger; use iroha_crypto::{KeyPair, PublicKey}; -use iroha_logger::{info, Configuration, Level}; +use iroha_logger::{prelude::*, Configuration, Level}; use iroha_p2p::{ network::{ConnectedPeers, GetConnectedPeers}, peer::PeerId, @@ -203,7 +203,7 @@ async fn multiple_networks() { ..Configuration::default() }; drop(iroha_logger::init(&log_config)); - iroha_logger::info!("Starting..."); + info!("Starting..."); let delay = Duration::from_millis(200); tokio::time::sleep(delay).await; @@ -235,7 +235,7 @@ async fn multiple_networks() { tokio::time::sleep(delay * 3).await; - iroha_logger::info!("Sending posts..."); + info!("Sending posts..."); for b in &brokers { for id in &peer_ids { let post = Post { @@ -245,7 +245,7 @@ async fn multiple_networks() { b.issue_send(post).await; } } - iroha_logger::info!("Posts sent"); + info!("Posts sent"); tokio::time::sleep(delay * 5).await; assert_eq!(msgs.load(Ordering::SeqCst), 90); diff --git a/permissions_validators/Cargo.toml b/permissions_validators/Cargo.toml index 56b0d76a71e..f6c33cedf92 100644 --- a/permissions_validators/Cargo.toml +++ b/permissions_validators/Cargo.toml @@ -13,6 +13,3 @@ roles = ["iroha_core/roles"] iroha_core = { path = "../core"} iroha_data_model = { path = "../data_model" } iroha_macro = { path = "../macro" } - -[dev-dependencies] -maplit = "1.0.2" diff --git a/schema/Cargo.toml b/schema/Cargo.toml index 0a9345d3890..f8595d7cc82 100644 --- a/schema/Cargo.toml +++ b/schema/Cargo.toml @@ -4,12 +4,11 @@ version = "0.1.0" authors = ["Iroha 2 team "] edition = "2021" -[dev-dependencies] -trybuild = { version = "1.0", features = ["diff"] } - [dependencies] -serde_json = "1.0" -serde = { version = "1.0", features = ["derive"] } -parity-scale-codec = { version = "2", features = ["derive"] } iroha_schema_derive = { path = "derive" } + +serde = { version = "1.0", features = ["derive"] } fixnum = { version = "0.6", features = ["i64"]} + +[dev-dependencies] +parity-scale-codec = { version = "2", features = ["derive"] } diff --git a/schema/derive/Cargo.toml b/schema/derive/Cargo.toml index df30006ce48..5d77731c146 100644 --- a/schema/derive/Cargo.toml +++ b/schema/derive/Cargo.toml @@ -12,4 +12,3 @@ proc-macro = true proc-macro2 = "1.0" quote = "1.0" syn = "1.0.72" -parity-scale-codec = { version = "2", features = ["derive"] } diff --git a/telemetry/Cargo.toml b/telemetry/Cargo.toml index 5839774a37d..6400b76162b 100644 --- a/telemetry/Cargo.toml +++ b/telemetry/Cargo.toml @@ -9,6 +9,10 @@ build = "build.rs" dev-telemetry = [] [dependencies] +iroha_config = { path = "../config" } +iroha_logger = { path = "../logger" } +iroha_futures = { path = "../futures", features = ["telemetry"] } + async-trait = "0.1" chrono = "0.4" eyre = "0.6.5" @@ -16,16 +20,11 @@ futures = { version = "0.3.17", default-features = false, features = ["std", "as serde_json = "1" streaming-stats = "0.2" serde = { version = "1", features = ["derive"] } -tracing = "0.1" tokio = { version = "1.6.0", features = ["rt", "rt-multi-thread", "macros"]} tokio-stream = { version = "0.1.6", features = ["fs"]} tokio-tungstenite = { version = "0.13.0", features = ["tls"] } url = { version = "2.2.2", features = ["serde"] } -iroha_config = { path = "../config" } -iroha_logger = { path = "../logger" } -iroha_futures = { path = "../futures", features = ["telemetry"] } - [build-dependencies] anyhow = "1.0" vergen = { version = "5", default-features = false, features = ["cargo", "git"] } diff --git a/version/Cargo.toml b/version/Cargo.toml index d696608b07b..d9d222636e0 100644 --- a/version/Cargo.toml +++ b/version/Cargo.toml @@ -13,14 +13,13 @@ json = ["serde_json"] derive = ["iroha_version_derive"] [dependencies] +iroha_version_derive = { path = "derive", optional = true } +iroha_macro = { path = "../macro" } + eyre = "0.6.5" serde = { version = "1.0", features = ["derive"] } serde_json = {version = "1.0", optional = true } thiserror = "1.0.28" -iroha_derive = { path = "../macro/derive" } -iroha_macro = { path = "../macro" } -iroha_schema = { path = "../schema"} parity-scale-codec = { version = "2", features = ["derive"], optional = true } -iroha_version_derive = { path = "derive", optional = true } warp = { version = "0.3", default-features = false, optional = true } diff --git a/version/derive/Cargo.toml b/version/derive/Cargo.toml index 0dfa653e70c..da53c222be4 100644 --- a/version/derive/Cargo.toml +++ b/version/derive/Cargo.toml @@ -4,6 +4,8 @@ version = "0.1.0" authors = ["Iroha 2 team "] edition = "2021" +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + [lib] proc-macro = true @@ -12,14 +14,12 @@ syn = {version = "1", features = ["parsing", "full"] } quote = "1.0" proc-macro2 = "1.0" proc-macro-error = "1.0" -iroha_macro = {path = "../../macro" } -iroha_derive = {path = "../../macro/derive" } [dev-dependencies] +iroha_version = {path = "../../version", features = ["scale", "json"]} +iroha_macro = {path = "../../macro" } + serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" trybuild = "1.0" parity-scale-codec = { version = "2", features = ["derive"]} -iroha_version = {path = "../../version", features = ["scale", "json"]} - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/version/derive/src/lib.rs b/version/derive/src/lib.rs index 8ebabcff943..c8c2598a37d 100644 --- a/version/derive/src/lib.rs +++ b/version/derive/src/lib.rs @@ -74,7 +74,7 @@ pub fn version_with_json(attr: TokenStream, item: TokenStream) -> TokenStream { /// use iroha_version_derive::{declare_versioned, version}; /// use iroha_version::json::*; /// -/// declare_versioned!(VersionedMessage 1..2, Debug, Clone, iroha_derive::FromVariant); +/// declare_versioned!(VersionedMessage 1..2, Debug, Clone, iroha_macro::FromVariant); /// /// #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] /// #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] diff --git a/version/derive/tests/as_version.rs b/version/derive/tests/as_version.rs index bc1a3fa2a8b..92fefe58b53 100644 --- a/version/derive/tests/as_version.rs +++ b/version/derive/tests/as_version.rs @@ -6,7 +6,7 @@ mod tests { use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; - declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); + declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] diff --git a/version/derive/tests/json.rs b/version/derive/tests/json.rs index 1c56e349422..1d9452077eb 100644 --- a/version/derive/tests/json.rs +++ b/version/derive/tests/json.rs @@ -19,7 +19,7 @@ mod tests { #![allow(unused_results)] use super::*; - declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); + declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] @@ -35,7 +35,7 @@ mod tests { use super::*; - declare_versioned!(VersionedMessage 1..4, Debug, Clone, iroha_derive::FromVariant); + declare_versioned!(VersionedMessage 1..4, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] diff --git a/version/derive/tests/scale.rs b/version/derive/tests/scale.rs index be378cd8633..be03e0b239d 100644 --- a/version/derive/tests/scale.rs +++ b/version/derive/tests/scale.rs @@ -20,7 +20,7 @@ mod tests { use super::*; - declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); + declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] @@ -36,7 +36,7 @@ mod tests { use super::*; - declare_versioned!(VersionedMessage 1..4, Debug, Clone, iroha_derive::FromVariant); + declare_versioned!(VersionedMessage 1..4, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] diff --git a/version/derive/tests/ui/ok_declare_several_vesrioned.rs b/version/derive/tests/ui/ok_declare_several_vesrioned.rs index 71d2fb99fd1..bf2b89532d7 100644 --- a/version/derive/tests/ui/ok_declare_several_vesrioned.rs +++ b/version/derive/tests/ui/ok_declare_several_vesrioned.rs @@ -2,7 +2,7 @@ use iroha_version_derive::{declare_versioned, version}; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; -declare_versioned!(VersionedMessage 1..2, Debug, Clone, iroha_derive::FromVariant); +declare_versioned!(VersionedMessage 1..2, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] struct Message; @@ -11,7 +11,7 @@ impl Message { pub fn handle(&self) {} } -declare_versioned!(VersionedMessage2 1..2, Debug, Clone, iroha_derive::FromVariant); +declare_versioned!(VersionedMessage2 1..2, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage2", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] struct Message2; diff --git a/version/derive/tests/ui/ok_declare_versioned.rs b/version/derive/tests/ui/ok_declare_versioned.rs index 4bff3ec7bfb..ba108cdfe90 100644 --- a/version/derive/tests/ui/ok_declare_versioned.rs +++ b/version/derive/tests/ui/ok_declare_versioned.rs @@ -2,7 +2,7 @@ use iroha_version_derive::{declare_versioned, version}; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; -declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); +declare_versioned!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode, Serialize, Deserialize)] diff --git a/version/derive/tests/ui/ok_declare_versioned_json.rs b/version/derive/tests/ui/ok_declare_versioned_json.rs index d255503b985..aded3fa0e12 100644 --- a/version/derive/tests/ui/ok_declare_versioned_json.rs +++ b/version/derive/tests/ui/ok_declare_versioned_json.rs @@ -1,7 +1,7 @@ use iroha_version_derive::{declare_versioned_with_json, version_with_json}; use serde::{Deserialize, Serialize}; -declare_versioned_with_json!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); +declare_versioned_with_json!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version_with_json(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/version/derive/tests/ui/ok_declare_versioned_scale.rs b/version/derive/tests/ui/ok_declare_versioned_scale.rs index 92893abf9ad..fc14abad177 100644 --- a/version/derive/tests/ui/ok_declare_versioned_scale.rs +++ b/version/derive/tests/ui/ok_declare_versioned_scale.rs @@ -1,7 +1,7 @@ use iroha_version_derive::{declare_versioned_with_scale, version_with_scale}; use parity_scale_codec::{Decode, Encode}; -declare_versioned_with_scale!(VersionedMessage 1..3, Debug, Clone, iroha_derive::FromVariant); +declare_versioned_with_scale!(VersionedMessage 1..3, Debug, Clone, iroha_macro::FromVariant); #[version_with_scale(n = 1, versioned = "VersionedMessage", derive = "Debug, Clone")] #[derive(Debug, Clone, Decode, Encode)] diff --git a/version/src/lib.rs b/version/src/lib.rs index 2c9b6149061..1b73462d708 100644 --- a/version/src/lib.rs +++ b/version/src/lib.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// Module which contains error and result for versioning pub mod error { - use iroha_derive::FromVariant; + use iroha_macro::FromVariant; use thiserror::Error; #[cfg(feature = "warp")] use warp::{