From 21ab8c79b059d107ad8b185b0c74f385bdf68e42 Mon Sep 17 00:00:00 2001 From: Andrew McKenzie Date: Fri, 6 Dec 2024 14:56:34 +0000 Subject: [PATCH] carry across tweaks from mobile pr --- Cargo.lock | 65 ++++++++++++------- Cargo.toml | 4 +- iot_config/src/client/mod.rs | 6 +- iot_config/src/lib.rs | 19 ++---- iot_config/src/sub_dao_epoch_reward_info.rs | 22 ++++--- iot_config/src/sub_dao_service.rs | 4 +- iot_verifier/src/reward_share.rs | 29 ++++----- iot_verifier/src/rewarder.rs | 26 ++++---- iot_verifier/src/telemetry.rs | 2 +- iot_verifier/tests/integrations/common/mod.rs | 2 +- 10 files changed, 95 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b7d12867..467ceadde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -1615,17 +1615,17 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beacon" version = "0.1.0" -source = "git+https://github.com/helium/proto?branch=andymck/sub-dao-epoch-support#fffce9d335b1e5d74ffd5da27ddba6e60b6d9d7c" +source = "git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support#6d7e5da2db436692b88cf2b616f34682fe582c4b" dependencies = [ "base64 0.21.7", "byteorder", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "prost", "rand 0.8.5", "rand_chacha 0.3.0", "rust_decimal", "serde", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", ] @@ -1788,7 +1788,7 @@ dependencies = [ "file-store", "futures", "futures-util", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "http-serde", "humantime-serde", @@ -2630,7 +2630,7 @@ dependencies = [ "axum 0.7.4", "bs58 0.4.0", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "notify", "serde", @@ -3212,7 +3212,7 @@ dependencies = [ "futures-util", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hex-literal", "http 0.2.11", "lazy_static", @@ -3794,7 +3794,7 @@ dependencies = [ "h3o", "helium-anchor-gen", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=master)", "hex", "hex-literal", "itertools", @@ -3821,6 +3821,23 @@ dependencies = [ [[package]] name = "helium-proto" version = "0.1.0" +source = "git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support#6d7e5da2db436692b88cf2b616f34682fe582c4b" +dependencies = [ + "bytes", + "prost", + "prost-build", + "serde", + "serde_json", + "strum", + "strum_macros", + "tonic", + "tonic-build", +] + +[[package]] +name = "helium-proto" +version = "0.1.0" +source = "git+https://github.com/helium/proto?branch=master#8e3edc2053a16ec98421d83211399338836f91e4" dependencies = [ "bytes", "prost", @@ -3874,7 +3891,7 @@ dependencies = [ "async-trait", "chrono", "derive_builder", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hextree", "rust_decimal", "rust_decimal_macros", @@ -4290,7 +4307,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "humantime-serde", "metrics", @@ -4360,7 +4377,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hextree", "http 0.2.11", "http-serde", @@ -4404,7 +4421,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "http-serde", "humantime-serde", @@ -4447,7 +4464,7 @@ dependencies = [ "h3o", "helium-crypto", "helium-lib", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http-serde", "humantime-serde", "iot-config", @@ -5036,7 +5053,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hextree", "http 0.2.11", "http-serde", @@ -5079,7 +5096,7 @@ dependencies = [ "futures", "h3o", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "mobile-config", "prost", "rand 0.8.5", @@ -5115,7 +5132,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "http-serde", "humantime-serde", @@ -5160,7 +5177,7 @@ dependencies = [ "h3o", "helium-crypto", "helium-lib", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hex-assignments", "hextree", "http-serde", @@ -5844,7 +5861,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "http 0.2.11", "hyper 0.14.28", "jsonrpsee", @@ -5927,7 +5944,7 @@ dependencies = [ "futures-util", "helium-anchor-gen", "helium-lib", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "humantime-serde", "metrics", "metrics-exporter-prometheus", @@ -6068,7 +6085,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" dependencies = [ "bytes", - "heck 0.4.0", + "heck 0.5.0", "itertools", "log", "multimap", @@ -6127,7 +6144,7 @@ dependencies = [ [[package]] name = "pyth-solana-receiver-sdk" version = "0.3.1" -source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja/cap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" +source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja%2Fcap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" dependencies = [ "anchor-lang 0.29.0", "hex", @@ -6138,7 +6155,7 @@ dependencies = [ [[package]] name = "pythnet-sdk" version = "2.3.0" -source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja/cap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" +source = "git+https://github.com/madninja/pyth-crosschain.git?branch=madninja%2Fcap_solana_dep#6576247294bde3ab7b62f7a2dfb4d4d48c401b35" dependencies = [ "anchor-lang 0.30.1", "bincode", @@ -6566,7 +6583,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", - "helium-proto", + "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "humantime-serde", "lazy_static", "metrics", @@ -9993,7 +10010,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", "twox-hash", "xorf", diff --git a/Cargo.toml b/Cargo.toml index fae3f6697..acac87a64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,6 +132,6 @@ sqlx = { git = "https://github.com/launchbadge/sqlx.git", rev = "42dd78fe931df65 # Patching for beacon must point directly to the crate, it will not look in the # repo for sibling crates. # - [patch.'https://github.com/helium/proto'] - helium-proto = { path = "../../proto" } +# [patch.'https://github.com/helium/proto'] +# helium-proto = { path = "../../proto" } # beacon = { path = "../../proto" } diff --git a/iot_config/src/client/mod.rs b/iot_config/src/client/mod.rs index d76ebcebb..18ef8133d 100644 --- a/iot_config/src/client/mod.rs +++ b/iot_config/src/client/mod.rs @@ -25,8 +25,10 @@ pub enum ClientError { Verification(#[from] file_store::Error), #[error("error resolving region params: {0}")] UndefinedRegionParams(String), - #[error("error {0}")] - AnyhowError(#[from] anyhow::Error), + #[error("Invalid SubDaoRewardInfo proto response {0}")] + InvalidSubDaoRewardInfoProto( + #[from] crate::sub_dao_epoch_reward_info::SubDaoRewardInfoParseError, + ), } #[async_trait::async_trait] diff --git a/iot_config/src/lib.rs b/iot_config/src/lib.rs index 1f21597ea..36450406a 100644 --- a/iot_config/src/lib.rs +++ b/iot_config/src/lib.rs @@ -18,8 +18,7 @@ pub mod sub_dao_epoch_reward_info; pub mod sub_dao_service; pub use admin_service::AdminService; -use anyhow::anyhow; -use chrono::{DateTime, Duration, TimeZone, Utc}; +use chrono::{DateTime, Duration, Utc}; pub use client::{Client, Settings as ClientSettings}; pub use gateway_service::GatewayService; pub use org_service::OrgService; @@ -71,18 +70,12 @@ pub struct EpochPeriod { pub period: Range>, } -impl TryFrom for EpochPeriod { - type Error = anyhow::Error; - - fn try_from(next_reward_epoch: u64) -> anyhow::Result { - let start_time = Utc - .timestamp_opt(0, 0) - .single() - .ok_or_else(|| anyhow!("Failed to get Unix epoch start time"))? - + Duration::days(next_reward_epoch as i64); +impl From for EpochPeriod { + fn from(next_reward_epoch: u64) -> Self { + let start_time = DateTime::::UNIX_EPOCH + Duration::days(next_reward_epoch as i64); let end_time = start_time + Duration::days(1); - Ok(EpochPeriod { + EpochPeriod { period: start_time..end_time, - }) + } } } diff --git a/iot_config/src/sub_dao_epoch_reward_info.rs b/iot_config/src/sub_dao_epoch_reward_info.rs index eb0d37d02..940155bd3 100644 --- a/iot_config/src/sub_dao_epoch_reward_info.rs +++ b/iot_config/src/sub_dao_epoch_reward_info.rs @@ -7,7 +7,7 @@ use std::ops::Range; #[derive(Clone, Debug)] pub struct ResolvedSubDaoEpochRewardInfo { - pub epoch: u64, + pub epoch_day: u64, pub epoch_address: String, pub sub_dao_address: String, pub epoch_period: Range>, @@ -25,30 +25,34 @@ pub struct RawSubDaoEpochRewardInfo { rewards_issued_at: DateTime, } -impl TryFrom for SubDaoEpochRewardInfoProto { - type Error = anyhow::Error; +#[derive(thiserror::Error, Debug)] +pub enum SubDaoRewardInfoParseError { + #[error("file_store: {0}")] + FileStore(#[from] file_store::Error), +} - fn try_from(info: RawSubDaoEpochRewardInfo) -> Result { - Ok(Self { +impl From for SubDaoEpochRewardInfoProto { + fn from(info: RawSubDaoEpochRewardInfo) -> Self { + Self { epoch: info.epoch, epoch_address: info.epoch_address, sub_dao_address: info.sub_dao_address, rewards_issued: info.rewards_issued, delegation_rewards_issued: info.delegation_rewards_issued, rewards_issued_at: info.rewards_issued_at.encode_timestamp(), - }) + } } } impl TryFrom for ResolvedSubDaoEpochRewardInfo { - type Error = anyhow::Error; + type Error = SubDaoRewardInfoParseError; fn try_from(info: SubDaoEpochRewardInfoProto) -> Result { - let epoch_period: EpochPeriod = info.epoch.try_into()?; + let epoch_period: EpochPeriod = info.epoch.into(); let epoch_rewards = Decimal::from(info.rewards_issued + info.delegation_rewards_issued); Ok(Self { - epoch: info.epoch, + epoch_day: info.epoch, epoch_address: info.epoch_address, sub_dao_address: info.sub_dao_address, epoch_period: epoch_period.period, diff --git a/iot_config/src/sub_dao_service.rs b/iot_config/src/sub_dao_service.rs index dde804d39..94244d22b 100644 --- a/iot_config/src/sub_dao_service.rs +++ b/iot_config/src/sub_dao_service.rs @@ -84,9 +84,7 @@ impl sub_dao::sub_dao_server::SubDao for SubDaoService { Err(Status::not_found(epoch.to_string())) }, |info| { - let info = info.try_into().map_err(|_| { - Status::internal("error serializing sub_dao epoch reward info") - })?; + let info = info.into(); let mut res = SubDaoEpochRewardInfoResV1 { info: Some(info), timestamp: Utc::now().encode_timestamp(), diff --git a/iot_verifier/src/reward_share.rs b/iot_verifier/src/reward_share.rs index bf2607d61..ec01bea6a 100644 --- a/iot_verifier/src/reward_share.rs +++ b/iot_verifier/src/reward_share.rs @@ -5,7 +5,6 @@ use futures::stream::TryStreamExt; use helium_crypto::PublicKeyBinary; use helium_proto::services::poc_lora as proto; use helium_proto::services::poc_lora::iot_reward_share::Reward as ProtoReward; -use iot_config::sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo; use lazy_static::lazy_static; use rust_decimal::prelude::*; use rust_decimal_macros::dec; @@ -229,7 +228,7 @@ impl GatewayShares { pub fn into_reward_shares( self, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_period: &Range>, beacon_rewards_per_share: Decimal, witness_rewards_per_share: Decimal, dc_transfer_rewards_per_share: Decimal, @@ -262,10 +261,9 @@ impl GatewayShares { ( total_gateway_reward, proto::IotRewardShare { - start_period: reward_info.epoch_period.start.encode_timestamp(), - end_period: reward_info.epoch_period.end.encode_timestamp(), + start_period: reward_period.start.encode_timestamp(), + end_period: reward_period.end.encode_timestamp(), reward: Some(ProtoReward::GatewayReward(gateway_reward)), - epoch: reward_info.epoch, }, ) }) @@ -273,7 +271,7 @@ impl GatewayShares { pub async fn calculate_rewards_per_share( &self, - reward_info: &ResolvedSubDaoEpochRewardInfo, + epoch_emissions: Decimal, hnt_price: HntPrice, ) -> anyhow::Result<(Decimal, Decimal, Decimal)> { // the total number of shares for beacons, witnesses and data transfer @@ -281,7 +279,7 @@ impl GatewayShares { let (total_beacon_shares, total_witness_shares, total_dc_shares) = self.total_shares(); // the max rewards for dc transfer this epoch - let total_dc_transfer_rewards = get_scheduled_dc_tokens(reward_info.epoch_emissions); + let total_dc_transfer_rewards = get_scheduled_dc_tokens(epoch_emissions); // convert the total spent data transfer DC to it equiv hnt bone value // the rewards distributed to gateways will be equal to this @@ -299,7 +297,7 @@ impl GatewayShares { // the total amounts of hnt rewards this epoch for beacons, witnesses // taking into account any remaining dc transfer rewards let (total_beacon_rewards, total_witness_rewards) = - get_scheduled_poc_tokens(reward_info.epoch_emissions, dc_transfer_rewards_unused); + get_scheduled_poc_tokens(epoch_emissions, dc_transfer_rewards_unused); // work out the rewards per share for beacons, witnesses and dc transfer let beacon_rewards_per_share = rewards_per_share(total_beacon_rewards, total_beacon_shares); @@ -431,6 +429,7 @@ mod test { use super::*; use crate::{reward_share, HntPrice}; use chrono::Duration; + use iot_config::sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo; pub const EPOCH_ADDRESS: &str = "112E7TxoNHV46M6tiPA8N1MkeMeQxc9ztb4JQLXBVAAUfq1kJLoF"; pub const SUB_DAO_ADDRESS: &str = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6"; @@ -464,7 +463,7 @@ mod test { ) -> ResolvedSubDaoEpochRewardInfo { let now = Utc::now(); ResolvedSubDaoEpochRewardInfo { - epoch: 1, + epoch_day: 1, epoch_address: EPOCH_ADDRESS.into(), sub_dao_address: SUB_DAO_ADDRESS.into(), epoch_period: (now - epoch_duration)..now, @@ -595,7 +594,7 @@ mod test { let gw_shares = GatewayShares::new(shares).unwrap(); let (beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share) = gw_shares - .calculate_rewards_per_share(&reward_info, hnt_price.clone()) + .calculate_rewards_per_share(reward_info.epoch_emissions, hnt_price.clone()) .await .unwrap(); @@ -608,7 +607,7 @@ mod test { let mut rewards: HashMap = HashMap::new(); let mut allocated_gateway_rewards = 0_u64; for (reward_amount, reward) in gw_shares.into_reward_shares( - &reward_info, + &reward_info.epoch_period, beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share, @@ -815,7 +814,7 @@ mod test { let gw_shares = GatewayShares::new(shares).unwrap(); let (beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share) = gw_shares - .calculate_rewards_per_share(&reward_info, hnt_price) + .calculate_rewards_per_share(reward_info.epoch_emissions, hnt_price) .await .unwrap(); @@ -828,7 +827,7 @@ mod test { let mut rewards: HashMap = HashMap::new(); let mut allocated_gateway_rewards = 0_u64; for (reward_amount, reward) in gw_shares.into_reward_shares( - &reward_info, + &reward_info.epoch_period, beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share, @@ -1006,7 +1005,7 @@ mod test { let gw_shares = GatewayShares::new(shares).unwrap(); let (beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share) = gw_shares - .calculate_rewards_per_share(&reward_info, hnt_price) + .calculate_rewards_per_share(reward_info.epoch_emissions, hnt_price) .await .unwrap(); @@ -1019,7 +1018,7 @@ mod test { let mut rewards: HashMap = HashMap::new(); let mut allocated_gateway_rewards = 0_u64; for (reward_amount, reward) in gw_shares.into_reward_shares( - &reward_info, + &reward_info.epoch_period, beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share, diff --git a/iot_verifier/src/rewarder.rs b/iot_verifier/src/rewarder.rs index d5d92f095..1a544680e 100644 --- a/iot_verifier/src/rewarder.rs +++ b/iot_verifier/src/rewarder.rs @@ -91,7 +91,7 @@ where loop { let next_reward_epoch = next_reward_epoch(&self.pool).await?; - let next_reward_epoch_period = EpochPeriod::try_from(next_reward_epoch)?; + let next_reward_epoch_period = EpochPeriod::from(next_reward_epoch); let scheduler = Scheduler::new( self.reward_period_hours, @@ -148,7 +148,7 @@ where tracing::info!( "Rewarding for epoch {} period: {} to {} with hnt bone price: {}", - reward_info.epoch, + reward_info.epoch_day, reward_info.epoch_period.start, reward_info.epoch_period.end, hnt_price.price_per_hnt_bone @@ -178,7 +178,7 @@ where GatewayShares::clear_rewarded_shares(&mut transaction, reward_info.epoch_period.start) .await?; - save_next_reward_epoch(&mut transaction, reward_info.epoch + 1).await?; + save_next_reward_epoch(&mut transaction, reward_info.epoch_day + 1).await?; transaction.commit().await?; @@ -201,7 +201,7 @@ where end_timestamp: reward_info.epoch_period.end.encode_timestamp(), written_files, reward_data: Some(IotRewardData(reward_data)), - epoch: reward_info.epoch, + epoch: reward_info.epoch_day, price: hnt_price.hnt_price_in_bones, }, [], @@ -268,7 +268,7 @@ pub async fn reward_poc_and_dc( let gateway_shares = GatewayShares::new(reward_shares)?; let (beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share) = gateway_shares - .calculate_rewards_per_share(reward_info, hnt_price) + .calculate_rewards_per_share(reward_info.epoch_emissions, hnt_price) .await?; // get the total poc and dc rewards for the period @@ -280,7 +280,7 @@ pub async fn reward_poc_and_dc( let mut allocated_gateway_rewards = 0_u64; for (gateway_reward_amount, reward_share) in gateway_shares.into_reward_shares( - reward_info, + &reward_info.epoch_period, beacon_rewards_per_share, witness_rewards_per_share, dc_transfer_rewards_per_share, @@ -302,7 +302,7 @@ pub async fn reward_poc_and_dc( rewards_sink, UnallocatedRewardType::Poc, unallocated_poc_reward_amount, - reward_info, + &reward_info.epoch_period, ) .await?; Ok(RewardPocDcDataPoints { @@ -331,7 +331,6 @@ pub async fn reward_operational( start_period: reward_info.epoch_period.start.encode_timestamp(), end_period: reward_info.epoch_period.end.encode_timestamp(), reward: Some(ProtoReward::OperationalReward(op_fund_reward)), - epoch: reward_info.epoch, }, [], ) @@ -352,7 +351,7 @@ pub async fn reward_operational( rewards_sink, UnallocatedRewardType::Operation, unallocated_operation_reward_amount, - reward_info, + &reward_info.epoch_period, ) .await?; Ok(()) @@ -375,7 +374,7 @@ pub async fn reward_oracles( rewards_sink, UnallocatedRewardType::Oracle, unallocated_oracle_reward_amount, - reward_info, + &reward_info.epoch_period, ) .await?; Ok(()) @@ -385,17 +384,16 @@ async fn write_unallocated_reward( rewards_sink: &file_sink::FileSinkClient, unallocated_type: UnallocatedRewardType, unallocated_amount: u64, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_period: &Range>, ) -> anyhow::Result<()> { if unallocated_amount > 0 { let unallocated_reward = proto::IotRewardShare { - start_period: reward_info.epoch_period.start.encode_timestamp(), - end_period: reward_info.epoch_period.end.encode_timestamp(), + start_period: reward_period.start.encode_timestamp(), + end_period: reward_period.end.encode_timestamp(), reward: Some(ProtoReward::UnallocatedReward(UnallocatedReward { reward_type: unallocated_type as i32, amount: unallocated_amount, })), - epoch: reward_info.epoch, }; rewards_sink.write(unallocated_reward, []).await?.await??; }; diff --git a/iot_verifier/src/telemetry.rs b/iot_verifier/src/telemetry.rs index 610ef5718..8fd559978 100644 --- a/iot_verifier/src/telemetry.rs +++ b/iot_verifier/src/telemetry.rs @@ -20,7 +20,7 @@ const LAST_REWARDED_END_TIME: &str = "last_rewarded_end_time"; pub async fn initialize(db: &Pool) -> anyhow::Result<()> { let next_reward_epoch = rewarder::next_reward_epoch(db).await?; - let epoch_period: EpochPeriod = next_reward_epoch.try_into()?; + let epoch_period: EpochPeriod = next_reward_epoch.into(); last_rewarded_end_time(epoch_period.period.start); num_beacons(Report::count_all_beacons(db).await?); Ok(()) diff --git a/iot_verifier/tests/integrations/common/mod.rs b/iot_verifier/tests/integrations/common/mod.rs index 5071ace05..d9cfdd7d2 100644 --- a/iot_verifier/tests/integrations/common/mod.rs +++ b/iot_verifier/tests/integrations/common/mod.rs @@ -42,7 +42,7 @@ pub fn default_rewards_info( ) -> ResolvedSubDaoEpochRewardInfo { let now = Utc::now(); ResolvedSubDaoEpochRewardInfo { - epoch: 1, + epoch_day: 1, epoch_address: EPOCH_ADDRESS.into(), sub_dao_address: SUB_DAO_ADDRESS.into(), epoch_period: (now - epoch_duration)..now,