From e5c24852a78b85678b1a1ed7b7007b8e0fc754fb Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Mon, 19 Aug 2024 15:34:23 -0400 Subject: [PATCH 01/14] Add subscriber referral eligibility ingest --- src/service/poc_mobile.proto | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 97b750c2..dfda39a4 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -278,6 +278,33 @@ message verified_subscriber_location_ingest_report_v1 { uint64 timestamp = 3; } +message subscriber_referral_eligibility_req_v1 { + // Id of the subsciber which will get the referral rewards + bytes subscriber_id = 1; + // Shares rewardsed to the subscriber + uint64 shares = 2; + // Pubkey of the carrier for which the subscriber is attached + bytes carrier_pub_key = 3; + // Signed payload of the request + bytes signature = 4; +} + +message subscriber_referral_eligibility_resp_v1 { string id = 1; } + +enum subscriber_referral_eligibility_status { + referral_eligibility_status_valid = 0; + referral_eligibility_status_invalid_subscriber_id = 1; + referral_eligibility_status_invalid_carrier_key = 2; +} + +message subscriber_referral_eligibility_ingest_report_v1 { + subscriber_referral_eligibility_req_v1 report = 1; + // Status of the report + subscriber_referral_eligibility_status status = 2; + // Timestamp in milliseconds since the unix epoch + uint64 timestamp = 3; +} + service poc_mobile { rpc submit_speedtest(speedtest_req_v1) returns (speedtest_resp_v1); rpc submit_cell_heartbeat(cell_heartbeat_req_v1) @@ -301,6 +328,9 @@ service poc_mobile { rpc submit_subscriber_verified_mapping_event( subscriber_verified_mapping_event_req_v1) returns (subscriber_verified_mapping_event_res_v1); + rpc submit_subscriber_referral_eligibility( + subscriber_referral_eligibility_req_v1) + returns (subscriber_referral_eligibility_resp_v1); } message file_info { @@ -811,4 +841,4 @@ message verified_subscriber_verified_mapping_event_ingest_report_v1 { subscriber_verified_mapping_event_verification_status status = 2; // Timestamp in milliseconds since unix epoch uint64 timestamp = 3; -} \ No newline at end of file +} From e074c5b7a39e382c3233332b7c50dbb1cb2079a5 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 15:16:46 -0400 Subject: [PATCH 02/14] Address comments --- src/service/poc_mobile.proto | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index dfda39a4..9b44682b 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -283,25 +283,34 @@ message subscriber_referral_eligibility_req_v1 { bytes subscriber_id = 1; // Shares rewardsed to the subscriber uint64 shares = 2; + // Timestamp in seconds since the unix epoch + uint64 timestamp = 3; // Pubkey of the carrier for which the subscriber is attached - bytes carrier_pub_key = 3; + bytes carrier_pub_key = 4; // Signed payload of the request - bytes signature = 4; + bytes signature = 5; } message subscriber_referral_eligibility_resp_v1 { string id = 1; } +message subscriber_referral_eligibility_ingest_report_v1 { + // Timestamp in milliseconds since the unix epoch + uint64 received_timestamp = 1; + subscriber_referral_eligibility_req_v1 report = 1; +} + enum subscriber_referral_eligibility_status { referral_eligibility_status_valid = 0; referral_eligibility_status_invalid_subscriber_id = 1; referral_eligibility_status_invalid_carrier_key = 2; } -message subscriber_referral_eligibility_ingest_report_v1 { - subscriber_referral_eligibility_req_v1 report = 1; +message verified_subscriber_referral_eligibility_ingest_report_v1 { + subscriber_referral_eligibility_ingest_report_v1 report = 1; // Status of the report subscriber_referral_eligibility_status status = 2; - // Timestamp in milliseconds since the unix epoch + // Timestamp at which verification was determined, in milliseconds since + // the unix epoch uint64 timestamp = 3; } @@ -794,8 +803,7 @@ enum service_provider_boosted_rewards_banned_radio_verification_status { sp_boosted_rewards_ban_invalid_carrier_key = 1; } -message -verified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { +messageverified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { // The verified report service_provider_boosted_rewards_banned_radio_ingest_report_v1 report = 1; // The status determined by the verification From 875672e1c186119cae8a8ef44aaa18ecede1d707 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 15:19:29 -0400 Subject: [PATCH 03/14] Fix --- src/service/poc_mobile.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 9b44682b..118f8583 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -803,7 +803,7 @@ enum service_provider_boosted_rewards_banned_radio_verification_status { sp_boosted_rewards_ban_invalid_carrier_key = 1; } -messageverified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { +message verified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { // The verified report service_provider_boosted_rewards_banned_radio_ingest_report_v1 report = 1; // The status determined by the verification From 6db3aca28cb8cbf9868e478ac9345349aad9d809 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 15:24:56 -0400 Subject: [PATCH 04/14] Another one --- src/service/poc_mobile.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 118f8583..2bc7d5dc 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -296,7 +296,7 @@ message subscriber_referral_eligibility_resp_v1 { string id = 1; } message subscriber_referral_eligibility_ingest_report_v1 { // Timestamp in milliseconds since the unix epoch uint64 received_timestamp = 1; - subscriber_referral_eligibility_req_v1 report = 1; + subscriber_referral_eligibility_req_v1 report = 2; } enum subscriber_referral_eligibility_status { From a4a84f639d967c6919cd5249a044ec08dc017758 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 15:32:03 -0400 Subject: [PATCH 05/14] Fmt --- src/service/poc_mobile.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 2bc7d5dc..d54cad6a 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -803,7 +803,8 @@ enum service_provider_boosted_rewards_banned_radio_verification_status { sp_boosted_rewards_ban_invalid_carrier_key = 1; } -message verified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { +message +verified_service_provider_boosted_rewards_banned_radio_ingest_report_v1 { // The verified report service_provider_boosted_rewards_banned_radio_ingest_report_v1 report = 1; // The status determined by the verification From c3df910864054c777d9962bd31dc6890d8565f2f Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 17:25:53 -0400 Subject: [PATCH 06/14] No longer are only subscribers rewarded, so are everyone else --- src/service/poc_mobile.proto | 60 ++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index d54cad6a..093a2fc8 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -278,37 +278,42 @@ message verified_subscriber_location_ingest_report_v1 { uint64 timestamp = 3; } -message subscriber_referral_eligibility_req_v1 { - // Id of the subsciber which will get the referral rewards - bytes subscriber_id = 1; +message referral_reward_req_v1 { + // Entity to be rewarded + oneof entity { + // Subscriber reward + bytes subscriber_id = 1; + // Gateway reward + bytes gateway_key = 2; + } // Shares rewardsed to the subscriber - uint64 shares = 2; + uint64 shares = 3; // Timestamp in seconds since the unix epoch - uint64 timestamp = 3; + uint64 timestamp = 4; // Pubkey of the carrier for which the subscriber is attached - bytes carrier_pub_key = 4; + bytes carrier_pub_key = 5; // Signed payload of the request - bytes signature = 5; + bytes signature = 6; } -message subscriber_referral_eligibility_resp_v1 { string id = 1; } +message referral_reward_resp_v1 { string id = 1; } -message subscriber_referral_eligibility_ingest_report_v1 { +message referral_reward_ingest_report_v1 { // Timestamp in milliseconds since the unix epoch uint64 received_timestamp = 1; - subscriber_referral_eligibility_req_v1 report = 2; + referral_reward_req_v1 report = 2; } -enum subscriber_referral_eligibility_status { - referral_eligibility_status_valid = 0; - referral_eligibility_status_invalid_subscriber_id = 1; - referral_eligibility_status_invalid_carrier_key = 2; +enum referral_reward_status { + referral_reward_status_valid = 0; + referral_reward_status_invalid_subscriber_id = 1; + referral_reward_status_invalid_carrier_key = 2; } -message verified_subscriber_referral_eligibility_ingest_report_v1 { - subscriber_referral_eligibility_ingest_report_v1 report = 1; +message verified_referral_reward_ingest_report_v1 { + referral_reward_ingest_report_v1 report = 1; // Status of the report - subscriber_referral_eligibility_status status = 2; + referral_reward_status status = 2; // Timestamp at which verification was determined, in milliseconds since // the unix epoch uint64 timestamp = 3; @@ -337,9 +342,9 @@ service poc_mobile { rpc submit_subscriber_verified_mapping_event( subscriber_verified_mapping_event_req_v1) returns (subscriber_verified_mapping_event_res_v1); - rpc submit_subscriber_referral_eligibility( - subscriber_referral_eligibility_req_v1) - returns (subscriber_referral_eligibility_resp_v1); + rpc submit_referral_reward( + referral_reward_req_v1) + returns (referral_reward_resp_v1); } message file_info { @@ -605,6 +610,20 @@ message subscriber_reward { uint64 verification_mapping_amount = 3; } +message referral_reward { + // Entity given the reward + oneof entity { + // Subscriber reward + bytes subscriber_id = 1; + // Gateway reward + bytes gateway_key = 2; + } + // Amount in bones given by the service provider + uint64 service_provider_amount = 2; + // Amount in bones matched by the network + uint64 matched_amount = 3; +} + message service_provider_reward { // rewardable entity id of the service provider to which the reward will be // credited @@ -643,6 +662,7 @@ message mobile_reward_share { service_provider_reward service_provider_reward = 6; unallocated_reward unallocated_reward = 7; radio_reward_v2 radio_reward_v2 = 8; + subscriber_reward subscriber_reward = 9; } } From 1f46c0d1ffa2ff8b1e478afa61d487bd098939a9 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 17:26:57 -0400 Subject: [PATCH 07/14] Fix --- src/service/poc_mobile.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 093a2fc8..bc0f5d92 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -619,9 +619,9 @@ message referral_reward { bytes gateway_key = 2; } // Amount in bones given by the service provider - uint64 service_provider_amount = 2; + uint64 service_provider_amount = 3; // Amount in bones matched by the network - uint64 matched_amount = 3; + uint64 matched_amount = 4; } message service_provider_reward { From 0029507192c060dcefa783939046536b2430e664 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 21 Aug 2024 17:36:24 -0400 Subject: [PATCH 08/14] fix fix --- src/service/poc_mobile.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index bc0f5d92..e086fff1 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -662,7 +662,7 @@ message mobile_reward_share { service_provider_reward service_provider_reward = 6; unallocated_reward unallocated_reward = 7; radio_reward_v2 radio_reward_v2 = 8; - subscriber_reward subscriber_reward = 9; + referral_reward referral_reward = 9; } } From f4f77a13bb30775ef89b7f7b118f52c7c793e65f Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Thu, 22 Aug 2024 14:19:05 -0400 Subject: [PATCH 09/14] s/referral/promotion/g, add allocations to reward manifest --- src/reward_manifest.proto | 7 +++++++ src/service/poc_mobile.proto | 36 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/reward_manifest.proto b/src/reward_manifest.proto index d1658c05..48305222 100644 --- a/src/reward_manifest.proto +++ b/src/reward_manifest.proto @@ -7,6 +7,13 @@ import "decimal.proto"; message mobile_reward_data { Decimal poc_bones_per_reward_share = 1; Decimal boosted_poc_bones_per_reward_share = 2; + repeated service_provider_allocation sp_allocations = 3; +} + +message service_provider_allocation { + bytes pub_key = 1; + // The percentage of the SP rewards that are allocated to the incentive fun, in basis points + uint32 incentive_escrow_fund_bps = 2; } message iot_reward_data { diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index e086fff1..8f43b673 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -278,7 +278,7 @@ message verified_subscriber_location_ingest_report_v1 { uint64 timestamp = 3; } -message referral_reward_req_v1 { +message promotion_reward_req_v1 { // Entity to be rewarded oneof entity { // Subscriber reward @@ -286,34 +286,34 @@ message referral_reward_req_v1 { // Gateway reward bytes gateway_key = 2; } - // Shares rewardsed to the subscriber + // Shares rewarded to the subscriber uint64 shares = 3; // Timestamp in seconds since the unix epoch uint64 timestamp = 4; - // Pubkey of the carrier for which the subscriber is attached + // Pubkey of the carrier for which the entity is attached bytes carrier_pub_key = 5; // Signed payload of the request bytes signature = 6; } -message referral_reward_resp_v1 { string id = 1; } +message promotion_reward_resp_v1 { string id = 1; } -message referral_reward_ingest_report_v1 { +message promotion_reward_ingest_report_v1 { // Timestamp in milliseconds since the unix epoch uint64 received_timestamp = 1; - referral_reward_req_v1 report = 2; + promotion_reward_req_v1 report = 2; } -enum referral_reward_status { - referral_reward_status_valid = 0; - referral_reward_status_invalid_subscriber_id = 1; - referral_reward_status_invalid_carrier_key = 2; +enum promotion_reward_status { + promotion_reward_status_valid = 0; + promotion_reward_status_invalid_subscriber_id = 1; + promotion_reward_status_invalid_carrier_key = 2; } -message verified_referral_reward_ingest_report_v1 { - referral_reward_ingest_report_v1 report = 1; +message verified_promotion_reward_ingest_report_v1 { + promotion_reward_ingest_report_v1 report = 1; // Status of the report - referral_reward_status status = 2; + promotion_reward_status status = 2; // Timestamp at which verification was determined, in milliseconds since // the unix epoch uint64 timestamp = 3; @@ -342,9 +342,9 @@ service poc_mobile { rpc submit_subscriber_verified_mapping_event( subscriber_verified_mapping_event_req_v1) returns (subscriber_verified_mapping_event_res_v1); - rpc submit_referral_reward( - referral_reward_req_v1) - returns (referral_reward_resp_v1); + rpc submit_promotion_reward( + promotion_reward_req_v1) + returns (promotion_reward_resp_v1); } message file_info { @@ -610,7 +610,7 @@ message subscriber_reward { uint64 verification_mapping_amount = 3; } -message referral_reward { +message promotion_reward { // Entity given the reward oneof entity { // Subscriber reward @@ -662,7 +662,7 @@ message mobile_reward_share { service_provider_reward service_provider_reward = 6; unallocated_reward unallocated_reward = 7; radio_reward_v2 radio_reward_v2 = 8; - referral_reward referral_reward = 9; + promotion_reward promotion_reward = 9; } } From 358984e5ba88271b3a1e7bd9624d0b102094cf54 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Thu, 22 Aug 2024 15:35:06 -0400 Subject: [PATCH 10/14] Fmt --- src/reward_manifest.proto | 3 ++- src/service/poc_mobile.proto | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reward_manifest.proto b/src/reward_manifest.proto index 48305222..150606d4 100644 --- a/src/reward_manifest.proto +++ b/src/reward_manifest.proto @@ -12,7 +12,8 @@ message mobile_reward_data { message service_provider_allocation { bytes pub_key = 1; - // The percentage of the SP rewards that are allocated to the incentive fun, in basis points + // The percentage of the SP rewards that are allocated to the incentive fun, + // in basis points uint32 incentive_escrow_fund_bps = 2; } diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 8f43b673..57f5d684 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -342,8 +342,7 @@ service poc_mobile { rpc submit_subscriber_verified_mapping_event( subscriber_verified_mapping_event_req_v1) returns (subscriber_verified_mapping_event_res_v1); - rpc submit_promotion_reward( - promotion_reward_req_v1) + rpc submit_promotion_reward(promotion_reward_req_v1) returns (promotion_reward_resp_v1); } From 2d4c86e81f5e8909363e8a9fd1b0acd7d086db89 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Thu, 22 Aug 2024 16:32:20 -0400 Subject: [PATCH 11/14] Rename verified promotion reward ingest report --- src/service/poc_mobile.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index 57f5d684..cbc66409 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -310,7 +310,7 @@ enum promotion_reward_status { promotion_reward_status_invalid_carrier_key = 2; } -message verified_promotion_reward_ingest_report_v1 { +message verified_promotion_reward_v1 { promotion_reward_ingest_report_v1 report = 1; // Status of the report promotion_reward_status status = 2; From 72905c9a0b8893daf4da2fae6bdc9bbfc2f1a2a8 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Wed, 28 Aug 2024 14:34:53 -0400 Subject: [PATCH 12/14] Add invalid gateway key to promotion reward ingest status --- src/service/poc_mobile.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service/poc_mobile.proto b/src/service/poc_mobile.proto index cbc66409..51023db7 100644 --- a/src/service/poc_mobile.proto +++ b/src/service/poc_mobile.proto @@ -307,7 +307,8 @@ message promotion_reward_ingest_report_v1 { enum promotion_reward_status { promotion_reward_status_valid = 0; promotion_reward_status_invalid_subscriber_id = 1; - promotion_reward_status_invalid_carrier_key = 2; + promotion_reward_status_invalid_gateway_key = 2; + promotion_reward_status_invalid_carrier_key = 3; } message verified_promotion_reward_v1 { From 734bd1ef05e50f1a047a1dc28e5d78b24e7deccd Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Fri, 13 Sep 2024 11:43:38 -0700 Subject: [PATCH 13/14] Add service provider promotion fund Also adds strum so we can target enums who's variants we want to iterate over. This way, we don't have to hardcode a vec of service providers whenever one is added to proto. --- Cargo.toml | 2 ++ build.rs | 4 ++++ src/lib.rs | 1 + src/service_provider.proto | 14 ++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 356e04bb..b11a461f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,8 @@ bytes = { workspace = true } prost = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } +strum = { version = "0.26.3", features = ["derive"] } +strum_macros = "0.26.4" [build-dependencies] tonic-build = { workspace = true, optional = true } diff --git a/build.rs b/build.rs index 58a118f5..b5c2cda4 100644 --- a/build.rs +++ b/build.rs @@ -36,6 +36,10 @@ macro_rules! config { ($config:expr) => { $config .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") + .enum_attribute( + ".helium.service_provider", + "#[derive(strum_macros::EnumIter)]", + ) .field_attribute( ".helium.tagged_spreading.region_spreading", "#[serde(with = \"serde_region_spreading\" )]", diff --git a/src/lib.rs b/src/lib.rs index 6c84d431..2c1d585b 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ include!(concat!(env!("OUT_DIR"), "/helium.rs")); pub use blockchain_txn::Txn; pub use prost::{DecodeError, EncodeError, Message}; +pub use strum::IntoEnumIterator; #[cfg(feature = "services")] pub mod services { diff --git a/src/service_provider.proto b/src/service_provider.proto index 313ee295..ebf85e50 100644 --- a/src/service_provider.proto +++ b/src/service_provider.proto @@ -5,3 +5,17 @@ package helium; enum service_provider { helium_mobile = 0; } + +message service_provider_promotion_fund_v1 { + /// The timestamp for this report in milliseconds since unix epoch + uint64 timestamp = 1; + + /// Service Provider that is allocating funds for promotions + service_provider service_provider = 2; + + /// Percentage of Rewards allocated for promotions + /// stored in Basis Points + /// + /// https://www.investopedia.com/terms/b/basispoint.asp + uint32 bps = 3; +} From effd56a31ab83a1079c7819cd1f783f4141c9c9b Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Mon, 30 Sep 2024 12:42:56 -0700 Subject: [PATCH 14/14] use service_provider as key in reward_manifest --- src/reward_manifest.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/reward_manifest.proto b/src/reward_manifest.proto index 150606d4..21003b4c 100644 --- a/src/reward_manifest.proto +++ b/src/reward_manifest.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package helium; import "decimal.proto"; +import "service_provider.proto"; message mobile_reward_data { Decimal poc_bones_per_reward_share = 1; @@ -11,7 +12,7 @@ message mobile_reward_data { } message service_provider_allocation { - bytes pub_key = 1; + service_provider service_provider = 1; // The percentage of the SP rewards that are allocated to the incentive fun, // in basis points uint32 incentive_escrow_fund_bps = 2;