Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subscriber referral eligibility ingest messages #413

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\" )]",
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions src/reward_manifest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ 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 {
Expand Down
61 changes: 60 additions & 1 deletion src/service/poc_mobile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,48 @@ message verified_subscriber_location_ingest_report_v1 {
uint64 timestamp = 3;
}

message promotion_reward_req_v1 {
// Entity to be rewarded
oneof entity {
// Subscriber reward
bytes subscriber_id = 1;
// Gateway reward
bytes gateway_key = 2;
}
// 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 entity is attached
bytes carrier_pub_key = 5;
// Signed payload of the request
bytes signature = 6;
}

message promotion_reward_resp_v1 { string id = 1; }

message promotion_reward_ingest_report_v1 {
// Timestamp in milliseconds since the unix epoch
uint64 received_timestamp = 1;
promotion_reward_req_v1 report = 2;
}

enum promotion_reward_status {
promotion_reward_status_valid = 0;
promotion_reward_status_invalid_subscriber_id = 1;
promotion_reward_status_invalid_gateway_key = 2;
promotion_reward_status_invalid_carrier_key = 3;
}

message verified_promotion_reward_v1 {
promotion_reward_ingest_report_v1 report = 1;
// Status of the report
promotion_reward_status status = 2;
// Timestamp at which verification was determined, in milliseconds since
// the unix epoch
uint64 timestamp = 3;
maplant marked this conversation as resolved.
Show resolved Hide resolved
}

service poc_mobile {
rpc submit_speedtest(speedtest_req_v1) returns (speedtest_resp_v1);
rpc submit_cell_heartbeat(cell_heartbeat_req_v1)
Expand All @@ -301,6 +343,8 @@ 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)
returns (promotion_reward_resp_v1);
}

message file_info {
Expand Down Expand Up @@ -566,6 +610,20 @@ message subscriber_reward {
uint64 verification_mapping_amount = 3;
}

message promotion_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 = 3;
// Amount in bones matched by the network
uint64 matched_amount = 4;
andymck marked this conversation as resolved.
Show resolved Hide resolved
}

message service_provider_reward {
// rewardable entity id of the service provider to which the reward will be
// credited
Expand Down Expand Up @@ -604,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;
promotion_reward promotion_reward = 9;
}
}

Expand Down Expand Up @@ -811,4 +870,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;
}
}
14 changes: 14 additions & 0 deletions src/service_provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading