Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deploy to berachain #5375

Merged
merged 21 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-garlics-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Deploy to berachain.
2 changes: 1 addition & 1 deletion .registryrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3170b725e1e46fdf0c65844fa0454cea1243c8c7
78895565b7f4a57e94d1b6a8f069d670f8ed98c7
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::{Debug, Write};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

Expand All @@ -14,6 +15,7 @@ use ethers::prelude::{
use ethers::types::Address;
use ethers_signers::Signer;
use hyperlane_core::rpc_clients::FallbackProvider;
use reqwest::header::{HeaderName, HeaderValue};
use reqwest::{Client, Url};
use thiserror::Error;

Expand Down Expand Up @@ -73,12 +75,8 @@ pub trait BuildableWithProvider {
Ok(match &conn.rpc_connection {
RpcConnectionConf::HttpQuorum { urls } => {
let mut builder = QuorumProvider::builder().quorum(Quorum::Majority);
let http_client = Client::builder()
.timeout(HTTP_CLIENT_TIMEOUT)
.build()
.map_err(EthereumProviderConnectionError::from)?;
for url in urls {
let http_provider = Http::new_with_client(url.clone(), http_client.clone());
let http_provider = build_http_provider(url.clone())?;
// Wrap the inner providers as RetryingProviders rather than the QuorumProvider.
// We've observed issues where the QuorumProvider will first get the latest
// block number and then submit an RPC at that block height,
Expand All @@ -104,12 +102,8 @@ pub trait BuildableWithProvider {
}
RpcConnectionConf::HttpFallback { urls } => {
let mut builder = FallbackProvider::builder();
let http_client = Client::builder()
.timeout(HTTP_CLIENT_TIMEOUT)
.build()
.map_err(EthereumProviderConnectionError::from)?;
for url in urls {
let http_provider = Http::new_with_client(url.clone(), http_client.clone());
let http_provider = build_http_provider(url.clone())?;
let metrics_provider = self.wrap_rpc_with_metrics(
http_provider,
url.clone(),
Expand All @@ -127,11 +121,7 @@ pub trait BuildableWithProvider {
.await?
}
RpcConnectionConf::Http { url } => {
let http_client = Client::builder()
.timeout(HTTP_CLIENT_TIMEOUT)
.build()
.map_err(EthereumProviderConnectionError::from)?;
let http_provider = Http::new_with_client(url.clone(), http_client);
let http_provider = build_http_provider(url.clone())?;
let metrics_provider = self.wrap_rpc_with_metrics(
http_provider,
url.clone(),
Expand Down Expand Up @@ -312,3 +302,42 @@ where
const FREQUENCY: Frequency = Frequency::Duration(Duration::from_secs(12).as_millis() as _);
GasEscalatorMiddleware::new(provider, escalator, FREQUENCY)
}

fn build_http_provider(url: Url) -> ChainResult<Http> {
let mut queries_to_keep = vec![];
let mut headers = reqwest::header::HeaderMap::new();

// A hack to pass custom headers to the provider without
// requiring a bunch of changes to our configuration surface area.
// Any `custom_rpc_header` query parameter is expected to have the value
// format: `header_name:header_value`, will be added to the headers
// of the HTTP client, and removed from the URL params.
let mut updated_url = url.clone();
for (key, value) in url.query_pairs() {
if key != "custom_rpc_header" {
queries_to_keep.push((key.clone(), value.clone()));
continue;
}
if let Some((header_name, header_value)) = value.split_once(':') {
let header_name =
HeaderName::from_str(header_name).map_err(ChainCommunicationError::from_other)?;
let mut header_value =
HeaderValue::from_str(header_value).map_err(ChainCommunicationError::from_other)?;
header_value.set_sensitive(true);
headers.insert(header_name, header_value);
}
}

updated_url
.query_pairs_mut()
.clear()
.extend_pairs(queries_to_keep);

let http_client = Client::builder()
.timeout(HTTP_CLIENT_TIMEOUT)
.default_headers(headers)
.build()
.map_err(EthereumProviderConnectionError::from)?;

Ok(Http::new_with_client(url, http_client))
}
Loading
Loading