Skip to content

Commit 35e2100

Browse files
committed
Feature/wasm tendermint rpc client (#3744)
* wasm-compatible reqwest-based rpc client * better constructors for the reqwest based client * fixed usages of the client * introduced /network/details endpoint to nym-api to return used network information (#3758) * introduced /network/details endpoint to nym-api to return used network information * introduced endpoints for nym contract information
1 parent efe81f3 commit 35e2100

File tree

75 files changed

+1336
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1336
-317
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ cw3 = { version = "=1.1.0" }
134134
cw4 = { version = "=1.1.0" }
135135
cw-controllers = { version = "=1.1.0" }
136136
dotenvy = "0.15.6"
137+
futures = "0.3.28"
137138
generic-array = "0.14.7"
138139
getrandom = "0.2.10"
139140
k256 = "0.13"
@@ -148,7 +149,7 @@ tap = "1.0.1"
148149
tendermint-rpc = "0.32" # same version as used by cosmrs
149150
thiserror = "1.0.38"
150151
tokio = "1.24.1"
151-
url = "2.2"
152+
url = "2.4"
152153
zeroize = "1.6.0"
153154

154155
# wasm-related dependencies

clients/native/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ path = "src/lib.rs"
1414

1515
[dependencies]
1616
# dependencies to review:
17-
futures = "0.3" # bunch of futures stuff, however, now that I think about it, it could perhaps be completely removed
17+
futures = { workspace = true } # bunch of futures stuff, however, now that I think about it, it could perhaps be completely removed
1818
# the AsyncRead, AsyncWrite, Stream, Sink, etc. traits could be used from tokio
1919
# channels should really be replaced with crossbeam due to that implementation being more efficient
2020
# and the single instance of abortable we have should really be refactored anyway
21-
url = "2.2"
21+
url = { workspace = true }
2222

2323
clap = { version = "4.0", features = ["cargo", "derive"] }
2424
dirs = "4.0"
@@ -28,7 +28,7 @@ pretty_env_logger = "0.4" # for formatting log messages
2828
rand = { version = "0.7.3", features = ["wasm-bindgen"] } # rng-related traits + some rng implementation to use
2929
serde = { workspace = true, features = ["derive"] } # for config serialization/deserialization
3030
serde_json = { workspace = true }
31-
thiserror = "1.0.34"
31+
thiserror = { workspace = true }
3232
tap = "1.0.1"
3333
tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] } # async runtime
3434
tokio-tungstenite = "0.14" # websocket

clients/socks5/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pretty_env_logger = "0.4"
1414
serde = { workspace = true, features = ["derive"] } # for config serialization/deserialization
1515
serde_json = { workspace = true }
1616
tap = "1.0.1"
17-
thiserror = "1.0.34"
17+
thiserror = { workspace = true }
1818
tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] }
19-
url = "2.2"
19+
url = { workspace = true }
2020

2121
# internal
2222
nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] }

