Skip to content

Commit

Permalink
don't break route create on unsendable update
Browse files Browse the repository at this point in the history
more helpful logs and status messages
  • Loading branch information
michaeldjeffrey authored and jeffgrunewald committed May 1, 2023
1 parent 7139005 commit 2e80ace
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 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 @@ -55,14 +55,14 @@ sqlx = {version = "0", features = [
]}

helium-crypto = {version = "0.6.8", features=["sqlx-postgres", "multisig"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "macpie/skf", features = ["services"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "master", features = ["services"]}
hextree = "*"
solana-client = "1.14"
solana-sdk = "1.14"
solana-program = "1.11"
spl-token = "3.5.0"
reqwest = {version = "0", default-features=false, features = ["gzip", "json", "rustls-tls"]}
beacon = {git = "https://github.com/helium/gateway-rs.git", branch = "jg/temp-skf-proto-update"}
beacon = {git = "https://github.com/helium/gateway-rs.git", branch = "main"}
humantime = "2"
metrics = "0"
metrics-exporter-prometheus = "0"
Expand Down
6 changes: 6 additions & 0 deletions iot_config/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ impl Daemon {
region_updater,
)?;

let pubkey = settings
.signing_keypair()
.map(|keypair| keypair.public_key().to_string())?;
tracing::debug!("listening on {listen_addr}");
tracing::debug!("signing as {pubkey}");

let server = transport::Server::builder()
.http2_keepalive_interval(Some(Duration::from_secs(250)))
.http2_keepalive_timeout(Some(Duration::from_secs(60)))
Expand Down
16 changes: 8 additions & 8 deletions iot_config/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ pub async fn create_route(
signer,
signature: vec![],
};
signing_key
_ = signing_key
.sign(&update.encode_to_vec())
.map_err(|err| anyhow!(format!("error signing route stream response: {err:?}")))
.map_err(|err| tracing::error!("error signing route stream response: {err:?}"))
.and_then(|signature| {
update.signature = signature;
update_tx.send(update).map_err(|err| {
anyhow!(format!("error broadcasting route stream response: {err:?}"))
tracing::warn!("error broadcasting route stream response: {err:?}")
})
})?;
});
};

Ok(new_route)
Expand Down Expand Up @@ -206,12 +206,12 @@ pub async fn update_route(

_ = signing_key
.sign(&update_res.encode_to_vec())
.map_err(|err| anyhow!(format!("error signing route stream response: {err:?}")))
.map_err(|err| tracing::error!("error signing route stream response: {err:?}"))
.and_then(|signature| {
update_res.signature = signature;
update_tx.send(update_res).map_err(|err| {
anyhow!(format!("error broadcasting route stream response: {err:?}"))
})
update_tx
.send(update_res)
.map_err(|err| tracing::warn!("error broadcasting route stream response: {err:?}"))
});

Ok(updated_route)
Expand Down
13 changes: 9 additions & 4 deletions iot_config/src/route_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,15 @@ impl RouteService {
.await;

for update in updates {
if !ranges.iter().any(|range| range.contains_addr(update.devaddr.into())) {
let devaddr = update.devaddr.into();
if !ranges.iter().any(|range| range.contains_addr(devaddr)) {
let ranges = ranges
.iter()
.map(|r| format!("{} -- {}", r.start_addr, r.end_addr))
.collect::<Vec<_>>()
.join(", ");
return Err(Status::invalid_argument(format!(
"devaddr {} not within registered ranges for route {}",
update.devaddr, route_id
"devaddr {devaddr} not within registered ranges for route {route_id} :: {ranges}"
)));
}
}
Expand Down Expand Up @@ -890,7 +895,7 @@ struct DevAddrEuiValidator {

#[derive(thiserror::Error, Debug)]
enum DevAddrEuiValidationError {
#[error("devaddr or range outside of bounds {0}")]
#[error("devaddr range outside of constraint bounds {0}")]
DevAddrOutOfBounds(String),
#[error("no route for update {0}")]
NoRouteId(String),
Expand Down

0 comments on commit 2e80ace

Please sign in to comment.