Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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 @@ -131,5 +131,5 @@ anchor-lang = { git = "https://github.com/madninja/anchor.git", branch = "madnin
# helium-proto = { path = "../proto" }
# beacon = { path = "../proto/beacon" }

# [patch.'https://github.com/helium/proto']
# helium-proto = { git = "https://www.github.com/helium/proto.git", branch = "fix-carrier-id" }
[patch.'https://github.com/helium/proto']
helium-proto = { git = "https://www.github.com/helium/proto.git", branch = "kurotych/speedtest-bounds" }
8 changes: 4 additions & 4 deletions coverage_point_calculator/src/speedtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ type Millis = u32;
#[derive(Debug, Default, Clone, Copy, PartialEq, PartialOrd)]
pub struct BytesPs(u64);

impl BytesPs {
const BYTES_PER_MEGABYTE: u64 = 125_000;
pub const BYTES_PER_MEGABIT: u64 = 125_000;

impl BytesPs {
pub fn new(bytes_per_second: u64) -> Self {
Self(bytes_per_second)
}

pub fn mbps(megabytes_per_second: u64) -> Self {
Self(megabytes_per_second * Self::BYTES_PER_MEGABYTE)
Self(megabytes_per_second * BYTES_PER_MEGABIT)
}

fn as_mbps(&self) -> u64 {
self.0 / Self::BYTES_PER_MEGABYTE
self.0 / BYTES_PER_MEGABIT
}

pub fn as_bps(&self) -> u64 {
Expand Down
13 changes: 11 additions & 2 deletions mobile_verifier/src/speedtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
Settings,
};
use chrono::{DateTime, Utc};
use coverage_point_calculator::speedtest::BYTES_PER_MEGABIT;
use file_store::{
file_info_poller::{FileInfoStream, LookbackBehavior},
file_sink::FileSinkClient,
Expand Down Expand Up @@ -31,6 +32,10 @@ use task_manager::{ManagedTask, TaskManager};
use tokio::sync::mpsc::Receiver;

const SPEEDTEST_AVG_MAX_DATA_POINTS: usize = 6;
// The limit must be 300 megabits per second.
// Values in proto are in bytes/sec format.
// Convert 300 megabits per second to bytes per second.
const SPEEDTEST_MAX_BYTES_PER_SECOND: u64 = 300 * BYTES_PER_MEGABIT;

pub type EpochSpeedTests = HashMap<PublicKeyBinary, Vec<Speedtest>>;

Expand Down Expand Up @@ -176,11 +181,15 @@ where
&self,
speedtest: &CellSpeedtestIngestReport,
) -> anyhow::Result<SpeedtestResult> {
let pubkey = speedtest.report.pubkey.clone();
if speedtest.report.upload_speed > SPEEDTEST_MAX_BYTES_PER_SECOND
|| speedtest.report.download_speed > SPEEDTEST_MAX_BYTES_PER_SECOND
{
return Ok(SpeedtestResult::SpeedtestValueOutOfBounds);
}

match self
.gateway_info_resolver
.resolve_gateway_info(&pubkey)
.resolve_gateway_info(&speedtest.report.pubkey)
.await?
{
Some(gw_info) if gw_info.is_data_only() => {
Expand Down
Loading