diff --git a/Cargo.lock b/Cargo.lock index b8c2ad9c7..d9f54b940 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=mj/sp-promotions-v2#a8d299d99ca50a0d646f8607e37d7f0fd0866b96" dependencies = [ "base64 0.21.7", "byteorder", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2#a8d299d99ca50a0d646f8607e37d7f0fd0866b96" +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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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=mj/sp-promotions-v2)", "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..299b1cba6 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 = "mj/sp-promotions-v2", features = [ "services", ] } -beacon = { git = "https://github.com/helium/proto", branch = "master" } +beacon = { git = "https://github.com/helium/proto", branch = "mj/sp-promotions-v2" } solana-client = "1.18" solana-sdk = "1.18" solana-program = "1.18" diff --git a/mobile_config/src/client/carrier_service_client.rs b/mobile_config/src/client/carrier_service_client.rs index 96f213a9f..69e9be28c 100644 --- a/mobile_config/src/client/carrier_service_client.rs +++ b/mobile_config/src/client/carrier_service_client.rs @@ -5,7 +5,7 @@ use file_store::traits::{MsgVerify, TimestampEncode}; use helium_crypto::{Keypair, PublicKey, Sign}; use helium_proto::{ services::{mobile_config, Channel}, - Message, ServiceProvider, ServiceProviderPromotion, + Message, ServiceProvider, ServiceProviderPromotions, }; use retainer::Cache; use std::{str::FromStr, sync::Arc, time::Duration}; @@ -17,8 +17,9 @@ pub trait CarrierServiceVerifier { payer: &str, ) -> Result; - async fn list_incentive_promotions(&self) - -> Result, Self::Error>; + async fn list_incentive_promotions( + &self, + ) -> Result, Self::Error>; } #[derive(Clone)] pub struct CarrierServiceClient { @@ -68,7 +69,7 @@ impl CarrierServiceVerifier for CarrierServiceClient { async fn list_incentive_promotions( &self, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { let mut request = mobile_config::CarrierIncentivePromotionListReqV1 { timestamp: Utc::now().encode_timestamp_millis(), signer: self.signing_key.public_key().into(), diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index 263901fd7..a433594e7 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -316,7 +316,7 @@ where boosted_poc_bones_per_reward_share: Some(helium_proto::Decimal { value: poc_dc_shares.boost.to_string(), }), - sp_promotions: sp_promotions.into_proto(), + service_provider_promotions: sp_promotions.into_proto(), }; self.reward_manifests .write( diff --git a/mobile_verifier/src/service_provider/dc_sessions.rs b/mobile_verifier/src/service_provider/dc_sessions.rs index 499e100f1..3c1de37bf 100644 --- a/mobile_verifier/src/service_provider/dc_sessions.rs +++ b/mobile_verifier/src/service_provider/dc_sessions.rs @@ -106,7 +106,7 @@ where pub mod tests { use chrono::Duration; - use helium_proto::{ServiceProvider, ServiceProviderPromotion}; + use helium_proto::{ServiceProvider, ServiceProviderPromotions}; use crate::data_session::HotspotDataSession; @@ -136,7 +136,7 @@ pub mod tests { async fn list_incentive_promotions( &self, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { Ok(vec![]) } } diff --git a/mobile_verifier/src/service_provider/promotions.rs b/mobile_verifier/src/service_provider/promotions.rs index 9038d46a7..a731f2f2c 100644 --- a/mobile_verifier/src/service_provider/promotions.rs +++ b/mobile_verifier/src/service_provider/promotions.rs @@ -5,7 +5,7 @@ use rust_decimal_macros::dec; use crate::service_provider::ServiceProviderId; mod proto { - pub use helium_proto::{Promotion, ServiceProviderPromotion}; + pub use helium_proto::{service_provider_promotions::Promotion, ServiceProviderPromotions}; } pub async fn get_promotions( @@ -16,10 +16,10 @@ pub async fn get_promotions( } #[derive(Debug, Default, Clone)] -pub struct ServiceProviderPromotions(Vec); +pub struct ServiceProviderPromotions(Vec); impl ServiceProviderPromotions { - pub fn into_proto(self) -> Vec { + pub fn into_proto(self) -> Vec { self.0 } @@ -44,8 +44,8 @@ impl ServiceProviderPromotions { } } -impl From> for ServiceProviderPromotions { - fn from(value: Vec) -> Self { +impl From> for ServiceProviderPromotions { + fn from(value: Vec) -> Self { Self(value) } } diff --git a/mobile_verifier/src/service_provider/reward.rs b/mobile_verifier/src/service_provider/reward.rs index 385415dbd..9bb11af79 100644 --- a/mobile_verifier/src/service_provider/reward.rs +++ b/mobile_verifier/src/service_provider/reward.rs @@ -12,10 +12,10 @@ use super::{dc_sessions::ServiceProviderDCSessions, promotions::ServiceProviderP mod proto { pub use helium_proto::{ + service_provider_promotions::Promotion, services::poc_mobile::{ mobile_reward_share::Reward, MobileRewardShare, PromotionReward, ServiceProviderReward, }, - Promotion, }; } @@ -350,19 +350,19 @@ mod tests { let sp_infos = ServiceProviderRewardInfos::new( ServiceProviderDCSessions::from([(0, dec!(12)), (1, dec!(6))]), ServiceProviderPromotions::from(vec![ - helium_proto::ServiceProviderPromotion { + helium_proto::ServiceProviderPromotions { service_provider: 0, incentive_escrow_fund_bps: 5000, - promotions: vec![helium_proto::Promotion { + promotions: vec![helium_proto::service_provider_promotions::Promotion { entity: "promo-0".to_string(), shares: 1, ..Default::default() }], }, - helium_proto::ServiceProviderPromotion { + helium_proto::ServiceProviderPromotions { service_provider: 1, incentive_escrow_fund_bps: 10000, - promotions: vec![helium_proto::Promotion { + promotions: vec![helium_proto::service_provider_promotions::Promotion { entity: "promo-1".to_string(), shares: 1, ..Default::default() @@ -450,16 +450,16 @@ mod tests { let sp_infos = ServiceProviderRewardInfos::new( ServiceProviderDCSessions::from([(0, sp_session)]), - ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotion { + ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotions { service_provider: 0, incentive_escrow_fund_bps: 10000, promotions: vec![ - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-0".to_string(), shares: 1, ..Default::default() }, - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-1".to_string(), shares: 2, ..Default::default() @@ -489,16 +489,16 @@ mod tests { let sp_infos = ServiceProviderRewardInfos::new( ServiceProviderDCSessions::from([(0, sp_session)]), - ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotion { + ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotions { service_provider: 0, incentive_escrow_fund_bps: 10000, promotions: vec![ - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-0".to_string(), shares: 1, ..Default::default() }, - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-1".to_string(), shares: 2, ..Default::default() @@ -528,16 +528,16 @@ mod tests { let sp_infos = ServiceProviderRewardInfos::new( ServiceProviderDCSessions::from([(0, sp_session)]), - ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotion { + ServiceProviderPromotions::from(vec![helium_proto::ServiceProviderPromotions { service_provider: 0, incentive_escrow_fund_bps: 100, // severely limit promotions promotions: vec![ - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-0".to_string(), shares: 1, ..Default::default() }, - helium_proto::Promotion { + helium_proto::service_provider_promotions::Promotion { entity: "promo-1".to_string(), shares: 2, ..Default::default() @@ -562,7 +562,7 @@ mod tests { use proptest::prelude::*; prop_compose! { - fn arb_promotion()(entity: String, shares in 1..=100u32) -> helium_proto::Promotion { + fn arb_promotion()(entity: String, shares in 1..=100u32) -> helium_proto::service_provider_promotions::Promotion { proto::Promotion { entity, shares, ..Default::default() } } } @@ -572,8 +572,8 @@ mod tests { sp_id in 0..10_i32, bps in arb_bps(), promotions in prop::collection::vec(arb_promotion(), 0..10) - ) -> helium_proto::ServiceProviderPromotion { - helium_proto::ServiceProviderPromotion { + ) -> helium_proto::ServiceProviderPromotions { + helium_proto::ServiceProviderPromotions { service_provider: sp_id, incentive_escrow_fund_bps: bps, promotions @@ -746,11 +746,11 @@ mod tests { entity: &str, incentive_escrow_fund_bps: u32, shares: u32, - ) -> helium_proto::ServiceProviderPromotion { - helium_proto::ServiceProviderPromotion { + ) -> helium_proto::ServiceProviderPromotions { + helium_proto::ServiceProviderPromotions { service_provider: sp_id, incentive_escrow_fund_bps, - promotions: vec![helium_proto::Promotion { + promotions: vec![helium_proto::service_provider_promotions::Promotion { entity: entity.to_string(), start_ts: Utc::now().encode_timestamp_millis(), end_ts: Utc::now().encode_timestamp_millis(), diff --git a/mobile_verifier/tests/integrations/rewarder_sp_rewards.rs b/mobile_verifier/tests/integrations/rewarder_sp_rewards.rs index 47fb9fb9c..f118466c5 100644 --- a/mobile_verifier/tests/integrations/rewarder_sp_rewards.rs +++ b/mobile_verifier/tests/integrations/rewarder_sp_rewards.rs @@ -4,10 +4,11 @@ use std::string::ToString; use async_trait::async_trait; use chrono::{DateTime, Duration as ChronoDuration, Utc}; use helium_proto::{ + service_provider_promotions::Promotion, services::poc_mobile::{ MobileRewardShare, ServiceProviderReward, UnallocatedReward, UnallocatedRewardType, }, - Promotion, ServiceProvider, ServiceProviderPromotion, + ServiceProvider, ServiceProviderPromotions, }; use rust_decimal::prelude::*; use rust_decimal_macros::dec; @@ -28,7 +29,7 @@ pub type ValidSpMap = HashMap; #[derive(Debug, Clone)] pub struct MockCarrierServiceClient { pub valid_sps: ValidSpMap, - pub promotions: Vec, + pub promotions: Vec, } impl MockCarrierServiceClient { @@ -39,7 +40,7 @@ impl MockCarrierServiceClient { } } - fn with_promotions(self, promotions: Vec) -> Self { + fn with_promotions(self, promotions: Vec) -> Self { Self { promotions, ..self } } } @@ -61,7 +62,7 @@ impl CarrierServiceVerifier for MockCarrierServiceClient { async fn list_incentive_promotions( &self, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { Ok(self.promotions.clone()) } } @@ -161,7 +162,7 @@ async fn test_service_provider_promotion_rewards(pool: PgPool) -> anyhow::Result let valid_sps = HashMap::from_iter([(PAYER_1.to_string(), SP_1.to_string())]); // promotions allocated 15.00% let carrier_client = - MockCarrierServiceClient::new(valid_sps).with_promotions(vec![ServiceProviderPromotion { + MockCarrierServiceClient::new(valid_sps).with_promotions(vec![ServiceProviderPromotions { service_provider: 0, incentive_escrow_fund_bps: 1500, promotions: vec![