diff --git a/Cargo.lock b/Cargo.lock index 8cac0dc9c..c0a66f49c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5050,6 +5050,7 @@ dependencies = [ "futures", "futures-util", "helium-crypto", + "helium-lib", "helium-proto 0.1.0 (git+https://github.com/helium/proto?branch=andymck%2Fsub-dao-epoch-support)", "hextree", "http 0.2.11", diff --git a/mobile_config/Cargo.toml b/mobile_config/Cargo.toml index ae323e008..a6156f19e 100644 --- a/mobile_config/Cargo.toml +++ b/mobile_config/Cargo.toml @@ -22,6 +22,7 @@ file-store = { path = "../file_store" } futures = { workspace = true } futures-util = { workspace = true } helium-crypto = { workspace = true, features = ["sqlx-postgres"] } +helium-lib = { workspace = true } helium-proto = { workspace = true } humantime = { workspace = true } humantime-serde = { workspace = true } diff --git a/mobile_config/src/client/sub_dao_client.rs b/mobile_config/src/client/sub_dao_client.rs index 3f89ea4c3..b33bf5678 100644 --- a/mobile_config/src/client/sub_dao_client.rs +++ b/mobile_config/src/client/sub_dao_client.rs @@ -2,6 +2,7 @@ use super::{call_with_retry, ClientError, Settings}; use crate::sub_dao_epoch_reward_info::EpochRewardInfo; use file_store::traits::MsgVerify; use helium_crypto::{Keypair, PublicKey, Sign}; +use helium_lib::keypair::Pubkey; use helium_proto::{ services::{ sub_dao::{self, SubDaoEpochRewardInfoReqV1}, @@ -34,7 +35,7 @@ pub trait SubDaoEpochRewardInfoResolver: Clone + Send + Sync + 'static { async fn resolve_info( &self, - sub_dao: &str, + sub_dao: &Pubkey, epoch: u64, ) -> Result, Self::Error>; } @@ -45,11 +46,11 @@ impl SubDaoEpochRewardInfoResolver for SubDaoClient { async fn resolve_info( &self, - sub_dao: &str, + sub_dao: &Pubkey, epoch: u64, ) -> Result, Self::Error> { let mut request = SubDaoEpochRewardInfoReqV1 { - sub_dao_address: sub_dao.into(), + sub_dao_address: sub_dao.to_string(), epoch, signer: self.signing_key.public_key().into(), signature: vec![], diff --git a/mobile_verifier/src/cli/reward_from_db.rs b/mobile_verifier/src/cli/reward_from_db.rs index a2891b5a9..f00fe9400 100644 --- a/mobile_verifier/src/cli/reward_from_db.rs +++ b/mobile_verifier/src/cli/reward_from_db.rs @@ -1,12 +1,13 @@ use crate::{ heartbeats::HeartbeatReward, + resolve_subdao_pubkey, reward_shares::{ get_scheduled_tokens_for_poc, CoverageShares, DataTransferAndPocAllocatedRewardBuckets, }, rewarder::boosted_hex_eligibility::BoostedHexEligibility, sp_boosted_rewards_bans::BannedRadios, speedtests_average::SpeedtestAverages, - unique_connections, Settings, MOBILE_SUB_DAO_ONCHAIN_ADDRESS, + unique_connections, Settings, }; use anyhow::Result; use helium_crypto::PublicKey; @@ -32,8 +33,10 @@ impl Cmd { let reward_epoch = self.reward_epoch; let sub_dao_rewards_client = SubDaoClient::from_settings(&settings.config_client)?; + let sub_dao = resolve_subdao_pubkey(); + let reward_info = sub_dao_rewards_client - .resolve_info(MOBILE_SUB_DAO_ONCHAIN_ADDRESS, reward_epoch) + .resolve_info(&sub_dao, reward_epoch) .await? .ok_or(anyhow::anyhow!( "No reward info found for epoch {}", diff --git a/mobile_verifier/src/lib.rs b/mobile_verifier/src/lib.rs index ce37c18b6..cd326d3a7 100644 --- a/mobile_verifier/src/lib.rs +++ b/mobile_verifier/src/lib.rs @@ -22,11 +22,10 @@ pub mod unique_connections; pub use settings::Settings; use async_trait::async_trait; +use helium_lib::keypair::Pubkey; use rust_decimal::Decimal; use std::error::Error; -pub const MOBILE_SUB_DAO_ONCHAIN_ADDRESS: &str = "39Lw1RH6zt8AJvKn3BTxmUDofzduCM2J3kSaGDZ8L7Sk"; - pub enum GatewayResolution { GatewayNotFound, GatewayNotAsserted, @@ -122,3 +121,7 @@ impl PriceInfo { } } } + +pub fn resolve_subdao_pubkey() -> Pubkey { + helium_lib::dao::SubDao::Mobile.key() +} diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index d423da2e1..e659adb06 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -2,7 +2,7 @@ use crate::{ boosting_oracles::db::check_for_unprocessed_data_sets, coverage, data_session, heartbeats::{self, HeartbeatReward}, - radio_threshold, + radio_threshold, resolve_subdao_pubkey, reward_shares::{ self, CalculatedPocRewardShares, CoverageShares, DataTransferAndPocAllocatedRewardBuckets, MapperShares, TransferRewards, @@ -11,7 +11,7 @@ use crate::{ sp_boosted_rewards_bans, speedtests, speedtests_average::SpeedtestAverages, subscriber_location, subscriber_verified_mapping_event, telemetry, unique_connections, - PriceInfo, Settings, MOBILE_SUB_DAO_ONCHAIN_ADDRESS, + PriceInfo, Settings, }; use anyhow::bail; use chrono::{DateTime, TimeZone, Utc}; @@ -24,6 +24,7 @@ use file_store::{ use futures_util::TryFutureExt; use self::boosted_hex_eligibility::BoostedHexEligibility; +use helium_lib::keypair::Pubkey; use helium_lib::token::Token; use helium_proto::{ reward_manifest::RewardData::MobileRewardData, @@ -58,7 +59,7 @@ mod db; const REWARDS_NOT_CURRENT_DELAY_PERIOD: i64 = 5; pub struct Rewarder { - sub_dao_address: String, + sub_dao: Pubkey, pool: Pool, carrier_client: A, hex_service_client: B, @@ -140,8 +141,12 @@ where price_tracker: PriceTracker, speedtest_averages: FileSinkClient, ) -> anyhow::Result { + // get the subdao address + let sub_dao = resolve_subdao_pubkey(); + tracing::info!("Mobile SubDao pubkey: {}", sub_dao); + Ok(Self { - sub_dao_address: MOBILE_SUB_DAO_ONCHAIN_ADDRESS.into(), + sub_dao, pool, carrier_client, hex_service_client, @@ -246,7 +251,7 @@ where pub async fn reward(&self, next_reward_epoch: u64) -> anyhow::Result<()> { let reward_info = self .sub_dao_epoch_reward_client - .resolve_info(&self.sub_dao_address, next_reward_epoch) + .resolve_info(&self.sub_dao, next_reward_epoch) .await? .ok_or(anyhow::anyhow!( "No reward info found for epoch {}", diff --git a/mobile_verifier/tests/integrations/common/mod.rs b/mobile_verifier/tests/integrations/common/mod.rs index aaeea9e60..32aec3fdf 100644 --- a/mobile_verifier/tests/integrations/common/mod.rs +++ b/mobile_verifier/tests/integrations/common/mod.rs @@ -5,6 +5,7 @@ use file_store::{ }; use futures::{stream, StreamExt}; use helium_crypto::PublicKeyBinary; +use helium_lib::keypair::Pubkey; use helium_lib::token::Token; use helium_proto::services::{ mobile_config::NetworkKeyRole, @@ -79,7 +80,7 @@ impl SubDaoEpochRewardInfoResolver for MockSubDaoRewardsClient { async fn resolve_info( &self, - _sub_dao: &str, + _sub_dao: &Pubkey, _epoch: u64, ) -> Result, Self::Error> { Ok(self.info.clone())