Skip to content

Commit

Permalink
fixup! fix everything that was depending on rm'd namada crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jun 21, 2024
1 parent 77ba84b commit e12cdab
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ wasmer = "4.3.1"
wasmer-cache = "4.3.1"
wasmer-compiler-singlepass = "4.3.1"
wasmer-vm = "4.3.1"
wasmtimer = "0.2.0"
winapi = "0.3.9"
yansi = "0.5.1"
zeroize = { version = "1.5.5", features = ["zeroize_derive"] }
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ check:
check-mainnet:
$(cargo) check --workspace --features "mainnet"

# Check that every crate can be built with default features and that namada crate
# can be built for wasm
# Check that every crate can be built with default features and that SDK crate
# can be built for wasm and with all features enabled
check-crates:
rustup target add --toolchain $(nightly) wasm32-unknown-unknown
$(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \
make -C $(wasms) check && \
make -C $(wasms_for_tests) check && \
cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk" && \
cargo check --package namada_sdk --target wasm32-unknown-unknown --no-default-features && \
cargo check --package namada_sdk --all-features

clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings
Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namada_core = {path = "../core"}
namada_macros = {path = "../macros"}
namada_migrations = {path = "../migrations", optional = true}
namada_sdk = {path = "../sdk", default-features = false, features = [
"async-client", "std", "tendermint-rpc", "rand", "validation", "multicore"
"std", "validation", "multicore"
]}
namada_test_utils = {path = "../test_utils", optional = true}
namada_vm = {path = "../vm"}
Expand Down
11 changes: 9 additions & 2 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ migrations = [
"linkme",
]
benches = ["proptest"]
control_flow = ["futures", "tokio"]
control_flow = ["futures", "tokio", "wasmtimer"]

[dependencies]
namada_macros = {path = "../macros"}
Expand Down Expand Up @@ -72,10 +72,16 @@ tendermint = {workspace = true}
tendermint-proto = {workspace = true}
thiserror.workspace = true
tiny-keccak = {version = "2.0.2", features = ["keccak"]}
tokio = { workspace = true, optional = true, features = ["full"]}
tracing.workspace = true
uint = "0.9.5"
zeroize.workspace = true
wasmtimer = { workspace = true, optional = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { workspace = true, optional = true, features = ["full"] }

[target.'cfg(target_family = "wasm")'.dependencies]
tokio = { workspace = true, optional = true, default-features = false, features = ["sync"] }

[dev-dependencies]
assert_matches.workspace = true
Expand All @@ -88,3 +94,4 @@ test-log.workspace = true
tokio = { workspace = true, features = ["full"] }
toml.workspace = true
tracing-subscriber.workspace = true
wasmtimer.workspace = true
2 changes: 1 addition & 1 deletion crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namada-eth-bridge = [
namada_apps_lib = {path = "../apps_lib"}
namada_migrations = {path = "../migrations", optional = true}
namada_replay_protection = {path = "../replay_protection"}
namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std", "rand"]}
namada_sdk = {path = "../sdk", default-features = false, features = ["validation", "std"]}
namada_test_utils = {path = "../test_utils", optional = true}
namada_vm = {path = "../vm"}
namada_vote_ext = { path = "../vote_ext" }
Expand Down
28 changes: 6 additions & 22 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,11 @@ version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

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

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

multicore = ["masp_proofs/multicore"]

namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"]

std = ["fd-lock"]
rand = ["dep:rand", "rand_core", "namada_core/rand"]

# tendermint-rpc support
tendermint-rpc = ["async-client", "dep:tendermint-rpc"]

# Enable queries support for an async client
async-client = ["async-trait"]

async-send = []

namada-eth-bridge = ["namada_ethereum_bridge/namada-eth-bridge"]

# for integration tests and test utilities
Expand All @@ -49,7 +35,6 @@ testing = [
"namada_storage/testing",
"namada_token/testing",
"namada_tx/testing",
"async-client",
"proptest",
"jubjub",
"validation",
Expand All @@ -74,7 +59,7 @@ migrations = [

[dependencies]
namada_account = { path = "../account" }
namada_core = { path = "../core", features = ["control_flow"] }
namada_core = { path = "../core", features = ["control_flow", "rand"] }
namada_ethereum_bridge = { path = "../ethereum_bridge", default-features = false }
namada_events = { path = "../events" }
namada_gas = { path = "../gas" }
Expand All @@ -92,7 +77,7 @@ namada_vm = { path = "../vm", optional = true }
namada_vote_ext = { path = "../vote_ext" }
namada_vp = { path = "../vp", optional = true }

async-trait = { workspace = true, optional = true }
async-trait.workspace = true
bimap.workspace = true
borsh.workspace = true
borsh-ext.workspace = true
Expand All @@ -119,16 +104,16 @@ paste.workspace = true
patricia_tree.workspace = true
proptest = { workspace = true, optional = true }
prost.workspace = true
rand = { workspace = true, optional = true }
rand_core = { workspace = true, optional = true }
rand.workspace = true
rand_core.workspace = true
regex.workspace = true
ripemd.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
slip10_ed25519.workspace = true
smooth-operator.workspace = true
tendermint-rpc = { workspace = true, optional = true }
tendermint-rpc.workspace = true
thiserror.workspace = true
tiny-bip39.workspace = true
tiny-hderive.workspace = true
Expand All @@ -141,7 +126,6 @@ tokio = { workspace = true, features = ["full"] }

[target.'cfg(target_family = "wasm")'.dependencies]
tokio = { workspace = true, default-features = false, features = ["sync"] }
wasmtimer = "0.2.0"

[dev-dependencies]
namada_account = { path = "../account", features = ["testing"]}
Expand Down
5 changes: 2 additions & 3 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
extern crate alloc;

pub use namada_core::*;
#[cfg(feature = "tendermint-rpc")]
pub use tendermint_rpc;
pub use {
bip39, masp_primitives, masp_proofs, namada_account as account,
namada_gas as gas, namada_governance as governance, namada_ibc as ibc,
namada_parameters as parameters, namada_proof_of_stake as proof_of_stake,
namada_state as state, namada_storage as storage, namada_token as token,
zeroize,
tendermint_rpc, zeroize,
};

pub mod eth_bridge;
Expand All @@ -41,6 +39,7 @@ pub mod error;
pub mod events;
pub(crate) mod internal_macros;
pub mod io;
#[cfg(feature = "migrations")]
pub mod migrations;
pub mod queries;
pub mod wallet;
Expand Down
25 changes: 2 additions & 23 deletions crates/sdk/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#![allow(missing_docs)]

#[cfg(not(feature = "migrations"))]
use core::fmt::Formatter;
#[cfg(feature = "migrations")]
use core::fmt::{Display, Formatter};
#[cfg(feature = "migrations")]
use core::str::FromStr;
use std::marker::PhantomData;
use std::path::{Path, PathBuf};
Expand All @@ -15,20 +11,13 @@ use data_encoding::HEXUPPER;
use eyre::eyre;
use namada_core::hash::Hash;
use namada_core::storage::{BlockHeight, Key};
#[cfg(feature = "migrations")]
use namada_macros::derive_borshdeserializer;
#[cfg(feature = "migrations")]
use namada_macros::typehash;
#[cfg(feature = "migrations")]
use namada_migrations::TypeHash;
#[cfg(feature = "migrations")]
use namada_migrations::*;
use namada_macros::{derive_borshdeserializer, typehash};
use namada_migrations::{TypeHash, *};
use namada_storage::{DbColFam, DbMigration, DB};
use regex::Regex;
use serde::de::{DeserializeOwned, Error, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[cfg(feature = "migrations")]
/// The maximum number of character printed per value.
const PRINTLN_CUTOFF: usize = 300;

Expand Down Expand Up @@ -58,7 +47,6 @@ pub struct UpdateValue {
bytes: UpdateBytes,
}

#[cfg(feature = "migrations")]
impl UpdateValue {
/// Using a type that is a thin wrapper around bytes but with a custom
/// serialization when we don't want to use Borsh necessarily
Expand Down Expand Up @@ -119,7 +107,6 @@ impl UpdateValue {
}
}

#[cfg(feature = "migrations")]
impl<T: TypeHash + BorshSerialize + BorshDeserialize> From<T> for UpdateValue {
fn from(value: T) -> Self {
Self {
Expand Down Expand Up @@ -196,7 +183,6 @@ pub enum DbUpdateType {

impl DbMigration for DbUpdateType {}

#[cfg(feature = "migrations")]
impl DbUpdateType {
/// Get the key or pattern being modified as string
pub fn pattern(&self) -> String {
Expand Down Expand Up @@ -432,7 +418,6 @@ impl<D: DbMigration> IntoIterator for DbChanges<D> {
self.changes.into_iter()
}
}
#[cfg(feature = "migrations")]
impl Display for DbUpdateType {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Expand Down Expand Up @@ -484,7 +469,6 @@ pub enum UpdateStatus {
Add(Vec<(String, String)>),
}

#[cfg(feature = "migrations")]
impl Display for UpdateStatus {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Expand Down Expand Up @@ -543,18 +527,14 @@ pub fn commit<D: DB>(
}
}

#[cfg(feature = "migrations")]
derive_borshdeserializer!(Vec::<u8>);
#[cfg(feature = "migrations")]
derive_borshdeserializer!(Vec::<String>);
#[cfg(feature = "migrations")]
derive_borshdeserializer!(u64);

#[derive(BorshSerialize, BorshDeserialize)]
#[repr(transparent)]
pub struct SerializeWrapper<T: BorshSerialize + BorshDeserialize>(T);

#[cfg(feature = "migrations")]
impl TypeHash
for SerializeWrapper<
std::collections::BTreeMap<String, namada_core::address::Address>,
Expand All @@ -564,7 +544,6 @@ impl TypeHash
typehash!(SerializeWrapper<BTreeMap<String, Address>>);
}

#[cfg(feature = "migrations")]
#[distributed_slice(REGISTER_DESERIALIZERS)]
static BTREEMAP_STRING_ADDRESS: fn() = || {
use std::collections::BTreeMap;
Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ use crate::tendermint::block::Height;
/// A client with async request dispatcher method, which can be used to invoke
/// type-safe methods from a root [`Router`], generated
/// via `router!` macro.
#[cfg(any(test, feature = "async-client"))]
#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
pub trait Client {
Expand Down
5 changes: 1 addition & 4 deletions crates/sdk/src/queries/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ macro_rules! pattern_and_handler_to_method {

#[allow(dead_code)]
#[allow(clippy::too_many_arguments)]
#[cfg(any(test, feature = "async-client"))]
#[doc = "Request value with optional data (used for e.g. \
`dry_run_tx`), optionally specified height (supported for \
`storage_value`) and optional proof (supported for \
Expand Down Expand Up @@ -451,7 +450,6 @@ macro_rules! pattern_and_handler_to_method {

#[allow(dead_code)]
#[allow(clippy::too_many_arguments)]
#[cfg(any(test, feature = "async-client"))]
#[doc = "Request value with optional data (used for e.g. \
`dry_run_tx`), optionally specified height (supported for \
`storage_value`) and optional proof (supported for \
Expand Down Expand Up @@ -507,7 +505,6 @@ macro_rules! pattern_and_handler_to_method {

#[allow(dead_code)]
#[allow(clippy::too_many_arguments)]
#[cfg(any(test, feature = "async-client"))]
#[doc = "Request a simple borsh-encoded value from `" $handle "`, \
without any additional request data, specified block height or \
proof."]
Expand Down Expand Up @@ -729,7 +726,7 @@ macro_rules! router_type {

/// Compile time tree patterns router with type-safe dynamic parameter parsing,
/// automatic routing, type-safe path constructors and optional client query
/// methods (enabled with `feature = "async-client"`).
/// methods.
///
/// The `router!` macro implements greedy matching algorithm.
///
Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/queries/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use namada_ibc::event::IbcEventType;
use namada_state::{DBIter, LastBlock, StateRead, StorageHasher, DB};
use namada_storage::{ResultExt, StorageRead};
use namada_token::storage_key::masp_token_map_key;
#[cfg(any(test, feature = "async-client"))]
use namada_tx::data::TxResult;

use self::eth_bridge::{EthBridge, ETH_BRIDGE};
Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/queries/vp/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ where
}

/// Client-only methods for the router type are composed from router functions.
#[cfg(any(test, feature = "async-client"))]
pub mod client_only_methods {
use super::*;
use crate::queries::{Client, RPC};
Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/queries/vp/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ where
}
}

#[cfg(any(test, feature = "async-client"))]
pub mod client_only_methods {
use borsh::BorshDeserialize;
use namada_core::address::Address;
Expand Down
6 changes: 2 additions & 4 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ namada-eth-bridge = [

[dependencies]
namada_core = {path = "../core", features = ["testing"]}
namada_sdk = {path = "../sdk", default-features = false, features = [
"tendermint-rpc", "validation", "std", "rand", "testing"
]}
namada_sdk = {path = "../sdk", features = ["validation", "testing"]}
namada_test_utils = {path = "../test_utils"}
namada_tx_env = {path = "../tx_env"}
namada_tx_prelude = {path = "../tx_prelude"}
Expand Down Expand Up @@ -59,7 +57,7 @@ tokio = {workspace = true, features = ["full"]}
namada_apps_lib = {path = "../apps_lib", features = ["testing"]}
namada_node = { path = "../node", features = ["testing"] }
namada_sdk = {path = "../sdk", default-features = false, features = [
"tendermint-rpc", "validation", "std", "rand", "testing", "migrations"
"validation", "testing", "migrations"
]}
namada_vm_env = {path = "../vm_env"}

Expand Down
2 changes: 1 addition & 1 deletion crates/tests/src/vm_host_env/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use namada_sdk::tx::Tx;
pub use namada_sdk::tx::*;
use namada_sdk::{account, token};
use namada_tx_prelude::transaction::TxSentinel;
use namada_tx_prelude::{BatchedTx, BorshSerializeExt, Ctx};
use namada_tx_prelude::{BorshSerializeExt, Ctx};
use namada_vm::wasm::run::Error;
use namada_vm::wasm::{self, TxCache, VpCache};
use namada_vm::WasmCacheRwAccess;
Expand Down
Loading

0 comments on commit e12cdab

Please sign in to comment.