From fa49cda2d31bc76f4180a0efcc72d0788e1e55d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 8 Jan 2024 16:19:01 +0000 Subject: [PATCH] various fixes --- benches/Cargo.toml | 2 +- core/src/types/address.rs | 2 +- core/src/types/key/common.rs | 4 ++-- core/src/types/key/ed25519.rs | 4 ++-- core/src/types/key/mod.rs | 4 ++-- core/src/types/key/secp256k1.rs | 4 ++-- encoding_spec/Cargo.toml | 2 +- proof_of_stake/src/error.rs | 1 - sdk/Cargo.toml | 2 +- shared/Cargo.toml | 2 ++ wasm_for_tests/wasm_source/Cargo.lock | 14 ++++++++++++++ 11 files changed, 28 insertions(+), 13 deletions(-) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index b467253e2d..6d9e1b33fd 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -40,7 +40,7 @@ path = "host_env.rs" [dependencies] [dev-dependencies] -namada = { path = "../shared", features = ["testing"] } +namada = { path = "../shared", features = ["std", "testing"] } namada_apps = { path = "../apps", features = ["benches"] } masp_primitives.workspace = true borsh.workspace = true diff --git a/core/src/types/address.rs b/core/src/types/address.rs index 53a736e1d5..fd71eb821e 100644 --- a/core/src/types/address.rs +++ b/core/src/types/address.rs @@ -728,7 +728,7 @@ pub mod tests { } /// Generate a new established address. -#[cfg(feature = "rand")] +#[cfg(any(test, feature = "rand"))] pub fn gen_established_address(seed: impl AsRef) -> Address { use rand::prelude::ThreadRng; use rand::{thread_rng, RngCore}; diff --git a/core/src/types/key/common.rs b/core/src/types/key/common.rs index 8fd921449d..7db4641879 100644 --- a/core/src/types/key/common.rs +++ b/core/src/types/key/common.rs @@ -7,7 +7,7 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; -#[cfg(feature = "rand")] +#[cfg(any(test, feature = "rand"))] use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -394,7 +394,7 @@ impl super::SigScheme for SigScheme { const TYPE: SchemeType = SchemeType::Common; - #[cfg(feature = "rand")] + #[cfg(any(test, feature = "rand"))] fn generate(_csprng: &mut R) -> SecretKey where R: CryptoRng + RngCore, diff --git a/core/src/types/key/ed25519.rs b/core/src/types/key/ed25519.rs index 7096ba21cc..2e118fe90e 100644 --- a/core/src/types/key/ed25519.rs +++ b/core/src/types/key/ed25519.rs @@ -10,7 +10,7 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use borsh_ext::BorshSerializeExt; use data_encoding::HEXLOWER; -#[cfg(feature = "rand")] +#[cfg(any(test, feature = "rand"))] use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use zeroize::{Zeroize, ZeroizeOnDrop}; @@ -350,7 +350,7 @@ impl super::SigScheme for SigScheme { const TYPE: SchemeType = SchemeType::Ed25519; - #[cfg(feature = "rand")] + #[cfg(any(test, feature = "rand"))] fn generate(csprng: &mut R) -> SecretKey where R: CryptoRng + RngCore, diff --git a/core/src/types/key/mod.rs b/core/src/types/key/mod.rs index 8bfb51d80c..7416587bf3 100644 --- a/core/src/types/key/mod.rs +++ b/core/src/types/key/mod.rs @@ -11,7 +11,7 @@ use std::str::FromStr; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use borsh_ext::BorshSerializeExt; use data_encoding::HEXUPPER; -#[cfg(feature = "rand")] +#[cfg(any(test, feature = "rand"))] use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -225,7 +225,7 @@ pub trait SigScheme: Eq + Ord + Debug + Serialize + Default { const TYPE: SchemeType; /// Generate a keypair. - #[cfg(feature = "rand")] + #[cfg(any(test, feature = "rand"))] fn generate(csprng: &mut R) -> Self::SecretKey where R: CryptoRng + RngCore; diff --git a/core/src/types/key/secp256k1.rs b/core/src/types/key/secp256k1.rs index 29407b9191..06ae2c4216 100644 --- a/core/src/types/key/secp256k1.rs +++ b/core/src/types/key/secp256k1.rs @@ -14,7 +14,7 @@ use data_encoding::HEXLOWER; use ethabi::Token; use k256::ecdsa::RecoveryId; use k256::elliptic_curve::sec1::ToEncodedPoint; -#[cfg(feature = "rand")] +#[cfg(any(test, feature = "rand"))] use rand::{CryptoRng, RngCore}; use serde::de::{Error, SeqAccess, Visitor}; use serde::ser::SerializeTuple; @@ -548,7 +548,7 @@ impl super::SigScheme for SigScheme { const TYPE: SchemeType = SchemeType::Secp256k1; - #[cfg(feature = "rand")] + #[cfg(any(test, feature = "rand"))] fn generate(csprng: &mut R) -> SecretKey where R: CryptoRng + RngCore, diff --git a/encoding_spec/Cargo.toml b/encoding_spec/Cargo.toml index 972c50a2cc..838457b824 100644 --- a/encoding_spec/Cargo.toml +++ b/encoding_spec/Cargo.toml @@ -16,7 +16,7 @@ version.workspace = true default = [] [dependencies] -namada = {path = "../shared"} +namada = { path = "../shared", features = ["std", "tendermint-rpc", "download-params"] } borsh.workspace = true itertools.workspace = true lazy_static.workspace = true diff --git a/proof_of_stake/src/error.rs b/proof_of_stake/src/error.rs index ec8e7c9733..6516809575 100644 --- a/proof_of_stake/src/error.rs +++ b/proof_of_stake/src/error.rs @@ -4,7 +4,6 @@ use std::num::TryFromIntError; use namada_core::types::address::Address; use namada_core::types::dec::Dec; use namada_core::types::storage::Epoch; -use namada_storage; use thiserror::Error; use crate::rewards; diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index a567c4bdd6..411db9f311 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -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"] +default = ["tendermint-rpc", "download-params", "std"] multicore = ["masp_proofs/multicore"] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 5cc94ca0e6..627d6fafbb 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -69,6 +69,8 @@ multicore = [ "namada_sdk/multicore", "namada_token/multicore", ] +# Download MASP params if they're not present +download-params = ["namada_sdk/download-params"] [dependencies] namada_account = { path = "../account" } diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 2702a6d803..39c79a2f62 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -1783,6 +1783,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fd-lock" +version = "3.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" +dependencies = [ + "cfg-if 1.0.0", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "ff" version = "0.13.0" @@ -3575,6 +3586,7 @@ dependencies = [ "derivation-path", "ethbridge-bridge-contract", "ethers", + "fd-lock", "futures", "itertools 0.10.5", "lazy_static", @@ -3599,6 +3611,8 @@ dependencies = [ "paste", "proptest", "prost 0.12.3", + "rand 0.8.5", + "rand_core 0.6.4", "ripemd", "serde", "serde_json",