From b58822479095834944b5a20d587bd037ac10f5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 24 Jun 2024 15:43:25 +0100 Subject: [PATCH] fixup! shielded_token: feature guard validation to avoid compilation into wasm --- crates/apps_lib/Cargo.toml | 2 +- crates/encoding_spec/Cargo.toml | 2 +- crates/namada/Cargo.toml | 1 - crates/node/Cargo.toml | 2 +- crates/sdk/Cargo.toml | 4 ++-- crates/shielded_token/Cargo.toml | 20 +++++--------------- crates/shielded_token/src/lib.rs | 1 - crates/shielded_token/src/validation.rs | 1 + crates/tests/Cargo.toml | 2 +- crates/token/Cargo.toml | 2 +- 10 files changed, 13 insertions(+), 24 deletions(-) diff --git a/crates/apps_lib/Cargo.toml b/crates/apps_lib/Cargo.toml index 82585e696d3..c769cff7fe0 100644 --- a/crates/apps_lib/Cargo.toml +++ b/crates/apps_lib/Cargo.toml @@ -36,7 +36,7 @@ namada-eth-bridge = [ namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]} namada_macros = {path = "../macros"} namada_migrations = {path = "../migrations", optional = true} -namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std", "rand"]} +namada_sdk = {path = "../sdk", default-features = false, features = ["download-params", "std", "rand"]} namada_test_utils = {path = "../test_utils", optional = true} async-trait.workspace = true diff --git a/crates/encoding_spec/Cargo.toml b/crates/encoding_spec/Cargo.toml index 5db557c51c0..519f0f81033 100644 --- a/crates/encoding_spec/Cargo.toml +++ b/crates/encoding_spec/Cargo.toml @@ -17,7 +17,7 @@ default = [] namada-eth-bridge = ["namada/namada-eth-bridge"] [dependencies] -namada = { path = "../namada" } +namada = { path = "../namada", features = ["rand", "tendermint-rpc"] } borsh.workspace = true itertools.workspace = true lazy_static.workspace = true diff --git a/crates/namada/Cargo.toml b/crates/namada/Cargo.toml index e3fddc76cbc..d5984572313 100644 --- a/crates/namada/Cargo.toml +++ b/crates/namada/Cargo.toml @@ -73,7 +73,6 @@ multicore = [ "namada_sdk/multicore", "namada_token/multicore", ] -validation = ["namada_sdk/validation"] rand = ["namada_sdk/rand"] migrations = [ "namada_migrations", diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index c9fe647f4e0..7e4d13b9c58 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -47,7 +47,7 @@ namada-eth-bridge = [ namada = {path = "../namada", features = ["multicore", "http-client", "tendermint-rpc", "std"]} namada_apps_lib = {path = "../apps_lib"} namada_migrations = {path = "../migrations", optional = true} -namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std", "rand"]} +namada_sdk = {path = "../sdk", default-features = false, features = ["download-params", "std", "rand"]} namada_test_utils = {path = "../test_utils", optional = true} arse-merkle-tree = { workspace = true, features = ["blake2b"] } diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 8278bdd0547..d1632ffe97a 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -23,7 +23,7 @@ multicore = ["masp_proofs/multicore"] namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"] -std = ["fd-lock"] +std = ["fd-lock", "download-params"] rand = ["dep:rand", "rand_core", "namada_core/rand"] # tendermint-rpc support @@ -53,7 +53,7 @@ testing = [ "jubjub", ] -validation = ["namada_token/validation"] +download-params = ["namada_token/download-params"] migrations = [ "namada_migrations", "namada_account/migrations", diff --git a/crates/shielded_token/Cargo.toml b/crates/shielded_token/Cargo.toml index 0dde066c20c..63a808b6259 100644 --- a/crates/shielded_token/Cargo.toml +++ b/crates/shielded_token/Cargo.toml @@ -15,32 +15,26 @@ version.workspace = true [features] default = [] multicore = ["dep:rayon"] -validation = [ - "namada_gas", - "lazy_static", - "masp_proofs", - "rand_core", -] testing = [ "multicore", - "validation", "namada_core/testing", "masp_primitives/test-dependencies", ] +download-params = ["masp_proofs/download-params"] [dependencies] namada_controller = { path = "../controller" } namada_core = { path = "../core" } -namada_gas = { path = "../gas", optional = true } +namada_gas = { path = "../gas" } namada_parameters = { path = "../parameters" } namada_storage = { path = "../storage" } namada_trans_token = { path = "../trans_token" } borsh.workspace = true -lazy_static = { workspace = true, optional = true } +lazy_static.workspace = true masp_primitives.workspace = true -masp_proofs = { workspace = true, optional = true, features = ["download-params"] } -rand_core = { workspace = true, optional = true } +masp_proofs = { workspace = true } +rand_core.workspace = true rayon = { workspace = true, optional = true } serde.workspace = true smooth-operator.workspace = true @@ -48,13 +42,9 @@ tracing.workspace = true [dev-dependencies] namada_core = { path = "../core", features = ["testing"] } -namada_gas = { path = "../gas" } namada_parameters = { path = "../parameters", features = ["testing"] } namada_storage = { path = "../storage", features = ["testing"] } -lazy_static.workspace = true -masp_proofs = { workspace = true, features = ["download-params"] } proptest.workspace = true -rand_core.workspace = true rayon.workspace = true test-log.workspace = true diff --git a/crates/shielded_token/src/lib.rs b/crates/shielded_token/src/lib.rs index 625a5318f9a..50d137955c5 100644 --- a/crates/shielded_token/src/lib.rs +++ b/crates/shielded_token/src/lib.rs @@ -21,7 +21,6 @@ pub mod conversion; mod storage; pub mod storage_key; pub mod utils; -#[cfg(any(test, feature = "validation", feature = "testing"))] pub mod validation; use std::str::FromStr; diff --git a/crates/shielded_token/src/validation.rs b/crates/shielded_token/src/validation.rs index 79a4caad627..c52300b4d19 100644 --- a/crates/shielded_token/src/validation.rs +++ b/crates/shielded_token/src/validation.rs @@ -75,6 +75,7 @@ lazy_static! { let [spend_path, convert_path, output_path] = [SPEND_NAME, CONVERT_NAME, OUTPUT_NAME].map(|p| params_dir.join(p)); + #[cfg(feature = "download-params")] if !spend_path.exists() || !convert_path.exists() || !output_path.exists() { let paths = masp_proofs::download_masp_parameters(None).expect( "MASP parameters were not present, expected the download to \ diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index dcb7e8d0832..6c76c5d8168 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -33,7 +33,7 @@ namada-eth-bridge = [ [dependencies] namada = {path = "../namada", features = ["testing"]} namada_core = {path = "../core", features = ["testing"]} -namada_sdk = {path = "../sdk", default-features = false, features = ["tendermint-rpc", "validation", "std", "rand"]} +namada_sdk = {path = "../sdk", default-features = false, features = ["tendermint-rpc", "download-params", "std", "rand"]} namada_test_utils = {path = "../test_utils"} namada_tx_prelude = {path = "../tx_prelude"} namada_vp_prelude = {path = "../vp_prelude"} diff --git a/crates/token/Cargo.toml b/crates/token/Cargo.toml index 058f57f3a49..175f73b54ad 100644 --- a/crates/token/Cargo.toml +++ b/crates/token/Cargo.toml @@ -15,7 +15,7 @@ version.workspace = true [features] default = [] multicore = ["namada_shielded_token/multicore"] -validation = ["namada_shielded_token/validation"] +download-params = ["namada_shielded_token/download-params"] testing = ["namada_core/testing", "namada_shielded_token/testing", "proptest"] [dependencies]