Skip to content

Commit

Permalink
bump proto to pin tonic to 0.10 (#788)
Browse files Browse the repository at this point in the history
* bump proto to pin tonic to 0.10

* proto back to master
  • Loading branch information
madninja authored Apr 12, 2024
1 parent bfa8f91 commit 684a003
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 164 deletions.
204 changes: 97 additions & 107 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sqlx = {version = "0", features = [
"runtime-tokio-rustls"
]}
helium-anchor-gen = {git = "https://github.com/helium/helium-anchor-gen.git"}
helium-crypto = {version = "0.8.1", features=["sqlx-postgres", "multisig"]}
helium-crypto = {version = "0.8.4", features=["sqlx-postgres", "multisig"]}
hextree = {git = "https://github.com/jaykickliter/HexTree", branch = "main", features = ["disktree"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "master", features = ["services"]}
solana-client = "1.16"
Expand All @@ -78,7 +78,7 @@ rust_decimal = "1"
rust_decimal_macros = "1"
base64 = ">=0.21"
sha2 = "0.10"
tonic = {version = "0", features = ["tls", "tls-roots"]}
tonic = {version = "0.10", features = ["tls", "tls-roots"]}
http = "<=0.2"
triggered = "0"
futures = "*"
Expand Down
2 changes: 1 addition & 1 deletion file_store/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl TryFrom<RadioHexSignalLevelProto> for RadioHexSignalLevel {

fn try_from(v: RadioHexSignalLevelProto) -> Result<Self> {
Ok(Self {
signal_level: SignalLevel::from_i32(v.signal_level).ok_or_else(|| {
signal_level: SignalLevel::try_from(v.signal_level).map_err(|_| {
DecodeError::unsupported_signal_level("coverage_object_req_v1", v.signal_level)
})?,
signal_power: v.signal_power,
Expand Down
2 changes: 1 addition & 1 deletion file_store/src/iot_beacon_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl From<IotBeaconIngestReport> for LoraBeaconReportReqV1 {
impl TryFrom<LoraBeaconReportReqV1> for IotBeaconReport {
type Error = Error;
fn try_from(v: LoraBeaconReportReqV1) -> Result<Self> {
let data_rate: DataRate = DataRate::from_i32(v.datarate).ok_or_else(|| {
let data_rate: DataRate = DataRate::try_from(v.datarate).map_err(|_| {
DecodeError::unsupported_datarate("iot_beacon_report_req_v1", v.datarate)
})?;
let timestamp = v.timestamp()?;
Expand Down
18 changes: 8 additions & 10 deletions file_store/src/iot_invalid_poc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ impl TryFrom<LoraInvalidBeaconReportV1> for IotInvalidBeaconReport {
type Error = Error;
fn try_from(v: LoraInvalidBeaconReportV1) -> Result<Self> {
let inv_reason = v.reason;
let invalid_reason: InvalidReason =
InvalidReason::from_i32(inv_reason).ok_or_else(|| {
DecodeError::unsupported_invalid_reason("iot_invalid_beacon_report_v1", inv_reason)
})?;
let invalid_reason: InvalidReason = InvalidReason::try_from(inv_reason).map_err(|_| {
DecodeError::unsupported_invalid_reason("iot_invalid_beacon_report_v1", inv_reason)
})?;
Ok(Self {
received_timestamp: v.timestamp()?,
reason: invalid_reason,
Expand Down Expand Up @@ -107,13 +106,12 @@ impl TryFrom<LoraInvalidWitnessReportV1> for IotInvalidWitnessReport {
type Error = Error;
fn try_from(v: LoraInvalidWitnessReportV1) -> Result<Self> {
let inv_reason = v.reason;
let invalid_reason: InvalidReason =
InvalidReason::from_i32(inv_reason).ok_or_else(|| {
DecodeError::unsupported_invalid_reason("iot_invalid_witness_report_v1", inv_reason)
})?;
let invalid_reason: InvalidReason = InvalidReason::try_from(inv_reason).map_err(|_| {
DecodeError::unsupported_invalid_reason("iot_invalid_witness_report_v1", inv_reason)
})?;
let participant_side = v.participant_side;
let side: InvalidParticipantSide = InvalidParticipantSide::from_i32(participant_side)
.ok_or_else(|| {
let side: InvalidParticipantSide = InvalidParticipantSide::try_from(participant_side)
.map_err(|_| {
DecodeError::unsupported_participant_side(
"iot_invalid_witness_report_v1",
participant_side,
Expand Down
6 changes: 3 additions & 3 deletions file_store/src/iot_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ impl TryFrom<PacketRouterPacketReportV1> for PacketRouterPacketReport {
type Error = Error;

fn try_from(v: PacketRouterPacketReportV1) -> Result<Self> {
let data_rate = DataRate::from_i32(v.datarate).ok_or_else(|| {
let data_rate = DataRate::try_from(v.datarate).map_err(|_| {
DecodeError::unsupported_datarate("iot_packet_router_packet_report_v1", v.datarate)
})?;
let region = Region::from_i32(v.region).ok_or_else(|| {
let region = Region::try_from(v.region).map_err(|_| {
DecodeError::unsupported_region("iot_packet_router_packet_report_v1", v.region)
})?;
let packet_type = PacketType::from_i32(v.r#type).ok_or_else(|| {
let packet_type = PacketType::try_from(v.r#type).map_err(|_| {
DecodeError::unsupported_packet_type("iot_packet_router_packet_report_v1", v.r#type)
})?;
let received_timestamp = v.timestamp()?;
Expand Down
6 changes: 3 additions & 3 deletions file_store/src/iot_valid_poc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ impl TryFrom<LoraVerifiedWitnessReportV1> for IotVerifiedWitnessReport {
type Error = Error;
fn try_from(v: LoraVerifiedWitnessReportV1) -> Result<Self> {
let received_timestamp = v.timestamp()?;
let status = VerificationStatus::from_i32(v.status).ok_or_else(|| {
let status = VerificationStatus::try_from(v.status).map_err(|_| {
DecodeError::unsupported_status_reason("iot_verified_witness_report_v1", v.status)
})?;
let invalid_reason = InvalidReason::from_i32(v.invalid_reason).ok_or_else(|| {
let invalid_reason = InvalidReason::try_from(v.invalid_reason).map_err(|_| {
DecodeError::unsupported_invalid_reason(
"iot_verified_witness_report_v1",
v.invalid_reason,
)
})?;
let participant_side =
InvalidParticipantSide::from_i32(v.participant_side).ok_or_else(|| {
InvalidParticipantSide::try_from(v.participant_side).map_err(|_| {
DecodeError::unsupported_participant_side(
"iot_verified_witness_report_v1",
v.participant_side,
Expand Down
4 changes: 2 additions & 2 deletions file_store/src/iot_witness_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ impl TryFrom<LoraWitnessReportReqV1> for IotWitnessReport {
type Error = Error;
fn try_from(v: LoraWitnessReportReqV1) -> Result<Self> {
let dr = v.datarate;
let data_rate: DataRate = DataRate::from_i32(dr)
.ok_or_else(|| DecodeError::unsupported_datarate("iot_witness_report_req_v1", dr))?;
let data_rate: DataRate = DataRate::try_from(dr)
.map_err(|_| DecodeError::unsupported_datarate("iot_witness_report_req_v1", dr))?;
let timestamp = v.timestamp()?;

Ok(Self {
Expand Down
6 changes: 3 additions & 3 deletions file_store/src/mobile_radio_invalidated_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl MsgDecode for VerifiedInvalidatedRadioThresholdIngestReport {
impl TryFrom<InvalidatedRadioThresholdReportReqV1> for InvalidatedRadioThresholdReportReq {
type Error = Error;
fn try_from(v: InvalidatedRadioThresholdReportReqV1) -> Result<Self> {
let reason = InvalidatedThresholdReason::from_i32(v.reason).ok_or_else(|| {
let reason = InvalidatedThresholdReason::try_from(v.reason).map_err(|_| {
DecodeError::unsupported_invalidated_reason(
"invalidated_radio_threshold_report_req_v1",
v.reason,
Expand Down Expand Up @@ -146,8 +146,8 @@ impl TryFrom<VerifiedInvalidatedRadioThresholdIngestReportV1>
{
type Error = Error;
fn try_from(v: VerifiedInvalidatedRadioThresholdIngestReportV1) -> Result<Self> {
let status = InvalidatedRadioThresholdReportVerificationStatus::from_i32(v.status)
.ok_or_else(|| {
let status = InvalidatedRadioThresholdReportVerificationStatus::try_from(v.status)
.map_err(|_| {
DecodeError::unsupported_status_reason(
"verified_invalidated_radio_threshold_ingest_report_v1",
v.status,
Expand Down
13 changes: 6 additions & 7 deletions file_store/src/mobile_radio_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ impl From<RadioThresholdIngestReport> for RadioThresholdIngestReportV1 {
impl TryFrom<VerifiedRadioThresholdIngestReportV1> for VerifiedRadioThresholdIngestReport {
type Error = Error;
fn try_from(v: VerifiedRadioThresholdIngestReportV1) -> Result<Self> {
let status =
RadioThresholdReportVerificationStatus::from_i32(v.status).ok_or_else(|| {
DecodeError::unsupported_status_reason(
"verified_radio_threshold_ingest_report_v1",
v.status,
)
})?;
let status = RadioThresholdReportVerificationStatus::try_from(v.status).map_err(|_| {
DecodeError::unsupported_status_reason(
"verified_radio_threshold_ingest_report_v1",
v.status,
)
})?;
Ok(Self {
report: v
.report
Expand Down
2 changes: 1 addition & 1 deletion file_store/src/mobile_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl MsgTimestamp<u64> for InvalidDataTransferIngestReport {
impl TryFrom<InvalidDataTransferIngestReportV1> for InvalidDataTransferIngestReport {
type Error = Error;
fn try_from(v: InvalidDataTransferIngestReportV1) -> Result<Self> {
let reason = DataTransferIngestReportStatus::from_i32(v.reason).ok_or_else(|| {
let reason = DataTransferIngestReportStatus::try_from(v.reason).map_err(|_| {
DecodeError::unsupported_status_reason("invalid_data_transfer_session_reason", v.reason)
})?;
Ok(Self {
Expand Down
2 changes: 1 addition & 1 deletion file_store/src/mobile_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl From<SubscriberLocationIngestReport> for SubscriberLocationIngestReportV1 {
impl TryFrom<VerifiedSubscriberLocationIngestReportV1> for VerifiedSubscriberLocationIngestReport {
type Error = Error;
fn try_from(v: VerifiedSubscriberLocationIngestReportV1) -> Result<Self> {
let status = SubscriberReportVerificationStatus::from_i32(v.status).ok_or_else(|| {
let status = SubscriberReportVerificationStatus::try_from(v.status).map_err(|_| {
DecodeError::unsupported_status_reason(
"verified_subscriber_location_ingest_report_v1",
v.status,
Expand Down
4 changes: 2 additions & 2 deletions iot_config/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pub enum KeyType {

impl KeyType {
pub fn from_i32(v: i32) -> anyhow::Result<Self> {
ProtoKeyType::from_i32(v)
ProtoKeyType::try_from(v)
.map(|kt| kt.into())
.ok_or_else(|| anyhow!("unsupported key type {}", v))
.map_err(|_| anyhow!("unsupported key type {}", v))
}
}

Expand Down
2 changes: 1 addition & 1 deletion iot_config/src/admin_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl iot_config::Admin for AdminService {
let signer = verify_public_key(&request.signer)?;
self.verify_admin_request_signature(&signer, &request)?;

let region = Region::from_i32(request.region).ok_or_else(|| {
let region = Region::try_from(request.region).map_err(|_| {
Status::invalid_argument(format!("invalid lora region {}", request.region))
})?;

Expand Down
2 changes: 1 addition & 1 deletion iot_config/src/gateway_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl iot_config::Gateway for GatewayService {
let address: &PublicKeyBinary = &pubkey.into();
tracing::debug!(pubkey = %address, "fetching region params");

let default_region = Region::from_i32(request.region).ok_or_else(|| {
let default_region = Region::try_from(request.region).map_err(|_| {
Status::invalid_argument(format!("invalid lora region {}", request.region))
})?;

Expand Down
6 changes: 3 additions & 3 deletions iot_config/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,9 @@ pub struct UnsupportedFlowTypeError(i32);

impl FlowType {
fn from_i32(v: i32) -> Result<Self, UnsupportedFlowTypeError> {
proto::FlowTypeV1::from_i32(v)
proto::FlowTypeV1::try_from(v)
.map(|ft| ft.into())
.ok_or(UnsupportedFlowTypeError(v))
.map_err(|_| UnsupportedFlowTypeError(v))
}
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ impl From<proto::Protocol> for Protocol {
let mut mapping = BTreeMap::new();
for entry in gwmp.mapping {
let region =
proto::Region::from_i32(entry.region).unwrap_or(proto::Region::Us915);
proto::Region::try_from(entry.region).unwrap_or(proto::Region::Us915);
mapping.insert(region, entry.port);
}
Protocol::Gwmp(Gwmp { mapping })
Expand Down
4 changes: 2 additions & 2 deletions mobile_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pub enum KeyRole {

impl KeyRole {
pub fn from_i32(v: i32) -> anyhow::Result<Self> {
ProtoKeyRole::from_i32(v)
ProtoKeyRole::try_from(v)
.map(|kr| kr.into())
.ok_or_else(|| anyhow::anyhow!("unsupported key role {}", v))
.map_err(|_| anyhow::anyhow!("unsupported key role {}", v))
}
}

Expand Down
2 changes: 1 addition & 1 deletion mobile_verifier/tests/rewarder_sp_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn test_service_provider_rewards(pool: PgPool) -> anyhow::Result<()> {
if let Ok((sp_reward, unallocated_reward)) = rewards {
assert_eq!(
SP_1.to_string(),
ServiceProvider::from_i32(sp_reward.service_provider_id)
ServiceProvider::try_from(sp_reward.service_provider_id)
.unwrap()
.to_string()
);
Expand Down
4 changes: 2 additions & 2 deletions price/src/price_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl TryFrom<PriceReportV1> for Price {
type Error = Error;

fn try_from(value: PriceReportV1) -> Result<Self, Self::Error> {
let tt: BlockchainTokenTypeV1 = BlockchainTokenTypeV1::from_i32(value.token_type)
.ok_or_else(|| anyhow!("unsupported token type: {:?}", value.token_type))?;
let tt: BlockchainTokenTypeV1 = BlockchainTokenTypeV1::try_from(value.token_type)
.map_err(|_| anyhow!("unsupported token type: {:?}", value.token_type))?;
Ok(Self {
timestamp: Utc
.timestamp_opt(value.timestamp as i64, 0)
Expand Down
22 changes: 11 additions & 11 deletions reward_index/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ impl Indexer {
r.discovery_location_amount,
)),
Some(MobileReward::ServiceProviderReward(r)) => {
if let Some(sp) = ServiceProvider::from_i32(r.service_provider_id) {
Ok((
RewardKey {
key: sp.to_string(),
reward_type: RewardType::MobileServiceProvider,
},
r.amount,
))
} else {
bail!("failed to decode service provider")
}
ServiceProvider::try_from(r.service_provider_id)
.map(|sp| {
Ok((
RewardKey {
key: sp.to_string(),
reward_type: RewardType::MobileServiceProvider,
},
r.amount,
))
})
.map_err(|_| anyhow!("failed to decode service provider"))?
}
Some(MobileReward::UnallocatedReward(r)) => Ok((
RewardKey {
Expand Down

0 comments on commit 684a003

Please sign in to comment.