From e606ec17a0e607ef83a0101568352d992852f9f0 Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Wed, 13 Dec 2023 12:23:12 +0100 Subject: [PATCH 1/6] Add ws producer to stream updated accounts --- Cargo.lock | 145 ++++++++++++++++++++++++++++++----------- node/src/subscriber.rs | 1 + server/Cargo.toml | 5 +- server/src/lib.rs | 10 ++- server/src/server.rs | 2 + server/src/ws.rs | 84 ++++++++++++++++++++++++ 6 files changed, 207 insertions(+), 40 deletions(-) create mode 100644 server/src/ws.rs diff --git a/Cargo.lock b/Cargo.lock index 2e3bb9b..c45c00f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,6 +142,7 @@ checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", + "base64 0.21.7", "bitflags 1.3.2", "bytes", "futures-util", @@ -159,8 +160,10 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", + "sha1", "sync_wrapper", "tokio", + "tokio-tungstenite", "tower", "tower-layer", "tower-service", @@ -225,6 +228,15 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bindgen" version = "0.65.1" @@ -534,9 +546,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ "cfg-if", "cpufeatures", @@ -794,7 +806,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3b3e4fc7882223c86a7cfd8ccdb58e017b89a9f91d90114beafa0e8d35b45fb" dependencies = [ - "curve25519-dalek 4.1.1", + "curve25519-dalek 4.1.2", "generic-array", "hex", "rand 0.8.5", @@ -894,7 +906,7 @@ dependencies = [ [[package]] name = "everscale-rpc-node" -version = "0.1.2" +version = "0.2.0" dependencies = [ "anyhow", "argh", @@ -918,7 +930,7 @@ dependencies = [ [[package]] name = "everscale-rpc-server" -version = "0.2.3" +version = "0.3.0" dependencies = [ "anyhow", "arc-swap", @@ -926,10 +938,12 @@ dependencies = [ "axum", "axum-jrpc", "base64 0.13.1", + "bincode", "broxus-util", "bytes", "everscale-rpc-models", "fdlimit", + "futures-util", "hex", "humantime", "metrics", @@ -948,6 +962,7 @@ dependencies = [ "tower", "tower-http", "tracing", + "uuid", "weedb", ] @@ -1237,9 +1252,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -1442,18 +1457,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1925,9 +1940,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] @@ -1951,19 +1966,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -1984,9 +1998,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -2692,6 +2706,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2906,13 +2931,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -3092,6 +3116,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -3437,6 +3473,25 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -3482,6 +3537,22 @@ dependencies = [ "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "getrandom 0.2.12", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -3535,9 +3606,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3545,9 +3616,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -3560,9 +3631,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -3572,9 +3643,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3582,9 +3653,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -3595,15 +3666,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/node/src/subscriber.rs b/node/src/subscriber.rs index 5b867b1..02c7b2d 100644 --- a/node/src/subscriber.rs +++ b/node/src/subscriber.rs @@ -20,6 +20,7 @@ impl ton_indexer::Subscriber for EngineSubscriber { async fn process_block(&self, ctx: ProcessBlockContext<'_>) -> Result<()> { self.rpc_state .process_block(ctx.block_stuff(), ctx.shard_state_stuff()) + .await .context("Failed to update server state") } diff --git a/server/Cargo.toml b/server/Cargo.toml index 42e4fea..864f204 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -6,12 +6,14 @@ edition = "2021" [dependencies] anyhow = "1.0" arc-swap = { version = "1.6", features = ["weak"] } -axum = { version = "0.6.0", features = ["http2"] } +axum = { version = "0.6.0", features = ["http2", "ws"] } axum-jrpc = { version = "0.5.1", features = ["serde_json"] } base64 = "0.13" +bincode = "1.3" broxus-util = { version = "0.2", default-features = false } bytes = "1.4.0" fdlimit = "0.2.1" +futures-util = "0.3" hex = "0.4" humantime = "2.1" num_cpus = "1.13.1" @@ -25,6 +27,7 @@ tower = "0.4.12" tower-http = { version = "0.4.0", features = ["cors", "timeout"] } tracing = "0.1.37" metrics = "0.22.0" +uuid = { version = "1.6", features = ["v4", "serde"] } weedb = { version = "0.1", features = ["zstd", "lz4", "jemalloc"] } nekoton-abi = { git = "https://github.com/broxus/nekoton.git", default-features = false } diff --git a/server/src/lib.rs b/server/src/lib.rs index f734600..dc9c229 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -19,6 +19,7 @@ mod proto; mod server; mod storage; mod utils; +mod ws; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { @@ -90,6 +91,7 @@ impl ApiConfig { pub struct RpcState { config: Config, engine: ArcSwapWeak, + ws_producer: ws::WsProducer, runtime_storage: RuntimeStorage, persistent_storage: Option, jrpc_counters: Counters, @@ -107,6 +109,7 @@ impl RpcState { config, engine: Default::default(), runtime_storage: Default::default(), + ws_producer: Default::default(), persistent_storage, jrpc_counters: Counters::named("jrpc"), proto_counters: Counters::named("proto"), @@ -206,7 +209,7 @@ impl RpcState { Ok(()) } - pub fn process_block( + pub async fn process_block( &self, block_stuff: &BlockStuff, shard_state: Option<&ShardStateStuff>, @@ -218,9 +221,10 @@ impl RpcState { block_info, shard_state, ) + .await } - pub fn process_block_parts( + pub async fn process_block_parts( &self, block_id: &ton_block::BlockIdExt, block: &ton_block::Block, @@ -240,6 +244,8 @@ impl RpcState { storage.update(block_id, block, shard_state)?; } + self.ws_producer.handle_block(block).await?; + Ok(()) } diff --git a/server/src/server.rs b/server/src/server.rs index 62c6f1e..43d7d82 100644 --- a/server/src/server.rs +++ b/server/src/server.rs @@ -12,6 +12,7 @@ use axum::RequestExt; use crate::jrpc; use crate::proto; +use crate::ws; use crate::RpcState; pub struct Server { @@ -60,6 +61,7 @@ impl Server { let router = axum::Router::new() .route("/", get(health_check)) .route("/", post(common_route)) + .route("/ws", get(ws::ws_router)) .route("/rpc", post(jrpc::jrpc_router)) .route("/proto", post(proto::proto_router)) .layer(service) diff --git a/server/src/ws.rs b/server/src/ws.rs new file mode 100644 index 0000000..915889f --- /dev/null +++ b/server/src/ws.rs @@ -0,0 +1,84 @@ +use std::sync::Arc; + +use anyhow::Result; +use axum::extract::ws::{Message, WebSocket}; +use axum::extract::{Query, State, WebSocketUpgrade}; +use futures_util::stream::SplitSink; +use futures_util::{SinkExt, StreamExt}; +use rustc_hash::FxHashMap; +use serde::{Deserialize, Serialize}; +use tokio::sync::Mutex; +use ton_block::{Deserializable, HashmapAugType}; +use ton_types::HashmapType; + +use crate::server::Server; + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct WebSocketUpgradeQuery { + client_id: uuid::Uuid, +} + +pub async fn ws_router( + ws: WebSocketUpgrade, + State(ctx): State>, + Query(query): Query, +) -> axum::response::Response { + ws.on_upgrade(move |socket| handle_socket(query.client_id, ctx, socket)) +} + +async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSocket) { + let (sender, mut receiver) = socket.split(); + + let clients = &state.state().ws_producer.clients; + clients.lock().await.insert(client_id, sender); + + while let Some(msg) = receiver.next().await { + match msg { + Ok(Message::Close(_)) | Err(_) => { + tracing::warn!(%client_id, "websocket connection closed"); + clients.lock().await.remove(&client_id); + return; + } + Ok(_) => {} + } + } +} + +#[derive(Default)] +pub struct WsProducer { + clients: Mutex>>, +} + +impl WsProducer { + pub async fn handle_block(&self, block: &ton_block::Block) -> Result<()> { + let extra = block.read_extra()?; + let account_blocks = extra.read_account_blocks()?; + + let mut accounts = FxHashMap::default(); + account_blocks.iterate_with_keys(|account, value| { + let mut lt = 0; + value.transactions().iterate_slices(|_, mut value| { + let tx_cell = value.checked_drain_reference()?; + let tx = ton_block::Transaction::construct_from_cell(tx_cell)?; + if lt < tx.logical_time() { + lt = tx.logical_time(); + } + + Ok(true) + })?; + accounts.insert(account.into_vec(), lt); + + Ok(true) + })?; + + let message = bincode::serialize(&accounts)?; + let mut clients = self.clients.lock().await; + for (_, client) in clients.iter_mut() { + let message = axum::extract::ws::Message::Binary(message.clone()); + client.send(message).await?; + } + + Ok(()) + } +} From e1f50ecfe0d6929feb9c61ade2ee1c0b13a5f2b9 Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Fri, 9 Feb 2024 13:35:02 +0100 Subject: [PATCH 2/6] Add workchain id to accounts producer data --- server/src/lib.rs | 4 +++- server/src/ws.rs | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/server/src/lib.rs b/server/src/lib.rs index dc9c229..d51ebf3 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -244,7 +244,9 @@ impl RpcState { storage.update(block_id, block, shard_state)?; } - self.ws_producer.handle_block(block).await?; + self.ws_producer + .handle_block(block_id.shard_id.workchain_id(), block) + .await?; Ok(()) } diff --git a/server/src/ws.rs b/server/src/ws.rs index 915889f..2993888 100644 --- a/server/src/ws.rs +++ b/server/src/ws.rs @@ -8,8 +8,8 @@ use futures_util::{SinkExt, StreamExt}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use tokio::sync::Mutex; -use ton_block::{Deserializable, HashmapAugType}; -use ton_types::HashmapType; +use ton_block::{Deserializable, HashmapAugType, MsgAddressInt}; +use ton_types::{AccountId, HashmapType}; use crate::server::Server; @@ -47,15 +47,15 @@ async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSoc #[derive(Default)] pub struct WsProducer { - clients: Mutex>>, + clients: Mutex>>, } impl WsProducer { - pub async fn handle_block(&self, block: &ton_block::Block) -> Result<()> { + pub async fn handle_block(&self, workchain_id: i32, block: &ton_block::Block) -> Result<()> { let extra = block.read_extra()?; let account_blocks = extra.read_account_blocks()?; - let mut accounts = FxHashMap::default(); + let mut accounts = Vec::with_capacity(account_blocks.len()?); account_blocks.iterate_with_keys(|account, value| { let mut lt = 0; value.transactions().iterate_slices(|_, mut value| { @@ -67,7 +67,14 @@ impl WsProducer { Ok(true) })?; - accounts.insert(account.into_vec(), lt); + + let address = + MsgAddressInt::with_standart(None, workchain_id as i8, AccountId::from(account))?; + + accounts.push(AccountInfo { + account: nekoton_proto::utils::addr_to_bytes(&address).to_vec(), + account_lt: lt, + }); Ok(true) })?; @@ -75,10 +82,16 @@ impl WsProducer { let message = bincode::serialize(&accounts)?; let mut clients = self.clients.lock().await; for (_, client) in clients.iter_mut() { - let message = axum::extract::ws::Message::Binary(message.clone()); + let message = Message::Binary(message.clone()); client.send(message).await?; } Ok(()) } } + +#[derive(Clone, Serialize, Deserialize)] +struct AccountInfo { + pub account: Vec, + pub account_lt: u64, +} From c662804e15f258413e2869b2ab66a93e7b5b1a1c Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Fri, 9 Feb 2024 17:58:42 +0100 Subject: [PATCH 3/6] WIP: speed up sending ws messages --- server/src/ws.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/server/src/ws.rs b/server/src/ws.rs index 2993888..7107a67 100644 --- a/server/src/ws.rs +++ b/server/src/ws.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use anyhow::Result; use axum::extract::ws::{Message, WebSocket}; use axum::extract::{Query, State, WebSocketUpgrade}; -use futures_util::stream::SplitSink; +use futures_util::stream::{FuturesUnordered, SplitSink}; use futures_util::{SinkExt, StreamExt}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; @@ -80,10 +80,25 @@ impl WsProducer { })?; let message = bincode::serialize(&accounts)?; + let mut clients = self.clients.lock().await; - for (_, client) in clients.iter_mut() { - let message = Message::Binary(message.clone()); - client.send(message).await?; + let messages_to_send = FuturesUnordered::new(); + for (client_id, client) in clients.iter_mut() { + messages_to_send.push(async { + let message = Message::Binary(message.clone()); + let res = client.send(message).await; + (*client_id, res) + }); + } + + let messages_to_send = messages_to_send + .collect::)>>() + .await; + + for (client_id, result) in messages_to_send { + if let Err(e) = result { + tracing::error!(%client_id, "failed to send message to ws client: {e}"); + } } Ok(()) From e6e29668f52904ea804e78ba7c90c72c715c1cbb Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Mon, 12 Feb 2024 14:43:15 +0100 Subject: [PATCH 4/6] Use channels to avoid blocking when brodcasting ws messages --- server/src/ws.rs | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/server/src/ws.rs b/server/src/ws.rs index 7107a67..05ce457 100644 --- a/server/src/ws.rs +++ b/server/src/ws.rs @@ -3,11 +3,11 @@ use std::sync::Arc; use anyhow::Result; use axum::extract::ws::{Message, WebSocket}; use axum::extract::{Query, State, WebSocketUpgrade}; -use futures_util::stream::{FuturesUnordered, SplitSink}; +use futures_util::stream::SplitSink; use futures_util::{SinkExt, StreamExt}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; -use tokio::sync::Mutex; +use tokio::sync::{mpsc, Mutex}; use ton_block::{Deserializable, HashmapAugType, MsgAddressInt}; use ton_types::{AccountId, HashmapType}; @@ -28,17 +28,21 @@ pub async fn ws_router( } async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSocket) { - let (sender, mut receiver) = socket.split(); + let (tx, rx) = mpsc::unbounded_channel(); let clients = &state.state().ws_producer.clients; - clients.lock().await.insert(client_id, sender); + clients.lock().await.insert(client_id, tx); + + let (sender, mut receiver) = socket.split(); + + start_listening_ws_events(client_id, sender, rx); while let Some(msg) = receiver.next().await { match msg { Ok(Message::Close(_)) | Err(_) => { tracing::warn!(%client_id, "websocket connection closed"); clients.lock().await.remove(&client_id); - return; + break; } Ok(_) => {} } @@ -47,7 +51,7 @@ async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSoc #[derive(Default)] pub struct WsProducer { - clients: Mutex>>, + clients: Mutex>>, } impl WsProducer { @@ -82,27 +86,34 @@ impl WsProducer { let message = bincode::serialize(&accounts)?; let mut clients = self.clients.lock().await; - let messages_to_send = FuturesUnordered::new(); for (client_id, client) in clients.iter_mut() { - messages_to_send.push(async { - let message = Message::Binary(message.clone()); - let res = client.send(message).await; - (*client_id, res) - }); + let message = Message::Binary(message.clone()); + if let Err(e) = client.send(message) { + tracing::error!(%client_id, "failed to send ws message to channel: {e}") + } } - let messages_to_send = messages_to_send - .collect::)>>() - .await; + Ok(()) + } +} - for (client_id, result) in messages_to_send { - if let Err(e) = result { +fn start_listening_ws_events( + client_id: uuid::Uuid, + mut ws_sender: SplitSink, + mut events_rx: mpsc::UnboundedReceiver, +) { + tokio::spawn(async move { + while let Some(message) = events_rx.recv().await { + if let Err(e) = ws_sender.send(message).await { tracing::error!(%client_id, "failed to send message to ws client: {e}"); } } - Ok(()) - } + tracing::warn!(%client_id, "stopped listening for ws events"); + + events_rx.close(); + while events_rx.recv().await.is_some() {} + }); } #[derive(Clone, Serialize, Deserialize)] From 1e18d41fb174f208e9543eaeecd841b61113c796 Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Mon, 12 Feb 2024 17:38:15 +0100 Subject: [PATCH 5/6] Use bounded channels for ws clients to avoid of memory leaks --- server/src/ws.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/server/src/ws.rs b/server/src/ws.rs index 05ce457..4bcc2c8 100644 --- a/server/src/ws.rs +++ b/server/src/ws.rs @@ -28,7 +28,8 @@ pub async fn ws_router( } async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSocket) { - let (tx, rx) = mpsc::unbounded_channel(); + const BUFFER_SIZE: usize = 100; + let (tx, rx) = mpsc::channel(BUFFER_SIZE); let clients = &state.state().ws_producer.clients; clients.lock().await.insert(client_id, tx); @@ -51,7 +52,7 @@ async fn handle_socket(client_id: uuid::Uuid, state: Arc, socket: WebSoc #[derive(Default)] pub struct WsProducer { - clients: Mutex>>, + clients: Mutex>>, } impl WsProducer { @@ -86,12 +87,16 @@ impl WsProducer { let message = bincode::serialize(&accounts)?; let mut clients = self.clients.lock().await; - for (client_id, client) in clients.iter_mut() { + clients.retain(|client_id, client_tx| { let message = Message::Binary(message.clone()); - if let Err(e) = client.send(message) { - tracing::error!(%client_id, "failed to send ws message to channel: {e}") + match client_tx.try_send(message) { + Ok(_) => true, + Err(e) => { + tracing::error!(%client_id, "failed to send ws message to channel: {e}"); + false + } } - } + }); Ok(()) } @@ -100,7 +105,7 @@ impl WsProducer { fn start_listening_ws_events( client_id: uuid::Uuid, mut ws_sender: SplitSink, - mut events_rx: mpsc::UnboundedReceiver, + mut events_rx: mpsc::Receiver, ) { tokio::spawn(async move { while let Some(message) = events_rx.recv().await { @@ -109,6 +114,10 @@ fn start_listening_ws_events( } } + if let Err(e) = ws_sender.close().await { + tracing::error!(%client_id, "failed to close ws connection: {e}") + } + tracing::warn!(%client_id, "stopped listening for ws events"); events_rx.close(); From 86eb6064deb9755e7e882fd1d869a491f3d0cdad Mon Sep 17 00:00:00 2001 From: Alexey Pashinov Date: Mon, 12 Feb 2024 17:40:23 +0100 Subject: [PATCH 6/6] Fix client example build --- Cargo.lock | 330 ++++++++++++++++++++++++++++++------ client/Cargo.toml | 1 + client/examples/multisig.rs | 2 +- 3 files changed, 276 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c45c00f..4e07a9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,16 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + [[package]] name = "aes" version = "0.8.3" @@ -28,17 +38,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "ahash" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom 0.2.12", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.7" @@ -104,6 +103,12 @@ dependencies = [ "serde", ] +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + [[package]] name = "async-compression" version = "0.4.6" @@ -216,6 +221,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + [[package]] name = "base64" version = "0.13.1" @@ -228,6 +239,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64ct" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" + [[package]] name = "bincode" version = "1.3.3" @@ -374,6 +391,30 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "cipher" version = "0.4.4" @@ -382,6 +423,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] @@ -502,6 +544,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -509,9 +557,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "crypto-mac" version = "0.11.1" @@ -533,9 +592,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest 0.9.0", @@ -730,7 +789,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.2.1", + "curve25519-dalek 3.2.0", "ed25519", "rand 0.7.3", "serde", @@ -790,6 +849,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "errno" version = "0.3.8" @@ -821,7 +889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c027f89fc3be3dc5eb9a6e30fc4118d254ed56f8f53a31e6addccf56f27067ef" dependencies = [ "aes", - "ahash 0.8.7", + "ahash", "anyhow", "async-trait", "bytes", @@ -1225,9 +1293,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.7", -] [[package]] name = "hashbrown" @@ -1235,7 +1300,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" dependencies = [ - "ahash 0.8.7", + "ahash", ] [[package]] @@ -1262,14 +1327,35 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + [[package]] name = "hmac" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac", + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ "digest 0.9.0", + "generic-array", + "hmac 0.8.1", ] [[package]] @@ -1335,7 +1421,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.5", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -1582,6 +1668,50 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "libsecp256k1" +version = "0.7.0" +source = "git+https://github.com/broxus/libsecp256k1.git#fae765aa1a0de4f0c7b7b386d0d46475943291b2" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "git+https://github.com/broxus/libsecp256k1.git#fae765aa1a0de4f0c7b7b386d0d46475943291b2" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "git+https://github.com/broxus/libsecp256k1.git#fae765aa1a0de4f0c7b7b386d0d46475943291b2" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "git+https://github.com/broxus/libsecp256k1.git#fae765aa1a0de4f0c7b7b386d0d46475943291b2" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "libz-sys" version = "1.1.15" @@ -1621,15 +1751,6 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "lru" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" -dependencies = [ - "hashbrown 0.12.3", -] - [[package]] name = "lz4-sys" version = "1.9.4" @@ -1667,13 +1788,19 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "memzero" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" + [[package]] name = "metrics" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77b9e10a211c839210fd7f99954bda26e5f8e26ec686ad68da6a32df7c80e782" dependencies = [ - "ahash 0.8.7", + "ahash", "portable-atomic", ] @@ -1764,38 +1891,50 @@ dependencies = [ [[package]] name = "nekoton" version = "0.13.1" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "anyhow", "async-trait", "base64 0.13.1", + "chacha20poly1305", + "curve25519-dalek-ng", "downcast-rs", "dyn-clone", + "ed25519-dalek 1.0.1 (git+https://github.com/broxus/ed25519-dalek.git)", + "erased-serde", "futures-util", + "getrandom 0.2.12", "hex", + "hmac 0.11.0", "log", - "lru", "nekoton-abi", "nekoton-contracts", "nekoton-utils", "num-bigint", "once_cell", "parking_lot", - "quick_cache 0.3.0", + "pbkdf2", + "quick_cache", + "rand 0.8.5", + "secstr", "serde", "serde_json", + "sha2 0.9.9", "thiserror", + "tiny-bip39", + "tiny-hderive", "tokio", "ton_abi", "ton_block", "ton_executor", "ton_types", + "zeroize", ] [[package]] name = "nekoton-abi" version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "anyhow", "base64 0.13.1", @@ -1822,7 +1961,7 @@ dependencies = [ [[package]] name = "nekoton-contracts" version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "anyhow", "nekoton-abi", @@ -1838,7 +1977,7 @@ dependencies = [ [[package]] name = "nekoton-derive" version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "either", "proc-macro2", @@ -1849,7 +1988,7 @@ dependencies = [ [[package]] name = "nekoton-proto" version = "0.1.0" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "anyhow", "nekoton-abi", @@ -1861,18 +2000,22 @@ dependencies = [ [[package]] name = "nekoton-utils" version = "0.13.0" -source = "git+https://github.com/broxus/nekoton.git#0e5181512d16ea79c04c6171a62a8a1292ee01ce" +source = "git+https://github.com/broxus/nekoton.git#82e682e9e5282bbc7092a71929e3832573514f5a" dependencies = [ "anyhow", "base64 0.13.1", + "chacha20poly1305", "ed25519-dalek 1.0.1 (git+https://github.com/broxus/ed25519-dalek.git)", "hex", - "hmac", + "hmac 0.11.0", + "pbkdf2", + "secstr", "serde", "sha2 0.9.9", "thiserror", "ton_block", "ton_types", + "zeroize", ] [[package]] @@ -2029,6 +2172,9 @@ name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +dependencies = [ + "parking_lot_core", +] [[package]] name = "opaque-debug" @@ -2109,6 +2255,17 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "password-hash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -2121,6 +2278,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pbkdf2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" +dependencies = [ + "crypto-mac 0.11.1", + "hmac 0.11.0", + "password-hash", + "sha2 0.9.9", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -2222,6 +2391,17 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "portable-atomic" version = "1.6.0" @@ -2318,24 +2498,13 @@ dependencies = [ "winapi", ] -[[package]] -name = "quick_cache" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5253a3a0d56548d5b0be25414171dc780cc6870727746d05bd2bde352eee96c5" -dependencies = [ - "ahash 0.8.7", - "hashbrown 0.13.1", - "parking_lot", -] - [[package]] name = "quick_cache" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58c20af3800cee5134b79a3bd4a3d4b583c16ccfa5f53338f46400851a5b3819" dependencies = [ - "ahash 0.8.7", + "ahash", "equivalent", "hashbrown 0.14.3", "parking_lot", @@ -2624,6 +2793,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "secstr" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04f657244f605c4cf38f6de5993e8bd050c8a303f86aeabff142d5c7c113e12" +dependencies = [ + "libc", + "serde", +] + [[package]] name = "security-framework" version = "2.9.2" @@ -3021,6 +3200,35 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +[[package]] +name = "tiny-bip39" +version = "0.8.0" +source = "git+https://github.com/broxus/tiny-bip39.git#d2a73124c2fbead4f969f8a5e075ee22040f63cc" +dependencies = [ + "anyhow", + "hmac 0.11.0", + "once_cell", + "pbkdf2", + "rand 0.8.5", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "zeroize", +] + +[[package]] +name = "tiny-hderive" +version = "0.3.0" +source = "git+https://github.com/broxus/tiny-hderive.git#050986d85711497076ba552ce53806885274a4d2" +dependencies = [ + "base58", + "hmac 0.11.0", + "libsecp256k1", + "memzero", + "sha2 0.9.9", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -3147,7 +3355,7 @@ name = "ton-indexer" version = "0.3.2" source = "git+https://github.com/broxus/ton-indexer.git#9bbb5c0509d1a7e92464d65b75b64f80dd116165" dependencies = [ - "ahash 0.8.7", + "ahash", "anyhow", "arc-swap", "async-trait", @@ -3170,7 +3378,7 @@ dependencies = [ "num-traits", "once_cell", "parking_lot", - "quick_cache 0.4.1", + "quick_cache", "rand 0.8.5", "rlimit", "serde", @@ -3525,6 +3733,16 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + [[package]] name = "url" version = "2.5.0" @@ -3887,9 +4105,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.3.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] diff --git a/client/Cargo.toml b/client/Cargo.toml index 32ded0f..946772a 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -36,6 +36,7 @@ everscale-rpc-models = { path = "../models" } ed25519-dalek = "1.0.1" hex = "0.4.3" tracing-subscriber = { version = "0.3", features = ["env-filter"] } +nekoton = { git = "https://github.com/broxus/nekoton.git", default-features = true } [features] default = ["log"] diff --git a/client/examples/multisig.rs b/client/examples/multisig.rs index 88b3fbc..4dc203f 100644 --- a/client/examples/multisig.rs +++ b/client/examples/multisig.rs @@ -47,7 +47,7 @@ async fn main() { bounce: false, destination: to, amount: 1_000_000_000, - /// can be built with `nekoton_abi::MessageBuilder` + // can be built with `nekoton_abi::MessageBuilder` body: None, state_init: None, },