Better context to track down errors during init (#1911)

### Description

- Additional context to error to track down what chain's configuration
is invalid.

### Drive-by changes

None

### Related issues

- Fixes
https://discord.com/channels/935678348330434570/961711527092682783/1082783165803937853

### Backward compatibility

_Are these changes backward compatible?_

Yes

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None


### Testing

_What kind of testing have these changes undergone?_

Manual
pull/1959/head
Mattie Conover 2 years ago committed by GitHub
parent 1c004f4b10
commit 52404d25a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      rust/chains/hyperlane-ethereum/src/trait_builder.rs
  2. 19
      rust/hyperlane-base/src/settings/mod.rs

@ -34,6 +34,9 @@ pub enum EthereumProviderConnectionError {
/// A URL string could not be parsed
#[error("Failed to parse url {1:?}: {0}")]
InvalidUrl(url::ParseError, String),
/// A URL string was `""`
#[error("The url is an empty string; ensure the default configuration has been overridden")]
EmptyUrl,
/// Underlying websocket library threw an error
#[error(transparent)]
WebsocketClientError(#[from] WsClientError),
@ -62,6 +65,7 @@ pub trait BuildableWithProvider {
rpc_metrics: Option<JsonRpcClientMetrics>,
middleware_metrics: Option<(MiddlewareMetrics, PrometheusMiddlewareConf)>,
) -> ChainResult<Self::Output> {
use EthereumProviderConnectionError::{EmptyUrl, InvalidUrl};
Ok(match conn {
ConnectionConf::HttpQuorum { urls } => {
let mut builder = QuorumProvider::builder().quorum(Quorum::Majority);
@ -70,9 +74,12 @@ pub trait BuildableWithProvider {
.build()
.map_err(EthereumProviderConnectionError::from)?;
for url in urls.split(',') {
let parsed_url = url.parse::<Url>().map_err(|e| {
EthereumProviderConnectionError::InvalidUrl(e, url.to_owned())
})?;
if url.is_empty() {
return Err(EmptyUrl.into());
}
let parsed_url = url
.parse::<Url>()
.map_err(|e| InvalidUrl(e, url.to_owned()))?;
let http_provider =
Http::new_with_client(parsed_url.clone(), http_client.clone());
// Wrap the inner providers as RetryingProviders rather than the QuorumProvider.
@ -107,16 +114,13 @@ pub trait BuildableWithProvider {
.map_err(EthereumProviderConnectionError::from)?;
for url in urls.split(',') {
let http_provider = Http::new_with_client(
url.parse::<Url>().map_err(|e| {
EthereumProviderConnectionError::InvalidUrl(e, url.to_owned())
})?,
url.parse::<Url>()
.map_err(|e| InvalidUrl(e, url.to_owned()))?,
http_client.clone(),
);
let metrics_provider = self.wrap_rpc_with_metrics(
http_provider,
Url::parse(url).map_err(|e| {
EthereumProviderConnectionError::InvalidUrl(e, url.to_owned())
})?,
Url::parse(url).map_err(|e| InvalidUrl(e, url.to_owned()))?,
&rpc_metrics,
&middleware_metrics,
);
@ -131,9 +135,7 @@ pub trait BuildableWithProvider {
.timeout(HTTP_CLIENT_TIMEOUT)
.build()
.map_err(EthereumProviderConnectionError::from)?;
let parsed_url = url
.parse::<Url>()
.map_err(|e| EthereumProviderConnectionError::InvalidUrl(e, url.clone()))?;
let parsed_url = url.parse::<Url>().map_err(|e| InvalidUrl(e, url.clone()))?;
let http_provider = Http::new_with_client(parsed_url.clone(), http_client);
let metrics_provider = self.wrap_rpc_with_metrics(
http_provider,

@ -186,8 +186,14 @@ impl Settings {
db: DB,
metrics: &CoreMetrics,
) -> eyre::Result<CachingMailbox> {
let mailbox = self.build_mailbox(chain_name, metrics).await?;
let indexer = self.build_mailbox_indexer(chain_name, metrics).await?;
let mailbox = self
.build_mailbox(chain_name, metrics)
.await
.with_context(|| format!("Building mailbox for {chain_name}"))?;
let indexer = self
.build_mailbox_indexer(chain_name, metrics)
.await
.with_context(|| format!("Building mailbox indexer for {chain_name}"))?;
let hyperlane_db = HyperlaneDB::new(chain_name, db);
Ok(CachingMailbox::new(
mailbox.into(),
@ -224,7 +230,9 @@ impl Settings {
address: H256,
metrics: &CoreMetrics,
) -> eyre::Result<Box<dyn MultisigIsm>> {
let setup = self.chain_setup(chain_name)?;
let setup = self
.chain_setup(chain_name)
.with_context(|| format!("Building multisig ism for {chain_name}"))?;
setup.build_multisig_ism(address, metrics).await
}
@ -235,7 +243,10 @@ impl Settings {
metrics: &CoreMetrics,
) -> eyre::Result<Arc<dyn ValidatorAnnounce>> {
let setup = self.chain_setup(chain_name)?;
let announce = setup.build_validator_announce(metrics).await?;
let announce = setup
.build_validator_announce(metrics)
.await
.with_context(|| format!("Building validator announce for {chain_name}"))?;
Ok(announce.into())
}

Loading…
Cancel
Save