diff --git a/Cargo.lock b/Cargo.lock index 7297ba324..f727a1c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1118,7 +1118,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=master#d86b3e3394e8d9f014fcef3ee08740b3fe269e99" +source = "git+https://github.com/helium/proto?branch=master#7d85f190b207a3ac8d6ad081e2f70e45eecd1a3a" dependencies = [ "base64 0.21.0", "byteorder", @@ -2944,7 +2944,7 @@ dependencies = [ [[package]] name = "helium-proto" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=master#d86b3e3394e8d9f014fcef3ee08740b3fe269e99" +source = "git+https://github.com/helium/proto?branch=master#7d85f190b207a3ac8d6ad081e2f70e45eecd1a3a" dependencies = [ "bytes", "prost", diff --git a/file_store/src/iot_invalid_poc.rs b/file_store/src/iot_invalid_poc.rs index 74d527260..d137ba516 100644 --- a/file_store/src/iot_invalid_poc.rs +++ b/file_store/src/iot_invalid_poc.rs @@ -17,6 +17,9 @@ pub struct IotInvalidBeaconReport { pub received_timestamp: DateTime, pub reason: InvalidReason, pub report: IotBeaconReport, + pub location: Option, + pub gain: i32, + pub elevation: i32, } #[derive(Serialize, Clone)] @@ -75,6 +78,9 @@ impl TryFrom for IotInvalidBeaconReport { .report .ok_or_else(|| Error::not_found("iot invalid beacon report v1"))? .try_into()?, + location: v.location.parse().ok(), + gain: v.gain, + elevation: v.elevation, }) } } @@ -87,6 +93,12 @@ impl From for LoraInvalidBeaconReportV1 { received_timestamp, reason: v.reason as i32, report: Some(report), + location: v + .location + .map(|l| l.to_string()) + .unwrap_or_else(String::new), + gain: v.gain, + elevation: v.elevation, } } } diff --git a/iot_verifier/src/purger.rs b/iot_verifier/src/purger.rs index b565fbef4..31dfd445b 100644 --- a/iot_verifier/src/purger.rs +++ b/iot_verifier/src/purger.rs @@ -198,6 +198,9 @@ impl Purger { received_timestamp, reason: InvalidReason::Stale, report: beacon.clone(), + location: None, + gain: 0, + elevation: 0, } .into(); diff --git a/iot_verifier/src/runner.rs b/iot_verifier/src/runner.rs index 1fe336fca..169d81d68 100644 --- a/iot_verifier/src/runner.rs +++ b/iot_verifier/src/runner.rs @@ -1,7 +1,12 @@ use crate::{ - gateway_cache::GatewayCache, hex_density::HexDensityMap, last_beacon::LastBeacon, poc::Poc, - poc_report::Report, region_cache::RegionCache, reward_share::GatewayPocShare, telemetry, - Settings, + gateway_cache::GatewayCache, + hex_density::HexDensityMap, + last_beacon::LastBeacon, + poc::{Poc, VerifyBeaconResult}, + poc_report::Report, + region_cache::RegionCache, + reward_share::GatewayPocShare, + telemetry, Settings, }; use chrono::{Duration as ChronoDuration, Utc}; use denylist::DenyList; @@ -149,7 +154,7 @@ impl Runner { match self.handle_denylist_tick().await { Ok(()) => (), Err(err) => { - tracing::error!("fatal loader error, denylist_tick triggered: {err:?}"); + tracing::error!("error whilst handling denylist tick: {err:?}"); } }, _ = db_timer.tick() => @@ -404,9 +409,9 @@ impl Runner { VerificationStatus::Invalid => { // the beacon is invalid, which in turn renders all witnesses invalid self.handle_invalid_poc( + beacon_verify_result, &beacon_report, witnesses, - beacon_verify_result.invalid_reason, iot_invalid_beacon_sink, iot_invalid_witness_sink, ) @@ -418,9 +423,9 @@ impl Runner { async fn handle_invalid_poc( &self, + beacon_verify_result: VerifyBeaconResult, beacon_report: &IotBeaconIngestReport, witness_reports: Vec, - invalid_reason: InvalidReason, iot_invalid_beacon_sink: &FileSinkClient, iot_invalid_witness_sink: &FileSinkClient, ) -> anyhow::Result<()> { @@ -428,10 +433,22 @@ impl Runner { let beacon = &beacon_report.report; let beacon_id = beacon.data.clone(); let beacon_report_id = beacon_report.ingest_id(); + + let (location, elevation, gain) = match beacon_verify_result.gateway_info { + Some(gateway_info) => match gateway_info.metadata { + Some(metadata) => (Some(metadata.location), metadata.elevation, metadata.gain), + None => (None, 0, 0), + }, + None => (None, 0, 0), + }; + let invalid_poc: IotInvalidBeaconReport = IotInvalidBeaconReport { received_timestamp: beacon_report.received_timestamp, - reason: invalid_reason, + reason: beacon_verify_result.invalid_reason, report: beacon.clone(), + location, + elevation, + gain, }; let invalid_poc_proto: LoraInvalidBeaconReportV1 = invalid_poc.into(); // save invalid poc to s3, if write fails update attempts and go no further @@ -439,7 +456,7 @@ impl Runner { match iot_invalid_beacon_sink .write( invalid_poc_proto, - &[("reason", invalid_reason.as_str_name())], + &[("reason", beacon_verify_result.invalid_reason.as_str_name())], ) .await { @@ -459,7 +476,7 @@ impl Runner { let invalid_witness_report: IotInvalidWitnessReport = IotInvalidWitnessReport { received_timestamp: witness_report.received_timestamp, report: witness_report.report, - reason: invalid_reason, + reason: beacon_verify_result.invalid_reason, participant_side: InvalidParticipantSide::Beaconer, }; let invalid_witness_report_proto: LoraInvalidWitnessReportV1 = @@ -467,7 +484,7 @@ impl Runner { match iot_invalid_witness_sink .write( invalid_witness_report_proto, - &[("reason", invalid_reason.as_str_name())], + &[("reason", beacon_verify_result.invalid_reason.as_str_name())], ) .await {