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

Include share values in rewards manifest #827

Merged
merged 36 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3427ddf
output share values in rewards manifest for iot and mobile
andymck Jun 7, 2024
5986102
tweaks
andymck Jun 7, 2024
57609a1
fmt
andymck Jun 7, 2024
06d655e
Store coverage points received by boosting separately
michaeldjeffrey Jun 26, 2024
5bbdeda
Add struct for containing allocated Rewards for Data transfer and POC
michaeldjeffrey Jun 27, 2024
b9e360b
Move calucating reward shares for poc to coverage point calculator
michaeldjeffrey Jun 27, 2024
29a4351
Correct points for share calculation alway includes multipliers
michaeldjeffrey Jun 27, 2024
97d44eb
Use the AllocatedRewardShare struct for calculating unallocated data …
michaeldjeffrey Jun 27, 2024
64c9c0f
Add caller to timeout message for file sink during debugging
michaeldjeffrey Jun 27, 2024
78ca743
Fix first hex_boosting intregration test
michaeldjeffrey Jun 27, 2024
68ab48a
Fix second hex_boosting integration test
michaeldjeffrey Jun 27, 2024
eeebb65
Fix third hex_boosting integration test
michaeldjeffrey Jun 27, 2024
63eb9eb
Fix fourth hex_boosting integration test
michaeldjeffrey Jun 28, 2024
deeee63
Use new proto branch
maplant Jun 28, 2024
1a48209
Merge remote-tracking branch 'origin/main' into andymck/includes-shar…
maplant Jun 28, 2024
c96c9a1
Overview all changed tests
michaeldjeffrey Jun 28, 2024
870e653
Move reward share calculation where it belongs
michaeldjeffrey Jun 28, 2024
a329c82
Add doc for CoveragePoints::coverage_points
michaeldjeffrey Jun 28, 2024
192e2a5
remove whitespace
michaeldjeffrey Jun 28, 2024
4c92270
Unwrap calculating expected rewards in tests
michaeldjeffrey Jun 28, 2024
cc7a514
Update formatting of comment for Doc.rs readability
michaeldjeffrey Jul 1, 2024
758cb41
Fix broken doclink
michaeldjeffrey Jul 1, 2024
5a41baf
fully expose `HexPoints` members
michaeldjeffrey Jul 1, 2024
16f35b3
Add reward data to manifest struct
Jul 1, 2024
d9ae734
remove public from helper member
michaeldjeffrey Jul 3, 2024
2b021e0
rename points -> shares for poc rewards
michaeldjeffrey Jul 3, 2024
406cd4e
coverage_points() -> coverage_points_v1() to call out location differ…
michaeldjeffrey Jul 3, 2024
a8a3774
Merge remote-tracking branch 'origin/mj/hip-122-restrict-boosting-fro…
maplant Jul 8, 2024
3222652
Merge branch 'andymck/includes-share-values-in-manifest' of github.co…
maplant Jul 8, 2024
81b495e
Update to latest
maplant Jul 8, 2024
9bc4e1b
Merge remote-tracking branch 'origin/main' into andymck/includes-shar…
maplant Jul 10, 2024
4b39829
Update proto
maplant Jul 10, 2024
953088f
I guess this is more correct?
maplant Jul 10, 2024
6c0b5d8
Rename fields to be more accurate
maplant Jul 11, 2024
6a30efc
Update proto to master
maplant Jul 11, 2024
7e9e2fa
Annoying
maplant Jul 11, 2024
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
50 changes: 31 additions & 19 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 @@ -70,7 +70,7 @@ 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 = "map/decimalize", features = [
"services",
] }
solana-client = "1.18"
Expand All @@ -82,7 +82,7 @@ reqwest = { version = "0", default-features = false, features = [
"json",
"rustls-tls",
] }
beacon = { git = "https://github.com/helium/proto", branch = "master" }
beacon = { git = "https://github.com/helium/proto", branch = "map/decimalize" }
humantime = "2"
humantime-serde = "1"
metrics = ">=0.22"
Expand Down
8 changes: 8 additions & 0 deletions file_store/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ pub enum DecodeError {
Uri(#[from] http::uri::InvalidUri),
#[error("integer conversion error")]
FromInt(#[from] std::num::TryFromIntError),
#[error("error parsing decimal")]
IntoDecimal(#[from] rust_decimal::Error),
#[error("empty field: {0}")]
EmptyField(&'static str),
#[error("unsupported region, type: {0}, value: {1}")]
UnsupportedRegion(String, i32),
#[error("unsupported datarate, type: {0}, value: {1}")]
Expand Down Expand Up @@ -166,6 +170,10 @@ impl DecodeError {
pub fn unsupported_invalidated_reason<E: ToString>(msg1: E, msg2: i32) -> Error {
Error::Decode(Self::UnsupportedInvalidReason(msg1.to_string(), msg2))
}

pub const fn empty_field(field: &'static str) -> Error {
Error::Decode(Self::EmptyField(field))
}
}

impl From<helium_crypto::Error> for Error {
Expand Down
60 changes: 60 additions & 0 deletions file_store/src/reward_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
use crate::{error::DecodeError, traits::MsgDecode, Error};
use chrono::{DateTime, TimeZone, Utc};
use helium_proto as proto;
use rust_decimal::Decimal;

#[derive(Clone, Debug)]
pub struct RewardManifest {
pub written_files: Vec<String>,
pub start_timestamp: DateTime<Utc>,
pub end_timestamp: DateTime<Utc>,
pub reward_data: Option<RewardData>,
}

#[derive(Clone, Debug)]
pub enum RewardData {
MobileRewardData {
poc_bones_per_coverage_point: Decimal,
dc_bones_per_share: Decimal,
},
IotRewardData {
poc_bones_per_beacon_reward_share: Decimal,
poc_bones_per_witness_reward_share: Decimal,
dc_bones_per_share: Decimal,
},
}

impl MsgDecode for RewardManifest {
Expand All @@ -31,6 +46,51 @@ impl TryFrom<proto::RewardManifest> for RewardManifest {
.ok_or(Error::Decode(DecodeError::InvalidTimestamp(
value.end_timestamp,
)))?,
reward_data: match value.reward_data {
Some(proto::reward_manifest::RewardData::MobileRewardData(reward_data)) => {
Some(RewardData::MobileRewardData {
poc_bones_per_coverage_point: reward_data
.poc_bones_per_coverage_point
.ok_or(DecodeError::empty_field("poc_bones_per_coverage_point"))?
.value
.parse()
.map_err(DecodeError::from)?,
dc_bones_per_share: reward_data
.dc_bones_per_share
.ok_or(DecodeError::empty_field("dc_bones_per_share"))?
.value
.parse()
.map_err(DecodeError::from)?,
})
}
Some(proto::reward_manifest::RewardData::IotRewardData(reward_data)) => {
Some(RewardData::IotRewardData {
poc_bones_per_beacon_reward_share: reward_data
.poc_bones_per_beacon_reward_share
.ok_or(DecodeError::empty_field(
"poc_bones_per_beacon_reward_share",
))?
.value
.parse()
.map_err(DecodeError::from)?,
poc_bones_per_witness_reward_share: reward_data
.poc_bones_per_witness_reward_share
.ok_or(DecodeError::empty_field(
"poc_bones_per_witness_reward_share",
))?
.value
.parse()
.map_err(DecodeError::from)?,
dc_bones_per_share: reward_data
.dc_bones_per_share
.ok_or(DecodeError::empty_field("dc_bones_per_share"))?
.value
.parse()
.map_err(DecodeError::from)?,
})
}
None => None,
},
})
}
}
Loading