Skip to content

Commit

Permalink
Merge pull request #898 from helium/andymck/hip138-mobile
Browse files Browse the repository at this point in the history
hip138 - mobile & iot verifier implementations
  • Loading branch information
andymck authored Jan 28, 2025
2 parents 09054c3 + 35ea8b9 commit 150daae
Show file tree
Hide file tree
Showing 53 changed files with 2,107 additions and 927 deletions.
55 changes: 29 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ sqlx = { git = "https://github.com/launchbadge/sqlx.git", rev = "42dd78fe931df65
# repo for sibling crates.
#
# [patch.'https://github.com/helium/proto']
# helium-proto = { path = "../proto" }
# beacon = { path = "../proto/beacon" }
# helium-proto = { path = "../../proto" }
# beacon = { path = "../../proto" }
50 changes: 35 additions & 15 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
mobile_radio_threshold::VerifiedRadioThresholdIngestReport,
mobile_session::{DataTransferSessionIngestReport, InvalidDataTransferIngestReport},
mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport},
reward_manifest::RewardManifest,
speedtest::{CellSpeedtest, CellSpeedtestIngestReport},
traits::{MsgDecode, TimestampDecode},
unique_connections::UniqueConnectionReq,
Expand All @@ -23,12 +24,13 @@ use helium_proto::{
services::{
packet_verifier::ValidDataTransferSession as ValidDataTransferSessionProto,
poc_lora::{
iot_reward_share::Reward as IotReward, IotRewardShare as IotRewardShareProto,
LoraBeaconIngestReportV1, LoraInvalidWitnessReportV1, LoraPocV1,
LoraWitnessIngestReportV1,
},
poc_mobile::{
mobile_reward_share::Reward, CellHeartbeatIngestReportV1, CellHeartbeatReqV1,
CoverageObjectV1, Heartbeat, HexUsageStatsIngestReportV1,
mobile_reward_share::Reward as MobileReward, CellHeartbeatIngestReportV1,
CellHeartbeatReqV1, CoverageObjectV1, Heartbeat, HexUsageStatsIngestReportV1,
InvalidDataTransferIngestReportV1, MobileRewardShare, OracleBoostingReportV1,
RadioRewardShare, RadioUsageStatsIngestReportV1, SpeedtestAvg, SpeedtestIngestReportV1,
SpeedtestReqV1, UniqueConnectionsIngestReportV1,
Expand All @@ -38,7 +40,7 @@ use helium_proto::{
router::PacketRouterPacketReportV1,
},
BlockchainTxn, BoostedHexUpdateV1 as BoostedHexUpdateProto, Message, PriceReportV1,
RewardManifest, SubnetworkRewards,
RewardManifest as RewardManifestProto, SubnetworkRewards,
};
use serde_json::json;
use std::io;
Expand Down Expand Up @@ -255,29 +257,51 @@ impl Cmd {
"validity": heartbeat.validity,
}))?;
}
FileType::IotRewardShare => {
let reward = IotRewardShareProto::decode(msg)?;
match reward.reward {
Some(IotReward::GatewayReward(reward)) => print_json(&json!({
"type": "gateway_reward",
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"dc_transfer_amount": reward.dc_transfer_amount,
"beacon_amount": reward.beacon_amount,
"witness_amount": reward.witness_amount,
}))?,
Some(IotReward::OperationalReward(reward)) => print_json(&json!({
"type": "operational_reward",
"amount": reward.amount,
}))?,
Some(IotReward::UnallocatedReward(reward)) => print_json(&json!({
"type": "unallocated_reward",
"unallocated_reward_type": reward.reward_type,
"amount": reward.amount,
}))?,
_ => (),
}
}
FileType::MobileRewardShare => {
let reward = MobileRewardShare::decode(msg)?;
match reward.reward {
Some(Reward::GatewayReward(reward)) => print_json(&json!({
Some(MobileReward::GatewayReward(reward)) => print_json(&json!({
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"dc_transfer_reward": reward.dc_transfer_reward,
}))?,
Some(Reward::RadioReward(reward)) => print_json(&json!({
Some(MobileReward::RadioReward(reward)) => print_json(&json!({
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"cbsd_id": reward.cbsd_id,
"poc_reward": reward.poc_reward,
"boosted_hexes": reward.boosted_hexes,
}))?,
Some(Reward::SubscriberReward(reward)) => print_json(&json!({
Some(MobileReward::SubscriberReward(reward)) => print_json(&json!({
"subscriber_id": reward.subscriber_id,
"discovery_location_amount": reward.discovery_location_amount,
"verification_mapping_amount": reward.verification_mapping_amount,
}))?,
Some(Reward::ServiceProviderReward(reward)) => print_json(&json!({
Some(MobileReward::ServiceProviderReward(reward)) => print_json(&json!({
"service_provider": reward.service_provider_id,
"amount": reward.amount,
}))?,
Some(Reward::UnallocatedReward(reward)) => print_json(&json!({
Some(MobileReward::UnallocatedReward(reward)) => print_json(&json!({
"unallocated_reward_type": reward.reward_type,
"amount": reward.amount,
}))?,
Expand All @@ -296,13 +320,9 @@ impl Cmd {
}))?;
}
FileType::RewardManifest => {
let manifest = RewardManifest::decode(msg)?;
print_json(&json!({
"written_files": manifest.written_files,
"start_timestamp": manifest.start_timestamp,
"end_timestamp": manifest.end_timestamp,
"reward_data": manifest.reward_data.unwrap()
}))?;
let manifest = RewardManifestProto::decode(msg)?;
let report = RewardManifest::try_from(manifest)?;
print_json(&report)?;
}
FileType::SignedPocReceiptTxn => {
// This just outputs a binary of the txns instead of the typical decode.
Expand Down
6 changes: 6 additions & 0 deletions file_store/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub enum DecodeError {
UnsupportedPacketType(String, i32),
#[error("file stream try decode error: {0}")]
FileStreamTryDecode(String),
#[error("unsupported token type {0}")]
UnsupportedTokenType(String, i32),
}

#[derive(Error, Debug)]
Expand Down Expand Up @@ -174,6 +176,10 @@ impl DecodeError {
pub const fn empty_field(field: &'static str) -> Error {
Error::Decode(Self::EmptyField(field))
}

pub fn unsupported_token_type<E: ToString>(msg1: E, msg2: i32) -> Error {
Error::Decode(Self::UnsupportedTokenType(msg1.to_string(), msg2))
}
}

impl From<helium_crypto::Error> for Error {
Expand Down
Loading

0 comments on commit 150daae

Please sign in to comment.