clients/webassembly/Cargo.lock

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/webassembly/src/client/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use nym_task::TaskManager;
2525
use nym_topology::provider_trait::{HardcodedTopologyProvider, TopologyProvider};
2626
use nym_topology::NymTopology;
2727
use nym_validator_client::client::IdentityKey;
28-
use nym_validator_client::QueryWasmRpcNyxdClient;
28+
use nym_validator_client::QueryReqwestRpcNyxdClient;
2929
use rand::rngs::OsRng;
3030
use rand::RngCore;
3131
use std::sync::Arc;
@@ -152,7 +152,11 @@ impl NymClientBuilder {
152152
let maybe_topology_provider = self.topology_provider();
153153

154154
let mut base_builder: BaseClientBuilder<_, FullWasmClientStorage> =
155-
BaseClientBuilder::<QueryWasmRpcNyxdClient, _>::new(&self.config.base, storage, None);
155+
BaseClientBuilder::<QueryReqwestRpcNyxdClient, _>::new(
156+
&self.config.base,
157+
storage,
158+
None,
159+
);
156160
if let Some(topology_provider) = maybe_topology_provider {
157161
base_builder = base_builder.with_topology_provider(topology_provider);
158162
}

clients/webassembly/src/tester/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use nym_sphinx::preparer::PreparedFragment;
2626
use nym_task::TaskManager;
2727
use nym_topology::NymTopology;
2828
use nym_validator_client::client::IdentityKey;
29-
use nym_validator_client::QueryWasmRpcNyxdClient;
29+
use nym_validator_client::QueryReqwestRpcNyxdClient;
3030
use rand::rngs::OsRng;
3131
use std::collections::HashSet;
3232
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
@@ -41,7 +41,8 @@ mod ephemeral_receiver;
4141
pub(crate) mod helpers;
4242

4343
pub type NodeTestMessage = TestMessage<WasmTestMessageExt>;
44-
type LockedGatewayClient = Arc<AsyncMutex<GatewayClient<QueryWasmRpcNyxdClient, EphemeralStorage>>>;
44+
type LockedGatewayClient =
45+
Arc<AsyncMutex<GatewayClient<QueryReqwestRpcNyxdClient, EphemeralStorage>>>;
4546

4647
pub(crate) const DEFAULT_TEST_TIMEOUT: Duration = Duration::from_secs(10);
4748
pub(crate) const DEFAULT_TEST_PACKETS: u32 = 20;
@@ -77,7 +78,7 @@ pub struct NymNodeTesterBuilder {
7778
base_topology: NymTopology,
7879

7980
// unimplemented
80-
bandwidth_controller: Option<BandwidthController<QueryWasmRpcNyxdClient, EphemeralStorage>>,
81+
bandwidth_controller: Option<BandwidthController<QueryReqwestRpcNyxdClient, EphemeralStorage>>,
8182
}
8283

8384
fn address(keys: &ManagedKeys, gateway_identity: NodeIdentity) -> Recipient {

common/async-file-watcher/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ edition = "2021"
88
[dependencies]
99
log = "0.4"
1010
tokio = { workspace = true, features = ["time"] }
11-
futures = "0.3"
11+
futures = { workspace = true }
1212
notify = "5.1.0"

common/bandwidth-controller/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
bip39 = { workspace = true }
1010
rand = "0.7.3"
1111
thiserror = "1.0"
12-
url = "2.2"
12+
url = { workspace = true }
1313

1414
nym-coconut-interface = { path = "../coconut-interface" }
1515
nym-credential-storage = { path = "../credential-storage" }

common/client-core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async-trait = { workspace = true }
1212
base64 = "0.21.2"
1313
dashmap = "5.4.0"
1414
dirs = "4.0"
15-
futures = "0.3"
15+
futures = { workspace = true }
1616
humantime-serde = "1.0"
1717
log = { workspace = true }
1818
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
@@ -25,7 +25,7 @@ thiserror = "1.0.34"
2525
time = "0.3.17"
2626
tokio = { version = "1.24.1", features = ["macros"]}
2727
tungstenite = { version = "0.13.0", default-features = false }
28-
url = { version ="2.2", features = ["serde"] }
28+
url = { workspace = true, features = ["serde"] }
2929
zeroize = { workspace = true }
3030

3131
# internal

common/client-core/src/client/base_client/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::client::topology_control::{
2525
};
2626
use crate::config::{Config, DebugConfig};
2727
use crate::error::ClientCoreError;
28-
use crate::init::{setup_gateway, GatewaySetup, InitialisationDetails};
28+
use crate::init::{setup_gateway, GatewaySetup, InitialisationDetails, InitialisationResult};
2929
use crate::{config, spawn_future};
3030
use futures::channel::mpsc;
3131
use log::{debug, info};

common/client-libs/gateway-client/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ edition = "2021"
99
[dependencies]
1010
# TODO: (for this and other crates), similarly to 'tokio', import only required "futures" modules rather than
1111
# the entire crate
12-
futures = "0.3"
12+
futures = { workspace = true }
1313
log = { workspace = true }
14-
thiserror = "1.0"
15-
url = "2.2"
14+
thiserror = { workspace = true }
15+
url = { workspace = true }
1616
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
1717
tokio = { version = "1.24.1", features = ["macros"] }
1818

common/client-libs/mixnet-client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
futures = "0.3"
10+
futures = { workspace = true }
1111
log = { workspace = true }
1212
tokio = { version = "1.24.1", features = ["time", "net", "rt"] }
1313
tokio-util = { version = "0.7.4", features = ["codec"] }

common/client-libs/validator-client/Cargo.toml

+9-8
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ nym-service-provider-directory-common = { path = "../../cosmwasm-smart-contracts
2323
serde = { workspace = true, features = ["derive"] }
2424
serde_json = { workspace = true }
2525
reqwest = { workspace = true, features = ["json"] }
26-
thiserror = "1"
26+
thiserror = { workspace = true }
2727
log = { workspace = true }
28-
url = { version = "2.2", features = ["serde"] }
28+
url = { workspace = true, features = ["serde"] }
2929
tokio = { workspace = true, features = ["sync", "time"] }
30-
futures = "0.3"
30+
futures = { workspace = true }
3131
openssl = { version = "^0.10.55", features = ["vendored"], optional = true }
3232

3333
nym-coconut-interface = { path = "../../coconut-interface" }
@@ -53,14 +53,17 @@ prost = { version = "0.11", default-features = false }
5353
flate2 = { version = "1.0.20" }
5454
sha2 = { version = "0.9.5" }
5555
itertools = { version = "0.10" }
56-
zeroize = { version = "1.5.7", features = ["zeroize_derive"] }
56+
zeroize = { workspace = true, features = ["zeroize_derive"] }
5757
cosmwasm-std = { workspace = true }
5858

59+
# required for polling for broadcast result
60+
[target."cfg(target_arch = \"wasm32\")".dependencies.wasmtimer]
61+
workspace = true
62+
features = ["tokio"]
63+
5964
[dev-dependencies]
6065
bip39 = { workspace = true }
61-
#cosmrs = { workspace = true, features = ["rpc", "bip32"] }
6266
cosmrs = { workspace = true, features = ["bip32"] }
63-
tokio = { version = "1.24.1", features = ["rt-multi-thread", "macros"] }
6467
ts-rs = "6.1.2"
6568

6669
[[example]]
@@ -72,12 +75,10 @@ required-features = ["http-client"]
7275

7376
[[example]]
7477
name = "query_service_provider_directory"
75-
# TODO: validate the requirements
7678
required-features = ["http-client"]
7779

7880
[[example]]
7981
name = "query_name_service"
80-
# TODO: validate the requirements
8182
required-features = ["http-client"]
8283

8384
[features]

0 commit comments

Comments
 (0)