Skip to content

Commit

Permalink
Merge pull request #618 from helium/jg/fix-invalid-witness-md
Browse files Browse the repository at this point in the history
fix witness metadata on invalid reports
  • Loading branch information
jeffgrunewald authored Aug 27, 2023
2 parents baa056b + 3365724 commit 1a4907e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = [
"solana",
"task_manager",
]
resolver = "2"

[workspace.package]
authors = ["Nova Labs <[email protected]>"]
Expand Down Expand Up @@ -58,7 +59,6 @@ sqlx = {version = "0", features = [
"macros",
"runtime-tokio-rustls"
]}

helium-crypto = {version = "0.6.8", features=["sqlx-postgres", "multisig"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "master", features = ["services"]}
hextree = "*"
Expand Down
11 changes: 4 additions & 7 deletions ingest/src/server_mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,10 @@ pub async fn grpc_server(shutdown: triggered::Listener, settings: &Settings) ->
let Some(api_token) = settings
.token
.as_ref()
.and_then(|token| {
format!("Bearer {token}")
.parse::<MetadataValue<_>>()
.ok()
}) else {
bail!("expected valid api token in settings");
};
.and_then(|token| format!("Bearer {token}").parse::<MetadataValue<_>>().ok())
else {
bail!("expected valid api token in settings");
};

tracing::info!(
"grpc listening on {grpc_addr} and server mode {:?}",
Expand Down
2 changes: 1 addition & 1 deletion iot_config/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl gateway_info::GatewayInfoResolver for Client {
.filter_map(|resp| async move { resp.ok() })
.map(move |resp| (resp, pubkey.clone()))
.filter_map(|(resp, pubkey)| async move { resp.verify(&pubkey).map(|_| resp).ok() })
.flat_map(|resp| stream::iter(resp.gateways.into_iter()))
.flat_map(|resp| stream::iter(resp.gateways))
.map(gateway_info::GatewayInfo::from)
.boxed();

Expand Down
8 changes: 6 additions & 2 deletions iot_packet_verifier/src/burner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ where
pub async fn burn(&mut self) -> Result<(), BurnError<P::Error, S::Error>> {
// Create burn transaction and execute it:

let Some(Burn { payer, amount }) = self.pending_burns.fetch_next().await
.map_err(BurnError::SqlError)? else {
let Some(Burn { payer, amount }) = self
.pending_burns
.fetch_next()
.await
.map_err(BurnError::SqlError)?
else {
return Ok(());
};

Expand Down
8 changes: 4 additions & 4 deletions iot_verifier/src/poc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl Poc {
0,
0,
InvalidParticipantSide::Beaconer,
))
));
};
// run the witness verifications
match do_witness_verifications(
Expand Down Expand Up @@ -320,9 +320,9 @@ impl Poc {
invalid_response.details,
&witness_report.report,
witness_report.received_timestamp,
Some(beaconer_metadata.location),
beaconer_metadata.gain,
beaconer_metadata.elevation,
Some(witness_metadata.location),
witness_metadata.gain,
witness_metadata.elevation,
InvalidParticipantSide::Witness,
)),
}
Expand Down
2 changes: 1 addition & 1 deletion mobile_config/src/client/gateway_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl gateway_info::GatewayInfoResolver for GatewayClient {
Err(_) => None,
}
})
.flat_map(|res| stream::iter(res.gateways.into_iter()))
.flat_map(|res| stream::iter(res.gateways))
.map(gateway_info::GatewayInfo::from)
.boxed();

Expand Down
2 changes: 1 addition & 1 deletion solana/src/balance_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl BalanceMonitor {
Some(rpc_client) => {
let Ok(keypair) = Keypair::from_bytes(&rpc_client.keypair) else {
tracing::error!("sol monitor: keypair failed to deserialize");
return Err(Box::new(SolanaRpcError::InvalidKeypair))
return Err(Box::new(SolanaRpcError::InvalidKeypair));
};
let app_metric_name = format!("{app_account}-sol-balance");

Expand Down
3 changes: 2 additions & 1 deletion task_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn start_futures(
) -> Vec<StopableLocalFuture> {
shutdown_triggers
.into_iter()
.zip(tasks.into_iter())
.zip(tasks)
.map(
|((shutdown_trigger, shutdown_listener), task)| StopableLocalFuture {
shutdown_trigger,
Expand All @@ -134,6 +134,7 @@ fn start_futures(
.collect()
}

#[allow(clippy::manual_try_fold)]
async fn stop_all(futures: Vec<StopableLocalFuture>) -> anyhow::Result<()> {
futures::stream::iter(futures.into_iter().rev())
.fold(Ok(()), |last_result, local| async move {
Expand Down

0 comments on commit 1a4907e

Please sign in to comment.