From d2f27a1d118fab554def7b9dbb49903a2963e36b Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Tue, 22 Oct 2024 16:31:28 +0300 Subject: [PATCH 01/13] Add info_stream_filtered endpoint --- Cargo.lock | 56 +++++++++++++++++++++++++++++++++++------------------- Cargo.toml | 4 ++-- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8c2ad9c7..4ad6123d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1617,17 +1617,17 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=master#47598512b7d282c34b619adf140403feeb138e71" +source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#56207ca2bd76b7590c457b2582090e8783d0586e" dependencies = [ "base64 0.21.7", "byteorder", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "prost", "rand 0.8.5", "rand_chacha 0.3.0", "rust_decimal", "serde", - "sha2 0.10.8", + "sha2 0.9.9", "thiserror", ] @@ -1791,7 +1791,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "http-serde", "humantime-serde", @@ -2642,7 +2642,7 @@ dependencies = [ "axum 0.7.4", "bs58 0.4.0", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "notify", "serde", @@ -3242,7 +3242,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "hex-literal", "http 0.2.11", "lazy_static", @@ -3855,7 +3855,7 @@ dependencies = [ "h3o", "helium-anchor-gen 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=master)", "hex", "hex-literal", "itertools", @@ -3895,6 +3895,22 @@ dependencies = [ "tonic-build", ] +[[package]] +name = "helium-proto" +version = "0.1.0" +source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#56207ca2bd76b7590c457b2582090e8783d0586e" +dependencies = [ + "bytes", + "prost", + "prost-build", + "serde", + "serde_json", + "strum", + "strum_macros", + "tonic", + "tonic-build", +] + [[package]] name = "helium-sub-daos" version = "0.1.8" @@ -3945,7 +3961,7 @@ dependencies = [ "async-trait", "chrono", "derive_builder", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "hextree", "rust_decimal", "rust_decimal_macros", @@ -4370,7 +4386,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "humantime-serde", "metrics", @@ -4439,7 +4455,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "hextree", "http 0.2.11", "http-serde", @@ -4481,7 +4497,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "http-serde", "humantime-serde", @@ -4523,7 +4539,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http-serde", "humantime-serde", "iot-config", @@ -5129,7 +5145,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "hextree", "http 0.2.11", "http-serde", @@ -5169,7 +5185,7 @@ dependencies = [ "futures", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "mobile-config", "prost", "rand 0.8.5", @@ -5214,7 +5230,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "http-serde", "humantime-serde", @@ -5258,7 +5274,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "hex-assignments", "hextree", "http-serde", @@ -5942,7 +5958,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "http 0.2.11", "hyper 0.14.28", "jsonrpsee", @@ -6025,7 +6041,7 @@ dependencies = [ "futures-util", "helium-anchor-gen 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", "helium-lib", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "humantime-serde", "metrics", "metrics-exporter-prometheus", @@ -6676,7 +6692,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", "humantime-serde", "lazy_static", "metrics", @@ -10078,7 +10094,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.10.8", + "sha2 0.9.9", "thiserror", "twox-hash", "xorf", diff --git a/Cargo.toml b/Cargo.toml index a45355a99..b4993f4d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,10 +70,10 @@ helium-lib = { git = "https://github.com/helium/helium-wallet-rs.git", branch = hextree = { git = "https://github.com/jaykickliter/HexTree", branch = "main", features = [ "disktree", ] } -helium-proto = { git = "https://github.com/helium/proto", branch = "master", features = [ +helium-proto = { git = "https://github.com/helium/proto", branch = "mobile-config-filteres-hostpots-stream", features = [ "services", ] } -beacon = { git = "https://github.com/helium/proto", branch = "master" } +beacon = { git = "https://github.com/helium/proto", branch = "mobile-config-filteres-hostpots-stream" } solana-client = "1.18" solana-sdk = "1.18" solana-program = "1.18" From 36c3b99f94908f2c1e1db37cb4be6647af3f9670 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Tue, 22 Oct 2024 18:21:08 +0300 Subject: [PATCH 02/13] Add device_types to GatewayInfoStreamReqV1 --- Cargo.lock | 10 +++++----- mobile_config/src/client/gateway_client.rs | 1 + mobile_config/src/gateway_info.rs | 9 +++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ad6123d3..2c91be058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1617,7 +1617,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#56207ca2bd76b7590c457b2582090e8783d0586e" +source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#1c8796510bbf7513bd35b745fc58aca4a5ca08eb" dependencies = [ "base64 0.21.7", "byteorder", @@ -1627,7 +1627,7 @@ dependencies = [ "rand_chacha 0.3.0", "rust_decimal", "serde", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", ] @@ -3898,7 +3898,7 @@ dependencies = [ [[package]] name = "helium-proto" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#56207ca2bd76b7590c457b2582090e8783d0586e" +source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#1c8796510bbf7513bd35b745fc58aca4a5ca08eb" dependencies = [ "bytes", "prost", @@ -6191,7 +6191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" dependencies = [ "bytes", - "heck 0.4.0", + "heck 0.5.0", "itertools", "log", "multimap", @@ -10094,7 +10094,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", "twox-hash", "xorf", diff --git a/mobile_config/src/client/gateway_client.rs b/mobile_config/src/client/gateway_client.rs index 69ab7f128..dfaa00bed 100644 --- a/mobile_config/src/client/gateway_client.rs +++ b/mobile_config/src/client/gateway_client.rs @@ -97,6 +97,7 @@ impl GatewayInfoResolver for GatewayClient { ) -> Result { let mut req = mobile_config::GatewayInfoStreamReqV1 { batch_size: self.batch_size, + device_types: vec![], signer: self.signing_key.public_key().into(), signature: vec![], }; diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index a9ada7896..9128022bf 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -151,6 +151,15 @@ pub(crate) mod db { .boxed()) } + // pub fn filtered_info_stream<'a>( + // db: impl PgExecutor<'a> + 'a, + // ) -> impl Stream + 'a { + // sqlx::query_as::<_, GatewayInfo>(GET_METADATA_SQL) + // .fetch(db) + // .filter_map(|metadata| async move { metadata.ok() }) + // .boxed() + // } + pub fn all_info_stream<'a>( db: impl PgExecutor<'a> + 'a, ) -> impl Stream + 'a { From 8fbd85793bd6eeb376778cfad4b7990ab37caacb Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Wed, 23 Oct 2024 16:55:00 +0300 Subject: [PATCH 03/13] Add filter by device type --- Cargo.lock | 4 +-- mobile_config/src/gateway_info.rs | 44 ++++++++++++++++++-------- mobile_config/src/gateway_service.rs | 15 +++++++-- mobile_config/tests/gateway_service.rs | 1 + 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c91be058..20a115a58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1627,7 +1627,7 @@ dependencies = [ "rand_chacha 0.3.0", "rust_decimal", "serde", - "sha2 0.10.8", + "sha2 0.9.9", "thiserror", ] @@ -10094,7 +10094,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.10.8", + "sha2 0.9.9", "thiserror", "twox-hash", "xorf", diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index 9128022bf..af67db125 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -73,6 +73,17 @@ pub enum DeviceType { WifiDataOnly, } +impl DeviceType { + fn to_sql_argument(&self) -> String { + match self { + DeviceType::Cbrs => "\"cbrs\"".to_string(), + DeviceType::WifiIndoor => "\"wifiIndoor\"".to_string(), + DeviceType::WifiOutdoor => "\"wifiOutdoor\"".to_string(), + DeviceType::WifiDataOnly => "\"wifiDataOnly\"".to_string(), + } + } +} + impl From for DeviceType { fn from(dtp: DeviceTypeProto) -> Self { match dtp { @@ -116,9 +127,11 @@ pub(crate) mod db { join key_to_assets kta on infos.asset = kta.asset "#; const BATCH_SQL_WHERE_SNIPPET: &str = " where kta.entity_key = any($1::bytea[]) "; + const DEVICE_TYPES_WHERE_SNIPPET: &str = " where device_type::text = any($1) "; lazy_static::lazy_static! { static ref BATCH_METADATA_SQL: String = format!("{GET_METADATA_SQL} {BATCH_SQL_WHERE_SNIPPET}"); + static ref DEVICE_TYPES_METADATA_SQL: String = format!("{GET_METADATA_SQL} {DEVICE_TYPES_WHERE_SNIPPET}"); } pub async fn get_info( @@ -151,22 +164,27 @@ pub(crate) mod db { .boxed()) } - // pub fn filtered_info_stream<'a>( - // db: impl PgExecutor<'a> + 'a, - // ) -> impl Stream + 'a { - // sqlx::query_as::<_, GatewayInfo>(GET_METADATA_SQL) - // .fetch(db) - // .filter_map(|metadata| async move { metadata.ok() }) - // .boxed() - // } - pub fn all_info_stream<'a>( db: impl PgExecutor<'a> + 'a, + device_types: &'a [DeviceType], ) -> impl Stream + 'a { - sqlx::query_as::<_, GatewayInfo>(GET_METADATA_SQL) - .fetch(db) - .filter_map(|metadata| async move { metadata.ok() }) - .boxed() + match device_types.is_empty() { + true => sqlx::query_as::<_, GatewayInfo>(GET_METADATA_SQL) + .fetch(db) + .filter_map(|metadata| async move { metadata.ok() }) + .boxed(), + false => sqlx::query_as::<_, GatewayInfo>(&DEVICE_TYPES_METADATA_SQL) + .bind( + device_types + .into_iter() + .map(|v| v.to_sql_argument()) + .into_iter() + .collect::>(), + ) + .fetch(db) + .filter_map(|metadata| async move { metadata.ok() }) + .boxed(), + } } impl sqlx::FromRow<'_, sqlx::postgres::PgRow> for GatewayInfo { diff --git a/mobile_config/src/gateway_service.rs b/mobile_config/src/gateway_service.rs index 048980d55..700c3d8e3 100644 --- a/mobile_config/src/gateway_service.rs +++ b/mobile_config/src/gateway_service.rs @@ -1,5 +1,5 @@ use crate::{ - gateway_info::{self, GatewayInfo}, + gateway_info::{self, DeviceType, GatewayInfo}, key_cache::KeyCache, telemetry, verify_public_key, GrpcResult, GrpcStreamResult, }; @@ -156,7 +156,10 @@ impl mobile_config::Gateway for GatewayService { let signer = verify_public_key(&request.signer)?; self.verify_request_signature(&signer, &request)?; - tracing::debug!("fetching all gateways' info"); + tracing::debug!( + "fetching all gateways' info. Device types: {:?} ", + request.device_types + ); let pool = self.metadata_pool.clone(); let signing_key = self.signing_key.clone(); @@ -164,8 +167,14 @@ impl mobile_config::Gateway for GatewayService { let (tx, rx) = tokio::sync::mpsc::channel(100); + let device_types: Vec = request + .device_types() + .into_iter() + .map(|v| v.into()) + .collect(); + tokio::spawn(async move { - let stream = gateway_info::db::all_info_stream(&pool); + let stream = gateway_info::db::all_info_stream(&pool, &device_types); stream_multi_gateways_info(stream, tx.clone(), signing_key.clone(), batch_size).await }); diff --git a/mobile_config/tests/gateway_service.rs b/mobile_config/tests/gateway_service.rs index 8a818baad..89ea200a3 100644 --- a/mobile_config/tests/gateway_service.rs +++ b/mobile_config/tests/gateway_service.rs @@ -16,6 +16,7 @@ async fn gateway_info_authorization_errors(pool: PgPool) -> anyhow::Result<()> { // this test. But we're only interested in Authization Errors. let admin_key = make_keypair(); // unlimited access + dbg!(admin_key.public_key()); let gw_key = make_keypair(); // access to self let unknown_key = make_keypair(); // no access let server_key = make_keypair(); // signs responses From 7e09406aaea07583845f29d52ee8d24d7cd4f8b4 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Wed, 23 Oct 2024 17:18:02 +0300 Subject: [PATCH 04/13] Add device_types to GatewayClient --- mobile_config/src/client/gateway_client.rs | 18 +++++++++++++++--- mobile_config/tests/gateway_service.rs | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mobile_config/src/client/gateway_client.rs b/mobile_config/src/client/gateway_client.rs index dfaa00bed..212039e4e 100644 --- a/mobile_config/src/client/gateway_client.rs +++ b/mobile_config/src/client/gateway_client.rs @@ -4,7 +4,10 @@ use file_store::traits::MsgVerify; use futures::stream::{self, StreamExt}; use helium_crypto::{Keypair, PublicKey, PublicKeyBinary, Sign}; use helium_proto::{ - services::{mobile_config, Channel}, + services::{ + mobile_config::{self, DeviceType}, + Channel, + }, Message, }; use retainer::Cache; @@ -50,7 +53,10 @@ pub trait GatewayInfoResolver: Clone + Send + Sync + 'static { address: &PublicKeyBinary, ) -> Result, Self::Error>; - async fn stream_gateways_info(&mut self) -> Result; + async fn stream_gateways_info( + &mut self, + device_types: &[DeviceType], + ) -> Result; } #[async_trait::async_trait] @@ -92,12 +98,18 @@ impl GatewayInfoResolver for GatewayClient { Ok(response) } + /// Returns all gateways if device_types is empty + /// Otherwise, only selected device_types async fn stream_gateways_info( &mut self, + device_types: &[DeviceType], ) -> Result { let mut req = mobile_config::GatewayInfoStreamReqV1 { batch_size: self.batch_size, - device_types: vec![], + device_types: device_types + .into_iter() + .map(|v| DeviceType::into(*v)) + .collect(), signer: self.signing_key.public_key().into(), signature: vec![], }; diff --git a/mobile_config/tests/gateway_service.rs b/mobile_config/tests/gateway_service.rs index 89ea200a3..8a818baad 100644 --- a/mobile_config/tests/gateway_service.rs +++ b/mobile_config/tests/gateway_service.rs @@ -16,7 +16,6 @@ async fn gateway_info_authorization_errors(pool: PgPool) -> anyhow::Result<()> { // this test. But we're only interested in Authization Errors. let admin_key = make_keypair(); // unlimited access - dbg!(admin_key.public_key()); let gw_key = make_keypair(); // access to self let unknown_key = make_keypair(); // no access let server_key = make_keypair(); // signs responses From b82445cc1a1c193f28129eca96cfda05efd89d37 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Wed, 23 Oct 2024 17:27:17 +0300 Subject: [PATCH 05/13] Fix clippy warnings --- mobile_config/src/client/gateway_client.rs | 5 +---- mobile_config/src/gateway_info.rs | 3 +-- mobile_config/src/gateway_service.rs | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/mobile_config/src/client/gateway_client.rs b/mobile_config/src/client/gateway_client.rs index 212039e4e..a1a4a381f 100644 --- a/mobile_config/src/client/gateway_client.rs +++ b/mobile_config/src/client/gateway_client.rs @@ -106,10 +106,7 @@ impl GatewayInfoResolver for GatewayClient { ) -> Result { let mut req = mobile_config::GatewayInfoStreamReqV1 { batch_size: self.batch_size, - device_types: device_types - .into_iter() - .map(|v| DeviceType::into(*v)) - .collect(), + device_types: device_types.iter().map(|v| DeviceType::into(*v)).collect(), signer: self.signing_key.public_key().into(), signature: vec![], }; diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index af67db125..ca8a96fa1 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -176,9 +176,8 @@ pub(crate) mod db { false => sqlx::query_as::<_, GatewayInfo>(&DEVICE_TYPES_METADATA_SQL) .bind( device_types - .into_iter() + .iter() .map(|v| v.to_sql_argument()) - .into_iter() .collect::>(), ) .fetch(db) diff --git a/mobile_config/src/gateway_service.rs b/mobile_config/src/gateway_service.rs index 700c3d8e3..f00655db3 100644 --- a/mobile_config/src/gateway_service.rs +++ b/mobile_config/src/gateway_service.rs @@ -167,11 +167,7 @@ impl mobile_config::Gateway for GatewayService { let (tx, rx) = tokio::sync::mpsc::channel(100); - let device_types: Vec = request - .device_types() - .into_iter() - .map(|v| v.into()) - .collect(); + let device_types: Vec = request.device_types().map(|v| v.into()).collect(); tokio::spawn(async move { let stream = gateway_info::db::all_info_stream(&pool, &device_types); From fbac46179455c5fd5257a2a0055f6fe3da57f95f Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Wed, 23 Oct 2024 17:34:19 +0300 Subject: [PATCH 06/13] Fix test --- mobile_verifier/tests/integrations/speedtests.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mobile_verifier/tests/integrations/speedtests.rs b/mobile_verifier/tests/integrations/speedtests.rs index 38d2fe629..5c6e9b9e8 100644 --- a/mobile_verifier/tests/integrations/speedtests.rs +++ b/mobile_verifier/tests/integrations/speedtests.rs @@ -6,7 +6,9 @@ use file_store::{ FileInfo, }; use helium_crypto::PublicKeyBinary; -use helium_proto::services::poc_mobile::SpeedtestAvgValidity; +use helium_proto::services::{ + mobile_config::DeviceType as MobileDeviceType, poc_mobile::SpeedtestAvgValidity, +}; use mobile_config::{ client::gateway_client::GatewayInfoResolver, gateway_info::{DeviceType, GatewayInfo, GatewayInfoStream}, @@ -35,7 +37,10 @@ impl GatewayInfoResolver for MockGatewayInfoResolver { })) } - async fn stream_gateways_info(&mut self) -> Result { + async fn stream_gateways_info( + &mut self, + _device_types: &[MobileDeviceType], + ) -> Result { todo!() } } From 1b1a059a76fc27e627b7cf4dcdfb4a9fdc107db2 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Thu, 24 Oct 2024 09:00:45 +0300 Subject: [PATCH 07/13] Add gateway_stream_info_data_types test --- mobile_config/tests/gateway_service.rs | 194 ++++++++++++++++++++++++- 1 file changed, 192 insertions(+), 2 deletions(-) diff --git a/mobile_config/tests/gateway_service.rs b/mobile_config/tests/gateway_service.rs index 8a818baad..832da6825 100644 --- a/mobile_config/tests/gateway_service.rs +++ b/mobile_config/tests/gateway_service.rs @@ -1,5 +1,9 @@ -use helium_crypto::{KeyTag, Keypair, PublicKey, Sign}; -use helium_proto::services::mobile_config::{self as proto, GatewayClient}; +use futures::stream::StreamExt; + +use helium_crypto::{KeyTag, Keypair, PublicKey, PublicKeyBinary, Sign}; +use helium_proto::services::mobile_config::{ + self as proto, DeviceType, GatewayClient, GatewayInfoStreamReqV1, GatewayInfoStreamResV1, +}; use mobile_config::{ gateway_service::GatewayService, key_cache::{CacheKeys, KeyCache}, @@ -78,10 +82,196 @@ async fn gateway_info_authorization_errors(pool: PgPool) -> anyhow::Result<()> { Ok(()) } +#[sqlx::test] +async fn gateway_stream_info_data_types(pool: PgPool) { + let admin_key = make_keypair(); + let server_key = make_keypair(); + let asset1_pubkey = make_keypair().public_key().clone(); + let asset1_hex_idx = 631711281837647359_i64; + let asset2_hex_idx = 631711286145955327_i64; + let asset3_hex_idx = 631711286145006591_i64; + let asset2_pubkey = make_keypair().public_key().clone(); + let asset3_pubkey = make_keypair().public_key().clone(); + + create_db_tables(&pool).await; + add_db_record( + &pool, + "asset1", + asset1_hex_idx, + "\"wifiIndoor\"", + asset1_pubkey.clone().into(), + ) + .await; + add_db_record( + &pool, + "asset2", + asset2_hex_idx, + "\"wifiDataOnly\"", + asset2_pubkey.clone().into(), + ) + .await; + add_db_record( + &pool, + "asset3", + asset3_hex_idx, + "\"wifiDataOnly\"", + asset3_pubkey.clone().into(), + ) + .await; + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let addr = listener.local_addr().unwrap(); + + // Start the gateway server + let keys = CacheKeys::from_iter([(admin_key.public_key().to_owned(), KeyRole::Administrator)]); + let (_key_cache_tx, key_cache) = KeyCache::new(keys); + let gws = GatewayService::new(key_cache, pool.clone(), server_key); + let _handle = tokio::spawn( + transport::Server::builder() + .add_service(proto::GatewayServer::new(gws)) + .serve_with_incoming(tokio_stream::wrappers::TcpListenerStream::new(listener)), + ); + let mut client = GatewayClient::connect(format!("http://{addr}")) + .await + .unwrap(); + + // Check wifi indoor + let req = make_gateway_stream_signed_req(&admin_key, &[DeviceType::WifiIndoor]); + let mut stream = client.info_stream(req).await.unwrap().into_inner(); + let res = stream.next().await.unwrap().unwrap(); + let gw_info = res.gateways.first().unwrap(); + let pub_key = PublicKey::from_bytes(gw_info.address.clone()).unwrap(); + assert_eq!(pub_key, asset1_pubkey.clone()); + assert_eq!( + DeviceType::try_from(gw_info.device_type).unwrap(), + DeviceType::WifiIndoor + ); + assert_eq!( + i64::from_str_radix(&gw_info.metadata.clone().unwrap().location, 16).unwrap(), + asset1_hex_idx + ); + assert_eq!(stream.next().await.is_none(), true); + + // Check wifi data only + let req = make_gateway_stream_signed_req(&admin_key, &[DeviceType::WifiDataOnly]); + let stream = client.info_stream(req).await.unwrap().into_inner(); + + let resp = stream + .filter_map(|result| async { result.ok() }) + .collect::>() + .await; + let gateways = resp.first().unwrap().gateways.clone(); + assert_eq!(gateways.len(), 2); + let device_type = gateways.get(0).unwrap().device_type; + assert_eq!( + DeviceType::try_from(device_type).unwrap(), + DeviceType::WifiDataOnly + ); + let device_type = gateways.get(1).unwrap().device_type; + assert_eq!( + DeviceType::try_from(device_type).unwrap(), + DeviceType::WifiDataOnly + ); + + // Check all + let req = make_gateway_stream_signed_req(&admin_key, &[]); + let stream = client.info_stream(req).await.unwrap().into_inner(); + + let resp = stream + .filter_map(|result| async { result.ok() }) + .collect::>() + .await; + let gateways = resp.first().unwrap().gateways.clone(); + assert_eq!(gateways.len(), 3); +} + +async fn add_db_record( + pool: &PgPool, + asset: &str, + location: i64, + device_type: &str, + key: PublicKeyBinary, +) { + add_mobile_hotspot_infos(pool, asset, location, device_type).await; + add_asset_key(pool, asset, key).await; +} + +async fn add_mobile_hotspot_infos(pool: &PgPool, asset: &str, location: i64, device_type: &str) { + sqlx::query( + r#" + INSERT INTO +"mobile_hotspot_infos" ("asset", "location", "device_type") + VALUES +($1, $2, $3::jsonb); + "#, + ) + .bind(asset) + .bind(location) + .bind(device_type) + .execute(pool) + .await + .unwrap(); +} + +async fn add_asset_key(pool: &PgPool, asset: &str, key: PublicKeyBinary) { + let b58 = bs58::decode(key.to_string()).into_vec().unwrap(); + sqlx::query( + r#" + INSERT INTO + "key_to_assets" ("asset", "entity_key") + VALUES ($1, $2); + "#, + ) + .bind(asset) + .bind(b58) + .execute(pool) + .await + .unwrap(); +} + +async fn create_db_tables(pool: &PgPool) { + sqlx::query( + r#" + CREATE TABLE mobile_hotspot_infos ( + asset character varying(255) NULL, + location numeric NULL, + device_type jsonb NOT NULL + );"#, + ) + .execute(pool) + .await + .unwrap(); + + sqlx::query( + r#" + CREATE TABLE key_to_assets ( + asset character varying(255) NULL, + entity_key bytea NULL + );"#, + ) + .execute(pool) + .await + .unwrap(); +} fn make_keypair() -> Keypair { Keypair::generate(KeyTag::default(), &mut rand::rngs::OsRng) } +fn make_gateway_stream_signed_req( + signer: &Keypair, + device_types: &[DeviceType], +) -> proto::GatewayInfoStreamReqV1 { + let mut req = GatewayInfoStreamReqV1 { + batch_size: 10000, + signer: signer.public_key().to_vec(), + signature: vec![], + device_types: device_types.iter().map(|v| DeviceType::into(*v)).collect(), + }; + + req.signature = signer.sign(&req.encode_to_vec()).unwrap(); + req +} + fn make_signed_info_request(address: &PublicKey, signer: &Keypair) -> proto::GatewayInfoReqV1 { let mut req = proto::GatewayInfoReqV1 { address: address.to_vec(), From ef9d21aaa81c7449b80ab855bf30728d0b66d44a Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Thu, 24 Oct 2024 09:05:58 +0300 Subject: [PATCH 08/13] Fix clippy --- mobile_config/tests/gateway_service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile_config/tests/gateway_service.rs b/mobile_config/tests/gateway_service.rs index 832da6825..c1eb71dd3 100644 --- a/mobile_config/tests/gateway_service.rs +++ b/mobile_config/tests/gateway_service.rs @@ -150,7 +150,7 @@ async fn gateway_stream_info_data_types(pool: PgPool) { i64::from_str_radix(&gw_info.metadata.clone().unwrap().location, 16).unwrap(), asset1_hex_idx ); - assert_eq!(stream.next().await.is_none(), true); + assert!(stream.next().await.is_none()); // Check wifi data only let req = make_gateway_stream_signed_req(&admin_key, &[DeviceType::WifiDataOnly]); @@ -162,7 +162,7 @@ async fn gateway_stream_info_data_types(pool: PgPool) { .await; let gateways = resp.first().unwrap().gateways.clone(); assert_eq!(gateways.len(), 2); - let device_type = gateways.get(0).unwrap().device_type; + let device_type = gateways.first().unwrap().device_type; assert_eq!( DeviceType::try_from(device_type).unwrap(), DeviceType::WifiDataOnly From b53ad2d05c5e6b8e92a298bae2080ef46b20288d Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Thu, 24 Oct 2024 19:42:39 +0300 Subject: [PATCH 09/13] Fix review comments --- mobile_config/src/gateway_info.rs | 23 +++++++++++------------ mobile_config/src/gateway_service.rs | 10 +++++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index ca8a96fa1..bc4c70e88 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -73,17 +73,6 @@ pub enum DeviceType { WifiDataOnly, } -impl DeviceType { - fn to_sql_argument(&self) -> String { - match self { - DeviceType::Cbrs => "\"cbrs\"".to_string(), - DeviceType::WifiIndoor => "\"wifiIndoor\"".to_string(), - DeviceType::WifiOutdoor => "\"wifiOutdoor\"".to_string(), - DeviceType::WifiDataOnly => "\"wifiDataOnly\"".to_string(), - } - } -} - impl From for DeviceType { fn from(dtp: DeviceTypeProto) -> Self { match dtp { @@ -99,6 +88,16 @@ impl From for DeviceType { #[error("invalid device type string")] pub struct DeviceTypeParseError; +impl std::fmt::Display for DeviceType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DeviceType::Cbrs => write!(f, "cbrs"), + DeviceType::WifiIndoor => write!(f, "wifiIndoor"), + DeviceType::WifiOutdoor => write!(f, "wifiOutdoor"), + DeviceType::WifiDataOnly => write!(f, "wifiDataOnly"), + } + } +} impl std::str::FromStr for DeviceType { type Err = DeviceTypeParseError; @@ -177,7 +176,7 @@ pub(crate) mod db { .bind( device_types .iter() - .map(|v| v.to_sql_argument()) + .map(|v| format!("\"{}\"", v)) .collect::>(), ) .fetch(db) diff --git a/mobile_config/src/gateway_service.rs b/mobile_config/src/gateway_service.rs index f00655db3..90f1a11f9 100644 --- a/mobile_config/src/gateway_service.rs +++ b/mobile_config/src/gateway_service.rs @@ -156,11 +156,6 @@ impl mobile_config::Gateway for GatewayService { let signer = verify_public_key(&request.signer)?; self.verify_request_signature(&signer, &request)?; - tracing::debug!( - "fetching all gateways' info. Device types: {:?} ", - request.device_types - ); - let pool = self.metadata_pool.clone(); let signing_key = self.signing_key.clone(); let batch_size = request.batch_size; @@ -169,6 +164,11 @@ impl mobile_config::Gateway for GatewayService { let device_types: Vec = request.device_types().map(|v| v.into()).collect(); + tracing::debug!( + "fetching all gateways' info. Device types: {:?} ", + device_types + ); + tokio::spawn(async move { let stream = gateway_info::db::all_info_stream(&pool, &device_types); stream_multi_gateways_info(stream, tx.clone(), signing_key.clone(), batch_size).await From 426a48929f6a14c4d7914b6a53e26ed94da49c45 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Fri, 25 Oct 2024 12:58:24 +0300 Subject: [PATCH 10/13] Add comment --- mobile_config/src/gateway_info.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index bc4c70e88..ada624a81 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -176,6 +176,8 @@ pub(crate) mod db { .bind( device_types .iter() + // The device_types field has a jsonb type but is being used as a string, + // which forces us to add quotes. .map(|v| format!("\"{}\"", v)) .collect::>(), ) From 7ac526e79ce561d453424863f9b18f40e0937482 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 28 Oct 2024 18:59:33 +0200 Subject: [PATCH 11/13] Use helium-proto master --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4993f4d7..a45355a99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,10 +70,10 @@ helium-lib = { git = "https://github.com/helium/helium-wallet-rs.git", branch = hextree = { git = "https://github.com/jaykickliter/HexTree", branch = "main", features = [ "disktree", ] } -helium-proto = { git = "https://github.com/helium/proto", branch = "mobile-config-filteres-hostpots-stream", features = [ +helium-proto = { git = "https://github.com/helium/proto", branch = "master", features = [ "services", ] } -beacon = { git = "https://github.com/helium/proto", branch = "mobile-config-filteres-hostpots-stream" } +beacon = { git = "https://github.com/helium/proto", branch = "master" } solana-client = "1.18" solana-sdk = "1.18" solana-program = "1.18" From 56c81f6c61a9ea02910f2990d7cd6e33aba00fd9 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 28 Oct 2024 19:33:11 +0200 Subject: [PATCH 12/13] Update helium-proto, helium-lib --- Cargo.lock | 339 ++++++++++++++++++++--------------------------------- 1 file changed, 125 insertions(+), 214 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20a115a58..e82993524 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -264,6 +264,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "anchor-client" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb48c4a7911038da546dc752655a29fa49f6bd50ebc1edca218bac8da1012acd" +dependencies = [ + "anchor-lang 0.29.0", + "anyhow", + "futures", + "regex", + "serde", + "solana-account-decoder", + "solana-client", + "solana-sdk", + "thiserror", + "tokio", + "url", +] + [[package]] name = "anchor-client" version = "0.30.0" @@ -475,17 +494,15 @@ dependencies = [ [[package]] name = "anchor-spl" -version = "0.30.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bd077c34449319a1e4e0bc21cea572960c9ae0d0fefda0dd7c52fcc3c647a3" +checksum = "6c4fd6e43b2ca6220d2ef1641539e678bfc31b6cc393cf892b373b5997b6a39a" dependencies = [ - "anchor-lang 0.30.1", - "spl-associated-token-account 3.0.2", - "spl-pod 0.2.2", + "anchor-lang 0.29.0", + "solana-program", + "spl-associated-token-account 2.3.0", "spl-token 4.0.0", - "spl-token-2022 3.0.2", - "spl-token-group-interface 0.2.3", - "spl-token-metadata-interface 0.3.3", + "spl-token-2022 0.9.0", ] [[package]] @@ -1617,17 +1634,17 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#1c8796510bbf7513bd35b745fc58aca4a5ca08eb" +source = "git+https://github.com/helium/proto?branch=master#ad18fa2ac0864a2ec0da1c362139778cfd512ce2" dependencies = [ "base64 0.21.7", "byteorder", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "prost", "rand 0.8.5", "rand_chacha 0.3.0", "rust_decimal", "serde", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", ] @@ -1791,7 +1808,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "http-serde", "humantime-serde", @@ -2129,15 +2146,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "circuit-breaker" -version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "circuit-breaker" version = "0.1.0" @@ -2642,7 +2650,7 @@ dependencies = [ "axum 0.7.4", "bs58 0.4.0", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "notify", "serde", @@ -2780,15 +2788,6 @@ dependencies = [ "parking_lot_core 0.9.8", ] -[[package]] -name = "data-credits" -version = "0.2.2" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "data-credits" version = "0.2.2" @@ -3167,15 +3166,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "fanout" -version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "fanout" version = "0.1.0" @@ -3242,7 +3232,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "hex-literal", "http 0.2.11", "lazy_static", @@ -3752,28 +3742,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "helium-anchor-gen" -version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", - "circuit-breaker 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "data-credits 0.2.2 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "fanout 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "helium-entity-manager 0.2.11 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "helium-sub-daos 0.1.8 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "hexboosting 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "lazy-distributor 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "lazy-transactions 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "mobile-entity-manager 0.1.3 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "price-oracle 0.2.1 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "rewards-oracle 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "treasury-management 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", - "voter-stake-registry 0.3.3 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", -] - [[package]] name = "helium-anchor-gen" version = "0.1.0" @@ -3781,19 +3749,19 @@ source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aec dependencies = [ "anchor-gen", "anchor-lang 0.30.1", - "circuit-breaker 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "data-credits 0.2.2 (git+https://github.com/helium/helium-anchor-gen.git)", - "fanout 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "helium-entity-manager 0.2.11 (git+https://github.com/helium/helium-anchor-gen.git)", - "helium-sub-daos 0.1.8 (git+https://github.com/helium/helium-anchor-gen.git)", - "hexboosting 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "lazy-distributor 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "lazy-transactions 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "mobile-entity-manager 0.1.3 (git+https://github.com/helium/helium-anchor-gen.git)", - "price-oracle 0.2.1 (git+https://github.com/helium/helium-anchor-gen.git)", - "rewards-oracle 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "treasury-management 0.2.0 (git+https://github.com/helium/helium-anchor-gen.git)", - "voter-stake-registry 0.3.3 (git+https://github.com/helium/helium-anchor-gen.git)", + "circuit-breaker", + "data-credits", + "fanout", + "helium-entity-manager", + "helium-sub-daos", + "hexboosting", + "lazy-distributor", + "lazy-transactions", + "mobile-entity-manager", + "price-oracle", + "rewards-oracle", + "treasury-management", + "voter-stake-registry", ] [[package]] @@ -3806,7 +3774,7 @@ dependencies = [ "bs58 0.5.0", "byteorder", "ed25519-compact", - "getrandom 0.1.16", + "getrandom 0.2.10", "k256", "lazy_static", "multihash", @@ -3821,15 +3789,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "helium-entity-manager" -version = "0.2.11" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "helium-entity-manager" version = "0.2.11" @@ -3842,9 +3801,9 @@ dependencies = [ [[package]] name = "helium-lib" version = "0.0.0" -source = "git+https://github.com/helium/helium-wallet-rs.git?branch=master#4acf688beac3c507c33843a745516839e1f814b2" +source = "git+https://github.com/helium/helium-wallet-rs.git?branch=master#6b8a6bbf343027087a401cd907c9f6c848991aac" dependencies = [ - "anchor-client", + "anchor-client 0.29.0", "anchor-spl", "angry-purple-tiger 0.1.0", "async-trait", @@ -3853,9 +3812,9 @@ dependencies = [ "chrono", "futures", "h3o", - "helium-anchor-gen 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git?branch=main)", + "helium-anchor-gen", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=master)", + "helium-proto", "hex", "hex-literal", "itertools", @@ -3882,7 +3841,7 @@ dependencies = [ [[package]] name = "helium-proto" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=master#47598512b7d282c34b619adf140403feeb138e71" +source = "git+https://github.com/helium/proto?branch=master#ad18fa2ac0864a2ec0da1c362139778cfd512ce2" dependencies = [ "bytes", "prost", @@ -3895,31 +3854,6 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "helium-proto" -version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream#1c8796510bbf7513bd35b745fc58aca4a5ca08eb" -dependencies = [ - "bytes", - "prost", - "prost-build", - "serde", - "serde_json", - "strum", - "strum_macros", - "tonic", - "tonic-build", -] - -[[package]] -name = "helium-sub-daos" -version = "0.1.8" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "helium-sub-daos" version = "0.1.8" @@ -3961,7 +3895,7 @@ dependencies = [ "async-trait", "chrono", "derive_builder", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "hextree", "rust_decimal", "rust_decimal_macros", @@ -3974,15 +3908,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hexboosting" -version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "hexboosting" version = "0.1.0" @@ -4386,7 +4311,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "humantime-serde", "metrics", @@ -4455,7 +4380,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "hextree", "http 0.2.11", "http-serde", @@ -4497,7 +4422,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "http-serde", "humantime-serde", @@ -4539,7 +4464,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http-serde", "humantime-serde", "iot-config", @@ -4794,15 +4719,6 @@ dependencies = [ "libc", ] -[[package]] -name = "lazy-distributor" -version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "lazy-distributor" version = "0.2.0" @@ -4812,15 +4728,6 @@ dependencies = [ "anchor-lang 0.30.1", ] -[[package]] -name = "lazy-transactions" -version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "lazy-transactions" version = "0.2.0" @@ -5145,7 +5052,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "hextree", "http 0.2.11", "http-serde", @@ -5185,7 +5092,7 @@ dependencies = [ "futures", "h3o", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "mobile-config", "prost", "rand 0.8.5", @@ -5197,15 +5104,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "mobile-entity-manager" -version = "0.1.3" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "mobile-entity-manager" version = "0.1.3" @@ -5230,7 +5128,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "http-serde", "humantime-serde", @@ -5274,7 +5172,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "hex-assignments", "hextree", "http-serde", @@ -5642,7 +5540,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.58", @@ -5958,7 +5856,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "http 0.2.11", "hyper 0.14.28", "jsonrpsee", @@ -6039,9 +5937,9 @@ dependencies = [ "file-store", "futures", "futures-util", - "helium-anchor-gen 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", + "helium-anchor-gen", "helium-lib", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "humantime-serde", "metrics", "metrics-exporter-prometheus", @@ -6062,15 +5960,6 @@ dependencies = [ "triggered", ] -[[package]] -name = "price-oracle" -version = "0.2.1" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "price-oracle" version = "0.2.1" @@ -6249,11 +6138,10 @@ dependencies = [ [[package]] name = "pyth-solana-receiver-sdk" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e6559643f0b377b6f293269251f6a804ae7332c37f7310371f50c833453cd0" +version = "0.3.1" +source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja/cap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" dependencies = [ - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", "hex", "pythnet-sdk", "solana-program", @@ -6261,9 +6149,8 @@ dependencies = [ [[package]] name = "pythnet-sdk" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbbc0456f9f27c9ad16b6c3bf1b2a7fea61eebf900f4d024a0468b9a84fe0c1" +version = "2.3.0" +source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja/cap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" dependencies = [ "anchor-lang 0.30.1", "bincode", @@ -6272,7 +6159,6 @@ dependencies = [ "byteorder", "fast-math", "hex", - "proc-macro2", "rustc_version 0.4.0", "serde", "sha3 0.10.6", @@ -6692,7 +6578,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mobile-config-filteres-hostpots-stream)", + "helium-proto", "humantime-serde", "lazy_static", "metrics", @@ -6723,15 +6609,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "rewards-oracle" -version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "rewards-oracle" version = "0.2.0" @@ -7453,14 +7330,14 @@ dependencies = [ name = "solana" version = "0.1.0" dependencies = [ - "anchor-client", + "anchor-client 0.30.0", "anyhow", "async-trait", "chrono", "clap 4.4.8", "file-store", "futures", - "helium-anchor-gen 0.1.0 (git+https://github.com/helium/helium-anchor-gen.git)", + "helium-anchor-gen", "helium-crypto", "itertools", "metrics", @@ -8451,6 +8328,20 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "spl-tlv-account-resolution" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "062e148d3eab7b165582757453632ffeef490c02c86a48bfdb4988f63eefb3b9" +dependencies = [ + "bytemuck", + "solana-program", + "spl-discriminator 0.1.1", + "spl-pod 0.1.1", + "spl-program-error 0.3.1", + "spl-type-length-value 0.3.1", +] + [[package]] name = "spl-tlv-account-resolution" version = "0.5.2" @@ -8509,6 +8400,28 @@ dependencies = [ "thiserror", ] +[[package]] +name = "spl-token-2022" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4abf34a65ba420584a0c35f3903f8d727d1f13ababbdc3f714c6b065a686e86" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive 0.4.2", + "num-traits", + "num_enum 0.7.2", + "solana-program", + "solana-zk-token-sdk", + "spl-memo", + "spl-pod 0.1.1", + "spl-token 4.0.0", + "spl-token-metadata-interface 0.2.0", + "spl-transfer-hook-interface 0.3.0", + "spl-type-length-value 0.3.1", + "thiserror", +] + [[package]] name = "spl-token-2022" version = "1.0.0" @@ -8611,6 +8524,22 @@ dependencies = [ "spl-type-length-value 0.4.3", ] +[[package]] +name = "spl-transfer-hook-interface" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051d31803f873cabe71aec3c1b849f35248beae5d19a347d93a5c9cccc5d5a9b" +dependencies = [ + "arrayref", + "bytemuck", + "solana-program", + "spl-discriminator 0.1.1", + "spl-pod 0.1.1", + "spl-program-error 0.3.1", + "spl-tlv-account-resolution 0.4.0", + "spl-type-length-value 0.3.1", +] + [[package]] name = "spl-transfer-hook-interface" version = "0.4.1" @@ -9357,15 +9286,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "treasury-management" -version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "treasury-management" version = "0.2.0" @@ -9415,7 +9335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "rand 0.7.3", + "rand 0.8.5", "static_assertions", ] @@ -9614,15 +9534,6 @@ dependencies = [ "vcell", ] -[[package]] -name = "voter-stake-registry" -version = "0.3.3" -source = "git+https://github.com/helium/helium-anchor-gen.git?branch=main#761b839a71cc6d2aecf4be994af9d8206aeae0e1" -dependencies = [ - "anchor-gen", - "anchor-lang 0.30.1", -] - [[package]] name = "voter-stake-registry" version = "0.3.3" @@ -10094,7 +10005,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", "twox-hash", "xorf", From 5632499d29228a51d751a33d7485ee50f70ac39a Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Mon, 28 Oct 2024 19:44:38 +0200 Subject: [PATCH 13/13] Downgrade anchor-lang to 0.29 --- Cargo.lock | 79 +++++++++++++++++++++--------------------------------- Cargo.toml | 2 +- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e82993524..ba84a1667 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -283,25 +283,6 @@ dependencies = [ "url", ] -[[package]] -name = "anchor-client" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4adc1b211826d72036dc2fcb679a8ef7fe5b9afda376b0b26debe19e28de3ea" -dependencies = [ - "anchor-lang 0.30.1", - "anyhow", - "futures", - "regex", - "serde", - "solana-account-decoder", - "solana-client", - "solana-sdk", - "thiserror", - "tokio", - "url", -] - [[package]] name = "anchor-derive-accounts" version = "0.29.0" @@ -2149,10 +2130,10 @@ dependencies = [ [[package]] name = "circuit-breaker" version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -2791,10 +2772,10 @@ dependencies = [ [[package]] name = "data-credits" version = "0.2.2" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -3169,10 +3150,10 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fanout" version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -3745,10 +3726,10 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "helium-anchor-gen" version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", "circuit-breaker", "data-credits", "fanout", @@ -3792,10 +3773,10 @@ dependencies = [ [[package]] name = "helium-entity-manager" version = "0.2.11" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -3803,7 +3784,7 @@ name = "helium-lib" version = "0.0.0" source = "git+https://github.com/helium/helium-wallet-rs.git?branch=master#6b8a6bbf343027087a401cd907c9f6c848991aac" dependencies = [ - "anchor-client 0.29.0", + "anchor-client", "anchor-spl", "angry-purple-tiger 0.1.0", "async-trait", @@ -3857,10 +3838,10 @@ dependencies = [ [[package]] name = "helium-sub-daos" version = "0.1.8" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -3911,10 +3892,10 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hexboosting" version = "0.1.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -4722,19 +4703,19 @@ dependencies = [ [[package]] name = "lazy-distributor" version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] name = "lazy-transactions" version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -5107,10 +5088,10 @@ dependencies = [ [[package]] name = "mobile-entity-manager" version = "0.1.3" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -5963,10 +5944,10 @@ dependencies = [ [[package]] name = "price-oracle" version = "0.2.1" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -6612,10 +6593,10 @@ dependencies = [ [[package]] name = "rewards-oracle" version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -7330,7 +7311,7 @@ dependencies = [ name = "solana" version = "0.1.0" dependencies = [ - "anchor-client 0.30.0", + "anchor-client", "anyhow", "async-trait", "chrono", @@ -9289,10 +9270,10 @@ dependencies = [ [[package]] name = "treasury-management" version = "0.2.0" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] @@ -9537,10 +9518,10 @@ dependencies = [ [[package]] name = "voter-stake-registry" version = "0.3.3" -source = "git+https://github.com/helium/helium-anchor-gen.git#761b839a71cc6d2aecf4be994af9d8206aeae0e1" +source = "git+https://github.com/helium/helium-anchor-gen.git#a7e694d49245ca9830bcfef68cce34f230c91011" dependencies = [ "anchor-gen", - "anchor-lang 0.30.1", + "anchor-lang 0.29.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a45355a99..9860df9a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ license = "Apache-2.0" edition = "2021" [workspace.dependencies] -anchor-client = { version = "0.30.0", features = ["async"] } +anchor-client = { version = "0.29.0", features = ["async"] } anyhow = { version = "1", features = ["backtrace"] } bs58 = { version = "0.4", features = ["check"] } thiserror = "1"