hyperlane-xyz / hyperlane-monorepo

The home for Hyperlane core contracts, sdk packages, and other infrastructure
https://hyperlane.xyz
Other
295 stars 312 forks source link

Plaintext gRPC URLs set with the `https` prefix should throw a better error message #3465

Open daniel-savu opened 5 months ago

daniel-savu commented 5 months ago

Problem

It's possible to run an agent for a cosmos chain and specify a gRPC URL with the wrong http protocol (e.g. https for plaintext ones). The agent will successfully run past the config parsing step, then print a bunch of "invalid message" / "corrupt message" errors and crash, which doesn't make it obvious what the issue is

Logs:

{"timestamp":"2024-03-21T11:42:27.600507Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:27.600632Z","level":"WARN","fields":{"message":"Metric update failed for wallet validator (neutron19hg3dr425wlm06vc08ve4pux2smlv6g363tc7u) on chain neutron balance for native currency; All fallback providers failed. (Errors: [Other(Status { code: Unavailable, message: \"error trying to connect: received corrupt message of type InvalidContentType\", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: \"error trying to connect: received corrupt message of type InvalidContentType\", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: \"error trying to connect: received corrupt message of type InvalidContentType\", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: \"error trying to connect: received corrupt message of type InvalidContentType\", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) })])"},"target":"hyperlane_base::metrics::agent_metrics"}
{"timestamp":"2024-03-21T11:42:27.875750Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:27.875795Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:27.875870Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:27.875897Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.261707Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.261743Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.261898Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.261928Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.645072Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.645115Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.645755Z","level":"DEBUG","fields":{"message":"reconnect::poll_ready: hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) })"},"target":"tonic::transport::service::reconnect"}
{"timestamp":"2024-03-21T11:42:28.645783Z","level":"DEBUG","fields":{"message":"error: error trying to connect: received corrupt message of type InvalidContentType"},"target":"tonic::transport::service::reconnect"}
thread 'main' panicked at 'Failed to announce validator: All fallback providers failed. (Errors: [Other(Status { code: Unavailable, message: "error trying to connect: received corrupt message of type InvalidContentType", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: "error trying to connect: received corrupt message of type InvalidContentType", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: "error trying to connect: received corrupt message of type InvalidContentType", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) }), Other(Status { code: Unavailable, message: "error trying to connect: received corrupt message of type InvalidContentType", source: Some(tonic::transport::Error(Transport, hyper::Error(Connect, Custom { kind: InvalidData, error: InvalidMessage(InvalidContentType) }))) })])

Location:
    agents/validator/src/validator.rs:315:38', agents/validator/src/validator.rs:173:31

Solution

Somehow return a better error message to have the user check the url prefix

tkporter commented 5 months ago

Is it because the default one in mainnet3_config.json was used? https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/config/mainnet3_config.json#L485

daniel-savu commented 5 months ago

Turns out it was because we were still using https instead of http and the default that @tkporter pointed out is a plaintext URL. Wondering if there's a way to make it more clear in the error message