Skip to content

Commit

Permalink
shielded_token: feature guard validation to avoid compilation into wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jun 17, 2024
1 parent d056b13 commit 9b5a94b
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion crates/apps_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["download-params", "std", "rand"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std", "rand"]}
namada_test_utils = {path = "../test_utils", optional = true}

async-trait.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/encoding_spec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default = []
namada-eth-bridge = ["namada/namada-eth-bridge"]

[dependencies]
namada = { path = "../namada", features = ["rand", "tendermint-rpc", "download-params"] }
namada = { path = "../namada" }
borsh.workspace = true
itertools.workspace = true
lazy_static.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions crates/namada/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ multicore = [
"namada_sdk/multicore",
"namada_token/multicore",
]
# Download MASP params if they're not present
download-params = ["namada_sdk/download-params"]
validation = ["namada_sdk/validation"]
rand = ["namada_sdk/rand"]
migrations = [
"namada_migrations",
Expand Down
2 changes: 1 addition & 1 deletion crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["download-params", "std", "rand"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std", "rand"]}
namada_test_utils = {path = "../test_utils", optional = true}

arse-merkle-tree = { workspace = true, features = ["blake2b"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["tendermint-rpc", "download-params", "std", "rand", "migrations"]
default = ["tendermint-rpc", "std", "rand", "migrations"]

mainnet = ["namada_core/mainnet", "namada_events/mainnet"]

Expand Down Expand Up @@ -53,7 +53,7 @@ testing = [
"jubjub",
]

download-params = ["namada_token/download-params"]
validation = ["namada_token/validation"]
migrations = [
"namada_migrations",
"namada_account/migrations",
Expand Down
16 changes: 10 additions & 6 deletions crates/shielded_token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ version.workspace = true
[features]
default = []
multicore = ["dep:rayon"]
# Download MASP params if they're not present
download-params = ["masp_proofs/download-params"]
validation = [
"namada_gas",
"lazy_static",
"masp_proofs",
"rand_core",
]
testing = [
"multicore",
"namada_core/testing",
Expand All @@ -26,16 +30,16 @@ testing = [
[dependencies]
namada_controller = { path = "../controller" }
namada_core = { path = "../core" }
namada_gas = { path = "../gas" }
namada_gas = { path = "../gas", optional = true }
namada_parameters = { path = "../parameters" }
namada_storage = { path = "../storage" }
namada_trans_token = { path = "../trans_token" }

borsh.workspace = true
lazy_static.workspace = true
lazy_static = { workspace = true, optional = true }
masp_primitives.workspace = true
masp_proofs.workspace = true
rand_core.workspace = true
masp_proofs = { workspace = true, optional = true, features = ["download-params"] }
rand_core = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }
serde.workspace = true
smooth-operator.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/shielded_token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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;
Expand Down
1 change: 0 additions & 1 deletion crates/shielded_token/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ 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 \
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", "download-params", "std", "rand"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["tendermint-rpc", "validation", "std", "rand"]}
namada_test_utils = {path = "../test_utils"}
namada_tx_prelude = {path = "../tx_prelude"}
namada_vp_prelude = {path = "../vp_prelude"}
Expand Down
2 changes: 1 addition & 1 deletion crates/token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version.workspace = true
[features]
default = []
multicore = ["namada_shielded_token/multicore"]
download-params = ["namada_shielded_token/download-params"]
validation = ["namada_shielded_token/validation"]
testing = ["namada_core/testing", "namada_shielded_token/testing", "proptest"]

[dependencies]
Expand Down

0 comments on commit 9b5a94b

Please sign in to comment.