Repository: mintlayer/mintlayer-core
Pull request #657 (2023-01-27 18:21:09)

Workspace dependencies
This is mostly for discussion. I think that it is convenient to specify the versions of widely used dependencies in the root toml file. It is even more important for things such as `parity-scale-codec`, even though we have a CI check. 

stanislav-tkach: Yes, it was added in the 1.64 [version](https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#cargo-improvements-workspace-inheritance-and-multi-target-builds).

It is convenient to specify the version only once, but I'm not sure when exactly a dependency should be moved to the workspace file. For now I have moved the dependencies that are used in 4+ crates.

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index f835c94fb..4310be080 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -77,6 +77,18 @@ serialization = { path = "serialization"}
 storage = { path = "storage"}
 utxo = { path = "utxo"}
 
+[workspace.dependencies]
+async-trait = "0.1"
+futures = "0.3"
+hex = "0.4"
+itertools = "0.10"
+jsonrpsee = "0.16"
+parity-scale-codec = "3.1"
+serde = "1.0"
+static_assertions = "1.1"
+thiserror = "1.0"
+tokio = "1.0"
+
 [profile.release]
 debug-assertions = true
 overflow-checks = true
diff --git a/accounting/Cargo.toml b/accounting/Cargo.toml
index 7e757ed65..7578be75d 100644
--- a/accounting/Cargo.toml
+++ b/accounting/Cargo.toml
@@ -11,8 +11,8 @@ common = {path = '../common'}
 serialization = {path = "../serialization"}
 utils = {path = '../utils'}
 
-thiserror = "1.0"
-parity-scale-codec = "3.1"
+thiserror.workspace = true
+parity-scale-codec.workspace = true
 
 [dev-dependencies]
 proptest = "1.0"
diff --git a/blockprod/Cargo.toml b/blockprod/Cargo.toml
index ead2484b9..590fc3c8f 100644
--- a/blockprod/Cargo.toml
+++ b/blockprod/Cargo.toml
@@ -15,10 +15,10 @@ logging = {path = '../logging'}
 utils = {path = '../utils'}
 rpc = { path = "../rpc/" }
 
-thiserror = "1.0"
-tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
-futures = "0.3"
+thiserror.workspace = true
+tokio = { workspace = true, default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
+futures.workspace = true
 void = "1.0"
 crossbeam-channel = "0.5"
-jsonrpsee = {version = "0.16", features = ["macros"]}
-async-trait = "0.1"
+jsonrpsee = { workspace = true, features = ["macros"] }
+async-trait.workspace = true
diff --git a/chainstate/Cargo.toml b/chainstate/Cargo.toml
index bc89cf946..dab28c0c5 100644
--- a/chainstate/Cargo.toml
+++ b/chainstate/Cargo.toml
@@ -19,17 +19,16 @@ utxo = {path = '../utxo'}
 utils = {path = '../utils'}
 consensus = {path = "../consensus"}
 
-async-trait = "0.1"
-hex = "0.4"
-itertools = "0.10"
-jsonrpsee = {version = "0.16", features = ["macros"]}
-thiserror = "1.0"
-
-[dev-dependencies]
-test-utils = { path = "../test-utils" }
-
+async-trait.workspace = true
+hex.workspace = true
+itertools.workspace = true
+jsonrpsee = { workspace = true, features = ["macros"] }
+thiserror.workspace = true
 mockall = "0.11"
 rstest = "0.16"
 serde_json = "1.0"
-static_assertions = "1.1"
-tokio = "1.19"
+static_assertions.workspace = true
+tokio.workspace = true
+
+[dev-dependencies]
+test-utils = { path = "../test-utils" }
diff --git a/chainstate/storage/Cargo.toml b/chainstate/storage/Cargo.toml
index 76d45b57c..0c06ec544 100644
--- a/chainstate/storage/Cargo.toml
+++ b/chainstate/storage/Cargo.toml
@@ -21,7 +21,7 @@ crypto = { path = '../../crypto' }
 test-utils = {path = '../../test-utils'}
 utils = { path = '../../utils' }
 
-itertools = "0.10"
+itertools.workspace = true
 mockall = "0.11"
 num-traits = "0.2"
 rstest = "0.16"
diff --git a/chainstate/tx-verifier/Cargo.toml b/chainstate/tx-verifier/Cargo.toml
index 725ef66bc..d58382ed2 100644
--- a/chainstate/tx-verifier/Cargo.toml
+++ b/chainstate/tx-verifier/Cargo.toml
@@ -15,7 +15,7 @@ pos_accounting = {path = '../../pos_accounting'}
 utils = {path = '../../utils'}
 utxo = {path = '../../utxo'}
 
-thiserror = "1.0"
+thiserror.workspace = true
 fallible-iterator = "0.2.0"
 replace_with = "0.1"
 
diff --git a/chainstate/types/Cargo.toml b/chainstate/types/Cargo.toml
index 066495b63..304fdb155 100644
--- a/chainstate/types/Cargo.toml
+++ b/chainstate/types/Cargo.toml
@@ -11,5 +11,5 @@ serialization = { path = "../../serialization" }
 common = { path = "../../common/" }
 storage = { path = "../../storage/" }
 
-thiserror = "1.0"
-parity-scale-codec = "3.1"
+thiserror.workspace = true
+parity-scale-codec.workspace = true
diff --git a/common/Cargo.toml b/common/Cargo.toml
index f192b38f9..36306264e 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -18,11 +18,11 @@ anyhow = "1.0"
 bech32 = "0.9"
 generic-array = "0.14"
 merkletree = "0.22"
-parity-scale-codec = "3.1"
+parity-scale-codec.workspace = true
 serde = "1.0"
-static_assertions = "1.1"
-thiserror = "1.0"
-hex = "0.4"
+static_assertions.workspace = true
+thiserror.workspace = true
+hex.workspace = true
 
 # for fixed_hash
 arbitrary = "1.1"
@@ -35,7 +35,7 @@ expect-test = "1.3"
 proptest = "1.0"
 serde_test = "1.0"
 serde_json = "1.0"
-itertools = "0.10"
+itertools.workspace = true
 serial_test = "0.9"
 rstest = "0.16"
 test-utils = {path = '../test-utils'}
diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml
index 7696494d5..8ed775f14 100644
--- a/consensus/Cargo.toml
+++ b/consensus/Cargo.toml
@@ -9,7 +9,7 @@ common = {path = '../common'}
 chainstate-types = {path = '../chainstate/types'}
 chainstate-storage = {path = '../chainstate/storage'}
 
-thiserror = "1.0"
+thiserror.workspace = true
 num = "0.4.0"
 
 [dev-dependencies]
diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml
index d7e08513e..63d02549e 100644
--- a/crypto/Cargo.toml
+++ b/crypto/Cargo.toml
@@ -19,12 +19,12 @@ ripemd = "0.1"
 blake2 = "0.10"
 generic-array = "0.14"
 rand = "0.8"
-parity-scale-codec = "3.1"
+parity-scale-codec.workspace = true
 num = "0.4"
 num-derive = "0.3"
 num-traits = "0.2"
 chacha20poly1305 = "0.10"
-thiserror = "1.0"
+thiserror.workspace = true
 schnorrkel = "0.10.2"
 merlin = { version = "3.0.0", default-features = false }
 argon2 = { version = "0.4", features = ["std"] }
@@ -34,5 +34,5 @@ zeroize = "1.5.7"
 test-utils = { path = "../test-utils" }
 
 rstest = "0.16"
-hex = "0.4"
+hex.workspace = true
 rand_chacha = "0.3.1"
diff --git a/mempool/Cargo.toml b/mempool/Cargo.toml
index e0db26e36..c0e98475f 100644
--- a/mempool/Cargo.toml
+++ b/mempool/Cargo.toml
@@ -16,12 +16,12 @@ logging = { path = '../logging' }
 rpc = { path = '../rpc' }
 
 anyhow = "1.0"
-async-trait = "0.1"
-jsonrpsee = {version = "0.16", features = ["macros"]}
-thiserror = "1.0"
+async-trait.workspace = true
+jsonrpsee = { workspace = true, features = ["macros"] }
+thiserror.workspace = true
 mockall = "0.11.0"
 parking_lot = "0.12"
-tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
+tokio = { workspace = true, default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
 
 [dev-dependencies]
 chainstate-storage = { path = '../chainstate/storage' }
diff --git a/node/Cargo.toml b/node/Cargo.toml
index 0d47db3f3..be98a6ab1 100644
--- a/node/Cargo.toml
+++ b/node/Cargo.toml
@@ -22,9 +22,9 @@ storage-lmdb = { path = "../storage/lmdb" }
 # External dependencies
 anyhow = "1.0"
 clap = { version = "4", features = ["derive"] }
-jsonrpsee = { version = "0.16", features = ["macros"] }
-tokio = { version = "1.19", default-features = false }
-serde = { version = "1", features = ["derive"] }
+jsonrpsee = { workspace = true, features = ["macros"] }
+tokio = { workspace = true, default-features = false }
+serde = { workspace = true, features = ["derive"] }
 toml = "0.5"
 directories = "4.0"
 paste = "1.0"
diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml
index 137c31576..cced33c49 100644
--- a/p2p/Cargo.toml
+++ b/p2p/Cargo.toml
@@ -20,21 +20,21 @@ subsystem = { path = "../subsystem/" }
 utils = { path = "../utils/" }
 storage = { path = "../storage" }
 
-async-trait = "0.1"
+async-trait.workspace = true
 bytes = "1.1"
-futures = "0.3"
-itertools = "0.10"
-parity-scale-codec = "3.1"
+futures.workspace = true
+itertools.workspace = true
+parity-scale-codec.workspace = true
 sscanf = "0.4"
-thiserror = "1.0"
+thiserror.workspace = true
 void = "1.0"
 tap = "1.0"
 once_cell = "1.13"
-jsonrpsee = { version = "0.16", features = ["macros"]}
-tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
+jsonrpsee = { workspace = true, features = ["macros"] }
+tokio = { workspace = true, default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
 tokio-util = {version = "0.7", default-features = false, features = ["codec"] }
 snowstorm = "0.4.0"
-serde = "1.0"
+serde.workspace = true
 socket2 = { version = "0.4.0", features = ["all"] }
 
 [dev-dependencies]
diff --git a/pos_accounting/Cargo.toml b/pos_accounting/Cargo.toml
index 8d7be799a..088ddbf6b 100644
--- a/pos_accounting/Cargo.toml
+++ b/pos_accounting/Cargo.toml
@@ -14,8 +14,8 @@ chainstate-types = { path = '../chainstate/types' }
 serialization = {path = "../serialization"}
 typename = { path = "../utils/typename" }
 
-thiserror = "1.0"
-parity-scale-codec = "3.1"
+thiserror.workspace = true
+parity-scale-codec.workspace = true
 
 [dev-dependencies]
 test-utils = { path = "../test-utils" }
diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml
index 5e82f8185..68a853e71 100644
--- a/rpc/Cargo.toml
+++ b/rpc/Cargo.toml
@@ -14,9 +14,8 @@ utils = { path = "../utils/" }
 
 # External dependencies
 anyhow = "1.0"
-async-trait = "0.1"
-jsonrpsee = { version = "0.16", features = ["full"] }
+async-trait.workspace = true
+jsonrpsee = { workspace = true, features = ["full"] }
 
 [dev-dependencies]
-async-trait = "0.1"
-tokio = "1.19"
+tokio.workspace = true
diff --git a/script/Cargo.toml b/script/Cargo.toml
index 8fcd06d55..dcba2c715 100644
--- a/script/Cargo.toml
+++ b/script/Cargo.toml
@@ -10,14 +10,14 @@ serialization = { path = "../serialization" }
 utils = { path = '../utils' }
 typename = { path = "../utils/typename" }
 
-parity-scale-codec = "3.1"
-thiserror = "1.0"
+parity-scale-codec.workspace = true
+thiserror.workspace = true
 
 [dev-dependencies]
 logging = { path = '../logging' }
 
 flate2 = "1.0"
-hex = "0.4"
+hex.workspace = true
 hex-literal = "0.3"
 proptest = "1.0"
 
diff --git a/serialization/core/Cargo.toml b/serialization/core/Cargo.toml
index c0524972f..ae6f3e283 100644
--- a/serialization/core/Cargo.toml
+++ b/serialization/core/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-parity-scale-codec = {version = "3.1.2", features = ["derive", "chain-error"]}
+parity-scale-codec = { workspace = true, features = ["derive", "chain-error"] }
 
 [dev-dependencies]
 arraytools = "0.1"
diff --git a/serialization/tagged/Cargo.toml b/serialization/tagged/Cargo.toml
index 5fd33530b..7b604bd63 100644
--- a/serialization/tagged/Cargo.toml
+++ b/serialization/tagged/Cargo.toml
@@ -8,10 +8,10 @@ license = "MIT"
 serialization-core = { path = '../core' }
 serialization-tagged-derive = { path = 'derive' }
 
-static_assertions = "1.1"
+static_assertions.workspace = true
 
 [dev-dependencies]
 serialization = { path = '..' }
 
-parity-scale-codec = {version = "3.1", features = ["derive", "chain-error"]}
+parity-scale-codec = { workspace = true, features = ["derive", "chain-error"] }
 proptest = "1.0"
diff --git a/serialization/tagged/derive/Cargo.toml b/serialization/tagged/derive/Cargo.toml
index 6b565dcfb..cf2da8c95 100644
--- a/serialization/tagged/derive/Cargo.toml
+++ b/serialization/tagged/derive/Cargo.toml
@@ -10,5 +10,5 @@ proc-macro = true
 [dependencies]
 syn = "1.0"
 quote = "1.0"
-itertools = "0.10"
+itertools.workspace = true
 proc-macro2 = "1.0"
diff --git a/storage/core/Cargo.toml b/storage/core/Cargo.toml
index 57e336930..95f5f9059 100644
--- a/storage/core/Cargo.toml
+++ b/storage/core/Cargo.toml
@@ -11,5 +11,5 @@ utils = { path = '../../utils' }
 logging = { path = '../../logging' }
 
 # External dependencies
-thiserror = "1.0"
-itertools = "0.10"
+thiserror.workspace = true
+itertools.workspace = true
diff --git a/subsystem/Cargo.toml b/subsystem/Cargo.toml
index 9cc7b4e6f..77372acaf 100644
--- a/subsystem/Cargo.toml
+++ b/subsystem/Cargo.toml
@@ -9,16 +9,16 @@ default = [ "time" ]
 time = [ "tokio/time" ]
 
 [dependencies]
-# External dependencies
-async-trait = "0.1"
-cfg-if = "1.0"
-thiserror = "1.0"
-futures = { version = "0.3", default-features = false, features = ["alloc"]}
-tokio = { version = "1.0", default-features = false, features = ["macros", "rt", "rt-multi-thread", "signal", "sync"]}
-
 # Local dependencies
 logging = { path = "../logging" }
 
+# External dependencies
+async-trait.workspace = true
+cfg-if = "1.0"
+thiserror.workspace = true
+futures = { workspace = true, default-features = false, features = ["alloc"]}
+tokio = { workspace = true, default-features = false, features = ["macros", "rt", "rt-multi-thread", "signal", "sync"]}
+
 [dev-dependencies]
 testing_logger = "0.1"
 
diff --git a/utils/Cargo.toml b/utils/Cargo.toml
index 121989eb1..4368cf703 100644
--- a/utils/Cargo.toml
+++ b/utils/Cargo.toml
@@ -12,7 +12,7 @@ num-traits = "0.2"
 slave-pool = "0.2"
 
 [dev-dependencies]
-static_assertions = "1.1"
+static_assertions.workspace = true
 
 [target.'cfg(loom)'.dependencies]
 loom = "0.5"
diff --git a/utils/typename-derive/Cargo.toml b/utils/typename-derive/Cargo.toml
index 681419e6f..c2912104b 100644
--- a/utils/typename-derive/Cargo.toml
+++ b/utils/typename-derive/Cargo.toml
@@ -10,4 +10,4 @@ proc-macro = true
 [dependencies]
 syn = "1.0"
 quote = "1.0"
-itertools = "0.10"
+itertools.workspace = true
diff --git a/utxo/Cargo.toml b/utxo/Cargo.toml
index 3472e104e..534a74679 100644
--- a/utxo/Cargo.toml
+++ b/utxo/Cargo.toml
@@ -12,12 +12,12 @@ logging = { path = "../logging/" }
 serialization = { path = "../serialization" }
 chainstate-types = { path = '../chainstate/types' }
 
-parity-scale-codec = { version = "3.1", features = ["chain-error"] }
-thiserror = "1.0"
+parity-scale-codec = { workspace = true, features = ["chain-error"] }
+thiserror.workspace = true
 
 [dev-dependencies]
 crypto = { path = '../crypto' }
 test-utils = {path = '../test-utils'}
 
-itertools = "0.10"
+itertools.workspace = true
 rstest = "0.16"


Test patch:
diff --git a/chainstate/test-framework/Cargo.toml b/chainstate/test-framework/Cargo.toml
index 816211688..197468a59 100644
--- a/chainstate/test-framework/Cargo.toml
+++ b/chainstate/test-framework/Cargo.toml
@@ -19,10 +19,10 @@ utils = { path = '../../utils' }
 utxo = {path = '../../utxo'}
 
 rstest = "0.16"
-itertools = "0.10"
+itertools.workspace = true
 
 [dev-dependencies]
 consensus = { path = '../../consensus' }
 logging = { path = '../../logging' }
 
-hex = "0.4"
+hex.workspace = true
diff --git a/chainstate/test-suite/Cargo.toml b/chainstate/test-suite/Cargo.toml
index f2cffb277..89ea390cb 100644
--- a/chainstate/test-suite/Cargo.toml
+++ b/chainstate/test-suite/Cargo.toml
@@ -22,8 +22,8 @@ tx-verifier = { path = '../tx-verifier' }
 utils = { path = '../../utils' }
 utxo = { path = '../../utxo' }
 
-hex = "0.4"
-itertools = "0.10"
+hex.workspace = true
+itertools.workspace = true
 
 [dev-dependencies]
 rstest = "0.16"
diff --git a/p2p/backend-test-suite/Cargo.toml b/p2p/backend-test-suite/Cargo.toml
index de18efcd8..22c8e8927 100644
--- a/p2p/backend-test-suite/Cargo.toml
+++ b/p2p/backend-test-suite/Cargo.toml
@@ -13,6 +13,6 @@ serialization = { path = "../../serialization" }
 chainstate = { path = "../../chainstate/" }
 subsystem = { path = "../../subsystem/" }
 
-tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
-futures = "0.3"
+tokio = { workspace = true, default-features = false, features = ["io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] }
+futures.workspace = true
 libtest-mimic = "0.6"
diff --git a/p2p/p2p-test-utils/Cargo.toml b/p2p/p2p-test-utils/Cargo.toml
index 925faddf7..6b9b73daa 100644
--- a/p2p/p2p-test-utils/Cargo.toml
+++ b/p2p/p2p-test-utils/Cargo.toml
@@ -13,4 +13,4 @@ mempool = { path = "../../mempool/" }
 subsystem = { path = "../../subsystem/" }
 
 portpicker = "0.1"
-tokio = { version = "1", default-features = false, features = ["io-util", "macros", "net", "rt", "sync"] }
+tokio = { workspace = true, default-features = false, features = ["io-util", "macros", "net", "rt", "sync"] }
diff --git a/test/Cargo.toml b/test/Cargo.toml
index ecb951e7a..4c8bb6872 100644
--- a/test/Cargo.toml
+++ b/test/Cargo.toml
@@ -8,11 +8,11 @@ license = "MIT"
 [dependencies]
 node = { path = "../node" }
 
-tokio = { version = "1.19", features = ['full'] }
+tokio = { workspace = true, features = ['full'] }
 
 [dev-dependencies]
 libtest-mimic = "0.6"
-thiserror = "1.0"
+thiserror.workspace = true
 
 [[test]]
 name = "functional"