Skip to content

Commit

Permalink
Verified data transfer (#872)
Browse files Browse the repository at this point in the history
* Replace invalid-data-transfer-session with verified-data-transfer-session

Verified meaning we know about the entities in the report. Even data
sessions that have no rewardable data are written. They will not,
however, be put into the database for rewarding.

* point at updated proto for new verified data report

* More tests for data transfer reports

* remove assert for extreme edgecase in service provider rewards
  • Loading branch information
michaeldjeffrey authored Oct 8, 2024
1 parent 2e3a438 commit 59595dc
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 108 deletions.
56 changes: 36 additions & 20 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 @@ -71,10 +71,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/verified-data-transfer", features = [
"services",
] }
beacon = { git = "https://github.com/helium/proto", branch = "master" }
beacon = { git = "https://github.com/helium/proto", branch = "mj/verified-data-transfer" }
solana-client = "1.18"
solana-sdk = "1.18"
solana-program = "1.18"
Expand Down
4 changes: 4 additions & 0 deletions file_store/src/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub const DATA_TRANSFER_SESSION_INGEST_REPORT: &str = "data_transfer_session_ing
pub const INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT: &str =
"invalid_data_transfer_session_ingest_report";
pub const VALID_DATA_TRANSFER_SESSION: &str = "valid_data_transfer_session";
pub const VERIFIED_DATA_TRANSFER_SESSION: &str = "verified_data_transfer_session";
pub const PRICE_REPORT: &str = "price_report";
pub const MOBILE_REWARD_SHARE: &str = "mobile_reward_share";
pub const MAPPER_MSG: &str = "mapper_msg";
Expand Down Expand Up @@ -196,6 +197,7 @@ pub enum FileType {
DataTransferSessionIngestReport,
InvalidDataTransferSessionIngestReport,
ValidDataTransferSession,
VerifiedDataTransferSession,
PriceReport,
MobileRewardShare,
SubscriberLocationReq,
Expand Down Expand Up @@ -276,6 +278,7 @@ impl fmt::Display for FileType {
INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT
}
Self::ValidDataTransferSession => VALID_DATA_TRANSFER_SESSION,
Self::VerifiedDataTransferSession => VERIFIED_DATA_TRANSFER_SESSION,
Self::PriceReport => PRICE_REPORT,
Self::MobileRewardShare => MOBILE_REWARD_SHARE,
Self::MapperMsg => MAPPER_MSG,
Expand Down Expand Up @@ -353,6 +356,7 @@ impl FileType {
INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT
}
Self::ValidDataTransferSession => VALID_DATA_TRANSFER_SESSION,
Self::VerifiedDataTransferSession => VERIFIED_DATA_TRANSFER_SESSION,
Self::PriceReport => PRICE_REPORT,
Self::MobileRewardShare => MOBILE_REWARD_SHARE,
Self::MapperMsg => MAPPER_MSG,
Expand Down
30 changes: 28 additions & 2 deletions file_store/src/mobile_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use chrono::{DateTime, Utc};
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::{
invalid_data_transfer_ingest_report_v1::DataTransferIngestReportStatus,
DataTransferEvent as DataTransferEventProto, DataTransferRadioAccessTechnology,
DataTransferSessionIngestReportV1, DataTransferSessionReqV1, InvalidDataTransferIngestReportV1,
verified_data_transfer_ingest_report_v1, DataTransferEvent as DataTransferEventProto,
DataTransferRadioAccessTechnology, DataTransferSessionIngestReportV1, DataTransferSessionReqV1,
InvalidDataTransferIngestReportV1, VerifiedDataTransferIngestReportV1,
};

use serde::Serialize;
Expand Down Expand Up @@ -112,6 +113,31 @@ impl From<InvalidDataTransferIngestReport> for InvalidDataTransferIngestReportV1
}
}

#[derive(Serialize, Clone, Debug)]
pub struct VerifiedDataTransferIngestReport {
pub report: DataTransferSessionIngestReport,
pub status: verified_data_transfer_ingest_report_v1::ReportStatus,
pub timestamp: DateTime<Utc>,
}

impl MsgTimestamp<u64> for VerifiedDataTransferIngestReport {
fn timestamp(&self) -> u64 {
self.timestamp.encode_timestamp_millis()
}
}

impl From<VerifiedDataTransferIngestReport> for VerifiedDataTransferIngestReportV1 {
fn from(v: VerifiedDataTransferIngestReport) -> Self {
let timestamp = v.timestamp();
let report: DataTransferSessionIngestReportV1 = v.report.into();
Self {
report: Some(report),
status: v.status as i32,
timestamp,
}
}
}

#[derive(Serialize, Clone, Debug)]
pub struct DataTransferEvent {
pub pub_key: PublicKeyBinary,
Expand Down
5 changes: 5 additions & 0 deletions file_store/src/traits/file_sink_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ impl_file_sink!(
FileType::InvalidDataTransferSessionIngestReport.to_str(),
"invalid_data_transfer_session"
);
impl_file_sink!(
poc_mobile::VerifiedDataTransferIngestReportV1,
FileType::VerifiedDataTransferSession.to_str(),
"verified_data_transfer_session"
);
impl_file_sink!(
poc_mobile::InvalidatedRadioThresholdIngestReportV1,
FileType::InvalidatedRadioThresholdIngestReport.to_str(),
Expand Down
Loading

0 comments on commit 59595dc

Please sign in to comment.